From b01844eef40c55202c9c4e6ee2633edc0d70bc47 Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Thu, 8 Aug 2019 15:57:11 -0500 Subject: [PATCH 1/2] Add codecoverage.io --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4e4311d..25d4d83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,18 @@ language: python python: - "2.7" + +cache: + - pip + +# Install the codecov pip dependency +install: + - pip install codecov + +# Run the unit test +script: + - coverage run tests.py + +# Push the results back to codecov +after_success: + - codecov From 8a18e22ef21c0b3255b225a6583edc1d9a8c7b89 Mon Sep 17 00:00:00 2001 From: Danny Sauer Date: Tue, 5 May 2020 16:16:39 -0500 Subject: [PATCH 2/2] cleanup --- rainbow/rainbow_server.py | 50 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/rainbow/rainbow_server.py b/rainbow/rainbow_server.py index ebd5b91..16fc13d 100755 --- a/rainbow/rainbow_server.py +++ b/rainbow/rainbow_server.py @@ -2,9 +2,10 @@ import crypt import psycopg2 import multiprocessing -from string import letters,digits,printable +from string import letters, digits, printable from itertools import product -from threading import Thread +# from threading import Thread + def generate_data(q, maxlen=2, minlen=1): """ create base passwords for consumer threads to crypt @@ -13,54 +14,61 @@ def generate_data(q, maxlen=2, minlen=1): alphabet = printable for l in range(minlen, maxlen+1): for s in product(alphabet, repeat=l): - q.put( ''.join(s) ) + q.put(''.join(s)) + def record_data(q): """ pull data from the queue and add to database """ + salt_chars = letters + digits + './' db = psycopg2.connect( dbname='rainbow', host='humpy', user='rainbow', password='bowrain', - ); - cur = db.cursor(); + ) + cur = db.cursor() while True: vals = q.get() for val in vals: - #print val['h'] - try: - cur.execute(""" - INSERT INTO three_des - (pass, hash) - VALUES(%(p)s, %(h)s) - """, - val + # print val['h'] + for salt in product(salt_chars, 2): + try: + print("{v}: {h}}".format(v=val, h=crypt(val, salt))) + cur.execute( + """ + INSERT INTO three_des + (pass, hash) + VALUES(%(p)s, %(h)s) + """, + val, + crypt(val, salt), ) - except: - print "Failed to insert" + except: + print("Failed to insert") db.commit() q.task_done() + passwords = multiprocessing.JoinableQueue(maxsize=0) hashes = multiprocessing.JoinableQueue(maxsize=0) # only one generator for i in range(1): - t = multiprocessing.Process( target=generate_data, args=(passwords, 5, 1)) + t = multiprocessing.Process(target=generate_data, args=(passwords, 5, 1)) t.start() # only one data recorder? for i in range(2): - t = multiprocessing.Process( target=record_data, args=(hashes,)) + t = multiprocessing.Process(target=record_data, args=(hashes,)) t.start() passwords.join() -print "all passwords consumed" +print("all passwords consumed") hashes.join() -print "all hashes done" +print("all hashes done") for p in multiprocessing.active_children(): - print "joining process " , p.pid + print("joining process ", p.pid) if not p.join(2): - print "terminating process " , p.pid + print("terminating process ", p.pid) p.terminate()