Hallo Perlgurus!
Ich will mich mit LWP auf meinen Speedport W504V einloggen.
Hier der wichtige Ausschnitt aus
https://192.168.0.1/hcti_start_passwort.stm
<DIV class=lineThW></DIV>
<DIV class=titel><DIV class=colVoll>Gerätepasswort Eingabe</DIV></DIV>
<form name="tF" method="post" action="/cgi-bin/login.cgi" onSubmit="return evaltF();">
<DIV class=rowHalb></DIV>
<DIV class=rowStd>
<DIV class=colLast><input type="password" class="stylepwd" name="pws" size="12" maxlength="12" onkeypress="return stEnter(event,this);" autocomplete="off"></DIV>
</DIV>
</form>
Ich muss also das PW in das Feld pws schreiben und den POST-Request auf /cgi-bin/login.cgi abfeuern oder?
Jetzt sieht mein Perl-Script so aus:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w
use strict;
use warnings;
use LWP::UserAgent;
use HTTP::Request::Common qw{ POST };
use CGI;
use HTTP::Cookies;
use Crypt::SSLeay;
$ENV{HTTPS_CA_DIR} = "/opt/certs";
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $md5 = '0000';
my $url = 'https://speedport.ip/cgi-bin/login.cgi';
my $ua = LWP::UserAgent->new();
$ua->agent("Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8) Gecko/20051111 Firefox/1.5");
$ua->cookie_jar(
HTTP::Cookies->new(
file => 'mycookies.txt',
autosave => 1
)
);
my $request = POST( $url, [ 'pws' => $md5 ] );
my $content = $ua->request($request)->as_string();
my $cgi = CGI->new();
print $cgi->header(), $content;
Als Ergebnis kommt:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Content-Type: text/html; charset=ISO-8859-1
HTTP/1.1 403 Forbidden
Cache-Control: max-age=0, must-revalidate
Connection: close
Pragma: no-cache
Server: Apache
Content-Type: text/html
Client-Date: Tue, 11 Dec 2012 14:14:44 GMT
Client-Peer: 192.168.0.1:443
Client-Response-Num: 1
Client-SSL-Cert-Issuer: /O=VeriSign Trust Network/OU=VeriSign, Inc./OU=VeriSign International Server CA - Class 3/OU=www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97 VeriSign
Client-SSL-Cert-Subject: /C=DE/ST=Hessen/L=Darmstadt/O=Deutsche Telekom AG/OU=P&I PSO/DCS/CN=speedport.ip
Client-SSL-Cipher: AES256-SHA
Title: 403 Forbidden
<HEAD><TITLE>403 Forbidden</TITLE></HEAD>
<BODY><H1>403 Forbidden</H1>
Your client does not have permission to get this page.(code=41193) from this server.<P>
</BODY>
Bitte um Hilfe, ich komme da trotz stundenlanger Versuche nicht weiter!
Vielen Dank
Stefan
Last edited: 2012-12-11 15:19:10 +0100 (CET)