Skip to content

Instantly share code, notes, and snippets.

@ei-grad
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ei-grad/0d3189111c82ce1fe8c0 to your computer and use it in GitHub Desktop.
Save ei-grad/0d3189111c82ce1fe8c0 to your computer and use it in GitHub Desktop.
from Conntrack import ConnectionManager, NFCT_O_XML
from lxml.etree import fromstring
def filter_nat(xml):
d = fromstring(xml)
orig_src = d.xpath("..//meta[@direction='original']/layer3/src/text()")[0]
repl_dst = d.xpath("..//meta[@direction='reply']/layer3/dst/text()")[0]
return orig_src != repl_dst
for i in ConnectionManager(NFCT_O_XML).list():
if filter_nat(i):
print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment