Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > Programming languages > Some code to obfuscate conditional branches in a dissassembler
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 10th October 12:35
andrew pogrebennyk
External User
 
Posts: 1
Default Some code to obfuscate conditional branches in a dissassembler



The "Secure Programming Cookbook for C and C++" proposed the following
code to obfuscate conditional branches in a dissassembler:

#define IF_ZERO(val) \
asm(" xorl %%ebx, %%ebx\n\t" \
" negl %%eax\n\t" \
" rcl $3, %%ebx\n\t" \
" movl 0f( , %%ebx ), %%eax \n\t" \
" jmp *%%eax \n" \
"0: \n\t" \
" .long 1f\n\t" \
" .long 2f\n" \
"1: \n" \
: : "a" (val) : "%ebx");

#define ELSE \
asm(" jmp 3f\n\t" \
"2: \n");

#define ENDIF \
asm("3: \n");

The IF_ZERO macro places the value to be tested in the eax register, then
uses the negl instruction to set the carry flag if the value in the eax
register is nonzero. The carry flag is then rotated into a register and
used as an index into a jump table. The macro can be used to test for
equality by subtracting one value from another and passing it the result.

The problem is that GCC (version 3.3.5, Debian GNU/Linux Sarge) says
"Error: local label `"2" (instance number 1 if a fb label)' is not
defined". I'm not strong in assembly yes, what is wrong there? Thanks.

Best regards,
Andrew Pogrebennyk
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666