while true--snip-#print "icmp -type% code% (icmp_header typeicmp_header codenow check for the type and code if icmp_header code = and icmp_header type = make sure host is in our target subnet if ipaddress(ip_header src_addressin ipnetwork(subnet)make sure it has our magic message if raw_buffer[len(raw_buffer)-len(magic_message):=magic_messageprint "host up%sip_header src_address this last bit of code should be fairly straightforward to understand we define simple string signature so that we can test that the responses are coming from udp packets that we sent originally our udp_sender function simply takes in subnet that we specify at the top of our scriptiterates through all ip addresses in that subnetand fires udp datagrams at them in the main body of our scriptjust before the main packet decoding loopwe spawn udp_sender in separate thread to ensure that we aren' interfering with our ability to sniff responses if we detect the anticipated icmp messagewe first check to make sure that the icmp response is coming from within our target subnet we then perform our final check of making sure that the icmp response has our magic string in it if all of these checks passwe print out the source ip address of where the icmp message originated let' try it out