Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse conntrack updates to structure NFCTAttrTuple or dicrinary #1197

Open
sever-sever opened this issue May 24, 2024 · 0 comments
Open

Parse conntrack updates to structure NFCTAttrTuple or dicrinary #1197

sever-sever opened this issue May 24, 2024 · 0 comments

Comments

@sever-sever
Copy link

sever-sever commented May 24, 2024

Is there any way to parse conntrack netlink updates to the NFCTAttrTuple, JSON or dictionary?

#!/usr/bin/env python3

from pyroute2.netlink import nfnetlink
from pyroute2 import conntrack

ct = conntrack.Conntrack()
ct.bind()
ct.add_membership(nfnetlink.NFNLGRP_CONNTRACK_NEW)

while True:
    data = ct.recv(4096)
    if data:
        print(data)

We get:

# ./tmp3.py 
b'\xa4\x00\x00\x00\x00\x01\x00\x06\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00<\x00\x01\x80\x14\x00\x01\x80\x08\x00\x01\x00d@\x00\x01\x08\x00\x02\x00\x01\x01\x01\x01$\x00\x02\x80\x05\x00\x01\x00\x01\x00\x00\x00\x06\x00\x04\x00\x1cn\x00\x00\x05\x00\x05\x00\x08\x00\x00\x00\x05\x00\x06\x00\x00\x00\x00\x00<\x00\x02\x80\x14\x00\x01\x80\x08\x00\x01\x00\x01\x01\x01\x01\x08\x00\x02\x00\xc0\xa8z\xde$\x00\x02\x80\x05\x00\x01\x00\x01\x00\x00\x00\x06\x00\x04\x00\x0f0\x00\x00\x05\x00\x05\x00\x00\x00\x00\x00\x05\x00\x06\x00\x00\x00\x00\x00\x08\x00\x0c\x00\xfa\xdb!\x83\x08\x00\x03\x00\x00\x00\x01\x98\x08\x00\x07\x00\x00\x00\x00\x1e'

Is there any native tool to parse/extract this data from the hex? To get the Source Address, Destination Address, sport, dport, translation address/port, protocol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant