Coder Social home page Coder Social logo

mithreindeir / dynzasm Goto Github PK

View Code? Open in Web Editor NEW
36.0 5.0 10.0 192 KB

X86/X64/ARM/MIPS Assembler/Disassembler/Decomposer Library

License: Apache License 2.0

C 82.79% TeX 15.30% Makefile 0.82% Ruby 1.10%
disassembler assembler reverse-engineering

dynzasm's Introduction

Dynzasm

Build Status Coverity Scan Build Status

Dynzasm is a fast lightweight disassembly library written in c99 code with no external dependencies. Disassembly is structured as trees with arbitrary formatting strings, allowing detailed disassembly information and making it easy to support custom syntaxes.

ARCH Disassembly SUPPORT Assembler Support
X86 Most (excluding extensions) Partial (No fp, or isa ext)
X64 Most (excluding extensions) Partial (No fp, or isa ext)
ARM Partial None (WIP)
MIPS Most None (WIP)

Includes sample commandline utility

./dynzasm --help
Usage: ./dynzasm options filename
	--arch=<architecture> Set architecture to be disassembled (x86, arm, or mips
	--mode=<mode> Set the architecture mode (32 or 64)
	--entry=<addr> Set a starting address
	-a convert ascii to hex
	-A Assemble
If no file is specified stdin will be used
Must specify architecture and mode
echo "55 48 89 e5 48 83 ec 70" | ./dynzasm --arch=x86 --mode=64 -a --addr=0x2172 
0x002172:	55                            	push	rbp
0x002173:	48 89 e5                      	mov	rbp, rsp
0x002176:	48 83 ec 70                   	sub	rsp, 0x70

An example of using the assembler from stdin, and piping it into the disassembler.

./dynzasm --arch=x86 --mode=64 -A | ./dynzasm --arch=x86 --mode=64 -a
push rbp
mov rbp, rsp
mov eax, 0
ret
00000000:	55                            	push	rbp
0x000001:	48 8b ec                      	mov	rbp, rsp
0x000004:	b8 00 00 00 00                	mov	eax, 0
0x000009:	c3                            	ret

It is also very easy to use as a library. Detailed semantics from disassembly for easy analysis coming soon.

#include "disas.h"

int main()
{
	
  struct disassembler *ds = ds_init(X86_ARCH, MODE_64B);
  unsigned char bytes[] =  "\x55\x48\x89\xe5\xb8\x00\x00\x00\x00\xc3";

  ds_decode(ds, bytes, sizeof(bytes)-1, 0x0);
  struct dis *dis = NULL;
  
  DS_FOREACH(ds, dis) {
    printf("%#08lx:\t%s\t%s\n", dis->address, dis->mnemonic, dis->op_squash);
  }
  
  ds_destroy(ds);
  return 0;
}

dynzasm's People

Contributors

mithreindeir avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

dynzasm's Issues

The "lea" instruction is not disassembled correctly

Hello friend!: Thank you for your code. The "lea" instruction is not disassembled correctly. I was reviewing the code and it's a matter of modifying line 174 of the file /src/arch/x86/x86.ins, instead of
"8d lea Gv", modify by "8d lea Gv Av". That is, it was only necessary to place the letters that identify the memory operators: Av.
Enough with that to decode the machine code well in 32 and 64 bits, so I guess it was just a little oversight.

Invalid assemble list for x64

Hello Mithreindeir,

This is a very good product, thanks for you developing it.
Now I can't find the root cause, I faced the following disassemble code.

00:   4c 8d 44 24 20                    lea     r8, [rsp+0x00000020]
05:   49 83 00 01 4d                    add     qword [r9], 0x4d
0a:   8b 00                             mov     eax, dword [rax]

But I expected it as below, and it works as I expected.

00:   4c 8d 44 24 20                    lea     r8, [rsp+0x00000020]
05:   49 83 00 01                       add     qword [r8], 0x01
09:   4d 8b 00                          mov     r8, qword [r8]

What is wrong do you know?
Can you please advise me?

Thank you very much in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.