!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/alt/php54/usr/share/pear/test/Security/Symfony/Component/Security/Core/Tests/Util/   drwxr-xr-x
Free 293.91 GB of 429.69 GB (68.4%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     SecureRandomTest.php (5.71 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\Security\Core\Tests\Util;

use 
Symfony\Component\Security\Core\Util\SecureRandom;

class 
SecureRandomTest extends \PHPUnit_Framework_TestCase
{
    
/**
     * T1: Monobit test
     *
     * @dataProvider getSecureRandoms
     */
    
public function testMonobit($secureRandom)
    {
        
$nbOnBits substr_count($this->getBitSequence($secureRandom20000), '1');
        
$this->assertTrue($nbOnBits 9654 && $nbOnBits 10346'Monobit test failed, number of turned on bits: '.$nbOnBits);
    }

    
/**
     * T2: Chi-square test with 15 degrees of freedom (chi-Quadrat-Anpassungstest)
     *
     * @dataProvider getSecureRandoms
     */
    
public function testPoker($secureRandom)
    {
        
$b $this->getBitSequence($secureRandom20000);
        
$c = array();
        for (
$i 0$i <= 15$i++) {
            
$c[$i] = 0;
        }

        for (
$j 1$j <= 5000$j++) {
            
$k $j 1;
            
$c[$b[$k 3] + $b[$k 2] + $b[$k 1] + $b[$k]] += 1;
        }

        
$f 0;
        for (
$i 0$i <= 15$i++) {
            
$f += $c[$i] * $c[$i];
        }

        
$Y 16/5000 $f 5000;

        
$this->assertTrue($Y 1.03 && $Y 57.4'Poker test failed, Y = '.$Y);
    }

    
/**
     * Run test
     *
     * @dataProvider getSecureRandoms
     */
    
public function testRun($secureRandom)
    {
        
$b $this->getBitSequence($secureRandom20000);

        
$runs = array();
        for (
$i 1$i <= 6$i++) {
            
$runs[$i] = 0;
        }

        
$addRun = function ($run) use (&$runs) {
            if (
$run 6) {
                
$run 6;
            }

            
$runs[$run] += 1;
        };

        
$currentRun 0;
        
$lastBit null;
        for (
$i 0$i 20000$i++) {
            if (
$lastBit === $b[$i]) {
                
$currentRun += 1;
            } else {
                if (
$currentRun 0) {
                    
$addRun($currentRun);
                }

                
$lastBit $b[$i];
                
$currentRun 0;
            }
        }
        if (
$currentRun 0) {
            
$addRun($currentRun);
        }

        
$this->assertTrue($runs[1] > 2267 && $runs[1] < 2733'Runs of length 1 outside of defined interval: '.$runs[1]);
        
$this->assertTrue($runs[2] > 1079 && $runs[2] < 1421'Runs of length 2 outside of defined interval: '.$runs[2]);
        
$this->assertTrue($runs[3] > 502 && $runs[3] < 748'Runs of length 3 outside of defined interval: '.$runs[3]);
        
$this->assertTrue($runs[4] > 233 && $runs[4] < 402'Runs of length 4 outside of defined interval: '.$runs[4]);
        
$this->assertTrue($runs[5] > 90 && $runs[5] < 223'Runs of length 5 outside of defined interval: '.$runs[5]);
        
$this->assertTrue($runs[6] > 90 && $runs[6] < 233'Runs of length 6 outside of defined interval: '.$runs[6]);
    }

    
/**
     * Long-run test
     *
     * @dataProvider getSecureRandoms
     */
    
public function testLongRun($secureRandom)
    {
        
$b $this->getBitSequence($secureRandom20000);

        
$longestRun $currentRun 0;
        
$lastBit null;
        for (
$i 0$i 20000$i++) {
            if (
$lastBit === $b[$i]) {
                
$currentRun += 1;
            } else {
                if (
$currentRun $longestRun) {
                    
$longestRun $currentRun;
                }
                
$lastBit $b[$i];
                
$currentRun 0;
            }
        }
        if (
$currentRun $longestRun) {
            
$longestRun $currentRun;
        }

        
$this->assertTrue($longestRun 34'Failed longest run test: '.$longestRun);
    }

    
/**
     * Serial Correlation (Autokorrelationstest)
     *
     * @dataProvider getSecureRandoms
     */
    
public function testSerialCorrelation($secureRandom)
    {
        
$shift rand(15000);
        
$b $this->getBitSequence($secureRandom20000);

        
$Z 0;
        for (
$i 0$i 5000$i++) {
            
$Z += $b[$i] === $b[$i $shift] ? 0;
        }

        
$this->assertTrue($Z 2326 && $Z 2674'Failed serial correlation test: '.$Z);
    }

    public function 
getSecureRandoms()
    {
        
$secureRandoms = array();

        
// only add if openssl is indeed present
        
$secureRandom = new SecureRandom();
        if (
$this->hasOpenSsl($secureRandom)) {
            
$secureRandoms[] = array($secureRandom);
        }

        
// no-openssl with custom seed provider
        
$secureRandom = new SecureRandom(sys_get_temp_dir().'/_sf2.seed');
        
$this->disableOpenSsl($secureRandom);
        
$secureRandoms[] = array($secureRandom);

        return 
$secureRandoms;
    }

    protected function 
disableOpenSsl($secureRandom)
    {
        
$ref = new \ReflectionProperty($secureRandom'useOpenSsl');
        
$ref->setAccessible(true);
        
$ref->setValue($secureRandomfalse);
        
$ref->setAccessible(false);
    }

    protected function 
hasOpenSsl($secureRandom)
    {
        
$ref = new \ReflectionProperty($secureRandom'useOpenSsl');
        
$ref->setAccessible(true);

        
$ret $ref->getValue($secureRandom);

        
$ref->setAccessible(false);

        return 
$ret;
    }

    private function 
getBitSequence($secureRandom$length)
    {
        
$bitSequence '';
        for (
$i 0$i $length$i += 40) {
            
$value unpack('H*'$secureRandom->nextBytes(5));
            
$value str_pad(base_convert($value[1], 162), 40'0'STR_PAD_LEFT);
            
$bitSequence .= $value;
        }

        return 
substr($bitSequence0$length);
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

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

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

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.1951 ]--