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
|
||||
* '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
|
||||
|
||||
|
39
nerves.py
39
nerves.py
@ -7,13 +7,6 @@ v 0.1
|
||||
|
||||
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
|
||||
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)
|
||||
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:
|
||||
ephemeralportmin = args.ephemeralportmin
|
||||
@ -189,21 +199,20 @@ def main():
|
||||
leds.mode = 0
|
||||
ws.sendWSall("/players Sniffing")
|
||||
|
||||
if platform == 'darwin':
|
||||
print("Running on", platform, "-> en0")
|
||||
#sniff(iface='en0', prn=print_summary, store=0)
|
||||
sniff(iface='en0', prn=print_summary, store=0,filter=args.filter)
|
||||
|
||||
|
||||
if filters != None:
|
||||
print('with filters', filters)
|
||||
sniff(iface=ifn, prn=print_summary, store=0, filter= filters)
|
||||
else:
|
||||
print("Running on", platform, "-> eth0")
|
||||
sniff(iface='eth0', prn=print_summary, store=0)
|
||||
print('without filter')
|
||||
sniff(iface=ifn, prn=print_summary, store=0)
|
||||
|
||||
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
finally:
|
||||
|
||||
leds.cls()
|
||||
ws_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)
|
||||
|
||||
Use WS port 8081
|
||||
v0.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)
|
||||
v0.1b
|
||||
By Sam Neurohack
|
||||
|
||||
LICENCE : BY NC
|
||||
|
||||
scapy filter like : -f 'tcp'
|
||||
'''
|
||||
import log
|
||||
|
||||
@ -34,12 +35,16 @@ wsPORT = 8081
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="A Scanner Interface Darkly")
|
||||
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("-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()
|
||||
|
||||
|
||||
debug = args.debug
|
||||
print('Debug mode :', debug)
|
||||
|
||||
if args.ephemeralportmin:
|
||||
ephemeralportmin = args.ephemeralportmin
|
||||
else:
|
||||
@ -50,6 +55,24 @@ if args.ephemeralportmax:
|
||||
else:
|
||||
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):
|
||||
@ -111,16 +134,13 @@ def run(*args):
|
||||
|
||||
try:
|
||||
|
||||
if platform == 'darwin':
|
||||
print("Running on", platform, "-> en0")
|
||||
#sniff(iface='en0', prn=print_summary, store=0, filter= args.filter)
|
||||
sniff(iface='en0', prn=print_summary, store=0)
|
||||
|
||||
if filters != None:
|
||||
print('with filters', filters)
|
||||
sniff(iface=ifn, prn=print_summary, store=0, filter= filters)
|
||||
else:
|
||||
print("Running on", platform, "-> eth0")
|
||||
sniff(iface='eth0', prn=print_summary, store=0)
|
||||
print('without filter')
|
||||
sniff(iface=ifn, prn=print_summary, store=0)
|
||||
|
||||
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
|
33
ws.py
33
ws.py
@ -16,10 +16,10 @@ import _thread, time
|
||||
|
||||
from websocket_server import WebsocketServer
|
||||
import argparse
|
||||
#import leds
|
||||
import leds
|
||||
import traceback
|
||||
|
||||
debug = 0
|
||||
|
||||
Players=0
|
||||
clientmode = False
|
||||
broadcast = True
|
||||
@ -36,6 +36,7 @@ print ("Arguments parsing if needed...")
|
||||
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("-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()
|
||||
# Server name
|
||||
if args.IP:
|
||||
@ -49,6 +50,9 @@ if args.port:
|
||||
else:
|
||||
wsPORT = 8081
|
||||
|
||||
debug = args.debug
|
||||
print('Debug mode', debug)
|
||||
|
||||
|
||||
def Start(serverIP, wsPORT):
|
||||
global wserver
|
||||
@ -105,21 +109,15 @@ def client_left(client, wserver):
|
||||
def message_received(client, wserver, message):
|
||||
global crtfunc
|
||||
|
||||
print("")
|
||||
if len(message) > 200:
|
||||
message = message[:200]+'..'
|
||||
|
||||
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("/")
|
||||
|
||||
# debug
|
||||
if debug > 0:
|
||||
print("wscommand :",wscommand)
|
||||
if debug == True:
|
||||
print("Main got from WS", client['id'], "said :", message, ": wscommand :",wscommand,"and wspath :", wspath)
|
||||
|
||||
# noarg
|
||||
if len(wspath) == 1:
|
||||
@ -128,8 +126,9 @@ def message_received(client, wserver, message):
|
||||
|
||||
# functions : /func 1
|
||||
elif wscommand[1] == "func":
|
||||
if debug > 0:
|
||||
if debug == True:
|
||||
print("func function with ", wspath[1])
|
||||
|
||||
crtfunc +=1
|
||||
if crtfunc == len(funcs):
|
||||
crtfunc = 0
|
||||
@ -159,13 +158,13 @@ def message_received(client, wserver, message):
|
||||
elif wscommand[1] == "termspy":
|
||||
|
||||
print('incoming port', str(wspath[1]),'from termspy')
|
||||
'''
|
||||
|
||||
if leds.mode == 2:
|
||||
|
||||
# port = int(wspath[1])
|
||||
if int(wspath[1]) != wsPORT:
|
||||
leds.nextnerve(int(wspath[1]))
|
||||
'''
|
||||
|
||||
'''
|
||||
# CC : /device/cc/2 127
|
||||
elif wscommand[2] == "cc":
|
||||
@ -196,7 +195,7 @@ def send(message):
|
||||
def sendWSall(message):
|
||||
|
||||
if broadcast == True:
|
||||
if debug >0:
|
||||
if debug == True:
|
||||
print("WS sending to all %s" % (message))
|
||||
|
||||
wserver.send_message_to_all(message)
|
||||
@ -226,9 +225,5 @@ if __name__ == '__main__':
|
||||
|
||||
except Exception:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
wserver.close()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user