packet_head 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/packet_head +4 -0
- data/lib/packet_head/version.rb +3 -0
- data/lib/packet_head.rb +74 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 25b74dce257ed07975fcbb353df3ae2939f2ba47
|
4
|
+
data.tar.gz: 59ac181c1cd47cbe1ec8b3ef456a829045a9421b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21adf96b0de75493809a2e626c1a2e23aeb818096f6b0dfba283217bde626d2d065b64c4ae70e471059c99074725dc7253435305c71cf579120c8acb6ceceda3
|
7
|
+
data.tar.gz: 62a3e083ccff78cb9af56088c77d42ad6f82cdba0b23a6ae54d77398c91edef8f1c30365f19240fb3c034b34b0d36fcc4a9876adc7b1e89cd6703784280a03f0
|
data/bin/packet_head
ADDED
data/lib/packet_head.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "packetgen"
|
2
|
+
require "command_lion"
|
3
|
+
require "colorize"
|
4
|
+
require "packet_head/version"
|
5
|
+
|
6
|
+
module PacketHead
|
7
|
+
|
8
|
+
trap("SIGINT") { exit 0 }
|
9
|
+
|
10
|
+
CommandLion::App.run do
|
11
|
+
name "Packet Head".colorize(:yellow)
|
12
|
+
version "1.0.0"
|
13
|
+
description "Streaming captured packet headers straight to the command-line."
|
14
|
+
|
15
|
+
command :capture do
|
16
|
+
description "Capture from a given network interface ( default: #{Pcap.lookupdev.colorize(:yellow)} )."
|
17
|
+
type :string
|
18
|
+
default Pcap.lookupdev
|
19
|
+
|
20
|
+
action do
|
21
|
+
capture = Pcap.open_live(argument, options[:snaplen].argument, options[:promisc].argument, options[:buffer].argument)
|
22
|
+
loop do
|
23
|
+
while packet = capture.next
|
24
|
+
begin
|
25
|
+
PacketGen.parse(packet).headers.map(&:class).map {|h| h.to_s.split("::").last }.join(" - ")
|
26
|
+
rescue
|
27
|
+
# some error, yolo
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
option :snaplen do
|
35
|
+
default 65535
|
36
|
+
type :integer
|
37
|
+
description "Amount of data for each frame that is actually captured ( default: #{default.to_s.colorize(:yellow)} )."
|
38
|
+
end
|
39
|
+
|
40
|
+
option :promisc do
|
41
|
+
type :bool
|
42
|
+
default true
|
43
|
+
description "Capture all traffic received rather than only what's meant to receive ( default: #{default.to_s.colorize(:yellow)} )."
|
44
|
+
end
|
45
|
+
|
46
|
+
option :buffer do
|
47
|
+
type :integer
|
48
|
+
default 1
|
49
|
+
description "Read time out in milliseconds when capturing packets -- 0 means no time out ( default: #{default.to_s.colorize(:yellow)} )."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
command :read do
|
54
|
+
description "Read a given pcap file's packet headers to STDOUT."
|
55
|
+
type :string
|
56
|
+
|
57
|
+
before do
|
58
|
+
unless File.extname(argument).downcase == ".pcap" || File.extname(argument).downcase == ".pcapng"
|
59
|
+
puts "Please provide a .pcap or .pcapng file!"
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
action do
|
65
|
+
packets = PacketGen.read(argument)
|
66
|
+
packets.each do |packet|
|
67
|
+
puts packet.headers.map(&:class).map {|h| h.to_s.split("::").last }.join(" - ")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: packet_head
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kent 'picat' Gruber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: command_lion
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: packetgen
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.1
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.15'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.15'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- kgruber1@emich.edu
|
100
|
+
executables:
|
101
|
+
- packet_head
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- bin/packet_head
|
106
|
+
- lib/packet_head.rb
|
107
|
+
- lib/packet_head/version.rb
|
108
|
+
homepage: https://github.com/picatz/packet_head
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.6.12
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Streaming packet header types to the command-line.
|
132
|
+
test_files: []
|