## Installatiecommando's voor VirtualBox ### Ubuntu: ```bash wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" sudo apt update sudo apt install virtualbox-7.1 ``` ### Fedora: ```bash sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm sudo dnf install VirtualBox kernel-devel-$(uname -r) sudo akmods sudo systemctl restart vboxdrv ``` ## Systeemupdate na installatie Ubuntu Server ```bash sudo apt update && sudo apt upgrade -y sudo apt install vim ``` ## Netwerkconfiguratie (netplan) ```yaml network: version: 2 ethernets: enp0s3: addresses: [192.168.xx.xx/24] gateway4: 192.168.xx.xx nameservers: addresses: [8.8.8.8, 8.8.4.4] enp0s8: addresses: [192.168.56.xxx/24] ``` ## Installatie benodigde afhankelijkheden ```bash sudo apt-get install git python3-venv libssl-dev libffi-dev build-essential libpython3-dev python3-minimal authbind vim iptables jq ``` ## Gebruiker aanmaken voor Cowrie ```bash sudo adduser --disabled-password cowrie ``` ## Firewall & Portforwarding script (/etc/init.d/cowrie-fw) ```bash #!/bin/bash # Reset alleen de NAT tabel iptables -t nat -F iptables -t nat -X # Port forwarding voor SSH (22) en Telnet (23) naar Cowrie iptables -t nat -A PREROUTING -p tcp --dport 22 -j REDIRECT --to-port 2222 iptables -t nat -A PREROUTING -p tcp --dport 23 -j REDIRECT --to-port 2223 ``` ## Uitvoerbaar maken en toevoegen aan systeemstart ```bash chmod +x /etc/init.d/cowrie-fw update-rc.d cowrie-fw defaults ``` ## Python Virtual Environment setup ```bash sudo su - cowrie git clone http://github.com/cowrie/cowrie cd cowrie python -m venv cowrie-env source cowrie-env/bin/activate python -m pip install --upgrade pip python -m pip install --upgrade -r requirements.txt ``` ## Cowrie configureren ```bash cd etc cp cowrie.cfg.dist cowrie.cfg vi cowrie.cfg ``` In cowrie.cfg, zoek en wijzig: ``` # Enable Telnet support, disabled by default enabled = true ``` ## Configuratie van gebruikers ```bash cd ../honeyfs/etc vi passwd ``` ## Cowrie starten ```bash cd ../.. bin/cowrie start ``` ## Logbestanden bekijken ```bash tail -f /var/log/cowrie/cowrie.log ``` ## Statistieken script ```bash #!/bin/bash # Statistieken genereren met timestamp echo "Statistieken $(date)" >> stats.txt # Aantal unieke aanvallende IP adressen echo "Unieke IP's:" >> stats.txt grep "New connection:" cowrie.log | awk '{split($6,ip,":"); print ip[1]}' | sort -u | wc -l >> stats.txt # Meest gebruikte wachtwoorden top 5 echo "Top 5 wachtwoorden:" >> stats.txt grep "login attempt" cowrie.log | awk -F"[']" '{print $4}' | sort | uniq -c | sort -nr | head -n 5 >> stats.txt # Inlogpogingen per uur voor analyse van piekbelasting echo "Inlogpogingen per uur:" >> stats.txt grep "login attempt" cowrie.log | awk '{split($1,dt,"T"); split(dt[2],time,":"); print time[1]}' | sort | uniq -c | sort -n >> stats.txt # Overzicht van commando's die aanvallers probeerden uit te voeren echo "Uitgevoerde commando's:" >> stats.txt grep "CMD:" cowrie.log | awk -F"CMD: " '{print $2}' | sort | uniq -c | sort -nr >> stats.txt ``` Dit zijn alle code-snippets en commando's uit het PDF-document. De code is direct bruikbaar voor het opzetten van een Cowrie honeypot op een Ubuntu Server in VirtualBox.