Defacing - Defacing a website means to change its look for anyone who visits the website.
Hackers sometimes deface the website to claim that they had successfully hacked it.
Stored XSS is commonly used for this.
Defacing Elements
Three HTML elements are usually utilized to change the main look of a web page:
- Background Color
document.body.style.background
- Background
document.body.background
- Page Title
document.title
- Page Text
DOM.innerHTML
Change Background
We can choose a certain color or use an image to change the background.
With a color chosen:
With image chose:
Change Page Title
Change Page Text
We can change the text o the specific HTML element/DOM using the innerHTML
function:
We can also utilize jQuery functions to achieve the same if jQuery is already imported:
Hacker group usually leave a message on the web page and leave nothing else on it.
Below will change the entire HTML code from the main body using innerHTML
:
Below is the example defacing payload from Hackthebox:
We should minify it as such: