-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from LordSk/pak
Pak tool 1.0
- Loading branch information
Showing
16 changed files
with
1,423 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/Pak/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
OpenSSL_include_x64 = "C:/Prog/Libs/openssl-1.0.2/include" | ||
OpenSSL_libdir_x64 = "C:/Prog/Libs/openssl-1.0.2/lib/Win32/static/Release" | ||
zlib_include = "C:/Prog/Libs/zlib-1.2.11" | ||
zlib_libdir_x64 = "C:/Prog/Libs/zlib-1.2.11" | ||
brotli_include = "C:/Prog/Libs/vcpkg/installed/x64-windows/include" | ||
brotli_libdir_x64 = "C:/Prog/Libs/vcpkg/installed/x64-windows/lib" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
-- | ||
dofile("config.lua"); | ||
|
||
BUILD_DIR = path.getabsolute("./build") | ||
|
||
solution "Pak tools" | ||
location(BUILD_DIR) | ||
|
||
configurations { | ||
"Debug", | ||
"Release" | ||
} | ||
|
||
platforms { | ||
"x32", | ||
"x64" | ||
} | ||
|
||
language "C++" | ||
|
||
configuration {"Debug"} | ||
targetsuffix "_debug" | ||
flags { | ||
"Symbols", | ||
"FullSymbols" | ||
} | ||
defines { | ||
"DEBUG", | ||
"CONF_DEBUG" | ||
} | ||
links { | ||
} | ||
|
||
configuration {"Release"} | ||
flags { | ||
"Optimize", | ||
"Symbols", | ||
"NoBufferSecurityCheck" | ||
} | ||
defines { | ||
"NDEBUG", | ||
"CONF_RELEASE", | ||
} | ||
links { | ||
} | ||
|
||
configuration {} | ||
flags { | ||
"Cpp14" | ||
} | ||
|
||
targetdir("../build") | ||
|
||
includedirs { | ||
"src", | ||
} | ||
|
||
links { | ||
"kernel32", | ||
"user32", | ||
"winmm", | ||
"advapi32" | ||
} | ||
|
||
flags { | ||
"NoExceptions", | ||
"NoRTTI", | ||
"EnableSSE", | ||
"EnableSSE2", | ||
"EnableAVX", | ||
"EnableAVX2", | ||
"EnableMinimalRebuild", | ||
"StaticRuntime", | ||
} | ||
|
||
defines { | ||
"_CRT_SECURE_NO_DEPRECATE", | ||
"_CRT_NONSTDC_NO_DEPRECATE", | ||
"WIN32_LEAN_AND_MEAN", | ||
"NOMINMAX", | ||
} | ||
|
||
-- disable exception related warnings | ||
buildoptions{ "/wd4577", "/wd4530" } | ||
|
||
|
||
project "pak" | ||
kind "ConsoleApp" | ||
|
||
configuration {} | ||
|
||
includedirs { | ||
"src", | ||
brotli_include | ||
} | ||
|
||
libdirs { | ||
brotli_libdir_x64 | ||
} | ||
|
||
links { | ||
"brotlidec", | ||
"shlwapi" | ||
} | ||
|
||
files { | ||
"src/**.h", | ||
"src/**.c", | ||
"src/**.cpp", | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
import brotli | ||
|
||
f = open("FileList.xml.pak_decrypted", "rb") | ||
data = f.read() | ||
f.close() | ||
|
||
decompressed_data = brotli.decompress(data) | ||
|
||
f = open("FileList.xml", "wb") | ||
f.write(decompressed_data) | ||
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from Crypto.Cipher import AES | ||
import struct | ||
|
||
f = open("FileList.xml.pak", "rb") | ||
data = f.read() | ||
f.close() | ||
|
||
# read header | ||
header = struct.unpack("4shh", data[:8]) | ||
print(header) | ||
to_decrypt = data[8:136] | ||
|
||
|
||
key = b'\xa0\x1d\x3d\x99\x3b\x82\x0f\x1e\x13\x0a\x89\x55\x8d\xc0\xde\x22' | ||
# key = b'\x49\x59\x63\x55\xfd\x61\x71\x01\x00\xf3\xb9\xde\xb6\x6f\xb2\xa5' | ||
|
||
def decrypt(mode): | ||
cipher = AES.new(key, mode) | ||
plaintext = cipher.decrypt(to_decrypt) | ||
sub = struct.unpack("iii", plaintext[:12]) | ||
print(sub) | ||
|
||
#f = open("out.decrypted", "wb") | ||
#f.write(plaintext) | ||
#f.close() | ||
|
||
decrypt(AES.MODE_ECB) | ||
decrypt(AES.MODE_CBC) | ||
decrypt(AES.MODE_CFB) | ||
decrypt(AES.MODE_OFB) | ||
decrypt(AES.MODE_CTR) | ||
decrypt(AES.MODE_OPENPGP) | ||
decrypt(AES.MODE_CCM) | ||
decrypt(AES.MODE_EAX) | ||
decrypt(AES.MODE_GCM) | ||
decrypt(AES.MODE_OCB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
import shutil | ||
import glob | ||
import sys | ||
import subprocess | ||
|
||
if len(sys.argv) < 3: | ||
print('Usage: python extract_paks.py "Path\\To\\MXM" "Path\\To\\Extraction"') | ||
print('Example: python extract_paks.py "C:\\MXM" "C:\\MXM_extracted"') | ||
exit() | ||
|
||
script_dir = os.path.dirname(os.path.realpath(__file__)) | ||
cur_dir = os.path.realpath(os.getcwd()) | ||
input_dir = sys.argv[1] | ||
output_dir = sys.argv[2] | ||
|
||
#print(script_dir, cur_dir, input_dir, output_dir) | ||
|
||
tool_path = os.path.realpath(os.path.join(script_dir, "pak.exe")) | ||
#print(tool_path) | ||
|
||
pak_files = glob.glob(input_dir + '/**/*.pak', recursive=True) | ||
#print(pak_files) | ||
|
||
for f in pak_files: | ||
fdir = os.path.dirname(f)[len(input_dir)+1:] | ||
filename = os.path.basename(f) | ||
|
||
#print(filename) | ||
#print(filename[:-4]) | ||
#print(output_dir) | ||
#print(fdir) | ||
os.makedirs(os.path.join(output_dir, fdir), exist_ok=True) | ||
|
||
print('"%s" "%s" "%s"' % (tool_path, f, os.path.join(output_dir, fdir, filename[:-4]))) | ||
#os.system('"%s" "%s" "%s"' % (tool_path, f, os.path.join(output_dir, fdir, filename[:-4]))) | ||
subprocess.run([tool_path, f, os.path.join(output_dir, fdir, filename[:-4])]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "base.h" | ||
|
||
FILE* g_LogFile; | ||
const char* g_LogFileName; | ||
|
||
void LogInit(const char* name) | ||
{ | ||
g_LogFileName = name; | ||
g_LogFile = fopen(g_LogFileName, "wb"); | ||
ASSERT(g_LogFile); | ||
} | ||
|
||
struct Logger | ||
{ | ||
~Logger() { | ||
fclose(g_LogFile); | ||
} | ||
}; | ||
|
||
static Logger g_Logger; |
Oops, something went wrong.