PHP: Snoopy captures pages and simulates submission forms

Source: Internet
Author: User
PHP code
  1. <?
  2. $ Url = "http://www.taoav.com ";
  3. Include ("Snoopy. php ");
  4. $ Snoopy = new Snoopy;
  5. $ Snoopy-> fetch ($ URL); // get all content
  6. Echo $ Snoopy-> results; // display the result
  7. // Optional
  8. $ Snoopy-> fetchtext // get text content (remove HTML code)
  9. $ Snoopy-> fetchlinks // obtain the link
  10. $ Snoopy-> fetchform // obtain the form
  11. ?>

 

Form submission

PHP code
  1. <? PHP
  2. $ Formvars ["username"] = "admin ";
  3. $ Formvars ["PWD"] = "admin ";
  4. $ Action = "http://www.taoav.com"; // form submission address
  5. $ Snoopy-> submit ($ action, $ formvars); // $ formvars is the submitted Array
  6. Echo $ Snoopy-> results; // obtain the result returned after the form is submitted.
  7. // Optional
  8. $ Snoopy-> submittext; // after submission, only the HTML-removed text is returned.
  9. $ Snoopy-> submitlinks; // after submission, only the link is returned.
  10. ?>

Since the form has been submitted, we can do a lot of things. Next we will disguise the IP address and the browser.
Disguise

PHP code
  1. <? PHP
  2. $ Formvars ["username"] = "admin ";
  3. $ Formvars ["PWD"] = "admin ";
  4. $ Action = "http://www.taoav.com ";
  5. Include "Snoopy. php ";
  6. $ Snoopy = new Snoopy;
  7. $ Snoopy-> Cookies ["PHPSESSID"] = 'fc0000b1918bd522cc863f000090e6fff7 '; // disguise sessionid
  8. $ Snoopy-> agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)"; // camouflage Browser
  9. $ Snoopy-> Referer = http://www.php100.com; // camouflage Source Page address http_referer
  10. $ Snoopy-> rawheaders ["Pragma"] = "no-Cache"; // The HTTP header information of the cache
  11. $ Snoopy-> rawheaders ["x_forwarded_for"] = "127.0.0.101"; // disguise IP Address
  12. $ Snoopy-> submit ($ action, $ formvars );
  13. Echo $ Snoopy-> results;
  14. ?>

 

In the past, we could disguise session as a Web browser and IP address, and Haha could do a lot of things.
For example, you can vote for an IP address with a verification code.
PS: here, the disguised IP address is actually an HTTP header, so the IP address obtained through remote_addr cannot be disguised,
Instead, IP addresses obtained through HTTP headers (which can prevent proxies) can be created by themselves.
Let's briefly describe how to use the Verification Code:
First, use a normal browser to view the page and find the sessionid corresponding to the Verification code,
Write down sessionid and verification code value at the same time,
Next, we will use Snoopy to forge.
Principle: because it is the same sessionid, the verification code obtained is the same as the one entered for the first time.

Sometimes we may need to forge more things, and Snoopy comes to mind completely for us.

PHP code
  1. <? PHP
  2. $ Snoopy-> proxy_host = "www.php100.com ";
  3. $ Snoopy-> proxy_port = "8080"; // use a proxy
  4. $ Snoopy-> maxredirs = 2; // redirect times
  5. $ Snoopy-> expandlinks = true; // whether to complete the link is often used during collection
  6. // For example, the link for/images/taoav.gif can be changed to its full link http://www.taoav.com/images/taoav.gif
  7. $ Snoopy-> maxframes = 5 // maximum number of frames allowed
  8. // When capturing the frame, $ Snoopy-> results returns an array.
  9. $ Snoopy-> error // error message returned
  10. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.