Giter Club home page Giter Club logo

net2pcap's People

Contributors

nbareil avatar phil777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

net2pcap's Issues

^C shall not try to recv() a new packet

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:

  • Do not set SA_RESTART flag
  • Replace the whole logic with signalfd()

The latter is the best option but will require a careful rewrite of the main loop.

Minimal BPF support

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"

force the change of gid if only uid was given

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)

use ioctl(SO_TIMESTAMP) for packet timestamp

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.