packetfu 1.1.11 → 1.1.12.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.rspec +2 -0
- data/.travis.yml +2 -3
- data/README.md +127 -0
- data/examples/100kpackets.rb +11 -10
- data/examples/ackscan.rb +4 -1
- data/examples/arp.rb +4 -5
- data/examples/arphood.rb +5 -4
- data/examples/dissect_thinger.rb +10 -7
- data/examples/ethernet.rb +8 -3
- data/examples/ids.rb +22 -4
- data/examples/idsv2.rb +25 -6
- data/examples/ifconfig.rb +6 -3
- data/examples/new-simple-stats.rb +5 -6
- data/examples/packetfu-shell.rb +11 -48
- data/examples/pcap2pcapng.rb +32 -0
- data/examples/simple-sniffer.rb +9 -4
- data/examples/simple-stats.rb +7 -8
- data/examples/slammer.rb +2 -2
- data/examples/uniqpcap.rb +17 -7
- data/lib/packetfu.rb +10 -175
- data/lib/packetfu/capture.rb +2 -2
- data/lib/packetfu/common.rb +142 -0
- data/lib/packetfu/config.rb +8 -8
- data/lib/packetfu/inject.rb +3 -3
- data/lib/packetfu/packet.rb +22 -18
- data/lib/packetfu/pcap.rb +2 -1
- data/lib/packetfu/pcapng.rb +37 -0
- data/lib/packetfu/pcapng/block.rb +25 -0
- data/lib/packetfu/pcapng/epb.rb +112 -0
- data/lib/packetfu/pcapng/file.rb +316 -0
- data/lib/packetfu/pcapng/idb.rb +125 -0
- data/lib/packetfu/pcapng/shb.rb +146 -0
- data/lib/packetfu/pcapng/spb.rb +83 -0
- data/lib/packetfu/pcapng/unknown_block.rb +60 -0
- data/lib/packetfu/protos.rb +3 -0
- data/lib/packetfu/protos/arp.rb +10 -10
- data/lib/packetfu/protos/icmpv6.rb +131 -0
- data/lib/packetfu/protos/icmpv6/header.rb +69 -0
- data/lib/packetfu/protos/icmpv6/mixin.rb +14 -0
- data/lib/packetfu/protos/ip.rb +4 -5
- data/lib/packetfu/protos/ipv6/header.rb +2 -0
- data/lib/packetfu/protos/udp.rb +24 -12
- data/lib/packetfu/structfu.rb +27 -0
- data/lib/packetfu/utils.rb +55 -9
- data/lib/packetfu/version.rb +1 -1
- data/packetfu.gemspec +13 -7
- data/spec/arp_spec.rb +11 -5
- data/spec/eth_spec.rb +20 -11
- data/spec/fake_packets.rb +28 -0
- data/spec/hsrp_spec.rb +15 -0
- data/spec/icmp_spec.rb +12 -5
- data/spec/icmpv6_spec.rb +98 -0
- data/spec/invalid_spec.rb +28 -0
- data/spec/ip_spec.rb +10 -5
- data/spec/ipv4_icmp.pcap +0 -0
- data/spec/ipv4_udp.pcap +0 -0
- data/spec/ipv6_icmp.pcap +0 -0
- data/spec/ipv6_spec.rb +4 -0
- data/spec/ipv6_udp.pcap +0 -0
- data/spec/lldp_spec.rb +36 -0
- data/spec/octets_spec.rb +43 -0
- data/spec/packet_spec.rb +24 -0
- data/spec/packetfu_spec.rb +6 -1
- data/spec/pcap_spec.rb +286 -0
- data/spec/pcapng/epb_spec.rb +81 -0
- data/spec/pcapng/file_spec.rb +295 -0
- data/spec/pcapng/file_spec_helper.rb +45 -0
- data/spec/pcapng/idb_spec.rb +53 -0
- data/spec/pcapng/shb_spec.rb +42 -0
- data/spec/pcapng/spb_spec.rb +43 -0
- data/spec/pcapng/unknown_block_spec.rb +36 -0
- data/spec/spec_helper.rb +3 -31
- data/spec/tcp_spec.rb +4 -1
- data/spec/udp_spec.rb +149 -1
- data/spec/utils_spec.rb +98 -15
- data/test/pcapng-test/output_be/advanced/test100.pcapng +0 -0
- data/test/pcapng-test/output_be/advanced/test100.txt +11 -0
- data/test/pcapng-test/output_be/advanced/test101.pcapng +0 -0
- data/test/pcapng-test/output_be/advanced/test101.txt +11 -0
- data/test/pcapng-test/output_be/advanced/test102.pcapng +0 -0
- data/test/pcapng-test/output_be/advanced/test102.txt +14 -0
- data/test/pcapng-test/output_be/basic/test001.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test001.txt +9 -0
- data/test/pcapng-test/output_be/basic/test002.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test002.txt +7 -0
- data/test/pcapng-test/output_be/basic/test003.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test003.txt +8 -0
- data/test/pcapng-test/output_be/basic/test004.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test004.txt +9 -0
- data/test/pcapng-test/output_be/basic/test005.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test005.txt +9 -0
- data/test/pcapng-test/output_be/basic/test006.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test006.txt +9 -0
- data/test/pcapng-test/output_be/basic/test007.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test007.txt +9 -0
- data/test/pcapng-test/output_be/basic/test008.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test008.txt +9 -0
- data/test/pcapng-test/output_be/basic/test009.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test009.txt +9 -0
- data/test/pcapng-test/output_be/basic/test010.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test010.txt +9 -0
- data/test/pcapng-test/output_be/basic/test011.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test011.txt +10 -0
- data/test/pcapng-test/output_be/basic/test012.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test012.txt +10 -0
- data/test/pcapng-test/output_be/basic/test013.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test013.txt +9 -0
- data/test/pcapng-test/output_be/basic/test014.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test014.txt +9 -0
- data/test/pcapng-test/output_be/basic/test015.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test015.txt +9 -0
- data/test/pcapng-test/output_be/basic/test016.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test016.txt +11 -0
- data/test/pcapng-test/output_be/basic/test017.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test017.txt +9 -0
- data/test/pcapng-test/output_be/basic/test018.pcapng +0 -0
- data/test/pcapng-test/output_be/basic/test018.txt +12 -0
- data/test/pcapng-test/output_be/difficult/test200.pcapng +0 -0
- data/test/pcapng-test/output_be/difficult/test200.txt +8 -0
- data/test/pcapng-test/output_be/difficult/test201.pcapng +0 -0
- data/test/pcapng-test/output_be/difficult/test201.txt +11 -0
- data/test/pcapng-test/output_be/difficult/test202.pcapng +0 -0
- data/test/pcapng-test/output_be/difficult/test202.txt +14 -0
- data/test/pcapng-test/output_le/advanced/test100.pcapng +0 -0
- data/test/pcapng-test/output_le/advanced/test100.txt +11 -0
- data/test/pcapng-test/output_le/advanced/test101.pcapng +0 -0
- data/test/pcapng-test/output_le/advanced/test101.txt +11 -0
- data/test/pcapng-test/output_le/advanced/test102.pcapng +0 -0
- data/test/pcapng-test/output_le/advanced/test102.txt +14 -0
- data/test/pcapng-test/output_le/basic/test001.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test001.txt +9 -0
- data/test/pcapng-test/output_le/basic/test002.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test002.txt +7 -0
- data/test/pcapng-test/output_le/basic/test003.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test003.txt +8 -0
- data/test/pcapng-test/output_le/basic/test004.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test004.txt +9 -0
- data/test/pcapng-test/output_le/basic/test005.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test005.txt +9 -0
- data/test/pcapng-test/output_le/basic/test006.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test006.txt +9 -0
- data/test/pcapng-test/output_le/basic/test007.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test007.txt +9 -0
- data/test/pcapng-test/output_le/basic/test008.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test008.txt +9 -0
- data/test/pcapng-test/output_le/basic/test009.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test009.txt +9 -0
- data/test/pcapng-test/output_le/basic/test010.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test010.txt +9 -0
- data/test/pcapng-test/output_le/basic/test011.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test011.txt +10 -0
- data/test/pcapng-test/output_le/basic/test012.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test012.txt +10 -0
- data/test/pcapng-test/output_le/basic/test013.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test013.txt +9 -0
- data/test/pcapng-test/output_le/basic/test014.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test014.txt +9 -0
- data/test/pcapng-test/output_le/basic/test015.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test015.txt +9 -0
- data/test/pcapng-test/output_le/basic/test016.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test016.txt +11 -0
- data/test/pcapng-test/output_le/basic/test017.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test017.txt +9 -0
- data/test/pcapng-test/output_le/basic/test018.pcapng +0 -0
- data/test/pcapng-test/output_le/basic/test018.txt +12 -0
- data/test/pcapng-test/output_le/difficult/test200.pcapng +0 -0
- data/test/pcapng-test/output_le/difficult/test200.txt +8 -0
- data/test/pcapng-test/output_le/difficult/test201.pcapng +0 -0
- data/test/pcapng-test/output_le/difficult/test201.txt +11 -0
- data/test/pcapng-test/output_le/difficult/test202.pcapng +0 -0
- data/test/pcapng-test/output_le/difficult/test202.txt +14 -0
- data/test/sample-ipv6.pcapng +0 -0
- data/test/sample-spb.pcapng +0 -0
- data/test/sample.pcapng +0 -0
- data/test/sample2.pcapng +0 -0
- metadata +190 -68
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -2
- data/INSTALL.rdoc +0 -40
- data/README.rdoc +0 -64
- data/examples/examples.rb +0 -4
- data/setup.rb +0 -1586
- data/test/func_lldp.rb +0 -25
- data/test/ptest.rb +0 -16
- data/test/test_eth.rb +0 -93
- data/test/test_hsrp.rb +0 -20
- data/test/test_invalid.rb +0 -28
- data/test/test_octets.rb +0 -36
- data/test/test_pcap.rb +0 -211
- data/test/test_udp.rb +0 -100
- metadata.gz.sig +0 -2
data/spec/utils_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# -*- coding: binary -*-
|
2
|
-
|
3
2
|
require 'spec_helper'
|
3
|
+
require 'packetfu/protos/eth'
|
4
|
+
require 'packetfu/protos/ip'
|
5
|
+
require 'packetfu/utils'
|
4
6
|
|
5
7
|
include PacketFu
|
6
8
|
|
@@ -14,7 +16,7 @@ describe Utils do
|
|
14
16
|
|
15
17
|
it "should work on Mac OSX Yosemite" do
|
16
18
|
stub_const("RUBY_PLATFORM", "x86_64-darwin14")
|
17
|
-
mac_osx_reply = "ifconfig en0\n" +
|
19
|
+
mac_osx_reply = "ifconfig en0\n" +
|
18
20
|
"en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500\n" +
|
19
21
|
"ether 78:31:c1:ce:39:bc\n" +
|
20
22
|
"inet6 fe80::7a31:c1ff:fece:39bc%en0 prefixlen 64 scopeid 0x4\n" +
|
@@ -41,13 +43,13 @@ describe Utils do
|
|
41
43
|
|
42
44
|
it "should work on Ubuntu 14.04 LTS" do
|
43
45
|
stub_const("RUBY_PLATFORM", "x86_64-linux")
|
44
|
-
ubuntu_reply = "eth0 Link encap:Ethernet HWaddr 00:0c:29:2a:e3:bd\n" +
|
45
|
-
"inet addr:192.168.10.174 Bcast:192.168.10.255 Mask:255.255.255.0\n" +
|
46
|
-
"inet6 addr: fe80::20c:29ff:fe2a:e3bd/64 Scope:Link\n" +
|
47
|
-
"UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\n" +
|
48
|
-
"RX packets:65782 errors:0 dropped:0 overruns:0 frame:0\n" +
|
49
|
-
"TX packets:31354 errors:0 dropped:0 overruns:0 carrier:0\n" +
|
50
|
-
"collisions:0 txqueuelen:1000\n" +
|
46
|
+
ubuntu_reply = "eth0 Link encap:Ethernet HWaddr 00:0c:29:2a:e3:bd\n" +
|
47
|
+
"inet addr:192.168.10.174 Bcast:192.168.10.255 Mask:255.255.255.0\n" +
|
48
|
+
"inet6 addr: fe80::20c:29ff:fe2a:e3bd/64 Scope:Link\n" +
|
49
|
+
"UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1\n" +
|
50
|
+
"RX packets:65782 errors:0 dropped:0 overruns:0 frame:0\n" +
|
51
|
+
"TX packets:31354 errors:0 dropped:0 overruns:0 carrier:0\n" +
|
52
|
+
"collisions:0 txqueuelen:1000\n" +
|
51
53
|
"RX bytes:40583515 (40.5 MB) TX bytes:3349554 (3.3 MB)"
|
52
54
|
allow(PacketFu::Utils).to receive(:ifconfig_data_string).and_return(ubuntu_reply)
|
53
55
|
util_reply = PacketFu::Utils.ifconfig("eth0")
|
@@ -68,11 +70,11 @@ describe Utils do
|
|
68
70
|
|
69
71
|
it "should work on FreeBSD" do
|
70
72
|
stub_const("RUBY_PLATFORM", "freebsd")
|
71
|
-
freebsd_reply = "dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500\n" +
|
72
|
-
"options=80008<VLAN_MTU,LINKSTATE>\n" +
|
73
|
-
"ether 00:a0:cc:da:da:da\n" +
|
74
|
-
"inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255\n" +
|
75
|
-
"media: Ethernet autoselect (100baseTX <full-duplex>)\n" +
|
73
|
+
freebsd_reply = "dc0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500\n" +
|
74
|
+
"options=80008<VLAN_MTU,LINKSTATE>\n" +
|
75
|
+
"ether 00:a0:cc:da:da:da\n" +
|
76
|
+
"inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255\n" +
|
77
|
+
"media: Ethernet autoselect (100baseTX <full-duplex>)\n" +
|
76
78
|
"status: active"
|
77
79
|
allow(PacketFu::Utils).to receive(:ifconfig_data_string).and_return(freebsd_reply)
|
78
80
|
util_reply = PacketFu::Utils.ifconfig("dc0")
|
@@ -91,5 +93,86 @@ describe Utils do
|
|
91
93
|
expect(util_reply[:ip4_obj]).to eq(IPAddr.new("192.168.1.0/24"))
|
92
94
|
end
|
93
95
|
|
96
|
+
it "should work on OpenBSD" do
|
97
|
+
stub_const("RUBY_PLATFORM", "openbsd")
|
98
|
+
openbsd_reply = "em0: flags=8b43\\<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST\\> mtu 1500\n" +
|
99
|
+
" lladdr 00:01:02:03:04:05\n" +
|
100
|
+
" priority: 0\n" +
|
101
|
+
" groups: egress\n" +
|
102
|
+
" media: Ethernet autoselect (1000baseT full-duplex,rxpause,txpause)\n" +
|
103
|
+
" status: active\n" +
|
104
|
+
" inet 10.0.0.1 netmask 0xffffff00 broadcast 10.0.0.255"
|
105
|
+
allow(PacketFu::Utils).to receive(:ifconfig_data_string).and_return(openbsd_reply)
|
106
|
+
util_reply = PacketFu::Utils.ifconfig("em0")
|
107
|
+
|
108
|
+
# Ensure we got a hash back
|
109
|
+
expect(util_reply).to be_a(::Hash)
|
110
|
+
|
111
|
+
# Ensure all our values parse correctly
|
112
|
+
expect(util_reply[:iface]).to eq("em0")
|
113
|
+
expect(util_reply[:eth_saddr]).to eq("00:01:02:03:04:05")
|
114
|
+
expect(util_reply[:eth_src]).to eq("\x00\x01\x02\x03\x04\x05")
|
115
|
+
expect(util_reply[:ip6_saddr]).to eq(nil)
|
116
|
+
expect(util_reply[:ip6_obj]).to eq(nil)
|
117
|
+
expect(util_reply[:ip_saddr]).to eq("10.0.0.1")
|
118
|
+
expect(util_reply[:ip_src]).to eq("\n\x00\x00\x01")
|
119
|
+
expect(util_reply[:ip4_obj]).to eq(IPAddr.new("10.0.0.0/24"))
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
context 'when using arp' do
|
125
|
+
|
126
|
+
before(:all) do
|
127
|
+
@whoami = lambda { |iface| {
|
128
|
+
:iface => iface,
|
129
|
+
:eth_saddr => '00:01:02:03:dd:b3',
|
130
|
+
:eth_src => "\x00\x01\x02\x03\xdd\xb3",
|
131
|
+
:ip_saddr => '192.168.254.1',
|
132
|
+
:ip_src => 0xc0a8fe01,
|
133
|
+
:ip_src_bin => "\xc0\xa8\xfe\x01",
|
134
|
+
:eth_dst => "\x00\x01\x02\x03\xcc\xb2",
|
135
|
+
:eth_daddr => '00:01:02:03:cc:b2',
|
136
|
+
} }
|
137
|
+
end
|
138
|
+
|
139
|
+
context 'when cached' do
|
140
|
+
it 'should work on Mac OSX Yosemite' do
|
141
|
+
stub_const('RUBY_PLATFORM', 'macosx')
|
142
|
+
mac_osx_reply = "? (192.168.254.57) at 64:00:00:00:cc:b2 on en0 ifscope [ethernet]\n"
|
143
|
+
allow(PacketFu::Utils).to receive(:arp_cache_raw).and_return(mac_osx_reply)
|
144
|
+
whoami_reply = @whoami.call('em0')
|
145
|
+
allow(PacketFu::Utils).to receive(:whoami?).and_return(whoami_reply)
|
146
|
+
util_reply = PacketFu::Utils.arp('192.168.254.57')
|
147
|
+
|
148
|
+
expect(util_reply).to be_a(String)
|
149
|
+
expect(util_reply).to eq('64:00:00:00:cc:b2')
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'should work on Ubuntu 14.04 LTS' do
|
153
|
+
stub_const('RUBY_PLATFORM', 'x86_64-linux')
|
154
|
+
ubuntu_reply = "? (192.168.254.56) at 00:01:02:03:cc:b2 [ether] on eth0\n"
|
155
|
+
allow(PacketFu::Utils).to receive(:arp_cache_raw).and_return(ubuntu_reply)
|
156
|
+
whoami_reply = @whoami.call('eth0')
|
157
|
+
allow(PacketFu::Utils).to receive(:whoami?).and_return(whoami_reply)
|
158
|
+
util_reply = PacketFu::Utils.arp('192.168.254.56')
|
159
|
+
|
160
|
+
expect(util_reply).to be_a(String)
|
161
|
+
expect(util_reply).to eq('00:01:02:03:cc:b2')
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should work on FreeBSD' do
|
165
|
+
stub_const('RUBY_PLATFORM', 'freebsd')
|
166
|
+
freebsd_reply = "? (192.168.254.57) at 00:13:20:c3:7d:22 on em0 [ethernet]\n"
|
167
|
+
allow(PacketFu::Utils).to receive(:arp_cache_raw).and_return(freebsd_reply)
|
168
|
+
whoami_reply = @whoami.call('em0')
|
169
|
+
allow(PacketFu::Utils).to receive(:whoami?).and_return(whoami_reply)
|
170
|
+
util_reply = PacketFu::Utils.arp('192.168.254.57')
|
171
|
+
|
172
|
+
expect(util_reply).to be_a(String)
|
173
|
+
expect(util_reply).to eq('00:13:20:c3:7d:22')
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
94
177
|
end
|
95
|
-
end
|
178
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Description: All block types, intermixed
|
2
|
+
Category: advanced
|
3
|
+
|
4
|
+
Block counts:
|
5
|
+
CB: 1
|
6
|
+
DCB: 2
|
7
|
+
EPB: 4
|
8
|
+
IDB: 3
|
9
|
+
ISB: 6
|
10
|
+
NRB: 3
|
11
|
+
SHB: 1
|
12
|
+
SPB: 1
|
13
|
+
|
14
|
+
Block sequence: SHB, CB, NRB, IDB, IDB, ISB, EPB, ISB, ISB, DCB, IDB, EPB, ISB, SPB, NRB, EPB, ISB, EPB, DCB, NRB, ISB
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|