Commit 5a6ab532 authored by Pieter-Jan Moreels's avatar Pieter-Jan Moreels
Browse files

Merge remote-tracking branch 'upstream/master'

parents 9d350a24 3e01c341
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ from lib.Config import Configuration
import lib.DatabaseLayer as dbLayer

import csv
import argparse

# dictionary
exploitdburl = Configuration.getexploitdbDict()
@@ -29,6 +30,11 @@ db = Configuration.getMongoConnection()
exploitdb = db.exploitdb
info = db.info

argparser = argparse.ArgumentParser(description='Populate/update the exploitdb ref database')
argparser.add_argument('-v', action='store_true', help='verbose output', default=False)
args = argparser.parse_args()


try:
    f = Configuration.getFile(exploitdburl)
except:
@@ -53,6 +59,8 @@ bulk = exploitdb.initialize_ordered_bulk_op()
with open(csvfile, newline='') as csvtoparse:
    exploitcsv = csv.DictReader(csvtoparse, delimiter=',')
    for row in exploitcsv:
        if args.v:
            print ("{} ({}) Imported".format(row['id'],row['description']))
        bulk.find({'id': row['id']}).upsert().update({"$set": {'description': row['description'], 'type': row['type'], 'date': row['date'], 'port': row['port'], 'author': row['author'], 'file': row['file'], 'platform': row['platform'], 'id': row['id']}})

bulk.execute()