Thread: Question about conversions between assembly, binary, and c

  1. #1
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001

    Question about conversions between assembly, binary, and c

    Ok,
    I have a program I'm testing for someone. Basically he wants me to crack his password security. So, I've got a couple of disassemblers hex editors, etc. I have one unique program that can convert binary files into corresponding c code (definetly easier to read than assembly). Anyhow, does that mean that the executable can be read by this program and turned into c code? Or is there some other file type i need to use. My thought was to dissasemble the exe to assembly, then convert that to binary, then that to c...but thinking about it I decided that perhaps it was possible to go straight from exe to C using the utility. Am I going down the wrong path here? thanks.

    [example]
    myprog.exe -->
    assembly -->
    0101010101000001111 -->
    C

    or

    myprog.exe -->
    C
    ?
    [/example]
    PHP and XML
    Let's talk about SAX

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Which path to take depends on your tools. I don't know which tool you are using for converting binary files to C code, so I can't give an answer to that.

    An EXE is a binary, which can be disassembled. Probably the generated assembly code can be translated to C, but ofcourse this will be very primitive.

    It would help a lot if you told us which tools you are using.

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> Probably the generated assembly code can be translated to C,

    However, there are several code sequences that could compile to the same object code, so there is no guarantee that the resulting code would be the same as the original. Disassembly is always very much hit and miss.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    Well i think my plans are pretty much shot anyway.
    The freeware that converted the binary to C doesn't work, it has run time errors, (it's called 2ASM) I tried to email the author but it's a bogus email address. So I guess I'm stuck, The disassembler could be either W32Dasm or SoftIce or IDA disassembler (haven't decided which to use yet) I have hex workshop and hiew for hex editing. And for editing/compiler the C code i have MSVC 6. For compiling the Assembly (if needed) I have masm.
    PHP and XML
    Let's talk about SAX

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    You're using MSVC 6 only for C editing and compiling? Note that MSVC 6 also has a very good debugger, which shows you the disassembled code through which you can run. You can also inspect the registers etc. This could be useful to analyse the algorithm your friend has implemented.

  6. #6
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    OK,
    I did, debug, step into and got assembly code.
    I've gotten another binary to C (the other actually turned out to just put hex code into a c struct) this new one DCC32 actually outputs real c code, but the only problem is, it says it can't read the new EXE type (maybe 16 bit vs 32) but it says it should work for win 95 and nt so i don't know why it can't read this exe, i also tried it on windows calc just to see if it was my buddies program and the same thing so i don't know whats up.
    Last edited by Waldo2k2; 07-17-2002 at 01:54 PM.
    PHP and XML
    Let's talk about SAX

  7. #7
    Registered User Dual-Catfish's Avatar
    Join Date
    Sep 2001
    Posts
    802
    I doubt you need all these fancy tools. I just use W32DASM and Hex Workshop for stuff like this. For programs like this, it's almost always as easy as changing a JE to a JNE.

    If you have no idea what a JE or JNE are, go here: http://www1.lunarpages.com/istudios/tuts/asmfj.html

  8. #8
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    yup sure do know what ya mean.
    thanks, mostly i just got exited when i say a program that can take binary and spit out actual C code ie:
    011101010000101
    --> int main() {
    ...

    maybe i'll use it sometime. thanks again.
    PHP and XML
    Let's talk about SAX

Popular pages Recent additions subscribe to a feed