This file contains hidden or 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 netfilterqueue import NetfilterQueue | |
| import subprocess | |
| import signal | |
| import dpkt | |
| import traceback | |
| import socket | |
| import sys | |
| TARGET_IP = '173.252.110.27' |
This file contains hidden or 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 dpkt | |
| import socket | |
| import binascii | |
| hex_ip_packets = [ | |
| 'binascii.hexlify output of SYN' # replace with your own captured output | |
| 'binascii.hexlify output of HTTP GET' # replace with your own captured output | |
| ] | |
| raw_socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW) |
This file contains hidden or 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
| if [ -f /tmp/skip-only-enable-connectable-sta-mode-wifi-interface ] ; then | |
| logger -s -t fqrouter skip-only-enable-connectable-sta-mode-wifi-interface found | |
| return | |
| fi | |
| if [ "remove" == "$ACTION" -a "wlan0" == "$INTERFACE" ] ; then | |
| /etc/init.d/disable_sta_mode_wifi_interfaces start | |
| fi | |
| if [ "add" == "$ACTION" -a "wlan0" == "$INTERFACE" ] ; then | |
| logger -s -t fqrouter try to bring up sta mode wifi interface |
This file contains hidden or 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) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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() |