packetgen 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/packetgen/deprecation.rb +7 -1
- data/lib/packetgen/header/arp.rb +6 -7
- data/lib/packetgen/header/asn1_base.rb +2 -1
- data/lib/packetgen/header/base.rb +27 -24
- data/lib/packetgen/header/bootp.rb +14 -14
- data/lib/packetgen/header/dhcp/option.rb +8 -8
- data/lib/packetgen/header/dhcp/options.rb +2 -2
- data/lib/packetgen/header/dhcp.rb +6 -7
- data/lib/packetgen/header/dhcpv6/duid.rb +1 -1
- data/lib/packetgen/header/dhcpv6/option.rb +37 -15
- data/lib/packetgen/header/dhcpv6/options.rb +3 -3
- data/lib/packetgen/header/dhcpv6/relay.rb +1 -0
- data/lib/packetgen/header/dhcpv6.rb +13 -14
- data/lib/packetgen/header/dns/name.rb +9 -8
- data/lib/packetgen/header/dns/opt.rb +3 -0
- data/lib/packetgen/header/dns/option.rb +7 -7
- data/lib/packetgen/header/dns/qdsection.rb +2 -2
- data/lib/packetgen/header/dns/question.rb +1 -0
- data/lib/packetgen/header/dns/rrsection.rb +2 -2
- data/lib/packetgen/header/dns.rb +76 -60
- data/lib/packetgen/header/dot11/control.rb +5 -5
- data/lib/packetgen/header/dot11/data.rb +11 -10
- data/lib/packetgen/header/dot11/element.rb +1 -1
- data/lib/packetgen/header/dot11/management.rb +18 -15
- data/lib/packetgen/header/dot11/sub_mngt.rb +22 -21
- data/lib/packetgen/header/dot11.rb +38 -38
- data/lib/packetgen/header/dot1q.rb +5 -4
- data/lib/packetgen/header/dot1x.rb +8 -8
- data/lib/packetgen/header/eap/fast.rb +3 -3
- data/lib/packetgen/header/eap/md5.rb +11 -3
- data/lib/packetgen/header/eap/tls.rb +9 -8
- data/lib/packetgen/header/eap/ttls.rb +13 -10
- data/lib/packetgen/header/eap.rb +58 -33
- data/lib/packetgen/header/eth.rb +26 -12
- data/lib/packetgen/header/gre.rb +26 -2
- data/lib/packetgen/header/http/headers.rb +6 -5
- data/lib/packetgen/header/http/request.rb +24 -16
- data/lib/packetgen/header/http/response.rb +22 -15
- data/lib/packetgen/header/icmp.rb +10 -10
- data/lib/packetgen/header/icmpv6.rb +10 -9
- data/lib/packetgen/header/igmp.rb +21 -10
- data/lib/packetgen/header/igmpv3/group_record.rb +7 -2
- data/lib/packetgen/header/igmpv3/mq.rb +1 -1
- data/lib/packetgen/header/igmpv3/mr.rb +1 -1
- data/lib/packetgen/header/igmpv3.rb +11 -10
- data/lib/packetgen/header/ip/addr.rb +6 -2
- data/lib/packetgen/header/ip/option.rb +18 -5
- data/lib/packetgen/header/ip.rb +52 -35
- data/lib/packetgen/header/ipv6/addr.rb +14 -13
- data/lib/packetgen/header/ipv6/extension.rb +9 -7
- data/lib/packetgen/header/ipv6/hop_by_hop.rb +26 -7
- data/lib/packetgen/header/ipv6.rb +31 -22
- data/lib/packetgen/header/llc.rb +20 -13
- data/lib/packetgen/header/mdns.rb +9 -2
- data/lib/packetgen/header/mld.rb +11 -9
- data/lib/packetgen/header/mldv2/mcast_address_record.rb +6 -1
- data/lib/packetgen/header/mldv2/mlq.rb +8 -8
- data/lib/packetgen/header/mldv2/mlr.rb +4 -4
- data/lib/packetgen/header/mldv2.rb +1 -1
- data/lib/packetgen/header/ospfv2/db_description.rb +10 -10
- data/lib/packetgen/header/ospfv2/hello.rb +11 -10
- data/lib/packetgen/header/ospfv2/ls_ack.rb +5 -6
- data/lib/packetgen/header/ospfv2/ls_request.rb +7 -6
- data/lib/packetgen/header/ospfv2/ls_update.rb +7 -7
- data/lib/packetgen/header/ospfv2/lsa.rb +33 -10
- data/lib/packetgen/header/ospfv2/lsa_header.rb +3 -2
- data/lib/packetgen/header/ospfv2.rb +31 -26
- data/lib/packetgen/header/ospfv3/db_description.rb +12 -13
- data/lib/packetgen/header/ospfv3/hello.rb +10 -9
- data/lib/packetgen/header/ospfv3/ipv6_prefix.rb +6 -2
- data/lib/packetgen/header/ospfv3/ls_ack.rb +5 -6
- data/lib/packetgen/header/ospfv3/ls_request.rb +10 -10
- data/lib/packetgen/header/ospfv3/ls_update.rb +7 -7
- data/lib/packetgen/header/ospfv3/lsa.rb +23 -9
- data/lib/packetgen/header/ospfv3/lsa_header.rb +3 -2
- data/lib/packetgen/header/ospfv3.rb +38 -34
- data/lib/packetgen/header/sctp/chunk.rb +38 -17
- data/lib/packetgen/header/sctp/error.rb +169 -197
- data/lib/packetgen/header/sctp/padded32.rb +3 -3
- data/lib/packetgen/header/sctp/parameter.rb +85 -132
- data/lib/packetgen/header/sctp.rb +14 -3
- data/lib/packetgen/header/snmp.rb +108 -7
- data/lib/packetgen/header/tcp/option.rb +7 -0
- data/lib/packetgen/header/tcp/options.rb +11 -3
- data/lib/packetgen/header/tcp.rb +33 -26
- data/lib/packetgen/header/tftp.rb +16 -10
- data/lib/packetgen/header/udp.rb +15 -13
- data/lib/packetgen/header.rb +19 -13
- data/lib/packetgen/headerable.rb +9 -3
- data/lib/packetgen/inspect.rb +2 -7
- data/lib/packetgen/packet.rb +94 -36
- data/lib/packetgen/pcapng/block.rb +2 -1
- data/lib/packetgen/pcapng/file.rb +41 -14
- data/lib/packetgen/pcapng/idb.rb +2 -1
- data/lib/packetgen/pcapng/shb.rb +2 -1
- data/lib/packetgen/pcapng/spb.rb +1 -1
- data/lib/packetgen/pcapng.rb +2 -0
- data/lib/packetgen/proto.rb +4 -0
- data/lib/packetgen/unknown_packet.rb +3 -3
- data/lib/packetgen/utils.rb +2 -1
- data/lib/packetgen/version.rb +1 -1
- data/lib/packetgen.rb +8 -2
- metadata +4 -4
@@ -11,18 +11,18 @@ module PacketGen
|
|
11
11
|
class DNS
|
12
12
|
# @!parse
|
13
13
|
# # DNS option is a TLV object:
|
14
|
-
# # * {#code} is a
|
15
|
-
# # *
|
16
|
-
# # * {#data} is a
|
14
|
+
# # * {#code} is a BinStruct::Int16,
|
15
|
+
# # * +#length+ is a BinStruct::Int16,
|
16
|
+
# # * {#data} is a BinStruct::String.
|
17
17
|
# #
|
18
18
|
# # @since 1.3.0
|
19
|
-
# # @since 3.1.0 defined with
|
19
|
+
# # @since 3.1.0 defined with BinStruct::AbstractTLV
|
20
20
|
# # @!parse class Option < BinStruct::AbstractTLV; end
|
21
21
|
# # @!attribute code
|
22
|
-
# # Alias for
|
22
|
+
# # Alias for +#type+
|
23
23
|
# # @return [Integer]
|
24
24
|
# # @!attribute data
|
25
|
-
# # Alias for
|
25
|
+
# # Alias for +#value+
|
26
26
|
# # @return [BinStruct::String]
|
27
27
|
# class Option < BinStruct::AbstractTLV; end
|
28
28
|
# @private
|
@@ -30,7 +30,7 @@ module PacketGen
|
|
30
30
|
length_class: BinStruct::Int16,
|
31
31
|
aliases: { code: :type, data: :value })
|
32
32
|
|
33
|
-
# Array of {Option}.
|
33
|
+
# Array of {Option}s.
|
34
34
|
# @since 3.1.1
|
35
35
|
class ArrayOfOptions < BinStruct::Array
|
36
36
|
set_of Option
|
@@ -25,14 +25,14 @@ module PacketGen
|
|
25
25
|
# @param [Question] q
|
26
26
|
# @return [Question]
|
27
27
|
|
28
|
-
# Read Question section from a string
|
28
|
+
# Read Question section from a binary string
|
29
29
|
# @param [String] str binary string
|
30
30
|
# @return [QDSection] self
|
31
31
|
def read(str)
|
32
32
|
clear
|
33
33
|
return self if str.nil?
|
34
34
|
|
35
|
-
|
35
|
+
str = str.b unless str.encoding == Encoding::ASCII_8BIT
|
36
36
|
while !str.empty? && (self.size < @counter.to_i)
|
37
37
|
question = Question.new(@dns).read(str)
|
38
38
|
str.slice!(0, question.sz)
|
@@ -21,13 +21,13 @@ module PacketGen
|
|
21
21
|
end
|
22
22
|
|
23
23
|
# Read RR section from a string
|
24
|
-
# @param [String] str binary string
|
24
|
+
# @param [String] str binary binary string
|
25
25
|
# @return [RRSection] self
|
26
26
|
def read(str)
|
27
27
|
clear
|
28
28
|
return self if str.nil?
|
29
29
|
|
30
|
-
|
30
|
+
str = str.b unless str.encoding == Encoding::BINARY
|
31
31
|
while !str.empty? && (self.size < @counter.to_i)
|
32
32
|
rr = RR.new(@dns).read(str)
|
33
33
|
rr = OPT.new(@dns).read(str) if rr.type?('OPT')
|
data/lib/packetgen/header/dns.rb
CHANGED
@@ -33,70 +33,77 @@ module PacketGen
|
|
33
33
|
# * {#ns}, authoritary section,
|
34
34
|
# * {#ar}, additional information section.
|
35
35
|
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
36
|
+
# @example Create a DNS header
|
37
|
+
# # standalone
|
38
|
+
# dns = PacketGen::Header::DNS.new
|
39
|
+
# # in a IP packet
|
40
|
+
# pkt = PacketGen.gen('IP').add('UDP').add('DNS')
|
41
|
+
# # access to DNS header
|
42
|
+
# pkt.dns.class # => PacketGen::Header::DNS
|
43
43
|
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
44
|
+
# @example DNS attributes
|
45
|
+
# dns = PacketGen::Header::DNS.new
|
46
|
+
# dns.id = 0x1234
|
47
|
+
# dns.qr = false
|
48
|
+
# # opcode may be set as an Integer (all values are possible)
|
49
|
+
# # or as a String (only keys from PacketGen::Header::DNS::OPCODES)
|
50
|
+
# dns.opcode = 0xe # set as integer, value not defined in standard
|
51
|
+
# dns.opcode = 'query' # set as string
|
52
|
+
# # Set flags
|
53
|
+
# dns.aa = dns.tc = dns.rd = dns.ra = false
|
54
|
+
# # rcode may be set as an Integer (all values are possible)
|
55
|
+
# # or as a String (only keys from PacketGen::Header::DNS::RCODES)
|
56
|
+
# dns.rcode = 11
|
57
|
+
# dns.rcode = 'refused'
|
58
|
+
# # Section counts may be set by hand. They also be set automatically when adding
|
59
|
+
# # an element to a section.
|
60
|
+
# dns.qdcount = 123
|
61
|
+
# dns.ancount = 0x1234
|
62
|
+
# dns.nscount = 1
|
63
|
+
# dns.arcount = 0
|
64
|
+
# # Access to DNS sections:
|
65
|
+
# dns.qd.class # => PacketGen::Header::DNS::QDSection
|
66
|
+
# dns.an.class # => PacketGen::Header::DNS::RRSection
|
67
|
+
# dns.ns.class # => PacketGen::Header::DNS::RRSection
|
68
|
+
# dns.ar.class # => PacketGen::Header::DNS::RRSection
|
65
69
|
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
70
|
+
# @example Add a question to DNS question section
|
71
|
+
# dns = PacketGen::Header::DNS.new
|
72
|
+
# # add a question about example.net IP address. Increment qdcount
|
73
|
+
# dns.qd << PacketGen::Header::DNS::Question.new(dns, name: 'example.net')
|
74
|
+
# # or
|
75
|
+
# dns.qd << { rtype: 'Question', name: 'example.net' }
|
76
|
+
# dns.qdcount #=> 2
|
77
|
+
# # add a question about example.net IPv6 address. Dot not modify qdcount
|
78
|
+
# dns.qd.push(PacketGen::Header::DNS::Question.new(dns, name: 'example.net', type: 'AAAA'))
|
79
|
+
# # or
|
80
|
+
# dns.qd.push(rtype: 'Question', name: 'example.net', type: 'AAAA')
|
81
|
+
# dns.qdcount #=> 2
|
77
82
|
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
83
|
+
# @example Add a ressource record to a DNS section
|
84
|
+
# dns = PacketGen::Header::DNS.new
|
85
|
+
# # add a RR to answer section. Increment ancount
|
86
|
+
# dns.an << PacketGen::Header::DNS::RR.new(dns, name: 'example.net', rdata: IPAddr.new('1.2.3.4').hton)
|
87
|
+
# # or
|
88
|
+
# dns.an << { rtype: 'RR', name: 'example.net', rdata: IPAddr.new('1.2.3.4').hton }
|
89
|
+
# dns.ancount #=> 2
|
90
|
+
# # add a RR to NS section. Dot not modify nscount
|
91
|
+
# rdata = PacketGen::Header::DNS::Name.new(dns: dns).from_human('dns.net')
|
92
|
+
# dns.ns.push(PacketGen::Header::DNS::RR.new(dns, name: 'example.net', type: 'NS', rdata: rdata))
|
93
|
+
# # or
|
94
|
+
# dns.ns.push(rtype: 'RR', name: 'example.net', type: 'NS', rdata: rdata)
|
95
|
+
# dns.nscount #=> 0
|
90
96
|
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
97
|
+
# @example Extended DNS (EDNS(0)) options
|
98
|
+
# dns = PacketGen::Header::DNS.new
|
99
|
+
# # Add an OPT to ar section
|
100
|
+
# dns.ar << PacketGen::Header::DNS::OPT.new(dns, udp_size: 4096, ext_rcode: 43)
|
101
|
+
# # or
|
102
|
+
# dns.ar << { rtype: 'OPT', udp_size: 4096, ext_rcode: 43 }
|
103
|
+
# # add an option to OPT record
|
104
|
+
# dns.ar.last.options << PacketGen::Header::DNS::Option.new(code: 48, data: '12')
|
105
|
+
# # or
|
106
|
+
# dns.ar.last.options << { code: 48, data: '12' }
|
100
107
|
# @author Sylvain Daubert
|
101
108
|
# @since 1.3.0
|
102
109
|
class DNS < Base
|
@@ -140,6 +147,7 @@ module PacketGen
|
|
140
147
|
}.freeze
|
141
148
|
|
142
149
|
# @!attribute id
|
150
|
+
# 16-bit identifier to match up replies and queries
|
143
151
|
# @return [Integer]
|
144
152
|
define_attr :id, BinStruct::Int16
|
145
153
|
# @!attribute u16
|
@@ -166,27 +174,35 @@ module PacketGen
|
|
166
174
|
undef opcode=, rcode=
|
167
175
|
|
168
176
|
# @!attribute qdcount
|
177
|
+
# Number of entries in {#qd question section}
|
169
178
|
# @return [Integer]
|
170
179
|
define_attr :qdcount, BinStruct::Int16
|
171
180
|
# @!attribute ancount
|
181
|
+
# Number of ressource recors in {#an answer section}
|
172
182
|
# @return [Integer]
|
173
183
|
define_attr :ancount, BinStruct::Int16
|
174
184
|
# @!attribute nscount
|
185
|
+
# Number of name resource recors in {#ns authority records section}
|
175
186
|
# @return [Integer]
|
176
187
|
define_attr :nscount, BinStruct::Int16
|
177
188
|
# @!attribute arcount
|
189
|
+
# Number of ressources recors in {#ar additional records section}
|
178
190
|
# @return [Integer]
|
179
191
|
define_attr :arcount, BinStruct::Int16
|
180
192
|
# @!attribute qd
|
193
|
+
# Question section
|
181
194
|
# @return [QDSection]
|
182
195
|
define_attr :qd, QDSection, builder: ->(h, t) { t.new(h, h[:qdcount]) }
|
183
196
|
# @!attribute an
|
197
|
+
# Answer section
|
184
198
|
# @return [RRSection]
|
185
199
|
define_attr :an, RRSection, builder: ->(h, t) { t.new(h, h[:ancount]) }
|
186
200
|
# @!attribute ns
|
201
|
+
# Authority records section
|
187
202
|
# @return [RRSection]
|
188
203
|
define_attr :ns, RRSection, builder: ->(h, t) { t.new(h, h[:nscount]) }
|
189
204
|
# @!attribute ar
|
205
|
+
# Additional record section
|
190
206
|
# @return [RRSection]
|
191
207
|
define_attr :ar, RRSection, builder: ->(h, t) { t.new(h, h[:arcount]) }
|
192
208
|
|
@@ -12,16 +12,16 @@ module PacketGen
|
|
12
12
|
class Dot11
|
13
13
|
# IEEE 802.11 control frame header
|
14
14
|
#
|
15
|
-
# This class
|
15
|
+
# This class makes a {Dot11} header with {#type} set to +1+
|
16
16
|
# (control frame).
|
17
17
|
#
|
18
18
|
# A IEEE 802.11 control header consists of:
|
19
|
-
# * a {#frame_ctrl} (
|
20
|
-
# * a {#id}/duration (
|
19
|
+
# * a {#frame_ctrl} (+BinStruct::Int16+),
|
20
|
+
# * a {#id}/duration (+BinStruct::Int16le+),
|
21
21
|
# * a {#mac1} ({Eth::MacAddr}).
|
22
22
|
# * sometimes a {#mac2} ({Eth::MacAddr}),
|
23
|
-
# * a {#body} (a
|
24
|
-
# * and a Frame check sequence ({#fcs}, of type
|
23
|
+
# * a {#body} (a +BinStruct::String+ or another {Headerable} class),
|
24
|
+
# * and a Frame check sequence ({#fcs}, of type +BinStruct::Int32le+).
|
25
25
|
# @author Sylvain Daubert
|
26
26
|
class Control < Dot11
|
27
27
|
# Control subtypes
|
@@ -16,15 +16,16 @@ module PacketGen
|
|
16
16
|
# (data frame).
|
17
17
|
#
|
18
18
|
# A IEEE 802.11 data header consists of:
|
19
|
-
# * a {#frame_ctrl} (
|
20
|
-
# * a {#id}/duration (
|
19
|
+
# * a {#frame_ctrl} (+BinStruct::Int16+),
|
20
|
+
# * a {#id}/duration (+BinStruct::Int16le+),
|
21
|
+
# * a {#mac1} ({Eth::MacAddr}),
|
21
22
|
# * a {#mac2} ({Eth::MacAddr}),
|
22
23
|
# * a {#mac3} ({Eth::MacAddr}),
|
23
|
-
# * a {#sequence_ctrl} (
|
24
|
+
# * a {#sequence_ctrl} (+BinStruct::Int16+),
|
24
25
|
# * sometimes a {#mac4} ({Eth::MacAddr}),
|
25
|
-
# * sometimes a {#qos_ctrl} (
|
26
|
-
# * a {#body} (a
|
27
|
-
# * and a Frame check sequence ({#fcs}, of type
|
26
|
+
# * sometimes a {#qos_ctrl} (+BinStruct::Int16+),
|
27
|
+
# * a {#body} (a +BinStruct::String+ or another {Headerable} class),
|
28
|
+
# * and a Frame check sequence ({#fcs}, of type +BinStruct::Int32le+).
|
28
29
|
# @author Sylvain Daubert
|
29
30
|
class Data < Dot11
|
30
31
|
# @param [Hash] options
|
@@ -65,14 +66,14 @@ module PacketGen
|
|
65
66
|
self
|
66
67
|
end
|
67
68
|
|
68
|
-
# Get destination MAC address
|
69
|
+
# Get destination MAC address. {#from_ds} and {#to_ds} must be set before using these method.
|
69
70
|
# @return [String]
|
70
71
|
def dst
|
71
72
|
_src_mac, dst_mac = src_dst_from_mac
|
72
73
|
self.send(dst_mac)
|
73
74
|
end
|
74
75
|
|
75
|
-
# Set destination MAC address
|
76
|
+
# Set destination MAC address. {#from_ds} and {#to_ds} must be set before using these method.
|
76
77
|
# @param [String] mac MAC address to set
|
77
78
|
# @return [String]
|
78
79
|
def dst=(mac)
|
@@ -80,14 +81,14 @@ module PacketGen
|
|
80
81
|
self.send(:"#{dst_mac}=", mac)
|
81
82
|
end
|
82
83
|
|
83
|
-
# Get source MAC address
|
84
|
+
# Get source MAC address. {#from_ds} and {#to_ds} must be set before using these method.
|
84
85
|
# @return [String]
|
85
86
|
def src
|
86
87
|
src_mac, = src_dst_from_mac
|
87
88
|
self.send(src_mac)
|
88
89
|
end
|
89
90
|
|
90
|
-
# Set source MAC address
|
91
|
+
# Set source MAC address. {#from_ds} and {#to_ds} must be set before using these method.
|
91
92
|
# @param [String] mac MAC address to set
|
92
93
|
# @return [String]
|
93
94
|
def src=(mac)
|
@@ -15,7 +15,7 @@ module PacketGen
|
|
15
15
|
# #
|
16
16
|
# # An {Element} is a piece of data contained in a Dot11 management frame.
|
17
17
|
# # @since 1.4.0
|
18
|
-
# # @since 3.1.0 subclass of
|
18
|
+
# # @since 3.1.0 subclass of +BinStruct::AbstractTLV+
|
19
19
|
# class Element < BinStruct::AbstractTLV; end
|
20
20
|
# @private
|
21
21
|
Element = BinStruct::AbstractTLV.create
|
@@ -16,28 +16,31 @@ module PacketGen
|
|
16
16
|
# (management frame).
|
17
17
|
#
|
18
18
|
# A IEEE 802.11 management header consists of:
|
19
|
-
# * a {#frame_ctrl} (
|
20
|
-
# * a {#id}/duration (
|
19
|
+
# * a {#frame_ctrl} (+BinStruct::Int16+),
|
20
|
+
# * a {#id}/duration (+BinStruct::Int16le+),
|
21
21
|
# * a {#mac1} ({Eth::MacAddr}).
|
22
22
|
# * a {#mac2} ({Eth::MacAddr}),
|
23
23
|
# * a {#mac3} ({Eth::MacAddr}),
|
24
|
-
# * a {#sequence_ctrl} (
|
25
|
-
# * a {#body} (a
|
26
|
-
# * and a Frame check sequence ({#fcs}, of type
|
24
|
+
# * a {#sequence_ctrl} (+BinStruct::Int16+),
|
25
|
+
# * a {#body} (a +BinStruct::String+ or another {Headerable} class),
|
26
|
+
# * and a Frame check sequence ({#fcs}, of type +BinStruct::Int32le+).
|
27
27
|
#
|
28
28
|
# Management frames should be constructed with more headers from
|
29
|
-
# {SubMngt} subclasses.
|
29
|
+
# {SubMngt} subclasses. Some frames also need to have {Element}.
|
30
30
|
#
|
31
|
-
#
|
31
|
+
# @example Build a {DeAuth} frame:
|
32
32
|
# PacketGen.gen('Dot11::Management').add('Dot11::DeAuth')
|
33
33
|
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
# pkt.dot11_beacon.
|
40
|
-
# pkt.dot11_beacon.
|
34
|
+
# @example a {Beacon} frame with elements:
|
35
|
+
# bssid = '00:01:02:03:04:05'
|
36
|
+
# pkt = PacketGen.gen('Dot11::Management', mac1: 'ff:ff:ff:ff:ff:ff', mac2: bssid, mac3: bssid)
|
37
|
+
# .add('Dot11::Beacon')
|
38
|
+
# # Directly add elements to Beacon
|
39
|
+
# pkt.dot11_beacon.elements << { type: 'SSID', value: "SSIDSSID" }
|
40
|
+
# pkt.dot11_beacon.elements << { type: 'Rates', value: "\x82\x84\x8b\x96\x12\x24\x48\x6c" }
|
41
|
+
# # Add elements to beacon through management header
|
42
|
+
# pkt.dot11_management.add_element(type: 'DSset', value: "\x06")
|
43
|
+
# pkt.dot11_management.add_element(type: 'TIM', value: "\x00\x01\x00\x00")
|
41
44
|
# @author Sylvain Daubert
|
42
45
|
class Management < Dot11
|
43
46
|
# @param [Hash] options
|
@@ -48,7 +51,7 @@ module PacketGen
|
|
48
51
|
define_applicable_attributes
|
49
52
|
end
|
50
53
|
|
51
|
-
# Add an {Element}
|
54
|
+
# Add an {Element} to header in body (for example, a {Dot11::Beacon})
|
52
55
|
# @param [Integer,String] type element type
|
53
56
|
# @param [Object] value element value
|
54
57
|
# @return [self]
|
@@ -19,6 +19,7 @@ module PacketGen
|
|
19
19
|
# may be accessed through {#elements}.
|
20
20
|
# @author Sylvain Daubert
|
21
21
|
class SubMngt < Base
|
22
|
+
# Elements of submngt header
|
22
23
|
# @return [Array<Element>]
|
23
24
|
define_attr :elements, ArrayOfElements
|
24
25
|
end
|
@@ -28,8 +29,8 @@ module PacketGen
|
|
28
29
|
# Specialize {Dot11::Management} with +subtype+ set to 0.
|
29
30
|
#
|
30
31
|
# Add fields:
|
31
|
-
# * {#cap} (
|
32
|
-
# * {#listen_interval} (
|
32
|
+
# * {#cap} (+BinStruct::Int16le+),
|
33
|
+
# * {#listen_interval} (+BinStruct::Int16le+).
|
33
34
|
# @author Sylvain Daubert
|
34
35
|
class AssoReq < SubMngt
|
35
36
|
# @!attribute cap
|
@@ -47,9 +48,9 @@ module PacketGen
|
|
47
48
|
# Specialize {Dot11::Management} with +subtype+ set to 1.
|
48
49
|
#
|
49
50
|
# Add fields:
|
50
|
-
# * {#cap} (
|
51
|
-
# * {#status} (
|
52
|
-
# * {#aid} (
|
51
|
+
# * {#cap} (+BinStruct::Int16le+),
|
52
|
+
# * {#status} (+BinStruct::Int16le+),
|
53
|
+
# * {#aid} (+BinStruct::Int16le+).
|
53
54
|
# @author Sylvain Daubert
|
54
55
|
class AssoResp < SubMngt
|
55
56
|
# @!attribute cap
|
@@ -70,8 +71,8 @@ module PacketGen
|
|
70
71
|
# Specialize {Dot11::Management} with +subtype+ set to 2.
|
71
72
|
#
|
72
73
|
# Add fields:
|
73
|
-
# * {#cap} (
|
74
|
-
# * {#listen_interval} (
|
74
|
+
# * {#cap} (+BinStruct::Int16le+),
|
75
|
+
# * {#listen_interval} (+BinStruct::Int16le+),
|
75
76
|
# * {#current_ap} ({Eth::MacAddr}).
|
76
77
|
# @author Sylvain Daubert
|
77
78
|
class ReAssoReq < AssoReq
|
@@ -87,9 +88,9 @@ module PacketGen
|
|
87
88
|
# Specialize {Dot11::Management} with +subtype+ set to 3.
|
88
89
|
#
|
89
90
|
# Add fields:
|
90
|
-
# * {#cap} (
|
91
|
-
# * {#status} (
|
92
|
-
# * {#aid} (
|
91
|
+
# * {#cap} (+BinStruct::Int16le+),
|
92
|
+
# * {#status} (+BinStruct::Int16le+),
|
93
|
+
# * {#aid} (+BinStruct::Int16le+).
|
93
94
|
# @author Sylvain Daubert
|
94
95
|
class ReAssoResp < AssoResp
|
95
96
|
end
|
@@ -112,9 +113,9 @@ module PacketGen
|
|
112
113
|
# Specialize {Dot11::Management} with +subtype+ set to 5.
|
113
114
|
#
|
114
115
|
# Add fields:
|
115
|
-
# * {#timestamp} (
|
116
|
-
# * {#beacon_interval} (
|
117
|
-
# * {#cap} (
|
116
|
+
# * {#timestamp} (+BinStruct::Int64le+),
|
117
|
+
# * {#beacon_interval} (+BinStruct::Int16le+),
|
118
|
+
# * {#cap} (+BinStruct::Int16le+).
|
118
119
|
# @author Sylvain Daubert
|
119
120
|
class ProbeResp < SubMngt
|
120
121
|
# @!attribute timestamp
|
@@ -135,9 +136,9 @@ module PacketGen
|
|
135
136
|
# Specialize {Dot11::Management} with +subtype+ set to 8.
|
136
137
|
#
|
137
138
|
# Add fields:
|
138
|
-
# * {#timestamp} (
|
139
|
-
# * {#interval} (
|
140
|
-
# * {#cap} (
|
139
|
+
# * {#timestamp} (+BinStruct::Int64le+),
|
140
|
+
# * {#interval} (+BinStruct::Int16le+),
|
141
|
+
# * {#cap} (+BinStruct::Int16le+).
|
141
142
|
# @author Sylvain Daubert
|
142
143
|
class Beacon < SubMngt
|
143
144
|
# @!attribute timestamp
|
@@ -168,7 +169,7 @@ module PacketGen
|
|
168
169
|
# Specialize {Dot11::Management} with +subtype+ set to 10.
|
169
170
|
#
|
170
171
|
# Add fields:
|
171
|
-
# * {#reason} (
|
172
|
+
# * {#reason} (+BinStruct::Int16le+).
|
172
173
|
# @author Sylvain Daubert
|
173
174
|
class Disas < SubMngt
|
174
175
|
# @!attribute reason
|
@@ -183,9 +184,9 @@ module PacketGen
|
|
183
184
|
# Specialize {Dot11::Management} with +subtype+ set to 11.
|
184
185
|
#
|
185
186
|
# Add fields:
|
186
|
-
# * {#algo} (
|
187
|
-
# * {#seqnum} (
|
188
|
-
# * {#status} (
|
187
|
+
# * {#algo} (+BinStruct::Int16le+),
|
188
|
+
# * {#seqnum} (+BinStruct::Int16le+),
|
189
|
+
# * {#status} (+BinStruct::Int16le+).
|
189
190
|
# @author Sylvain Daubert
|
190
191
|
class Auth < SubMngt
|
191
192
|
# @!attribute algo
|
@@ -206,7 +207,7 @@ module PacketGen
|
|
206
207
|
# Specialize {Dot11::Management} with +subtype+ set to 12.
|
207
208
|
#
|
208
209
|
# Add fields:
|
209
|
-
# * {#reason} (
|
210
|
+
# * {#reason} (+BinStruct::Int16le+).
|
210
211
|
# @author Sylvain Daubert
|
211
212
|
class DeAuth < SubMngt
|
212
213
|
# @!attribute reason
|