From 1522a21d24add0d78f7e4a5fae7654b709045754 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Fri, 27 Aug 2021 22:34:19 -0400 Subject: Forward-port Python POC to Python 3 Signed-off-by: Malfurious --- GarbageProofOfConcept.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) mode change 100644 => 100755 GarbageProofOfConcept.py diff --git a/GarbageProofOfConcept.py b/GarbageProofOfConcept.py old mode 100644 new mode 100755 index 0c07873..e6e4030 --- a/GarbageProofOfConcept.py +++ b/GarbageProofOfConcept.py @@ -1,7 +1,9 @@ +#!/usr/bin/env python + import hashlib from itertools import combinations -data = "abc" +data = b"abc" length = len(data) hexdigest = hashlib.sha256(data).hexdigest() @@ -21,24 +23,24 @@ lookupTable = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8] sum1 = 0 -for i in xrange(length): +for i in range(length): sum1 += lookupTable[bytearray(data)[i]] -print("The length is: {0}").format(length) -print("The ones count is: {0}").format(sum1) +print("The length is: {0}".format(length)) +print("The ones count is: {0}".format(sum1)) combinations = list(combinations(range(length * 8),sum1)) numCombs = len(combinations) count = 1 for comb in combinations: - print("Trying {0}/{1}").format(count, numCombs) + print("Trying {0}/{1}".format(count, numCombs)) count += 1 a = [0] * length for bit in comb: - a[bit/8] |= 1 << (bit % 8) + a[bit//8] |= 1 << (bit % 8) if hashlib.sha256(bytearray(a)).hexdigest() == hexdigest: - print("Found! {0}").format(a) + print("Found! {0}".format(a)) break else: print("failed to find") -- cgit v1.2.3