Technical implementation of online voting cheating (pure technical exchange, do not use it as you !!)

zhaozj2021-02-08  222

Affirming: Pure technical exchange, do not use it! ! The scope of the technical application discussed in the article is still a wide range, in addition to voting this comparative application, you can also complete, such as automatic fill in the form, email automatic application, website registration. There are two methods provided here: Method 1: Realize the COM interface provided by the IE control. This approach is to edit web forms (sometimes modify web code) through the IHTMLDocument2 interface, and then trigger an event submitting web page. This approach is used to download a lot of data-independent data, such as a picture, etc., such as a picture, etc. (of course you can turn off the options in IE), the efficiency is very low, and each vote I have to open an IE control, if your machine is different, wait to press RESET ~~. In addition, this method is more encoded and is very annoying. Method 2: The work submitted by the Wininet API is implemented. This approach is much better than the previous method, not only high efficiency, less resource, but also simpler than the previous one. The following will introduce two methods: Method 1: Implement 1 through the COM interface provided by IE control 1, my program is based on dialog, not HTMLVIEW, so put a IE control on the dialog (Insert ActiveX Control, there is a Microsoft Web browser that gives this IE control, such as M_CtrLweb. Also, please add the header file, IE COM interface is put in it. and should add it if not. 2. Join the DownloadWizard to join the DownloadComplete event, so that the web download you can do the work. Of course, you can also do this in the events such as ProgressChange, but you have to judge the web page is not almost downloaded to the right position, you want to save trouble, and use Downloadcomplete directly. 3, the next step is to open the target web page with this control, when do you open your own, I opened it in InitDialog, the code is as follows: Colevariant Vaurl = "http://www.onlytest.net"; m_ctrlweb. Navigate2 (& Vaurl, & VtMissing, & VTMissing, & VTMissing, & VTMissing); where VTMissing is used as the default parameters. 4, then it is the main operation. These operations are placed in OndownloadCompleteExplorer. For the convenience, I wrote several functions to complete specific features, explain these functions before the specific instructions for the operations in OndownloadCompleteExplorer.

// Function: Decision web pages do not have a strname specified element // parameter: POBJALLELEMENT: Collection of all elements in the web page // strname: Id or Name Bool Hasitem (IhtmlelementCollection * Pobjallelelement, CString Strname) {CComptrin Idispatch> PDISP; POBJALLELEMENT-> Item (Colevariant (Strname), Colevariant ((long) 0), & PDISP); if (PDISP == NULL) Return False; Else Return True;} // Features: In the text box of the web page Enter strings // parameter: POBJALLELEMENT: Collection of all elements in the web page // strname: Id or name // strtext to edit text box: IHTMLELEMENTCOLLECTION * Pobjallelelement, CString Strname , CString strText) {CComPtr pDisp; pobjAllElement-> item (COleVariant (strName), COleVariant ((long) 0), & pDisp); CComQIPtr pElement; if (pDisp == NULL) {AfxMessageBox (strName "not found!") } Else {Pelement-> put_value (strtext.allocsystring ());}} // function: Submit a web // parameter: POBJALLELEMENT: Collection of all elements in the web page // strName: You can submit the FORM button id or name (may be directly Form to submit submitted) void SubmitPage (IHTMLElementCollection * pobjAllElement, CString strName) {CComPtrpDisp; pobjAllElement-> item (COleVariant (strName), COleVariant ((long) 0), & pDisp); CComQIPtrpElement; if ( PDISP ==

NULL) {AFXMessageBox (Strname "No!");} Else {pelement = pdisp; pelement-> click ();}} // function: Select a checkbox in the web page (in fact, click) // Parameters: Pobjallelement : // strName page collection of all the elements: the selected CheckBox to the id or name void CheckItem (IHTMLElementCollection * pobjAllElement, CString strName) {CComPtr pDisp; pobjAllElement-> item (COleVariant (strName), COleVariant ((long) 0) , & pdisp); ccomqiptr pelement; if (pdisp == null) {afxMessageBox (Strname "did not find!");} else {pelement = pdisp; pelement-> click ();}} use these A function can easily complete the voting operation. The code in the OndownloadCompleteExplorer is listed below.

Also assume that the voting page is http://www.onlytest.com/vote.htm, the data is submitted to http://www.onlytest.com /vote2.aspvoid cvotedlg :: OndownloadcompleteExplorer () {// Todo: Add Your Control NOTIFICATION handler code here IHTMLElementCollection * objAllElement = NULL; IHTMLDocument2 * objDocument = NULL; CString strUrl, strTemp; strUrl = m_ctrlWeb.GetLocationURL (); // get URL if the current page (strUrl.IsEmpty ()) return; objDocument = (IHTMLDocument2 * M_ctrlweb.getdocument (); // Get the IHTMLDocument2 interface pointer ObjDocument-> get_all (& objallelement); // Get a collection of all elements of the page // Since all pages are running, this function is executed, so you must decide the message according to the URL Source web IF (strurl == "http://www.onlytest.com/vote.htm") {ccomptr PDISP; if (HasiteM (ObjalleElement, "voteform") == true) // voteform is a voting option Form {Objallelement-> Item (Colevariant ("voteform"), Colevariant ((long) 0), & PDISP); ccomqiptr pelement; if (pdisp == null) {// interface pointer acquisition failed, End the procedure, no additional processing, after the reason, Enddi Alog (IDOK); Return;} else {// If the voting result is open in a new window, you should modify the web code, let the result display pelement = pdisp in this control; pelement-> put_target (ccombstr ("_ self")); / / Isometrically equivalent target = "_ self" pelement-> put_action (ccombstr ("vote2.asp")); // is equivalent to action = "vote2.asp"} CheckItem (ObjalleleMent, "CHK2"); // The ID in the form is ChK2 Checkbox selection SubmitPage (ObjalleleMent, "Vote"); / / Submit the web page, vote is the ID or name}} else if (Strurl == "of the Submit button

http://www.onlytest.com/vote2.asp ") {enddialog (idok); // If the voting handle page has been downloaded, the program is ended, the reason is seen.}} The ticket is already thrown out, but see The process sequence you may be strange, why do you have an error to end the program with an endDialog in the middle, not to continue to vote? Things are like this, some websites can only vote, and an IE control is created, After connecting to the server (with sessions), the session key is set (a family), so if you continue to vote with this IE control, the server will tell you that you have already voted (of course, if the stupid written by the voting program, no management This, then it is much simpler). This problem I want to deal with the running process of Wininet API, but it seems to be very trouble, so I use a very stupid but simple way: voting the program as a program, then another The program calls this voting program. After the ticket is completed, the main program runs the voter again, so repeatedly. As for something such as the number of voters, the shared memory segment is the easiest (a family saying), not Here, this method is discussed here. Method 2: This method is very small through the Wininet API to implement a form, and it does not need to download too much useless data (such as pictures, etc.), and because you don't need to download too much useless data (such as pictures, etc.). Therefore, the efficiency is much higher, and the code is implemented is a function. It is very suitable for use in the thread. The key to use this method is to know what data should be submitted to the server if you go to the web file, and then analyze what should be submitted to the server? Data, the web page is very simple, if the web is very complicated, then it is a matter of labor. Now it is not a test. We will not do it. Now there is a simpler method, which is the network under Win2000. Monitor, manual investment, see what data is submitted to the server. In this way, we can put the data in the data belonging to the HTTP protocol. Data directly from the monitor is not used, because monitoring The part of the display text is replaced by a variety of characters such as the cycle. These parts must be changed back to the original carriage return, the wrap (the http header can do not need to manage, as long as you can distinguish the border. Also note that in submission information may have information information, if you have modified the contents of the submitted data, and the data length changes, the value of the Content-Length item must be changed. For example, Content-Length is originally The value is 100, there is a data "1" in the data, and now it is changed to "12", then content-leng TH must be changed to 101, otherwise the server will return an error.

The following is the voting function: uint vote (lpvoid) {cinternetSession session; theapp.m_nthreads ; // Used to record the Try {ChttpConnection * PConnection = session.gethttpConnection ("www.onlytest.net"); / / Website Server Chttpfile * Pfile = PConnection-> OpenRequest (chttpConnection :: http_verb_post, "vote2.asp"); // Directly submit data directly to the voting processing page Add a HTTP header to the submission data, which can be Get pfile-> addrequestheaders ("accept: image / gif, image / x-xbitmap, image / jpeg, image / pjpeg, application / vnd.ms-powerpoint, application / vnd.ms-excel, application / msword, * / * "); Pfile-> addRequestHeaders (" refere: http://www.onlytest.net/vote.htm "); Pfile-> AddRequestHeaders (" Accept-language: zh-cn "); Pfile-> AddRequestHeaders (" Content -Type: Multipart / Form-Data; Boundary = -------------------------- 7D11DC24268052C "); Pfile-> AddRequestHeaders (" accept- Encoding: gzip, deflate "); Pfile-> AddRequestHeaders (" User-agent: mozilla / 4.0 (compatible; msie 5.01; windows nt 5.0) "); Pfile-> AddRequestHeaders (" Content-le NGTH: 1351 "); Pfile-> AddRequestHeaders (" Connection: Keep-alive "); Pfile-> AddRequestHeaders (" cache-control: no-cache "); // The HTTP head should be true data, below TheApp.m_strformData is the data to be submitted, the server processes the information returned in Pfile-> SendRequest (Null, 0, THEAPP.M_STRFORMDATA.GETBUFFER (0), THEAPP.M_STRFORMDATA.GETLENGTH ()); // Submit all data // In fact, the voting here is already over, but if you want to see the results, you can analyze the return page, get some data char szbuffer [11001]; // Used to store the return processing page, how big The actual situation.

Of course, Int nlen = pfile-> read (Szbuffer, 11000); // read the return result, the HTML code, the HTML code, is actually the HTML code of the voting result page, is, cstring straTemp = szbuffer // cstring although it is abused, but it is convenient, 嘿嘿 ~ pfile-> close (); // Data read out to turn the closing thing to PConnection-> close (); delete pfile; delete PConnection Session.close (); // The following code is to analyze the data you are interested in, and there is no relationship with the vote, it doesn't explain int npos = strtemp.find ("Option A"); INT NTEMPPOS = NPOS; IF (NpOS == - 1) {THEAPP.M_NTHREADS -; return 0;} npos = startp.find ("Table Width = 100> ", NPOS) 36; int Nendpos = strTemp.Find ("Ticket", NPOS); m_nournum = atoi (strTemp.MID (NPOS, NENDPOS-NPOS); NPOS = strTemp.Find (" 1 "); npos = strTemp.Find (" Table Width = 100> ", NPOS 36; Nendpos = Strtemp.Find (" Ticket " , NPOS); M_NDIFF = ATOI (Strtemp.MID (NPOS, NENDPOS-NPOS) - m_nournum; m_nvote ;} catch (...) { } Theapp.m_nthreads -; return 0;} You can see that the key code is then only a few lines. If the result of the voting is not analyzed, there are few more than the method 1, and it doesn't matter if it is not a way. However, this method also exists in the SESSION repetition problem that said. And according to me, the new open thread session is also repeated. So I estimate that the session key is determined according to the Process ID (a speech, welcome everyone to discuss). But if you start N threads at the same time, n threads can be thrown in the ticket, and you will not say "you have already voted". It is estimated because this information is submitted at the same time, and the server does not know that this session is actually voted when processing a message. I don't know this reason, you can discuss it. The way two programs vote will be written here. I am really general, so there is a mistake in the article, you don't want to say anything, and you will find out that everyone will discuss it. In addition, the SESSION problem that said in the article also hopes that everyone will discuss it.

转载请注明原文地址:https://www.9cbs.com/read-2605.html

New Post(0)