VC設置cookies實現文件刷下載量

 

VC設置cookies實現文件刷下載量

分類: c/c++ 250人閱讀 評論(0) 收藏 舉報

目錄(?)[+]

同學XXX提問:

大家好,我們做的Android應用已經成功在中興匯天地成功上架了,打開“中興匯天地應用商店”http://apps.ztems.com/,搜索欄搜索“睿雲”就能找到了,但是需要你註冊一個應用商店的賬號,完成後就可以下載了,還可以給我們評論。最簡單的刷下載量請直接點擊http://dl5.ztems.com/tmpfile/cst2009/2009001/appSoft/2013/10/9/ruiyun.apk(經測試可以下載,不能增加下載量)
以上兩種方法均可,第一種更好,第二種也可。但是在大家空閒的時候還是推薦第一種。XXX在此謝謝各位的幫助了。

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


類似這樣的app下載網站,是不會驗證IP,更不會驗證MAC,來實現僅僅讓一個客戶端下載一次.(驗證IP,我們可以用代理IP來實現我們的刷下載量的目的)


模擬登錄一下,看看服務器是怎樣處理用戶請求的.

用抓包軟件監測下:


[plain] view plaincopy
  1. POST /storeUserbasicFacade/login.ssm HTTP/1.1  
  2. Host: apps.ztems.com  
  3. Connection: keep-alive  
  4. Content-Length: 72  
  5. Origin: http://apps.ztems.com  
  6. User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36  
  7. Content-Type: text/plain;charset=UTF-8  
  8. Accept: */*  
  9. Referer: http://apps.ztems.com/newLogin.html  
  10. Accept-Encoding: gzip,deflate,sdch  
  11. Accept-Language: zh-CN,zh;q=0.8  
  12. Cookie: JSESSIONID=811B619FA8744978B07238A82F1E6A8B.app42-1; zte_store_view=4028329f417e6dcd01419d5dafa21aa3-1131011170551%2C  
  13.   
  14. [{"email":"******","userPasswd":"****","checkCode":"3367"}]  

http://apps.ztems.com/newLogin.html

/storeUserbasicFacade/login.ssm

這種東西由於水平有限暫時不知道如何去處理,所以就從cookies入手了.

得到了cookies我們就可以非常輕鬆的繞過後臺登錄了.


接下來用VC實現上述操作,利用win api

InternetSetCookie

Syntax

BOOL InternetSetCookie(
  _In_  LPCTSTR lpszUrl,
  _In_  LPCTSTR lpszCookieName,
  _In_  LPCTSTR lpszCookieData
);

Parameters

lpszUrl [in]

Pointer to a null-terminated string that specifies the URL for which the cookie should be set.

lpszCookieName [in]

Pointer to a null-terminated string that specifies the name to be associated with the cookie data. If this parameter is NULL, no name is associated with the cookie.

lpszCookieData [in]

Pointer to the actual data to be associated with the URL.

Return value

Returns TRUE if successful, or FALSE otherwise. To get a specific error message, call GetLastError.

Remarks

Cookies created by InternetSetCookie without an expiration date are stored in memory and are available only in the same process that created them. Cookies that include an expiration date are stored in the windows\cookies directory.

Creating a new cookie might cause a dialog box to appear on the screen asking the user if they want to allow or disallow cookies from this site based on the privacy settings for the user.

Caution  InternetSetCookie will unconditionally create a cookie even if “Block all cookies” is set in Internet Explorer. This behavior can be viewed as a breach of privacy even though such cookies are not subsequently sent back to servers while the “Block all cookies” setting is active. Applications should use InternetSetCookieEx to correctly honor the user's privacy settings.

For more cookie internals, see http://blogs.msdn.com/ieinternals/archive/2009/08/20/WinINET-IE-Cookie-Internals-FAQ.aspx.

Like all other aspects of the WinINet API, this function cannot be safely called from within DllMain or the constructors and destructors of global objects.

Note  WinINet does not support server implementations. In addition, it should not be used from a service. For server implementations or services use Microsoft Windows HTTP Services (WinHTTP).

  1. #include <iostream>  
  2. #include <cstdio>  
  3. #include <afxinet.h>  
  4. using namespace std;  
  5.   
  6. CString getHtml(CString url)  
  7. {  
  8.     CString content;  
  9.     CString data;  
  10.     DWORD dwStatusCode;  
  11.     CInternetSession session(TEXT("HttpClient"));  
  12.   
  13.     CHttpFile* pfile = (CHttpFile *)session.OpenURL(url);  
  14.     pfile->QueryInfoStatusCode(dwStatusCode);  
  15.     if(dwStatusCode == HTTP_STATUS_OK)  
  16.     {   
  17.         while (pfile->ReadString(data))  
  18.         {  
  19.             content += data;  
  20.         }  
  21.     }  
  22.     pfile->Close();  
  23.     delete pfile;  
  24.     session.Close();  
  25.     return content;  
  26. }  
  27.   
  28. int main()  
  29. {  
  30.     CString url = "http://apps.ztems.com/fdpc?appcode=4028329f417e6dcd01419d5dafa21aa3";  
  31.     InternetSetCookie(url, NULL, TEXT("JSESSIONID=811B619FA8744978B07238A82F1E6A8B.app42-1; zte_store_view=;expires=Sat,01-Jan-2014 00:00:00GMT"));  
  32.     getHtml(url);  
  33. }  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章