After mucking around getting mysql and MySQLdb libs to compile and install properly with python on OS-Lion I spent a couple of hours mucking around testing connecting to a remote db hosted on GoDaddy.
I came up with this simple test harness to perform a couple of simple tests on the link to make sure that it can be raised and is working correctly.
#!/usr/bin/python
import sys, re
import os, glob, MySQLdb, _mysql
import socket, subprocess
def main():
DB = 'adminsecscan'
DB_HOST = '50.63.244.10'
DB_USER = 'adminsecscan'
DB_PASSWORD = 'Password'
conn = MySQLdb.Connection(db=DB, host=DB_HOST,port=3306, user=DB_USER,passwd=DB_PASSWORD)
print conn.get_server_info()
myCursor = conn.cursor()
myCursor.execute("show databases;")
rows = myCursor.fetchall()
for row in rows:
print row
conn.close
if __name__ == '__main__':
main()
Next steps will be to develop a schema and parse the XML output and add the scans to the DB, also enumerate the devices connected to the network and store them in a table that can be used to show connection to the network overtime.
The other idea is to use one of the packet capture libraries like pcapy to sniff the RDP or DHCP traffic and grab to IP and MAC Addresses of new devices as they join the network, so a more comprehensive scan can be performed.