<?php
#!/usr/bin/python
import socket,sys
def main(dest):
ttl = 1
max = 30
dest = socket.gethostbyname(dest)
icmp = socket.getprotobyname('icmp')
port = 12345
while True:
incoming = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)
outgoing = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
outgoing.setsockopt(socket.SOL_IP, socket.IP_TTL, ttl)
incoming.bind(("", port))
outgoing.sendto("", (dest, port))
NULL, address = incoming.recvfrom(1024)
address = address[0]
fuckery = socket.gethostbyaddr(address)[0]
if address is not None:
current = '{0} {1}'.format(fuckery,address)
else:
current = '*'
print '{0} {1}'.format(ttl,current)
ttl += 1
if address == dest or ttl > max:
break
if __name__ == '__main__':
main(sys.argv[1])