def fs45gcheck( root='root', persistence='persistence' ): fuse.fuse_python_api=(0, 2) fs = fs45g() fs.root = root fs.persistence = persistence if fs.setup() == False: syslog.closelog() sys.exit(1) sums = fs.FSData.root.sha_sums() list = os.listdir(fs.persistence) deletelist=[] for dirs in list: path = fs.persistence + '/' + dirs files = os.listdir(path) for fn in files: fpath = path+'/'+fn if fn[:2]!=dirs: deletelist.append(fpath) print 'error dir: '+fpath elif tools.hashfile(fpath) != fn: deletelist.append(fpath) print 'error sha: ' + fpath elif not fn in sums: deletelist.append(fpath) print 'error in fs: ' + fpath for fpath in deletelist: os.unlink(fpath)
def fs45gcheck(root='root', persistence='persistence'): fuse.fuse_python_api = (0, 2) fs = fs45g() fs.root = root fs.persistence = persistence if fs.setup() == False: syslog.closelog() sys.exit(1) sums = fs.FSData.root.sha_sums() list = os.listdir(fs.persistence) deletelist = [] for dirs in list: path = fs.persistence + '/' + dirs files = os.listdir(path) for fn in files: fpath = path + '/' + fn if fn[:2] != dirs: deletelist.append(fpath) print 'error dir: ' + fpath elif tools.hashfile(fpath) != fn: deletelist.append(fpath) print 'error sha: ' + fpath elif not fn in sums: deletelist.append(fpath) print 'error in fs: ' + fpath for fpath in deletelist: os.unlink(fpath)
def run(sourceName, scope, ip,nodeName, dataFile, date, con): date=str(date) if(checkExists(dataFile, con)== False): print('Importing :', dataFile, ' from ', sourceName) hostsData = readFile(dataFile) hash=tools.hashfile(open(dataFile, "rb"),dataFile) store(sourceName,scope, ip, nodeName,hostsData, hash, date, con) else: print(dataFile + " already imported")
def run(sourceName,scope, sourceIP,nodeName, dataFile, date, portnames, con):#=getPortNames('adapters\\thirddata\\service-names-port-numbers.xml')): date=str(date) if(checkExists(dataFile, con)== False): print('Importing :', dataFile, ' from ', sourceName) hostsData = readFile(dataFile, portnames) hash=tools.hashfile(open(dataFile, "rb"),dataFile) store(sourceName, scope, sourceIP, nodeName, hostsData, hash, date, con) else: print(dataFile + " already imported")
def run(sourceName,scope, dataFile, date, con): if(checkExists(dataFile, con)== False): print('Importing :', dataFile, ' from ', sourceName) hostsData = hosts(dataFile) #timestamp = str(datetime.date.today()) hash=tools.hashfile(open(dataFile, "rb"),dataFile) #storeBasic(con) store(sourceName,scope, hostsData, hash, date, con) else: print(dataFile + " already imported")
def checkExists(dataF, con): hash = tools.hashfile(open(dataF, "rb"), dataF) result = None if con: result = con['metaelement'].fetchByExample({'hash': hash}, batchSize=100) if (len(result) != 0): return True else: return False
def run(sourceName,scope,mainIP, nodename ,dataFile, date, con): date=str(date) if(checkExists(dataFile, con)== False): print('Importing :', dataFile, ' from ', sourceName) hostsData = readFile(dataFile) hash=tools.hashfile(open(dataFile, "rb"),dataFile) store(sourceName, scope, mainIP, hostsData, hash, date, con) else: print(dataFile + " already imported") #run('pfSense_Config','system', "..\\data\\pfsense\\config-fw-01_localdomain.xml", tools.creationDate("..\\data\\pfsense\\config-fw-01_localdomain.xml"), createConArango('claimOmania')) #run('pfSense_Config','system', '10.1.1.1',"..\\data\\pfsense\\config-fw-01.localdomain-20170502161728.xml", tools.creationDate("..\\data\\pfsense\\config-fw-01.localdomain-20170502161728.xml"), createConArango('claimOmania'))
def run(sourceName,scope, sourceIP,nodeName, dataFile, date, con): date=str(date) if(checkExists(dataFile, con)== False): print('Importing :', dataFile, ' from ', sourceName) hostsData = readFile(dataFile) hash=tools.hashfile(open(dataFile, "rb"),dataFile) store(sourceName, scope, sourceIP, nodeName, hostsData, hash, date, con) else: print(dataFile + " already imported") #run('winscanner', '10.1.1.112',"..\\data\\p0f\\p0f_output", tools.creationDate("..\\data\\p0f\\p0f_output"), createConArango('claimOmania')) #run('winscanner', '10.1.1.112',"..\\data\\p0f\\p0f_output_allLANs", tools.creationDate("..\\data\\p0f\\p0f_output_allLANs"), createConArango('claimOmania')) #run('Wireshark', 'subnet','192.168.109.112','Winscanner',"..\\data\\wireshark\\summary-packets_fixed.xml", tools.creationDate("..\\data\\wireshark\\summary-packets_fixed.xml"), createConArango('claimOmania'))
def run(sourceName, scope, ip, nodeName, dataFile, date, con): date = str(date) if (checkExists(dataFile, con) == False): print('Importing :', dataFile, ' from ', sourceName) hostsData = readFile(dataFile) hash = tools.hashfile(open(dataFile, "rb"), dataFile) store(sourceName, scope, ip, nodeName, hostsData, hash, date, con) else: print(dataFile + " already imported") #run('Powershell-Get-UserAccounts','system', '192.168.109.21','bldad01',"..\\data\\bldad01\\UserAccounts.xml", tools.creationDate("..\\data\\bldad01\\ADDomainUsers.xml"), createConArango('claimOmania')) #run('Powershell-Get-UserAccounts','system', '192.168.109.23','bldde01',"..\\data\\bldde01\\UserAccounts.xml", tools.creationDate("..\\data\\bldde01\\ADDomainUsers.xml"), createConArango('claimOmania'))
def run(sourceName, scope, dataFile, date, con): date = str(date) if (checkExists(dataFile, con) == False): print('Importing :', dataFile, ' from ', sourceName) hostsData = readFile(dataFile) hash = tools.hashfile(open(dataFile, "rb"), dataFile) store(sourceName, scope, hostsData, hash, date, con) else: print(dataFile + " already imported") #run('HP-Procurve','system', "..\\data\\hp-procurve\\HP-Procurve_startup.txt", tools.creationDate("..\\data\\hp-procurve\\HP-Procurve_startup.txt"), createConArango('claimOmania')) #print(tools.creationDate("..\\data\\hp-procurve\\HP-Procurve_startup.txt")) #pprint(readFile("..\\data\\hp-procurve\\HP-Procurve_startup.txt"))