Finally able to properly task scans
This commit is contained in:
Родитель
f8a57627eb
Коммит
71a04ed44f
|
@ -1,7 +1,6 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
psql -v ON_ERROR_STOP=1 --username "sshobs" <<-EOSQL
|
||||
CREATE DATABASE ssh_observatory;
|
||||
GRANT ALL PRIVILEGES ON DATABASE ssh_observatory TO sshobs;
|
||||
EOSQL
|
||||
createdb -O sshobs --no-password dbname
|
||||
createdb ssh_observatory
|
||||
psql -U sshobs -d ssh_observatory < /app/schema.sql
|
|
@ -1,7 +1,7 @@
|
|||
-- Define the scan table
|
||||
CREATE TABLE IF NOT EXISTS scans (
|
||||
id SERIAL PRIMARY KEY,
|
||||
timestamp timestamp default current_timestamp
|
||||
timestamp timestamp default current_timestamp,
|
||||
target VARCHAR(255) NOT NULL,
|
||||
port SMALLINT NOT NULL,
|
||||
state VARCHAR(255) NOT NULL,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM postgres
|
||||
MAINTAINER Jonathan Claudius
|
||||
ADD ./database/init-user-db.sh /docker-entrypoint-initdb.d/
|
||||
ADD ./database/schema.sql /docker-entrypoint-initdb.d/
|
||||
ADD ./database/schema.sql /app/schema.sql
|
||||
ADD ./database/init-user-db.sh /docker-entrypoint-initdb.d/
|
|
@ -3,7 +3,9 @@ require 'uri'
|
|||
require 'json'
|
||||
|
||||
target = ARGV[0] || "ssh.mozilla.com"
|
||||
api_server = URI.parse("https://sshscan.rubidus.com")
|
||||
#api_server = URI.parse("https://sshscan.rubidus.com")
|
||||
api_server = URI.parse("http://127.0.0.1:8000")
|
||||
|
||||
|
||||
warn "[+] Submitting scan request for #{target}"
|
||||
response = Net::HTTP.post_form(api_server + "/api/v1/scan", {"target" => target})
|
||||
|
|
|
@ -214,6 +214,9 @@ https://github.com/mozilla/ssh_scan_api/wiki/ssh_scan-Web-API\n"
|
|||
end
|
||||
|
||||
get '/stats' do
|
||||
require 'pry'
|
||||
binding.pry
|
||||
|
||||
{
|
||||
"SCAN_STATES" => {
|
||||
"QUEUED" => settings.db.queue_count,
|
||||
|
@ -261,7 +264,6 @@ https://github.com/mozilla/ssh_scan_api/wiki/ssh_scan-Web-API\n"
|
|||
set :db, SSHScan::Database.from_hash(options)
|
||||
set :target_validator, SSHScan::TargetValidator.new(options["config_file"])
|
||||
set :results, {}
|
||||
set :stats, SSHScan::Stats.new
|
||||
set :authentication, options["authentication"]
|
||||
set :authenticator, SSHScan::Authenticator.from_config_file(
|
||||
options["config_file"]
|
||||
|
|
|
@ -10,14 +10,15 @@ module SSHScan
|
|||
end
|
||||
|
||||
# Helps us create a SSHScan::DB::Postgres object with a hash
|
||||
def self.from_hash(opts)
|
||||
database = opts["name"] || "ssh_observatory"
|
||||
server = ENV['sshscan.database.host'] || opts["server"]
|
||||
port = opts["port"]
|
||||
username = opts["username"]
|
||||
password = opts["password"]
|
||||
def self.from_hash(opts)
|
||||
client_options = {}
|
||||
client_options[:host] = ENV['sshscan.database.host'] || opts["server"]
|
||||
client_options[:port] = opts[:port] = opts["port"] || 5432
|
||||
client_options[:user] = opts["username"] if opts["username"]
|
||||
client_options[:password] = opts["password"] if opts["password"]
|
||||
client_options[:dbname] = opts["name"] || "ssh_observatory"
|
||||
|
||||
client = PG.connect( host: server, port: port, user: username, password: password, dbname: database )
|
||||
client = PG.connect(client_options)
|
||||
return SSHScan::DB::Postgres.new(client)
|
||||
end
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ require 'tempfile'
|
|||
describe SSHScan::DB::Postgres do
|
||||
before :each do
|
||||
opts = {
|
||||
:username => "sshobs",
|
||||
:database => "ssh_observatory"
|
||||
"username" => "sshobs",
|
||||
"database" => "ssh_observatory"
|
||||
}
|
||||
|
||||
@postgres = SSHScan::DB::Postgres.from_hash(opts)
|
||||
|
|
Загрузка…
Ссылка в новой задаче