Skip to content

Instantly share code, notes, and snippets.

@ammaraskar
Created September 13, 2017 21:12
Show Gist options
  • Save ammaraskar/c9e8437a921dcb4be07fdbdd2a12e67a to your computer and use it in GitHub Desktop.
Save ammaraskar/c9e8437a921dcb4be07fdbdd2a12e67a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
inputs = """qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
abcd5
aBcDeF
aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDe
aBc9F1
aBcDeFg94JkLmNo8qRsTuVwXyZaBcD2
aBcDeF@
aBcDeF$
AbCdEfGG
aBcDeFgg
aBcDeFgHiJkawfa
abcdefghijkl
AbCdEfGhIjKAWFA
ABCDEFGHIJKL
123456
ab12345f2456gD986f2e35a6f
Exon#Mobi@Le21
123456789abcdef@gDWSS@Aw4
""".split("\n")
outputs = """Error: Password length invalid.
Error: Password length invalid.
11
36
16
41
17
17
3
3
17
14
17
14
8
32
26
21
""".split("\n")
import tempfile
import subprocess
for i, inp in enumerate(inputs):
with tempfile.NamedTemporaryFile() as fp:
fp.write(inp.encode('utf-8'))
output = subprocess.Popen(["pwcheck.sh", fp.name],
stderr=subprocess.DEVNULL,
stdout=subprocess.PIPE).communicate()[0]
output = output.decode('utf-8')
if outputs[i] not in output:
print("[!] Invalid output for: " + inp)
print("Expected: " + outputs[i])
print("Got: ", output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment