decrypt .txt files

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

decrypt .txt files

Post by jessijung »

Can you help me decrypt file to translate it, please? ( in folder lua/ txt/ ... )
This is apk:
https://drive.google.com/file/d/164Y7WK ... CSOGutwk4Y
This is assets
https://drive.google.com/file/d/1QIWQo8 ... D9lWBuZ26A
Thanks so much!
Last edited by jessijung on Mon Sep 24, 2018 5:53 pm, edited 3 times in total.
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Decrypt lua files of Cocos2dx ?

Post by jessijung »

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?
Last edited by jessijung on Sat Sep 01, 2018 5:10 am, edited 1 time in total.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Android One Piece cocos2dx lua decrypt el files

Post by aluigi »

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.
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android One Piece cocos2dx lua decrypt el files

Post by jessijung »

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

Code: Select all

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: Select all

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;
}
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by Ekey »

decryption

Code: Select all

   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: Select all

m_Key > youaiABC
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by aluigi »

Code: Select all

comtype zlib_noerror
filexor "youaiABC"
get NAME filename
math OFFSET = 1
get SIZE asize
math SIZE - OFFSET
clog NAME OFFSET SIZE SIZE
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

aluigi wrote:

Code: Select all

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: Select all

   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: Select all

m_Key > youaiABC


Thanks Ekey, I need the script to extract it to change and re-import
How to change it and re-import?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by aluigi »

The script works perfectly with all the EL files.
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

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
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by aluigi »

Code: Select all

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
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

It works perfectly!
Thanks ALUIGI so much!
Last edited by jessijung on Sat Sep 22, 2018 12:35 pm, edited 2 times in total.
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

I found function parse file .txt , .cfg
Last edited by jessijung on Sat Sep 22, 2018 12:36 pm, edited 1 time in total.
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

Hi Aluigi , I try to learn bms script
I have followed the instructions : http://aluigi.altervista.org/quickbms/comtype_scan.htm
to scan bit.el in lua folder but
comtype_scan: https://ibb.co/daAfje
encryption_scan: https://ibb.co/iugmPe

How did you determine it?(zlib_noerror, filexor)
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by aluigi »

Do NEVER try to use the *_scan sripts, NEVER.
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

Help me decrypt file .txt such as Varible.txt in assets folder, please
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by jessijung »

Can you help me write the script to export and re- import .txt file?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: [Android] Dream One Piece .txt file

Post by aluigi »

Is it the same game of viewtopic.php?f=9&t=8445 ?
jessijung
Posts: 20
Joined: Thu Aug 23, 2018 5:44 pm

Re: [Android] Dream One Piece .txt file

Post by jessijung »

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

Yes, I need help to decrypt .txt file
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Android youai.dreamonepiece cocos2dx lua decrypt el files

Post by aluigi »

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