Compare commits
No commits in common. "c52a06c09c7ab6f3fd38372ce749b7659a12c2c4" and "8084cadad91c13ded4047529c4afcb872a729997" have entirely different histories.
c52a06c09c
...
8084cadad9
25
runall.py
25
runall.py
|
@ -1,20 +1,11 @@
|
||||||
from itertools import product
|
from itertools import product
|
||||||
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ '
|
|
||||||
|
|
||||||
|
|
||||||
def check_pair(script, instr, outstr):
|
def check_pair(script, instr, outstr):
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[
|
["/usr/bin/env", "bash", "-c", script],
|
||||||
"/usr/bin/env", "bash", "-c",
|
|
||||||
";\n".join((
|
|
||||||
# Cleanup child processes on exit
|
|
||||||
"trap 'kill -9 $(jobs -p)' SIGINT SIGTERM EXIT",
|
|
||||||
script,
|
|
||||||
))
|
|
||||||
],
|
|
||||||
timeout=5,
|
|
||||||
input=instr.encode(),
|
input=instr.encode(),
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
)
|
)
|
||||||
|
@ -30,14 +21,12 @@ def check_pairs(script, pairs):
|
||||||
|
|
||||||
def find_script(pairs, max_length):
|
def find_script(pairs, max_length):
|
||||||
candidates = []
|
candidates = []
|
||||||
chars_count = len(chars)
|
chars = len(string.printable)
|
||||||
total_options = int((chars_count ** (max_length + 1) - 1) / (chars_count - 1))
|
total_options = int((chars ** (max_length + 1) - 1) / (chars - 1))
|
||||||
current_option = 0
|
current_option = 0
|
||||||
|
|
||||||
for length in range(max_length + 1):
|
for length in range(max_length + 1):
|
||||||
for letters in product(chars, repeat=length):
|
for letters in product(string.printable, repeat=length):
|
||||||
current_option += 1
|
|
||||||
|
|
||||||
if current_option % 1000 == 0:
|
if current_option % 1000 == 0:
|
||||||
print(f"Progress: {current_option}/{total_options}")
|
print(f"Progress: {current_option}/{total_options}")
|
||||||
|
|
||||||
|
@ -47,6 +36,8 @@ def find_script(pairs, max_length):
|
||||||
print("> Found candidate:", script)
|
print("> Found candidate:", script)
|
||||||
candidates.append(script)
|
candidates.append(script)
|
||||||
|
|
||||||
|
current_option += 1
|
||||||
|
|
||||||
print("Candidates:", candidates)
|
print("Candidates:", candidates)
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,7 +48,7 @@ if __name__ == '__main__':
|
||||||
("1", "1"),
|
("1", "1"),
|
||||||
("2", "2"),
|
("2", "2"),
|
||||||
("3", "3"),
|
("3", "3"),
|
||||||
), max_length=3)
|
), max_length=2)
|
||||||
|
|
||||||
# Successor
|
# Successor
|
||||||
print("\nSearching for successor")
|
print("\nSearching for successor")
|
||||||
|
|
Loading…
Reference in New Issue