packetgen 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eee53816de9d4f92c8e4eaef9d0e7e366fccdae2
4
- data.tar.gz: a02bf2781972588fadd2f9bf2a94603b81353563
3
+ metadata.gz: 4b5b7c4c6b94e7e5e2323d99a06f687109495539
4
+ data.tar.gz: 363abe5a21f82d8f0fe8f791912109c55d795218
5
5
  SHA512:
6
- metadata.gz: cf215ff8ebb85469fc383a77a4a92f63cb7b384afa7aabec96b1d69efb2fe41dde5f5b44cefacde92c9af0d3c7c4244c6a1f29ed39d45ac3221b2cd9fe485345
7
- data.tar.gz: c0a6cd54c3fb4813bd31e56c718057ad985e8f54d0ae25766d2c445fa0144af2831e34ec7fdc38fe26bb8eedc4be79dbd89a7e99b956463c2a8ef77a5e6a5abd
6
+ metadata.gz: 7782f886a780d71bd9e976bb9185742979f8a5d0a4818a07a9b8c249d4628616db690a4620e80a346ec19357df288c4d2b598804095b648e1373cf9f99c15a73
7
+ data.tar.gz: e8838e0e6ba458472090661066cdd90ac4358f02e4eea53adf4c2c09867ee83c0e4c318241a30f0cb255d91cf393319002b378c174161744596b2bd2f84e2e2d
@@ -59,6 +59,7 @@ module PacketGen
59
59
  end
60
60
 
61
61
  # IEEE 802.11 Association Request frame
62
+ # @author Sylvain Daubert
62
63
  class AssoReq < SubMngt
63
64
  # @!attribute cap
64
65
  # @return [Integer] 16-bit capabillities word
@@ -71,6 +72,7 @@ module PacketGen
71
72
  Management.bind_header AssoReq, op: :and, type: 0, subtype: 0
72
73
 
73
74
  # IEEE 802.11 Association Response frame
75
+ # @author Sylvain Daubert
74
76
  class AssoResp < SubMngt
75
77
  # @!attribute cap
76
78
  # @return [Integer] 16-bit capabillities word
@@ -86,6 +88,7 @@ module PacketGen
86
88
  Management.bind_header AssoResp, op: :and, type: 0, subtype: 1
87
89
 
88
90
  # IEEE 802.11 ReAssociation Request frame
91
+ # @author Sylvain Daubert
89
92
  class ReAssoReq < AssoReq
90
93
  # @!attribute current_ap
91
94
  # @return [Eth::MAcAddr]
@@ -95,18 +98,21 @@ module PacketGen
95
98
  Management.bind_header ReAssoReq, op: :and, type: 0, subtype: 2
96
99
 
97
100
  # IEEE 802.11 ReAssociation Response frame
101
+ # @author Sylvain Daubert
98
102
  class ReAssoResp < AssoResp
99
103
  end
100
104
  Header.add_class ReAssoResp
101
105
  Management.bind_header ReAssoResp, op: :and, type: 0, subtype: 3
102
106
 
103
107
  # IEEE 802.11 Probe Request frame
108
+ # @author Sylvain Daubert
104
109
  class ProbeReq < SubMngt
105
110
  end
106
111
  Header.add_class ProbeReq
107
112
  Management.bind_header ProbeReq, op: :and, type: 0, subtype: 4
108
113
 
109
114
  # IEEE 802.11 Probe Response frame
115
+ # @author Sylvain Daubert
110
116
  class ProbeResp < SubMngt
111
117
  # @!attribute timestamp
112
118
  # @return [Integer] 64-bit timestamp
@@ -122,6 +128,7 @@ module PacketGen
122
128
  Management.bind_header ProbeResp, op: :and, type: 0, subtype: 5
123
129
 
124
130
  # IEEE 802.11 Beacon frame
131
+ # @author Sylvain Daubert
125
132
  class Beacon < SubMngt
126
133
  # @!attribute timestamp
127
134
  # @return [Integer] 64-bit timestamp
@@ -137,11 +144,13 @@ module PacketGen
137
144
  Management.bind_header Beacon, op: :and, type: 0, subtype: 8
138
145
 
139
146
  # IEEE 802.11 ATIM frame
147
+ # @author Sylvain Daubert
140
148
  class ATIM < SubMngt; end
141
149
  Header.add_class ATIM
142
150
  Management.bind_header ATIM, op: :and, type: 0, subtype: 9
143
151
 
144
152
  # IEEE 802.11 Disassociation frame
153
+ # @author Sylvain Daubert
145
154
  class Disas < SubMngt
146
155
  # @!attribute reason
147
156
  # @return [Integer] 16-bit reason value
@@ -151,6 +160,7 @@ module PacketGen
151
160
  Management.bind_header Disas, op: :and, type: 0, subtype: 10
152
161
 
153
162
  # IEEE 802.11 Authentication frame
163
+ # @author Sylvain Daubert
154
164
  class Auth < SubMngt
155
165
  # @!attribute algo
156
166
  # @return [Integer] 16-bit algo value
@@ -166,6 +176,7 @@ module PacketGen
166
176
  Management.bind_header Auth, op: :and, type: 0, subtype: 11
167
177
 
168
178
  # IEEE 802.11 Deauthentication frame
179
+ # @author Sylvain Daubert
169
180
  class DeAuth < SubMngt
170
181
  # @!attribute reason
171
182
  # @return [Integer] 16-bit reason value
@@ -43,6 +43,8 @@ module PacketGen
43
43
  #
44
44
  # == Save packets to a file
45
45
  # Packet.write 'file.pcapng', packets
46
+ #
47
+ # @author Sylvain Daubert
46
48
  class Packet
47
49
  # @return [Array<Header::Base]
48
50
  attr_reader :headers
@@ -91,11 +93,23 @@ module PacketGen
91
93
 
92
94
  # Read packets from +filename+.
93
95
  #
94
- # For more control, see {PcapNG::File}.
95
- # @param [String] filename PcapNG file
96
+ # For more control, see {PcapNG::File} or {PCAPRUB::Pcap}.
97
+ # @param [String] filename PcapNG or Pcap file.
96
98
  # @return [Array<Packet>]
99
+ # @author Sylvain Daubert
100
+ # @author Kent Gruber
97
101
  def self.read(filename)
98
- PcapNG::File.new.read_packets filename
102
+ begin
103
+ PcapNG::File.new.read_packets filename
104
+ rescue => e
105
+ raise ArgumentError, e unless File.extname(filename.downcase) == '.pcap'
106
+ packets = []
107
+ PCAPRUB::Pcap.open_offline(filename).each_packet do |packet|
108
+ next unless packet = PacketGen.parse(packet.to_s)
109
+ packets << packet
110
+ end
111
+ packets
112
+ end
99
113
  end
100
114
 
101
115
  # Write packets to +filename+
@@ -19,6 +19,7 @@ module PacketGen
19
19
  # String :data
20
20
  # String :options
21
21
  # Int32 :block_len2
22
+ # @author Sylvain Daubert
22
23
  class EPB < Block
23
24
 
24
25
  # Minimum EPB size
@@ -7,6 +7,7 @@ module PacketGen
7
7
  module PcapNG
8
8
 
9
9
  # PcapNG::File is a complete Pcap-NG file handler.
10
+ # @author Sylvain Daubert
10
11
  class File
11
12
 
12
13
  # Known link types
@@ -16,6 +16,7 @@ module PacketGen
16
16
  # Int64 :snaplen Default: 0 (no limit)
17
17
  # String :options
18
18
  # Int32 :block_len2
19
+ # @author Sylvain Daubert
19
20
  class IDB < Block
20
21
 
21
22
  # Minimum IDB size
@@ -17,6 +17,7 @@ module PacketGen
17
17
  # Int64 :section_len
18
18
  # String :options Default: ''
19
19
  # Int32 :block_len2
20
+ # @author Sylvain Daubert
20
21
  class SHB < Block
21
22
 
22
23
  # @return [:little, :big]
@@ -14,6 +14,7 @@ module PacketGen
14
14
  # Int32 :orig_len
15
15
  # String :data
16
16
  # Int32 :block_len2
17
+ # @author Sylvain Daubert
17
18
  class SPB < Block
18
19
 
19
20
  # Minimum SPB size
@@ -7,6 +7,7 @@ module PacketGen
7
7
  module PcapNG
8
8
 
9
9
  # {UnknownBlock} is used to handle unsupported blocks of a pcapng file.
10
+ # @author Sylvain Daubert
10
11
  class UnknownBlock < Block
11
12
 
12
13
  # Minimum Iblock size
@@ -8,6 +8,7 @@ module PacketGen
8
8
 
9
9
  # Module to handle PCAP-NG file format.
10
10
  # See http://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi?url=https://raw.githubusercontent.com/pcapng/pcapng/master/draft-tuexen-opsawg-pcapng.xml&modeAsFormat=html/ascii&type=ascii
11
+ # @author Sylvain Daubert
11
12
  module PcapNG
12
13
 
13
14
  # Section Header Block type number
@@ -65,9 +65,9 @@ module PacketGen
65
65
  self.old_type = val
66
66
  else
67
67
  unless has_human_types?
68
- raise TypeError, "no human types defined for #{self.class}"
68
+ raise TypeError, 'need an Integer'
69
69
  end
70
- new_val = self.class::TYPES[val.to_s]
70
+ new_val = self.class::TYPES.key(val.to_s)
71
71
  raise ArgumentError, "unknown #{val.to_s} type" if new_val.nil?
72
72
  self.old_type = new_val
73
73
  end
@@ -8,5 +8,5 @@
8
8
  # @author Sylvain Daubert
9
9
  module PacketGen
10
10
  # PacketGen version
11
- VERSION = "1.4.2"
11
+ VERSION = "1.4.3"
12
12
  end
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: 1.4.2
4
+ version: 1.4.3
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-03-30 00:00:00.000000000 Z
11
+ date: 2017-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pcaprub