Skip to content

Commit

Permalink
Potential fix for issue #2
Browse files Browse the repository at this point in the history
Changed the way I process SNMP strings. I believe this resolves the issue for issue #2.
  • Loading branch information
unixrox committed Jun 6, 2018
1 parent e757ee7 commit a51942b
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions prebellico.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from itertools import groupby
from collections import defaultdict
import string
import pdb
from pdb import set_trace as bp

# Parse arguments from user via argparse
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -433,12 +433,11 @@ def udpdiscovery(header,data):
# If we have a response from a host on port 161, notify the user and extract the SNMP string - note this is buggy as there is not SNMP packet verification
if udp_source_port == 161:
snmppacketfilterregex = re.compile('[a-zA-Z0-9.*].*(?=:)')# Regex to yank data before colon within snmp string data
snmptempdata = snmppacketfilterregex.findall(tempdata)
printable = set(string.printable)
#print printable
communitystring = filter(lambda x: x in printable, snmptempdata[0])
#print communitystring
communitystring = communitystring[2:]
snmptempdata=snmppacketfilterregex.findall(tempdata)
potentialSnmpStrings = re.split('[\x00-\x1f,\x7f-\xff]',snmptempdata[0])
for justTheString in potentialSnmpStrings:
if len(justTheString) > 4:
communitystring = justTheString
if communitystring in snmpstrings.keys():
for host in snmpstrings[string]:
if host == source_ip:
Expand Down

0 comments on commit a51942b

Please sign in to comment.