Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Parse IPtables informational logging
- #!/usr/bin/python
- def select(string, text):
- pos = text.find(string)
- if pos < 0:
- return None
- else:
- end = text[pos:].find(' ')
- out = line[pos + len(string):pos + end]
- return out
- def mysql_insert(text):
- src = select('SRC=', text)
- proto = select('PROTO=', text)
- dpt = select('DPT=', text)
- #not interested in PING
- if proto == 'ICMP':
- pass
- elif src == '0.0.0.0':
- pass
- elif dpt == None:
- pass
- #Exclude own ip
- elif src == '1.1.1.1':
- pass
- #Exclude VPS provider noise
- elif src.find('18.100.18') >= 0:
- pass
- else:
- print src, proto, dpt
- with open('syslog.1') as f:
- for line in f.readlines():
- mysql_insert(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement