Browse Source

v1.2 FIX: re.match/re.search

boson 2 years ago
parent
commit
773ee3ff7f
2 changed files with 14 additions and 5 deletions
  1. 9 0
      README.md
  2. 5 5
      sisniff

+ 9 - 0
README.md

@@ -65,6 +65,15 @@ optional arguments:
 * <code>filter</code> is in same syntax as tcpdump uses. Must be written in double-quotes "..."
 
 
+##### Example Commands
+<pre>
+# sisniff -i wlan0 "port not ssh"
+# sisniff -i wlan0 -p *vpn*
+# sisniff -i wlan0 -p not-thunderbird-bin -4 "host not www.zweiernet.ch"
+# sisniff -i eth0 -p firefox -pHl		
+</pre>
+
+
 ##### Example Output
 
 ![ ](https://git.zweiernet.ch/sigi/sisniff/raw/master/Terminal_059.png)

+ 5 - 5
sisniff

@@ -35,7 +35,7 @@ def _to_str(inp):
         return "".join( chr(x) for x in inp)
     
 
-VERSION = "1.1"
+VERSION = "1.2"
 
 PROC_TCP4 = "/proc/net/tcp"
 PROC_UDP4 = "/proc/net/udp"
@@ -330,18 +330,18 @@ def doPackets(packet):
     else:
         if filter_prog.startswith('not-'):
             filter_progn = filter_prog[4:]
-            if filter_progn.startswith('*') and filter_progn.endswith('*') and re.match(filter_progn[1:-1], program):
+            if filter_progn.startswith('*') and filter_progn.endswith('*') and re.search(filter_progn[1:-1], program):
                 return
-            elif filter_progn.startswith('*') and not filter_progn.endswith('*') and re.match(filter_progn[1:]+'$', program):
+            elif filter_progn.startswith('*') and not filter_progn.endswith('*') and re.search(filter_progn[1:]+'$', program):
         	    return
             elif not filter_progn.startswith('*') and filter_progn.endswith('*') and re.match('^'+filter_progn[:-1], program):
         	    return
             elif not filter_progn.startswith('*') and not filter_progn.endswith('*') and re.match('^'+filter_progn+'$', program):
                 return
         else:
-            if filter_prog.startswith('*') and filter_prog.endswith('*') and not re.match(filter_prog[1:-1], program):
+            if filter_prog.startswith('*') and filter_prog.endswith('*') and not re.search(filter_prog[1:-1], program):
                 return
-            elif filter_prog.startswith('*') and not filter_prog.endswith('*') and not re.match(filter_prog[1:]+'$', program):
+            elif filter_prog.startswith('*') and not filter_prog.endswith('*') and not re.search(filter_prog[1:]+'$', program):
         	    return
             elif not filter_prog.startswith('*') and filter_prog.endswith('*') and not re.match('^'+filter_prog[:-1], program):
         	    return