/
loginTest.go
182 lines (165 loc) · 12.5 KB
/
loginTest.go
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
package main
/*
Function:
测试www.bugbank.cn自动化登录
Notice:
程序部分地方跟时间戳有关,可能需要根据实际情况调整。
*/
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
"github.com/robertkrimen/otto"
"crypto/md5"
"encoding/hex"
"time"
"strconv"
)
var (
vm = otto.New()
)
const (
encyptFunctions = `
var token;
var b = token;
var a = "qXSdHWfbSZaaLeHBRhLgxBiG" ;
var c = 1;
var d = 1 ;
var e = "O1QPXI01LAf2l0";
var f = 1;
var x_s,x_t,x_w,x_x,x_y,x_z,x_A,
x_b=new Array(0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964),
x_c=new Array(0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697),
x_d=new Array(0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272),
x_e=new Array(0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144),
x_f=new Array(0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256),
x_g=new Array(0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488),
x_h=new Array(0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746),
x_i=new Array(0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568),
x_j=new Array(0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578),
x_k=new Array(0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488),
x_l=new Array(0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800),
x_m=new Array(0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744),
x_n=new Array(0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128),
x_o=new Array(0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261),
x_p=a.length>8?3:1,
x_q=new Array(32*x_p),
x_r=new Array(0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0),
x_u=0,
x_v=0;
for(x_x=0;x_p>x_x;x_x++)
for(x_y=a.charCodeAt(x_u++)<<24|a.charCodeAt(x_u++)<<16|a.charCodeAt(x_u++)<<8|a.charCodeAt(x_u++),x_z=a.charCodeAt(x_u++)<<24|a.charCodeAt(x_u++)<<16|a.charCodeAt(x_u++)<<8|a.charCodeAt(x_u++),x_w=252645135&(x_y>>>4^x_z),x_z^=x_w,x_y^=x_w<<4,x_w=65535&(x_z>>>-16^x_y),x_y^=x_w,x_z^=x_w<<-16,x_w=858993459&(x_y>>>2^x_z),x_z^=x_w,x_y^=x_w<<2,x_w=65535&(x_z>>>-16^x_y),x_y^=x_w,x_z^=x_w<<-16,x_w=1431655765&(x_y>>>1^x_z),x_z^=x_w,x_y^=x_w<<1,x_w=16711935&(x_z>>>8^x_y),x_y^=x_w,x_z^=x_w<<8,x_w=1431655765&(x_y>>>1^x_z),x_z^=x_w,x_y^=x_w<<1,x_w=x_y<<8|240&x_z>>>20,x_y=x_z<<24|16711680&x_z<<8|65280&x_z>>>8|240&x_z>>>24,x_z=x_w,x_A=0;x_A<x_r.length;x_A++)x_r[x_A]?(x_y=x_y<<2|x_y>>>26,x_z=x_z<<2|x_z>>>26):(x_y=x_y<<1|x_y>>>27,x_z=x_z<<1|x_z>>>27),x_y&=-15,x_z&=-15,x_s=x_b[x_y>>>28]|x_c[15&x_y>>>24]|x_d[15&x_y>>>20]|x_e[15&x_y>>>16]|x_f[15&x_y>>>12]|x_g[15&x_y>>>8]|x_h[15&x_y>>>4],x_t=x_i[x_z>>>28]|x_j[15&x_z>>>24]|x_k[15&x_z>>>20]|x_l[15&x_z>>>16]|x_m[15&x_z>>>12]|x_n[15&x_z>>>8]|x_o[15&x_z>>>4],x_w=65535&(x_t>>>16^x_s),x_q[x_v++]=x_s^x_w,x_q[x_v++]=x_t^x_w<<16;
var o=x_q;
var g,h,i,j,k,l,m,n,q,r,s,u,v,w,x,y,p,z,A,B,C,D,E,F,G,H,I,J,K;
for(c&&(b=unescape(encodeURIComponent(b))),
g=new Array(16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756),
h=new Array(-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344),
i=new Array(520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584),
j=new Array(8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928),
k=new Array(256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080),
l=new Array(536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312),
m=new Array(2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154),
n=new Array(268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696),
p=0,
F=b.length,
G=0,
H=32==o.length?3:9,
y=3==H?c?new Array(0,32,2):new Array(30,-2,-2):c?new Array(0,32,2,62,30,-2,64,96,2):new Array(94,62,-2,32,64,2,30,-2,-2),2==f?b+=" ":1==f?c&&(s=8-F%8,b+=String.fromCharCode(s,s,s,s,s,s,s,s),8===s&&(F+=8)):f||(b+="\0\0\0\0\0\0\0\0"),I="",J="",1==d&&(z=e.charCodeAt(p++)<<24|e.charCodeAt(p++)<<16|e.charCodeAt(p++)<<8|e.charCodeAt(p++),B=e.charCodeAt(p++)<<24|e.charCodeAt(p++)<<16|e.charCodeAt(p++)<<8|e.charCodeAt(p++),p=0);F>p;){for(w=b.charCodeAt(p++)<<24|b.charCodeAt(p++)<<16|b.charCodeAt(p++)<<8|b.charCodeAt(p++),x=b.charCodeAt(p++)<<24|b.charCodeAt(p++)<<16|b.charCodeAt(p++)<<8|b.charCodeAt(p++),1==d&&(c?(w^=z,x^=B):(A=z,C=B,z=w,B=x)),s=252645135&(w>>>4^x),x^=s,w^=s<<4,s=65535&(w>>>16^x),x^=s,w^=s<<16,s=858993459&(x>>>2^w),w^=s,x^=s<<2,s=16711935&(x>>>8^w),w^=s,x^=s<<8,s=1431655765&(w>>>1^x),x^=s,w^=s<<1,w=w<<1|w>>>31,x=x<<1|x>>>31,r=0;H>r;r+=3)
{
for(D=y[r+1],E=y[r+2],q=y[r];q!=D;q+=E)u=x^o[q],v=(x>>>4|x<<28)^o[q+1],s=w,w=x,x=s^(h[63&u>>>24]|j[63&u>>>16]|l[63&u>>>8]|n[63&u]|g[63&v>>>24]|i[63&v>>>16]|k[63&v>>>8]|m[63&v]);s=w,w=x,x=s}w=w>>>1|w<<31,x=x>>>1|x<<31,s=1431655765&(w>>>1^x),x^=s,w^=s<<1,s=16711935&(x>>>8^w),w^=s,x^=s<<8,s=858993459&(x>>>2^w),w^=s,x^=s<<2,s=65535&(w>>>16^x),x^=s,w^=s<<16,s=252645135&(w>>>4^x),x^=s,w^=s<<4,1==d&&(c?(z=w,B=x):(w^=A,x^=C)),J+=String.fromCharCode(w>>>24,255&w>>>16,255&w>>>8,255&w,x>>>24,255&x>>>16,255&x>>>8,255&x),G+=8,512==G&&(I+=J,J="",G=0)}
I+=J,I=I.replace(/\0*$/g,""),c||(1===f&&(F=I.length,K=0,F&&(K=I.charCodeAt(F-1)),8>=K&&(I=I.substring(0,F-K))),I=decodeURIComponent(escape(I)));I;
`
)
func getToken(unixTime string) string {
client := &http.Client{}
req, err := http.NewRequest("POST", "http://www.bugbank.cn/api/token", nil)
if err != nil {
// handle error
}
cookieValue := "CNZZDATA1259553499=859115587-1468723984-|" + unixTime
req.Header.Set("x-client-id", "user-web")
req.Header.Set("X-Requested-With","XMLHttpRequest")
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36")
req.Header.Set("Origin", "http://www.bugbank.cn")
req.Header.Set("Referer","http://www.bugbank.cn/signin.html")
req.Header.Set("Cookie", cookieValue)
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
return string(body)[10:41]
}
func login(token string,unixTime string,email string, passwd string) string {
client := &http.Client{}
loginData := "email=" + email + "&password="+ passwd +"&token=" + token
req, err := http.NewRequest("POST", "http://www.bugbank.cn/api/signin", strings.NewReader(loginData))
if err != nil {
// handle error
}
cookieValue := "CNZZDATA1259553499=859115587-1468723984-|" + unixTime
req.Header.Set("x-client-id", "user-web")
req.Header.Set("X-Requested-With","XMLHttpRequest")
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36")
req.Header.Set("Origin", "http://www.bugbank.cn")
req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
req.Header.Set("Referer","http://www.bugbank.cn/signin.html")
req.Header.Set("Cookie", cookieValue)
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
// handle error
}
if resp.Status =="200" {
fmt.Printf("Logined Successfully!\n")
}else{
fmt.Printf("%s \nOops! Failed.\n",resp.Status)
}
return string(body)
}
func getUnixTime() string{
client := &http.Client{}
toUrl := "http://s95.cnzz.com/z_stat.php?id=1259553499&web_id=1259553499&_=" + strconv.FormatInt(time.Now().Unix(),10)
req, err := http.NewRequest("POST", toUrl, nil)
if err != nil {
// handle error
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36")
req.Header.Set("Referer","http://www.bugbank.cn/signin.html")
req.Header.Set("Cookie", "cna=LeEIEAcrgBMCAdOh90HCDPdK")
resp, err := client.Do(req)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return string(body)[94:104]
}
func main() {
fmt.Printf("Login......\n")
unixTime :=getUnixTime()
//*******************token process begin************************
var orignalToken = getToken(unixTime)
//fmt.Printf("%s \n",orignalToken)
vm.Set("token",orignalToken)
token, error := vm.Run(encyptFunctions)
if error !=nil{
//handler error
}
md5_t := md5.New()
s_token,error :=token.ToString();
if error !=nil{
//handler error
}
md5_t.Write([]byte(s_token))
true_token := hex.EncodeToString(md5_t.Sum(nil))
//*******************token process end************************
time.Sleep(1*time.Second)
email := ""//your email
pwd := ""//your password
md5_p := md5.New()
md5_p.Write([]byte(pwd))
passwd := hex.EncodeToString(md5_p.Sum(nil))
result := login(true_token, unixTime,email,passwd)
fmt.Printf("%s\n", result)
}