6

I want to know is there any tools to use assembly file and convert it to an intermediate language such as RREIL and then generate control flow graph from the intermediate language ? This is the example my assembly file:

7c90e430:   lea 0x10(%esp), %edi    R@edi[0xd38e0500][4](W) T0  A@0x0012fd30[0x00000000][4](R) T0
7c90e434:   popl  %eax  R@eax[0x0041771b][4](W) T0  M@0x0012fd20[0x7c901166][4](R) T0
7c90e435:   calll  %eax R@eax[0x7c901166][4](R) T0  M@0x0012fd20[0x7c901166][4](W) T0
7c901166:   lea 0x10(%esp), %eax    R@eax[0x7c901166][4](W) T0  A@0x0012fd30[0x00000000][4](R) T0
7c90116a:   movl  %eax, 0x4(%esp)   M@0x0012fd24[0x00000000][4](W) T0   R@eax[0x0012fd30][4](R) T0
7c90116e:   xor %ebp, %ebp  R@ebp[0x00150748][4](RW) T0 R@ebp[0x00150748][4](R) T0
7c901170:   jmp 0x7c91b057  J@0x00000000[0x00019ee7][4](R) T0
7c91b057:   mov %edi, %edi  R@edi[0x0012fd30][4](W) T0  R@edi[0x0012fd30][4](R) T0
7c91b059:   pushl  %ebp R@ebp[0x00000000][4](R) T0  M@0x0012fd1c[0x00000000][4](W) T0
7c91b05a:   mov %esp, %ebp  R@ebp[0x00000000][4](W) T0  R@esp[0x0012fd1c][4](R) T0
7c91b05c:   cmpb  $0x0, 0x7c97b20c  M@0x7c97b20c[0x00000000][1](R) T0   I@0x00000000[0x00000000][1](R) T0
7c91b063:   jz 0x7c9226ed   J@0x00000000[0x0000768a][4](R) T0

This file is generated after runing a binary in a sandbox so I do not want to convert it to binary and do the process.

P.S: As I know all of existing tools use binary and do this process while I have an assembly file and want to do this process.

2 Answers 2

8

I wrote an article on that very topic about 20 years ago. It's titled Assembly Language Control Flow Graphing and was published in the September 1998 issue of Dr. Dobb's Journal. It used Perl to parse the assembly code to generate a Postscript representation of the control flow graph. That graph then can either be printed or viewed on screen by anything that can render Postscript. It was written for an 8-bit microcontroller that is now obsolete, but the code could be adapted for use with any instruction set. It could also, without much difficulty, be adapted to output SVG.

Sample output from a simple bubble sort in that assembly language looks like this: enter image description here

The numbers at the left represent line numbers in the original bubble.asm file. Flows toward the bottom are on the right of the vertical line. Flows toward the top are on the left.

8

In fact, you have many of these tools. Mostly, what you seems to need is what is called symbolic execution of binary programs which requires to translate the semantics of the assembly language into an intermediate language to pass it to an SMT-solver that handle bit-vector logic formula (usually Z3). But, beware, not all tools support the translation to an intermediate language.

Here is a small sample of such tools (not exhaustive though), given in lexicographic order (to avoid any bias):

I will get back to this list if I realize that I forgot some.

And, concerning the fact that you get assembly code, then just compile it and you will get binary. :-)

3
  • Tnx for your answer. As I know most of them working with only binaries. Due to some research reasons I do not want to compile binary. That is why I looking for a tool that can directly works with assemblies not binaries. Aug 10, 2015 at 17:18
  • 2
    At least Miasm2 can take assembly language as input, and probably many others... But, you should spend more time describing your problem than just dropping four lines here, you might get more relevant answers, then.
    – perror
    Aug 10, 2015 at 17:24
  • Which tool is best to use in Linux to generate cfg from existing assembly?
    – txs
    Mar 28, 2018 at 5:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.