| Class | PacketFu::TCPPacket |
| In: |
lib/packetfu/tcp.rb
|
| Parent: | Packet |
TCPPacket is used to construct TCP packets. They contain an EthHeader, an IPHeader, and a TCPHeader.
tcp_pkt = PacketFu::TCPPacket.new
tcp_pkt.tcp_flags.syn=1
tcp_pkt.tcp_dst=80
tcp_pkt.tcp_win=5840
tcp_pkt.tcp_options="mss:1460,sack.ok,ts:#{rand(0xffffffff)};0,nop,ws:7"
tcp_pkt.ip_saddr=[rand(0xff),rand(0xff),rand(0xff),rand(0xff)].join('.')
tcp_pkt.ip_daddr=[rand(0xff),rand(0xff),rand(0xff),rand(0xff)].join('.')
tcp_pkt.recalc
tcp_pkt.to_f('/tmp/tcp.pcap')
:eth A pre-generated EthHeader object. :ip A pre-generated IPHeader object. :flavor TODO: Sets the "flavor" of the TCP packet. This will include TCP options and the initial window size, per stack. There is a lot of variety here, and it's one of the most useful methods to remotely fingerprint devices. :flavor will span both ip and tcp for consistency. :type TODO: Set up particular types of packets (syn, psh_ack, rst, etc). This can change the initial flavor. :config A hash of return address details, often the output of Utils.whoami?
| eth_header | [RW] | |
| headers | [RW] | |
| ip_header | [RW] | |
| tcp_header | [RW] |
tcp_calc_sum() computes the TCP checksum, and is called upon intialization. It usually should be called just prior to dropping packets to a file or on the wire.