[Xss-labs] Breakthrough record 10~15

[Xss-labs] Breakthrough record 10~15


[Level10] parameter injection

1. Test process

try:<script>alert(/xss/)</script>

image-20210312215153124

It feels like being encoded by the entity

View the source code of the page:

image-20210312215325303

Sure enough, it is encoded by the html entity, so what should I do? If it is not in the input tag, it cannot constitute an event. .

But look carefully below, there are three strange forms:

image-20210312215603992

So whether the idea can be passed to these forms, causing the event to be triggered

Then construct the payload:

?keyword=ninainaide&t_sort=" οnmοuseοver="alert(/xss/)
image-20210312214743450

View the page source code:

image-20210312215903232

As expected, but the page cannot trigger the event without an input box

At this time, we must modify the front-end code to delete hidden:

image-20210312220038491

An input box appeared:

image-20210312220100724

Move the mouse to the input box, and the window pops up successfully:

image-20210312214312390

2. Source code analysis

<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str11 = $_GET["t_sort"];
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>

From the above code analysis, it is difficult to bypass the html entity encoding of the output point, and the parameter value passed in t_sort is filtered by <>, but the onfocus and onmouseover attributes can be used.


[Level11] http header injection

1. Test process

Initial test:

image-20210312221617745

Source code:

image-20210312221653963

This is similar to the previous level, but with a hidden input box.

Test to see which one can pass the parameter, pass a pass to each input box, and find that only t_sort can pass in.

So test it with the payload of the previous level:

image-20210312222259902

The result is "encoded, it's hard to deal with

image-20210312222142350

I can’t close that. After looking at the source code, it turns out that the secret is in HTTP_REFERER.

Capture the packet directly, add the Referer field, and insert the payload

image-20210312223523815

Check the source code and find that the payload is inserted successfully!

image-20210312223705961

After deleting hidden, click the input box to pop up the window successfully!

image-20210312223746286

2. Source code analysis

<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_SERVER['HTTP_REFERER'];  
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.htmlspecialchars($str00).'" type="hidden">
<input name="t_ref"  value="'.$str33.'" type="hidden">  //将referer字段插入value中
</form>
</center>';
?>

As can be seen from the above code, the backend outputs the HTTP_REFERER field of the http header in the value attribute of the input tag, and only filters <>, which can be bypassed with the onfocus or onmouseover attributes.


[Level12] http header injection

1. Test process

Enter one first<script>alert(/xss/)</script>

image-20210313084902418

As shown in the figure, the output point is encoded by the html entity, but the value of the User-Agent field is output in the value attribute in the input tag below, so the preliminary judgment should be the injection of the http header.

Use burp to capture packets:

image-20210313085249801

As shown in the figure, insert the payload in the User-Agent field.

image-20210313085400331

Check the source code after putting the package, the payload is inserted successfully.

image-20210313085519505

As usual, delete the hidden value and click the input box:

image-20210313085617267

2. Source code analysis

Compared with the previous level, there is no big change, just replace the HTTP_REFERER field of the injection point with the HTTP_USER_AGENT field.


[Level13] cookie injection

1. Test process

Enter one first<script>alert(/xss/)</script>

image-20210313091429449

It is found that the output point is also encoded, but the value value in the input tag below is a bit strange.

Use burp to capture the packet and have a look:

image-20210313091618890

It turns out that the user field in the cookie seems to be url-encoded.

Then construct the payload:" onfocus="alert(/xss/)

Then url encoding is:%22%20onfocus%3D%22alert%28%2fxss%2f%29

Directly replace the cookie field value:

image-20210313091911066

Check the source code after putting the package:

image-20210313092001874

Found that the payload was inserted successfully.

As usual, delete the hidden value and click the input box:

image-20210313092057043

image-20210313092144781

success!

2. Source code analysis

<?php 
setcookie("user", "call me maybe?", time()+3600);
ini_set("display_errors", 0);   //设置错误信息不会被记录
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_COOKIE["user"];  
$str22=str_replace(">","",$str11);
$str33=str_replace("<","",$str22);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form id=search>
<input name="t_link"  value="'.'" type="hidden">
<input name="t_history"  value="'.'" type="hidden">
<input name="t_sort"  value="'.htmlspecialchars($str00).'" type="hidden">
<input name="t_cook"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>

From the source code, we can see that this level is similar to the previous level, except that it is replaced by cookie injection.


[Level14] exif parsing injection

1. Test process

After reaching the fourteenth level, I jumped directly, and the page cannot be opened as a result, then there is nothing wrong. . .

image-20210313104300239

2. Source code analysis

Key code, a webpage is redirected, but it can’t be opened

<iframe name="leftframe" marginwidth=10 marginheight=10 src="http://www.exifviewer.org/" frameborder=no width="80%" scrolling="no" height=80%></iframe>

This level cannot be done, but I am not reconciled and I am ready to reproduce it myself.

Knowledge supplement:

  • What is exif:

    Exchangeable image file format (English: Exchangeable image file format, the official abbreviation Exif ) is specially set for photos of digital cameras , and can record the attribute information and shooting data of digital photos. You can use the right mouse button to enter the property page to view part of the information.

    image-20210313121042413
  • exif xss vulnerability principle

    Some websites have the function of reading image exif information. When the website reads malicious exif information, this payload will be triggered.

In order to reproduce this vulnerability, I installed the exif viewer plug-in on my Chrome browser.

image-20210313121321536

I downloaded this plug-in from the chrome app store, and friends in need can send me a private message.

Next, make a picture with xss code:

Right-click the attribute directly and modify the value inside

image-20210313121518845

Upload the picture to your VPS after modification, and use chrome to access:

image-20210313120023710

As shown in the figure, the recurrence is successful!


【level15】

1. Test process

Enter one first: <scirpt>alert(/xss/)</script>test it

image-20210313150956850

The output point is very strange. After ng-include, I checked relevant information on the Internet and said that ng-include can load local related files.

Use the files of the first level as a springboard

payload:

level15.php?src='level1.php?name=<svg onload=alert(/xss/)>'

I tried other tags, img and a tags can be used, but the <script>tags do not work, very strange.

image-20210313142221477

2. Source code analysis

<html ng-app>
<head>
        <meta charset="utf-8">
        <script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
<script>
window.alert = function()  
{
    
         
confirm("完成的不错!");
 window.location.href="level16.php?keyword=test"; 
}
</script>
<title>欢迎来到level15</title>
</head>
<h1 align=center>欢迎来到第15关,自己想个办法走出去吧!</h1>
<p align=center><img src=level15.png></p>
<?php 
ini_set("display_errors", 0);
$str = $_GET["src"];
echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>';
?>

Guess you like

Origin blog.csdn.net/qq_43665434/article/details/114749570