#! /usr/bin/env python
from scapy.all import *

'''
UDP traceroute
send(IP(dst="8.8.8.8", ttl=(1,32))/UDP(sport=RandShort(), dport=30001)/"")

DNS traceroute
ans,unans=traceroute("4.2.2.1",l4=UDP(sport=RandShort())/DNS(qd=DNSQR(qname="thesprawl.org")))

A TCP traceroute
ans,unans=sr(IP(dst=target, ttl=(4,25),id=RandShort())/TCP(flags=0x2))

TCP SYN traceroute
ans,unans=sr(IP(dst="4.2.2.1",ttl=(1,10))/TCP(dport=53,flags="S"))

https://zh.wikipedia.org/wiki/Traceroute
http://scapy.readthedocs.io/en/latest/usage.html#advanced-traceroute
https://github.com/secdev/scapy/blob/master/scapy/layers/inet.py#L1458

'''


with open('cn.expand', 'r') as f:
	data = f.read().split("\n")


result = set()
for i in range(0, len(data), 1000):
	send(IP(dst=data[i:i+1000], ttl=(1,32))/UDP(sport=RandShort(), dport=30001)/"")
