Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:41+00:00 2026-05-26T12:38:41+00:00

I’m working on an x86 asm obfuscator that takes Intel-syntax code as a string

  • 0

I’m working on an x86 asm obfuscator that takes Intel-syntax code as a string and outputs an equivilent set of opcodes that are obfuscated.

Here’s an example:

mov eax, 0x5523
or eax, [ebx]
push eax
call someAPI

Becomes something like:

mov eax, 0xFFFFFFFF ; mov eax, 0x5523
and eax, 0x5523     ;
push [ebx]          ; xor eax, [ebx]
or [esp], eax       ;
pop eax             ;
push 12345h         ; push eax
mov [esp], eax      ;
call getEIP         ; call someAPI
getEIP:             ;
add [esp], 9        ;
jmp someAPI         ;

This is just an example, I’ve not checked that this doesn’t screw up flags (it probably does).

Right now I have an XML document that lists instruction templates (e.g. push e*x) and a list of replacement instructions that can be used.

What I’m looking for is a way to automatically generate opcode sequences that produce the same result as an input. I don’t mind doing an educated bruteforce, but I’m not sure how I’d approach this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:38:42+00:00Added an answer on May 26, 2026 at 12:38 pm

    What you need is an algebraic descripton of what the opcodes do, and a set of algebraic laws that allow you to determine equivalent operations.

    Then for each instruction, you look up its algebraic description (for the sake of an example,
    an

     XOR  eax,mem[ecx]
    

    whose algebraic equivalent is

     eax exclusive_or mem[ecx]
    

    enumerate algebraic equivalences using those algebra equivalents, such as:

     a exclusive_or b ==> (a and not b) or (b and not a)
    

    to generate equivalent algebraic statement for your XOR instruction

     eax exclusive_or mem[ecx] ==> (eax and not mem[ecx]) or (mem[ecx] and not eax)
    

    You may apply more algebraic laws to this, for instance de morgans’ theorem:

     a or b ==> not (not a and not b)
    

    to get

    (not (not (eax and not mem[ecx])) and (not (mem[ecx] and not eax)))
    

    At this point you have a specification of an algebraic computation that will do
    the same thing as the original. There’s your brute force.

    Now you have to “compile” this to machine instructions by matching what instructions
    will do with what this says. Like any compiler, you likely want to optimize the
    generated code (no point in fetching mem[ecx] twice). (All of this hard… its a code generator!)
    The resulting code sequence would be something like:

    mov ebx, mem[ecx]
    mov edx, ebx
    not edx
    and edx, eax
    not eax
    and eax, ebx
    not eax
    or eax, edx
    

    This is a lot of machinery to build manually.

    Another way to do this is to take advantage of a program transformation system that allows you to apply source-to-source transformations to code. Then you can encode “equivalences” as rewrites directly on the code.

    One of these tools is our DMS Software Reengineering Toolkit.

    DMS takes a langauge definition (essentially as an EBNF), automatically implements a parser, AST builder, and prettyprinter (anti parser, turning AST back into valid source text).
    [DMS doesn’t presently have an EBNF for ASM86, but dozens of EBNFs for various
    complex langauges have been build for DMS including several for miscellaneous non-x86 assemblers
    So you’d have to define the ASM86 EBNF to DMS. This is pretty straightforward; DMS
    has a really strong parser generator].

    Using that, DMS will let you write source transformations directly on the code. You could write the following transformations that implement the XOR equivalant and DeMorgan’s law directly:

      domain ASM86;
    
      rule obfuscate_XOR(r: register, m: memory_access):instruction:instruction
      =  " XOR \r, \m " 
          rewrites to
         " MOV \free_register\(\),\m
           NOT \free_register\(\)
           AND \free_register\(\),\r 
           NOT \r
           AND \r,\m
           OR \r,\free_register\(\)";
    
     rule obfuscate_OR(r1: register, r2: register):instruction:instruction
     = " OR \r1, \r2"
         rewrites to
        " MOV \free_register\(\),\r1
          NOT \free_register\(\)
          AND \free_register\(\),\r2
          NOT \r2
          AND \r1,\r2
          NOT \r1";
    

    with some additional magic in a meta-procedure called “free_register” that determines what registers
    are free at that point (of the AST match) in the code. (If you don’t want to do that, use the top of the stack
    as temporary everywhere as you did in your example).

    You’d need a bunch of rewrites to cover all the cases that you want to obfuscate, with thier combinatorics with registers and memory operands.

    Then the transformation engine can be asked to apply these transformations randomly once or more than once at each point in the code to scramble it.

    You can see a fully worked example of some algebraic transforms being applied with DMS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.