#!/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;