nbareil / net2pcap Goto Github PK
View Code? Open in Web Editor NEWNet2PCAP is a simple network-to-pcap capture file for Linux. Its goal is to be as simple as possible to be used in hostile environments
Net2PCAP is a simple network-to-pcap capture file for Linux. Its goal is to be as simple as possible to be used in hostile environments
If only UID is passed, net2pcap does not change GID, which could be misleading.
A good behavior would be change the GID to the primary group of the new UID.
(bugs found by segoon@openwall)
It would be convenient to support BPF filters in a minimal way, where the user provides directly the BPF opcodes.
Most of the work is already done by the tcpdump compiler, which can dump raw opcodes on stdout. We just need some glue (the following bpf2binary.py
code) to import it into net2pcap through a setsockopt(s, SO_ATTACH_FILTER. ...)
#! /usr/bin/env python
import fileinput
import struct
out=[]
for line in fileinput.input():
digits = map(int, line.split())
if len(digits) != 4: # skip first line
continue
binary = struct.pack('=hbbI', *digits)
out.append(binary)
print ''.join(out)
And then:
bpf_isn=$(tcpdump -i eth0 -ddd port 25 | ./bpf2binary.py)
net2pcap -i eth0 -F "$bpf_isn"
On ^C, term_received
is set to 1 in signal handler. SIGINT has the SA_RESTART flag enabled, that way, syscalls are automatically restarted. Which means that the termination will occured only at the next packet loop entry. On low-traffic network, next packet can arrive after several seconds.
Options available:
SA_RESTART
flagsignalfd()
The latter is the best option but will require a careful rewrite of the main loop.
segoon@openwall reported that the promiscuous state was not restored on exit.
UID and GID options should accept names.
net2pcap should be able to listen on all interfaces at the same time.
net2pcap shall use this ioctl instead of gettimeofday():
socket(7):
SO_TIMESTAMP
Enable or disable the receiving of the SO_TIMESTAMP control mes‐
sage. The timestamp control message is sent with level
SOL_SOCKET and the cmsg_data field is a struct timeval indicat‐
ing the reception time of the last packet passed to the user in
this call. See cmsg(3) for details on control messages.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.