Created
July 21, 2014 12:02
-
-
Save susemeee/a37bb9f76b3064c40573 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import Popen, PIPE | |
import sys | |
import argparse | |
key = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--dest', dest='pass_to_program', action='store', default=False, | |
help='program destination') | |
parser.add_argument('--max', dest='max_length', action='store', type=int, default=3, | |
help='Maxlength of bf') | |
parser.add_argument('--min', dest='min_length', action='store', type=int, default=1, | |
help='Maxlength of bf') | |
arg = parser.parse_args() | |
res = [] | |
a = 0 | |
def func(depth): | |
global a | |
for i in key: | |
res[a] = i | |
if a < depth-1: | |
a += 1 | |
func(depth) | |
else: | |
new_key = "".join(res) | |
if arg.pass_to_program: | |
sys.stdout.write(new_key+": ") | |
result = Popen([arg.pass_to_program, ""], stdout=PIPE, stdin=PIPE) | |
out = result.communicate(new_key) | |
print out | |
else: | |
print new_key | |
a -= 1 | |
if arg.min_length > arg.max_length: | |
print "{0} : max length is smaller than min length!".format(sys.argv[0]) | |
exit(0) | |
# initializing result objects | |
for i in xrange(0, arg.max_length): | |
res.append("") | |
for i in xrange(arg.min_length, arg.max_length+1): | |
a = 0 | |
func(i) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment