Class: PacketFu::HSRPPacket
- Includes:
- EthHeaderMixin, HSRPHeaderMixin, IPHeaderMixin, UDPHeaderMixin
- Defined in:
- lib/packetfu/protos/hsrp.rb
Overview
HSRPPacket is used to construct HSRP Packets. They contain an EthHeader, an IPHeader, and a UDPHeader.
Example
hsrp_pkt.new
hsrp_pkt.hsrp_opcode = 0
hsrp_pkt.hsrp_state = 16
hsrp_pkt.hsrp_priority = 254
hsrp_pkt.hsrp_group = 1
hsrp_pkt.hsrp_vip = 10.100.100.254
hsrp_pkt.recalc
hsrp_pkt.to_f('/tmp/hsrp.pcap')
Parameters
:eth
A pre-generated EthHeader object.
:ip
A pre-generated IPHeader object.
:udp
A pre-generated UDPHeader object.
:flavor
TODO: HSRP packets don't tend have any flavor.
:config
A hash of return address details, often the output of Utils.whoami?
Instance Attribute Summary collapse
-
#eth_header ⇒ Object
Returns the value of attribute eth_header.
-
#hsrp_header ⇒ Object
Returns the value of attribute hsrp_header.
-
#ip_header ⇒ Object
Returns the value of attribute ip_header.
-
#udp_header ⇒ Object
Returns the value of attribute udp_header.
Attributes inherited from Packet
#flavor, #headers, #iface, #inspect_style
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ HSRPPacket
constructor
A new instance of HSRPPacket.
-
#peek_format ⇒ Object
Peek provides summary data on packet contents.
Methods included from HSRPHeaderMixin
#hsrp_addr, #hsrp_addr=, #hsrp_group, #hsrp_group=, #hsrp_hellotime, #hsrp_hellotime=, #hsrp_holdtime, #hsrp_holdtime=, #hsrp_opcode, #hsrp_opcode=, #hsrp_password, #hsrp_password=, #hsrp_password_readable, #hsrp_priority, #hsrp_priority=, #hsrp_reserved, #hsrp_reserved=, #hsrp_state, #hsrp_state=, #hsrp_version, #hsrp_version=, #hsrp_vip, #hsrp_vip=, #hsrp_vip_readable
Methods included from UDPHeaderMixin
#udp_calc_len, #udp_dport, #udp_dport=, #udp_dst, #udp_dst=, #udp_len, #udp_len=, #udp_recalc, #udp_sport, #udp_sport=, #udp_src, #udp_src=, #udp_sum, #udp_sum=, #udp_sum_readable
Methods included from IPHeaderMixin
#ip_calc_id, #ip_calc_len, #ip_calc_sum, #ip_calc_sum_on_addr, #ip_daddr, #ip_daddr=, #ip_dst, #ip_dst=, #ip_dst_readable, #ip_frag, #ip_frag=, #ip_hl, #ip_hl=, #ip_hlen, #ip_id, #ip_id=, #ip_id_readable, #ip_len, #ip_len=, #ip_proto, #ip_proto=, #ip_recalc, #ip_saddr, #ip_saddr=, #ip_src, #ip_src=, #ip_src_readable, #ip_sum, #ip_sum=, #ip_sum_readable, #ip_tos, #ip_tos=, #ip_ttl, #ip_ttl=, #ip_v, #ip_v=
Methods included from EthHeaderMixin
#eth_daddr, #eth_daddr=, #eth_dst, #eth_dst=, #eth_dst_readable, #eth_proto, #eth_proto=, #eth_proto_readable, #eth_saddr, #eth_saddr=, #eth_src, #eth_src=, #eth_src_readable
Methods inherited from Packet
#==, #clone, #dissect, #dissection_table, force_binary, #handle_is_identity, #hexify, inherited, #inspect, #inspect_hex, #kind_of?, #layer, layer, #layer_symbol, layer_symbol, #method_missing, #orig_kind_of?, parse, #payload, #payload=, #peek, #proto, #read, #recalc, #respond_to?, #size, #to_f, #to_pcap, #to_s, #to_w, #write
Constructor Details
#initialize(args = {}) ⇒ HSRPPacket
Returns a new instance of HSRPPacket.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/packetfu/protos/hsrp.rb', line 62 def initialize(args={}) @eth_header = EthHeader.new(args).read(args[:eth]) @ip_header = IPHeader.new(args).read(args[:ip]) @ip_header.ip_proto = 0x11 @udp_header = UDPHeader.new(args).read(args[:udp]) @hsrp_header = HSRPHeader.new(args).read(args[:hsrp]) @udp_header.body = @hsrp_header @ip_header.body = @udp_header @eth_header.body = @ip_header @headers = [@eth_header, @ip_header, @udp_header, @hsrp_header] super end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PacketFu::Packet
Instance Attribute Details
#eth_header ⇒ Object
Returns the value of attribute eth_header.
46 47 48 |
# File 'lib/packetfu/protos/hsrp.rb', line 46 def eth_header @eth_header end |
#hsrp_header ⇒ Object
Returns the value of attribute hsrp_header.
46 47 48 |
# File 'lib/packetfu/protos/hsrp.rb', line 46 def hsrp_header @hsrp_header end |
#ip_header ⇒ Object
Returns the value of attribute ip_header.
46 47 48 |
# File 'lib/packetfu/protos/hsrp.rb', line 46 def ip_header @ip_header end |
#udp_header ⇒ Object
Returns the value of attribute udp_header.
46 47 48 |
# File 'lib/packetfu/protos/hsrp.rb', line 46 def udp_header @udp_header end |
Class Method Details
.can_parse?(str) ⇒ Boolean
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/packetfu/protos/hsrp.rb', line 48 def self.can_parse?(str) return false unless str.size >= 54 return false unless EthPacket.can_parse? str return false unless IPPacket.can_parse? str return false unless UDPPacket.can_parse? str temp_packet = UDPPacket.new temp_packet.read(str) if temp_packet.ip_ttl == 1 and [temp_packet.udp_sport,temp_packet.udp_dport] == [1985,1985] return true else return false end end |
Instance Method Details
#peek_format ⇒ Object
Peek provides summary data on packet contents.
76 77 78 79 80 81 82 83 84 |
# File 'lib/packetfu/protos/hsrp.rb', line 76 def peek_format peek_data = ["UH "] peek_data << "%-5d" % self.to_s.size peek_data << "%-16s" % self.hsrp_addr peek_data << "%-4d" % self.hsrp_group peek_data << "%-35s" % self.hsrp_password_readable peek_data << "%-15s" % self.ip_saddr peek_data.join end |