RubyIOC 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +3 -0
- data/LICENSE +7 -0
- data/README.md +7 -0
- data/Rakefile +8 -0
- data/RubyIOC.gemspec +24 -0
- data/lib/RubyIOC.rb +39 -0
- data/lib/RubyIOC/ioc.rb +58 -0
- data/lib/RubyIOC/iocitem.rb +59 -0
- data/lib/RubyIOC/iocitem/arp_entry_item.rb +33 -0
- data/lib/RubyIOC/iocitem/cookie_history_item.rb +33 -0
- data/lib/RubyIOC/iocitem/disk_item.rb +33 -0
- data/lib/RubyIOC/iocitem/dns_entry_item.rb +66 -0
- data/lib/RubyIOC/iocitem/driver_item.rb +33 -0
- data/lib/RubyIOC/iocitem/event_log_item.rb +33 -0
- data/lib/RubyIOC/iocitem/file_download_history_item.rb +33 -0
- data/lib/RubyIOC/iocitem/file_item.rb +33 -0
- data/lib/RubyIOC/iocitem/form_history_item.rb +33 -0
- data/lib/RubyIOC/iocitem/hash_item.rb +33 -0
- data/lib/RubyIOC/iocitem/hook_item.rb +33 -0
- data/lib/RubyIOC/iocitem/module_item.rb +33 -0
- data/lib/RubyIOC/iocitem/persistence_item.rb +33 -0
- data/lib/RubyIOC/iocitem/port_item.rb +33 -0
- data/lib/RubyIOC/iocitem/prefetch_item.rb +33 -0
- data/lib/RubyIOC/iocitem/process_item.rb +33 -0
- data/lib/RubyIOC/iocitem/registry_hive_item.rb +33 -0
- data/lib/RubyIOC/iocitem/registry_item.rb +33 -0
- data/lib/RubyIOC/iocitem/route_entry_item.rb +33 -0
- data/lib/RubyIOC/iocitem/service_item.rb +33 -0
- data/lib/RubyIOC/iocitem/string_match_item.rb +33 -0
- data/lib/RubyIOC/iocitem/system_info_item.rb +33 -0
- data/lib/RubyIOC/iocitem/system_restore_item.rb +33 -0
- data/lib/RubyIOC/iocitem/task_item.rb +33 -0
- data/lib/RubyIOC/iocitem/timeline_item.rb +33 -0
- data/lib/RubyIOC/iocitem/url_history_item.rb +33 -0
- data/lib/RubyIOC/iocitem/user_item.rb +81 -0
- data/lib/RubyIOC/iocitem/volume_item.rb +33 -0
- data/lib/RubyIOC/iocterm.rb +22 -0
- data/lib/RubyIOC/platform.rb +55 -0
- data/lib/RubyIOC/scanner.rb +110 -0
- data/lib/RubyIOC/version.rb +15 -0
- data/test/find_windows.ioc +75 -0
- data/test/test_dns_entry_item.ioc +14 -0
- data/test/test_iocitem_factory.rb +17 -0
- data/test/test_scan.rb +16 -0
- data/test/test_user_item.ioc +28 -0
- data/test/zeus.ioc +69 -0
- metadata +103 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2013 Matt Jezorek
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/RubyIOC.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "RubyIOC/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "RubyIOC"
|
7
|
+
s.version = RubyIOC::VERSION
|
8
|
+
s.authors = ["Matt Jezorek"]
|
9
|
+
s.email = ["mjezorek@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{RubyIOC is a ruby library used for indicators of compromise}
|
12
|
+
s.description = %q{RubyIOC is a ruby library used for indicators of compromise}
|
13
|
+
|
14
|
+
s.rubyforge_project = "RubyIOC"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "roxml"
|
24
|
+
end
|
data/lib/RubyIOC.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
require "rexml/document"
|
14
|
+
|
15
|
+
require "RubyIOC/version"
|
16
|
+
require "RubyIOC/platform"
|
17
|
+
require "RubyIOC/iocterm"
|
18
|
+
require "RubyIOC/iocitem"
|
19
|
+
require "RubyIOC/ioc"
|
20
|
+
require "RubyIOC/scanner"
|
21
|
+
|
22
|
+
=begin rdoc
|
23
|
+
RubyIOC is a simple gem that will allow the scanning of a system with indicators of compromise. RubyIOC will not tell you if the machine
|
24
|
+
is compromised or not but it will give you a score and what indicators have been found. Ideally you will want to see 0% and 0 found indicators.
|
25
|
+
However you may come back with 1% ond 2 indicators out of 200. It will also provide you a reference to the found indicators. From here you
|
26
|
+
can investigate whatever machine you wish to investigate.
|
27
|
+
|
28
|
+
Please note that when you use this software you are running on possibly compromised machiens, any credentials you use to facilitate the scan
|
29
|
+
should be considered compromised
|
30
|
+
=end
|
31
|
+
|
32
|
+
|
33
|
+
class String
|
34
|
+
def to_bool
|
35
|
+
return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
|
36
|
+
return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
|
37
|
+
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
|
38
|
+
end
|
39
|
+
end
|
data/lib/RubyIOC/ioc.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
|
14
|
+
=begin rdoc
|
15
|
+
=end
|
16
|
+
require "roxml"
|
17
|
+
|
18
|
+
module RubyIOC
|
19
|
+
|
20
|
+
class IndicatorItem
|
21
|
+
include ROXML
|
22
|
+
xml_name 'IndicatorItem'
|
23
|
+
xml_reader :id, :from => "@id"
|
24
|
+
xml_reader :condition, :from => "@condition"
|
25
|
+
xml_reader :context, :from => "Context"
|
26
|
+
xml_reader :content, :from => "Content"
|
27
|
+
xml_reader :document, :from => "@document", :in => "Context"
|
28
|
+
xml_reader :search, :from => "@search", :in => "Context"
|
29
|
+
xml_reader :context_type, :from => "@type", :in => "Context"
|
30
|
+
xml_reader :content_type, :from => "@type", :in => "Content"
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
class Indicator
|
35
|
+
include ROXML
|
36
|
+
xml_name 'Indicator'
|
37
|
+
xml_reader :id, :from => "@id"
|
38
|
+
xml_reader :operator, :from => "@operator"
|
39
|
+
xml_reader :indicator_item, :as => [RubyIOC::IndicatorItem]
|
40
|
+
xml_reader :indicators, :as => [RubyIOC::Indicator]
|
41
|
+
end
|
42
|
+
|
43
|
+
class IOC
|
44
|
+
include ROXML
|
45
|
+
=begin rdoc
|
46
|
+
This class is to create the IOC XML file so that we can read it in and process it easily
|
47
|
+
=end
|
48
|
+
xml_reader :id, :from => "@id"
|
49
|
+
xml_reader :last_modified, :from => "@last-modified"
|
50
|
+
xml_reader :short_description
|
51
|
+
xml_reader :description
|
52
|
+
xml_reader :keywords
|
53
|
+
xml_reader :authored_by
|
54
|
+
xml_reader :authored_date
|
55
|
+
xml_reader :links
|
56
|
+
xml_reader :indicators, :as => [RubyIOC::Indicator], :in => "definition"
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
module RubyIOC
|
14
|
+
module IOCItem
|
15
|
+
class IOCItemFactory
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
IOCItemFactory.load
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_type
|
22
|
+
""
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
|
29
|
+
@@factories = []
|
30
|
+
|
31
|
+
def IOCItemFactory.add_factory(factory)
|
32
|
+
@@factories.push(factory)
|
33
|
+
end
|
34
|
+
|
35
|
+
def IOCItemFactory.factories
|
36
|
+
@@factories
|
37
|
+
end
|
38
|
+
|
39
|
+
def IOCItemFactory.item_for(type)
|
40
|
+
@@factories.each { |itemfactory|
|
41
|
+
itf = itemfactory.new
|
42
|
+
if itf.get_type == type
|
43
|
+
return itf.create
|
44
|
+
end
|
45
|
+
}
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def IOCItemFactory.load
|
50
|
+
directory = File.expand_path(File.dirname(__FILE__)) + "/iocitem"
|
51
|
+
Dir.open(directory).each { |fn|
|
52
|
+
next unless (fn =~ /[.]rb$/)
|
53
|
+
require "#{directory}/#{fn}"
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
RubyIOC::IOCItem::IOCItemFactory.load
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
module RubyIOC
|
14
|
+
module IOCItem
|
15
|
+
class ArpEntryItem < RubyIOC::IOCTerm
|
16
|
+
def get_type
|
17
|
+
"ArpEntryItem"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ArpEntryItemFactory < RubyIOC::IOCItem::IOCItemFactory
|
22
|
+
def get_type
|
23
|
+
"ArpEntryItem"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
ArpEntryItem.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
ArpEntryItemFactory.add_factory(ArpEntryItemFactory)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
module RubyIOC
|
14
|
+
module IOCItem
|
15
|
+
class CookieHistoryItem < RubyIOC::IOCTerm
|
16
|
+
def get_type
|
17
|
+
"CookieHistoryItem"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class CookieHistoryItemFactory < RubyIOC::IOCItem::IOCItemFactory
|
22
|
+
def get_type
|
23
|
+
"CookieHistoryItem"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
CookieHistoryItem.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
CookieHistoryItemFactory.add_factory(CookieHistoryItemFactory)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
module RubyIOC
|
14
|
+
module IOCItem
|
15
|
+
class DiskItem < RubyIOC::IOCTerm
|
16
|
+
def get_type
|
17
|
+
"DiskItem"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class DiskItemFactory < RubyIOC::IOCItem::IOCItemFactory
|
22
|
+
def get_type
|
23
|
+
"DiskItem"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
DiskItem.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
DiskItemFactory.add_factory(DiskItemFactory)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
module RubyIOC
|
14
|
+
module IOCItem
|
15
|
+
class DnsEntryItem < RubyIOC::IOCTerm
|
16
|
+
def get_type
|
17
|
+
"DnsEntryItem"
|
18
|
+
end
|
19
|
+
|
20
|
+
def scan(indicator)
|
21
|
+
if RubyIOC::Platform.windows?
|
22
|
+
return search_windows_dns(indicator)
|
23
|
+
else
|
24
|
+
puts "Not implemented on this platform yet"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def search_windows_dns(indicator)
|
29
|
+
dns = get_windows_dns_cache
|
30
|
+
puts dns.to_yaml
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_windows_dns_cache
|
35
|
+
dns = []
|
36
|
+
dns_cache =`ipconfig /displaydns`
|
37
|
+
blocks = dns_cache.split(/\n\n/)
|
38
|
+
blocks.each do | block |
|
39
|
+
#puts block
|
40
|
+
temp = {}
|
41
|
+
temp[:record_name] = block.match(/\s*Record Name.*:\s(?<record>.*)/).to_a[1]
|
42
|
+
temp[:record_type] = block.match(/\s*Record Type.*:\s(?<record>.*)/).to_a[1]
|
43
|
+
temp[:time_to_live] = block.match(/\s*Time To Live.*:\s(?<record>.*)/).to_a[1]
|
44
|
+
temp[:data_length] = block.match(/\s*Data Length.*:\s(?<record>.*)/).to_a[1]
|
45
|
+
temp[:section] = block.match(/\s*Section.*:\s(?<record>.*)/).to_a[1]
|
46
|
+
temp[:a_record] = block.match(/\s*A \(Host\) Record.*:\s(?<record>.*)/).to_a[1]
|
47
|
+
temp[:cname] = block.match(/\s*CNAME Record.*:\s(?<record>.*)/).to_a[1]
|
48
|
+
dns << temp
|
49
|
+
end
|
50
|
+
return dns
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class DnsEntryItemFactory < RubyIOC::IOCItem::IOCItemFactory
|
55
|
+
def get_type
|
56
|
+
"DnsEntryItem"
|
57
|
+
end
|
58
|
+
|
59
|
+
def create
|
60
|
+
DnsEntryItem.new
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
DnsEntryItemFactory.add_factory(DnsEntryItemFactory)
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2013 Matt Jezorek
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
4
|
+
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
5
|
+
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
#
|
7
|
+
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
#
|
9
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
10
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
11
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
12
|
+
# IN THE SOFTWARE.
|
13
|
+
module RubyIOC
|
14
|
+
module IOCItem
|
15
|
+
class DriverItem < RubyIOC::IOCTerm
|
16
|
+
def get_type
|
17
|
+
"DriverItem"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class DriverItemFactory < RubyIOC::IOCItem::IOCItemFactory
|
22
|
+
def get_type
|
23
|
+
"DriverItem"
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
DriverItem.new
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
DriverItemFactory.add_factory(DriverItemFactory)
|
32
|
+
end
|
33
|
+
end
|