From 7f5980f70224308a7fc41967000ade6a4ebc3631 Mon Sep 17 00:00:00 2001
From: Chris Pomeroy <cpomeroy@localhost.localdomain>
Date: Sat, 02 Dec 2017 05:21:48 +0000
Subject: [PATCH] Fixed errant hex key generation.  Added for loop to just grab the correct info not specific array parts.

---
 getaaxkey/getaaxkey.py |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/getaaxkey/getaaxkey.py b/getaaxkey/getaaxkey.py
index a561ac9..4a5ea15 100644
--- a/getaaxkey/getaaxkey.py
+++ b/getaaxkey/getaaxkey.py
@@ -43,13 +43,16 @@
     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()
+    grep = subprocess.Popen(["grep", "-a", "hex"], stdin=cmd.stdout, stdout=subprocess.PIPE)
+    key, stderr = grep.communicate()
     key = key.split()
-    return key[2].split(':')[1]
+    for x in key:
+        if "hex" in x:
+            return x.split(':')[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 +62,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)

--
Gitblit v1.10.0