十块钱RMB | 用Digispark制作一个简单的Badusb

2019-04-23 13,332

Digispark是一个这样的很小的开发板

淘宝上10元左右一个

准备

  • Digispark ATtiny 85

  • Arduino IDE 1.8.4 (parrot 中的ide是2.x版本的没有Board Manager)

    https://www.arduino.cc/en/Main/Software

  • Digispark驱动程序 (Windows)

    https://github.com/digistump/DigistumpArduino/releases

配置Arduino 

文件->首选项

把这个网址添加到附加开发板管理网址

https://raw.githubusercontent.com/digistump/arduino-boards-index/master/package_digistump_index.json

点击确定(好)

然后打开开发板管理器

这时会自动更新一些东西,建议挂上代理,不然很慢

在Arduino中添加Digispark的支持

等待开发板管理器加载完成,搜索digistump并安装第一个Digistump AVR Boards

等待安装完成,完成后会有绿色表示

安装Windows下的驱动

打开上面的链接,下载Digistump.Drivers

解压后执行Install Drivers.exe即可

代码

拿一个最简单的键盘功能来演示

badusb现成代码最多的就是给大黄鸭准备的代码

在这里可以看到一些示例代码

比如第一个Hello World的样例代码,把hello world改成Happy Hacking

DELAY 3000
GUI r
DELAY 500
STRING notepad
DELAY 500
ENTER
DELAY 750
STRING Happy Hacking !!!
ENTER

然后用这里的在线工具

把大黄鸭代码转换成Digispark的代码(注意Board要选Digispark)

/*
 * Generated with <3 by Dckuino.js, an open source project !
 */
#include <avr/pgmspace.h>
#include "DigiKeyboard.h"
const char line1[] PROGMEM = "notepad";
const char line2[] PROGMEM = "Happy Hacking!!!";
char buffer[256];
#define GetPsz(x) (strncpy_P(buffer, (char*)x, 256))
#define KEY_UP_ARROW 0x52
#define KEY_DOWN_ARROW 0x51
#define KEY_LEFT_ARROW 0x50
#define KEY_RIGHT_ARROW 0x4F
#define KEY_LEFT_GUI 0xE3
#define KEY_ESC 0x29
#define KEY_TAB 0x2B
void digiBegin() {
 DigiKeyboard.sendKeyStroke(0,0);
 DigiKeyboard.delay(50);
}
void digiEnd() {
 const int led=1;
 pinMode(led, OUTPUT);
 while (1) {
 digitalWrite(led, !digitalRead(led));
 DigiKeyboard.delay(1000);
 }
}
void printText(char *txt) {
 DigiKeyboard.print(txt);
 DigiKeyboard.update();
}
void setup() {
 digiBegin();
 DigiKeyboard.delay(3000);
 DigiKeyboard.sendKeyStroke(KEY_R,MOD_GUI_LEFT);
 DigiKeyboard.delay(500);
 // notepad
 printText(GetPsz(line1));
 DigiKeyboard.delay(500);
 DigiKeyboard.sendKeyStroke(KEY_ENTER);
 DigiKeyboard.delay(750);
 // Happy Hacking!!!
 printText(GetPsz(line2));
 DigiKeyboard.sendKeyStroke(KEY_ENTER);
 digiEnd();
}
/* Unused endless loop */
void loop() {}

上传

Ardunio IDE中选择工具->开发板->Digispark (Default - 16.5mhz)

然后点击项目->上传等待编译完成

然后插入Digispark 开始上传

一旦上传完成,你会看到电脑自动的打开了运行然后打开了notepad,自动写了一句话

图文看不懂没关系

视频版:https://www.bilibili.com/video/av20732981

需要的代码:https://github.com/hak5darren/USB-Rubber-Ducky/wiki/Payloads 生成代码的工具:https://github.com/CYRO4S/Automator Arduino配置:https://www.bilibili.com/video/av18699066/ 驱动https://github.com/digistump/DigistumpArduino/releases

拓展

https://www.bilibili.com/video/av20174979

原文公众号:HACK学习呀

本文作者:HACK_Learn

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/104597.html

Tags:
评论  (0)
快来写下你的想法吧!

HACK_Learn

文章数:142 积分: 323

微信公众号:HACK学习呀

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号