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
#!/usr/bin/perl use strict; use warnings; use Fcntl qw(:DEFAULT :flock); use Data::Dumper; local $Data::Dumper::Purity;$Data::Dumper::Purity = 1; local $Data::Dumper::Useqq;$Data::Dumper::Useqq = 1; local $Data::Dumper::Deparse = 1;$Data::Dumper::Deparse = 1; local $Data::Dumper::Sortkeys;$Data::Dumper::Sortkeys = sub { my ($hash) = @_; return [(sort {lc $a cmp lc $b} keys %$hash)]; }; use 5.010; system('cls'); require Net::Fritz::Box; my $host = 'https://192.168.0.1:49443'; my $username = "uname"; # Username for scripting at FritzBox my $password = "upsw"; # Username's password at FritzBox my $config = Net::Fritz::ConfigFile->new( username => $username, password => $password, upnp_url => $host, ); my $config_hashref = $config->configuration; say Dumper($config_hashref);
Quote$VAR1 = {};
perldoc Net::Fritz::ConfigfileDESCRIPTION
This class encapsulates the configuration file handling for Net::Fritz::Box. It should not be needed to directly interact with this class. No user-serviceable parts inside!
CONFIGURATION FILE FORMAT
The configuration format is basically a flat text file with key = value per line. Empty lines as well as comments (prefixed by #) are supported.
These keys are recognized:
upnp_url
trdesc_path
username
password
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
#!/usr/bin/perl use strict; use warnings; use 5.010; require Net::Fritz::Box; require LWP::UserAgent; ########################################## my $host = 'https://192.168.0.1:49443'; my $username = "user"; # Username for scripting at FritzBox my $password = "pw1"; # Username's password at FritzBox my $passwcfg = 'pw2'; ########################################## my $fb = Net::Fritz::Box->new( username => $username, password => $password, upnp_url => $host, ); if (my $error = $fb->error) { die $error; } my $device = $fb->discover; if(my $error = $device->error) { die $error; } my $Service = $device->find_service('DeviceConfig:1'); if(my $error = $device->error) { die $error; } my $Response = $Service->call( 'X_AVM-DE_GetConfigFile', 'NewX_AVM-DE_Password' => $passwcfg ); my $ConfigFileUrl = $Response->data->{'NewX_AVM-DE_ConfigFileUrl'}; # liefert z. B. https://192.168.0.1:38317/TR064/3CDEFF68 my $UserAgent = LWP::UserAgent->new(); $UserAgent->ssl_opts( verify_hostname => 0, SSL_verify_mode => 0 ); my $URI = URI->new($ConfigFileUrl); my $Host = $URI->host(); my $Port = $URI->port(); $UserAgent->credentials("$Host:$Port",'HTTP Access',$username,$password); $UserAgent->credentials("$Host:$Port",'HTTPS Access',$username,$password); $Response = $UserAgent->get($ConfigFileUrl); unless($Response->is_success) { my $status_line = $Response->status_line; die "cannot download from URL '$ConfigFileUrl' -- $status_line"; } say $Response->decoded_content;
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
#!/usr/bin/perl use strict; use warnings; use 5.010; my $obj = {}; require Net::Fritz::Box; $obj->{fb_device} = Net::Fritz::Box->new( upnp_url => 'http://192.168.0.1:49000', username => 'upnp_benutzer', password => 'upnp_passwort', ); if (my $error = $obj->{fb_device}->error) { die "Objekterzeugung/Login durch Net::Fritz::Box->new() wirft Fehler: '$error'"; } my $device = $obj->{fb_device}->discover; my $service = $device->find_service('DeviceConfig:1'); my $response = $service->call( 'X_AVM-DE_GetConfigFile', 'NewX_AVM-DE_Password' => 'guipasswort', ); my $configfileurl = $response->data->{'NewX_AVM-DE_ConfigFileUrl'}; say "URL: '$configfileurl'";
Quotes:Client UPnPError 866 second factor authentication required