Help - Search - Member List - Calendar
Full Version: Logon na server ASP iz Perl script
Форумы RDA > Общение > Флейм
Gesha
V silu obstoyatel'stv vinuzhden zapolnyat' mnogo form
Reshil avtomatizirovat' process - no ne mogu sdelat' logon na server
Vot kod scripta - imya servera, login i pasw - real'nie
----------------------------------------------------------------
#!/usr/bin/perl -w

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Request::Common qw(POST);
use HTTP::Response;
use URI::Heuristic;
use HTTP::Cookies;

my $raw_url = 'www.************.com/admin';

open( OUTPUT, ">request.res") || die "File request.res can't be opened";
my $url = URI::Heuristic::uf_urlstr($raw_url);
$| = 1; # to flush next line
my $ua = LWP::UserAgent->new();

my $init_req = HTTP::Request->new(GET => $url);

my $response = $ua->request($init_req);
if ($response->is_error())
{
printf " %s\n", $response->status_line;
}
else
{
$init_cookie= HTTP::Cookies->new;
$init_cookie->extract_cookies($response);
$content = $response->as_string;
print OUTPUT $content;
}

$| = 1;
$login_req = POST 'http://www.**************.com/admin/index.asp',
[ UserName => '++++++++',
Password => '@@@@@@@@@',
action => 'Login'];
$init_cookie->add_cookie_header($login_req);

$req_txt = $login_req->as_string();
print OUTPUT $req_txt;

$response = $ua->request($login_req);
if ($response->is_error())
{
printf " %s\n", $response->status_line;
}
else
{
$content = $response->as_string;
print OUTPUT $content;
}
----------------------------------------------------------------
Vot kakoi otvet ya poluchayu:
http://www.*************.com/admin/admin_dblist.asp
Content-Length: 57
Content-Type: application/x-www-form-urlencoded
Cookie: ASPSESSIONIDGGGGGYQC=AJGDNIGANJLGIDMIKACNFKEI
Cookie2: $Version=1

UserName=+++++++++&Password=@@@@@@@@@@@&action=Login
HTTP/1.1 302 (Found) Object moved
Cache-Control: private
Connection: Keep-Alive
Date: Wed, 08 May 2002 16:59:39 GMT
Location: index.asp
Server: Microsoft-IIS/5.0
Content-Length: 130
Content-Type: text/html
Expires: Wed, 08 May 2002 16:59:40 GMT
Client-Date: Wed, 08 May 2002 16:48:47 GMT
Client-Peer: 209.125.209.156:80
Title: Object moved

<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="admin_dblist.asp">here</a>.</body>

-------------------------------------------------------------
Vopros - chego emu escho nado - mozhet kto znaet po kakomu printsipu on fil'truet request?

[This message has been edited by Gesha (edited 13 May 2002).]

SerG_DivX
Dlja avtomaticheskogo zapolnenija form sushestvuet programka - RoboForm (ochen udobnaja)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2025 Invision Power Services, Inc.