Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extract metadata from ConeShell (Cygames) processed binary
#include <cstdio>
#include <iostream>
#include <cstdint>
using namespace std;
void writeReverse(FILE* f, uint32_t num)
{
char* buf[4];
*(uint32_t*)buf = 0xFFFFFFFF - num;
fwrite(buf, 4, 1, f);
}
int main(int argc, char** argv)
{
if (argc < 2) return 1;
FILE* prog = fopen(argv[1], "rb");
if (!prog) return 2;
FILE* out = fopen("global-metadata.dat", "wb");
cout << "Finding metadata...\n" << endl;
uint32_t chk_against = 0x054ee450;
fseek(prog, 0, SEEK_END);
uint32_t offset = ftell(prog) / 2;
fseek(prog, offset, SEEK_SET);
//char chk[4];
uint32_t chk;
while (1) {
fread(&chk, 4, 1, prog);
if (chk == chk_against) {
break;
}
offset += 4;
if (offset % 8192 == 0) cout << "\r" << offset;
}
printf("\nFound at %x\nModifing\n", offset - 4);
writeReverse(out, *(uint32_t*)&chk);
uint32_t len = 4;
uint32_t* chk_len = (uint32_t*)&chk;
while (1) {
fread(&chk, 4, 1, prog);
if (*chk_len == len) break;
writeReverse(out, *chk_len);
len += 4;
if (len % 8192 == 0) cout << "\r" << len;
}
cout << "\r" << len << "\nDone\n";
return 0;
}
<?php
$f = fopen('zaga', 'r');
$o = fopen('global-metadata.dat', 'w');
echo "Finding metadata...\n";
$chk_against = hex2bin('50e44e05');
$offset = filesize('zaga')/2;
$offset -= $offset % 16;
fseek($f, $offset);
while (1) {
$chk = fread($f, 4);
if ($chk == $chk_against) break;
$offset += 4;
if ($offset % 1024 == 0) echo "\r$offset";
}
echo "\nfound at ".dechex(ftell($f) - 4)."\nModifing\n";
function writeReverse($f, $num) {
fwrite($f, pack('V', 0xffffffff-$num));
}
writeReverse($o, unpack('V', $chk)[1]);
$len = 4;
while (1) {
$chk_len = unpack('V', fread($f, 4))[1];
if ($chk_len == $len) break;
writeReverse($o, $chk_len);
$len += 4;
if ($len % 1024 == 0) echo "\r$len";
}
echo "\r$len";
echo "\nDone\n";
@ForyModz

This comment has been minimized.

Copy link

ForyModz commented Nov 17, 2018

how can i run this on ios? i want to extract the metadata from a running game but idk how to do it

@NyaMisty

This comment has been minimized.

Copy link

NyaMisty commented Jan 8, 2019

Thanks a lot! Saving lots of time for me ;)

@zxc20100123

This comment has been minimized.

Copy link

zxc20100123 commented Jun 4, 2019

damn this is sick, appreciate it!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.