I've been doing some work on port scanning. I'm trying to do a SYN scan (send SYN and and cut the cord if I get an SYN-ACK), and the operation worked perfect on single thread.
When trying to run it using eventlet (on a Celery threaded worker), I get the following exception when running it:
Child died unexpectedly. Packets may have not been sent
The following is my code that raises the issue:
def pscan(dest_ip, dest_port):
packet = IP(dst=dest_ip) / TCP(dport=int(dest_port), flags='S')
res = sr1(packet, verbose=False, timeout=1)
if res and res.haslayer(TCP):
if res[TCP].flags == 18: # SYN-ACK flag
return True
return False
Any thoughts?