From f75a70bc8fddc8b0aa94957eaa2b28a4e6d2cdea Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <chris.pomeroy@hotmail.com>
Date: Thu, 08 Mar 2018 15:47:00 +0000
Subject: [PATCH] Changed print from statement to function, changed getaaxkey to hand off generation of keys to faas
---
getaaxkey/getaaxkey.py | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/getaaxkey/getaaxkey.py b/getaaxkey/getaaxkey.py
index a561ac9..4a91508 100644
--- a/getaaxkey/getaaxkey.py
+++ b/getaaxkey/getaaxkey.py
@@ -2,6 +2,7 @@
import os
import subprocess
+import requests
def filechecksum(aaxfile):
ret = subprocess.Popen(["ffprobe", "-v", "info", "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
@@ -17,7 +18,7 @@
file = open(".authcode", "a")
file.write(hashsum + os.linesep)
except (IOError, OSError) as e:
- print "Can't write to .authcode"
+ print("Can't write to .authcode")
return 1
finally:
file.close()
@@ -31,7 +32,7 @@
with open(".authcode") as f:
hashes = f.read().split()
except (IOError, OSError) as e:
- print "Can't read in .authcode"
+ print("Can't read in .authcode")
return 1
finally:
f.close()
@@ -39,17 +40,15 @@
def newauthcode(checksum):
- rcwd = os.path.dirname(os.path.realpath(__file__))
- command = "./rcrack *.rtc -h "
- command += checksum
- cmd = subprocess.Popen(command, cwd=rcwd, stdout=subprocess.PIPE, shell=True)
- grep = subprocess.Popen(["grep","-a", "hex"], stdin=cmd.stdout,stdout=subprocess.PIPE)
- key,stderr = grep.communicate()
- key = key.split()
- return key[2].split(':')[1]
+ r = requests.post("http://x86-docker01.darkurthe.net:8080/function/checkkey", checksum )
+ if r.status_code == 200:
+ response = str(r.text)
+ return response.strip()
+ else:
+ return 1
def checkagainstexisting(abytes,aaxfile):
- ret = subprocess.Popen(["ffprobe","-activation_bytes", abytes ,"-hide_banner" , os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
+ ret = subprocess.Popen(["ffprobe", "-activation_bytes", abytes, "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE)
grep = subprocess.Popen(["grep", "mismatch", "-c"], stdin=ret.stderr, stdout=subprocess.PIPE)
works,out = grep.communicate()
return works.strip('\n')
@@ -59,10 +58,10 @@
authcodes = readauthcode()
abyte = ''
for x in authcodes:
- if (checkagainstexisting(x,aaxfile) == '0'):
+ if checkagainstexisting(x, aaxfile) == '0':
abyte = x
return abyte
- if (abyte == ''):
+ if abyte == '':
csum = filechecksum(aaxfile)
abyte = newauthcode(csum)
writeauthcode(abyte)
@@ -74,11 +73,11 @@
if len(sys.argv) >= 2:
args = sys.argv[1]
else:
- print "I need an file name to lookup"
+ print("I need an file name to lookup")
sys.exit(1)
checksum = filechecksum(args)
out = newauthcode(checksum.strip())
if out is not None:
- print sys.argv[1], "Auth code is:", out
+ print(sys.argv[1], "Auth code is:", out)
else:
- print sys.argv[1], "no Authcode found"
+ print(sys.argv[1], "no Authcode found")
--
Gitblit v1.10.0