本文已参与「新人创造礼」活动, 一同开启创造之路。SHA256逆向实战,论时刻戳验证的重要性。今日更一篇恨的期望不要被拉走蹲号子,本篇教程仅供学习技能探讨运用,如有侵权请联络删除,网站地址。
1.先抓一下包看一下有点什么
这里时刻戳过大从此可见恳求时候是会对timestampHeader字段进行验证的,那么咱们取一次新的参数且在100秒内运用
ok,恳求没啥问题,而且发现这里没有对cookies进行验证,那么只需要处理参数中的signatureHeader以及headers中的x-wif-signature就ok了,还需要留意一点的是timestampHeader字段既然验证了那么因该不只是超时时刻这么简单。
2.好,现在清晰了要处理的问题咱们开端找断点、追寻、逆向那一套。 在lnitiator中可见send咱们点进去断点
3.send这条路走不通咱们先全局索引一下加密参数
这不是SHA-2宗族的SHA256加密算法吗
4.断点开端今日逆向之旅
6.现在两个参数都清晰了开端写代码
老规矩先处理js,如果不习惯用这种方法能够运用python实现上篇文章中介绍了python实现常用的几种加密算法地址
function cc(t) {
const CryptoJS = require('crypto-js');
signatureHeader = CryptoJS.SHA256(t)
.toString(CryptoJS.enc.Hex)
.toUpperCase()
return signatureHeader
};
function aa(t) {
const CryptoJS = require('crypto-js');
zdwwsignature = CryptoJS.SHA256(t)
.toString(CryptoJS.enc.Hex)
.toUpperCase();
return zdwwsignature
};
生成两个加密参数
def get_data():
timestampHeader = int(time.time())
token = '23y0ufFl5YxIyGrI8hWRUZmKkvtSjLQA'
nonce = '123456789abcdefg'
cihui = str(timestampHeader) + token + nonce + str(timestampHeader)
signatureHeader = get_sign(cihui)
cihui = str(timestampHeader) + 'fTN2pfuisxTavbTuYVSsNJHetwq5bJvC' + 'QkjjtiLM2dCratiA' + str(timestampHeader)
signature = get_headersign(cihui)
def get_sign(cihui):
js = open("./getsign.js", "r", encoding="gbk", errors='ignore')
line = js.readline()
htmlstr = ''
while line:
htmlstr = htmlstr + line
line = js.readline()
ctx = execjs.compile(htmlstr)
result = ctx.call('cc', cihui)
return result
def get_headersign(cihui):
js = open("./getsign.js", "r", encoding="gbk", errors='ignore')
line = js.readline()
htmlstr = ''
while line:
htmlstr = htmlstr + line
line = js.readline()
ctx = execjs.compile(htmlstr)
result = ctx.call('aa', cihui)
return result
headers = {
'Accept': 'application/json, text/javascript, */*; q=0.01',
'Accept-Language': 'zh-CN,zh;q=0.9',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Content-Type': 'application/json; charset=UTF-8',
'Origin': 'http://bmfw.www.gov.cn',
'Pragma': 'no-cache',
'Referer': 'http://bmfw.www.gov.cn/ybypmlcx/index.html',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36',
'x-wif-nonce': 'QkjjtiLM2dCratiA',
'x-wif-paasid': 'smt-application',
'x-wif-signature': f'{signature}',
'x-wif-timestamp': f'{timestampHeader}',
}
json_data = {
'appId': 'NcApplication',
'paasHeader': 'zdww',
'nonceHeader': '123456789abcdefg',
'timestampHeader': f'{timestampHeader}',
'signatureHeader': f'{signatureHeader}',
'page': 1,
'page_size': 3000, # 1487+2166+892
'druge_type': '1',
'medifist_type': '',
'medisecond_type': '',
'medicine_name': '',
'key': 'dac066d11092301a2b833aac1048780d',
}
response = requests.post('http://bmfw.www.gov.cn/bjww/interface/interfaceJson', headers=headers,
json=json_data, verify=False)
print(response.json())
print(response)