[ Avaa Bypassed ]




Upload:

Command:

www-data@18.216.248.35: ~ $
# htpasswd-file-lib.pl
# Functions for reading and writing a .htpasswd format file
# XXX md5 and old password

use strict;
use warnings;
no warnings 'redefine';
no warnings 'uninitialized';
BEGIN { push(@INC, ".."); };
use WebminCore;
our (%access, $module_name, %config, %gconfig, %list_authusers_cache,
     %list_authgroups_cache, $null_file);
if (!$module_name) {
	&init_config();
	%access = &get_module_acl();
	}
do 'md5-lib.pl';
our $htdigest_command = &has_command("htdigest") || &has_command("htdigest2");

# list_users([file])
# Returns an array of user and password details from the given file
sub list_users
{
my ($file) = @_;
$file ||= $config{'file'};
if (!defined($list_authusers_cache{$file})) {
	$list_authusers_cache{$file} = [ ];
	local $_;
	my $lnum = 0;
	my $count = 0;
	if (open(HTPASSWD, "<".$file)) {
		while(<HTPASSWD>) {
			if (/^(#?)\s*([^:]+):(\S*)/) {
				push(@{$list_authusers_cache{$file}},
					  { 'user' => $2,
					    'pass' => $3,
					    'enabled' => !$1,
					    'file' => $file,
					    'line' => $lnum,
					    'index' => $count++ });
				}
			$lnum++;
			}
		close(HTPASSWD);
		}
	}
return $list_authusers_cache{$file};
}

# list_digest_users([file])
# Returns an array of user, domain and password details from the given file
sub list_digest_users
{
my ($file) = @_;
$file ||= $config{'file'};
if (!defined($list_authusers_cache{$file})) {
	$list_authusers_cache{$file} = [ ];
	local $_;
	my $lnum = 0;
	my $count = 0;
	if (open(HTPASSWD, "<".$file)) {
		while(<HTPASSWD>) {
			if (/^(#?)\s*(\S+):(\S+):(\S*)/) {
				push(@{$list_authusers_cache{$file}},
					  { 'user' => $2,
					    'dom' => $3,
					    'pass' => $4,
					    'enabled' => !$1,
					    'digest' => 1,
					    'file' => $file,
					    'line' => $lnum,
					    'index' => $count++ });
				}
			$lnum++;
			}
		close(HTPASSWD);
		}
	}
return $list_authusers_cache{$file};
}

# modify_user(&user)
sub modify_user
{
my $lref = &read_file_lines($_[0]->{'file'});
if ($_[0]->{'digest'}) {
	$lref->[$_[0]->{'line'}] = ($_[0]->{'enabled'} ? "" : "#").
			   "$_[0]->{'user'}:$_[0]->{'dom'}:$_[0]->{'pass'}";
	}
else {
	$lref->[$_[0]->{'line'}] = ($_[0]->{'enabled'} ? "" : "#").
				   "$_[0]->{'user'}:$_[0]->{'pass'}";
	}
&flush_file_lines($_[0]->{'file'});
}

# create_user(&user, [file])
sub create_user
{
$_[0]->{'file'} = $_[1] || $config{'file'};
my $lref = &read_file_lines($_[0]->{'file'});
$_[0]->{'line'} = @$lref;
if ($_[0]->{'digest'}) {
	push(@$lref, ($_[0]->{'enabled'} ? "" : "#").
		     "$_[0]->{'user'}:$_[0]->{'dom'}:$_[0]->{'pass'}");
	}
else {
	push(@$lref, ($_[0]->{'enabled'} ? "" : "#").
		     "$_[0]->{'user'}:$_[0]->{'pass'}");
	}
&flush_file_lines($_[0]->{'file'});
$list_authusers_cache{$_[0]->{'file'}} ||= [ ];
$_[0]->{'index'} = @{$list_authusers_cache{$_[0]->{'file'}}};
push(@{$list_authusers_cache{$_[0]->{'file'}}}, $_[0]);
}

# delete_user(&user)
sub delete_user
{
my $lref = &read_file_lines($_[0]->{'file'});
splice(@$lref, $_[0]->{'line'}, 1);
&flush_file_lines($_[0]->{'file'});
splice(@{$list_authusers_cache{$_[0]->{'file'}}}, $_[0]->{'index'}, 1);
map { $_->{'line'}-- if ($_->{'line'} > $_[0]->{'line'}) }
    @{$list_authusers_cache{$_[0]->{'file'}}};
}

# encrypt_password(string, [old], md5mode)
sub encrypt_password
{
my ($str, $old, $mode) = @_;
$mode ||= 0;
&seed_random();
if ($mode == 1) {
	# MD5
	return &encrypt_md5($str, $old);
	}
elsif ($mode == 2) {
	# SHA1
	return &encrypt_sha1($str);
	}
elsif ($mode == 3) {
	# Digest
	return &digest_password(undef, undef, $str);
	}
else {
	# Crypt
	if ($gconfig{'os_type'} eq 'windows' && &has_command("htpasswd")) {
		# Call htpasswd program
		my $qp = quotemeta($str);
		my $out = &backquote_command(
			"htpasswd -n -b foo $qp 2>&1 <$null_file");
		if ($out =~ /^foo:(\S+)/) {
			return $1;
			}
		else {
			&error("htpasswd failed : $out");
			}
		}
	else {
		# Use built-in encryption code and use system default
		my $salt = $old;
		&foreign_require('useradmin');
		return &useradmin::encrypt_password($str, $salt, 1);
		}
	}
}

# digest_password(user, realm, pass)
# Encrypts a password in the format used by htdigest
sub digest_password
{
my ($user, $dom, $pass) = @_;
my $temp = &tempname();
eval "use Digest::MD5";
if (!$@) {
	# Use the digest::MD5 module to do the encryption directly
	return Digest::MD5::md5_hex("$user:$dom:$pass");
	}
else {
	# Shell out to htdigest command
	&foreign_require("proc", "proc-lib.pl");
	my ($fh, $fpid) = &proc::pty_process_exec("$htdigest_command -c $temp ".quotemeta($dom)." ".quotemeta($user));
	&wait_for($fh, "password:");
	&sysprint($fh, "$pass\n");
	&wait_for($fh, "password:");
	&sysprint($fh, "$pass\n");
	&wait_for($fh);
	close($fh);
	my $tempusers = &list_digest_users($temp);
	unlink($temp);
	return $tempusers->[0]->{'pass'};
	}
}

# list_groups(file)
# Returns an array of group details from the given file
sub list_groups
{
my $file = $_[0];
if (!defined($list_authgroups_cache{$file})) {
	$list_authgroups_cache{$file} = [ ];
	local $_;
	my $lnum = 0;
	my $count = 0;
	open(HTPASSWD, "<".$file);
	while(<HTPASSWD>) {
		if (/^(#?)\s*(\S+):\s*(.*)/) {
			push(@{$list_authgroups_cache{$file}},
				  { 'group' => $2,
				    'enabled' => !$1,
				    'members' => [ split(/\s+/, $3) ],
				    'file' => $file,
				    'line' => $lnum,
				    'index' => $count++ });
			}
		$lnum++;
		}
	close(HTPASSWD);
	}
return $list_authgroups_cache{$file};
}

# modify_group(&group)
sub modify_group
{
my $lref = &read_file_lines($_[0]->{'file'});
$lref->[$_[0]->{'line'}] = ($_[0]->{'enabled'} ? "" : "#").
			   "$_[0]->{'group'}: ".
			   join(" ", @{$_[0]->{'members'}});
&flush_file_lines();
}

# create_group(&group, [file])
sub create_group
{
$_[0]->{'file'} = $_[1] || $config{'file'};
my $lref = &read_file_lines($_[0]->{'file'});
$_[0]->{'line'} = @$lref;
push(@$lref, ($_[0]->{'enabled'} ? "" : "#").
	      "$_[0]->{'group'}: ".
	      join(" ", @{$_[0]->{'members'}}));
&flush_file_lines();
$_[0]->{'index'} = @{$list_authgroups_cache{$_[0]->{'file'}}};
push(@{$list_authgroups_cache{$_[0]->{'file'}}}, $_[0]);
}

# delete_group(&group)
sub delete_group
{
my $lref = &read_file_lines($_[0]->{'file'});
splice(@$lref, $_[0]->{'line'}, 1);
&flush_file_lines();
splice(@{$list_authgroups_cache{$_[0]->{'file'}}}, $_[0]->{'index'}, 1);
map { $_->{'line'}-- if ($_->{'line'} > $_[0]->{'line'}) }
    @{$list_authgroups_cache{$_[0]->{'file'}}};
}


1;


Filemanager

Name Type Size Permission Actions
images Folder 0755
lang Folder 0755
CHANGELOG File 1.76 KB 0644
acl_security.pl File 1.19 KB 0755
cgi_args.pl File 838 B 0755
config File 104 B 0644
config-windows File 104 B 0644
config.info File 404 B 0644
config.info.bg File 736 B 0644
config.info.ca File 464 B 0644
config.info.cs File 438 B 0644
config.info.de File 520 B 0644
config.info.es File 377 B 0644
config.info.fi File 0 B 0644
config.info.fr File 510 B 0644
config.info.hu File 378 B 0644
config.info.ja File 521 B 0644
config.info.ko File 387 B 0644
config.info.ms File 0 B 0644
config.info.nl File 451 B 0644
config.info.no File 435 B 0644
config.info.tr File 352 B 0644
config.info.zh_TW File 169 B 0644
defaultacl File 32 B 0644
delete.cgi File 1.17 KB 0755
edit_dir.cgi File 4.02 KB 0755
edit_group.cgi File 1.3 KB 0755
edit_user.cgi File 1.58 KB 0755
htaccess-lib.pl File 3.88 KB 0755
htpasswd-file-lib.pl File 6.27 KB 0755
index.cgi File 4.49 KB 0755
log_parser.pl File 475 B 0755
md5-lib.pl File 7.58 KB 0755
module.info File 215 B 0644
module.info.af File 0 B 0644
module.info.af.auto File 149 B 0644
module.info.ar File 0 B 0644
module.info.ar.auto File 197 B 0644
module.info.be File 0 B 0644
module.info.be.auto File 210 B 0644
module.info.bg File 0 B 0644
module.info.bg.auto File 224 B 0644
module.info.ca File 126 B 0644
module.info.ca.auto File 24 B 0644
module.info.cs File 36 B 0644
module.info.cs.auto File 125 B 0644
module.info.da File 0 B 0644
module.info.da.auto File 142 B 0644
module.info.de File 146 B 0644
module.info.de.auto File 25 B 0644
module.info.el File 0 B 0644
module.info.el.auto File 314 B 0644
module.info.es File 35 B 0644
module.info.es.auto File 127 B 0644
module.info.eu File 0 B 0644
module.info.eu.auto File 150 B 0644
module.info.fa File 0 B 0644
module.info.fa.auto File 249 B 0644
module.info.fi File 33 B 0644
module.info.fi.auto File 117 B 0644
module.info.fr File 36 B 0644
module.info.fr.auto File 135 B 0644
module.info.he File 0 B 0644
module.info.he.auto File 197 B 0644
module.info.hr File 0 B 0644
module.info.hr.auto File 155 B 0644
module.info.hu File 40 B 0644
module.info.hu.auto File 140 B 0644
module.info.it File 0 B 0644
module.info.it.auto File 142 B 0644
module.info.ja File 45 B 0644
module.info.ja.auto File 161 B 0644
module.info.ko File 32 B 0644
module.info.ko.auto File 136 B 0644
module.info.lt File 0 B 0644
module.info.lt.auto File 178 B 0644
module.info.lv File 0 B 0644
module.info.lv.auto File 170 B 0644
module.info.ms File 119 B 0644
module.info.ms.auto File 22 B 0644
module.info.mt File 0 B 0644
module.info.mt.auto File 152 B 0644
module.info.nl File 35 B 0644
module.info.nl.auto File 122 B 0644
module.info.no File 33 B 0644
module.info.no.auto File 126 B 0644
module.info.pl File 0 B 0644
module.info.pl.auto File 149 B 0644
module.info.pt File 0 B 0644
module.info.pt.auto File 158 B 0644
module.info.pt_BR File 0 B 0644
module.info.pt_BR.auto File 167 B 0644
module.info.ro File 0 B 0644
module.info.ro.auto File 155 B 0644
module.info.ru File 0 B 0644
module.info.ru.auto File 208 B 0644
module.info.sk File 0 B 0644
module.info.sk.auto File 156 B 0644
module.info.sl File 0 B 0644
module.info.sl.auto File 154 B 0644
module.info.sv File 0 B 0644
module.info.sv.auto File 161 B 0644
module.info.th File 0 B 0644
module.info.th.auto File 274 B 0644
module.info.tr File 0 B 0644
module.info.tr.auto File 160 B 0644
module.info.uk File 0 B 0644
module.info.uk.auto File 208 B 0644
module.info.ur File 0 B 0644
module.info.ur.auto File 220 B 0644
module.info.vi File 0 B 0644
module.info.vi.auto File 180 B 0644
module.info.zh File 0 B 0644
module.info.zh.auto File 128 B 0644
module.info.zh_TW File 30 B 0644
module.info.zh_TW.auto File 101 B 0644
prefs.info File 28 B 0644
save_dir.cgi File 8.16 KB 0755
save_group.cgi File 1.28 KB 0755
save_user.cgi File 1.69 KB 0755
search.cgi File 1.81 KB 0755
useradmin_update.pl File 1.75 KB 0755