私はプロジェクトに取り組んでおり、アセンブリコードに機械コードを代入するために逆アセンブラが必要です...私はzydisとcapstoneを試しました。彼らが動作するようには思えいけない、私はプロのVisual Studio 15を使用して...、私はgithubの上で絶頂例をやってみましたが、それは仕事をdidntの私がコピーされたC++バインディングと、このコード:::私は蓋の分解器を使用する方法
#pragma once
#include <cccapstone/cppbindings/X86Disasm.hh>
namespace CapstoneBindingsTest
{
#define RANDOM_CODE "\xed\x00\x00\x00\x00\x1a\x5a\x0f\x1f\xff\xc2\x09\x80\x00\x00\x00\x07\xf7\xeb\x2a\xff\xff\x7f\x57\xe3\x01\xff\xff\x7f\x57\xeb\x00\xf0\x00\x00\x24\xb2\x4f\x00\x78"
static
size_t
SkipDataCallback(
__in const uint8_t *buffer,
__in uint64_t offset,
__in void *p
)
{
printf("\nskip data callback ! : %x %p !", offset, buffer);
return 1;//just for test, skip 1instr *data*
}
static
void
DisasmData(
__in CCsDisasm<CX86InsClass>& dis,
__in const void* code,
__in size_t size
)
{
dis.SetSyntax(cs_opt_value::CS_OPT_SYNTAX_INTEL);
auto insn = dis.Disasm(code, size);
if (!insn.get())
return;
printf("\n\nDISASM :\n\n");
for (size_t i = 0; i < insn->Count; i++)
{
printf("-> 0x%p:\t%s\t%s\n", insn->Instructions(i)->address, insn->Instructions(i)->mnemonic, insn->Instructions(i)->op_str);
//TODO
#if 0
if (!insn->Instructions(i).IsInInsGroup(x86_insn_group::X86_GRP_JUMP))
continue;
printf("\nCONTROL FLOW CHANGE instruction detected!\n");
printf("-> 0x%p:\t%s\t%s\n", insn->Instructions(i)->address, insn->Instructions(i)->mnemonic, insn->Instructions(i)->op_str);
#endif
}
}
static
void
X64Disasm(
__in const void* code,
__in size_t size,
__in bool allInfo = false
)
{
CX86Disasm64 dis;
if (dis.GetError())
return;
DisasmData(dis, code, size);
}
static
void
X64DisasmCallback(
__in const void* code,
__in size_t size,
__in bool allInfo = false
)
{
CX86Disasm64 dis;
if (dis.GetError())
return;
if (allInfo)
dis.SetDetail(cs_opt_value::CS_OPT_ON);
dis.SetSkipDataCallback(cs_opt_skipdata{ ".UNKOWNBYTES : ", SkipDataCallback, nullptr });
DisasmData(dis, code, size);
}
};
を使用し、私のプロジェクトフォルダ内のcppbingindsフォルダをpastenし、win32コンソールアプリケーション用のコードをコンパイルしようとしましたが、clrコンソールアプリケーション用ですが、変数insnや他のいくつかのエラーが複数発生します...私もzydis用にこのコードを試しました:: :
#include <stdio.h>
#include <Zydis/Zydis.h>
int main()
{
uint8_t data[] =
{
0x51, 0x8D, 0x45, 0xFF, 0x50, 0xFF, 0x75, 0x0C, 0xFF, 0x75,
0x08, 0xFF, 0x15, 0xA0, 0xA5, 0x48, 0x76, 0x85, 0xC0, 0x0F,
0x88, 0xFC, 0xDA, 0x02, 0x00
};
// Initialize decoder context.
ZydisDecoder decoder;
ZydisDecoderInit(
&decoder,
ZYDIS_MACHINE_MODE_LONG_64,
ZYDIS_ADDRESS_WIDTH_64);
// Initialize formatter. Only required when you actually plan to
// do instruction formatting ("disassembling"), like we do here.
ZydisFormatter formatter;
ZydisFormatterInit(&formatter, ZYDIS_FORMATTER_STYLE_INTEL);
// Loop over the instructions in our buffer.
uint64_t instructionPointer = 0x007FFFFFFF400000;
uint8_t* readPointer = data;
size_t length = sizeof(data);
ZydisDecodedInstruction instruction;
while (ZYDIS_SUCCESS(ZydisDecoderDecodeBuffer(
&decoder, readPointer, length, instructionPointer, &instruction)))
{
// Print current instruction pointer.
printf("%016" PRIX64 " ", instructionPointer);
// Format & print the binary instruction
// structure to human readable format.
char buffer[256];
ZydisFormatterFormatInstruction(
&formatter, &instruction, buffer, sizeof(buffer));
puts(buffer);
readPointer += instruction.length;
length -= instruction.length;
instructionPointer += instruction.length;
}
}
私は結果が:::
007FFFFFFF400000 push rcx
007FFFFFFF400001 lea eax, [rbp-0x01]
007FFFFFFF400004 push rax
007FFFFFFF400005 push qword ptr [rbp+0x0C]
007FFFFFFF400008 push qword ptr [rbp+0x08]
007FFFFFFF40000B call [0x008000007588A5B1]
007FFFFFFF400011 test eax, eax
007FFFFFFF400013 js 0x007FFFFFFF42DB15
ことが期待しかし、私はコンパイルエラーを持って、私はエラーを覚えてカントが、私はすぐに私は私のPCに着くと、この記事を更新します...
私はちょうど私が間違ってやっていることを知りたかったのですが、試してみるとよいサンプルがあれば、誰も私のためにコード全体を構築したくないのです...私はバイトをウィンドウのためのアセンブリ命令へのアドレス、任意の助けに感謝するでしょう。 C++/c#/ pythonのサンプル回答があれば幸いです... thnx in advance
ps、plz私はこのようなnoob質問だと思うのでこのポストをdownvoteしないでください。学び、私はおそらく
また、コードサンプルがgithubの
"しかし、私は自分のPCに着くとすぐにこの投稿を更新します..."将来の参考として、これは危険な選択です。あなたは戻って、質問を保留にするかもしれません。一度それが起こると、再びそれを解除することは本当に難しいことができます。 – user4581301
thnx、もう一度やり直してください – user8086906