#!/usr/bin/env ruby # # $Id: tcp 9 2008-03-02 04:44:32Z warchild $ # # Send a DNS request require 'rubygems' require 'racket' unless (ARGV.size == 3) puts "Usage: $0 " exit end n = Racket.new n.iface = "eth0" n.l3 = IPv4.new n.l3.src_ip = ARGV[0] n.l3.dst_ip = ARGV[1] n.l3.protocol = 0x6 n.l4 = TCP.new n.l4.src_port = 48484 n.l4.seq = 0xabcdef n.l4.ack = 0xfedcba n.l4.flag_ack = 1 n.l4.flag_psh = 1 n.l4.dst_port = 53 n.l4.window = 4445 n.l5 = DNS.new n.l5.tx_id = 1234 n.l5.add_question(ARGV[2], 1, 1) n.l4.add_option(2, "\xff\xee") n.l4.fix!(n.l3.src_ip, n.l3.dst_ip, n.l5) f = n.sendpacket n.layers.compact.each do |l| puts l.pretty end puts "Sent #{f}"