意识到了自己其实还挺菜的,比赛的三小时一个没做出来
这个笔记真的安全吗?
昨天比赛的时候没做出来,后面结束后群里大佬提示是最近挺火的一个next.js的漏洞,就是哪个评分10分的哪个

那我们找个exp用一下看看

成功执行啊,那后面找找flag文件,后面也可以手动复现一下这个漏洞,挺有学习价值的
但是不知道为什么,这个脚本执行ls命令返回500,然后就换了一个工具

然后拿到flag

工具在这:https://github.com/Rsatan/Next.js-Exploit-Tool/releases/tag/v1.3.0
secure file viewer
这个题是一个文件包含的题,比赛的时候试了挺久没做出啦,后面群里大佬提示有bak文件,然后现在重新做一次

得到源码

直接问Gemini


最后成功拿到,以后扫路径还是要多加点条件

源自于真实
初步看起来应该是爆破

那hydra爆破一下admin试试

先等着爆破admin,我们试试题目给的初试用户
发现有验证码

抓包发现可以更改verify用户

然后现在爆破看看
发现全部失败,换回sectest看看

但是很奇怪,我后面又爆破了一遍admin,又出来了

我不知道是不是我一开始请求了一下verify还是上次我没看到成功的爆破

成功拿下

东西很老,能用就好
打开是一个很老的wordpress站点

搜了一下发现有漏洞

wpscan扫出来也是这些漏洞

但是试了exploit-db的脚本,发现不太好使,然后换sqlmap扫

一个个试,然后找到一个权限高的,改模板页面

然后成功读到

综合挑战
进去是一个sql注入测试页面

sqlmap没扫出来,看看有没有其他文件

试了一下test可以读文件,add可以上传图片

但是不知道文件去哪了

那试试能不能读网页文件

可以读,那我们把这些文件都读了看看
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| <?php ob_start(); session_start();
include('c.php'); include('head.php'); if(@$_SESSION['logged']!=true) { $_SESSION['logged']='';
}
if($_SESSION['logged']==true && $_SESSION['admin']!='') {
echo "you are logged in :)"; header('Location: panel.php', true, 302); } else { echo '<div align=center style="margin:30px 0px 0px 0px;"> <font size=8 face="comic sans ms">--==[[ Lab ]]==--</font> <br><br> Show me your SQLI skills <br> <form method=post> Username :- <Input type=text name=un>   Password:- <input type=password name=ps> <br><br> <input type=submit name=login value="let\'s login">'; } if(isset($_POST['login'])) { $uname=str_replace('\'','',urldecode($_POST['un'])); $pass=str_replace('\'','',urldecode($_POST['ps'])); $run='select * from auth where pass=\''.$pass.'\' and uname=\''.$uname.'\''; $result = mysqli_query($conn, $run); if (mysqli_num_rows($result) > 0) {
$row = mysqli_fetch_assoc($result); echo "You are allowed<br>"; $_SESSION['logged']=true; $_SESSION['admin']=$row['username'];
header('Location: panel.php', true, 302);
} else { echo "<script>alert('Try again');</script>"; }
} echo "<font size=5 face=\"comic sans ms\" style=\"left: 0;bottom: 0; position: absolute;margin: 0px 0px 5px;\">B0X Powered By <font color=#ff9933>Pirates</font> ";
?>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| <?php
function file_download($download) { if(file_exists($download)) { header("Content-Description: File Transfer"); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Accept-Ranges: bytes'); header('Content-Disposition: attachment; filename="'.basename($download).'"'); header('Content-Length: ' . filesize($download)); header('Content-Type: application/octet-stream'); ob_clean(); flush(); readfile ($download); } else { echo "file not found"; } }
if(isset($_POST['file'])) { file_download($_POST['file']); } else{
echo '\'file\' parameter is empty. Please provide file path in \'file\' parameter '; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| <?php echo ' <html> <head> </script> <title>--==[[Lab]]==--</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <STYLE> body { font-family: Tahoma; color: black; } .side-pan { margin: 0; border:0px;
width:200px; padding: 5px 23px; margin:0px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 0px; border-bottom: 1px solid black; color: white; font-size: 20px; font-family: Georgia, serif; text-decoration: none; vertical-align: left; align:left; } div#left { width: 100%; height: 50px; float: left; } div#right { margin-left: 20%; height: 50px; color: white; font-size: 20px; font-family: Georgia, serif; } .main div { float: left; clear: none; } submit { BORDER: buttonhighlight 2px outset; BACKGROUND-COLOR: Black; width: 30%; color: #FFF; } #t input[type=\'submit\']{ COLOR: White; border:none; BACKGROUND-COLOR: black; } #t input[type=\'submit\']:hover {
BACKGROUND-COLOR: #ff9933; color: black;
} tr { BORDER: dashed 1px #333; color: #000; } td { BORDER: dashed 0px ; } .table1 { BORDER: 0px Black; BACKGROUND-COLOR: Black; color: #FFF; } .td1 { BORDER: 0px; BORDER-COLOR: #333333; font: 7pt Verdana; color: Green; } .tr1 { BORDER: 0px; BORDER-COLOR: #333333; color: #FFF; } table { BORDER: dashed 2px #333; BORDER-COLOR: #333333; BACKGROUND-COLOR: #191919;; color: #FFF; } textarea { border : dashed 2px #333; BACKGROUND-COLOR: Black; font: Fixedsys bold; color: #999; } A:link { border: 1px; COLOR: red; TEXT-DECORATION: none } A:visited { COLOR: red; TEXT-DECORATION: none } A:hover { color: White; TEXT-DECORATION: none } A:active { color: white; TEXT-DECORATION: none }
.download { margin: 0; border:0px; background:#C0C0C0; width:110px; height:30px;
margin:0px; -webkit-border-radius: 0px; -moz-border-radius: 0px; border-radius: 6px; border-bottom: 1px solid black; color: #28597a; font-size: 20px; font-family: Georgia, serif; text-decoration: none; vertical-align: left; align:left; }
</STYLE> <script type="text/javascript"> <!-- function lhook(id) { var e = document.getElementById(id); if(e.style.display == \'block\') e.style.display = \'none\'; else e.style.display = \'block\'; } //--> </script> ';
?>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <?php #header( 'Z-Powered-By:its chutiyapa xD' ); header('X-Frame-Options: SAMEORIGIN'); header( 'Server:testing only' ); header( 'X-Powered-By:testing only' );
ini_set( 'session.cookie_httponly', 1 );
$conn = mysqli_connect("localhost","ica","fEjGCK7bDHdiXocN","ica_lab");
// Check connection if (mysqli_connect_errno()) { echo "connection failed -> " . mysqli_connect_error(); }
?>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?php include('c.php');
if(isset($_POST['continue'])) { $run='select * from users '; $result = mysqli_query($conn, $run); if (mysqli_num_rows($result) > 0) { echo "<table width=90% ><tr><td>ID</td><td>User</td><td>Address</td><td>Image</td></tr>"; while($row = mysqli_fetch_assoc($result)) { echo '<tr><td>'.$row['id'].'</td><td>'.htmlspecialchars ($row['name'],ENT_COMPAT).'</td><td>'.htmlspecialchars ($row['address'],ENT_COMPAT).'</td><td><img src="uploaded_images/'.htmlspecialchars ($row['image'],ENT_COMPAT).'" height=90px width=100px></td></tr>'; } echo "</table>"; } }
?>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?php
echo '<form method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name=image> <input type=text name=name value="name"> <input type=text name=address value="address"> <input type=text name=id value=1337 > <input type="submit" value="upload" name="upload"> </form>';
?>
|
然后ai分析一波

panel.php内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| <?php ob_start(); session_start();
include('c.php'); include('head2.php'); if(@$_SESSION['logged']!=true ) { header('Location: index.php', true, 302); exit();
}
echo "Welcome to Lab "; echo '<form method=post style="margin: 10px 0px 10px 95%;"><input type=submit name=lg value=Logout></form>'; if(isset($_POST['lg'])) { unset($_SESSION['logged']); unset($_SESSION['admin']); header('Location: index.php', true, 302); } echo '<hr><br>';
echo '<form method=post>
<select name=load> <option value="show">Show Users</option> <option value="add">Add User</option> </select>
 <input type=submit name=continue value="continue"></form><br><br>'; if(isset($_POST['continue'])) { $dir=getcwd(); $choice=str_replace('./','',$_POST['load']);
if($choice==='add') { include($dir.'/'.$choice.'.php'); die(); }
if($choice==='show') {
include($dir.'/'.$choice.'.php'); die(); } else { include($dir.'/'.$_POST['load']); }
}
if(isset($_POST['upload'])) {
$name=mysqli_real_escape_string($conn,$_POST['name']); $address=mysqli_real_escape_string($conn,$_POST['address']); $id=mysqli_real_escape_string($conn,$_POST['id']);
if(!empty($_FILES['image']['name'])) { $iname=mysqli_real_escape_string($conn,$_FILES['image']['name']); $r=pathinfo($_FILES['image']['name'],PATHINFO_EXTENSION); $image=array('jpeg','jpg','gif','png'); if(in_array($r,$image)) { $finfo = @new finfo(FILEINFO_MIME); $filetype = @$finfo->file($_FILES['image']['tmp_name']); if(preg_match('/image\/jpeg/',$filetype ) || preg_match('/image\/png/',$filetype ) || preg_match('/image\/gif/',$filetype )) { if (move_uploaded_file($_FILES['image']['tmp_name'], 'uploaded_images/'.$_FILES['image']['name'])) { echo "Uploaded successfully "; $update='insert into users(name,address,image,id) values(\''.$name.'\',\''.$address.'\',\''.$iname.'\', \''.$id.'\')'; mysqli_query($conn, $update);
} } else { echo "<br>i told you dear, only png,jpg and gif file are allowed"; } } else { echo "<br>only png,jpg and gif file are allowed";
} }
}
?>
|
然后得到渗透路径

上传图片马

然后在panel通过show读取图片马路径

接下来就是读取flag

成功读取

内部监控暴露
打开是一个等待页面,我们直接扫目录

systemchart.php是一个get登录验证。info是phpinfo页面,blocks和chart用admin/admin进去后就是404,文件不存在

又扫了一遍,发现了一些新东西

打开发现是mantis,然后直接用mantis的历史漏洞去试

但是不知道是不出网还是我的云服务器在国外连不上,只能手动去复现,但是这个漏洞确实是成功了的,因为可以用重置后的password登录进去,没办法反弹,那我们就写一个webshell

没办法直接读,得提权

用蚁剑手动反弹一个shell,然后上传linpeas.sh,执行,原来之前反弹不成功是没有bash,用nc才成功,linpeas.sh也没发现什么有用的内容,后面看了别人的wp是通过计划任务反弹,然后有一个root的小文件,但是任何人都可以更改

往其中插入反弹shell的语句即可

挺奇怪的,不知道是不是我的shell问题还是怎么,linpeas应该是可以把这种文件找出来的,但是并没有找到
别人wp:Vulnhub打靶记录:tre_1 - C_CHL - 博客园