GithubHelp home page GithubHelp logo

bytemare / gonetmon Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 1.0 252 KB

A network activity monitor in Go.

License: GNU General Public License v3.0

Go 100.00%
capture-packets http-traffic sniffer gopacket golang pcap

gonetmon's Introduction

gonetmon

A network activity monitor in Go.

Build Status Go Report Card codebeat badge Codacy Badge GoDoc

The gonetmon package captures HTTP traffic and displays interesting statistics about the traffic.

Installing / Getting started

Notes

For now, gonetmon reliably works only on Linux. gopacket panics on MacOS and Windows support has not yet been integrated.

In order to be able to capture packets, you'll need the libpcap library. On your favorite Linux distribution, install it like so :

sudo apt-get install libpcap-dev

This will install libpcap-dev on your machine an allow you to capture packets / sniff traffic.

Let's suppose you have a working environment for Go. All that's left to do is getting the package :

go get github.com/bytemare/gonetmon

That just downloaded the project into your $GOPATH/src, and you're set.

'Alright, get me to it !'

Here you go :

cd $GOPATH/src/github.com/bytemare/gonetmon/Tests
go build sniffer.go
sudo ./sniffer

We need to run with elevated privileges, since the system wouldn't let us capture packets otherwise. This will clear your terminal and start showing things like the current http traffic, speed, top visited site, and even show some alerts if the traffic is high.

Not seeing anything ? That's maybe because there's no traffic, or because it's encrypted. Reminder : this only shows plaintext HTTP traffic. But don't worry, I got your back ! On the same machine, open another terminal :

cd Tests/RealTraffic/
go get
go run RealTraffic.go &> /dev/null

This is a webcrawler that will generate a lot of plaintext traffic for a minute or so, exactly what we need !

This is the kind of output that we'll have :

Image1

Note that the traffic spike triggered an alert. After some moments, when the storm is down, we'll have a message that we recovered from alert.

Image2

A handy little option for our sniffer here is that it can take a timeout (in seconds) as an argument, and will close itself after that timeout. Interesting if you want to dump your traffic for some time without being there.

sudo ./sniffer -timeout=200

In every case, you can gracefully shut down the monitoring by gently hitting CTRL+C on your keyboard.

Configuration

For now all configuration parameters have default values in the code. But it is fairly easy to change them in order to change the programs behaviour, just take a look a params.go.

Documentation

If you want to use specific functions, please read up on them in the documentation.

Todo

Like all engineering projects, there's always room to do better, and these are some of the next things I want to do :

Corrections

  • Improve documentation and its layout
  • When shutting down, the collector continues logging received packets' IP addresses. That must have something to do with messages still in the PacketSource channel. It would be better if this wouldn't happen.
  • Proper 'init()' functions that takes profit of go's 'init()' interpretation

Features

  • Ability to fully configure program behaviour with command line arguments and configuration file
  • Richer logging
  • Add more and better logs
  • Make it work on MacOS
  • Make it work on Windows
  • during runtime, continually watch out for new devices being opened
  • export results to different formats : json and/or html to display it in a browser ?
  • TCP Stream reassembly : coherently reassemble packets and calculate connection quality based upon round-trips
  • Ability to add more filters

gonetmon's People

Contributors

bytemare avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

fossabot

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.