GithubHelp home page GithubHelp logo

eshenhu / usock_route Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 24 KB

A kernel module which can route unix domain socket message into localhost port for debugging.

License: GNU General Public License v3.0

Makefile 0.40% C 99.60%

usock_route's Introduction

usock_route

A kernel module which can route unix domain socket message into localhost port for debugging.

Why

unix domain socket was used as one of important IPC methods in linux, such as D-BUS, systemd etc in fundamental services for linux, as well as some user application, BUT there is no a good solution for tracing the data on the fly of unix domain socket, This link [https://unix.stackexchange.com/questions/219853/how-to-passively-capture-from-unix-domain-sockets-af-unix-socket-monitoring] give some valuable suggetions on this topic. Comparing with caputure data on IP packet using tcpdump(pcap), almost every one of them has some diffculties on their usage.

Maybe a better one?

The basic idea is re-route the skb data send/recv by domain socket to one free port in one accessable IP address, then the user can use the rich wireshark lua tools to post-process those data further.

How

Linux provide kprobe for dynamic debugging/tracing the internal of linux. We intercept the unix_dgram_sendmsg/unix_dgram_recvmsg function and copy the user data into a pre-allocated FIFO buffer(size can be assigned by parameter during insmod), at the same time a periodic wake-up daemon process will re-reoute the FIFO data into a unique ADDR:PORT per Process-FD pair which was registered by debugfs interface.

Usage

Compiling

  1. Make this kernel module in your enviroment (it should not depend on specified kernel version?)
  2. insmod usock_route.ko

Tracing

  1. Find the pair of PID:FD which you want to trace, for example: PID : 1, FD : 2
  2. Decide which direction you want to trace, S/R (Send or Recv)
  3. Use the debugfs add them. f.g ($echo "1 2 S" > /debug/firmware/usock_filter)
  4. Check the PORT on previous request. f.g.($cat /debug/firmware/usock_filter)
  5. Use tcpdump/wireshark to trace the data.

Help

Contract me [eshenhu at gmail.com] if you have any suggestion.

usock_route's People

Contributors

eshenhu avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.