linux - 如何使用可重定向反编译器 cURL API?

标签 linux windows rest curl

我在 Windows 上,我正在尝试使用 cURL APIRetargetable Decompiler 提供。由于 cURL 是一个 Linux 实用程序,我从 here 下载了一个 Windows 版本。 .假设我要执行以下反编译: 这是使用可以工作并产生结果的浏览器。现在,当尝试从命令行使用 cURL 执行相同操作时,我收到错误。

输出:

>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 示例或文档。

最佳答案

没关系,这很简单。

开始进程:

>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"
    }
}

获取反编译(示例)代码:

>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

等等。

关于linux - 如何使用可重定向反编译器 cURL API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46613636/

相关文章:

api - laravel 4 使用通配符的模式过滤器

python - 在 gdb 中加载 python 支持

linux - 将 C 中的整数传递给进程

linux - python整数的numpy默认dtype

java - Jersey Client可以在多线程环境中使用rest api吗?

api - 如何将 Twitter API 用于超过 REST 速率限制的大型 Web 应用程序

linux - git:在任何客户端推送后自动在服务器上运行 bash 脚本

linux - 如何阻止 Supervisord 从 Node.js 服务器的日志输出中剥离颜色?

mysql - 接收错误: 'Access denied for user ' root' @'localhost' (using password: YES)' when trying to access localhost

c++ - 是否可以从 FILE_FLAG_SEQUENTIAL_SCAN 动态更改为 FILE_FLAG_RANDOM_ACCESS?