The unified diff between revisions [a2be3834..] and [10dab4ba..] is displayed below. It can also be downloaded as a raw diff.
#
#
# patch "get.py"
# from [ac6a59f4fd51dd35b87efd1627555f23d221500b]
# to [e614695939599851ce2a253b70b9e0318ac0e317]
#
# patch "plugins/postgresql.py"
# from [fe2f93a6eb8b4398f11d757375626a0b279e2315]
# to [d5a85a5e564d3dcc09cfb170575c0edf2b38bd36]
#
# patch "scan.py"
# from [d3daf2933d7bc372838c052440a35228248a4f00]
# to [3933e79c8966c423898e301b75f0bb0df18cb516]
#
============================================================
--- get.py ac6a59f4fd51dd35b87efd1627555f23d221500b
+++ get.py e614695939599851ce2a253b70b9e0318ac0e317
@@ -7,15 +7,15 @@ import os
import sys
import os
+import getopt
import pipes
import popen2
import string
+from getpass import getpass
from goatpy import smbwrapper
def retrieve_share(share):
- cmd = smbwrapper.build_basic_smbclient(target, workgroup) + ' ' + pipes.quote('//%s/%s' % (node, share))
- print
- print "Executing:", cmd
+ cmd = smbwrapper.build_basic_smbclient(target, workgroup, username=user, password=password) + ' ' + pipes.quote('//%s/%s' % (node, share))
os.system(cmd)
def print_share_menu():
@@ -35,20 +35,29 @@ if __name__ == "__main__":
except: pass
if __name__ == "__main__":
- if len(sys.argv) == 2:
- target = sys.argv[1]
- node, workgroup = smbwrapper.netbios_lookup(target)
- if not node or not workgroup:
- print "Netbios lookup failed."
- shares = map(lambda x: x[0], smbwrapper.list_shared_resources(target, node, workgroup))
+ share = None
+ user = None
+
+ matched, remain = getopt.getopt(sys.argv[1:], "u:s:")
+ for opt, value in matched:
+ if opt == '-u': user = value
+ elif opt == '-s': share = value
+ if len(remain) != 1:
+ sys.stderr.write("usage: %s [OPTION..] target\n" % (sys.argv[0]))
+ sys.exit(1)
+ target = remain[0]
+
+ if user != None: password = getpass('Enter password (warning; will appear in process list): ')
+ node, workgroup = smbwrapper.netbios_lookup(target)
+ if not node or not workgroup:
+ sys.stderr.write("Netbios lookup failed.")
+ sys.exit(1)
+
+ if not share:
+ shares = map(lambda x: x[0], smbwrapper.list_shared_resources(target, node, workgroup, username=user, password=password))
shares.sort()
while True:
print_share_menu()
- elif len(sys.argv) == 3:
- target = sys.argv[1]
- node, workgroup = smbwrapper.netbios_lookup(target)
- retrieve_share(sys.argv[2])
else:
- sys.stderr.write("usage: %s <ip> [share]\n" % (sys.argv[0]))
- sys.exit(1)
+ retrieve_share(share)
============================================================
--- plugins/postgresql.py fe2f93a6eb8b4398f11d757375626a0b279e2315
+++ plugins/postgresql.py d5a85a5e564d3dcc09cfb170575c0edf2b38bd36
@@ -31,6 +31,7 @@ def write_results(library, host, plugins
def write_results(library, host, plugins, results):
lock.acquire()
+ cnx.query("BEGIN")
for result in results:
# the first time we see a host, delete prior history for those plugins which ran in this scan
if (result.address[0]) not in seen_hosts:
@@ -48,6 +49,7 @@ def write_results(library, host, plugins
values = map(q, values)
query += ','.join(values) + ")"
cnx.query(query)
+ cnx.query("COMMIT")
lock.release()
def write_errors(library, host, errors):
============================================================
--- scan.py d3daf2933d7bc372838c052440a35228248a4f00
+++ scan.py 3933e79c8966c423898e301b75f0bb0df18cb516
@@ -87,8 +87,9 @@ class WaitThread(threading.Thread):
procs = os.wait()
print "Processes have terminated:", procs
except: pass
- import time
- time.sleep(1)
+ # for some reason, sometimes this fails unless
+ # this check is here. A bit mysterious.
+ if time != None: time.sleep(1)
class PluginLibrary:
def __init__(self, config):