Skip to content

Commit

Permalink
added user name authentication to fritzuploader.pl
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Aug 6, 2017
1 parent 61b5aee commit 990ed0c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion bin/fritzuploader.pl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use XML::Simple;# not included in perlmodlib
use Digest::MD5 qw(md5 md5_hex); # installed by default via perlmodlib
use Encode; # installed by default via perlmodlib
use URI::Encode qw(uri_encode uri_decode); # URL encoding
#use Data::Dumper;

##### use config file instead of command line arguments
Expand All @@ -38,6 +39,7 @@
### config parameters for fritzuploader.pl
############################################
#FRITZUPLOADER_FRITZBOX_IP = fritz.box
#FRITZUPLOADER_FRITZBOX_USER = <fbox_admin_user_if_needed>
#FRITZUPLOADER_FRITZBOX_PW = <fbox_admin_password>
#FRITZUPLOADER_XML_FILE = /path/to/phonebook.xml
#----------------------------------------------------
Expand All @@ -64,6 +66,10 @@ sub parse_config {
parse_config;

my $fritz = $cfg->{FRITZUPLOADER_FRITZBOX_IP}; # or IP address '192.168.1.1'
my $username = '-';
if (exists $cfg->{FRITZUPLOADER_FRITZBOX_USER} ) {
$username = $cfg->{FRITZUPLOADER_FRITZBOX_USER};
}
my $password = $cfg->{FRITZUPLOADER_FRITZBOX_PW};
my $phonebookFile = $cfg->{FRITZUPLOADER_XML_FILE};
#my $password = $ARGV[0] or die "Usage: $0 fritzbox-password\n";
Expand Down Expand Up @@ -95,7 +101,13 @@ sub parse_config {

$resp = HTTP::Request->new(POST => "$webcmurl/login_sid.lua");
$resp->content_type("application/x-www-form-urlencoded");
$resp->content("response=${challengeresponse}&page=/login_sid.lua");
# See: https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/AVM_Technical_Note_-_Session_ID.pdf
if ($username eq '-') {
$resp->content("response=${challengeresponse}&page=/login_sid.lua");

} else {
$resp->content("response=${challengeresponse}&page=/login_sid.lua&username=" . uri_encode( $username ) );
}

my $loginresp = $ua->request($resp);
die "Can't get SID " . $loginresp->status_line() . "\n" unless $loginresp->is_success();
Expand Down
3 changes: 3 additions & 0 deletions etc/egw2fbox.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ MUTT_EXPORT_FILE = /path/to/egw2fbox_basedir/data/mutt_egw_addresses
############################################
FRITZUPLOADER_FRITZBOX_IP = fritz.box
FRITZUPLOADER_FRITZBOX_PW = <fb_admin_password>
# Default: No user name -> admin user
# Commenting out -> need to create a user at FritzBox user with admin rights
#FRITZUPLOADER_FRITZBOX_USER = <fbox_admin_user_if_needed>
FRITZUPLOADER_XML_FILE = /path/to/egw2fbox_basedir/data/phonebook.xml


Expand Down

0 comments on commit 990ed0c

Please sign in to comment.