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

NSE improvement needed: unified raw packet sending library #2171

Open
dmiller-nmap opened this issue Nov 5, 2020 · 1 comment
Open

NSE improvement needed: unified raw packet sending library #2171

dmiller-nmap opened this issue Nov 5, 2020 · 1 comment

Comments

@dmiller-nmap
Copy link

Nmap is known for its ability to send and receive raw packets. NSE is known for enabling script authors to succinctly craft powerful networking scripts. But trying to send and receive raw packets in NSE is fraught with problems:

  1. Limited support for raw network packets depending on platform. Windows does not support this, but does support raw Ethernet frames, so we ought to make a mostly-transparent overlay for this via the ip_open() function.
  2. Packet crafting routines are duplicated between Lua (nselib/packet.lua and scattered throughout various scripts) and C++ (libnetutil, which has no Lua bindings). It's been a TODO item for a while to see about unifying these by binding libnetutil to Lua.
  3. Scripts which want to receive replies to their raw packets must manage coroutines (worker threads) and pcap handles in a specific way. We could probably consolidate a lot of duplicate code that has been written for this purpose into a library. A possible interface would be to define startup and teardown functions, a packet filter, a timeout, and a received-packet handler function, then call some sort of run() function to start the whole thing.

Stretch goal: extend Nsock's pcap support to allow pcap WRITE requests via pcap_inject() or pcap_sendpacket(). Then we can use that in most layer-2 cases where we use libdnet currently. Not sure what the caveats would be in that case; would have to compare code behind pcap_inject() and libdnet's eth_send().

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

No branches or pull requests

2 participants
@dmiller-nmap and others