Giter VIP home page Giter VIP logo

docker-assembly-gef-pyenv's Introduction

汇编语言学习容器

使用这个容器的学习笔记

相关的blog

注意事项

GEF已经安装进容器:

使用方法

$ docker run -it weli/docker-assembly-gef-pyenv bash

使用privileged mode运行容器

在容器当中使用gdb调试代码需要使用privileged mode

$ docker run -it --privileged weli/docker-assembly-gef-pyenv bash

编译汇编代码

$ pwd
/root
$ ls
foo.asm
$ cat foo.asm
global _start
_start:
  mov eax, 1
  mov ebx, 5
  int 0x80
$ yasm -f elf64 -g dwarf2 -l foo.lst foo.asm
$ ls
foo.asm  foo.lst  foo.o
$ ld -o foo foo.o
$ ls foo
foo
$ ./foo
$ echo $?
5

调试汇编代码

注意:在容器当中使用gdb调试代码需要使用privileged mode,参见上文。

$ pwd
/root
$ ls
foo      foo.asm  foo.lst  foo.o
bash-5.0# gdb -q foo
GEF for linux ready, type `gef' to start, `gef config' to configure
80 commands loaded for GDB 8.3 using Python engine 3.7
Reading symbols from foo...
gef➤  list
1	global _start
2	_start:
3	  mov eax, 1
4	  mov ebx, 5
5	  int 0x80
6
gef➤

截图:

c和assembly的混编

$ pwd
/root
$ ls asm.c
asm.c
$ cat asm.c
#include <stdio.h>
int main(void)
{
        int foo = 10, bar = 15;
        __asm__ __volatile__("addl  %%ebx,%%eax"
                             :"=a"(foo)
                             :"a"(foo), "b"(bar)
                             );
        printf("foo+bar=%d\n", foo);
        return 0;
}
$ cc -g asm.c -o asm
$ ls asm
asm
$ ./asm
foo+bar=25

代码例子

参考文档

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.