Forgotten your password?

Forum Index > Delphi/Pascal and Kylix > DirectConnect LockToKey
Author Message
key generator for dc hub software(s)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
procedure LockToKey(ptrLock: Pointer; ptrBuffer: Pointer);
//LockToKey - Meka][Meka - TEAMELITE - 2010
//Loosely based on Lock2Key by Lord_Zero written in MASM32
asm
  push esi
  push edi
  push ebx

  lea esi, [ptrLock]
  mov edi, ptrBuffer

  xor ecx, ecx

  cmp byte ptr[esi+ecx], '|'
  je @@endw1
  @@while1:
    cmp dword ptr[esi+ecx], '=kP '
    jne @@endif1
      jmp @@endw1
    @@endif1:
    inc ecx

    cmp byte ptr[esi+ecx], '|'
    jne @@while1
  @@endw1:

  cmp ecx, 3
  jnl @@endif2
    pop ebx
    pop edi
    pop esi
    ret
  @@endif2:

  mov al, [esi]
  xor al, 5
  mov ah, al
  shr ax, 4
  and ax, 0ff0h
  or al, ah
  mov [edi], al
  xor edx, edx
  inc edx

  cmp edx, ecx
  jnl @@endw2
  @@while2:
    mov al, [esi+edx]
    xor al, [esi+edx-1]
    mov ah, al
    shr ax, 4
    and ax, 0ff0h
    or al, ah
    mov [edi+edx], al
    inc edx

    cmp edx, ecx
    jl @@while2
  @@endw2:

  mov al, [edi]
  xor al, [edi+ecx-1]
  mov [edi], al
  xor edx, edx

  cmp edx, ecx
  jnl @@endw3
  @@while3:
    mov al,[edi+edx]
    mov [esi+edx],al
    inc edx

    cmp edx, ecx
    jl @@while3
  @@endw3:

  xor edx, edx

  cmp edx, ecx
  jnl @@endw4
  @@while4:
    lodsb
    //ifa
    cmp al, 0
    jne @@ifb
      mov eax, 'CD%/'
      stosd
      mov eax, '000N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifb:
    cmp al, 5
    jne @@ifc
      mov eax, 'CD%/'
      stosd
      mov eax, '500N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifc:
    cmp al, 36
    jne @@ifd
      mov eax, 'CD%/'
      stosd
      mov eax, '630N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifd:
    cmp al, 96
    jne @@ife
      mov eax, 'CD%/'
      stosd
      mov eax, '690N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ife:
    cmp al, 124
    jne @@iff
      mov eax, 'CD%/'
      stosd
      mov eax, '421N'
      stosd
      mov  ax, '/%'
      stosw
      jmp @@ifend
    @@iff:
    cmp al, 126
    jne @@ifelse
      mov eax, 'CD%/'
      stosd
      mov eax, '621N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifelse:
      stosb
    @@ifend:

    inc edx

    cmp edx, ecx
    jl @@while4
  @@endw4:

  mov al, 0h
  stosb

  pop ebx
  pop edi
  pop esi

  ret
end;


and example of use would be...

1
2
3
4
5
6
var
  skey: array[1..255] of AnsiChar;
begin
  LockToKey(@slock[1], @skey[1]);

  //skey is now your key


slock should be an ansistring containing the lock such as EXTENDEDPROTOCOL_HeXHub_TE_mzkfahwycyeq Pk=versiunea5.04

to help understand here is another example

1
2
3
4
5
6
7
8
9
var
  slock: AnsiString;
  skey: array[1..255] of AnsiChar;
begin
  slock := 'EXTENDEDPROTOCOL_HeXHub_TE_mzkfahwycyeq Pk=versiunea5.04';
  LockToKey(@slock[1], @skey[1]);

  ShowMessage(PAnsiChar(@skey[1]));
end;


there is other ways of using this, such as allocating the skey buffer but for simplicity i have used a static array of chars.

also with very little modification it could be used in any language that supports inline assembly

-MM
ok added pk string pos as requested by RoLex

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
function LockToKey2(ptrLock: Pointer; ptrBuffer: Pointer): Integer;
//LockToKey - Meka][Meka - TEAMELITE - 2010
//Loosely based on Lock2Key by Lord_Zero written in MASM32
//Added result PK position in ptrLock : request by RoLex
asm
  push esi
  push edi
  push ebx

  lea esi, [ptrLock]
  mov edi, ptrBuffer

  xor ecx, ecx

  cmp byte ptr[esi+ecx], 0
  je @@endw1
  @@while1:
    cmp dword ptr[esi+ecx], '=kP '
    jne @@endif1
      jmp @@endw1
    @@endif1:
    inc ecx

    cmp byte ptr[esi+ecx], 0
    jne @@while1
  @@endw1:

  cmp ecx, 3
  jnl @@endif2
    pop ebx
    pop edi
    pop esi
    ret
  @@endif2:

  push ecx

  mov al, [esi]
  xor al, 5
  mov ah, al
  shr ax, 4
  and ax, 0ff0h
  or al, ah
  mov [edi], al
  xor edx, edx
  inc edx

  cmp edx, ecx
  jnl @@endw2
  @@while2:
    mov al, [esi+edx]
    xor al, [esi+edx-1]
    mov ah, al
    shr ax, 4
    and ax, 0ff0h
    or al, ah
    mov [edi+edx], al
    inc edx

    cmp edx, ecx
    jl @@while2
  @@endw2:

  mov al, [edi]
  xor al, [edi+ecx-1]
  mov [edi], al
  xor edx, edx

  cmp edx, ecx
  jnl @@endw3
  @@while3:
    mov al,[edi+edx]
    mov [esi+edx],al
    inc edx

    cmp edx, ecx
    jl @@while3
  @@endw3:

  xor edx, edx

  cmp edx, ecx
  jnl @@endw4
  @@while4:
    lodsb
    //ifa
    cmp al, 0
    jne @@ifb
      mov eax, 'CD%/'
      stosd
      mov eax, '000N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifb:
    cmp al, 5
    jne @@ifc
      mov eax, 'CD%/'
      stosd
      mov eax, '500N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifc:
    cmp al, 36
    jne @@ifd
      mov eax, 'CD%/'
      stosd
      mov eax, '630N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifd:
    cmp al, 96
    jne @@ife
      mov eax, 'CD%/'
      stosd
      mov eax, '690N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ife:
    cmp al, 124
    jne @@iff
      mov eax, 'CD%/'
      stosd
      mov eax, '421N'
      stosd
      mov  ax, '/%'
      stosw
      jmp @@ifend
    @@iff:
    cmp al, 126
    jne @@ifelse
      mov eax, 'CD%/'
      stosd
      mov eax, '621N'
      stosd
      mov ax, '/%'
      stosw
      jmp @@ifend
    @@ifelse:
      stosb
    @@ifend:

    inc edx

    cmp edx, ecx
    jl @@while4
  @@endw4:

  mov al, 0h
  stosb

  pop eax
  pop ebx
  pop edi
  pop esi

  add eax, 5

  ret
end;


here is example of usage:

1
2
3
4
5
6
7
8
9
10
11
var
  slock: AnsiString;
  skey: array[1..255] of AnsiChar;
  intPK: Integer;
begin
  slock := 'EXTENDEDPROTOCOL_HeXHub_TE_mzkfahwycyeq Pk=versiunea5.04';
  intPK := LockToKey2(@slock[1], @skey[1]);

  ShowMessage( PAnsiChar(@skey[1]) ); //this is generated key
  ShowMessage( PAnsiChar(@slock[intPK]) ); //this is the PK string if any.
end;


;MM;
Forum Index > Delphi/Pascal and Kylix > DirectConnect LockToKey