Initial tool commit

This commit is contained in:
sqozz 2015-08-31 19:49:22 +02:00
parent af8dcc4b62
commit c145397203
3 changed files with 74 additions and 1 deletions

5
.gitignore vendored
View File

@ -33,4 +33,7 @@ nosetests.xml
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
.pydevproject
# Ask me for the key ;)
dlc2txt_KEY.py

View File

@ -1,3 +1,12 @@
DLCDecrypt
==========
This little tool can decrypt DLC Files.
Many thanks goes out to the folks of PyLoad. This code is mostly a ripoff of their DLC code modified to run alone.
Checkout pyload at: http://pyload.org/
### Usage:
```
./dlc2txt dlcFile.dlc
```
This produces a file named after the given name in the DLC.

61
dlc2txt.py Executable file
View File

@ -0,0 +1,61 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import urllib
import re
import requests
import base64
import xml.dom.minidom
from Crypto.Cipher import AES
def decrypt(fs_filename):
KEY = ""
IV = ""
API_URL = "http://service.jdownloader.org/dlcrypt/service.php?srcType=dlc&destType=pylo&data=%s"
with open(fs_filename) as dlc:
data = dlc.read().strip()
data += '=' * (-len(data) % 4)
dlc_key = data[-88:]
dlc_data = base64.b64decode(data[:-88])
dlc_content = load(API_URL % dlc_key)
print(dlc_content)
try:
rc = base64.b64decode(re.search(r'<rc>(.+)</rc>', dlc_content, re.S).group(1))
except AttributeError:
print("Error: invalid DLC")
key = iv = (AES.new(KEY, AES.MODE_CBC, IV).decrypt(rc)).decode('utf-8')
data = base64.b64decode(AES.new(key, AES.MODE_CBC, iv).decrypt(dlc_data)).decode('utf-8', 'ignore')
plainData = get_packages(data)[0]
print('\n'.join(plainData[1]))
with open(plainData[0], mode='wt', encoding='utf-8') as rawLinkFile:
rawLinkFile.write('\n'.join(plainData[1]))
def load(url):
r = requests.get(url)
return r.text
def fixurl(url):
return urllib.unquote(url.decode('unicode-escape')).strip().rstrip('/')
def get_packages(data):
root = xml.dom.minidom.parseString(data).documentElement
content = root.getElementsByTagName("content")[0]
return parse_packages(content)
def parse_packages(startNode):
return [(decode(base64.b64decode(decode(node.getAttribute("name")))), parse_links(node)) for node in startNode.getElementsByTagName("package")]
def parse_links(startNode):
return [decode(base64.b64decode(node.getElementsByTagName("url")[0].firstChild.data)) for node in startNode.getElementsByTagName("file")]
def decode(string):
try:
return string.decode("utf8", "replace")
except:
return string
decrypt(sys.argv[1])