Commit 0e8b7136 authored by Jason Frisvold's avatar Jason Frisvold
Browse files

- Add code to encrypt the output file

- Remove quotes from the config file, they're not needed and cause problems
parent 1bd5a2a3
......@@ -33,14 +33,15 @@ datadir = spawner_data
timingdb = timing.db
# This defines the location of the nmap binary, including the binary name
nmap_binary = '/usr/local/bin/nmap'
nmap_binary = /usr/bin/nmap
# The directory where output from scans should be placed. Include the trailing
# slash.
output_dir = '/opt/skynet/output/'
output_dir = /opt/skynet/output/
# Location of the gpg binary. This should be the full path and binary name.
gpg_binary = '/usr/bin/gpg'
gpg_binary = /usr/bin/gpg
# Location and name of the gpg key to use for encrypting scan results.
gpg_key = datadir + 'spawner.gpg.key'
# Name of the gpg key to use for encrypting scan results. This key needs to be
# imported into gpg
gpg_key = <keyname>
......@@ -29,6 +29,7 @@ import os, os.path
from subprocess import Popen
import re
import shlex
import tempfile
sys.path.append('../libs')
from skynettimer import SkynetTimer
......@@ -316,11 +317,9 @@ def spawn_process(spawnlist):
nmap_options = timingcursor.fetchone()
nmap_filename = 'nmap_xml.' + str(timer) + '.' + str(start_time) + \
'.xml'
fd, tmpfile = tempfile.mkstemp()
optionlist = shlex.split(cfg['nmap_binary'] + ' -oX ' +
cfg['output_dir'] + nmap_filename + ' ' +
optionlist = shlex.split(cfg['nmap_binary'] + ' -oX ' + tmpfile + ' ' +
nmap_options[1] + ' ' + nmap_options[0])
logger.debug('Will spawn with options ' + str(optionlist))
......@@ -338,8 +337,20 @@ def spawn_process(spawnlist):
spawned.wait()
logger.debug('Timer ' + str(timer) + ' completed.')
logger.debug('Encrypting ' + nmap_filename + ' via GPG (' +
cfg['gpg_binary'] + ')')
nmap_filename = cfg['output_dir'] + 'nmap_xml.' + str(timer) + '.' + \
str(start_time) + '.xml.gpg'
cmd = (cfg['gpg_binary'], '--batch', '--yes', '--output', nmap_filename,
'--encrypt', '--recipient', cfg['gpg_key'], tmpfile)
logger.debug('Encrypting ' + tmpfile + ' via GPG (' +
str(cmd) + ')')
Popen(cmd).wait()
logger.debug('Deleting temporary file - ' + tmpfile)
os.remove(tmpfile)
sys.exit(0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment