Skip to content

Commit c94e234

Browse files
committed
天天基金网-模拟登录成功
1 parent 97cb1a5 commit c94e234

7 files changed

Lines changed: 88 additions & 9 deletions

File tree

1234567.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
请求方式:post
88
请求协议:ajax
99
参数格式:{"CS":"MCUyQzAlMkMxMzgwMDAwMDAwMCUyQzEyMzQ1NiUyQzAlMkMlMkM="}
10-
参数产生:data:JSON.stringify({CS:JsEncrpt.encode(encodeURIComponent(opts.TabID+","+at+","+$.trim(name)+","+escape($.trim(tbpwd.val()))+","+$("#hidenum").val()+","+tbcode.val()+","+direct))}),
10+
参数产生:data:JSON.stringify({CS:JsEncrypt.encode(encodeURIComponent(opts.TabID+","+at+","+$.trim(name)+","+escape($.trim(tbpwd.val()))+","+$("#hidenum").val()+","+tbcode.val()+","+direct))}),
1111
获取表单数据加密方法:https://trade.1234567.com.cn/js/jsencrpt.js
1212
1313
上面可以看出,6个逗号,应该是7个参数
@@ -21,6 +21,14 @@
2121
得到解密后的参数构成如下:
2222
0,0,13800000000,123456,0,,
2323
模拟登录只需要构造成这个结构就可以了
24+
25+
整个模拟登录过程已完善
26+
登录入口:
27+
http://localhost:8000/
28+
响应页面:
29+
http://localhost:8000/login
30+
31+
说明:本次测试仅供学习
2432
"""
2533

2634
import requests
@@ -68,4 +76,7 @@ def form_to_json():
6876
返回结果如下:
6977
{"d":"{\u0027num\u0027:1000,\u0027msg\u0027:\u0027账户密码已连续输错5次,请在30分钟后再尝试登录。\u0027,\u0027risk\u0027:-1}"}
7078
说明ajax请求成功
79+
80+
登录成功返回:
81+
{"d":"{\u0027num\u0027:0,\u0027msg\u0027:\u0027ok\u0027,\u0027risk\u0027:-1,\u0027route\u0027:\u0027https://trade3.1234567.com.cn/\u0027}"}
7182
"""

static/js/jquery/jquery-1.10.2.min.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/js/jquery/jquery.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
(function () {
6-
var tool = window.JsEncrpt || {};
6+
var tool = window.JsEncrypt || {};
77

88
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
99
var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -158,5 +158,5 @@
158158
return result;
159159
};
160160

161-
window.JsEncrpt = tool;
161+
window.JsEncrypt = tool;
162162
})();

template/index.html

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,39 @@
33
<head lang="en">
44
<meta charset="UTF-8">
55
<title>python web</title>
6-
<script type="text/javascript" src="/static/js/jsencrpt.js"></script>
6+
<script type="text/javascript" src="/static/js/jquery/jquery.min.js"></script>
7+
<script type="text/javascript" src="/static/js/jsEncrypt.js"></script>
78
<script type="text/javascript">
8-
window.onload = function () {
9-
var text = JsEncrpt.decode("MCUyQzAlMkMxMzgwMDAwMDAwMCUyQzEyMzQ1NiUyQzAlMkMlMkM=");
10-
var text2 = decodeURIComponent(text);
11-
alert(text2);
12-
}
9+
$(document).ready(function(){
10+
//解密测试
11+
//var text = JsEncrypt.decode("MCUyQzAlMkMxMzgwMDAwMDAwMCUyQzEyMzQ1NiUyQzAlMkMlMkM=");
12+
//var text2 = decodeURIComponent(text);
13+
//弹出明文
14+
//alert(text2);
15+
16+
//加密
17+
$('#encrypt').click(function(){
18+
var text_encrypt = JsEncrypt.encode(encodeURIComponent("0,0,"+$('#username').val()+","+$('#password').val()+",0,,"));
19+
var text_payload = JSON.stringify({'CS':text_encrypt});
20+
$('#payload').val(text_payload);
21+
});
22+
});
23+
1324
</script>
1425
</head>
1526
<body>
1627
Hello Python~~
1728
I will try my best to learn it !
29+
<br/>
30+
<form method="post" action="/login">
31+
账号:<input type="text" id="username">
32+
<br/>
33+
密码:<input type="text" id="password">
34+
<br/>
35+
密参:<input type="text" name="payload" id="payload">
36+
<input type="button" id="encrypt" value="加密">
37+
<div id="err_show"></div>
38+
<button type="submit">登录</button>
39+
</form>
1840
</body>
1941
</html>

template/login.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head lang="en">
4+
<meta charset="UTF-8">
5+
<title></title>
6+
</head>
7+
<body>
8+
{{payload}}
9+
<hr/>
10+
{{content}}
11+
</body>
12+
</html>

web.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@
66
import tornado.web
77
import tornado.ioloop
88
import tornado.options
9+
import requests
10+
import json
911
# from handlers import *
1012

1113
from tornado.options import define, options
1214
define("port", default=8000, help="run on the given port", type=int)
1315

16+
s = requests.session()
17+
18+
# 登录页的url
19+
url = 'https://trade.1234567.com.cn/do.aspx/CheckedCS'
20+
21+
# 配置User-Agent
22+
header = {
23+
'Content-Type': 'application/json; charset=UTF-8', # 因为是ajax请求,格式为json,这个必须指定
24+
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36'
25+
}
26+
1427

1528
class IndexHandler(tornado.web.RequestHandler):
1629
def data_received(self, chunk):
@@ -23,8 +36,22 @@ def post(self):
2336
self.render('index.html')
2437

2538

39+
class LoginHandler(tornado.web.RequestHandler):
40+
def data_received(self, chunk):
41+
pass
42+
43+
def post(self):
44+
payload = self.get_argument("payload", '')
45+
print payload
46+
response = s.post(url, data=payload, headers=header)
47+
content = response.text
48+
print content
49+
return self.render('login.html', payload=payload, content=content)
50+
51+
2652
handlers = [
2753
(r'/', IndexHandler),
54+
(r'/login', LoginHandler),
2855
# (r'/member', memberHandler),
2956
# (r'/chat/(\d+)', chatHandler),
3057
# (r'/register', registerHandler),

0 commit comments

Comments
 (0)