!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/gwp.picotech.app/public_html/vendor/symfony/http-kernel/Profiler/   drwxr-xr-x
Free 28.46 GB of 117.98 GB (24.13%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     FileProfilerStorage.php (10.27 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\HttpKernel\Profiler;

/**
 * Storage for profiler using files.
 *
 * @author Alexandre Salomé <alexandre.salome@gmail.com>
 */
class FileProfilerStorage implements ProfilerStorageInterface
{
    
/**
     * Folder where profiler data are stored.
     */
    
private string $folder;

    
/**
     * Constructs the file storage using a "dsn-like" path.
     *
     * Example : "file:/path/to/the/storage/folder"
     *
     * @throws \RuntimeException
     */
    
public function __construct(string $dsn)
    {
        if (!
str_starts_with($dsn'file:')) {
            throw new 
\RuntimeException(\sprintf('Please check your configuration. You are trying to use FileStorage with an invalid dsn "%s". The expected format is "file:/path/to/the/storage/folder".'$dsn));
        }
        
$this->folder substr($dsn5);

        if (!
is_dir($this->folder) && false === @mkdir($this->folder0777true) && !is_dir($this->folder)) {
            throw new 
\RuntimeException(\sprintf('Unable to create the storage directory (%s).'$this->folder));
        }
    }

    public function 
find(?string $ip, ?string $url, ?int $limit, ?string $method, ?int $start null, ?int $end null, ?string $statusCode null, ?\Closure $filter null): array
    {
        
$file $this->getIndexFilename();

        if (!
file_exists($file)) {
            return [];
        }

        
$file fopen($file'r');
        
fseek($file0\SEEK_END);

        
$result = [];
        while (
\count($result) < $limit && $line $this->readLineFromFile($file)) {
            
$values str_getcsv($line',''"''\\');

            if (
\count($values)) {
                
// skip invalid lines
                
continue;
            }

            [
$csvToken$csvIp$csvMethod$csvUrl$csvTime$csvParent$csvStatusCode$csvVirtualType] = $values + [=> null];
            
$csvTime = (int) $csvTime;

            
$urlFilter false;
            if (
$url) {
                
$urlFilter str_starts_with($url'!') ? str_contains($csvUrlsubstr($url1)) : !str_contains($csvUrl$url);
            }

            if (
$ip && !str_contains($csvIp$ip) || $urlFilter || $method && !str_contains($csvMethod$method) || $statusCode && !str_contains($csvStatusCode$statusCode)) {
                continue;
            }

            if (
$start && $csvTime $start) {
                continue;
            }

            if (
$end && $csvTime $end) {
                continue;
            }

            
$profile = [
                
'token' => $csvToken,
                
'ip' => $csvIp,
                
'method' => $csvMethod,
                
'url' => $csvUrl,
                
'time' => $csvTime,
                
'parent' => $csvParent,
                
'status_code' => $csvStatusCode,
                
'virtual_type' => $csvVirtualType ?: 'request',
            ];

            if (
$filter && !$filter($profile)) {
                continue;
            }

            
$result[$csvToken] = $profile;
        }

        
fclose($file);

        return 
array_values($result);
    }

    public function 
purge(): void
    
{
        
$flags \FilesystemIterator::SKIP_DOTS;
        
$iterator = new \RecursiveDirectoryIterator($this->folder$flags);
        
$iterator = new \RecursiveIteratorIterator($iterator\RecursiveIteratorIterator::CHILD_FIRST);

        foreach (
$iterator as $file) {
            if (
is_file($file)) {
                
unlink($file);
            } else {
                
rmdir($file);
            }
        }
    }

    public function 
read(string $token): ?Profile
    
{
        return 
$this->doRead($token);
    }

    
/**
     * @throws \RuntimeException
     */
    
public function write(Profile $profile): bool
    
{
        
$file $this->getFilename($profile->getToken());

        
$profileIndexed is_file($file);
        if (!
$profileIndexed) {
            
// Create directory
            
$dir \dirname($file);
            if (!
is_dir($dir) && false === @mkdir($dir0777true) && !is_dir($dir)) {
                throw new 
\RuntimeException(\sprintf('Unable to create the storage directory (%s).'$dir));
            }
        }

        
$profileToken $profile->getToken();
        
// when there are errors in sub-requests, the parent and/or children tokens
        // may equal the profile token, resulting in infinite loops
        
$parentToken $profile->getParentToken() !== $profileToken $profile->getParentToken() : null;
        
$childrenToken array_filter(array_map(fn (Profile $p) => $profileToken !== $p->getToken() ? $p->getToken() : null$profile->getChildren()));

        
// Store profile
        
$data = [
            
'token' => $profileToken,
            
'parent' => $parentToken,
            
'children' => $childrenToken,
            
'data' => $profile->getCollectors(),
            
'ip' => $profile->getIp(),
            
'method' => $profile->getMethod(),
            
'url' => $profile->getUrl(),
            
'time' => $profile->getTime(),
            
'status_code' => $profile->getStatusCode(),
            
'virtual_type' => $profile->getVirtualType() ?? 'request',
        ];

        
$data serialize($data);

        if (
\function_exists('gzencode')) {
            
$data gzencode($data3);
        }

        if (
false === file_put_contents($file$data\LOCK_EX)) {
            return 
false;
        }

        if (!
$profileIndexed) {
            
// Add to index
            
if (false === $file fopen($this->getIndexFilename(), 'a')) {
                return 
false;
            }

            
fputcsv($file, [
                
$profile->getToken(),
                
$profile->getIp(),
                
$profile->getMethod(),
                
$profile->getUrl(),
                
$profile->getTime() ?: time(),
                
$profile->getParentToken(),
                
$profile->getStatusCode(),
                
$profile->getVirtualType() ?? 'request',
            ], 
',''"''\\');
            
fclose($file);

            if (
=== mt_rand(110)) {
                
$this->removeExpiredProfiles();
            }
        }

        return 
true;
    }

    
/**
     * Gets filename to store data, associated to the token.
     */
    
protected function getFilename(string $token): string
    
{
        
// Uses 4 last characters, because first are mostly the same.
        
$folderA substr($token, -22);
        
$folderB substr($token, -42);

        return 
$this->folder.'/'.$folderA.'/'.$folderB.'/'.$token;
    }

    
/**
     * Gets the index filename.
     */
    
protected function getIndexFilename(): string
    
{
        return 
$this->folder.'/index.csv';
    }

    
/**
     * Reads a line in the file, backward.
     *
     * This function automatically skips the empty lines and do not include the line return in result value.
     *
     * @param resource $file The file resource, with the pointer placed at the end of the line to read
     */
    
protected function readLineFromFile($file): mixed
    
{
        
$line '';
        
$position ftell($file);

        if (
=== $position) {
            return 
null;
        }

        while (
true) {
            
$chunkSize min($position1024);
            
$position -= $chunkSize;
            
fseek($file$position);

            if (
=== $chunkSize) {
                
// bof reached
                
break;
            }

            
$buffer fread($file$chunkSize);

            if (
false === ($upTo strrpos($buffer"\n"))) {
                
$line $buffer.$line;
                continue;
            }

            
$position += $upTo;
            
$line substr($buffer$upTo 1).$line;
            
fseek($filemax(0$position), \SEEK_SET);

            if (
'' !== $line) {
                break;
            }
        }

        return 
'' === $line null $line;
    }

    protected function 
createProfileFromData(string $token, array $data, ?Profile $parent null): Profile
    
{
        
$profile = new Profile($token);
        
$profile->setIp($data['ip']);
        
$profile->setMethod($data['method']);
        
$profile->setUrl($data['url']);
        
$profile->setTime($data['time']);
        
$profile->setStatusCode($data['status_code']);
        
$profile->setVirtualType($data['virtual_type'] ?: 'request');
        
$profile->setCollectors($data['data']);

        if (!
$parent && $data['parent']) {
            
$parent $this->read($data['parent']);
        }

        if (
$parent) {
            
$profile->setParent($parent);
        }

        foreach (
$data['children'] as $token) {
            if (
null !== $childProfile $this->doRead($token$profile)) {
                
$profile->addChild($childProfile);
            }
        }

        return 
$profile;
    }

    private function 
doRead($token, ?Profile $profile null): ?Profile
    
{
        if (!
$token || !file_exists($file $this->getFilename($token))) {
            return 
null;
        }

        
$h fopen($file'r');
        
flock($h\LOCK_SH);
        
$data stream_get_contents($h);
        
flock($h\LOCK_UN);
        
fclose($h);

        if (
\function_exists('gzdecode')) {
            
$data = @gzdecode($data) ?: $data;
        }

        if (!
$data unserialize($data)) {
            return 
null;
        }

        return 
$this->createProfileFromData($token$data$profile);
    }

    private function 
removeExpiredProfiles(): void
    
{
        
$minimalProfileTimestamp time() - 86400;
        
$file $this->getIndexFilename();
        
$handle fopen($file'r');

        if (
$offset is_file($file.'.offset') ? (int) file_get_contents($file.'.offset') : 0) {
            
fseek($handle$offset);
        }

        while (
$line fgets($handle)) {
            
$values str_getcsv($line',''"''\\');

            if (
\count($values)) {
                
// skip invalid lines
                
$offset += \strlen($line);
                continue;
            }

            [
$csvToken, , , , $csvTime] = $values;

            if (
$csvTime >= $minimalProfileTimestamp) {
                break;
            }

            @
unlink($this->getFilename($csvToken));
            
$offset += \strlen($line);
        }
        
fclose($handle);

        
file_put_contents($file.'.offset'$offset);
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0052 ]--