Underc0de

Programación Scripting => Ruby => Mensaje iniciado por: ANTRAX en Febrero 24, 2010, 04:07:43 PM

Título: Network Snniffer
Publicado por: ANTRAX en Febrero 24, 2010, 04:07:43 PM
Código (ruby) [Seleccionar]

#!/usr/bin/ruby

# this line imports the libpcap ruby bindings
require 'pcaplet'

# create a sniffer that grabs the first 1500 bytes of each packet
$network = Pcaplet.new('-s 1500')

# create a filter that uses our query string and the sniffer we just made
$filter = Pcap::Filter.new('udp and dst port 5060', $network.capture)

# add the new filter to the sniffer
$network.add_filter($filter)

# iterate over every packet that goes through the sniffer
for p in $network
# print packet data for each packet that matches the filter
puts p.udp_data if $filter =~ p
end