简体   繁体   English

获取操作码的简便方法

[英]easy way to get opcodes

I know how to get the opcodes and the corresponding assembly syntax from an executable; 我知道如何从可执行文件中获取操作码和相应的汇编语法; however is there an easy way to get the opcodes of a particular assembly instruction alone, without writing a program using the same and then, manually linking and loading it and doing an objdump on the executable? 但是有一种简单的方法可以单独获取特定汇编指令的操作码,而无需使用相同的程序编写程序,然后手动链接并加载它并对可执行文件执行objdump?

Is there a simple way to find the corresponding opcodes of a particular instruction? 有没有一种简单的方法来查找特定指令的相应操作码?

You can use gdb's (GNU Debugger's) x/bx command. 您可以使用gdb(GNU Debugger)的x / bx命令。

I made a tutorial here: 我在这里做了一个教程:

http://aimbots.net/tutorials/9276-how-get-op-codes.html http://aimbots.net/tutorials/9276-how-get-op-codes.html

http://aimbots.net/threads/9276-How-to-get-OP-codes http://aimbots.net/threads/9276-How-to-get-OP-codes

I asked a similar question a while back ( DOS debug like program for 32-bit x86 assembly ). 我前一段时间问了一个类似的问题( DOS调试就像32位x86程序集的程序 )。

Someone was kind enough to provide me with an automated script to do this. 有人很友好地为我提供了一个自动化脚本来完成这项工作。 You can follow the link to question, or refer to the script they provided to me below ... 您可以点击提问链接,或参考他们在下面提供给我的脚本......

opcode() {
  echo $* > tmp.S && nasm tmp.S -o tmp.o && od -x tmp.o
  rm -f tmp.o tmp.S
}

Hope this helps. 希望这可以帮助。

X86操作码和指令参考包含32位和64位x86处理器上的一组指令参考表及其相应的操作码。

For x86, you can just look them up in the Intel Manual ( Part 1 (AM) , Part 2 (NZ) ). 对于x86,您可以在英特尔手册( 第1部分(AM)第2部分(新西兰) )中查找它们。 And no, I don't know why the manual is split in 2 parts. 不,我不知道为什么手册分为两部分。

I'm not sure why you want opcodes. 我不确定你为什么要操作码。 But if its for exploit development you probably already have metasploit which comes with a really useful ruby script called nasm_shell.rb (in the tools directory). 但是如果它用于漏洞利用开发,你可能已经有了metasploit,它带有一个非常有用的ruby脚本,名为nasm_shell.rb(在tools目录中)。

Each line you type comes out as an ascii hex representation of the correct opcodes. 您键入的每一行都以正确操作码的ascii十六进制表示形式出现。

If its for some other purpose or you don't want some heavyweight toolkit like metasploit hanging around for whatever reason, you can just pull out the script and install its dependencies. 如果它出于某种其他目的或者您不希望某些重量级工具包(如metasploit)因任何原因而闲置,您可以拔出脚本并安装其依赖项。 It uses Rex and assumes nasm is installed. 它使用Rex并假设安装了nasm。

If you want to adapt it the actual code you need is just a few lines in the function shell.run 如果你想调整它,你需要的实际代码只是函数shell.run中的几行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM