|
From: Yoda-JM <yo...@us...> - 2010-01-23 09:44:39
|
Module: performous
Branch: master
Commit: aef30e2e17ab704a244c3c6fb2740f5d2727b686
Author: Vincent Le Ligeour <yo...@us...>
Date: Sat Jan 23 10:43:51 2010 +0100
Added Guitar Hero xen decrypter (need some love and some testing)
---
docs/CMakeLists.txt | 5 +++-
docs/gh_xen_decrypt.1 | 15 ++++++++++
tools/CMakeLists.txt | 3 +-
tools/gh_xen_decrypt.cpp | 68 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 89 insertions(+), 2 deletions(-)
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index d4f0c76..a54ca5d 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -22,7 +22,10 @@ if(UNIX)
message("WARNING: One of the following is missing: help2man, gzip; performous man page will not be generated")
endif(HELP2MAN AND GZIP)
if(ENABLE_TOOLS AND GZIP)
- set(TOOLS "ss_pak_extract" "ss_extract" "ss_cover_conv" "ss_adpcm_decode" "ss_ipu_decode" "ss_ipu_conv")
+ set(TOOLS
+ "ss_pak_extract" "ss_extract" "ss_cover_conv"
+ "ss_adpcm_decode" "ss_ipu_decode" "ss_ipu_conv"
+ "gh_xen_decrypt")
set(MAN_SECTION "1")
foreach(TOOL ${TOOLS})
set(TOOL_MANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${TOOL}.${MAN_SECTION})
diff --git a/docs/gh_xen_decrypt.1 b/docs/gh_xen_decrypt.1
new file mode 100644
index 0000000..d11b5a2
--- /dev/null
+++ b/docs/gh_xen_decrypt.1
@@ -0,0 +1,15 @@
+.TH "gh_xen_decrypt" "1" "" "" ""
+.SH "NAME"
+gh_xen_decrypt \- Tool for decrypting Guitar Hero xen files
+.SH "SYNOPSIS"
+\fBgh_xen_decrypt\fR input.xen output
+.TP
+\fBinput.xen\fR
+Xen source file
+.TP
+\fBoutput\fR
+destination file
+.SH "DESCRIPTION"
+Tool for decrypting Guitar Hero xen files
+.SH "SEE ALSO"
+\fIperformous\fR(6)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 7a1611e..75c3819 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -54,10 +54,11 @@ if (Boost_FOUND)
endif()
endif (Boost_FOUND)
+add_executable(gh_xen_decrypt gh_xen_decrypt.cpp)
add_executable(ss_adpcm_decode adpcm_decode.cpp pak.cpp)
add_executable(ss_ipu_decode ipu_decode.cpp)
add_executable(ss_ipu_conv ipu_conv.cpp ipuconvmain.cpp pak.cpp)
-set(targets ${targets} ss_pak_extract ss_adpcm_decode ss_ipu_decode ss_ipu_conv itg_pck)
+set(targets ${targets} gh_xen_decrypt ss_pak_extract ss_adpcm_decode ss_ipu_decode ss_ipu_conv itg_pck)
# add install target:
install(TARGETS ${targets} DESTINATION bin)
diff --git a/tools/gh_xen_decrypt.cpp b/tools/gh_xen_decrypt.cpp
new file mode 100644
index 0000000..971c75b
--- /dev/null
+++ b/tools/gh_xen_decrypt.cpp
@@ -0,0 +1,68 @@
+#include <cstdlib>
+#include <stdexcept>
+#include <fstream>
+#include <iostream>
+
+#define KEY_LEN 11
+
+// Code originaly credited by "Invo" and provided ASIS
+// found here: http://www.scorehero.com/forum/viewtopic.php?t=39923
+// This code code be use to "decrypt" ".xen" files used in at least GH3 PC
+// key should be guessed (xor)
+
+char SwapByteBits(unsigned char cInput) {
+ unsigned char nResult=0;
+
+ for(unsigned int i = 0 ; i < 8 ; i++) {
+ nResult = nResult << 1;
+ nResult |= (cInput & 1);
+ cInput = cInput >> 1;
+ }
+ return nResult;
+}
+
+
+// TODO: use boost iterator to decode in one line
+int main(int argc, char** argv) {
+ unsigned char cpKey[KEY_LEN] = "5atu6w4zaw";
+
+ // Check params
+ if (argc != 3) throw std::runtime_error(std::string("Usage: ") + argv[0] + " <Input> <Output>");
+
+ // Open files
+ std::ofstream outputFile(argv[2], std::ofstream::binary);
+ std::ifstream inputFile(argv[1], std::ios::binary);
+
+ // Get the file size
+ inputFile.seekg (0, std::ios::end);
+ unsigned int fileSize = inputFile.tellg();
+ inputFile.seekg (0, std::ios::beg);
+
+ // Allocate buffer
+ char *pBuffer = new char[fileSize];
+
+ // Reading inputfile
+ std::cout << "Reading input file (" << fileSize << " Bytes)... ";
+ inputFile.read(pBuffer, fileSize);
+ inputFile.close();
+ std::cout << "DONE!" << std::endl;
+
+ // Decrypt
+ std::cout << "Decrypting... ";
+ char *pInput = pBuffer;
+ for (unsigned int nLoopIdx = 0 ; nLoopIdx < fileSize ; nLoopIdx++) {
+ *pInput = SwapByteBits(*pInput ^ cpKey[nLoopIdx % (KEY_LEN-1)]);
+ pInput++;
+ }
+ std::cout << "DONE!" << std::endl;
+
+ // Write the output
+ std::cout << "Writing outpout file... ";
+ outputFile.write(pBuffer, fileSize);
+ outputFile.close();
+ delete [] pBuffer;
+ std::cout << "DONE!" << std::endl;
+
+ return EXIT_SUCCESS;
+}
+
|