packetnom 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da39ff5a4480b640bc6d56830c833db9d9eace99
4
- data.tar.gz: e5342d68de92bb8ca831506d4ff7a0be09814a77
3
+ metadata.gz: 4427150c842370e73dbd5ac68b957f0e0533ce25
4
+ data.tar.gz: 57a1080baaafc23fae7a3f350992256bc2ede7b3
5
5
  SHA512:
6
- metadata.gz: 0be19443b6ec3a24f9067f82ea261a173d7abe48f1a583307928eef13cbb641b59f7568cb00cd404f17d5a598fb2ca029afd7e9c921c5a131153db05f1126f2c
7
- data.tar.gz: 9f44f180e04fba37d016d42a0b0a55fdf269e8a0eab2eb46388664e55ce42c8e99396824d2c816a314112a9f07d1b8f1686efc02bf9b00bb670723b5bb692d20
6
+ metadata.gz: fa3b75eb9260a340c8a780f8d191020f9bc2ba3a3daef4233feeecae47aa7bf7c43371c6f9fe19c20e9758bc720b4b4d1d2719a90998d4f45f964b6cfa9f0ae1
7
+ data.tar.gz: 3e3264fd76588c8af17af9b6463f813675556990e5a4022d2b96fc83151914a803645fc8af5426706988d136de543da5e7a052c35338eaeaae54c3cabb2ce834
@@ -14,12 +14,33 @@ module Packetnom
14
14
  # Layer 2
15
15
  @dst = bytes[0..5].join(':')
16
16
  @src = bytes[6..11].join(':')
17
- @type = bytes[12..13].join() # http://en.wikipedia.org/wiki/EtherType
17
+ @type = bytes[12..13].join # http://en.wikipedia.org/wiki/EtherType
18
+
19
+ # WHY DOES THIS HAVE PADDING ON ETHERTYPE ON REPLAY?!
20
+ if @type.eql? '0000'
21
+ @type = bytes[13..14].join
22
+ end
23
+
24
+ end
25
+
26
+ def type? (is)
27
+ if type.eql? type
28
+ return true
29
+ end
30
+
31
+ false
18
32
  end
19
33
 
20
34
  def type
21
35
  types = {
22
36
  "0800" => "ip",
37
+ "0801" => "x.75",
38
+ "0802" => "nbs",
39
+ "0803" => "ecma",
40
+ "0804" => "chaosnet",
41
+ "0805" => "x.25",
42
+ "0806" => "arp",
43
+ "814C" => "snmp",
23
44
  "86dd" => "ipv6"
24
45
  }
25
46
 
@@ -19,22 +19,24 @@ module Packetnom
19
19
  attr_accessor :dst
20
20
 
21
21
  # Initialize the packet
22
- def initialize( bytes )
23
- @version = bytes[14].split(//)[0]
24
- @ihl = bytes[14].split(//)[1]
25
- @ds = bytes[15]
26
- @len = bytes[16..17].join().to_i(16)
27
- @id = bytes[18..19].join()
28
-
29
- @flags = bytes[20].split(//)[0].to_i(16) #todo
30
- @offset = "#{bytes[20].split(//)[1]}#{bytes[21]}".to_i(16) #todo
31
-
32
- @ttl = bytes[22].to_i(16)
33
- @proto = bytes[23].to_i(16)
34
- @sum = bytes[24..25].join().to_i(16)
35
- @src = bytes[26..29].map{|octet| octet.to_i(16).to_s(10)}.join('.')
36
- @dst = bytes[30..33].map{|octet| octet.to_i(16).to_s(10)}.join('.')
37
-
22
+ def initialize( bytes )
23
+ offset = Hash[bytes[0..24].map.with_index.to_a]['45']
24
+
25
+ @version = bytes[offset].split(//)[0]
26
+ @ihl = bytes[offset].split(//)[1]
27
+ @ds = bytes[offset+1]
28
+ @len = bytes[offset+2..offset+3].join().to_i(16)
29
+ @id = bytes[offset+4..offset+5].join().to_i(16)
30
+
31
+ options = bytes[offset+6..offset+7].join().to_i(16).to_s(2).rjust(16, '0')
32
+ @flags = options[0..2].to_i(2).to_s(10)
33
+ @offset = options[3..15].to_i(2).to_s(10)
34
+
35
+ @ttl = bytes[offset+8].to_i(16)
36
+ @proto = bytes[offset+9].to_i(16)
37
+ @sum = bytes[offset+10..offset+11].join()
38
+ @src = bytes[offset+12..offset+15].map{|octet| octet.to_i(16).to_s(10)}.join('.')
39
+ @dst = bytes[offset+16..offset+19].map{|octet| octet.to_i(16).to_s(10)}.join('.')
38
40
  end
39
41
 
40
42
  alias_method :length, :len
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packetnom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mackintosh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-26 00:00:00.000000000 Z
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi-pcap
@@ -61,7 +61,6 @@ files:
61
61
  - lib/packetnom.rb
62
62
  - lib/packet/eth.rb
63
63
  - lib/packet/ipv4.rb
64
- - lib/packet/ipv6.rb
65
64
  - lib/packet/tcp.rb
66
65
  - lib/packet/udp.rb
67
66
  homepage: http://github.com/mikemackintosh/packetnom
@@ -1,79 +0,0 @@
1
- module Packetnom
2
-
3
- class Packet
4
-
5
- class IPv6
6
-
7
- # Attributes
8
- attr_accessor :version
9
- attr_accessor :ihl
10
- attr_accessor :ds
11
- attr_accessor :len
12
- attr_accessor :id
13
- attr_accessor :flags
14
- attr_accessor :offset
15
- attr_accessor :ttl
16
- attr_accessor :proto
17
- attr_accessor :sum
18
- attr_accessor :src
19
- attr_accessor :dst
20
-
21
- # Initialize the packet
22
- def initialize( bytes )
23
- @version = bytes[14].split(//)[0]
24
- @ihl = bytes[14].split(//)[1]
25
- @ds = bytes[15]
26
- @len = bytes[16..17].join().to_i(16)
27
- @id = bytes[18..19].join()
28
-
29
- @flags = bytes[20].split(//)[0].to_i(16) #todo
30
- @offset = "#{bytes[20].split(//)[1]}#{bytes[21]}".to_i(16) #todo
31
-
32
- @ttl = bytes[22].to_i(16)
33
- @proto = bytes[23].to_i(16)
34
- @sum = bytes[24..25].join().to_i(16)
35
- @src = bytes[26..29].map{|octet| octet.to_i(16).to_s(10)}.join('.')
36
- @dst = bytes[30..33].map{|octet| octet.to_i(16).to_s(10)}.join('.')
37
-
38
- end
39
-
40
- alias_method :length, :len
41
- alias_method :checksum, :sum
42
-
43
- def protonum
44
- @proto.to_i
45
- end
46
- def proto
47
- protocol( @proto.to_i )
48
- end
49
- alias_method :protocol, :proto
50
-
51
- def src
52
- IPAddress @src
53
- end
54
- alias_method :source, :src
55
- alias_method :from, :src
56
-
57
-
58
- def dst
59
- IPAddress @dst
60
- end
61
- alias_method :dest, :dst
62
- alias_method :target, :dst
63
-
64
- private
65
-
66
- def protocol( proto )
67
- protocols = {
68
- 6 => "tcp",
69
- 17 => "udp",
70
- }
71
-
72
- protocols[ proto ]
73
- end
74
-
75
- end
76
-
77
- end
78
-
79
- end