unified2 0.5.4 → 0.6.0

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.
Files changed (46) hide show
  1. data/ChangeLog.md +10 -0
  2. data/README.md +41 -35
  3. data/Rakefile +3 -2
  4. data/bin/ru2 +76 -0
  5. data/example/example.rb +10 -18
  6. data/example/example2.rb +44 -0
  7. data/example/seeds/classification.config +1 -1
  8. data/example/seeds/gen-msg.map +86 -9
  9. data/example/seeds/sid-msg.map +2849 -316
  10. data/example/seeds/unified2-current.log +0 -0
  11. data/example/seeds/{unified2.log → unified2-legacy.log} +0 -0
  12. data/gemspec.yml +2 -1
  13. data/lib/unified2/classification.rb +12 -0
  14. data/lib/unified2/config_file.rb +4 -1
  15. data/lib/unified2/constructor/construct.rb +52 -6
  16. data/lib/unified2/constructor/event_ip4.rb +18 -3
  17. data/lib/unified2/constructor/event_ip6.rb +22 -4
  18. data/lib/unified2/constructor/extra_construct.rb +46 -0
  19. data/lib/unified2/constructor/extra_data.rb +37 -0
  20. data/lib/unified2/constructor/extra_data_header.rb +28 -0
  21. data/lib/unified2/constructor/legacy_event_ip4.rb +54 -0
  22. data/lib/unified2/constructor/legacy_event_ip6.rb +52 -0
  23. data/lib/unified2/constructor/packet.rb +9 -1
  24. data/lib/unified2/constructor/primitive/ipv4.rb +9 -0
  25. data/lib/unified2/constructor/record_header.rb +9 -0
  26. data/lib/unified2/constructor.rb +2 -1
  27. data/lib/unified2/core_ext/string.rb +2 -1
  28. data/lib/unified2/event.rb +290 -165
  29. data/lib/unified2/exceptions/binary_read_error.rb +11 -0
  30. data/lib/unified2/exceptions/file_not_found.rb +4 -1
  31. data/lib/unified2/exceptions/file_not_readable.rb +4 -1
  32. data/lib/unified2/exceptions/unknown_load_type.rb +4 -1
  33. data/lib/unified2/exceptions.rb +2 -1
  34. data/lib/unified2/extra.rb +128 -0
  35. data/lib/unified2/packet.rb +211 -0
  36. data/lib/unified2/protocol.rb +54 -63
  37. data/lib/unified2/sensor.rb +14 -2
  38. data/lib/unified2/signature.rb +12 -0
  39. data/lib/unified2/version.rb +4 -1
  40. data/lib/unified2.rb +65 -81
  41. data/spec/event_spec.rb +40 -27
  42. data/spec/legacy_event_spec.rb +122 -0
  43. data/spec/spec_helper.rb +10 -21
  44. data/spec/unified2_spec.rb +3 -3
  45. metadata +124 -140
  46. data/lib/unified2/payload.rb +0 -114
metadata CHANGED
@@ -1,197 +1,181 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: unified2
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 4
10
- version: 0.5.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dustin Willis Webber
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-06-27 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: packetfu
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
12
+ date: 2011-11-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bindata
16
+ requirement: &70345281255100 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 13
29
- segments:
30
- - 1
31
- - 1
32
- version: "1.1"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.4'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: hexdump
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70345281255100
25
+ - !ruby/object:Gem::Dependency
26
+ name: packetfu
27
+ requirement: &70345281252460 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
29
+ requirements:
41
30
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 15
44
- segments:
45
- - 0
46
- - 2
47
- version: "0.2"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.1'
48
33
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: bindata
52
34
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70345281252460
36
+ - !ruby/object:Gem::Dependency
37
+ name: hexdump
38
+ requirement: &70345281251340 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
40
+ requirements:
56
41
  - - ~>
57
- - !ruby/object:Gem::Version
58
- hash: 7
59
- segments:
60
- - 1
61
- - 4
62
- version: "1.4"
42
+ - !ruby/object:Gem::Version
43
+ version: '0.2'
63
44
  type: :runtime
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
45
+ prerelease: false
46
+ version_requirements: *70345281251340
47
+ - !ruby/object:Gem::Dependency
66
48
  name: ore-tasks
49
+ requirement: &70345281250320 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.5'
55
+ type: :development
67
56
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ version_requirements: *70345281250320
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70345281388740 !ruby/object:Gem::Requirement
69
61
  none: false
70
- requirements:
62
+ requirements:
71
63
  - - ~>
72
- - !ruby/object:Gem::Version
73
- hash: 1
74
- segments:
75
- - 0
76
- - 5
77
- version: "0.5"
64
+ - !ruby/object:Gem::Version
65
+ version: '2.4'
78
66
  type: :development
79
- version_requirements: *id004
80
- - !ruby/object:Gem::Dependency
81
- name: yard
82
67
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
68
+ version_requirements: *70345281388740
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: &70345281387940 !ruby/object:Gem::Requirement
84
72
  none: false
85
- requirements:
73
+ requirements:
86
74
  - - ~>
87
- - !ruby/object:Gem::Version
88
- hash: 7
89
- segments:
90
- - 0
91
- - 6
92
- - 0
93
- version: 0.6.0
75
+ - !ruby/object:Gem::Version
76
+ version: '0.7'
94
77
  type: :development
95
- version_requirements: *id005
96
- - !ruby/object:Gem::Dependency
97
- name: rspec
98
78
  prerelease: false
99
- requirement: &id006 !ruby/object:Gem::Requirement
79
+ version_requirements: *70345281387940
80
+ - !ruby/object:Gem::Dependency
81
+ name: rdiscount
82
+ requirement: &70345281386700 !ruby/object:Gem::Requirement
100
83
  none: false
101
- requirements:
84
+ requirements:
102
85
  - - ~>
103
- - !ruby/object:Gem::Version
104
- hash: 11
105
- segments:
106
- - 2
107
- - 4
108
- version: "2.4"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.6'
109
88
  type: :development
110
- version_requirements: *id006
111
- description: A ruby interface for unified2 output. rUnified2 allows you to manipulate unified2 output for custom storage and/or analysis.
112
- email:
89
+ prerelease: false
90
+ version_requirements: *70345281386700
91
+ description: A ruby interface for unified2 output. rUnified2 allows you to manipulate
92
+ unified2 output for custom storage and/or analysis.
93
+ email:
113
94
  - dustin.webber@gmail.com
114
- executables: []
115
-
95
+ executables:
96
+ - ru2
116
97
  extensions: []
117
-
118
- extra_rdoc_files:
98
+ extra_rdoc_files:
119
99
  - README.md
100
+ - ChangeLog.md
120
101
  - LICENSE.txt
102
+ files:
103
+ - .document
104
+ - .rspec
105
+ - .yardopts
121
106
  - ChangeLog.md
122
- files:
123
- - spec/spec_helper.rb
124
- - lib/unified2/event.rb
125
- - lib/unified2/constructor/record_header.rb
126
- - lib/unified2.rb
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/ru2
111
+ - example/example.rb
112
+ - example/example2.rb
113
+ - example/seeds/classification.config
114
+ - example/seeds/gen-msg.map
115
+ - example/seeds/sid-msg.map
116
+ - example/seeds/unified2-current.log
117
+ - example/seeds/unified2-legacy.log
127
118
  - gemspec.yml
128
- - .rspec
119
+ - lib/unified2.rb
120
+ - lib/unified2/classification.rb
129
121
  - lib/unified2/config_file.rb
130
- - example/seeds/unified2.log
131
- - example/seeds/sid-msg.map
132
- - .yardopts
133
- - lib/unified2/signature.rb
134
- - lib/unified2/sensor.rb
135
122
  - lib/unified2/constructor.rb
136
- - example/seeds/classification.config
137
- - spec/event_spec.rb
138
- - lib/unified2/protocol.rb
139
- - lib/unified2/payload.rb
140
- - lib/unified2/constructor/primitive/ipv4.rb
141
- - lib/unified2/constructor/event_ip6.rb
142
123
  - lib/unified2/constructor/construct.rb
143
- - example/example.rb
144
- - lib/unified2/version.rb
145
- - Rakefile
146
- - README.md
147
- - LICENSE.txt
148
- - spec/unified2_spec.rb
149
- - lib/unified2/exceptions/unknown_load_type.rb
150
- - lib/unified2/core_ext/string.rb
151
- - lib/unified2/core_ext.rb
152
124
  - lib/unified2/constructor/event_ip4.rb
153
- - unified2.gemspec
125
+ - lib/unified2/constructor/event_ip6.rb
126
+ - lib/unified2/constructor/extra_construct.rb
127
+ - lib/unified2/constructor/extra_data.rb
128
+ - lib/unified2/constructor/extra_data_header.rb
129
+ - lib/unified2/constructor/legacy_event_ip4.rb
130
+ - lib/unified2/constructor/legacy_event_ip6.rb
154
131
  - lib/unified2/constructor/packet.rb
155
- - lib/unified2/exceptions/file_not_readable.rb
156
- - lib/unified2/exceptions/file_not_found.rb
157
- - example/seeds/gen-msg.map
158
- - .document
132
+ - lib/unified2/constructor/primitive/ipv4.rb
133
+ - lib/unified2/constructor/record_header.rb
134
+ - lib/unified2/core_ext.rb
135
+ - lib/unified2/core_ext/string.rb
136
+ - lib/unified2/event.rb
159
137
  - lib/unified2/exceptions.rb
160
- - lib/unified2/classification.rb
161
- - ChangeLog.md
138
+ - lib/unified2/exceptions/binary_read_error.rb
139
+ - lib/unified2/exceptions/file_not_found.rb
140
+ - lib/unified2/exceptions/file_not_readable.rb
141
+ - lib/unified2/exceptions/unknown_load_type.rb
142
+ - lib/unified2/extra.rb
143
+ - lib/unified2/packet.rb
144
+ - lib/unified2/protocol.rb
145
+ - lib/unified2/sensor.rb
146
+ - lib/unified2/signature.rb
147
+ - lib/unified2/version.rb
148
+ - spec/event_spec.rb
149
+ - spec/legacy_event_spec.rb
150
+ - spec/spec_helper.rb
151
+ - spec/unified2_spec.rb
152
+ - unified2.gemspec
162
153
  homepage: https://github.com/mephux/unified2
163
- licenses:
154
+ licenses:
164
155
  - MIT
165
156
  post_install_message:
166
157
  rdoc_options: []
167
-
168
- require_paths:
158
+ require_paths:
169
159
  - lib
170
- required_ruby_version: !ruby/object:Gem::Requirement
160
+ required_ruby_version: !ruby/object:Gem::Requirement
171
161
  none: false
172
- requirements:
173
- - - ">="
174
- - !ruby/object:Gem::Version
175
- hash: 3
176
- segments:
177
- - 0
178
- version: "0"
179
- required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
167
  none: false
181
- requirements:
182
- - - ">="
183
- - !ruby/object:Gem::Version
184
- hash: 3
185
- segments:
186
- - 0
187
- version: "0"
168
+ requirements:
169
+ - - ! '>='
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
188
172
  requirements: []
189
-
190
173
  rubyforge_project: unified2
191
- rubygems_version: 1.8.1
174
+ rubygems_version: 1.8.10
192
175
  signing_key:
193
176
  specification_version: 3
194
177
  summary: A ruby interface for unified2 output.
195
- test_files:
178
+ test_files:
196
179
  - spec/event_spec.rb
180
+ - spec/legacy_event_spec.rb
197
181
  - spec/unified2_spec.rb
@@ -1,114 +0,0 @@
1
- require 'hexdump'
2
-
3
- module Unified2
4
- #
5
- # Payload
6
- #
7
- class Payload
8
-
9
- attr_accessor :linktype, :length, :packet
10
-
11
- #
12
- # Initialize payload object
13
- #
14
- # @param [String] raw Raw binary payload
15
- # @param [Hash] packet Packet attributes
16
- #
17
- # @option packet [String] :packet Packet
18
- # @option packet [Integer] :packet_length Packet length
19
- # @option packet [Integer] :linktype Packet linktype
20
- #
21
- def initialize(raw, packet={})
22
- @packet = raw
23
- @length = packet[:packet_length].to_i
24
- @linktype = packet[:linktype]
25
- end
26
-
27
- #
28
- # Blank?
29
- #
30
- # @return [true, false] Check is payload is blank
31
- #
32
- def blank?
33
- return true unless @packet
34
- false
35
- end
36
-
37
- #
38
- # Raw
39
- #
40
- # @return [String] Raw binary payload
41
- #
42
- def raw
43
- @packet
44
- end
45
-
46
- #
47
- # Hex
48
- #
49
- # @return [String] Convert payload to hex
50
- #
51
- def hex
52
- @hex = @packet.to_s.unpack('H*')
53
- return @hex.first if @hex
54
- nil
55
- end
56
-
57
- #
58
- # Dump
59
- #
60
- # @param [options] options Hash of options for Hexdump#dump
61
- #
62
- # @option options [Integer] :width (16)
63
- # The number of bytes to dump for each line.
64
- #
65
- # @option options [Symbol, Integer] :base (:hexadecimal)
66
- # The base to print bytes in. Supported bases include, `:hexadecimal`,
67
- # `:hex`, `16, `:decimal`, `:dec`, `10, `:octal`, `:oct`, `8`,
68
- # `:binary`, `:bin` and `2`.
69
- #
70
- # @option options [Boolean] :ascii (false)
71
- # Print ascii characters when possible.
72
- #
73
- # @option options [#<<] :output (STDOUT)
74
- # The output to print the hexdump to.
75
- #
76
- # @yield [index,hex_segment,print_segment]
77
- # The given block will be passed the hexdump break-down of each segment.
78
- #
79
- # @yieldparam [Integer] index
80
- # The index of the hexdumped segment.
81
- #
82
- # @yieldparam [Array<String>] hex_segment
83
- # The hexadecimal-byte representation of the segment.
84
- #
85
- # @yieldparam [Array<String>] print_segment
86
- # The print-character representation of the segment.
87
- #
88
- # @return [nil]
89
- #
90
- # @raise [ArgumentError]
91
- # The given data does not define the `#each_byte` method, or
92
- #
93
- # @note
94
- # Please view the hexdump documentation for more
95
- # information. Hexdump is a great lib by @postmodern.
96
- # (http://github.com/postmodern/hexdump)
97
- #
98
- def dump(options={})
99
- Hexdump.dump(@packet, options)
100
- end
101
-
102
- #
103
- # Checksum
104
- #
105
- # Create a unique payload checksum
106
- #
107
- # @return [String] Payload checksum
108
- #
109
- def checksum
110
- Digest::MD5.hexdigest(@packet)
111
- end
112
-
113
- end
114
- end