Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
/ decrypt_sp Public archive

Commit

Permalink
Update source
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoti committed Mar 27, 2024
1 parent 139a95a commit 41f0176
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 16 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
all:
gcc -Iinclude main.c -Llib -lkirk -o decrypt_sp

gcc -Iinclude main.c -Llib -lkirk -static -O2 -s -o decrypt_sp
strip decrypt_sp
gcc -v
file decrypt_sp
ldd decrypt_sp

clean:
rm decrypt_sp
rm decrypt_sp
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ git clone https://github.com/ProximaV/kirk-engine-full
cd kirk-engine-full
git checkout 883f992c02f12639d66be64c42f9771ab5f93691
make
cd ..
Expand Down
Binary file added lib/libkirk-x86.a
Binary file not shown.
Binary file added lib/libkirk-x86_64.a
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/libkirk.a_readme.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/ProximaV/kirk-engine-full
https://github.com/ProximaV/kirk-engine-full/commit/883f992c02f12639d66be64c42f9771ab5f93691
60 changes: 48 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <string.h>
#include <dirent.h>
#include <fcntl.h>
#include <malloc.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <malloc.h>
#include <dirent.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <kirk_engine.h>
#include "kirk_engine.h"

unsigned char buffer[10000000] __attribute__((aligned(64)));

Expand Down Expand Up @@ -368,7 +368,7 @@ int EncryptFile(char *input, char *output) {

int outsize;

memset(buffer,0, sizeof(buffer));
memset(buffer, 0, sizeof(buffer));
int size = ReadFile(input, buffer+0x150, sizeof(buffer)-0x150);

if (size < 0) {
Expand Down Expand Up @@ -400,17 +400,32 @@ void DecryptDir(char *indir, char *outdir) {
dfd = opendir(indir);

if (dfd != NULL) {
#ifdef __MINGW32__
struct dirent *de;
#else
struct dirent de, *dep;
#endif

memset(&de, 0, sizeof(struct dirent));
// memset(&de, 0, sizeof(struct dirent));
memset(&de, 0, sizeof(de));

#ifdef __MINGW32__
while ((de = readdir(dfd)) != NULL) {
sprintf(input, "%s/%s", indir, de->d_name);
sprintf(output, "%s/%s", outdir, de->d_name);
#else
while (readdir_r(dfd, &de, &dep) == 0 && dep != NULL) {
sprintf(input, "%s/%s", indir, de.d_name);
sprintf(output, "%s/%s", outdir, de.d_name);
#endif

output[strlen(output)-4] = 0; // remove enc extension

#ifdef __MINGW32__
if ((de->d_name[0] != '.') && (strcmp(de->d_name, "msid.bin"))) {
#else
if ((de.d_name[0] != '.') && (strcmp(de.d_name, "msid.bin"))) {
#endif
if (DecryptFile(input, output) != 0) {
//
} else {
Expand All @@ -429,15 +444,30 @@ void EncryptDir(char *indir, char *outdir) {
dfd = opendir(indir);

if (dfd != NULL) {
#ifdef __MINGW32__
struct dirent *de;
#else
struct dirent de, *dep;
#endif

memset(&de, 0, sizeof(struct dirent));
// memset(&de, 0, sizeof(struct dirent));
memset(&de, 0, sizeof(de));

#ifdef __MINGW32__
while ((de = readdir(dfd)) != NULL) {
sprintf(input, "%s/%s", indir, de->d_name);
sprintf(output, "%s/%s.%s", outdir, de->d_name, "enc");
#else
while (readdir_r(dfd, &de, &dep) == 0 && dep != NULL) {
sprintf(input, "%s/%s", indir, de.d_name);
sprintf(output, "%s/%s.%s", outdir, de.d_name, "enc");
#endif

#ifdef __MINGW32__
if ((de->d_name[0] != '.') && (strcmp(de->d_name, "msid.bin")) && (strcmp(de->d_name, "banner.bin"))) {
#else
if ((de.d_name[0] != '.') && (strcmp(de.d_name, "msid.bin")) && (strcmp(de.d_name, "banner.bin"))) {
#endif
if (EncryptFile(input, output) != 0) {
//
} else {
Expand Down Expand Up @@ -498,8 +528,11 @@ int main(int argc, char **argv) {
printf("Error: GetMSID() failed.\n");
return -1;
}

#ifdef __MINGW32__
mkdir("dec");
#else
mkdir("dec", 0777);
#endif
DecryptDir("prx", "dec");
} else if (!strcmp(argv[1], "-e")) {
printf("Encrypt mode...\n");
Expand All @@ -515,8 +548,11 @@ int main(int argc, char **argv) {
printf("Error: GetBanner() failed.\n");
return -1;
}

#ifdef __MINGW32__
mkdir("enc");
#else
mkdir("enc", 0777);
#endif
EncryptDir("dec", "enc");
} else {
printf("Error: incorrect mode.\n");
Expand Down
16 changes: 16 additions & 0 deletions windows.ms32mg32
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
exe = decrypt_sp
arc = -x86
ext = .exe

all:
gcc -Iinclude main.c -Llib -lkirk$(arc) -static -O2 -s -o $(exe)$(arc)$(ext)
strip $(exe)$(arc)$(ext)
gcc -v 2>&1 | grep Target > $(exe)$(arc).txt
gcc -v 2>&1 | grep "gcc " >> $(exe)$(arc).txt
unix2dos $(exe)$(arc).txt
file $(exe)$(arc)$(ext)
ldd "$(exe)$(arc)$(ext)"

clean:
rm $(exe)$(arc).txt
rm $(exe)$(arc)$(ext)
16 changes: 16 additions & 0 deletions windows.ms32mg64
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
exe = decrypt_sp
arc = -x86_64
ext = .exe

all:
gcc -Iinclude main.c -Llib -lkirk$(arc) -static -O2 -s -o $(exe)$(arc)$(ext)
strip $(exe)$(arc)$(ext)
gcc -v 2>&1 | grep Target > $(exe)$(arc).txt
gcc -v 2>&1 | grep "gcc " >> $(exe)$(arc).txt
unix2dos $(exe)$(arc).txt
file $(exe)$(arc)$(ext)
ldd "$(exe)$(arc)$(ext)"

clean:
rm $(exe)$(arc).txt
rm $(exe)$(arc)$(ext)

0 comments on commit 41f0176

Please sign in to comment.