scandb 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/README.txt +5 -5
- data/Rakefile +5 -5
- data/lib/scandb/database.rb +18 -6
- data/lib/scandb/host.rb +13 -4
- data/lib/scandb/host_name.rb +5 -1
- data/lib/scandb/model.rb +3 -2
- data/lib/scandb/nmap.rb +8 -3
- data/lib/scandb/os_class_guess.rb +3 -0
- data/lib/scandb/os_match.rb +1 -1
- data/lib/scandb/os_match_guess.rb +3 -0
- data/lib/scandb/port.rb +1 -3
- data/lib/scandb/runner.rb +23 -2
- data/lib/scandb/scanned_port.rb +3 -2
- data/lib/scandb/service.rb +1 -3
- data/lib/scandb/version.rb +1 -1
- metadata +9 -9
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
= ScanDB
|
2
2
|
|
3
3
|
* http://scandb.rubyforge.org/
|
4
|
-
* Postmodern
|
4
|
+
* Postmodern (postmodern.mod3 at gmail.com)
|
5
5
|
|
6
6
|
== DESCRIPTION:
|
7
7
|
|
@@ -15,9 +15,9 @@ various network scanning utilities.
|
|
15
15
|
== REQUIREMENTS:
|
16
16
|
|
17
17
|
* DataMapper:
|
18
|
-
* do_sqlite3 >= 0.9.
|
19
|
-
* dm-core >= 0.9.
|
20
|
-
* dm-types >= 0.9.
|
18
|
+
* do_sqlite3 >= 0.9.9
|
19
|
+
* dm-core >= 0.9.9
|
20
|
+
* dm-types >= 0.9.9
|
21
21
|
* libxml-ruby
|
22
22
|
|
23
23
|
== INSTALL:
|
@@ -31,7 +31,7 @@ various network scanning utilities.
|
|
31
31
|
ScanDB - A library for importing and analyzing information generated by
|
32
32
|
various network scanning utilities.
|
33
33
|
|
34
|
-
Copyright (c) 2008 Hal Brodigan (postmodern.mod3 at gmail.com)
|
34
|
+
Copyright (c) 2008-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
|
35
35
|
|
36
36
|
This program is free software; you can redistribute it and/or modify
|
37
37
|
it under the terms of the GNU General Public License as published by
|
data/Rakefile
CHANGED
@@ -6,13 +6,13 @@ require './lib/scandb/version.rb'
|
|
6
6
|
|
7
7
|
Hoe.new('scandb', ScanDB::VERSION) do |p|
|
8
8
|
p.rubyforge_name = 'scandb'
|
9
|
-
p.developer('Postmodern
|
9
|
+
p.developer('Postmodern', 'postmodern.mod3@gmail.com')
|
10
10
|
p.remote_rdoc_dir = ''
|
11
11
|
p.extra_deps = [
|
12
|
-
['do_sqlite3', '>=0.9.
|
13
|
-
['dm-core', '>=0.9.
|
14
|
-
['dm-types', '>=0.9.
|
15
|
-
['dm-serializer','>=0.9.
|
12
|
+
['do_sqlite3', '>=0.9.9'],
|
13
|
+
['dm-core', '>=0.9.9'],
|
14
|
+
['dm-types', '>=0.9.9'],
|
15
|
+
['dm-serializer','>=0.9.9'],
|
16
16
|
'libxml-ruby'
|
17
17
|
]
|
18
18
|
end
|
data/lib/scandb/database.rb
CHANGED
@@ -40,13 +40,16 @@ module ScanDB
|
|
40
40
|
CONFIG_FILE = File.join(Config::PATH,'database.yml')
|
41
41
|
|
42
42
|
# Default log path
|
43
|
-
DEFAULT_LOG_PATH = File.join(Config::PATH,'
|
43
|
+
DEFAULT_LOG_PATH = File.join(Config::PATH,'database.log')
|
44
44
|
|
45
45
|
# Default log level
|
46
|
-
DEFAULT_LOG_LEVEL = :
|
46
|
+
DEFAULT_LOG_LEVEL = :error
|
47
47
|
|
48
48
|
# Default database configuration
|
49
|
-
DEFAULT_CONFIG =
|
49
|
+
DEFAULT_CONFIG = {
|
50
|
+
:adapter => :sqlite3,
|
51
|
+
:database => File.join(Config::PATH,'scandb.db')
|
52
|
+
}
|
50
53
|
|
51
54
|
#
|
52
55
|
# Returns the Database configuration that is stored in the
|
@@ -78,6 +81,13 @@ module ScanDB
|
|
78
81
|
@@scandb_database_config = configuration
|
79
82
|
end
|
80
83
|
|
84
|
+
#
|
85
|
+
# Returns the current Database log.
|
86
|
+
#
|
87
|
+
def Database.log
|
88
|
+
@@scandb_database_log ||= nil
|
89
|
+
end
|
90
|
+
|
81
91
|
#
|
82
92
|
# Setup the Database log with the given _options_.
|
83
93
|
#
|
@@ -92,8 +102,7 @@ module ScanDB
|
|
92
102
|
stream = (options[:stream] || File.new(path,'w+'))
|
93
103
|
level = (options[:level] || DEFAULT_LOG_LEVEL)
|
94
104
|
|
95
|
-
DataMapper::Logger.new(stream,level)
|
96
|
-
return nil
|
105
|
+
return @@scandb_database_log = DataMapper::Logger.new(stream,level)
|
97
106
|
end
|
98
107
|
|
99
108
|
#
|
@@ -102,7 +111,10 @@ module ScanDB
|
|
102
111
|
# the Database.
|
103
112
|
#
|
104
113
|
def Database.setup(configuration=Database.config,&block)
|
105
|
-
|
114
|
+
# setup the logging
|
115
|
+
Database.setup_log unless Database.log
|
116
|
+
|
117
|
+
# setup the repository
|
106
118
|
DataMapper.setup(Model::REPOSITORY_NAME, configuration)
|
107
119
|
|
108
120
|
block.call if block
|
data/lib/scandb/host.rb
CHANGED
@@ -33,16 +33,25 @@ module ScanDB
|
|
33
33
|
include Model
|
34
34
|
|
35
35
|
# The IP address of the Host
|
36
|
-
property :ip, String
|
36
|
+
property :ip, String, :index => true
|
37
|
+
|
38
|
+
# The Date and Time at which the host was first scanned
|
39
|
+
property :scanned_at, DateTime
|
37
40
|
|
38
41
|
# The host-names of the host
|
39
|
-
has n, :names,
|
42
|
+
has n, :names,
|
43
|
+
:order => [:scanned_at.desc],
|
44
|
+
:class_name => 'HostName'
|
40
45
|
|
41
46
|
# The OS Class guesses of the host
|
42
|
-
has n, :os_class_guesses,
|
47
|
+
has n, :os_class_guesses,
|
48
|
+
:order => [:scanned_at.desc],
|
49
|
+
:class_name => 'OSClassGuess'
|
43
50
|
|
44
51
|
# The OS Match guesses of the host
|
45
|
-
has n, :os_match_guesses,
|
52
|
+
has n, :os_match_guesses,
|
53
|
+
:order => [:scanned_at.desc],
|
54
|
+
:class_name => 'OSMatchGuess'
|
46
55
|
|
47
56
|
# The scanned ports of the host
|
48
57
|
has n, :scanned_ports
|
data/lib/scandb/host_name.rb
CHANGED
data/lib/scandb/model.rb
CHANGED
@@ -24,6 +24,7 @@
|
|
24
24
|
require 'scandb/database'
|
25
25
|
|
26
26
|
require 'dm-core'
|
27
|
+
require 'dm-types'
|
27
28
|
require 'dm-serializer'
|
28
29
|
|
29
30
|
module ScanDB
|
@@ -38,11 +39,11 @@ module ScanDB
|
|
38
39
|
include DataMapper::Resource
|
39
40
|
include DataMapper::AutoMigrations
|
40
41
|
|
42
|
+
property :id, Serial
|
43
|
+
|
41
44
|
def self.default_repository_name
|
42
45
|
Model::REPOSITORY_NAME
|
43
46
|
end
|
44
|
-
|
45
|
-
property :id, Serial
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
data/lib/scandb/nmap.rb
CHANGED
@@ -32,11 +32,16 @@ module ScanDB
|
|
32
32
|
|
33
33
|
#
|
34
34
|
# Imports scan information from a Nmap XML scan file, specified by
|
35
|
-
# the _path_. Returns
|
36
|
-
# it will be passed the newly created
|
35
|
+
# the _path_. Returns the total number of Host objects that were
|
36
|
+
# imported. If a _block_ is given it will be passed the newly created
|
37
|
+
# Host object.
|
37
38
|
#
|
38
39
|
# Nmap.import_xml('path/to/scan.xml')
|
39
|
-
# # =>
|
40
|
+
# # => 124
|
41
|
+
#
|
42
|
+
# Nmap.import_xml('path/to/scan.xml') do |host|
|
43
|
+
# puts host.ip
|
44
|
+
# end
|
40
45
|
#
|
41
46
|
def Nmap.import_xml(path,&block)
|
42
47
|
doc = XML::Document.file(path)
|
data/lib/scandb/os_match.rb
CHANGED
@@ -32,6 +32,9 @@ module ScanDB
|
|
32
32
|
# The accuracy of the guess
|
33
33
|
property :accuracy, Integer
|
34
34
|
|
35
|
+
# The Date and Time when the OSMatch was first guessed
|
36
|
+
property :scanned_at, DateTime
|
37
|
+
|
35
38
|
# The OS Match for the guess
|
36
39
|
belongs_to :os_match, :class_name => 'OSMatch'
|
37
40
|
|
data/lib/scandb/port.rb
CHANGED
@@ -25,8 +25,6 @@ require 'scandb/model'
|
|
25
25
|
require 'scandb/host'
|
26
26
|
require 'scandb/service'
|
27
27
|
|
28
|
-
require 'dm-types/enum'
|
29
|
-
|
30
28
|
module ScanDB
|
31
29
|
class Port
|
32
30
|
|
@@ -37,7 +35,7 @@ module ScanDB
|
|
37
35
|
property :protocol, Enum[:tcp, :udp]
|
38
36
|
|
39
37
|
# The port number
|
40
|
-
property :number, Integer
|
38
|
+
property :number, Integer, :index => true
|
41
39
|
|
42
40
|
# The scanned ports related to this port
|
43
41
|
has n, :scanned, :class_name => 'ScannedPort'
|
data/lib/scandb/runner.rb
CHANGED
@@ -34,11 +34,28 @@ module ScanDB
|
|
34
34
|
#
|
35
35
|
def Runner.command_line(args)
|
36
36
|
options = OpenStruct.new
|
37
|
+
options.log = {}
|
37
38
|
|
38
39
|
opts = OptionParser.new do |opts|
|
39
|
-
opts.banner = 'usage: scandb [-v] [-d URI] [--import-nmap FILE | -L | -p PORT | -s NAME]'
|
40
|
+
opts.banner = 'usage: scandb [-v] [-l FILE] [-d URI] [--import-nmap FILE | -L | -p PORT | -s NAME]'
|
40
41
|
|
41
|
-
opts.on('-
|
42
|
+
opts.on('-l','--log FILE','The FILE to use for logging Database activity.','Defaults to ~/.scandb/database.log') do |file|
|
43
|
+
options.log[:path] = file
|
44
|
+
end
|
45
|
+
|
46
|
+
opts.on('--log-level LEVEL','Specifies the log-level.','Defaults to info') do |level|
|
47
|
+
options.log[:level] = level.to_sym
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.on('--log-stdout','Send log messages to stdout') do
|
51
|
+
options.log[:stream] = STDOUT
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on('--disable-log','Alias for --log-level off') do
|
55
|
+
options.log[:level] = :off
|
56
|
+
end
|
57
|
+
|
58
|
+
opts.on('-d','--database URI','The URI for the Database.') do |uri|
|
42
59
|
options.database = uri
|
43
60
|
end
|
44
61
|
|
@@ -98,6 +115,10 @@ module ScanDB
|
|
98
115
|
|
99
116
|
opts.parse!(args)
|
100
117
|
|
118
|
+
unless options.log.empty?
|
119
|
+
Database.setup_log(options.log)
|
120
|
+
end
|
121
|
+
|
101
122
|
Database.setup(options.database || Database.config)
|
102
123
|
|
103
124
|
if options.import
|
data/lib/scandb/scanned_port.rb
CHANGED
@@ -26,8 +26,6 @@ require 'scandb/service'
|
|
26
26
|
require 'scandb/port'
|
27
27
|
require 'scandb/host'
|
28
28
|
|
29
|
-
require 'dm-types/enum'
|
30
|
-
|
31
29
|
module ScanDB
|
32
30
|
class ScannedPort
|
33
31
|
|
@@ -37,6 +35,9 @@ module ScanDB
|
|
37
35
|
# <tt>:closed</tt>)
|
38
36
|
property :status, Enum[:open, :filtered, :closed]
|
39
37
|
|
38
|
+
# The Date and Time at which the port was first scanned
|
39
|
+
property :scanned_at, DateTime
|
40
|
+
|
40
41
|
# The Service that is running on the scanned port
|
41
42
|
belongs_to :service
|
42
43
|
|
data/lib/scandb/service.rb
CHANGED
@@ -23,15 +23,13 @@
|
|
23
23
|
|
24
24
|
require 'scandb/model'
|
25
25
|
|
26
|
-
require 'dm-types/enum'
|
27
|
-
|
28
26
|
module ScanDB
|
29
27
|
class Service
|
30
28
|
|
31
29
|
include Model
|
32
30
|
|
33
31
|
# Name of the service
|
34
|
-
property :name, String
|
32
|
+
property :name, String, :index => true
|
35
33
|
|
36
34
|
# Scanned ports that were found to be running the service
|
37
35
|
has n, :scanned, :class_name => 'ScannedPort'
|
data/lib/scandb/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scandb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Postmodern
|
7
|
+
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-01-09 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.9
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: dm-core
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.9.
|
33
|
+
version: 0.9.9
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: dm-types
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.9.
|
43
|
+
version: 0.9.9
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: dm-serializer
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.9.
|
53
|
+
version: 0.9.9
|
54
54
|
version:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: libxml-ruby
|
@@ -70,7 +70,7 @@ dependencies:
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 1.8.
|
73
|
+
version: 1.8.2
|
74
74
|
version:
|
75
75
|
description: ScanDB is a library for importing and analyzing information generated by various network scanning utilities.
|
76
76
|
email:
|
@@ -132,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
132
|
requirements: []
|
133
133
|
|
134
134
|
rubyforge_project: scandb
|
135
|
-
rubygems_version: 1.3.
|
135
|
+
rubygems_version: 1.3.1
|
136
136
|
signing_key:
|
137
137
|
specification_version: 2
|
138
138
|
summary: ScanDB is a library for importing and analyzing information generated by various network scanning utilities.
|