All Projects → aderyabin → Sniffer

aderyabin / Sniffer

Licence: mit
Log and Analyze Outgoing HTTP Requests

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Sniffer

mimesniffer
A MIME type sniffer for Go.
Stars: ✭ 22 (-95.28%)
Mutual labels:  sniffer
black-hat-python3-code
🏴‍☠️ tools (py3 version) of Black Hat Python book 🏴‍☠️
Stars: ✭ 51 (-89.06%)
Mutual labels:  sniffer
Probesniffer
🔍 A tool for sniffing unencrypted wireless probe requests from devices.
Stars: ✭ 288 (-38.2%)
Mutual labels:  sniffer
RaspberryPi-Packet-Sniffer
An HTTP and HTTPS sniffing tool created using a Raspberry Pi
Stars: ✭ 79 (-83.05%)
Mutual labels:  sniffer
diablo2
Utilities to work with diablo2, Clientless map rendering & packet sniffing
Stars: ✭ 126 (-72.96%)
Mutual labels:  sniffer
SnifferUI
基于MFC和WinPcap库开发的网络抓包和协议分析软件
Stars: ✭ 86 (-81.55%)
Mutual labels:  sniffer
NRF24 Sniffer
Sniffer for Nordic NRF24L01+ modules with MySensors support
Stars: ✭ 103 (-77.9%)
Mutual labels:  sniffer
Driftnet
Driftnet watches network traffic, and picks out and displays JPEG and GIF images for display
Stars: ✭ 330 (-29.18%)
Mutual labels:  sniffer
wifiexplorer-sensor
[DEPRECATED] Enables remote scanning in WiFi Explorer Pro
Stars: ✭ 37 (-92.06%)
Mutual labels:  sniffer
awesome-automotive-can-id
🚜 unpretentious attempt to collect CAN IDs and payloads for various car brands/models in one place.
Stars: ✭ 104 (-77.68%)
Mutual labels:  sniffer
CatWAN USB Stick
An Open Source USB Stick compatible with LoRa and LoRaWAN with Cortex M0+. To connect, review and analyze packages of LoRa®
Stars: ✭ 23 (-95.06%)
Mutual labels:  sniffer
SniffVPN
Traffic monitor for your VPN
Stars: ✭ 28 (-93.99%)
Mutual labels:  sniffer
VBA-CSV-interface
The most powerful and comprehensive CSV/TSV/DSV data management library for VBA, providing parsing/writing capabilities compliant with RFC-4180 specifications and a complete set of tools for manipulating records and fields.
Stars: ✭ 24 (-94.85%)
Mutual labels:  sniffer
zk-sniffer
sniffer and parse zookeeper packet
Stars: ✭ 38 (-91.85%)
Mutual labels:  sniffer
Esp wifi repeater
A full functional WiFi Repeater (correctly: a WiFi NAT Router)
Stars: ✭ 3,818 (+719.31%)
Mutual labels:  sniffer
icestick-lpc-tpm-sniffer
FPGA-based LPC bus sniffing tool for Lattice iCEstick Evaluation Kit
Stars: ✭ 41 (-91.2%)
Mutual labels:  sniffer
sniffer
🤒 A modern alternative network traffic sniffer.
Stars: ✭ 428 (-8.15%)
Mutual labels:  sniffer
Btle
Bluetooth Low Energy (BLE) packet sniffer and transmitter for both standard and non standard (raw bit) based on Software Defined Radio (SDR).
Stars: ✭ 411 (-11.8%)
Mutual labels:  sniffer
Esp8266 Injection Example
Example project to demonstrate packet injection / sniffer capabilities of ESP8266 IC.
Stars: ✭ 317 (-31.97%)
Mutual labels:  sniffer
Charles-Proxy-Mobile-Guide
The mobile hackers' guide to Charles Proxy 👍
Stars: ✭ 105 (-77.47%)
Mutual labels:  sniffer

Sniffer

Build Gem Version Join the chat at https://gitter.im/aderyabin/sniffer

Sniffer aims to help:

  • Log outgoing HTTP requests. Sniffer logs as JSON format for export to ELK, Logentries and etc.
  • Debug requests. Sniffer allows to save all requests/responses in storage for future debugging

Sniffer supports most common HTTP accessing libraries:

Demo

demo

Installation

Add this line to your application's Gemfile:

gem 'sniffer'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sniffer

Usage

Here's some simple examples to get you started:

require 'http'
require 'sniffer'

Sniffer.enable!

HTTP.get('http://example.com/?lang=ruby&author=matz')
Sniffer.data[0].to_h
# => {:request=>
#   {:host=>"example.com",
#    :query=>"/?lang=ruby&author=matz",
#    :port=>80,
#    :headers=>{"Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "Connection"=>"close"},
#    :body=>"",
#    :method=>:get},
#  :response=>
#   {:status=>200,
#    :headers=>
#     {"Content-Encoding"=>"gzip",
#      "Cache-Control"=>"max-age=604800",
#      "Content-Type"=>"text/html",
#      "Date"=>"Thu, 26 Oct 2017 13:47:00 GMT",
#      "Etag"=>"\"359670651+gzip\"",
#      "Expires"=>"Thu, 02 Nov 2017 13:47:00 GMT",
#      "Last-Modified"=>"Fri, 09 Aug 2013 23:54:35 GMT",
#      "Server"=>"ECS (lga/1372)",
#      "Vary"=>"Accept-Encoding",
#      "X-Cache"=>"HIT",
#      "Content-Length"=>"606",
#      "Connection"=>"close"},
#    :body=> "OK",
#    :timing=>0.23753299983218312}}

You can clear saved data

Sniffer.clear!

You can configure capacity of storage to prevent the huge memory usage and set up log rotation. By default log rotation is active (when capacity is set) and log works like a queue. If rotation is disabled - requests will be logged until result log size reaches the capacity.

# will fill the storage and stop logging
Sniffer.config.store = {capacity: 1000, rotate: false}

# will rotate logs to fit 1000 results (rotate is true by default)
Sniffer.config.store = {capacity: 1000}

You can reset config to default

Sniffer.reset!

You can enable and disable Sniffer

Sniffer.enable!
Sniffer.disable!

By default output log looks like that:

D, [2017-10-26T16:47:14.007152 #59511] DEBUG -- : {"port":80,"host":"example.com","query":"/?lang=ruby&author=matz","rq_connection":"close","method":"get","request_body":"","status":200,"rs_accept_ranges":"bytes","rs_cache_control":"max-age=604800","rs_content_type":"text/html","rs_date":"Thu, 26 Oct 2017 13:47:13 GMT","rs_etag":"\"359670651+gzip\"","rs_expires":"Thu, 02 Nov 2017 13:47:13 GMT","rs_last_modified":"Fri, 09 Aug 2013 23:54:35 GMT","rs_server":"ECS (lga/1385)","rs_vary":"Accept-Encoding","rs_x_cache":"HIT","rs_content_length":"1270","rs_connection":"close","timing":0.513012999901548,"response_body":"OK"}

where rq_xxx is request header and rs_xxx - response header

Configuration

Sniffer default options:

Sniffer.config do |c|
  c.logger = Logger.new($stdout)
  c.severity = Logger::Severity::DEBUG
  # HTTP options to log
  c.log = {
    request_url: true,
    request_headers: true,
    request_body: true,
    request_method: true,
    response_status: true,
    response_headers: true,
    response_body: true,
    timing: true
  }
  c.store =  true # save requests/responses to Sniffer.data
  c.enabled = false  # Sniffer disabled by default
  c.url_whitelist = nil
  c.url_blacklist = nil
end

Whitelist

You can add specific host url to whitelist as regexp or string. Sniffer will store only requests that matched.

Sniffer.config.url_whitelist = /whitelisted.com/

HTTP.get('http://example.com')
Sniffer.data[0].to_h
# => {}

HTTP.get('http://whitelisted.com/')
Sniffer.data[0].to_h
# => {{:request=>{:host=>"whitelisted.com", ....}}

Blacklist

You can add specific host url to blacklist as regexp or string. Sniffer will ignore all matched requests.

Sniffer.config.url_blacklist = /blacklisted.com/

HTTP.get('http://blacklisted.com')
Sniffer.data[0].to_h
# => {}

HTTP.get('http://example.com')
Sniffer.data[0].to_h
# => {{:request=>{:host=>"example.com", ...}}

Middleware

You can add the middleware to run custom code before/after the sniffed data was logged.

Sniffer.middleware do |chain|
  chain.add MyHook
end

class MyHook
  def request(data_item)
    puts "Before work"
    yield
    puts "After work"
  end

  def response(data_item)
    puts "Before work"
    yield
    puts "After work"
  end
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/aderyabin/sniffer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Acknowledge

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Sniffer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].