├── temp ├── tcpflowdump │ └── nothing.txt └── decrypthttp2.py ├── NIDS_python-main ├── temp │ ├── tcpflowdump │ │ └── nothing.txt │ ├── tcpstreamread.pcap │ ├── httpstreamread.pcap │ ├── temppackets │ │ └── 103257EtherIPTCP2019811984https_192168020852587PARawMSGINCOMINGHOMENETRANGEREAD.pkt │ ├── decrypthttp2.py │ └── showpackettemp │ │ └── EtherIPv6UDPfe801e61b4fffe08d97638322_ff02cssdpRaw.json ├── README.md ├── rules.txt ├── yararules │ └── rules1.yara ├── show_packetdat.py ├── nidsshowpacket │ ├── index.html │ ├── script.js │ └── styles.css ├── nidsweb │ ├── index.html │ ├── styles.css │ └── script.js ├── custom_ids.py └── nids_eel.py ├── README.md ├── rules.txt ├── yararules └── rules1.yara └── custom_ids.py /temp/tcpflowdump/nothing.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NIDS_python-main/temp/tcpflowdump/nothing.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /NIDS_python-main/temp/tcpstreamread.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleboy-byte/NIDS_python/HEAD/NIDS_python-main/temp/tcpstreamread.pcap -------------------------------------------------------------------------------- /NIDS_python-main/temp/httpstreamread.pcap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleboy-byte/NIDS_python/HEAD/NIDS_python-main/temp/httpstreamread.pcap -------------------------------------------------------------------------------- /NIDS_python-main/README.md: -------------------------------------------------------------------------------- 1 | # NIDS_python 2 | A custom GUI based NIDS (Network Intrusion Detection System) with stream follow capability for HTTP2 and TLS/TCP. 3 | Savedpcap directory has to be created in root folder. 4 | ssllogs filepath has to be modified in the custom_ids.py code. 5 | -------------------------------------------------------------------------------- /NIDS_python-main/temp/temppackets/103257EtherIPTCP2019811984https_192168020852587PARawMSGINCOMINGHOMENETRANGEREAD.pkt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleboy-byte/NIDS_python/HEAD/NIDS_python-main/temp/temppackets/103257EtherIPTCP2019811984https_192168020852587PARawMSGINCOMINGHOMENETRANGEREAD.pkt -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NIDS_python 2 | A custom GUI based NIDS (Network Intrusion Detection System) with stream follow capability for HTTP2 and TLS/TCP and yara rules matching applied for captured network traffic. 3 | Savedpcap directory has to be created in root folder. 4 | ssllogs filepath has to be modified in the custom_ids.py code. 5 | -------------------------------------------------------------------------------- /rules.txt: -------------------------------------------------------------------------------- 1 | !alert udp any any -> any 53 DNS DNS DNS 2 | !alert udp any 53 -> any any DNS DNS DNS 3 | !alert tcp 192.168.0.0/24 any -> any any OUTGOING HOME NET RANGE READ 4 | !alert udp any any -> any any UDP ALERT 5 | alert tcp any any -> 192.168.0.0/24 any INCOMING HOME NET RANGE READ 6 | alert tcp any any -> any 8080 HTTP TRAFFIC 7 | alert tcp any 80 -> any any HTTP TRAFFIC 8 | alert tcp any any -> any 80 HTTP TRAFFIC -------------------------------------------------------------------------------- /NIDS_python-main/rules.txt: -------------------------------------------------------------------------------- 1 | !alert udp any any -> any 53 DNS DNS DNS 2 | !alert udp any 53 -> any any DNS DNS DNS 3 | !alert tcp 192.168.0.0/24 any -> any any OUTGOING HOME NET RANGE READ 4 | !alert udp any any -> any any UDP ALERT 5 | alert tcp any any -> 192.168.0.0/24 any INCOMING HOME NET RANGE READ 6 | alert tcp any any -> any 8080 HTTP TRAFFIC 7 | alert tcp any 80 -> any any HTTP TRAFFIC 8 | alert tcp any any -> any 80 HTTP TRAFFIC -------------------------------------------------------------------------------- /temp/decrypthttp2.py: -------------------------------------------------------------------------------- 1 | import pyshark 2 | 3 | key_path = "C:\\Users\\sengu\\ssl1.log" 4 | pcap_file = 'tcpstreamread.pcap' 5 | 6 | 7 | cap = pyshark.FileCapture(pcap_file, 8 | display_filter="http2.streamid eq 5", 9 | override_prefs={'ssl.keylog_file': key_path}) 10 | 11 | dat = '' 12 | rawvallengthpassed = False 13 | for field, val in cap[0].http2._all_fields.items(): 14 | # if rawvallengthpassed == False: 15 | # if field == 'http2.header.name.length': 16 | # rawvallengthpassed = True 17 | # else: 18 | dat += str(field.split(".")[-1]) + " : " + str(val) + " \n\n" 19 | 20 | print(dat) 21 | 22 | -------------------------------------------------------------------------------- /NIDS_python-main/temp/decrypthttp2.py: -------------------------------------------------------------------------------- 1 | import pyshark 2 | 3 | key_path = "C:\\Users\\sengu\\ssl1.log" 4 | pcap_file = 'tcpstreamread.pcap' 5 | 6 | 7 | cap = pyshark.FileCapture(pcap_file, 8 | display_filter="http2.streamid eq 5", 9 | override_prefs={'ssl.keylog_file': key_path}) 10 | 11 | dat = '' 12 | rawvallengthpassed = False 13 | for field, val in cap[0].http2._all_fields.items(): 14 | # if rawvallengthpassed == False: 15 | # if field == 'http2.header.name.length': 16 | # rawvallengthpassed = True 17 | # else: 18 | dat += str(field.split(".")[-1]) + " : " + str(val) + " \n\n" 19 | 20 | print(dat) 21 | 22 | -------------------------------------------------------------------------------- /yararules/rules1.yara: -------------------------------------------------------------------------------- 1 | rule zipExtensionFound{ 2 | strings: 3 | $link1 = ".zip" 4 | condition: 5 | any of them 6 | } 7 | 8 | rule PE_FILE_HEADER{ 9 | meta: 10 | description = "YARA rules for pe detection in the NIDS program" 11 | author = "cybersecadventures01123" 12 | reference = "https://www.nextron-systems.com/2018/01/22/write-yara-rules-detect-embedded-exe-files-ole-objects/" 13 | strings: 14 | $hex1 = "546869732070726f6772616d2063616e6e6f742062652072756e20696e20444f53206d6f6465" ascii 15 | $hex1_txt = "This program cannot be run in DOS mode" 16 | $hex2 = "4b45524e454c33322e646c6c" ascii 17 | $hex2_txt = "KERNEL32.dll" nocase 18 | $hex3 = {4D 5A 40 00} // MZ@ 19 | //$hex3_txt = "MZ@" 20 | condition: 21 | any of them 22 | } -------------------------------------------------------------------------------- /NIDS_python-main/yararules/rules1.yara: -------------------------------------------------------------------------------- 1 | rule zipExtensionFound{ 2 | strings: 3 | $link1 = ".zip" 4 | condition: 5 | any of them 6 | } 7 | 8 | rule PE_FILE_HEADER{ 9 | meta: 10 | description = "YARA rules for pe detection in the NIDS program" 11 | author = "cybersecadventures01123" 12 | reference = "https://www.nextron-systems.com/2018/01/22/write-yara-rules-detect-embedded-exe-files-ole-objects/" 13 | strings: 14 | $hex1 = "546869732070726f6772616d2063616e6e6f742062652072756e20696e20444f53206d6f6465" ascii 15 | $hex1_txt = "This program cannot be run in DOS mode" 16 | $hex2 = "4b45524e454c33322e646c6c" ascii 17 | $hex2_txt = "KERNEL32.dll" nocase 18 | $hex3 = {4D 5A 40 00} // MZ@ 19 | //$hex3_txt = "MZ@" 20 | condition: 21 | any of them 22 | } -------------------------------------------------------------------------------- /NIDS_python-main/temp/showpackettemp/EtherIPv6UDPfe801e61b4fffe08d97638322_ff02cssdpRaw.json: -------------------------------------------------------------------------------- 1 | { 2 | "Ethernet": { 3 | "dst": "d0:c6:37:47:8e:02", 4 | "src": "1c:61:b4:08:d9:76", 5 | "type": "IPv6" 6 | }, 7 | "IPv6": { 8 | "version": "6", 9 | "tc": "0", 10 | "fl": "0", 11 | "plen": "382", 12 | "nh": "UDP", 13 | "hlim": "1", 14 | "src": "fe80::1e61:b4ff:fe08:d976", 15 | "dst": "ff02::c" 16 | }, 17 | "UDP": { 18 | "sport": "38322", 19 | "dport": "ssdp", 20 | "len": "382", 21 | "chksum": "0x8740" 22 | }, 23 | "Raw": { 24 | "load": "'NOTIFY * HTTP/1.1\\r\\nHOST: [FF02::C]:1900\\r\\nCACHE-CONTROL: max-age=60\\r\\nLOCATION: http://[::1]:1900/qyyjn/rootDesc.xml\\r\\nSERVER: TP-Link/TP-Link UPnP/1.1 MiniUPnPd/1.8\\r\\nNT: upnp:rootdevice\\r\\nUSN: uuid:e4c797e0-82ce-4f84-b56d-085d9d77c8cd::upnp:rootdevice\\r\\nNTS: ssdp:alive\\r\\nOPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\\r\\n01-NLS: 1\\r\\nBOOTID.UPNP.ORG: 1\\r\\nCONFIGID.UPNP.ORG: 1337\\r\\n\\r\\n'" 25 | } 26 | } -------------------------------------------------------------------------------- /NIDS_python-main/show_packetdat.py: -------------------------------------------------------------------------------- 1 | import eel 2 | import sys 3 | import json 4 | import pprint 5 | 6 | eel.init("nidsshowpacket") 7 | 8 | def is_port_in_use(port: int) -> bool: 9 | import socket 10 | with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: 11 | return s.connect_ex(('localhost', port)) == 0 12 | 13 | portdefined = int(sys.argv[1]) # --> argv 1 is port number 14 | # portfree = is_port_in_use(portdefined) 15 | # while not portfree: 16 | # portdefined += 1 17 | # portfree = is_port_in_use(portdefined) 18 | 19 | @eel.expose 20 | 21 | def ret_pktsummaryname(): 22 | return sys.argv[3] 23 | 24 | @eel.expose 25 | 26 | def get_packetdat(): 27 | pktfile = "temp/showpackettemp/" + sys.argv[2] # --> argv 2 is pktfile addr 28 | with open(pktfile, "r") as pfile: 29 | try: 30 | # pktdat = pfile.read() 31 | pktdat = json.load(pfile) 32 | except: 33 | pktdat = {"No Data":"No Data"} 34 | # if pktdat.strip() == "": 35 | # pktdat = {"No Data":"No Data"} 36 | # print("1") 37 | pprint.pprint(pktdat) 38 | return pktdat 39 | 40 | eel.start("index.html", port=portdefined, size=(900, 500)) -------------------------------------------------------------------------------- /NIDS_python-main/nidsshowpacket/index.html: -------------------------------------------------------------------------------- 1 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |