fixs scapy filters & debug
This commit is contained in:
parent
75c2d4b247
commit
d6874352df
@ -27,7 +27,7 @@ Default port websocket server : 8081
|
|||||||
|
|
||||||
* 'scapy' : listen to local network interface
|
* 'scapy' : listen to local network interface
|
||||||
* 'rainbow' : rainbow animation
|
* 'rainbow' : rainbow animation
|
||||||
* 'remote' : use termspy to listen a remote computer and send to nerves for display
|
* 'remote' : use termspy.py to listen a remote computer and send to nerves for display
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
||||||
|
39
nerves.py
39
nerves.py
@ -7,13 +7,6 @@ v 0.1
|
|||||||
|
|
||||||
A termeal version with fiber optics on raspberry pi
|
A termeal version with fiber optics on raspberry pi
|
||||||
|
|
||||||
goes with leds mode 0
|
|
||||||
|
|
||||||
sniff packets from interface en0 using python module scapy (2.3.1)
|
|
||||||
generate led color for bhoreal in usb midi mode depending on packet port number
|
|
||||||
send led number + color to PD patch boreal.pd
|
|
||||||
in OSC format : /bhoreal/in lednumber ledcolor
|
|
||||||
color is midi parameter so 0 to 127.
|
|
||||||
|
|
||||||
By Sam Neurohack
|
By Sam Neurohack
|
||||||
LICENCE : CC
|
LICENCE : CC
|
||||||
@ -68,6 +61,23 @@ parser.add_argument("-epi","--ephemeralportmin",help="ephemeral port min to excl
|
|||||||
parser.add_argument("-epa","--ephemeralportmax",help="ephemeral port max to exclude (61000 by default)",type=int)
|
parser.add_argument("-epa","--ephemeralportmax",help="ephemeral port max to exclude (61000 by default)",type=int)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.filter:
|
||||||
|
filters = args.filter
|
||||||
|
else:
|
||||||
|
filters = None
|
||||||
|
|
||||||
|
print('Filter :',filters)
|
||||||
|
|
||||||
|
if args.interface == None:
|
||||||
|
|
||||||
|
if platform == 'darwin':
|
||||||
|
ifn='en0'
|
||||||
|
else:
|
||||||
|
ifn='eth0'
|
||||||
|
|
||||||
|
else:
|
||||||
|
iface = args.interface
|
||||||
|
|
||||||
|
|
||||||
if args.ephemeralportmin:
|
if args.ephemeralportmin:
|
||||||
ephemeralportmin = args.ephemeralportmin
|
ephemeralportmin = args.ephemeralportmin
|
||||||
@ -189,21 +199,20 @@ def main():
|
|||||||
leds.mode = 0
|
leds.mode = 0
|
||||||
ws.sendWSall("/players Sniffing")
|
ws.sendWSall("/players Sniffing")
|
||||||
|
|
||||||
if platform == 'darwin':
|
|
||||||
print("Running on", platform, "-> en0")
|
if filters != None:
|
||||||
#sniff(iface='en0', prn=print_summary, store=0)
|
print('with filters', filters)
|
||||||
sniff(iface='en0', prn=print_summary, store=0,filter=args.filter)
|
sniff(iface=ifn, prn=print_summary, store=0, filter= filters)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Running on", platform, "-> eth0")
|
print('without filter')
|
||||||
sniff(iface='eth0', prn=print_summary, store=0)
|
sniff(iface=ifn, prn=print_summary, store=0)
|
||||||
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
leds.cls()
|
||||||
ws_thread.join()
|
ws_thread.join()
|
||||||
buttons_thread.join()
|
buttons_thread.join()
|
||||||
|
|
||||||
|
46
termspy.py
46
termspy.py
@ -1,11 +1,12 @@
|
|||||||
'''
|
'''
|
||||||
termspy.py : sniff packets from interface en1 using python module scapy (2.3.1)
|
termspy.py : sniff packets from interface en0/eth0 using python module scapy (2.3.1)
|
||||||
|
And send port number to nerves pi (WS server port 8081)
|
||||||
Use WS port 8081
|
v0.1b
|
||||||
v0.1
|
|
||||||
By Sam Neurohack
|
By Sam Neurohack
|
||||||
|
|
||||||
LICENCE : BY NC
|
LICENCE : BY NC
|
||||||
|
|
||||||
|
scapy filter like : -f 'tcp'
|
||||||
'''
|
'''
|
||||||
import log
|
import log
|
||||||
|
|
||||||
@ -34,12 +35,16 @@ wsPORT = 8081
|
|||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser(description="A Scanner Interface Darkly")
|
parser = argparse.ArgumentParser(description="A Scanner Interface Darkly")
|
||||||
parser.add_argument("-i","--interface", help="interface to scan")
|
parser.add_argument("-i","--interface", help="interface to scan")
|
||||||
#parser.add_argument("-f","--filter",help="tcpdump filter")
|
parser.add_argument("-f","--filter",help="tcpdump filter")
|
||||||
parser.add_argument("-epi","--ephemeralportmin",help="ephemeral port min to exclude (32768 by default), set to 65536 to include all ports",type=int)
|
parser.add_argument("-epi","--ephemeralportmin",help="ephemeral port min to exclude (32768 by default), set to 65536 to include all ports",type=int)
|
||||||
parser.add_argument("-epa","--ephemeralportmax",help="ephemeral port max to exclude (61000 by default)",type=int)
|
parser.add_argument("-epa","--ephemeralportmax",help="ephemeral port max to exclude (61000 by default)",type=int)
|
||||||
|
parser.add_argument("-d","--debug",action="store_true",default="True",help="Debug output")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
debug = args.debug
|
||||||
|
print('Debug mode :', debug)
|
||||||
|
|
||||||
if args.ephemeralportmin:
|
if args.ephemeralportmin:
|
||||||
ephemeralportmin = args.ephemeralportmin
|
ephemeralportmin = args.ephemeralportmin
|
||||||
else:
|
else:
|
||||||
@ -50,6 +55,24 @@ if args.ephemeralportmax:
|
|||||||
else:
|
else:
|
||||||
ephemeralportmax = 61000
|
ephemeralportmax = 61000
|
||||||
|
|
||||||
|
if args.filter:
|
||||||
|
filters = args.filter
|
||||||
|
else:
|
||||||
|
filters = None
|
||||||
|
|
||||||
|
print('Filter :',filters)
|
||||||
|
|
||||||
|
if args.interface == None:
|
||||||
|
|
||||||
|
if platform == 'darwin':
|
||||||
|
ifn='en0'
|
||||||
|
else:
|
||||||
|
ifn='eth0'
|
||||||
|
|
||||||
|
else:
|
||||||
|
iface = args.interface
|
||||||
|
|
||||||
|
print("Running on interface :", ifn)
|
||||||
|
|
||||||
|
|
||||||
def sendled(zzzport):
|
def sendled(zzzport):
|
||||||
@ -111,16 +134,13 @@ def run(*args):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
if platform == 'darwin':
|
if filters != None:
|
||||||
print("Running on", platform, "-> en0")
|
print('with filters', filters)
|
||||||
#sniff(iface='en0', prn=print_summary, store=0, filter= args.filter)
|
sniff(iface=ifn, prn=print_summary, store=0, filter= filters)
|
||||||
sniff(iface='en0', prn=print_summary, store=0)
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Running on", platform, "-> eth0")
|
print('without filter')
|
||||||
sniff(iface='eth0', prn=print_summary, store=0)
|
sniff(iface=ifn, prn=print_summary, store=0)
|
||||||
|
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
33
ws.py
33
ws.py
@ -16,10 +16,10 @@ import _thread, time
|
|||||||
|
|
||||||
from websocket_server import WebsocketServer
|
from websocket_server import WebsocketServer
|
||||||
import argparse
|
import argparse
|
||||||
#import leds
|
import leds
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
debug = 0
|
|
||||||
Players=0
|
Players=0
|
||||||
clientmode = False
|
clientmode = False
|
||||||
broadcast = True
|
broadcast = True
|
||||||
@ -36,6 +36,7 @@ print ("Arguments parsing if needed...")
|
|||||||
argsparser = argparse.ArgumentParser(description="Nerves experimental v0.1b help mode")
|
argsparser = argparse.ArgumentParser(description="Nerves experimental v0.1b help mode")
|
||||||
argsparser.add_argument("-i","--IP",help="IP to bind to (0.0.0.0 by default)", type=str)
|
argsparser.add_argument("-i","--IP",help="IP to bind to (0.0.0.0 by default)", type=str)
|
||||||
argsparser.add_argument("-p","--port",help="Websocket port to bind to (8081 by default)", type=str)
|
argsparser.add_argument("-p","--port",help="Websocket port to bind to (8081 by default)", type=str)
|
||||||
|
argsparser.add_argument("-d","--debug",action="store_true",default="False",help="Debug output")
|
||||||
args = argsparser.parse_args()
|
args = argsparser.parse_args()
|
||||||
# Server name
|
# Server name
|
||||||
if args.IP:
|
if args.IP:
|
||||||
@ -49,6 +50,9 @@ if args.port:
|
|||||||
else:
|
else:
|
||||||
wsPORT = 8081
|
wsPORT = 8081
|
||||||
|
|
||||||
|
debug = args.debug
|
||||||
|
print('Debug mode', debug)
|
||||||
|
|
||||||
|
|
||||||
def Start(serverIP, wsPORT):
|
def Start(serverIP, wsPORT):
|
||||||
global wserver
|
global wserver
|
||||||
@ -105,21 +109,15 @@ def client_left(client, wserver):
|
|||||||
def message_received(client, wserver, message):
|
def message_received(client, wserver, message):
|
||||||
global crtfunc
|
global crtfunc
|
||||||
|
|
||||||
print("")
|
|
||||||
if len(message) > 200:
|
if len(message) > 200:
|
||||||
message = message[:200]+'..'
|
message = message[:200]+'..'
|
||||||
|
|
||||||
wspath = message.split(" ")
|
wspath = message.split(" ")
|
||||||
if debug > 0:
|
|
||||||
print("Main got from WS", client['id'], "said :", message, "splitted in an wspath :", wspath)
|
|
||||||
else:
|
|
||||||
print("Main got WS Client", client['id'], "said :", message)
|
|
||||||
|
|
||||||
wscommand = wspath[0].split("/")
|
wscommand = wspath[0].split("/")
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
if debug > 0:
|
if debug == True:
|
||||||
print("wscommand :",wscommand)
|
print("Main got from WS", client['id'], "said :", message, ": wscommand :",wscommand,"and wspath :", wspath)
|
||||||
|
|
||||||
# noarg
|
# noarg
|
||||||
if len(wspath) == 1:
|
if len(wspath) == 1:
|
||||||
@ -128,8 +126,9 @@ def message_received(client, wserver, message):
|
|||||||
|
|
||||||
# functions : /func 1
|
# functions : /func 1
|
||||||
elif wscommand[1] == "func":
|
elif wscommand[1] == "func":
|
||||||
if debug > 0:
|
if debug == True:
|
||||||
print("func function with ", wspath[1])
|
print("func function with ", wspath[1])
|
||||||
|
|
||||||
crtfunc +=1
|
crtfunc +=1
|
||||||
if crtfunc == len(funcs):
|
if crtfunc == len(funcs):
|
||||||
crtfunc = 0
|
crtfunc = 0
|
||||||
@ -159,13 +158,13 @@ def message_received(client, wserver, message):
|
|||||||
elif wscommand[1] == "termspy":
|
elif wscommand[1] == "termspy":
|
||||||
|
|
||||||
print('incoming port', str(wspath[1]),'from termspy')
|
print('incoming port', str(wspath[1]),'from termspy')
|
||||||
'''
|
|
||||||
if leds.mode == 2:
|
if leds.mode == 2:
|
||||||
|
|
||||||
# port = int(wspath[1])
|
# port = int(wspath[1])
|
||||||
if int(wspath[1]) != wsPORT:
|
if int(wspath[1]) != wsPORT:
|
||||||
leds.nextnerve(int(wspath[1]))
|
leds.nextnerve(int(wspath[1]))
|
||||||
'''
|
|
||||||
'''
|
'''
|
||||||
# CC : /device/cc/2 127
|
# CC : /device/cc/2 127
|
||||||
elif wscommand[2] == "cc":
|
elif wscommand[2] == "cc":
|
||||||
@ -196,7 +195,7 @@ def send(message):
|
|||||||
def sendWSall(message):
|
def sendWSall(message):
|
||||||
|
|
||||||
if broadcast == True:
|
if broadcast == True:
|
||||||
if debug >0:
|
if debug == True:
|
||||||
print("WS sending to all %s" % (message))
|
print("WS sending to all %s" % (message))
|
||||||
|
|
||||||
wserver.send_message_to_all(message)
|
wserver.send_message_to_all(message)
|
||||||
@ -226,9 +225,5 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
wserver.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user