-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterceptor1.py
73 lines (37 loc) · 1.47 KB
/
interceptor1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import argparse
import os
import sys
import signal
import logging
from scapy.all import *
from colorama import init, Fore
import netfilterqueue
import re
logging.basicConfig(level=logging.INFO,
format="%(asctime)s %(levelname)s: %(message)s",
datefmt="%Y-%m-%d %H:%M:%S")
init()
GREEN = Fore.GREEN
RESET = Fore.RESET
def handle_interrupt(signum, frame):
logging.info("User interrupt signal received. Exiting...")
sys.exit(0)
def main():
parser = argparse.ArgumentParser(description="Interceptor - A network packet interceptor")
parser.add_argument("-i", "--iface", help="The network interface to listen on")
parser.add_argument("-a", "--address", help="The IP address of the target host to intercept traffic to/from")
parser.add_argument("-p", "--port", help="The port number of the target service to intercept traffic to/from")
args = parser.parse_args()
if not args.address:
logging.error("You must specify the target IP address to intercept traffic to/from")
sys.exit(1)
if not args.port:
logging.error("You must specify the target port number to intercept traffic to/from")
sys.exit(1)
# Set up the signal handler for user interrupts (Ctrl-C)
signal.signal(signal.SIGINT, handle_interrupt)
# Start the interception
interceptor = Interceptor(args.address, args.port, args.iface)
interceptor.start()
if __name__ == "__main__":
main()