1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$client = new SoapClient(
null,
array(
'location' => "http://".$fritzboxIP.":".$fritzboxPort."/upnp/control/wlanconfig2",
'uri' => "urn:dslforum-org:service:WLANConfiguration:2",
'noroot' => True,
'login' => $login,
'password' => $password
)
);
//print_r($client);
$NumberOfHosts = $client->GetTotalAssociations();
//print_r($NumberOfHosts);
for ($i=0;$i<$NumberOfHosts;$i++)
{
$Host = $client->GetGenericAssociatedDeviceInfo(new SoapParam($i,'NewAssociatedDeviceIndex'));
//print_r($Host);
$Hosts[] = $Host;
}
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
#!/usr/bin/perl -w use strict; use warnings; use SOAP::Lite; use Data::Dumper; # consts use constant { FRITZ_USER => "dslf-config", FRITZ_PASS => "***********", #BASIC_URI => "urn:schemas-upnp-org:service:", BASIC_URI => "urn:dslforum-org:service:", BASIC_PROXY => "http://fritz.box:49000/upnp/control/deviceinfo", HTTPS_PROXY => "https://fritz.box:", }; # zunächst fordern wie wie im ersten Beitrag den Security Port an my $s = SOAP::Lite -> uri('urn:dslforum-org:service:DeviceInfo:1') -> proxy('http://fritz.box:49000/upnp/control/deviceinfo') -> getSecurityPort(); my $port = $s->result; print "Using TCP port $port for Fritzbox access.\n"; # jetzt müssen wir die Zertifikatsüberprüfung abschalten BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME}=0; } undef $s; # hier die Abfrage der externen IP $s = SOAP::Lite -> uri(BASIC_URI . "WLANConfiguration:2") -> proxy(HTTPS_PROXY . $port . "/upnp/control/wlanconfig2", ssl_opts => [ SSL_verify_mode => 0 ] ) -> GetGenericAssociatedDeviceInfo( INDEX 1 - ???????? ); open FH, ">erg_dumper.txt" or die ("Fehler beim schreiben $!"); print FH Dumper $s; close FH; print "result: " . $s->result . "\n"; # dieser Code authentifiziert an der Box sub SOAP::Transport::HTTP::Client::get_basic_credentials { return FRITZ_USER => FRITZ_PASS; }
new SoapParam(1,'NewAssociatedDeviceIndex')
1 2 3 4
for (my $i = 0; $i < $numberOfHosts; $i++ ) { my $host = $s->GetGenericAssociatedDeviceInfo(SOAP::Data->type('integer')->name('NewAssociatedDeviceIndex')->value($i))->result; print Dumper $host }