1
Name:
Anonymous
2011-11-10 13:07
Have you seen original source code for following routine?
_BYTE *__fastcall decodeLZ_sub(_BYTE *Dst, void *Src)
{
_BYTE *D; // esi@1
_BYTE *S; // edi@1
unsigned int i; // ecx@1
char v5; // al@2
_BYTE *R; // esi@2
char v7; // dl@3
char v8; // al@3
__int16 v9; // ax@3
__int16 v10; // ax@5
char v11; // dl@7
char v12; // al@7
_BYTE *v13; // esi@7
unsigned __int8 v14; // dh@7
__int16 v15; // ax@7
__int16 v16; // dx@9
D = Dst;
S = Src;
for ( i = 0; ; S += i )
{
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
v5 = *D;
R = D + 1;
if ( v5 < 0 )
break;
v7 = v5;
v8 = *R;
D = R + 1;
HIBYTE(v9) = v8;
LOBYTE(v9) = v9 & 0x18;
if ( (_BYTE)v9 )
{
LOBYTE(i) = (unsigned __int8)v9 >> 3;
memcpy(S, D, i);
D += i;
S += i;
i = 0;
}
LOBYTE(i) = (HIBYTE(v9) & 7) + 3;
LOBYTE(v9) = HIBYTE(v9);
v10 = 4 * v9 & 0x380;
LOBYTE(v10) = v7 | v10;
memcpy(S, &S[-(unsigned __int16)(v10 + 1)], i);
S += i;
}
if ( v5 & 0x40 )
break;
v11 = v5;
v12 = *R;
v13 = R + 1;
HIBYTE(v15) = v12;
LOBYTE(v15) = *v13;
D = v13 + 1;
v14 = v15;
LOBYTE(v15) = v15 & 3;
if ( (_BYTE)v15 )
{
LOBYTE(i) = v15;
memcpy(S, D, i);
D += i;
S += i;
i = 0;
}
LOBYTE(i) = (HIBYTE(v15) & 0x1F) + 3;
HIBYTE(v16) = (v14 >> 1) & 0x7E;
LOBYTE(v16) = v11 & 0x3F;
LOBYTE(v15) = HIBYTE(v15);
memcpy(S, &S[-(unsigned __int16)((v16 | 2 * v15 & 0x1C0) + 1)], i);
S += i;
}
if ( v5 & 0x30 )
break;
LOBYTE(i) = 4 * ((v5 & 0xF) + 1);
memcpy(S, R, i);
D = &R[i];
S += i;
}
if ( v5 == -1 )
break;
LOBYTE(i) = v5 & 0xF;
memcpy(S, R, i);
D = &R[i];
}
return R;
}
2
Name:
Anonymous
2011-11-10 13:08
>>1
Also, it uses memcpy to copy overlapping regions. Worse is Better!
3
Name:
Anonymous
2011-11-10 13:28
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
Oh god it hurts to live.
4
Name:
Anonymous
2011-11-10 13:29
Enjoying your pirated disassembler?
Also that's pretty trivial as far as RE goes. Shouldn't take you more than half an hour or so.
5
Name:
Anonymous
2011-11-10 13:32
3 nested while(1), WTF?
Post the asm output, it looks like your decompiler misidentified the loop conditions. The innermost should start with something like while((c=*d++)<0)
6
Name:
Anonymous
2011-11-10 13:37
>>5
The outermost for is also missing its condition, which is actually this:
if ( v5 == -1 )
break;
Horrible decompiler. It would be easier to understand the asm.
7
Name:
Anonymous
2011-11-10 13:43
while ( 1 )
{
while ( 1 )
{
while ( 1 )
{
curly brackets are not next to while() statement?! there is something wrong with that compiler
9
Name:
Anonymous
2011-11-10 13:47
ITT /prog/ solves NP-complete problems for breakfast, producing a perfect automated decompiler.
10
Name:
Anonymous
2011-11-10 13:52
>>9
it is easy, I just proved P is NP and rest is straightforward
11
Name:
Anonymous
2011-11-10 15:14
Just upgraded to the latest version, went from 1.1 to 1.6. The improvements are very subtle at best. About 1-2% reduced decompiled code size, simplified some trivial shit, but the output is basically the same. Can't recommend. It would probably get rid of OP's while ( 1 )s, but that's hardly an improvement (I don't know why you people throw a fit over that, the exit conditions are perfectly clear, there's exactly one if (cond) break; per nesting level.) It still doesn't do C++ well at all.
12
Name:
Anonymous
2011-11-10 18:28
WHO THE FUCK NESTS WHILE(1) LOOPS
13
Name:
Anonymous
2011-11-10 19:01
>>6
Horrible decompiler. It would be easier to understand the asm.
But it's easy to maker errors translating code manually!
14
Name:
Anonymous
2011-11-10 19:05
>>9
ITT /prog/ solves NP-complete problems for breakfast, producing a perfect automated decompiler.
That crap works only on simple compiler produced code. It wont decompile handwritten assembly, Lisp fasls or Forth code.
15
Name:
Anonymous
2011-11-10 19:08
An example of code it wont decompile:
.data
byte_curbits db 0
word_maxvalue dw 0
word_dicreset dw 0
word_incbits dw 0
dword_buff2 dd 0
dword_buff3 dd 0
dword_buff4 dd 0
dword_427B51 dd 0
byte_427B4C db 0
word_nextcode dw 0
dword_427B4D dd 0
word_427ABE dw 0
word_427AC2 dw 0
word_427AC0 dw 0
dword_stack dd ?
dword_usize dd ?
dword_psize dd ?
dword_outbf dd ?
dword_input dd ?
dword_buff2_b db 8D00h dup(?)
dword_buff3_b db 4680h dup(?)
dword_buff4_b db 0FA0h dup(?)
.code
proc unlzw
pop eax ; retnaddr
pop [dword_usize]
pop [dword_psize]
pop [dword_outbf]
pop [dword_input] ; input
push eax ;retnaddr
push ebp
mov ebp, esp
push ebx
push esi
push edi
mov [dword_stack], esp
mov ebx, [dword_usize] ; u
mov eax, [dword_psize] ; p
mov edi, [dword_outbf] ; out
push edi ; output buffer
push eax ; packed size
push ebx ; unpacked size (edi size)
mov edx, dword_buff2_b
mov [dword_buff2], edx
mov edx, dword_buff3_b
mov [dword_buff3], edx
mov edx, dword_buff4_b
mov [dword_buff4], edx
pop ebx
pop eax
pop edi
push edi
mov edx, eax
mov eax, edx
mov [dword_427B51], 0
mov esi, [dword_input]
push esi
mov edi, [dword_input]
; call sub_40BAA9 ; read from file to buffer
pop esi
pop edi
; start unpacking code
mov al, 9
call lzwinit
mov [byte_427B4C], 0
loc_40BB49:
mov [word_nextcode], 100h
mov ebx, [dword_427B4D]
mov ch, [byte_curbits]
mov cl, [byte_427B4C]
mov edx, [dword_427B51]
loc_40BB6A:
shl ebx, 8
mov bl, [esi]
inc esi
add cl, 8
or edx, edx
jz short loc_40BB8C
dec edx
or edx, edx
ja short loc_40BB8C
mov esi, [dword_input]
mov [dword_427B51], 0
loc_40BB8C:
cmp ch, cl
jg short loc_40BB6A
mov [dword_427B51], edx
sub cl, ch
mov eax, ebx
shr eax, cl
and ax, [word_maxvalue]
mov [byte_427B4C], cl
mov [dword_427B4D], ebx
mov [word_427ABE], ax
mov [word_427AC2], ax
stosb
loc_40BBBC:
mov ebx, [dword_427B4D]
mov ch, [byte_curbits]
mov cl, [byte_427B4C]
mov edx, [dword_427B51]
loc_40BBD4:
shl ebx, 8
mov bl, [esi]
inc esi
add cl, 8
or edx, edx
jz short loc_40BBF6
dec edx
or edx, edx
ja short loc_40BBF6
mov esi, [dword_input]
mov [dword_427B51], 0
loc_40BBF6:
cmp ch, cl
jg short loc_40BBD4
mov [dword_427B51], edx
sub cl, ch
mov eax, ebx
shr eax, cl
and ax, [word_maxvalue]
mov [byte_427B4C], cl
mov [dword_427B4D], ebx
mov [word_427AC0], ax
cmp ax, [word_maxvalue]
jz loc_endproc
cmp ax, [word_dicreset]
jz loc_40BB49
mov ebp, [dword_buff4]
mov bx, ax
cmp ax, [word_nextcode]
jl short loc_40BC5D
mov dx, [word_427AC2]
mov [ebp+0], dl
inc ebp
mov bx, [word_427ABE]
loc_40BC5D:
push ax
xor cx, cx
jmp short loc_40BC93
; ---------------------------------------------------------------------------
loc_40BC64:
movzx ebx, bx
mov edx, [dword_buff3]
mov al, [ebx+edx]
mov [ebp+0], al
inc ebp
shl ebx, 1
mov edx, [dword_buff2]
mov bx, [edx+ebx]
inc cx
cmp cx, 0FA0h
jb short loc_40BC93
; Fatal error, code depth too great.
xor eax, eax
inc eax
mov esp, [dword_stack] ; restore stack
jmp loc_endproc_error
; ---------------------------------------------------------------------------
loc_40BC93:
cmp bx, 0FFh
jg short loc_40BC64
mov [ebp+0], bl
movzx ax, byte [ebp+0]
mov [word_427AC2], ax
loc_40BCA8:
cmp ebp, [dword_buff4]
jb short loc_40BCB7
mov al, [ebp+0]
stosb
dec ebp
jmp short loc_40BCA8
; ---------------------------------------------------------------------------
loc_40BCB7:
xor ebp, ebp
mov bp, [word_nextcode]
shl bp, 1
add ebp, [dword_buff2]
mov ax, [word_427ABE]
mov [ebp+0], ax
xor ebp, ebp
mov bp, [word_nextcode]
add ebp, [dword_buff3]
mov ax, [word_427AC2]
mov [ebp+0], al
inc [word_nextcode]
mov ax, [word_nextcode]
cmp ax, [word_incbits]
jle short loc_40BD16
cmp [byte_curbits], 0Eh
jge short loc_40BD16
mov al, [byte_curbits]
inc al
call lzwinit
loc_40BD16:
pop ax
mov [word_427ABE], ax
jmp loc_40BBBC
; ---------------------------------------------------------------------------
loc_endproc:
xor eax, eax
loc_endproc_error:
pop edi
pop esi
pop ebx
pop ebp
retn
endp
16
Name:
Anonymous
2011-11-10 19:10
Probably due to
push ax
...
pop ax
17
Name:
Anonymous
2011-11-10 19:17
Oh look it's that Nigger again who posts decompiled binaries and complains about autism
18
Name:
Anonymous
2011-11-10 19:32
>>17
Don't mind me, just checking whether code tags highlight
Nigger as a keyword.
nigger Nigger NIGGER lhadfuewouh Lhadfuewouh LHADFUEWOUH
19
Name:
Anonymous
2011-11-10 20:16
>>15
They don't analyze the stack since the majority of the code doesn't use it to its full power.
20
Name:
Anonymous
2011-11-10 20:29
>>19
Good code doesnt use stack. It uses generational garbage collector.
21
Name:
Anonymous
2011-11-10 21:06
Good code doesnt use stack.
Thus, Forth was never good code.
22
Name:
Anonymous
2011-11-10 22:39
>>21
Forth cant do continuations and all control constructs look uglier than a retarded jew. Kinda brainfuck.
23
Name:
Anonymous
2011-11-11 1:02
Here is a manually disassembled version. Note the obsence of memcpy (which were erroneously supplied by decompiler)
static int decodeLZ(u1 *Dst, u1 *Src) {
u4 A=0, B=0, C=0, D=0;
u1 *P, *O = Dst;
for (AL = *Src++; AL != 0xFF; AL = *Src++) {
if (!(AL&0x80)) {
DL = AL;
AL = *Src++;
AH = AL;
AL &= 0x18;
if (AL) {
AL >>= 3;
for (CL=AL; CL; CL--) *Dst++ = *Src++;
}
CL = (AH&7)+3; //backref len
AL = AH;
P = Dst - (((AX<<2)&0x380)|DL) - 1; //backref off
for (; CL; CL--) *Dst++ = *P++;
} else if (!(AL&0x40)) {
DL = AL;
AL = *Src++;
AH = AL;
AL = *Src++;
DH = AL;
AL &= 3;
for (CL=AL; CL; CL--) *Dst++ = *Src++;
CL = (AH&0x1F)+3;
DH = (DH>>1 )&0x7E;
DL = 0x3F;
AL = AH;
P = Dst - (((AX<<1)&0x1C0)|DX) - 1;
for (; CL; CL--) *Dst++ = *P++;
} else if (!(AL&0x30)) {
CL = ((AL&0xF)+1)<<2;
for (; CL; CL--) *Dst++ = *P++;
} else {
for (CL=AL&0xF; CL; CL--) *Dst++ = *Src++;
}
}
return Dst-O;
}
25
Name:
Cudder
!MhMRSATORI!FBeUS42x4uM+kgp
2011-11-11 5:02
Post the original, I'll try it with mine.
>>15
char byte_curbits;
short word_maxvalue;
short word_dicreset;
short word_incbits;
unsigned short *dword_buff2;
char *dword_buff3;
char *dword_buff4;
unsigned int dword_427B51;
char byte_427B4C;
unsigned short word_nextcode;
int dword_427B4D;
short word_427ABE;
short word_427AC2;
short word_427AC0;
char *dword_stack;
int dword_usize;
int dword_psize;
int dword_outbf;
int dword_input;
unsigned short dword_buff2_b[0x4680];
char dword_buff3_b[0x4680];
char dword_buff4_b[0xFA0];
int unlzw(char *arg_1, char *arg_2, int arg_3, int arg_4) {
dword_usize = arg_4;
dword_psize = arg_3;
dword_outbf = arg_2;
dword_input = arg_1;
char *v_edi = dword_outbf;
dword_buff2 = &dword_buff2_b;
dword_buff3 = &dword_buff3_b;
dword_buff4 = &dword_buff4_b;
dword_427B51 = 0;
char *v_esi = dword_input;
sub_40BAA9(v_esi, dword_outbf);
lzwinit();
byte_427B4C = 0;
short v_ax;
do { /* loc_40BB49 */
word_nextcode = 256;
int v_ebx = dword_427B4D;
char v_ch = byte_curbits;
char v_cl = byte_427B4C;
unsigned int v_edx = dword_427B51;
do { /* loc_40BB6A */
v_ebx = (v_ebx<<8) | *v_esi++;
v_cl += 8;
if(!v_edx && !--v_edx) {
v_esi = dword_input;
dword_427B51 = 0;
}
} while(v_ch > v_cl);
dword_427B51 = v_edx;
v_cl -= v_ch;
v_ax = (v_ebx<<v_cl)&word_maxvalue;
byte_427B4C = v_cl;
dword_427B4D = v_ebx;
word_427ABE = v_ax;
word_427AC2 = v_ax;
*v_edi++ = v_ax;
loc_40BBBC:
v_ebx = dword_427B4D;
v_ch = byte_curbits;
v_cl = byte_427B4C;
v_edx = dword_427B51;
do { /* loc_40BBD4 */
v_ebx = (v_ebx<<8) | *v_esi++;
v_cl += 8;
if(!v_edx && !--v_edx) {
v_esi = dword_input;
dword_427B51 = 0;
}
} while(v_ch > v_cl);
dword_427B51 = v_edx;
v_cl -= v_ch;
v_ax = (v_ebx<<v_cl)&word_maxvalue;
byte_427B4C = v_cl;
dword_427B4D = v_ebx;
word_427AC0 = v_ax;
if(v_ax == word_maxvalue)
return 0;
} while(v_ax == word_dicreset);
unsigned char *v_ebp = dword_buff4;
unsigned short v_bx = v_ax;
if(v_ax >= word_nextcode) {
*v_ebp++ = word_427AC2;
v_bx = word_427ABE;
}
unsigned short v_cx = 0;
while(v_bx > 255) {
*v_ebp++ = dword_buff3[v_bx];
v_bx = dword_buff2[v_bx];
if(++v_cx >= 4000)
return 1;
}
*v_ebp = v_bx;
word_427AC2 = *v_ebp;
while(v_ebp >= dword_buff4)
*v_edi++ = *v_ebp--;
dword_buff2[word_nextcode] = word_427ABE;
dword_buff3[word_nextcode++] = word_427AC2;
if((signed short)word_nextcode > word_incbits && byte_curbits < 14)
lzwinit();
word_427ABE = v_ax;
goto loc_40BBBC;
}
30
Name:
Cudder
!MhMRSATORI!FBeUS42x4uM+kgp
2011-11-12 4:22
After some minor expression substitution:
__Optlink char *l_0003F499(char *arg_1, char *arg_2) {
char *v_esi = arg_1;
char *v_edi = arg_2;
char v_al;
char v_ah;
char v_cl;
char v_dl;
char v_dh;
while(1) {
unsigned short v_ax;
v_al = *v_esi++;
if(v_al>=0) {
v_dl = v_al;
v_al = *v_esi++;
v_ah = v_al;
if(v_al&=24) {
v_cl = v_al<<3;
while(v_cl) {
*v_edi++ = *v_esi++;
v_cl--;
}
}
v_cl = (v_ah&7) + 3;
v_ax = (((((v_ah<<8)|v_ah)<<2)&0x380)|v_dl)+1;
{
char *v_esi = v_edi - v_ax;
while(v_cl) {
*v_edi++ = *v_esi++;
v_cl--;
}
}
continue;
} else if(v_al&64) {
v_dl = v_al;
v_ah = *v_esi++;
v_al = *v_esi++;
v_dh = v_al;
if(v_al&=3) {
v_cl = v_al;
while(v_cl) {
*v_edi++ = *v_esi++;
v_cl--;
}
}
v_cl = (v_ah&31) + 3;
v_ax = (((((v_ah<<8)|v_ah)<<1)&0x1c0)|(((v_dh>>1 )&126)<<8)|(v_dl&63))+1;
{
char *v_esi = v_edi - v_ax;
while(v_cl) {
*v_edi++ = *v_esi++;
v_cl--;
}
}
continue;
} else if(v_al&48) {
v_cl = ((v_al&15)+1)<<2;
while(v_cl) {
*v_edi++ = *v_esi++;
v_cl--;
}
continue;
} else if(v_al==-1)
break;
v_cl = v_al&15;
while(v_cl) {
*v_edi++ = *v_esi++;
v_cl--;
}
}
return v_esi;
}
31
Name:
Anonymous
2011-11-12 16:38
>>29
You should sell your converter to hexrays, cuz their is crappy.
32
Name:
Anonymous
2011-11-12 21:29
>>29-30
Go back to REchan, ragstorm.
33
Name:
Anonymous
2011-11-12 21:47
What is the difference between Anonix and LoseThos?
34
Name:
Anonymous
2011-11-12 21:52
Anonix is to LoseThos what Linux is to GNU.
35
Name:
Anonymous
2011-11-12 22:51
Nerd life
Graphics calculator hp40ag
the g is for gangsta
36
Name:
Anonymous
2011-11-13 2:11
>>33
LoseThos actually exists.
37
Name:
Cudder
!MhMRSATORI!FBeUS42x4uM+kgp
2011-11-13 4:11
>>31
It's currently not public but we have plans to release it as open-source/public domain sometime in the future.
It is a part of a larger system/analysis framework, intended to replace IDA. IDA is certainly not the greatest, being too windows/x86-centric and closed-source, making use of proprietary formats.
38
Name:
Anonymous
2011-11-13 9:10
Who's the better ``programmer'', Cudder or FrozenVoid?
39
Name:
Anonymous
2011-11-13 23:41
>>38
Why did you put "programmer" in quotes?
40
Name:
Anonymous
2011-11-13 23:46
>>37
You're very ambitious, considering that IDA took 20 years to develop into it's current state, while the best crackers contributed to it's development. Good luck.