def main(): config = json.loads(fh.get_config()) db = dbh.connect_database(config['db_name'], config['db_port_passwords']) collection = db['passwords'] try: collection.create_index("password", unique=True) collection.create_index("hash.md5", unique=True) collection.create_index("hash.sha1", unique=True) collection.create_index("hash.sha224", unique=True) collection.create_index("hash.sha256", unique=True) collection.create_index("hash.sha384", unique=True) collection.create_index("hash.sha512", unique=True) except pymongo.errors.OperationFailure as e: print e sys.exit(1) documents = dbh.find_all_documents(collection) for document in documents: password = document['password'].encode('utf-8') leetspeak = simple_leetspeak(password) if leetspeak != password: hash_string = ph.hash_password(leetspeak) insert_one(collection, leetspeak, hash_string)
def main(): parser = argparse.ArgumentParser( description='Add mail addresses from file to your mongodb instance') parser.add_argument('-f, --file', metavar='F', required=True, dest='file', help='non structured document with leaked mail addresses') parser.add_argument('-l, --leak', metavar='L', required=True, dest='leak', help='set leaked website or organistion name here') args = parser.parse_args() config = json.loads(fh.get_config()) db = dbh.connect_database(config['mongodb_db'], config['mongodb_port']) collection = db['mails'] try: collection.create_index('mail', unique=True) except pymongo.errors.OperationFailure as e: print u'{}'.format(e) sys.exit(1) document = ' '.join(fh.load_document(args.file)) mail_address_list = mh.extract_mail_address(document) for mail_address in mail_address_list: mail_address = uh.handle_unicode(mail_address.strip().lower()) insert_one(collection, mail_address, args.leak)
def main(): config = json.loads(fh.get_config()) db = dbh.connect_database(config['mongodb_db'], config['mongodb_port']) collection = db['mails'] documents = dbh.find_all_documents(collection) for document in documents: post = {'mail': ph.remove_whitespace(document['mail'])} dbh.update_one(collection, document['_id'], post)
def main(): config = json.loads(fh.get_config()) db = dbh.connect_database(config['mongodb_db'], config['mongodb_port']) amount = db['passwords'].count() step = 50000 for index in xrange(0, amount, step): documents = dbh.find_documents(db['passwords'], index, (index + step)) for document in documents: password = document['password'] if match_ip_address(password) or match_mail_address( password) or match_full_url(password): dbh.delete_one(db.passwords, document['_id'], password)
def worker(passwords, args): config = json.loads(fh.get_config()) db = dbh.connect_database(config['mongodb_db'], config['mongodb_port']) collection = db['passwords'] for password in passwords: password = password.strip().replace(' ', '') if password and not mh.extract_mail_address(password): password_string = uh.handle_unicode(password) if len(password_string) > 3 and len(password_string) < 32 and not ph.test_md5(password_string): hash_string = ph.hash_password(password_string) add_password.insert_one(collection, password_string, hash_string) return
def main(): config = json.loads(fh.get_config()) db = dbh.connect_database(config['mongodb_db'], config['mongodb_port']) col_password = db['passwords'] col_mail = db['mails'] try: col_mail.create_index('mail', unique=True) col_password.create_index("password", unique=True) col_password.create_index("hash.md5", unique=True) col_password.create_index("hash.sha1", unique=True) col_password.create_index("hash.sha224", unique=True) col_password.create_index("hash.sha256", unique=True) col_password.create_index("hash.sha384", unique=True) col_password.create_index("hash.sha512", unique=True) except OperationFailure as e: print u'{}'.format(e) sys.exit(1) api = connect_twitter(config) items = get_user_timeline(api, 'checkmydump') lines = iterate_items(items) for line in lines: for string in line.split('\r\n'): password = ph.extract_pastebin_password( re.split(r',|>>|::| |\|', string)[0]) try: password = password.split(':')[0] except KeyError as e: pass if not mh.extract_mail_address(password): password_string = uh.handle_unicode(password) if len(password_string) > 3 and len( password_string) < 32 and not ph.test_md5( password_string): insert_password(col_password, password_string, ph.hash_password(password_string)) for mail_address in mh.extract_mail_address(''.join(lines)): mail_address = uh.handle_unicode(mail_address.strip().lower()) insert_mail(col_mail, mail_address, 'pastebin.com')
def main(): config = json.loads(fh.get_config()) db = dbh.connect_database(config['db_name'], config['db_port_mails']) collection_source = db.mails_import collection_target = db['mails'] documents = dbh.find_all_documents(collection_source) try: for document in documents: if len(document['leak']) > 1: for leak in document['leak']: insert_one(collection_target, document['mail'], leak) else: insert_one(collection_target, document['mail'], document['leak'][0]) dbh.delete_one(collection_source, document['_id'], document['mail']) except CursorNotFound as e: pass
def main(): parser = argparse.ArgumentParser( description='Add passwords from file to your mongodb instance') parser.add_argument('-f, --file', metavar='F', required=True, dest='file', help='file with absolute or relative path') parser.add_argument('-c, --create', action='store_true', dest='create') args = parser.parse_args() config = json.loads(fh.get_config()) documents = fh.load_document(args.file) db = dbh.connect_database(config['mongodb_db'], config['mongodb_port']) collection = db['passwords'] if args.create: try: collection.create_index("password", unique=True) collection.create_index("hash.md5", unique=True) collection.create_index("hash.sha1", unique=True) collection.create_index("hash.sha224", unique=True) collection.create_index("hash.sha256", unique=True) collection.create_index("hash.sha384", unique=True) collection.create_index("hash.sha512", unique=True) except OperationFailure as e: print u'{}'.format(e) sys.exit(1) total = 0 length = len(documents) for i in xrange(0, length, 1024): docs = make_docs(documents[i:i + 1024]) insert_many(collection, docs) total += len(docs) print_progress(total, length) sys.stdout.write('\n')