This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function consolidate() { | |
var sheets = SpreadsheetApp.getActiveSpreadsheet().getSheets(); | |
var routers = {}; | |
var routerIps = []; | |
for (var i = 0; i < sheets.length; i++) { | |
var sheet = sheets[i]; | |
if (0 == sheet.getName().indexOf('__')) { | |
continue; | |
} | |
var values = sheet.getDataRange().getValues(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
send(IP(dst=8.8.8.8) / TCP(dport=53, flags='S', seq=0)) | |
offending_payload = str(DNS(rd=1, qd=DNSQR(qname="dl.dropbox.com"))) | |
offending_payload = struct.pack("!H", len(offending_payload)) + offending_payload | |
send(IP(dst=8.8.8.8) / TCP(dport=53, flags='A', seq=1, ack=100) / Raw(offending_payload)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class L2Sniffer(threading.Thread): | |
def __init__(self, iface, src, dst, no_filter=False): | |
super(L2Sniffer, self).__init__() | |
self.daemon = True | |
self.no_filter = no_filter | |
self.iface = iface | |
self.src = src | |
self.dst = dst | |
self.started = threading.Event() | |
self.started.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERROR_NO_DATA = 11 | |
class L3Sniffer(threading.Thread): | |
def __init__(self, src, dst): | |
super(L3Sniffer, self).__init__() | |
self.daemon = True | |
self.src = src | |
self.dst = dst | |
self.started = threading.Event() | |
self.started.clear() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TcpdumpSniffer(object): | |
def __init__(self, iface, src, dst): | |
self.iface = iface | |
self.src = src | |
self.dst = dst | |
self.packets = [] | |
def start_sniffing(self): | |
self.pcap_file_path = tempfile.mktemp() | |
filter = '(dst host %s and src host %s) or icmp' % (self.src, self.dst) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@contextlib.contextmanager | |
def capture(ifname, src, dst): | |
events = [] | |
filter = '(host %s and host %s) or icmp[0] = 11' % (src, dst) | |
p = subprocess.Popen( | |
['tcpdump', '-i', ifname, '-w', '-', filter], | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) | |
try: | |
yield events | |
finally: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import re | |
import struct | |
import random | |
import sys | |
# Generate random ip from ip range of specific network carrier | |
# It is useful because for same carrier, GFW tend to install device in a very narrow ip range | |
# There are at least 6 major network carriers in China which have GFW attached to its boarder gateway |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import dpkt | |
import sys | |
dst = sys.argv[1] | |
sport1 = 8080 | |
sport2 = 8081 | |
icmp_socket = sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) | |
icmp_socket.settimeout(2) | |
trace = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import dpkt.ip | |
import dpkt.dns | |
import sys | |
import os | |
dst = sys.argv[1] | |
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) | |
udp_socket.settimeout(2) | |
icmp_socket = sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scapy.all import * | |
import time | |
dst = sys.argv[1] | |
src = '' | |
for ttl in range(1, 15): | |
send(IP(dst=dst,src=src,id=ttl,ttl=ttl)/UDP()/DNS(rd=1,qd=DNSQR(qname="www.twitter.com"))) | |
send(IP(dst=dst,src=src,id=ttl,ttl=ttl)/TCP(dport=80,sport=8081)) # 非必要参照物 | |
time.sleep(2) |