如何使用可重定向的反编译器cURL API? [英] How to use Retargetable Decompiler cURL API?
问题描述
我正在使用 Windows
,并且正在尝试使用这是使用可以正常工作并产生结果的浏览器.现在,当尝试从命令行使用 cURL
执行相同操作时,出现错误.
I'm on Windows
and I'm trying to use the cURL API provided by Retargetable Decompiler
. Since cURL is a Linux utility, I downloaded a Windows
build from here. Let's say I want to perform the following decompilation:
This is using the browser which works and produces a result. Now when trying to do the same using cURL
from the command line, I get errors.
输出:
>curl --form "mode=raw" --form "input=code.bin" --form "architecture=powerpc" --form "endian=big" --form "raw_entry_point=0x0" --form "raw_section_vma=0x0" -u my-secret-api-key: "https://retdec.com/service/api/decompiler/decompilations" { "id": "yVWe4pe5", "links": { "decompilation": "https://retdec.com/service/api/decompiler/decompilations/yVWe4pe5", "status": "https://retdec.com/service/api/decompiler/decompilations/yVWe4pe5/status", "outputs": "https://retdec.com/service/api/decompiler/decompilations/yVWe4pe5/outputs" }}
{
"code": 400,
"description": "The input file is missing.",
"message": "Missing Input File"
}
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: id
curl: (6) Could not resolve host: yVWe4pe5,
curl: (6) Could not resolve host: links
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: decompilation
{
"code": 405,
"description": "The method is not allowed for the requested URL.",
"message": "Method Not Allowed"
}
curl: (6) Could not resolve host: status
{
"code": 404,
"description": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.",
"message": "Not Found"
}
curl: (6) Could not resolve host: outputs
{
"code": 405,
"description": "The method is not allowed for the requested URL.",
"message": "Method Not Allowed"
}
curl: (3) [globbing] unmatched close brace/bracket in column 1
也是,code.bin与命令行(脚本)位于同一目录中.我该如何运作?我实际上更喜欢使用 Java
而不是 cURL
的解决方案,但是首先使用 cURL
进行解决可能更容易理解,因为没有提供了Java
示例或文档.
Also yes, the code.bin is in the same directory as the command line (script). How can I make it work? I actually prefer a solution in Java
and not cURL
but doing it in cURL
first might be easier for understanding since no Java
examples or documentation is provided.
推荐答案
没关系,这很简单.
开始该过程:
>curl --form "mode=raw" --form "input=@code.bin;filename=code.bin" --form "architecture=powerpc" --form "endian=big" --form "raw_entry_point=0x0" --form "raw_section_vma=0x0" --form "target_language=c" -u my-secret-api-key: "https://retdec.com/service/api/decompiler/decompilations"
收到的(示例)响应:
{
"id": "mKgBoLa3jo",
"links": {
"decompilation": "https://retdec.com/service/api/decompiler/decompilations/mKgBoLa3jo",
"outputs": "https://retdec.com/service/api/decompiler/decompilations/mKgBoLa3jo/outputs",
"status": "https://retdec.com/service/api/decompiler/decompilations/mKgBoLa3jo/status"
}
}
获取反编译(示例)代码:
Getting the decompiled (example) code:
>curl -u my-secret-api-key: https://retdec.com/service/api/decompiler/decompilations/r8OW7AaAOb/outputs/hll
//
// This file was generated by the Retargetable Decompiler
// Website: https://retdec.com
// Copyright (c) 2017 Retargetable Decompiler <info@retdec.com>
//
#include <stdint.h>
// ------------------- Function Prototypes --------------------
int32_t entry_point(int32_t a1);
int32_t unknown_20ca300(int32_t a1, int32_t a2);
int32_t unknown_212363c(int32_t a1);
int32_t unknown_27a2ad4(int32_t a1, int32_t a2);
// ------------------------ Functions -------------------------
// Address range: 0x0 - 0x1ef
int32_t entry_point(int32_t a1) {
int32_t result = a1; // r26
if (unknown_27a2ad4(a1, 0x27a2ad4) != 0) {
// 0x94
result = -1;
unknown_212363c(0);
unknown_20ca300(0, 0x830000);
// branch -> 0x54
}
// 0x54
return result;
}
// --------------------- Meta-Information ---------------------
// Detected compiler/packer: gcc (gcc-powerpc-elf) (4.5.1 - 4.5.2)
// Detected functions: 1
// Decompiler release: v2.2.1 (2016-09-07)
// Decompilation date: 2017-10-06 22:50:25
以此类推.
这篇关于如何使用可重定向的反编译器cURL API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!