X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fremote.cgi;h=1b3dfed70a881dd3a358327a0666c9945e549d78;hp=84e08474c87fa8f425b207017f580a76e41859f3;hb=5b4464a94478059ceebf266bc31dee4a4ba18fac;hpb=748cfb0b8f5daba5cc0e6655ab93f0d32d3232b5 diff --git a/html/cgi-bin/remote.cgi b/html/cgi-bin/remote.cgi index 84e08474c8..1b3dfed70a 100644 --- a/html/cgi-bin/remote.cgi +++ b/html/cgi-bin/remote.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2011 IPFire Team # +# Copyright (C) 2007-2014 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -25,15 +25,23 @@ use strict; #use warnings; #use CGI::Carp 'fatalsToBrowser'; +use IO::Socket; + require '/var/ipfire/general-functions.pl'; +require "${General::swroot}/geoip-functions.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; +my %color = (); +my %mainsettings = (); my %remotesettings=(); my %checked=(); my $errormessage=''; my $counter = 0; +&General::readhash("${General::swroot}/main/settings", \%mainsettings); +&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); + &Header::showhttpheaders(); $remotesettings{'ENABLE_SSH'} = 'off'; @@ -120,7 +128,7 @@ $checked{'SSH_PORT'}{$remotesettings{'SSH_PORT'}} = "checked='checked'"; if ($errormessage) { &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "$errormessage \n"; + print "$errormessage \n"; &Header::closebox(); } @@ -166,14 +174,20 @@ END print "\n"; -&Header::openbox('100%', 'left', $Lang::tr{'ssh host keys'}); +&Header::openbox('100%', 'center', $Lang::tr{'ssh host keys'}); -print "\n"; +print "
\n"; print < - - + + + + + + + + + END ; @@ -181,8 +195,41 @@ END &viewkey("/etc/ssh/ssh_host_rsa_key.pub","RSA2"); &viewkey("/etc/ssh/ssh_host_dsa_key.pub","DSA"); &viewkey("/etc/ssh/ssh_host_ecdsa_key.pub","ECDSA"); +&viewkey("/etc/ssh/ssh_host_ed25519_key.pub","ED25519"); -print "
$Lang::tr{'ssh key'}$Lang::tr{'ssh fingerprint'}$Lang::tr{'ssh key size'}
$Lang::tr{'ssh key'}$Lang::tr{'type'}$Lang::tr{'ssh fingerprint'}$Lang::tr{'ssh key size'}
\n"; +print "\n\n"; + +&Header::closebox(); + +&Header::openbox('100%', 'center', $Lang::tr{'ssh active sessions'}); + +print < + + + + $Lang::tr{'ssh username'} + + + $Lang::tr{'ssh login time'} + + + $Lang::tr{'ip address'} + + + $Lang::tr{'country'} + + + $Lang::tr{'rdns'} + + + + +END + +&printactivelogins(); + +print "\n\n"; &Header::closebox(); @@ -201,6 +248,57 @@ sub viewkey my @temp = split(/ /,`/usr/bin/ssh-keygen -l -f $key`); my $keysize = &Header::cleanhtml($temp[0],"y"); my $fingerprint = &Header::cleanhtml($temp[1],"y"); - print "$key ($name)$fingerprint$keysize\n"; + print "$key$name$fingerprint$keysize\n"; } } + +sub printactivelogins() +{ + # print active SSH logins (grep outpout of "who -s") + my $command = "who -s"; + my @output = `$command`; + chomp(@output); + + my $id = 0; + + if ( scalar(@output) == 0 ) + { + # no logins appeared + my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'}; + print "$Lang::tr{'ssh no active logins'}\n"; + } else { + # list active logins... + + foreach my $line (@output) + { + my @arry = split(/\ +/, $line); + + my $username = @arry[0]; + my $logintime = join(' ', @arry[2..4]); + my $remoteip = @arry[5]; + $remoteip =~ s/[()]//g; + + # display more information about that IP adress... + my $ccode = &GeoIP::lookup($remoteip); + my $flag_icon = &GeoIP::get_flag_icon($ccode); + + # get rDNS... + my $iaddr = inet_aton($remoteip); + my $rdns = gethostbyaddr($iaddr, AF_INET); + if (!$rdns) { $rdns = $Lang::tr{'lookup failed'}; }; + + my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'}; + + print < + $username + $logintime + $remoteip + $ccode + $rdns + +END +; + } + } +}