Update makefile
This commit is contained in:
44
wrapper.py
Executable file
44
wrapper.py
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python3
|
||||
from ctypes import *
|
||||
import _ctypes
|
||||
|
||||
def c_parser(log_line):
|
||||
so_file = "lib/parser_lib.so"
|
||||
iptablesParser = CDLL(so_file)
|
||||
iptablesParser.iptablesParser.argtype = c_char_p
|
||||
iptablesParser.iptablesParser.restype = c_char_p
|
||||
|
||||
iptablesParser.lineParser.argtype = c_char_p
|
||||
iptablesParser.lineParser.restype = c_char_p
|
||||
|
||||
parser_arg = log_line.encode('utf-8')
|
||||
|
||||
# c_return = iptablesParser.iptablesParser(parser_arg)
|
||||
c_return = iptablesParser.lineParser(parser_arg)
|
||||
|
||||
_ctypes.dlclose(iptablesParser._handle)
|
||||
|
||||
# iptablesParser.freeme(c_return)
|
||||
|
||||
print()
|
||||
print("[ Return on Python ]"+"-"*50+"[+]")
|
||||
print(c_return.decode("utf-8"))
|
||||
print(c_return)
|
||||
|
||||
def file_pointer():
|
||||
f = open("/var/log/iptables.log", "r")
|
||||
i = 0
|
||||
for x in f:
|
||||
print()
|
||||
print("*"*100)
|
||||
print("SEQUENCE : ",i)
|
||||
print("*"*100)
|
||||
print(str(i)+" -> "+x)
|
||||
c_parser(str(x))
|
||||
if i >= 3:
|
||||
break
|
||||
i = i + 1
|
||||
|
||||
file_pointer()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user