Jump to content

Root Password qos


ooooyeahbabe

Recommended Posts

The Root Password automatically generated by WHMCS for placing an order is too complicated, which leads to an error when the user creates a VPS of Windows OS,

Quote

Allowed special characters for windows VPS root password are : > ! @ # $ % ^ & * _ - + = ?

and the password needs to be manually changed to pass. How to reduce this password or make it only contain complex special characters at most

Quote

! @ # $ % ^ & * _ - + = ?

So as to meet Windows requirements for passwords

c1.png

Link to comment
Share on other sites

Hello,
Try this:
 

<?php

/**
 * Stronger Password Generator for WHMCS Provisioning v3
 *
 * @package     WHMCS
 * @copyright   Katamaze
 * @link        https://katamaze.com
 * @author      Davide Mantenuto <info@katamaze.com>
 */

use WHMCS\Database\Capsule;

add_hook('OverrideModuleUsernameGeneration', 1, function($vars)
{
    $length['digit']    = '3'; // Number of digits in password
    $length['lower']    = '4'; // Number of UNIQUE lowercase characters in password
    $length['upper']    = '4'; // Number of UNIQUE uppercase characters in password
    $length['special']  = '2'; // Number of special characters in password

    // The same character cannot be used more than once (case sensitive)
    if ($length['lower'] + $length['upper'] == '26')
    {
        $length['lower'] = '13';
        $length['upper'] = '13';
    }

    $digits             = '0123456789';
    $chars              = 'abcdefghijklmnopqrstuvwxyz';
    $special            = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters
    $digits             = substr(str_shuffle($digits), 0, $length['digit']);
    $lower              = substr(str_shuffle($chars), 0, $length['lower']);
    $upper              = substr(str_shuffle(strtoupper(str_replace(str_split($lower), '', $chars) )), 0, $length['lower']);
    $special            = substr(str_shuffle($special), 0, $length['special']);
    $password           = str_shuffle($digits . $lower . $upper . $special);

    Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]);
});

 

Link to comment
Share on other sites

21 hours ago, Trle94 said:

Hello,
Try this:
 


<?php

/**
 * Stronger Password Generator for WHMCS Provisioning v3
 *
 * @package     WHMCS
 * @copyright   Katamaze
 * @link        https://katamaze.com
 * @author      Davide Mantenuto <info@katamaze.com>
 */

use WHMCS\Database\Capsule;

add_hook('OverrideModuleUsernameGeneration', 1, function($vars)
{
    $length['digit']    = '3'; // Number of digits in password
    $length['lower']    = '4'; // Number of UNIQUE lowercase characters in password
    $length['upper']    = '4'; // Number of UNIQUE uppercase characters in password
    $length['special']  = '2'; // Number of special characters in password

    // The same character cannot be used more than once (case sensitive)
    if ($length['lower'] + $length['upper'] == '26')
    {
        $length['lower'] = '13';
        $length['upper'] = '13';
    }

    $digits             = '0123456789';
    $chars              = 'abcdefghijklmnopqrstuvwxyz';
    $special            = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters
    $digits             = substr(str_shuffle($digits), 0, $length['digit']);
    $lower              = substr(str_shuffle($chars), 0, $length['lower']);
    $upper              = substr(str_shuffle(strtoupper(str_replace(str_split($lower), '', $chars) )), 0, $length['lower']);
    $special            = substr(str_shuffle($special), 0, $length['special']);
    $password           = str_shuffle($digits . $lower . $upper . $special);

    Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]);
});

 

This is hook?

Link to comment
Share on other sites

21 hours ago, Trle94 said:

Hello,
Try this:
 


<?php

/**
 * Stronger Password Generator for WHMCS Provisioning v3
 *
 * @package     WHMCS
 * @copyright   Katamaze
 * @link        https://katamaze.com
 * @author      Davide Mantenuto <info@katamaze.com>
 */

use WHMCS\Database\Capsule;

add_hook('OverrideModuleUsernameGeneration', 1, function($vars)
{
    $length['digit']    = '3'; // Number of digits in password
    $length['lower']    = '4'; // Number of UNIQUE lowercase characters in password
    $length['upper']    = '4'; // Number of UNIQUE uppercase characters in password
    $length['special']  = '2'; // Number of special characters in password

    // The same character cannot be used more than once (case sensitive)
    if ($length['lower'] + $length['upper'] == '26')
    {
        $length['lower'] = '13';
        $length['upper'] = '13';
    }

    $digits             = '0123456789';
    $chars              = 'abcdefghijklmnopqrstuvwxyz';
    $special            = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters
    $digits             = substr(str_shuffle($digits), 0, $length['digit']);
    $lower              = substr(str_shuffle($chars), 0, $length['lower']);
    $upper              = substr(str_shuffle(strtoupper(str_replace(str_split($lower), '', $chars) )), 0, $length['lower']);
    $special            = substr(str_shuffle($special), 0, $length['special']);
    $password           = str_shuffle($digits . $lower . $upper . $special);

    Capsule::table('tblhosting')->where('id', $vars['params']['serviceid'])->update(['password' => Encrypt($password)]);
});

 

Sorry , its not working  my version is 8.5.1

Link to comment
Share on other sites

46 minutes ago, Trle94 said:

I believe there is problem with this part of updating db with new details...

I create this in  configureproduct.tpl now its working

 

                                            <script>
                                                function makeid(length) {
                                                    var result = '';
                                                    var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
                                                    var charactersLength = characters.length;
                                                    for (var i = 0; i < length; i++) {
                                                        result += characters.charAt(Math.floor(Math.random() * charactersLength));
                                                    }
                                                    return result;
                                                }
                                                function generatePass(pLength){
                                                    var keyListAlpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
                                                            keyListInt="123456789",
                                                            keyListSpec="!@#$%^&*_-+=?",
                                                            password='';
                                                    var len = Math.ceil(pLength/2);
                                                    len = len - 1;
                                                    var lenSpec = pLength-2*len;
                                                    for (i=0;i<len;i++) {
                                                        password+=keyListAlpha.charAt(Math.floor(Math.random()*keyListAlpha.length));
                                                        password+=keyListInt.charAt(Math.floor(Math.random()*keyListInt.length));
                                                    }
                                                    for (i=0;i<lenSpec;i++)
                                                        password+=keyListSpec.charAt(Math.floor(Math.random()*keyListSpec.length));
                                                    password=password.split('').sort(function(){return 0.5-Math.random()}).join('');
                                                    return password;
                                                }          
                                                $(document).ready(function() {
                                                    $('#inputHostname').val('' + makeid({/literal}{$hostname_interfix}{literal}) + '{/literal}{$hostname_prefix}{$hostname_suffix}{literal}')
                                                });
                                                $(document).ready(function() {
                                                    $('#inputRootpw').val(generatePass(14));
                                                });
                                            </script>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated