packetgen 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/README.md +4 -0
- data/lib/packetgen.rb +1 -0
- data/lib/packetgen/config.rb +11 -6
- data/lib/packetgen/header/ike/auth.rb +5 -1
- data/lib/packetgen/header/ike/cert.rb +5 -0
- data/lib/packetgen/header/ike/certreq.rb +5 -0
- data/lib/packetgen/header/ike/id.rb +5 -0
- data/lib/packetgen/header/ike/ke.rb +6 -1
- data/lib/packetgen/header/ike/nonce.rb +5 -0
- data/lib/packetgen/header/ike/ts.rb +7 -4
- data/lib/packetgen/header/ike/vendor_id.rb +5 -0
- data/lib/packetgen/inspect.rb +5 -0
- data/lib/packetgen/packet.rb +3 -3
- data/lib/packetgen/proto.rb +42 -0
- data/lib/packetgen/types.rb +5 -1
- data/lib/packetgen/version.rb +1 -1
- data/packetgen.gemspec +1 -2
- metadata +4 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59b1fc19fea5c7400e6d70e01a83ca68351e646b
|
4
|
+
data.tar.gz: b9ef7b691f66d23d763e7cf03f98aab5314924b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddf2bf621ae0ddd6e30d4f1ee25f24b575d4b42b994203baa135cc58d0fac3ecce8c1549966faa381a8049c0585cd8517dc358c0e2399dc0afab1778121ef77
|
7
|
+
data.tar.gz: a02f287f900e5f7d21e845fd26c86b146375a87babc61252f4c73cf63c306ff403f0fef8220594d4b8e0d17a9f5f71bb6f2dbef7e61e49c1cc1472aed2180d63
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -148,6 +148,10 @@ classes. A special `config` object gives local network configuration:
|
|
148
148
|
|
149
149
|
If `pry` gem is installed, it is used as backend for `pgconsole`, else IRB is used.
|
150
150
|
|
151
|
+
## API documentation
|
152
|
+
|
153
|
+
see http://www.rubydoc.info/gems/packetgen
|
154
|
+
|
151
155
|
## Pull requests?
|
152
156
|
|
153
157
|
yes
|
data/lib/packetgen.rb
CHANGED
data/lib/packetgen/config.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# This file is part of PacketGen
|
2
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
3
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
|
+
# This program is published under MIT license.
|
5
|
+
|
1
6
|
require 'network_interface'
|
2
7
|
require 'socket'
|
3
8
|
|
@@ -5,24 +10,24 @@ module PacketGen
|
|
5
10
|
|
6
11
|
# Config class to provide +config+ object to pgconsole
|
7
12
|
# @author Sylvain Daubert
|
8
|
-
# @author Kent 'picat' Gruber
|
13
|
+
# @author Kent 'picat' Gruber
|
9
14
|
class Config
|
10
15
|
|
11
16
|
# Default network interface
|
12
|
-
# @return [String]
|
17
|
+
# @return [String]
|
13
18
|
attr_reader :iface
|
14
19
|
# MAC address of default interface
|
15
|
-
# @return [String]
|
20
|
+
# @return [String]
|
16
21
|
attr_reader :hwaddr
|
17
22
|
# IP address of default interface
|
18
|
-
# @return [String]
|
23
|
+
# @return [String]
|
19
24
|
attr_reader :ipaddr
|
20
25
|
# IPv6 address of default interface
|
21
|
-
# @return [String]
|
26
|
+
# @return [String]
|
22
27
|
attr_reader :ip6addr
|
23
28
|
|
24
29
|
# Create a configuration object. If +iface+ is not set,
|
25
|
-
# attempt to find it automatically or default to the
|
30
|
+
# attempt to find it automatically or default to the
|
26
31
|
# first available loopback interface.
|
27
32
|
# @param [String,nil] iface
|
28
33
|
def initialize(iface=nil)
|
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
@@ -194,4 +199,3 @@ module PacketGen
|
|
194
199
|
end
|
195
200
|
end
|
196
201
|
end
|
197
|
-
|
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
@@ -1,8 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
5
|
-
|
10
|
+
|
6
11
|
# This class handles Key Exchange payloads, as defined in RFC 7296 §3.4
|
7
12
|
#
|
8
13
|
# A KE payload contains a generic payload header (see {Payload}) and some
|
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
3
6
|
|
4
7
|
module PacketGen
|
5
8
|
module Header
|
@@ -105,10 +108,10 @@ module PacketGen
|
|
105
108
|
# @return [Integer]
|
106
109
|
def protocol=(value)
|
107
110
|
protocol = case value
|
108
|
-
|
111
|
+
when Integer
|
109
112
|
value
|
110
113
|
else
|
111
|
-
|
114
|
+
Proto.getprotobyname(value)
|
112
115
|
end
|
113
116
|
raise ArgumentError, "unknown protocol #{value.inspect}" unless protocol
|
114
117
|
self[:protocol].value = protocol
|
@@ -132,7 +135,7 @@ module PacketGen
|
|
132
135
|
if protocol == 0
|
133
136
|
''
|
134
137
|
else
|
135
|
-
|
138
|
+
Proto.getprotobynumber(protocol) || "#{protocol}"
|
136
139
|
end
|
137
140
|
end
|
138
141
|
|
@@ -1,4 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
|
2
7
|
module PacketGen
|
3
8
|
module Header
|
4
9
|
class IKE
|
data/lib/packetgen/inspect.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# This file is part of PacketGen
|
2
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
3
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
|
+
# This program is published under MIT license.
|
5
|
+
|
1
6
|
module PacketGen
|
2
7
|
|
3
8
|
# {Inspect} module provides methods to help writing +inspect+
|
data/lib/packetgen/packet.rb
CHANGED
@@ -45,7 +45,7 @@ module PacketGen
|
|
45
45
|
# Packet.write 'file.pcapng', packets
|
46
46
|
#
|
47
47
|
# @since 2.0.0
|
48
|
-
#
|
48
|
+
#
|
49
49
|
# Packet accessor has changed. When header class is in a namespace
|
50
50
|
# (for example Dot11::* header classes), to avoid clashes in names, such
|
51
51
|
# accessors are named +namespace_class+. For example {Header::Dot11::Data}
|
@@ -97,7 +97,7 @@ module PacketGen
|
|
97
97
|
capture.packets
|
98
98
|
end
|
99
99
|
|
100
|
-
# Read packets from +filename+.
|
100
|
+
# Read packets from +filename+. Mays read Pcap and Pcap-NG formats.
|
101
101
|
#
|
102
102
|
# For more control, see {PcapNG::File} or {PCAPRUB::Pcap}.
|
103
103
|
# @param [String] filename PcapNG or Pcap file.
|
@@ -111,7 +111,7 @@ module PacketGen
|
|
111
111
|
raise ArgumentError, e unless File.extname(filename.downcase) == '.pcap'
|
112
112
|
packets = []
|
113
113
|
PCAPRUB::Pcap.open_offline(filename).each_packet do |packet|
|
114
|
-
next unless packet = PacketGen.parse(packet.to_s)
|
114
|
+
next unless packet = PacketGen.parse(packet.to_s)
|
115
115
|
packets << packet
|
116
116
|
end
|
117
117
|
packets
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# This file is part of PacketGen
|
3
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
4
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
|
+
# This program is published under MIT license.
|
6
|
+
require 'socket'
|
7
|
+
|
8
|
+
module PacketGen
|
9
|
+
|
10
|
+
# Module handling some helper methods for protocols
|
11
|
+
# @author Sylvain Daubert
|
12
|
+
# @since 2.1.2
|
13
|
+
module Proto
|
14
|
+
|
15
|
+
# @private cache information used by {.getprotobyname} and
|
16
|
+
# {.getprotobynumber}
|
17
|
+
def self.prepare_cache
|
18
|
+
proto_constants = Socket.constants.grep(/IPPROTO_/)
|
19
|
+
@cache = {}
|
20
|
+
proto_constants.each do |const_sym|
|
21
|
+
name = const_sym.to_s[8..-1].downcase
|
22
|
+
number = Socket.const_get(const_sym)
|
23
|
+
@cache[name] = number
|
24
|
+
end
|
25
|
+
end
|
26
|
+
prepare_cache
|
27
|
+
|
28
|
+
# Get protocol number from its name
|
29
|
+
# @param [String] name
|
30
|
+
# @return [Integer,nil] return nil for unknown protocol names
|
31
|
+
def self.getprotobyname(name)
|
32
|
+
@cache[name]
|
33
|
+
end
|
34
|
+
|
35
|
+
# Get protocol name from its number
|
36
|
+
# @param [Integer] number
|
37
|
+
# @return [String,nil] return nil for unknown protocol numbers
|
38
|
+
def self.getprotobynumber(num)
|
39
|
+
@cache.key(num)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/packetgen/types.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
# This file is part of PacketGen
|
2
|
+
# See https://github.com/sdaubert/packetgen for more informations
|
3
|
+
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
|
4
|
+
# This program is published under MIT license.
|
5
|
+
|
1
6
|
module PacketGen
|
2
|
-
|
3
7
|
# Module to group all type definitions
|
4
8
|
module Types
|
5
9
|
end
|
data/lib/packetgen/version.rb
CHANGED
data/packetgen.gemspec
CHANGED
@@ -21,11 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.required_ruby_version = '>= 2.
|
24
|
+
spec.required_ruby_version = '>= 2.2.0'
|
25
25
|
|
26
26
|
spec.add_dependency 'pcaprub', '~>0.12.4'
|
27
27
|
spec.add_dependency 'network_interface'
|
28
|
-
spec.add_dependency 'net-proto', '~>1.2'
|
29
28
|
spec.add_dependency 'rasn1', '~>0.3', '>= 0.3.1'
|
30
29
|
|
31
30
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packetgen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Daubert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pcaprub
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: net-proto
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '1.2'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '1.2'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rasn1
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +203,7 @@ files:
|
|
217
203
|
- lib/packetgen/pcapng/shb.rb
|
218
204
|
- lib/packetgen/pcapng/spb.rb
|
219
205
|
- lib/packetgen/pcapng/unknown_block.rb
|
206
|
+
- lib/packetgen/proto.rb
|
220
207
|
- lib/packetgen/types.rb
|
221
208
|
- lib/packetgen/types/array.rb
|
222
209
|
- lib/packetgen/types/fields.rb
|
@@ -239,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
226
|
requirements:
|
240
227
|
- - ">="
|
241
228
|
- !ruby/object:Gem::Version
|
242
|
-
version: 2.
|
229
|
+
version: 2.2.0
|
243
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
244
231
|
requirements:
|
245
232
|
- - ">="
|