Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decai -Q does not provide pdc #100

Open
cryptax opened this issue Dec 12, 2024 · 0 comments
Open

decai -Q does not provide pdc #100

cryptax opened this issue Dec 12, 2024 · 0 comments

Comments

@cryptax
Copy link
Contributor

cryptax commented Dec 12, 2024

I initially asked decai to decompile a given function. The output was not excellent, so I want to ask it to improve using -Q.
It did not improve because it actually sent to the AI: my new prompt + the initial prompt + the initial decompiled output. This decompiled output is missing stuff, so with what it is given, it can't improve. Rather, it should be sent, as in the initial request, the pdc of the function, with my modified prompt.

[0x00002780]> decai -Q the function calls socket and connect. Please adjust your decompiled output.
curl -s https://api.anthropic.com/v1/messages          -H "Content-Type: application/json"          -H "anthropic-version: 2023-06-01"          -H "x-api-key: CENSORED"          -d '{"model":"claude-3-5-sonnet-20241022","max_tokens":5128,"messages":[{"role":"user","content":"Rewrite this function and respond ONLY with code, NO explanations, NO markdown, Change 'goto' into if/else/for/while, Simplify as much as possible, use better variable names, take function arguments and and strings from comments like 'string:', Rewrite this pseudocode into C\nthe function calls socket and connect. Please adjust your decompiled output.:\nint main(int argc, char **argv) {\n    void *ptr;\n    \n    ptr = calloc(argc + 1, 8);\n    if (!ptr) {\n        exit(-1);\n    }\n\n    char **saved_args = (char**)ptr;\n    char **orig_args = argv;\n    char **last_arg = argv + argc;\n\n    while (orig_args < last_arg) {\n        char *arg = strdup(*orig_args);\n        char *orig = *orig_args;\n        *saved_args = arg;\n        \n        size_t len = strlen(orig);\n        memset(orig, 0, len);\n        *orig_args = NULL;\n        \n        orig_args++;\n        saved_args++;\n    }\n\n    argv[0] = \"kdevtmpfs\";\n    prctl(15, \"kdevtmpfs\", 0, 0, 0);\n\n    char *cmd = *((char**)(argv + 1));\n    if (!cmd) {\n        return -1;\n    }\n\n    char *at = strchr(cmd, \"@\");\n    if (!at) {\n        if (strncmp(cmd, \"run\", strlen(\"run\")) != 0) {\n            return -1;\n        }\n        \n        // Run mode handling\n        int pipes[4];\n        pipe2(&pipes[0], 0x800);\n        pipe2(&pipes[2], 0x800);\n        \n        pid_t pid = fork();\n        if (pid < 0) {\n            exit(-1);\n        }\n        \n        if (pid == 0) {\n            // Child process\n            char *exec_args[] = {\"/bin/sh\", \"-c\", NULL};\n            char *env[] = {\"HOME=/proc\",\n                          \"PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin\",\n                          NULL};\n            \n            close(pipes[0]);\n            close(pipes[2]); \n            dup2(pipes[1], 1);\n            dup2(pipes[3], 2);\n            close(pipes[1]);\n            close(pipes[3]);\n            \n            execve(\"/bin/sh\", exec_args, env);\n            exit(-1);\n        }\n        \n        close(pipes[1]);\n        close(pipes[3]);\n        return 0;\n    }\n\n    return 0;\n}"}]}'
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant