packetgen 3.1.3 → 3.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/bin/pgconsole +1 -0
- data/lib/packetgen.rb +33 -4
- data/lib/packetgen/capture.rb +51 -28
- data/lib/packetgen/config.rb +17 -11
- data/lib/packetgen/deprecation.rb +33 -7
- data/lib/packetgen/header.rb +2 -9
- data/lib/packetgen/header/arp.rb +2 -2
- data/lib/packetgen/header/asn1_base.rb +2 -2
- data/lib/packetgen/header/base.rb +70 -74
- data/lib/packetgen/header/bootp.rb +3 -3
- data/lib/packetgen/header/dhcp.rb +2 -2
- data/lib/packetgen/header/dhcp/option.rb +2 -2
- data/lib/packetgen/header/dhcp/options.rb +2 -2
- data/lib/packetgen/header/dhcpv6.rb +12 -12
- data/lib/packetgen/header/dhcpv6/duid.rb +11 -5
- data/lib/packetgen/header/dhcpv6/option.rb +8 -16
- data/lib/packetgen/header/dhcpv6/options.rb +2 -2
- data/lib/packetgen/header/dhcpv6/relay.rb +2 -2
- data/lib/packetgen/header/dns.rb +9 -9
- data/lib/packetgen/header/dns/name.rb +20 -9
- data/lib/packetgen/header/dns/opt.rb +2 -2
- data/lib/packetgen/header/dns/option.rb +2 -2
- data/lib/packetgen/header/dns/qdsection.rb +3 -3
- data/lib/packetgen/header/dns/question.rb +37 -35
- data/lib/packetgen/header/dns/rr.rb +3 -3
- data/lib/packetgen/header/dns/rrsection.rb +2 -2
- data/lib/packetgen/header/dot11.rb +30 -51
- data/lib/packetgen/header/dot11/control.rb +5 -5
- data/lib/packetgen/header/dot11/data.rb +11 -7
- data/lib/packetgen/header/dot11/element.rb +16 -16
- data/lib/packetgen/header/dot11/management.rb +2 -2
- data/lib/packetgen/header/dot11/sub_mngt.rb +2 -12
- data/lib/packetgen/header/dot1q.rb +2 -2
- data/lib/packetgen/header/dot1x.rb +7 -20
- data/lib/packetgen/header/eap.rb +30 -33
- data/lib/packetgen/header/eap/fast.rb +2 -2
- data/lib/packetgen/header/eap/md5.rb +2 -2
- data/lib/packetgen/header/eap/tls.rb +2 -2
- data/lib/packetgen/header/eap/ttls.rb +2 -2
- data/lib/packetgen/header/eth.rb +13 -11
- data/lib/packetgen/header/gre.rb +2 -2
- data/lib/packetgen/header/http.rb +2 -0
- data/lib/packetgen/header/http/headers.rb +6 -4
- data/lib/packetgen/header/http/request.rb +36 -21
- data/lib/packetgen/header/http/response.rb +7 -7
- data/lib/packetgen/header/http/verbs.rb +3 -3
- data/lib/packetgen/header/icmp.rb +2 -2
- data/lib/packetgen/header/icmpv6.rb +2 -2
- data/lib/packetgen/header/igmp.rb +4 -4
- data/lib/packetgen/header/igmpv3.rb +3 -3
- data/lib/packetgen/header/igmpv3/group_record.rb +8 -6
- data/lib/packetgen/header/igmpv3/mq.rb +2 -2
- data/lib/packetgen/header/igmpv3/mr.rb +2 -2
- data/lib/packetgen/header/ip.rb +30 -31
- data/lib/packetgen/header/ip/addr.rb +10 -3
- data/lib/packetgen/header/ip/option.rb +8 -10
- data/lib/packetgen/header/ip/options.rb +3 -5
- data/lib/packetgen/header/ipv6.rb +2 -2
- data/lib/packetgen/header/ipv6/addr.rb +9 -2
- data/lib/packetgen/header/ipv6/extension.rb +2 -2
- data/lib/packetgen/header/ipv6/hop_by_hop.rb +3 -3
- data/lib/packetgen/header/llc.rb +2 -2
- data/lib/packetgen/header/mdns.rb +2 -2
- data/lib/packetgen/header/mld.rb +2 -2
- data/lib/packetgen/header/mldv2.rb +2 -2
- data/lib/packetgen/header/mldv2/mcast_address_record.rb +4 -2
- data/lib/packetgen/header/mldv2/mlq.rb +2 -2
- data/lib/packetgen/header/mldv2/mlr.rb +2 -2
- data/lib/packetgen/header/ospfv2.rb +9 -9
- data/lib/packetgen/header/ospfv2/db_description.rb +2 -2
- data/lib/packetgen/header/ospfv2/hello.rb +2 -2
- data/lib/packetgen/header/ospfv2/ls_ack.rb +2 -2
- data/lib/packetgen/header/ospfv2/ls_request.rb +4 -2
- data/lib/packetgen/header/ospfv2/ls_update.rb +2 -2
- data/lib/packetgen/header/ospfv2/lsa.rb +9 -5
- data/lib/packetgen/header/ospfv2/lsa_header.rb +8 -7
- data/lib/packetgen/header/ospfv3.rb +2 -2
- data/lib/packetgen/header/ospfv3/db_description.rb +2 -2
- data/lib/packetgen/header/ospfv3/hello.rb +2 -2
- data/lib/packetgen/header/ospfv3/ipv6_prefix.rb +4 -2
- data/lib/packetgen/header/ospfv3/ls_ack.rb +2 -2
- data/lib/packetgen/header/ospfv3/ls_request.rb +4 -2
- data/lib/packetgen/header/ospfv3/ls_update.rb +2 -2
- data/lib/packetgen/header/ospfv3/lsa.rb +5 -5
- data/lib/packetgen/header/ospfv3/lsa_header.rb +9 -8
- data/lib/packetgen/header/snmp.rb +33 -29
- data/lib/packetgen/header/tcp.rb +4 -23
- data/lib/packetgen/header/tcp/option.rb +11 -11
- data/lib/packetgen/header/tcp/options.rb +2 -2
- data/lib/packetgen/header/tftp.rb +6 -6
- data/lib/packetgen/header/udp.rb +3 -3
- data/lib/packetgen/headerable.rb +5 -4
- data/lib/packetgen/inject.rb +23 -0
- data/lib/packetgen/inspect.rb +23 -20
- data/lib/packetgen/packet.rb +82 -53
- data/lib/packetgen/pcap.rb +29 -0
- data/lib/packetgen/pcapng.rb +13 -13
- data/lib/packetgen/pcapng/block.rb +26 -13
- data/lib/packetgen/pcapng/epb.rb +25 -22
- data/lib/packetgen/pcapng/file.rb +260 -138
- data/lib/packetgen/pcapng/idb.rb +36 -38
- data/lib/packetgen/pcapng/shb.rb +51 -53
- data/lib/packetgen/pcapng/spb.rb +19 -19
- data/lib/packetgen/pcapng/unknown_block.rb +5 -13
- data/lib/packetgen/pcaprub_wrapper.rb +81 -0
- data/lib/packetgen/proto.rb +2 -2
- data/lib/packetgen/types.rb +3 -0
- data/lib/packetgen/types/abstract_tlv.rb +27 -7
- data/lib/packetgen/types/array.rb +22 -15
- data/lib/packetgen/types/cstring.rb +57 -20
- data/lib/packetgen/types/enum.rb +7 -2
- data/lib/packetgen/types/fieldable.rb +65 -0
- data/lib/packetgen/types/fields.rb +182 -117
- data/lib/packetgen/types/int.rb +18 -6
- data/lib/packetgen/types/int_string.rb +10 -2
- data/lib/packetgen/types/length_from.rb +20 -12
- data/lib/packetgen/types/oui.rb +4 -2
- data/lib/packetgen/types/string.rb +59 -8
- data/lib/packetgen/types/tlv.rb +4 -2
- data/lib/packetgen/utils.rb +4 -4
- data/lib/packetgen/utils/arp_spoofer.rb +2 -2
- data/lib/packetgen/version.rb +3 -3
- metadata +39 -61
- data/.gitignore +0 -13
- data/.rubocop.yml +0 -30
- data/.travis.yml +0 -19
- data/Gemfile +0 -4
- data/Rakefile +0 -21
- data/packetgen.gemspec +0 -36
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
# Bootstrap Protocol, {https://tools.ietf.org/html/rfc951
|
@@ -45,7 +45,7 @@ module PacketGen
|
|
45
45
|
# DHCP opcodes
|
46
46
|
OPCODES = {
|
47
47
|
'BOOTREQUEST' => 1,
|
48
|
-
'BOOTREPLY'
|
48
|
+
'BOOTREPLY' => 2
|
49
49
|
}.freeze
|
50
50
|
|
51
51
|
# @!attribute op
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
# Dynamic Host Configuration Protocol, {https://tools.ietf.org/html/rfc2131
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DHCP
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DHCP
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
# Dynamic Host Configuration Protocol for IPv6, {https://tools.ietf.org/html/rfc3315
|
@@ -55,16 +55,16 @@ module PacketGen
|
|
55
55
|
|
56
56
|
# DHCPv6 message types
|
57
57
|
MESSAGE_TYPES = {
|
58
|
-
'SOLLICIT'
|
59
|
-
'ADVERTISE'
|
60
|
-
'REQUEST'
|
61
|
-
'CONFIRM'
|
62
|
-
'RENEW'
|
63
|
-
'REBIND'
|
64
|
-
'REPLY'
|
65
|
-
'RELEASE'
|
66
|
-
'DECLINE'
|
67
|
-
'RECONFIGURE'
|
58
|
+
'SOLLICIT' => 1,
|
59
|
+
'ADVERTISE' => 2,
|
60
|
+
'REQUEST' => 3,
|
61
|
+
'CONFIRM' => 4,
|
62
|
+
'RENEW' => 5,
|
63
|
+
'REBIND' => 6,
|
64
|
+
'REPLY' => 7,
|
65
|
+
'RELEASE' => 8,
|
66
|
+
'DECLINE' => 9,
|
67
|
+
'RECONFIGURE' => 10,
|
68
68
|
'INFORMATION-REQUEST' => 11
|
69
69
|
}.freeze
|
70
70
|
|
@@ -1,20 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DHCPv6
|
11
11
|
# @abstract Base class for DUID (DHCP Unique ID)
|
12
12
|
# @author Sylvain Daubert
|
13
13
|
class DUID < Types::Fields
|
14
|
+
include Types::Fieldable
|
15
|
+
|
14
16
|
TYPES = {
|
15
17
|
'DUID-LLT' => 1,
|
16
|
-
'DUID-EN'
|
17
|
-
'DUID-LL'
|
18
|
+
'DUID-EN' => 2,
|
19
|
+
'DUID-LL' => 3
|
18
20
|
}.freeze
|
19
21
|
|
20
22
|
# @!attribute type
|
@@ -34,7 +36,7 @@ module PacketGen
|
|
34
36
|
# @param [String] str
|
35
37
|
# @return [DUID]
|
36
38
|
def read(str)
|
37
|
-
if self.
|
39
|
+
if self.instance_of?(DUID)
|
38
40
|
super
|
39
41
|
case type
|
40
42
|
when 1
|
@@ -58,6 +60,8 @@ module PacketGen
|
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
63
|
+
# rubocop:disable Naming/ClassAndModuleCamelCase
|
64
|
+
|
61
65
|
# DUID Based on Link-layer Address Plus Time
|
62
66
|
# @author Sylvain Daubert
|
63
67
|
class DUID_LLT < DUID
|
@@ -140,3 +144,5 @@ module PacketGen
|
|
140
144
|
end
|
141
145
|
end
|
142
146
|
end
|
147
|
+
|
148
|
+
# rubocop:enable Naming/ClassAndModuleCamelCase
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DHCPv6
|
@@ -17,6 +17,8 @@ module PacketGen
|
|
17
17
|
# field to replace it by specific option field(s).
|
18
18
|
# @author Sylvain Daubert
|
19
19
|
class Option < Types::Fields
|
20
|
+
include Types::Fieldable
|
21
|
+
|
20
22
|
# @!attribute type
|
21
23
|
# 16-bit option type
|
22
24
|
# @return [Integer]
|
@@ -55,7 +57,7 @@ module PacketGen
|
|
55
57
|
case options[:type]
|
56
58
|
when Integer
|
57
59
|
klass = Option.subclasses[options[:type]]
|
58
|
-
klass
|
60
|
+
klass&.new(options)
|
59
61
|
when String
|
60
62
|
if DHCPv6.const_defined?(options[:type])
|
61
63
|
klass = DHCPv6.const_get(options[:type])
|
@@ -85,7 +87,7 @@ module PacketGen
|
|
85
87
|
# Get human-readable {#type}
|
86
88
|
# @return [String]
|
87
89
|
def human_type
|
88
|
-
if self.
|
90
|
+
if self.instance_of?(Option)
|
89
91
|
"option#{type}"
|
90
92
|
else
|
91
93
|
self.class.to_s.sub(/.*::/, '')
|
@@ -95,7 +97,7 @@ module PacketGen
|
|
95
97
|
# Get a human-readable string for this option
|
96
98
|
# @return [String]
|
97
99
|
def to_human
|
98
|
-
str = "#{human_type}:"
|
100
|
+
str = +"#{human_type}:"
|
99
101
|
if respond_to?(:human_data) && !human_data.empty?
|
100
102
|
str << human_data
|
101
103
|
elsif !self[:data].nil?
|
@@ -230,17 +232,7 @@ module PacketGen
|
|
230
232
|
|
231
233
|
# @!attribute options
|
232
234
|
# @return [RequestedOptions]
|
233
|
-
define_field :options, RequestedOptions
|
234
|
-
|
235
|
-
# Populate object from +str+
|
236
|
-
# @param [String] str
|
237
|
-
# @return [self]
|
238
|
-
def read(str)
|
239
|
-
self[:type].read str[0, 2]
|
240
|
-
self[:length].read str[2, 2]
|
241
|
-
self[:options].read str[4, self.length]
|
242
|
-
self
|
243
|
-
end
|
235
|
+
define_field :options, RequestedOptions, builder: ->(h, t) { t.new(length_from: h[:length]) }
|
244
236
|
|
245
237
|
# Get human-readable data
|
246
238
|
# @return [String]
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DHCPv6
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DHCPv6
|
data/lib/packetgen/header/dns.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
# This file is part of PacketGen
|
3
5
|
# See https://github.com/sdaubert/packetgen for more informations
|
4
6
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
7
|
# This program is published under MIT license.
|
6
8
|
|
7
|
-
# frozen_string_literal: true
|
8
|
-
|
9
9
|
module PacketGen
|
10
10
|
module Header
|
11
11
|
# DNS: Domain Name Service
|
@@ -120,7 +120,7 @@ module PacketGen
|
|
120
120
|
|
121
121
|
# DNS opcodes
|
122
122
|
OPCODES = {
|
123
|
-
'query'
|
123
|
+
'query' => 0,
|
124
124
|
'iquery' => 1,
|
125
125
|
'status' => 2,
|
126
126
|
'notify' => 4,
|
@@ -129,13 +129,13 @@ module PacketGen
|
|
129
129
|
|
130
130
|
# DNS Response codes
|
131
131
|
RCODES = {
|
132
|
-
'ok'
|
133
|
-
'no-error'
|
134
|
-
'format-error'
|
135
|
-
'server-failure'
|
136
|
-
'name-error'
|
132
|
+
'ok' => 0,
|
133
|
+
'no-error' => 0,
|
134
|
+
'format-error' => 1,
|
135
|
+
'server-failure' => 2,
|
136
|
+
'name-error' => 3,
|
137
137
|
'not-implemented' => 4,
|
138
|
-
'refused'
|
138
|
+
'refused' => 5
|
139
139
|
}.freeze
|
140
140
|
|
141
141
|
# @!attribute id
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DNS
|
@@ -43,28 +43,32 @@ module PacketGen
|
|
43
43
|
self << Types::IntString.new
|
44
44
|
end
|
45
45
|
|
46
|
+
# Clear name
|
47
|
+
# @return [void]
|
48
|
+
def clear
|
49
|
+
super
|
50
|
+
@pointer = nil
|
51
|
+
@pointer_name = nil
|
52
|
+
end
|
53
|
+
|
46
54
|
# Read a sequence of label from a string
|
47
55
|
# @param [String] str binary string
|
48
56
|
# @return [Name] self
|
49
57
|
def read(str)
|
50
|
-
@pointer = nil
|
51
|
-
@pointer_name = nil
|
52
58
|
clear
|
53
59
|
return self if str.nil?
|
54
60
|
|
55
61
|
PacketGen.force_binary str
|
56
62
|
start = 0
|
57
63
|
loop do
|
58
|
-
index = str[start, 2].
|
64
|
+
index = str[start, 2].unpack1('n')
|
59
65
|
if pointer? index
|
60
66
|
# Pointer on another label
|
61
67
|
@pointer = str[start, 2]
|
62
68
|
break
|
63
69
|
else
|
64
|
-
label =
|
65
|
-
label.read(str[start..-1])
|
70
|
+
label = add_label_from(str[start..-1])
|
66
71
|
start += label.sz
|
67
|
-
self << label
|
68
72
|
break if label.length.zero? || str[start..-1].length.zero?
|
69
73
|
end
|
70
74
|
end
|
@@ -101,7 +105,7 @@ module PacketGen
|
|
101
105
|
return nil unless @pointer
|
102
106
|
return @pointer_name if @pointer_name
|
103
107
|
|
104
|
-
index = @pointer.
|
108
|
+
index = @pointer.unpack1('n')
|
105
109
|
mask = ~POINTER_MASK & 0xffff
|
106
110
|
ptr = index & mask
|
107
111
|
name = Name.new
|
@@ -112,6 +116,13 @@ module PacketGen
|
|
112
116
|
def record_from_hash(_hsh)
|
113
117
|
raise NotImplementedError, "not supported by #{self.class}"
|
114
118
|
end
|
119
|
+
|
120
|
+
def add_label_from(str)
|
121
|
+
label = Types::IntString.new
|
122
|
+
label.read(str)
|
123
|
+
self << label
|
124
|
+
label
|
125
|
+
end
|
115
126
|
end
|
116
127
|
end
|
117
128
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
require_relative 'option'
|
9
9
|
|
10
10
|
module PacketGen
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DNS
|
@@ -1,10 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DNS
|
@@ -35,7 +35,7 @@ module PacketGen
|
|
35
35
|
while !str.empty? && (self.size < @counter.to_i)
|
36
36
|
question = Question.new(@dns).read(str)
|
37
37
|
str.slice!(0, question.sz)
|
38
|
-
|
38
|
+
push question
|
39
39
|
end
|
40
40
|
self
|
41
41
|
end
|
@@ -1,56 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# This file is part of PacketGen
|
2
4
|
# See https://github.com/sdaubert/packetgen for more informations
|
3
5
|
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
6
|
# This program is published under MIT license.
|
5
7
|
|
6
|
-
# frozen_string_literal: true
|
7
|
-
|
8
8
|
module PacketGen
|
9
9
|
module Header
|
10
10
|
class DNS
|
11
11
|
# DNS Question
|
12
12
|
# @author Sylvain Daubert
|
13
13
|
class Question < Types::Fields
|
14
|
+
include Types::Fieldable
|
15
|
+
|
14
16
|
# Ressource Record types
|
15
17
|
TYPES = {
|
16
|
-
'A'
|
17
|
-
'NS'
|
18
|
-
'MD'
|
19
|
-
'MF'
|
20
|
-
'CNAME'
|
21
|
-
'SOA'
|
22
|
-
'MB'
|
23
|
-
'MG'
|
24
|
-
'MR'
|
25
|
-
'NULL'
|
26
|
-
'WKS'
|
27
|
-
'PTR'
|
28
|
-
'HINFO'
|
29
|
-
'MINFO'
|
30
|
-
'MX'
|
31
|
-
'TXT'
|
32
|
-
'AAAA'
|
33
|
-
'SRV'
|
34
|
-
'NAPTR'
|
35
|
-
'KX'
|
36
|
-
'CERT'
|
37
|
-
'OPT'
|
38
|
-
'DS'
|
39
|
-
'RRSIG'
|
40
|
-
'NSEC'
|
41
|
-
'DNSKEY'
|
42
|
-
'TKEY'
|
43
|
-
'TSIG'
|
44
|
-
'*'
|
18
|
+
'A' => 1,
|
19
|
+
'NS' => 2,
|
20
|
+
'MD' => 3,
|
21
|
+
'MF' => 4,
|
22
|
+
'CNAME' => 5,
|
23
|
+
'SOA' => 6,
|
24
|
+
'MB' => 7,
|
25
|
+
'MG' => 8,
|
26
|
+
'MR' => 9,
|
27
|
+
'NULL' => 10,
|
28
|
+
'WKS' => 11,
|
29
|
+
'PTR' => 12,
|
30
|
+
'HINFO' => 13,
|
31
|
+
'MINFO' => 14,
|
32
|
+
'MX' => 15,
|
33
|
+
'TXT' => 16,
|
34
|
+
'AAAA' => 28,
|
35
|
+
'SRV' => 33,
|
36
|
+
'NAPTR' => 35,
|
37
|
+
'KX' => 36,
|
38
|
+
'CERT' => 37,
|
39
|
+
'OPT' => 41,
|
40
|
+
'DS' => 43,
|
41
|
+
'RRSIG' => 46,
|
42
|
+
'NSEC' => 47,
|
43
|
+
'DNSKEY' => 48,
|
44
|
+
'TKEY' => 249,
|
45
|
+
'TSIG' => 250,
|
46
|
+
'*' => 255
|
45
47
|
}.freeze
|
46
48
|
|
47
49
|
# Ressource Record classes
|
48
50
|
CLASSES = {
|
49
|
-
'IN'
|
50
|
-
'CH'
|
51
|
-
'HS'
|
51
|
+
'IN' => 1,
|
52
|
+
'CH' => 3,
|
53
|
+
'HS' => 4,
|
52
54
|
'NONE' => 254,
|
53
|
-
'*'
|
55
|
+
'*' => 255
|
54
56
|
}.freeze
|
55
57
|
|
56
58
|
# @!attribute name
|