#!/usr/bin/ruby require 'pcaplet' conn = Pcaplet.new('-s 10000') MSN_REQUEST = Pcap::Filter.new('tcp and dst port 1863', conn.capture) MSN_RESPONSE = Pcap::Filter.new('tcp and src port 1863', conn.capture) conn.add_filter(MSN_REQUEST | MSN_RESPONSE) conn.each_packet do |pkt| data = pkt.tcp_data if data and data =~ /MSG(.*)\r\n\r\n(.*)/m header,body = $1,$2 header =~ /^\s*([^\s]+?)\s/ $user = $1 header =~ /^Content-Type:\s*([a-zA-Z\-\/]+)/; $type = $1; next unless $type == "text/plain" puts $user.ljust(30)[0..29] + " : " + body end end