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

Software: Apache. PHP/5.6.40 

uname -a: Linux cpanel06wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.80.el6.x86_64 #1 SMP Thu Sep 24
01:42:00 EDT 2020 x86_64
 

uid=851(cp949260) gid=853(cp949260) groups=853(cp949260) 

Safe-mode: OFF (not secure)

/opt/passenger-5.3.7-4.el6.cloudlinux/src/cxx_supportlib/   drwxr-xr-x
Free 235.15 GB of 981.82 GB (23.95%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     RandomGenerator.h (4.91 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
/*
 *  Phusion Passenger - https://www.phusionpassenger.com/
 *  Copyright (c) 2010-2018 Phusion Holding B.V.
 *
 *  "Passenger", "Phusion Passenger" and "Union Station" are registered
 *  trademarks of Phusion Holding B.V.
 *
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 *  of this software and associated documentation files (the "Software"), to deal
 *  in the Software without restriction, including without limitation the rights
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 *  copies of the Software, and to permit persons to whom the Software is
 *  furnished to do so, subject to the following conditions:
 *
 *  The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 *  THE SOFTWARE.
 */
#ifndef _PASSENGER_RANDOM_GENERATOR_H_
#define _PASSENGER_RANDOM_GENERATOR_H_

#include <string>

#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <oxt/system_calls.hpp>

#include <LoggingKit/LoggingKit.h>
#include <StaticString.h>
#include <Exceptions.h>
#include <StrIntTools/StrIntUtils.h>


namespace Passenger {

using namespace std;
using namespace boost;
using namespace oxt;

/**
 * A random data generator. Data is generated using /dev/urandom, and
 * is cryptographically secure. Unlike rand() and friends,
 * RandomGenerator does not require seeding.
 *
 * The reason why RandomGenerator isn't a singleton is because opening
 * /dev/urandom is *very* slow on Mac OS X and OpenBSD. Each object of
 * this class caches the /dev/urandom file handle.
 *
 * This class is thread-safe as long as there are no concurrent
 * calls to reopen() or close().
 */
class RandomGenerator: public boost::noncopyable {
private:
    FILE *handle;

public:
    RandomGenerator(bool open = true) {
        handle = NULL;
        if (open) {
            reopen();
        }
    }

    ~RandomGenerator() {
        boost::this_thread::disable_syscall_interruption dsi;
        close();
    }

    void reopen() {
        close();
        handle = syscalls::fopen("/dev/urandom", "r");
        if (handle == NULL) {
            throw FileSystemException("Cannot open /dev/urandom",
                errno, "/dev/urandom");
        }
        P_LOG_FILE_DESCRIPTOR_OPEN4(fileno(handle), __FILE__, __LINE__,
            "RandomGenerator");
    }

    void close() {
        if (handle != NULL) {
            P_LOG_FILE_DESCRIPTOR_CLOSE(fileno(handle));
            syscalls::fclose(handle);
            handle = NULL;
        }
    }

    StaticString generateBytes(void *buf, unsigned int size) {
        size_t ret = syscalls::fread(buf, 1, size, handle);
        if (ret != size) {
            throw IOException("Cannot read sufficient data from /dev/urandom");
        }
        return StaticString((const char *) buf, size);
    }

    string generateByteString(unsigned int size) {
        string result(size, '\0');
        generateBytes(&result[0], size);
        return result;
    }

    string generateHexString(unsigned int size) {
        string buf(size, '\0');
        generateBytes(&buf[0], size);
        return toHex(buf);
    }

    /**
     * Generates a random string of <em>size</em> bytes which is also
     * valid ASCII. The result consists only of the characters A-Z,
     * a-z and 0-9, and therefore the total number of possibilities
     * given a size of N is 62**N. However not every character has an
     * equal chance of being chosen: a-i have 5/256 chance of being
     * chosen, while other characters have 4/256 chance of being chosen.
     * Therefore, to match the entropy of a random binary string of
     * size N, one should choose a <em>size</em> which yields slightly
     * more possibilities than 2**N.
     */
    string generateAsciiString(unsigned int size) {
        string result(size, '\0');
        generateAsciiString(&result[0], size);
        return result;
    }

    void generateAsciiString(char *_buf, unsigned int size) {
        static const char chars[] = {
            'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
            'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
            'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
            'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
            '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
        };
        unsigned char *buf = (unsigned char *) _buf;
        generateBytes(buf, size);
        for (unsigned int i = 0; i < size; i++) {
            buf[i] = chars[buf[i] % sizeof(chars)];
        }
    }

    int generateInt() {
        int ret;
        generateBytes(&ret, sizeof(ret));
        return ret;
    }

    unsigned int generateUint() {
        return (unsigned int) generateInt();
    }
};

typedef boost::shared_ptr<RandomGenerator> RandomGeneratorPtr;

} // namespace Passenger

#endif /* _PASSENGER_RANDOM_GENERATOR_H_ */

:: 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.3028 ]--