Skip to content

Instantly share code, notes, and snippets.

@mdunham
Last active June 11, 2017 10:48
Show Gist options
  • Save mdunham/1c2d1d25b2703927d9d5955ec65279c2 to your computer and use it in GitHub Desktop.
Save mdunham/1c2d1d25b2703927d9d5955ec65279c2 to your computer and use it in GitHub Desktop.
Mass change all cpanel and user passwords in WHM
/**
* Utility for updating all domain and user cpanel passwords
*
* To use it login to your WHM and click on "Account Functions" then click on "Password Modification"
* Now copy all of the code below and paste it into your browsers dev tools console
* DO NOT FORGET before you run the code make sure you change the variable newPass on line 14 to what
* you want all the new passwords to be now just press enter and let it do its magic
*
* @author Matthew Dunham <matt@matthewdunham.net>
*/
(function (mainFrame, Commander, Storage) {
var
newPass = '', // The password must score at least 50 in strength
curIndex = null === Storage.getItem('inde') ? -1 : Storage.getItem('inde'),
maxAccts = mainFrame.querySelector('#domainselectEl').options.length,
changeNext = function () {
mainFrame = window.frames['mainFrame'].document;
Commander = window.frames['commander'].document;
if (curIndex < maxAccts) {
if (null === mainFrame.querySelector('form[name="fmain"]')) {
setTimeout(function () {
Commander.querySelector('a#account_functions_password_modification').click();
}, 2000);
setTimeout(changeNext, 6050);
return;
}
curIndex++;
Storage.setItem('inde', curIndex);
mainFrame.querySelector('form[name="fmain"]').setAttribute('target', 'mainFrame');
mainFrame.querySelector('#domainselectEl').selectedIndex = curIndex;
mainFrame.querySelector('#domainselectEl').dispatchEvent(new Event('change'));
mainFrame.querySelector('#password').value = newPass;
mainFrame.querySelector('#password2').value = newPass;
mainFrame.querySelector('#password').dispatchEvent(new Event('input'));
setTimeout(function () {
mainFrame.querySelector('form[name="fmain"]').submit();
}, 200);
setTimeout(function () {
Commander.querySelector('a#account_functions_password_modification').click();
}, 2000);
setTimeout(changeNext, 5750);
}
};
changeNext();
})(window.frames['mainFrame'].document, window.frames['commander'].document, window.sessionStorage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment