packetgen 1.0.0 → 1.0.1
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 +14 -7
- data/lib/packetgen.rb +1 -1
- data/lib/packetgen/capture.rb +2 -6
- data/lib/packetgen/header/header_methods.rb +6 -0
- data/lib/packetgen/packet.rb +2 -2
- data/lib/packetgen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cb4095a7e2fda39a7560ad82d4296016c5a633a
|
4
|
+
data.tar.gz: aed1db17fd5274a7d842ac6ba855ed73b7d271fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a520f1dfaf0a6960c33fb27c5f564923c4de11c8d310b77c7dcf151c688df70d15396b1ce74987b7a8ca811e86f58a2f6eaf1d0a18ba03613ed02aebde9f9730
|
7
|
+
data.tar.gz: e8396d8782c437335f50a3b8ee2e63138a9b0c4ea874b46838249fcb58e8f1acc89f1a7c24c6fd0fda5169c856f9724296e2c285c826223c91eebca5eba60a95
|
data/README.md
CHANGED
@@ -16,13 +16,16 @@ Yes. But PacketFu is limited:
|
|
16
16
|
* parse packets top-down, and sometimes bad parse down layers
|
17
17
|
* cannot send packet on wire at IP/IPv6 level (Ethernet header is mandatory)
|
18
18
|
|
19
|
-
##
|
19
|
+
## Installation
|
20
|
+
Via RubyGems:
|
20
21
|
|
21
|
-
|
22
|
+
$ gem install packetgen
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
Or add it to a Gemfile:
|
25
|
+
```ruby
|
26
|
+
gem 'packetgen'
|
27
|
+
```
|
28
|
+
## Usage
|
26
29
|
|
27
30
|
### Easily create packets
|
28
31
|
```
|
@@ -91,7 +94,7 @@ pkt.is? 'TCP' # => true
|
|
91
94
|
pkt.is? 'IP' # => true
|
92
95
|
pkt.is? 'UDP' # => false
|
93
96
|
|
94
|
-
# encapulsate/decapsulate packets
|
97
|
+
# encapulsate/decapsulate packets (TODO)
|
95
98
|
pkt2 = PacketGen.gen('IP').add('ESP', spi: 1234)
|
96
99
|
pkt.encap pkt2 # pkt is now a IP/ESP/IP/TCP packet
|
97
100
|
# eq. to pkt.encap('IP', 'ESP', esp_spi: 1234)
|
@@ -109,6 +112,10 @@ pkt.write('one_packet.pcapng')
|
|
109
112
|
PacketGen.write('more_packets.pcapng', packets)
|
110
113
|
```
|
111
114
|
|
115
|
+
## Pull requests?
|
116
|
+
|
117
|
+
yes
|
118
|
+
|
112
119
|
## License
|
113
120
|
MIT License (see [LICENSE](https://github.com/sdaubert/packetgen/LICENSE))
|
114
121
|
|
@@ -118,4 +125,4 @@ Copyright © 2016 Sylvain Daubert
|
|
118
125
|
All original code maintains its copyright from its original authors and licensing.
|
119
126
|
|
120
127
|
This is mainly for StrucFu (copied from [PacketFu](https://github.com/packetfu/packetfu))
|
121
|
-
and PcapNG module (also copied from PacketFu, but I am the author).
|
128
|
+
and PcapNG module (also copied from PacketFu, but I am the author).
|
data/lib/packetgen.rb
CHANGED
@@ -42,7 +42,7 @@ module PacketGen
|
|
42
42
|
# @yieldparam [Packet] packet
|
43
43
|
# @return [Array<Packet>]
|
44
44
|
def self.capture(iface, options={})
|
45
|
-
Packet.capture(iface, options) { |packet| yield packet }
|
45
|
+
Packet.capture(iface, options) { |packet| yield packet if block_given? }
|
46
46
|
end
|
47
47
|
|
48
48
|
# Shortcut for {Packet.read}
|
data/lib/packetgen/capture.rb
CHANGED
@@ -65,7 +65,7 @@ module PacketGen
|
|
65
65
|
@cap_thread.join(@timeout)
|
66
66
|
end
|
67
67
|
|
68
|
-
# Stop capture. Should be used from another thread, as {#start}
|
68
|
+
# Stop capture. Should be used from another thread, as {#start} blocks.
|
69
69
|
#
|
70
70
|
# BEWARE: multiple capture should not be started in different threads. No effort
|
71
71
|
# has been made to make Capture nor PacketGen thread-safe.
|
@@ -79,11 +79,7 @@ module PacketGen
|
|
79
79
|
def set_options(options)
|
80
80
|
@max = options[:max] if options[:max]
|
81
81
|
@filter = options[:filter] if options[:filter]
|
82
|
-
if options[:timeout]
|
83
|
-
@timeout = options[:timeout]
|
84
|
-
else
|
85
|
-
@timeout ||= 0
|
86
|
-
end
|
82
|
+
@timeout = options[:timeout] if options[:timeout]
|
87
83
|
if options[:promisc]
|
88
84
|
@promisc = options[:promisc]
|
89
85
|
else
|
data/lib/packetgen/packet.rb
CHANGED
@@ -169,7 +169,7 @@ module PacketGen
|
|
169
169
|
if binding.nil?
|
170
170
|
msg = "#{prev_header.class} knowns no layer association with #{protocol}. "
|
171
171
|
msg << "Try #{prev_header.class}.bind_layer(PacketGen::Header::#{protocol}, "
|
172
|
-
msg << "#{prev_header.
|
172
|
+
msg << "#{prev_header.protocol_name.downcase}_proto_field: "
|
173
173
|
msg << "value_for_#{protocol.downcase})"
|
174
174
|
raise ArgumentError, msg
|
175
175
|
end
|
@@ -252,7 +252,7 @@ module PacketGen
|
|
252
252
|
if @headers.first.respond_to? :to_w
|
253
253
|
@headers.first.to_w(iface)
|
254
254
|
else
|
255
|
-
type = @headers.first.
|
255
|
+
type = @headers.first.protocol_name
|
256
256
|
raise WireError, "don't known how to send a #{type} packet on wire"
|
257
257
|
end
|
258
258
|
end
|
data/lib/packetgen/version.rb
CHANGED
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.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Daubert
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pcaprub
|