Register | Login
Forum Index > Samples > DC LockToKey
Author Message
Pages: 1
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[41] DC LockToKey - posted: 2011-05-23 22:47:40
this function can be used to decode the lock sent from a Direct Connect hub

Code:
//
// Copyright (c) CodeZiron.com
//
function DC_LockToKey(char* src; char* buf) {
  uses ecx edx edi esi ebx;
   
  esi = src;  
  edi = buf;  
  
  //remove lock if passed also
  if (char*[esi] == ord('$Loc')) {
    add esi, 6    
  }  
  
  //add space for $Key 
  add edi, 5  
     
  al = byte[esi];
  xor al, 5
  ah = al;
  shr ax, 4
  and ax, 0x0ff0
  or al, ah  
  byte[edi] = al;
  
  ecx = xor;
  ecx++;
  while (char*[esi+ecx] <> ord(' Pk=')) {
    al = byte[esi+ecx];
    if (!al) {
      break;
    }
    xor al, [esi+ecx-1];
    ah = al;
    shr ax, 4
    and ax, 0x0ff0
    or al, ah    
    byte[edi+ecx] = al;
    ecx++;
  }
  
  if (ecx < 3) {
    return false;
  }
 
  al = byte[edi];
  xor al, [edi+ecx-1]
  byte[edi] = al;
  
  esi = edi;
  edi = buf;
  char*[edi] = ord('$Key');
  char[edi+4] = ord(' ');
  add edi, 5
 
  edx = xor;
  while (edx < ecx) {
    lodsb
    if (al == 0) {     
      ebx = '/%DCN000%/..';
      eax = char*[ebx];
      stosd
      eax = char*[ebx+4];
      stosd
      eax = char*[ebx+8];
      stosw
    } elseif (al == 5) {
      ebx = '/%DCN005%/..';
      eax = char*[ebx];
      stosd
      eax = char*[ebx+4];
      stosd
      eax = char*[ebx+8];
      stosw
    } elseif (al == 36) {
      ebx = '/%DCN036%/..';
      eax = char*[ebx];
      stosd
      eax = char*[ebx+4];
      stosd
      eax = char*[ebx+8];
      stosw
    } elseif (al == 96) {
      ebx = '/%DCN096%/..';
      eax = char*[ebx];
      stosd
      eax = char*[ebx+4];
      stosd
      eax = char*[ebx+8];
      stosw
    } elseif (al == 124) {
      ebx = '/%DCN124%/..';
      eax = char*[ebx];
      stosd
      eax = char*[ebx+4];
      stosd
      eax = char*[ebx+8];
      stosw
    } elseif (al == 126) {
      ebx = '/%DCN126%/..';
      eax = char*[ebx];
      stosd
      eax = char*[ebx+4];
      stosd
      eax = char*[ebx+8];
      stosw
    } else {
      stosb
    }
    edx++;
  }
  eax = xor;
  stosb
  
  return true;  
}


a quick sample using the function

Code:
//a buffer
char sKey[512];

DC_LockToKey('$Lock EXTENDEDPROTOCOL_HeXHub_TE_mzkfahwycyeq Pk=versiunea5.04', @sKey);

//source can also be without $Lock
DC_LockToKey('EXTENDEDPROTOCOL_HeXHub_TE_mzkfahwycyeq Pk=versiunea5.04', @sKey);

//write key
WriteLn(@sKey);


stats:

1,000,000 iterations breaking the above lock takes 407ms exactly, timed on a Core 2 Quad 2.4GHz with 2048MB DDR2 800

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[47] - posted: 2011-05-27 19:48:16
updated to use repeat and added an inline macro to shorten the code.

note that repeat requires compiler version 1.1.15.7

Code:
//
// Copyright (c) CodeZiron.com
//
function DC_LockToKey(char* src; char* buf) {
  uses ecx edx edi esi ebx;
   
  esi = src;  
  edi = buf;  
  
  //remove lock if passed also
  if (char*[esi] == ord('$Loc')) {
    add esi, 6    
  }  
  
  //add space for $Key 
  add edi, 5  
     
  al = byte[esi];
  xor al, 5
  ah = al;
  shr ax, 4
  and ax, 0x0ff0
  or al, ah  
  byte[edi] = al;
  
  xinc ecx;
  repeat {
    al = byte[esi+ecx];
    if (!al) {
      break;
    }
    xor al, [esi+ecx-1];
    ah = al;
    shr ax, 4
    and ax, 0x0ff0
    or al, ah    
    byte[edi+ecx] = al;
    ecx++;    
  } until (char*[esi+ecx] == ord(' Pk='));
  
  if (ecx < 3) {
    return false;
  }
 
  al = byte[edi];
  xor al, [edi+ecx-1]
  byte[edi] = al;
  
  esi = edi;
  edi = buf;
  char*[edi] = ord('$Key');
  char[edi+4] = ord(' ');
  add edi, 5
 
  inline op procedure stosDCN(s) {
    ebx = $s;
    eax = char*[ebx];
    stosd
    eax = char*[ebx+4];
    stosd
    eax = char*[ebx+8];
    stosw
  }
 
  edx = xor;
  repeat {
    lodsb
    if (al == 0) { 
      stosDCN '/%DCN000%/..';
    } elseif (al == 5) {
      stosDCN '/%DCN005%/..';
    } elseif (al == 36) {
      stosDCN '/%DCN036%/..';
    } elseif (al == 96) {
      stosDCN '/%DCN096%/..';
    } elseif (al == 124) {
      stosDCN '/%DCN124%/..';
    } elseif (al == 126) {
      stosDCN '/%DCN126%/..';
    } else {
      stosb
    }
    edx++;
  } while (edx < ecx);
  eax = xor;
  stosb
  
  return true;  
}


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 2 user(s) online. 0 member(s) and 2 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd