Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

decrypt .txt files

Featured Replies

  • Author
  • Localization

jessijung, posted Wed Aug 29, 2018 2:36 am (37909)


I think the general problem is decoding Lua so I'm looking for help, can you help me decode it?
This game use cocos2dx v2.x Lua, do not use xxtea encryption
I need help translating languages and pictures
Can you help me understand some pseudocode in IDA and decrypt it?
  • Author
  • Localization

aluigi, posted Wed Aug 29, 2018 9:29 am (37915)


In the meantime I have splitted the posts in a new topic and gave it a correct title.
Please write the complete name of the game.
  • Author
  • Localization

jessijung, posted Thu Aug 30, 2018 2:40 am (37940)


ok ^^ .
I searched in IDA to here but do not understand this pseudo code:

Code:
signed int __fastcall cocos2dx_lua_loader(int a1)
{
  int v1; // r9
  int v2; // r0
  int v3; // r5
  int i; // r1
  unsigned int *v5; // r0
  cocos2d::CCFileUtils *v6; // r4
  int (__fastcall *v7)(cocos2d::CCFileUtils *, void *, const char *, int *); // r6
  int v8; // r0
  unsigned __int8 *v9; // r6
  char *v10; // r7
  int v11; // r5
  int v12; // r5
  char *v13; // r5
  int v15; // r10
  char *v16; // r7
  int v17; // r0
  char *v18; // [sp 18h] [bp-38h]
  int v19; // [sp 1Ch] [bp-34h]
  const char *v20; // [sp 20h] [bp-30h]
  int v21; // [sp 24h] [bp-2Ch]
  int v22; // [sp 28h] [bp-28h]
  void *v23; // [sp 2Ch] [bp-24h]

  v1 = a1;
  v2 = luaL_checklstring(a1, 1, 0);
  sub_833298(&v18, v2, (int)&v23);
  if ( sub_831B58(&v18, ".lua", -1, 4) != -1 )
  {
    sub_832ED8(&v22, &v18, 0);
    sub_832D34(&v18, &v22);
    v3 = v22 - 12;
    if ( (int *)(v22 - 12) != &dword_A39394 && sub_83C244((_DWORD *)(v22 - 4), -1) <= 0 )
      sub_83213C(v3, &v23);
  }
  for ( i = sub_831C00(&v18, ".", 0, 1); i != -1; i = sub_831C00(&v18, ".", 0, 1) )
    sub_833020(&v18, i, 1, "/", 1);
  sub_832CF8(&v19);
  sub_832A74((unsigned int *)&v19, ".el", 3u);
  sub_832CF8(&v20);
  sub_832A74((unsigned int *)&v20, ".lua", 4u);
  v5 = sub_832A74((unsigned int *)&v18, ".el", 3u);
  v21 = 0;
  v6 = (cocos2d::CCFileUtils *)cocos2d::CCFileUtils::sharedFileUtils((cocos2d::CCFileUtils *)v5);
  v7 = *(int (__fastcall **)(cocos2d::CCFileUtils *, void *, const char *, int *))(*(_DWORD *)v6 16);
  v8 = cocos2d::CCFileUtils::sharedFileUtils(v6);
  (*(void (__fastcall **)(void **, int, char *))(*(_DWORD *)v8 24))(&v23, v8, v18);
  v9 = (unsigned __int8 *)v7(v6, v23, "rb", &v21);
  v10 = (char *)v23 - 12;
  if ( (char *)v23 - 12 != (char *)&dword_A39394 && sub_83C244((_DWORD *)v23 - 1, -1) <= 0 )
    sub_83213C(v10, &v22);
  if ( v9 )
  {
    v22 = 0;
    v23 = 0;
    if ( decBuffer(v21, v9, (unsigned int *)&v22, &v23) )
    {
      if ( luaL_loadbuffer(v1, (int)v23, v22, v20) )
      {
        v15 = lua_tolstring(v1, 1, 0);
        v16 = v18;
        v17 = lua_tolstring(v1, -1, 0);
        luaL_error(v1, "error loading module %s from file %s :\n\t%s", v15, v16, v17);
      }
      if ( v23 )
        operator delete[](v23);
    }
    operator delete[](v9);
  }
  else
  {
    cocos2d::CCLog((cocos2d *)"can not get file data of %s", v18);
  }
  v11 = (int)(v20 - 12);
  if ( v20 - 12 != (const char *)&dword_A39394 && sub_83C244((_DWORD *)v20 - 1, -1) <= 0 )
    sub_83213C(v11, &v23);
  v12 = v19 - 12;
  if ( (int *)(v19 - 12) != &dword_A39394 && sub_83C244((_DWORD *)(v19 - 4), -1) <= 0 )
    sub_83213C(v12, &v23);
  v13 = v18 - 12;
  if ( v18 - 12 != (char *)&dword_A39394 && sub_83C244((_DWORD *)v18 - 1, -1) <= 0 )
    sub_83213C(v13, &v23);
  return 1;
}


AND decrypt function , I can not understand it:

Code:
signed int __fastcall decBuffer(int a1, unsigned __int8 *a2, unsigned int *a3, _DWORD *a4)
{
  int v4; // r8
  unsigned __int8 *v5; // r7
  unsigned int *v6; // r9
  _DWORD *v7; // r11
  Bytef *v8; // r0
  Bytef *v9; // r10
  int v10; // r6
  int v11; // r4
  int v12; // r5
  int v13; // r4
  int v14; // r0
  signed int result; // r0

  v4 = a1;
  v5 = a2;
  v6 = a3;
  v7 = a4;
  v8 = (Bytef *)operator new[](*a2 << 13);
  v9 = v8;
  *v6 = *v5 << 13;
  if ( !v8 )
    return 0;
  if ( v4 )
  {
    v10 = 0;
    v11 = 0;
    v12 = 0;
    do
    {
      v11;
      v5[v10] ^= aYouaiabc_0[v12];
      v12 = (v12 1) & 7;
      v10 = v11;
    }
    while ( v11 != v4 );
  }
  v13 = j_uncompress(v8, v6, v5 1, v4 - 1);
  v14 = operator new[](*v6);
  *v7 = v14;
  if ( v13 || !v14 )
  {
    operator delete[](v9);
    result = 0;
  }
  else
  {
    j_memcpy(v14, v9, *v6);
    operator delete[](v9);
    result = 1;
  }
  return result;
}
  • Author
  • Localization

Ekey, posted Thu Aug 30, 2018 9:34 pm (37960)


decryption

Code:
   char pTemp;
    if ( dwSize )
    {
      int i = 0;
      int j = 0;
      int k = 0;
      do
      {
        j;
        pTemp = m_Key[k] ^ pBuffer[i];
        k = ((BYTE)k 1) & 7;
        pBuffer[i] = pTemp;
        i = j;
      }
      while ( j != dwSize );
    }
    v13 = uncompress(v8, v6, pBuffer 1, dwSize - 1); // zlib


Code:
m_Key > youaiABC
  • Author
  • Localization

aluigi, posted Fri Aug 31, 2018 5:43 am (37971)


Code:
comtype zlib_noerror
filexor "youaiABC"
get NAME filename
math OFFSET = 1
get SIZE asize
math SIZE - OFFSET
clog NAME OFFSET SIZE SIZE
  • Author
  • Localization

jessijung, posted Fri Aug 31, 2018 7:38 am (37975)


aluigi wrote:
Code:
comtype zlib_noerror
filexor "youaiABC"
get NAME filename
math OFFSET = 1
get SIZE asize
math SIZE - OFFSET
clog NAME OFFSET SIZE SIZE


I already use it in file youai.bms but the output are not expected
run bms: https://ibb.co/fx7JtU
main.el after decrypt : https://ibb.co/cypytU

Ekey wrote:
decryption

Code:
   char pTemp;
    if ( dwSize )
    {
      int i = 0;
      int j = 0;
      int k = 0;
      do
      {
        j;
        pTemp = m_Key[k] ^ pBuffer[i];
        k = ((BYTE)k 1) & 7;
        pBuffer[i] = pTemp;
        i = j;
      }
      while ( j != dwSize );
    }
    v13 = uncompress(v8, v6, pBuffer 1, dwSize - 1); // zlib


Code:
m_Key > youaiABC


Thanks Ekey, I need the script to extract it to change and re-import
How to change it and re-import?
  • Author
  • Localization

aluigi, posted Sat Sep 01, 2018 12:37 am (38002)


The script works perfectly with all the EL files.
  • Author
  • Localization

jessijung, posted Sat Sep 01, 2018 4:34 am (38008)


aluigi wrote:
The script works perfectly with all the EL files.

Thanks . so much, its work perfectly :D
How to encrypt the file after the change? I do not understand bms scripts much, I will try to learn it
  • Author
  • Localization

aluigi, posted Sun Sep 02, 2018 1:25 am (38038)


Code:
comtype zlib_compress
log MEMORY_FILE 0 0
put 'x' byte MEMORY_FILE
append
get SIZE asize
clog MEMORY_FILE 0 SIZE SIZE
append
get SIZE asize MEMORY_FILE
filexor "youaiABC"
get NAME filename
log NAME 0 SIZE MEMORY_FILE
  • Author
  • Localization

jessijung, posted Mon Sep 03, 2018 5:23 am (38071)


It works perfectly!
Thanks ALUIGI so much!
  • Author
  • Localization

jessijung, posted Tue Sep 04, 2018 10:02 am (38098)


I found function parse file .txt , .cfg
  • Author
  • Localization

aluigi, posted Thu Sep 06, 2018 2:48 am (38146)


Do NEVER try to use the *_scan sripts, NEVER.
  • Author
  • Localization

jessijung, posted Sat Sep 08, 2018 3:25 am (38190)


Help me decrypt file .txt such as Varible.txt in assets folder, please
  • Author
  • Localization

jessijung, posted Tue Sep 11, 2018 5:28 pm (38255)


Can you help me write the script to export and re- import .txt file?
  • Author
  • Localization

jessijung, posted Sun Sep 16, 2018 2:26 am (38446)


aluigi wrote:
Is it the same game of viewtopic.php?f=9&t=8445 ?

Yes, I need help to decrypt .txt file
  • Author
  • Localization

aluigi, posted Sun Sep 16, 2018 11:11 am (38453)


Moved in the original topic to keep everything focused on the game.
  • Author
  • Localization

jessijung, posted Sat Sep 22, 2018 12:39 pm (38723)


this is c code in function parse(*.txt file), can you help me write script decrypt it? thanks

Code:
error
  • Author
  • Localization

jessijung, posted Sat Sep 22, 2018 3:15 pm (38728)


... close ...
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.