| | |
| | | |
| | | import os |
| | | import subprocess |
| | | import requests |
| | | |
| | | def filechecksum(aaxfile): |
| | | ret = subprocess.Popen(["ffprobe", "-v", "info", "-hide_banner", os.path.abspath(aaxfile)], stderr=subprocess.PIPE) |
| | |
| | | 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() |
| | |
| | | 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() |
| | |
| | | |
| | | |
| | | 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() |
| | | for x in key: |
| | | if "hex" in x: |
| | | return x.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) |
| | |
| | | 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") |