天天看點

有道雲筆記python高亮_有道雲筆記自動簽到

主體步驟

1. 筆記本裝fiddler;獵豹WiFi開熱點;

2. 手機連接配接熱點,WiFi設定代理-手動-主機為192.168.1.1,端口為8888;

3. 手機浏覽器通路fiddler代理ip+端口,如獵豹WiFi是192.168.191.1:8888,安裝fiddler證書到手機;否則app是不給聯網的。

4. 抓app的包。

5. 分析app登入、簽到時都幹了什麼。

更多關于fiddller參考:

http://chessman-126-com.iteye.com/blog/2001501

http://www.cnphp6.com/archives/97865

http://www.cnblogs.com/mfryf/p/5028010.html

具體實施

好,假設你已經做好了準備工作。

(1)第一步,device_open

當有道雲筆記app打開時,app通路device_open,fiddler抓到的包:

注意傳回的delusers數組,删除使用者?怪吓人的。

上圖是POST請求,下圖是伺服器傳回(下同)。

有道雲筆記python高亮_有道雲筆記自動簽到
有道雲筆記python高亮_有道雲筆記自動簽到

(2)第二步,login

如圖,重點是請求時發送的usertoken,這個是app内部産生的。這個token變化的頻率是?

經測試,退出app後再次打開,此token沒有變化。或許是每天變化一次。後面測試。

伺服器傳回的就是set-cookie了。usertoken不變,cookie就不用變。

有道雲筆記python高亮_有道雲筆記自動簽到
有道雲筆記python高亮_有道雲筆記自動簽到

(3)login後的很多請求使用cookie

在這之後app的自動請求已有LOGIN=true的cookie了。

有道雲筆記python高亮_有道雲筆記自動簽到

(4)點選簽到通路伺服器 checkin 方法

點選簽到按鈕,請求checkin method

有道雲筆記python高亮_有道雲筆記自動簽到

傳回簽到是否成功,簽到得到的空間等等。

有道雲筆記python高亮_有道雲筆記自動簽到

2016/05/10 09:50

今天打開筆記簽到,user token 沒變,cookie也沒變。

2016/05/11 13:44

user token 和 cookie 依舊沒變。

由此推論,隻要app運作的環境不改變,發送給server的token不會變,傳回的cookie不會變。

退出賬号後再次登入,user token會改變。僅退出app(登入狀态是保留的),下次打開app自動登入,user token 不改變。

好,下面上代碼。關鍵是main函數中的三個方法,模拟了你打開app-點選簽到按鈕的這個過程。

程式中有的參數需要自己抓包然後放進去。

有道雲筆記python高亮_有道雲筆記自動簽到
有道雲筆記python高亮_有道雲筆記自動簽到

1 importjava.io.BufferedReader;2 importjava.io.IOException;3 importjava.io.InputStreamReader;4 importjava.io.OutputStream;5 importjava.net.HttpURLConnection;6 importjava.net.MalformedURLException;7 importjava.net.URL;8

9

10 importjava.io.PrintWriter;11 importjava.net.URLConnection;12 import java.util.*;13 import java.io.*;14 importjava.util.zip.GZIPInputStream;15 importjava.io.UnsupportedEncodingException;16

17 public classSignin {18 public static String seesion_cookie = null;19

20 public static void main(String[] args) throwsIOException {21

32

33 System.out.println("deviceOpen:" +deviceOpen());34 System.out.println("login:" +login());35 System.out.println("checkIn:" +checkIn());36

37 }38

39 public staticString deviceOpen() {40 String url = "http://note.youdao.com/yws/device_open/poll";41 String arg = "your_arg";42 Map headers = new HashMap();43 headers.put("Content-Length", "481");44 headers.put("Content-Type", "application/x-www-form-urlencoded");45

46 returnsendPost(url, arg, headers);47 }48

49 public staticString login() {50 String url = "http://note.youdao.com/login/acc/co/cq?product=YNOTE&cf=7&userid=.......";51 String arg = null;52 Map headers = new HashMap();53 headers.put("Content-Length", "0");54 headers.put("YNOTE-PC", "v2|urstoken||YNOTE|......");55

56 returnsendPost(url, arg, headers);57 }58

59 public staticString checkIn() {60 String url = "https://note.youdao.com/yws/mapi/user?method=checkin";61 String arg = "your_arg";62 Map headers = new HashMap();63 headers.put("Cookie", "YNOTE_LOGIN=true;" +seesion_cookie);64 headers.put("Content-Length", "481");65 headers.put("Content-Type", "application/x-www-form-urlencoded");66

67 returnsendPost(url, arg, headers);68 }69

70

71

72 public static String sendPost(String url, String param, Mapheaders) {73 PrintWriter out = null;74 BufferedReader in = null;75 StringBuilder result = newStringBuilder();76 try{77 URL realUrl = newURL(url);78

79 HttpURLConnection conn =(HttpURLConnection) realUrl.openConnection();80 conn.setRequestMethod("POST");81

82 conn.setRequestProperty("Accept-Encoding", "gzip");83 conn.setRequestProperty("Accept-Charset", "GBK,utf-8;q=0.7,*;q=0.3");84 for(String key : headers.keySet())85 conn.setRequestProperty(key, headers.get(key));86 conn.setRequestProperty("Host", "note.youdao.com");87 conn.setRequestProperty("Connection", "Keep-Alive");88 conn.setRequestProperty("User-Agent", "ynote-android");89

90 conn.setDoOutput(true);91 conn.setDoInput(true);92

93 out = newPrintWriter(conn.getOutputStream());94 if (param != null) out.print(param);95 out.flush();96 System.out.println(conn.getResponseCode() + " " +conn.getResponseMessage());97

98 for (int i = 1; conn.getHeaderFieldKey(i) != null; ++i) {99 if (conn.getHeaderFieldKey(i).equals("Set-Cookie") &&

100 conn.getHeaderField(i).contains("YNOTE_SESS=v2")) {101 seesion_cookie = conn.getHeaderField(i).split(";")[0];102 System.out.println("seesion_cookie:" +seesion_cookie);103 break;104 }105 }106

107 Reader reader = null;108 if ("gzip".equals(conn.getContentEncoding())) {109 System.out.println("Response body is encoded in gzip.");110 reader = new InputStreamReader(newGZIPInputStream(conn.getInputStream()));111 } else{112 reader = newInputStreamReader(conn.getInputStream());113 }114

115 in = newBufferedReader(reader);116 String line;117 while ((line = in.readLine()) != null) {118 result.append(line);119 }120 } catch(Exception e) {121 System.out.println("sendPost Exception !!! " +e);122 e.printStackTrace();123 }124

125 finally{126 try{127 if (out != null) out.close();128 if (in != null) in.close();129 } catch(IOException ex) {130 ex.printStackTrace();131 }132 }133

134 returnresult.toString();135 }136 }

Java Code

有道雲筆記python高亮_有道雲筆記自動簽到

2016/05/12 00:53

把程式放在伺服器上:

有道雲筆記python高亮_有道雲筆記自動簽到

設定crontab例行任務

有道雲筆記python高亮_有道雲筆記自動簽到

# signin.shcd/home/whuliss/Documents/

date >>signin_log

java SignIn>> signin_log

log:

Fri Jun 3 00:37:01 CST 2016checkIn:{"total":830472192,"time":1464885510110,"space":6291456,"success":1}

Sat Jun4 00:37:01 CST 2016checkIn:{"total":834666496,"time":1464971913651,"space":4194304,"success":1}

Sun Jun5 00:37:02 CST 2016checkIn:{"total":840957952,"time":1465058318146,"space":6291456,"success":1}

Mon Jun6 00:37:01 CST 2016checkIn:{"total":842006528,"time":1465144721286,"space":1048576,"success":1}

Tue Jun7 00:37:01 CST 2016checkIn:{"total":847249408,"time":1465231125472,"space":5242880,"success":1}

Wed Jun8 00:37:01 CST 2016checkIn:{"total":852492288,"time":1465317528907,"space":5242880,"success":1}