Browse Source

v1.5 new Param -P : disable promiscuous-mode

Peter Siegrist 6 months ago
parent
commit
68fa61285f
2 changed files with 13 additions and 7 deletions
  1. 4 3
      README.md
  2. 9 4
      sisniff

+ 4 - 3
README.md

@@ -40,10 +40,10 @@ Direct Download: `wget https://git.zweiernet.ch/sigi/sisniff/raw/master/sisniff`
 <pre>
 --------------------
 # sisniff -h
-usage: sisniff [-h] -i {eth0,lo,wlan0} [-n] [-p program|not-program] [-4] [-6] [-H] [-Hl] [filter]
+usage: sisniff [-h] -i {eth0,lo,wlan0} [-n] [-P] [-p program|not-program] [-4] [-6] [-H] [-Hl] [filter]
 
-sisniff V1.4
-2017-2022 by sigi <https://wiki.zweiernet.ch/wiki/sisniff>
+sisniff V1.5
+2017-2023 by sigi <https://wiki.zweiernet.ch/wiki/sisniff>
 
 positional arguments:
   filter                Filter (BPF syntax) on top of IP (in dbl-quotes "...")
@@ -52,6 +52,7 @@ optional arguments:
   -h, --help            show this help message and exit
   -i {eth0,lo,wlan0}    Interface
   -n                    Do not resolve IP-Addresses
+  -P                    Don't put interface into promiscuous mode
   -p program|not-program
                         Filter by program name (accepts * for matching) ([not-] negates)
   -4                    Only IPv4

+ 9 - 4
sisniff

@@ -35,7 +35,7 @@ def _to_str(inp):
         return "".join( chr(x) for x in inp)
     
 
-VERSION = "1.4"
+VERSION = "1.5"
 
 PROC_TCP4 = "/proc/net/tcp"
 PROC_UDP4 = "/proc/net/udp"
@@ -461,10 +461,11 @@ iface = conf.route.route("0.0.0.0")[0]
 rfilter = "ip or ip6"
 print("")
 # commandline params
-parser = argparse.ArgumentParser(description='sisniff V'+VERSION+"\n2017-2022 by sigi <https://wiki.zweiernet.ch/wiki/sisniff>",
+parser = argparse.ArgumentParser(description='sisniff V'+VERSION+"\n2017-2023 by sigi <https://wiki.zweiernet.ch/wiki/sisniff>",
                                    formatter_class=argparse.RawDescriptionHelpFormatter)
 parser.add_argument('-i', help="Interface", choices=iface_list)
 parser.add_argument('-n', help="Do not resolve IP-Addresses", action="store_true")
+parser.add_argument('-P', help="Don't put interface into promiscuous mode", action="store_true")
 parser.add_argument('-p', help='Filter by program name (accepts * for matching) ([not-] negates)', type=str, metavar='program|not-program')
 parser.add_argument('-4', dest='v4', help="Only IPv4", action="store_true")
 parser.add_argument('-6', dest='v6', help="Only IPv6", action="store_true")
@@ -490,7 +491,11 @@ if args.filter:
     print("\033[1m> Applying Filter: \"" + rfilter + fillter + "\"\033[0m") 
 if args.p:
     filter_prog = args.p
-    
+no_promisc = ""
+if args.P:
+	conf.sniff_promisc = conf.promisc = 0
+	no_promisc = " (disabled promiscuous mode)"
+
 
 # local addresses
 if args.v6:
@@ -510,7 +515,7 @@ else:
 	MYADDRS = MYADDRS + MYADDRS6
 xMYADDRS = xMYADDRS + [_to_v6_proc(expand_v6(x)) for x in MYADDRS6]
 print("> My IP-Addresses: " + str(MYADDRS))
-print("> Listening on: " + iface)
+print("> Listening on: " + iface + no_promisc)
 
 # confirmed connections cache (ringboffer)
 conn_cache = []