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

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/uploads/script/vendor/composer/composer/src/Composer/Installer/   drwxr-xr-x
Free 13.28 GB of 57.97 GB (22.92%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


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

/*
 * This file is part of Composer.
 *
 * (c) Nils Adermann <naderman@naderman.de>
 *     Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Composer\Installer;

use 
Composer\IO\IOInterface;
use 
Composer\Package\PackageInterface;
use 
Composer\Util\Filesystem;
use 
Composer\Util\Platform;
use 
Composer\Util\ProcessExecutor;
use 
Composer\Util\Silencer;

/**
 * Utility to handle installation of package "bin"/binaries
 *
 * @author Jordi Boggiano <j.boggiano@seld.be>
 * @author Konstantin Kudryashov <ever.zet@gmail.com>
 * @author Helmut Hummel <info@helhum.io>
 */
class BinaryInstaller
{
    protected 
$binDir;
    protected 
$binCompat;
    protected 
$io;
    protected 
$filesystem;

    
/**
     * @param IOInterface $io
     * @param string      $binDir
     * @param string      $binCompat
     * @param Filesystem  $filesystem
     */
    
public function __construct(IOInterface $io$binDir$binCompatFilesystem $filesystem null)
    {
        
$this->binDir $binDir;
        
$this->binCompat $binCompat;
        
$this->io $io;
        
$this->filesystem $filesystem ?: new Filesystem();
    }

    public function 
installBinaries(PackageInterface $package$installPath$warnOnOverwrite true)
    {
        
$binaries $this->getBinaries($package);
        if (!
$binaries) {
            return;
        }
        foreach (
$binaries as $bin) {
            
$binPath $installPath.'/'.$bin;
            if (!
file_exists($binPath)) {
                
$this->io->writeError('    <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
                continue;
            }

            
// in case a custom installer returned a relative path for the
            // $package, we can now safely turn it into a absolute path (as we
            // already checked the binary's existence). The following helpers
            // will require absolute paths to work properly.
            
$binPath realpath($binPath);

            
$this->initializeBinDir();
            
$link $this->binDir.'/'.basename($bin);
            if (
file_exists($link)) {
                if (
is_link($link)) {
                    
// likely leftover from a previous install, make sure
                    // that the target is still executable in case this
                    // is a fresh install of the vendor.
                    
Silencer::call('chmod'$link0777 & ~umask());
                }
                if (
$warnOnOverwrite) {
                    
$this->io->writeError('    Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
                }
                continue;
            }

            if (
$this->binCompat === "auto") {
                if (
Platform::isWindows()) {
                    
$this->installFullBinaries($binPath$link$bin$package);
                } else {
                    
$this->installSymlinkBinaries($binPath$link);
                }
            } elseif (
$this->binCompat === "full") {
                
$this->installFullBinaries($binPath$link$bin$package);
            }
            
Silencer::call('chmod'$link0777 & ~umask());
        }
    }

    public function 
removeBinaries(PackageInterface $package)
    {
        
$this->initializeBinDir();

        
$binaries $this->getBinaries($package);
        if (!
$binaries) {
            return;
        }
        foreach (
$binaries as $bin) {
            
$link $this->binDir.'/'.basename($bin);
            if (
is_link($link) || file_exists($link)) {
                
$this->filesystem->unlink($link);
            }
            if (
file_exists($link.'.bat')) {
                
$this->filesystem->unlink($link.'.bat');
            }
        }

        
// attempt removing the bin dir in case it is left empty
        
if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
            
Silencer::call('rmdir'$this->binDir);
        }
    }

    public static function 
determineBinaryCaller($bin)
    {
        if (
'.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
            return 
'call';
        }

        
$handle fopen($bin'r');
        
$line fgets($handle);
        
fclose($handle);
        if (
preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m'$line$match)) {
            return 
trim($match[1]);
        }

        return 
'php';
    }

    protected function 
getBinaries(PackageInterface $package)
    {
        return 
$package->getBinaries();
    }

    protected function 
installFullBinaries($binPath$link$binPackageInterface $package)
    {
        
// add unixy support for cygwin and similar environments
        
if ('.bat' !== substr($binPath, -4)) {
            
$this->installUnixyProxyBinaries($binPath$link);
            @
chmod($link0777 & ~umask());
            
$link .= '.bat';
            if (
file_exists($link)) {
                
$this->io->writeError('    Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
            }
        }
        if (!
file_exists($link)) {
            
file_put_contents($link$this->generateWindowsProxyCode($binPath$link));
        }
    }

    protected function 
installSymlinkBinaries($binPath$link)
    {
        if (!
$this->filesystem->relativeSymlink($binPath$link)) {
            
$this->installUnixyProxyBinaries($binPath$link);
        }
    }

    protected function 
installUnixyProxyBinaries($binPath$link)
    {
        
file_put_contents($link$this->generateUnixyProxyCode($binPath$link));
    }

    protected function 
initializeBinDir()
    {
        
$this->filesystem->ensureDirectoryExists($this->binDir);
        
$this->binDir realpath($this->binDir);
    }

    protected function 
generateWindowsProxyCode($bin$link)
    {
        
$binPath $this->filesystem->findShortestPath($link$bin);
        
$caller self::determineBinaryCaller($bin);

        return 
"@ECHO OFF\r\n".
            
"setlocal DISABLEDELAYEDEXPANSION\r\n".
            
"SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
            
"{$caller} \"%BIN_TARGET%\" %*\r\n";
    }

    protected function 
generateUnixyProxyCode($bin$link)
    {
        
$binPath $this->filesystem->findShortestPath($link$bin);

        
$binDir ProcessExecutor::escape(dirname($binPath));
        
$binFile basename($binPath);

        
$binContents file_get_contents($bin);
        
// For php files, we generate a PHP proxy instead of a shell one,
        // which allows calling the proxy with a custom php process
        
if (preg_match('{^(?:#!(?:/usr)?/bin/env php|#!(?:/usr)?/bin/php|<?php)\r?\n}'$binContents$match)) {
            
// verify the file is not a phar file, because those do not support php-proxying
            
if (false === ($pos strpos($binContents'__HALT_COMPILER')) || false === strpos(substr($binContents0$pos), 'Phar::mapPhar')) {
                
$proxyCode trim($match[0]);
                
// carry over the existing shebang if present, otherwise add our own
                
if ($proxyCode === "<?php") {
                    
$proxyCode "#!/usr/bin/env php";
                }
                
$binPathExported var_export($binPathtrue);
                return 
$proxyCode "\n" . <<<PROXY
<?php

/**
 * Proxy PHP file generated by Composer
 *
 * This file includes the referenced bin path (
$binPath) using eval to remove the shebang if present
 *
 * @generated
 */

\$binPath = realpath(__DIR__ . "/" . 
$binPathExported);
\$contents = file_get_contents(\$binPath);
\$contents = preg_replace('{^#!/.+\\r?\\n<\\?(php)?}', '', \$contents, 1, \$replaced);
if (\$replaced) {
    \$contents = strtr(\$contents, array(
        '__FILE__' => var_export(\$binPath, true),
        '__DIR__' => var_export(dirname(\$binPath), true),
    ));

    eval(\$contents);
    exit(0);
}
include \$binPath;

PROXY;
            }
        }

        
$proxyCode = <<<PROXY
#!/usr/bin/env sh

dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd 
$binDir && pwd)

if [ -d /proc/cygdrive ]; then
    case \$(which php) in
        \$(readlink -n /proc/cygdrive)/*)
            # We are in Cygwin using Windows php, so the path must be translated
            dir=\$(cygpath -m "\$dir");
            ;;
    esac
fi

"\${dir}/
$binFile" "\$@"

PROXY;

        return 
$proxyCode;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

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

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