|
@@ -23,10 +23,10 @@ import string
|
|
|
import fcntl
|
|
|
import struct
|
|
|
import argparse
|
|
|
-if sys.version_info.major == 2:
|
|
|
- import commands as subprocess
|
|
|
-elif sys.version_info.major == 3:
|
|
|
- import subprocess
|
|
|
+#if sys.version_info.major == 2:
|
|
|
+# import commands as subprocess
|
|
|
+#elif sys.version_info.major == 3:
|
|
|
+# import subprocess
|
|
|
|
|
|
def _to_str(inp):
|
|
|
if sys.version_info.major == 2:
|
|
@@ -35,7 +35,7 @@ def _to_str(inp):
|
|
|
return "".join( chr(x) for x in inp)
|
|
|
|
|
|
|
|
|
-VERSION = "1.3.1"
|
|
|
+VERSION = "1.4"
|
|
|
|
|
|
PROC_TCP4 = "/proc/net/tcp"
|
|
|
PROC_UDP4 = "/proc/net/udp"
|
|
@@ -453,15 +453,17 @@ if not check_root():
|
|
|
sys.exit()
|
|
|
|
|
|
# get the interfaces
|
|
|
-ifaces = subprocess.getoutput("ls /sys/class/net")
|
|
|
-iface_list = ifaces.split('\n')
|
|
|
+#ifaces = subprocess.getoutput("ls /sys/class/net")
|
|
|
+#iface_list = ifaces.split('\n')
|
|
|
+iface_list = get_if_list()
|
|
|
+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>",
|
|
|
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
|
-parser.add_argument('-i', help="Interface (required)", choices=iface_list, required=True)
|
|
|
+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='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")
|
|
@@ -470,7 +472,8 @@ parser.add_argument('-H', help="Show HTTP Payload", action="store_true")
|
|
|
parser.add_argument('-Hl', help="Show HTTP Payload, long output", action="store_true")
|
|
|
parser.add_argument('filter', nargs='?', help="Filter (BPF syntax) on top of IP (in dbl-quotes \"...\")", type=str)
|
|
|
args = parser.parse_args()
|
|
|
-iface = args.i
|
|
|
+if args.i:
|
|
|
+ iface = args.i
|
|
|
if args.n:
|
|
|
numeric = True
|
|
|
if args.v4:
|
|
@@ -507,6 +510,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)
|
|
|
|
|
|
# confirmed connections cache (ringboffer)
|
|
|
conn_cache = []
|