Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <?php // RAY_force_download.php
  2. error_reporting(E_ALL);
  3.  
  4. // A FILE TO DOWNLOAD - THIS LINK COULD COME IN THE URL VIA $_GET, OR COULD BE GENERATED INSIDE THE SCRIPT
  5. $url = "loader.exe";
  6.  
  7. // USE CASE
  8. force_download($url);
  9.  
  10.  
  11. function rand_string( $length ) {
  12.  
  13. $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  14. return substr(str_shuffle($chars),0,$length);
  15.  
  16. }
  17.  
  18.  
  19.  
  20. // FUNCTION TO FORCE A DOWNLOAD FROM A FILE
  21. function force_download($filename)
  22. {
  23. // GET THE CONTENTS OF THE FILE
  24. $filedata = @file_get_contents($filename);
  25.  
  26. if ($filedata)
  27. {
  28. // GET A NAME FOR THE FILE
  29. $basename = basename($filename);
  30.  
  31. $password = rand_string(12);
  32. $wea = "${password}.exe";
  33. // THESE HEADERS ARE USED ON ALL BROWSERS
  34. header("Content-Type: application-x/force-download");
  35. header("Content-Disposition: attachment; filename=\"$wea\"");
  36.  
  37. // THIS HEADER MUST BE OMITTED FOR IE 6+
  38. if (FALSE === strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE '))
  39. {
  40. header("Cache-Control: no-cache, must-revalidate");
  41. }
  42.  
  43. // THIS IS THE LAST HEADER
  44. header("Pragma: no-cache");
  45.  
  46. // FLUSH THE HEADERS TO THE BROWSER
  47. flush();
  48.  
  49. // CAPTURE THE FILE IN THE OUTPUT BUFFERS - WILL BE FLUSHED AT SCRIPT END
  50. ob_start();
  51. echo $filedata;
  52. }
  53.  
  54. // ERROR
  55. else
  56. {
  57. die("ERROR: UNABLE TO OPEN $filename");
  58. }
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement