Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- use strict;
- use warnings;
- use URI::Escape;
- use WWW::Curl;
- use WWW::Curl::Share;
- use WWW::Curl::Easy;
- sub do_curl {
- my ($url,$referer,$postfields);
- ($url,$referer,$postfields) = @_;
- my $header;
- my $body;
- my $curl = WWW::Curl::Easy->new;
- $curl->setopt(CURLOPT_HEADER,1);
- $curl->setopt(CURLOPT_FOLLOWLOCATION,1);
- $curl->setopt(CURLOPT_VERBOSE,0);
- $curl->setopt(CURLOPT_URL, $url);
- $curl->setopt(CURLOPT_REFERER, $referer);
- $curl->setopt(CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36');
- $postfields = uri_escape($postfields);
- $curl->setopt(CURLOPT_POSTFIELDS, $postfields);
- $curl->setopt(CURLOPT_HEADERDATA, \$header);
- $curl->setopt(CURLOPT_WRITEDATA,\$body);
- my $retcode = $curl->perform;
- if ($retcode == 0) {
- print "Sucesso!\n";
- return $body;
- } else {
- print("Falha\n");
- print("An error happened: $retcode ".$curl->strerror($retcode)." ".$curl->errbuf.";\n");
- return 0;
- }
- }
- print do_curl('https://www.google.com.br/','https://www.google.com.br/','login=user&senha=senha');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement