Jump to content
Sign in to follow this  
ooooyeahbabe

Root Password qos

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

Share this post


Link to post
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)]);
});

 

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
1 minute ago, Trle94 said:

What error do you get? And yes it is an hook.

Nothing , it like din't work .  still have another special string

    $digits             = '0123456789';
    $chars              = 'abcdefghijklmnopqrstuvwxyz';
    $special            = '!@#$%^&*?'; // Plesk does not consider (, ), -, = and + as special characters

Share this post


Link to post
Share on other sites
2 hours ago, ooooyeahbabe said:

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

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

Share this post


Link to post
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>

Share this post


Link to post
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.

Sign in to follow this  

  • 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