in progress
This commit is contained in:
parent
2c8196051f
commit
50376aa518
16
README.md
16
README.md
@ -0,0 +1,16 @@
|
|||||||
|
# Nerves
|
||||||
|
|
||||||
|
A termeal version with led strip on raspberry pi
|
||||||
|
|
||||||
|
# Install
|
||||||
|
|
||||||
|
sudo apt install python3-pip
|
||||||
|
sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
|
||||||
|
sudo python3 -m pip install --force-reinstall adafruit-blinka
|
||||||
|
sudo pip3 install scapy
|
||||||
|
|
||||||
|
|
||||||
|
# Based on previous work :
|
||||||
|
|
||||||
|
https://github.com/loloster/termeal
|
||||||
|
https://github.com/s0r00t/sniffeal
|
39
log.py
Normal file
39
log.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
'''
|
||||||
|
Log in color from
|
||||||
|
|
||||||
|
https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python
|
||||||
|
|
||||||
|
usage :
|
||||||
|
|
||||||
|
import log
|
||||||
|
log.info("Hello World")
|
||||||
|
log.err("System Error")
|
||||||
|
|
||||||
|
'''
|
||||||
|
HEADER = '\033[95m'
|
||||||
|
OKBLUE = '\033[94m'
|
||||||
|
OKGREEN = '\033[92m'
|
||||||
|
WARNING = '\033[93m'
|
||||||
|
FAIL = '\033[91m'
|
||||||
|
ENDC = '\033[0m'
|
||||||
|
BOLD = "\033[1m"
|
||||||
|
|
||||||
|
def disable():
|
||||||
|
HEADER = ''
|
||||||
|
OKBLUE = ''
|
||||||
|
OKGREEN = ''
|
||||||
|
WARNING = ''
|
||||||
|
FAIL = ''
|
||||||
|
ENDC = ''
|
||||||
|
|
||||||
|
def infog( msg):
|
||||||
|
print(OKGREEN + msg + ENDC)
|
||||||
|
|
||||||
|
def info( msg):
|
||||||
|
print(OKBLUE + msg + ENDC)
|
||||||
|
|
||||||
|
def warn( msg):
|
||||||
|
print(WARNING + msg + ENDC)
|
||||||
|
|
||||||
|
def err( msg):
|
||||||
|
print(FAIL + msg + ENDC)
|
46
nerves.py
46
nerves.py
@ -3,23 +3,46 @@
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
Nerves
|
Nerves
|
||||||
|
v 0.1
|
||||||
|
|
||||||
|
A termeal version with led strip on raspberry pi
|
||||||
|
|
||||||
|
|
||||||
sniff packets from interface en0 using python module scapy (2.3.1)
|
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
|
generate led color for bhoreal in usb midi mode depending on packet port number
|
||||||
send led number + color to PD patch boreal.pd
|
send led number + color to PD patch boreal.pd
|
||||||
in OSC format : /bhoreal/in lednumber ledcolor
|
in OSC format : /bhoreal/in lednumber ledcolor
|
||||||
color is midi parameter so 0 to 127.
|
color is midi parameter so 0 to 127.
|
||||||
v0.3
|
|
||||||
By Sam Neurohack
|
By Sam Neurohack
|
||||||
LICENCE : CC
|
LICENCE : CC
|
||||||
'''
|
|
||||||
|
|
||||||
from OSC import OSCClient, OSCMessage
|
'''
|
||||||
|
import log
|
||||||
|
|
||||||
|
print("")
|
||||||
|
print("")
|
||||||
|
log.infog("Nerves")
|
||||||
|
log.infog("v0.1b")
|
||||||
|
print("Loading...")
|
||||||
|
|
||||||
|
from OSC3 import OSCClient, OSCMessage
|
||||||
|
from sys import platform
|
||||||
from time import sleep
|
from time import sleep
|
||||||
import types
|
import types
|
||||||
import random
|
import random
|
||||||
from scapy.all import *
|
from scapy.all import *
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
argsparser = argparse.ArgumentParser(description="Nerves v0.1")
|
||||||
|
argsparser.add_argument("-v","--verbose",action="store_true",help="Verbose output")
|
||||||
|
args = argsparser.parse_args()
|
||||||
|
|
||||||
|
verbose=args.verbose
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
client = OSCClient()
|
client = OSCClient()
|
||||||
msg = OSCMessage()
|
msg = OSCMessage()
|
||||||
|
|
||||||
@ -38,7 +61,7 @@ def sendled(zzzport):
|
|||||||
client.sendto(msg, ('127.0.0.1', 9002))
|
client.sendto(msg, ('127.0.0.1', 9002))
|
||||||
msg.clearData()
|
msg.clearData()
|
||||||
except:
|
except:
|
||||||
print 'Connection refused'
|
print('Connection refused')
|
||||||
pass
|
pass
|
||||||
sleep(0.001)
|
sleep(0.001)
|
||||||
counter += 1
|
counter += 1
|
||||||
@ -58,26 +81,26 @@ def print_summary(pkt):
|
|||||||
tcp_dport=pkt[TCP].dport
|
tcp_dport=pkt[TCP].dport
|
||||||
|
|
||||||
if tcp_sport < 50000:
|
if tcp_sport < 50000:
|
||||||
print " IP src " + str(ip_src) + " TCP sport " + str(tcp_sport)
|
print (" IP src " + str(ip_src) + " TCP sport " + str(tcp_sport) )
|
||||||
sendled(tcp_sport)
|
sendled(tcp_sport)
|
||||||
if tcp_dport < 50000:
|
if tcp_dport < 50000:
|
||||||
print " IP dst " + str(ip_dst) + " TCP dport " + str(tcp_dport)
|
print (" IP dst " + str(ip_dst) + " TCP dport " + str(tcp_dport))
|
||||||
sendled(tcp_dport)
|
sendled(tcp_dport)
|
||||||
if UDP in pkt:
|
if UDP in pkt:
|
||||||
udp_sport=pkt[UDP].sport
|
udp_sport=pkt[UDP].sport
|
||||||
udp_dport=pkt[UDP].dport
|
udp_dport=pkt[UDP].dport
|
||||||
|
|
||||||
if udp_sport < 50000:
|
if udp_sport < 50000:
|
||||||
print " IP src " + str(ip_src) + " UDP sport " + str(udp_sport)
|
print (" IP src " + str(ip_src) + " UDP sport " + str(udp_sport) )
|
||||||
sendled(udp_sport)
|
sendled(udp_sport)
|
||||||
|
|
||||||
if udp_dport < 50000:
|
if udp_dport < 50000:
|
||||||
print " IP dst " + str(ip_dst) + " UDP dport " + str(udp_dport)
|
print (" IP dst " + str(ip_dst) + " UDP dport " + str(udp_dport))
|
||||||
sendled(udp_dport)
|
sendled(udp_dport)
|
||||||
|
|
||||||
|
|
||||||
if ARP in pkt and pkt[ARP].op in (1,2):
|
if ARP in pkt and pkt[ARP].op in (1,2):
|
||||||
print " ARP"
|
print (" ARP")
|
||||||
sendled(67)
|
sendled(67)
|
||||||
|
|
||||||
|
|
||||||
@ -85,4 +108,9 @@ def print_summary(pkt):
|
|||||||
def handle_error(self,request,client_address): # All callbacks
|
def handle_error(self,request,client_address): # All callbacks
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if platform == 'darwin':
|
||||||
sniff(iface='en0', prn=print_summary, store=0)
|
sniff(iface='en0', prn=print_summary, store=0)
|
||||||
|
else:
|
||||||
|
sniff(iface='eth0', prn=print_summary, store=0)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user