Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../global.php(29) : eval()'d code(6) : eval()'d code on line 1

PHP Warning: Use of undefined constant misc - assumed 'misc' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant index - assumed 'index' (this will throw an Error in a future version of PHP) in ..../includes/class_bootstrap.php(1422) : eval()'d code(4) : eval()'d code on line 1

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6

PHP Warning: Use of undefined constant onlinestatusphrase - assumed 'onlinestatusphrase' (this will throw an Error in a future version of PHP) in ..../includes/class_core.php(4684) : eval()'d code on line 6
xtea decryption
Page 1 of 3 123 LastLast
Results 1 to 10 of 27

Thread: xtea decryption

  1. #1

    xtea decryption

    hi, i need xtea enc/dec source.
    i belive there is something called tibiaapi, but i have NO IDEA what is it for.
    i just need to decrypt incoming packets go get logical data, and then encrypt them.

    thx.

  2. #2
    Senior Member
    Join Date
    Aug 2008
    Posts
    350

    xtea decryption

    http://en.wikipedia.org/wiki/XTEA
    Code:
    #include <stdint.h>
     
    void encipher(unsigned int num_rounds, uint32_t v[2], uint32_t const k[4]) {
        unsigned int i;
        uint32_t v0=v[0], v1=v[1], sum=0, delta=0x9E3779B9;
        for (i=0; i < num_rounds; i++) {
            v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]);
            sum += delta;
            v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);
        }
        v[0]=v0; v[1]=v1;
    }
     
    void decipher(unsigned int num_rounds, uint32_t v[2], uint32_t const k[4]) {
        unsigned int i;
        uint32_t v0=v[0], v1=v[1], delta=0x9E3779B9, sum=delta*num_rounds;
        for (i=0; i < num_rounds; i++) {
            v1 −= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);
            sum −= delta;
            v0 −= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]);
        }
        v[0]=v0; v[1]=v1;
    }
    TibiaAPI is a framework for tibia built by certain TP members, makes things quite simple.
    TibiaAPI in Google Code

    PS. There's also some libraries for de/encrypting around these forums.

  3. #3

    xtea decryption

    cmon dont just copy and paste codes from wiki, wich i dont understand.
    decrypt(in, out, size, key)
    plz in this format

  4. #4

    xtea decryption

    as for tibiaapi from your link, its either encrypted or there is smething wrong with it (dll no exports). ill keep my distance from it.

    i just need simple function to decrypt XTEA, cryptofuck isnt my best side, belive me i cant underastand it yet.

  5. #5

    xtea decryption

    Quote Originally Posted by AxxA
    cmon dont just copy and paste codes from wiki, wich i dont understand.
    decrypt(in, out, size, key)
    plz in this format
    plz dont act like a noob and dont ask about source codes...
    If u dont understand it u should learn more...

  6. #6

    xtea decryption

    #include <windows.h>
    char pp[]={0xcc, 0x00, 0x5a, 0x61, 0xee, 0xe4, 0x5f, 0xb0, 0x27, 0xc1, 0x46, 0x7d, 0xc3, 0x84, 0x90, 0x3f, 0x58, 0x7f, 0xb1, 0x69, 0x6c, 0x27, 0x3c, 0xca, 0xd2, 0xd1, 0x8d, 0xe6, 0x8d, 0x72, 0x22, 0x8d, 0x98, 0x6d, 0x33, 0xfb, 0x2e, 0x03, 0x0a, 0x83, 0x0e, 0x8d, 0x45, 0x86, 0x51, 0x59, 0xaf, 0x92, 0xe5, 0x1c, 0x80, 0xc6, 0xa5, 0xa8, 0x4f, 0x52, 0x18, 0xa3, 0xaa, 0x77, 0xa3, 0x00, 0x9b, 0xbe, 0x43, 0x75, 0x41, 0xc9, 0x96, 0xe6, 0x3d, 0x8e, 0x49, 0xc6, 0xff, 0x4d, 0xc5, 0xc6, 0x6f, 0xe6, 0x0a, 0xa2, 0xde, 0x50, 0xdb, 0x34, 0x13, 0x77, 0x87, 0x32, 0x61, 0x3f, 0xdf, 0x2b, 0xcf, 0xbb, 0x8a, 0xe8, 0x66, 0x04, 0x99, 0x97, 0xb8, 0x49, 0x81, 0x87, 0x0c, 0x12, 0xca, 0x17, 0x1f, 0x02, 0xf5, 0xe0, 0x71, 0xc3, 0xaf, 0x54, 0x80, 0x8b, 0x3e, 0x45, 0x75, 0x70, 0xc9, 0xba, 0x29, 0x28, 0xe7, 0xb6, 0xab, 0x0a, 0xa2, 0xf4, 0x18, 0xdf, 0x2c, 0x11, 0x5d, 0x97, 0x3e, 0x34, 0x15, 0x3f, 0xac, 0xea, 0xd0, 0x21, 0x8f, 0x0b, 0xed, 0xae, 0xfd, 0xe9, 0xd7, 0x53, 0x3b, 0x58, 0x07, 0xff, 0x6a, 0x44, 0x07, 0xb1, 0x19, 0xce, 0x41, 0xd9, 0x54, 0xc2, 0x43, 0x91, 0x32, 0x4f, 0x75, 0x31, 0x0b, 0xc4, 0x56, 0xac, 0x94, 0x8f, 0x8b, 0x92, 0x8b, 0x68, 0x60, 0xc1, 0xbf, 0xd6, 0x43, 0x7b, 0xe5, 0x36, 0x81, 0x26, 0xd8, 0x8c, 0xd8, 0x2d, 0x95, 0xc2, 0x5b, 0x85, 0x87, 0xac};
    char xGameKey[16];
    unsigned char* getDecryptedCopy(const char * buf, int len){
    unsigned char *data = (unsigned char*)malloc(sizeof(char)*(len+1));
    memcpy(data, buf, len);
    data[len]=0;
    int iPos = 0;
    while( iPos < len-1 )
    {
    DecipherTibia(data+iPos, xGameKey);
    int iLength = data[iPos+1] << 8 | data[iPos];
    iPos += iLength+2;
    }
    return data;
    }

    int DecipherTibia(void* p1, void* p2 ){
    char* data = (char*)p1;
    char* key = (char*)p2;
    unsigned char i1 = *(char*)p1;
    unsigned char i2 = *(((char*)p1)+1);
    unsigned int iCount = i1+i2*256;
    data += 2;
    int i;
    for(i=0; i < iCount/8; i++ )
    {
    tean( (long*)data, (long*)key, -32 );
    data +=8;
    }
    return iCount;
    }



    int tean(long *v, long *k, long N){
    unsigned long y = v[0],
    z = v[1],
    DELTA = 0x9e3779b9,
    limit,
    sum;

    if (N > 0) /* coding */
    { limit = DELTA * N;
    sum = 0;

    while (sum != limit)
    { y += (z << 4 ^ z >> 5) + z ^ sum + k[sum & 3];
    sum += DELTA;
    z += (y << 4 ^ y >> 5) + y ^ sum + k[sum >> 11 & 3];
    }
    }
    else /* decoding */
    { sum = DELTA * (-N);

    while (sum)
    { z -= (y << 4 ^ y >> 5) + y ^ sum + k[sum >> 11 & 3];
    sum -= DELTA;
    y -= (z << 4 ^ z >> 5) + z ^ sum + k[sum & 3];
    }
    }

    v[0] = y;
    v[1] = z;
    return;
    }

    int main(){
    int wnd;
    int proc;
    int i;
    char *a;
    unsigned int d;
    a = getDecryptedCopy(pp, sizeof(pp));
    wnd = FindWindowA("TibiaClient", 0);
    if(wnd != 0){
    GetWindowThreadProcessId(wnd, &proc);
    wnd = OpenProcess(PROCESS_VM_READ, 0, proc);
    ReadProcessMemory(wnd, 0x78BF34, xGameKey, 16, 0);
    for(i=0;i<sizeof(pp);i++){
    d = *(int*)(&a[i]);
    d <<= 24;
    d >>= 24;
    printf("%c", d);
    }



    }
    return 0;
    }

    so tell me why it doesnt work.
    address is from 8.5. i cant say, maybe you?
    im getting wrong packet (this is npc saying something to me)

  7. #7
    Senior Member
    Join Date
    Oct 2007
    Posts
    1,045

    xtea decryption

    Why do you declare "wnd" two times O.o?

  8. #8
    Senior Member
    Join Date
    May 2007
    Posts
    287

    xtea decryption

    XTea key changes everytime you login. In your code you're trying to decrypt a packet with a different key than was used to encrypt it.

    @Jesper:
    owned... lol
    you made me speechless for few seconds
    first wnd holds window's handle and later it holds handle to the process

  9. #9

    xtea decryption

    i censored variable names to post it for public.
    and packet is captured in same session, i know xtea key change.

    why i cant correctly decode it? wrong address? or smth?

  10. #10

    xtea decryption

    Code:
    #include <windows.h>
    int encipher(unsigned int num_rounds, unsigned int v[2], char *k) {
    unsigned int i, v0, v1, delta, sum;
    v0=v[0];
    v1=v[1];
    delta=0x9E3779B9;
    sum=delta*num_rounds;
    
    
    
    for (i=0; i < num_rounds; i++) {
    v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]);
    sum += delta;
    v1 += (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);
    }
    v[0]=v0;
    v[1]=v1;
    
    
    return 0;
    }
     
    int decipher(unsigned int num_rounds, unsigned int v[2], char *k) {
    unsigned int i, v0, v1, delta, sum;
    v0=v[0];
    v1=v[1];
    delta=0x9E3779B9;
    sum=delta*num_rounds;
    
    for (i=0; i < num_rounds; i++) {
    v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum>>11) & 3]);
    sum -= delta;
    v0 -= (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + k[sum & 3]);
    }
    v[0]=v0;
    v[1]=v1;
    
    
    return 0;
    }
    
    
    int main(){
    unsigned char key[16];
    unsigned char data[8];
    memset(data, 'A', sizeof(data));
    memset(key, 'i', sizeof(key));
    puts(data);
    encipher(32, &data, key);
    puts(data);
    
    puts("\r\n\r\n\r\n");
    decipher(32, &data, key);
    puts(data);
    return 0;
    }
    thats a problem. why it also doesnt work?!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •