#!/usr/bin/env ruby # # $Id: tcp2udp 9 2008-03-02 04:44:32Z warchild $ # # # Spew TCP packets back at the source but in UDP form. Gross. # Pointless. require 'rubygems' require 'pcaprub' require 'racket' if (ARGV.size < 1) puts "Usage: $0 [filter]" exit end begin p = Pcap::open_live(ARGV[0], 1500, true, 1000) unless (ARGV[1].nil?) p.setfilter(ARGV[1]) end rescue Exception => e puts "Pcap: Cannot open device #{ARGV[0]}: #{e}" exit end p.each do |pkt| if (p.datalink == Pcap::DLT_EN10MB) eth = Ethernet.new(pkt) case eth.ethertype when 0x0800: orig_ipv4 = IPv4.new(eth.payload) if (orig_ipv4.protocol