From: syl@alcor.concordia.ca (Sylvain Robitaille)
Subject: Re: corrupt /etc/passwd
Date: 23 Jul 2002 14:11:06 GMT [thread overview]
Message-ID: <ahjo5q$9qf$1@newsflash.concordia.ca> (raw)
In-Reply-To: 3d3d52b5$1@eumel.hag.hilti.com
On Tue, 23 Jul 2002 14:57:22 +0200, Skaghk wrote:
> I got a box running Tru64 V. 4.0 which got a blown up /etc/passwd. The
> file currently consitst of 4096 characters of ASCII 0. Surprisingly
> users still can log in and su to root also works well. Changing
> passwords ist the only thing, that does not work.
Appended below my signature is the start of a Perl script which will
convert the /etc/passwd.dir and /etc/passwd.pag files into a not quite
complete /etc/passwd.txt. You're going to need to either work on the
script to complete it (It was really written for .htpasswd files with
less information), or you'll need to go through the resulting passwd.txt
file and fix up userids, groupids, and take ':' characters out of the
GCOS field. Whether you want to add to the script or fix up the output
manually probably depends on how many users you have...
When you're done, rename /etc/passwd.txt to /etc/passwd.
I'm sorry I don't have a more complete solution, but I hope this at
least helps get you started in the right direction.
Reloading from backup *would* be a *lot* easier, of course... ;-)
--
----------------------------------------------------------------------
Sylvain Robitaille syl@alcor.concordia.ca
Systems analyst Concordia University
Instructional & Information Technology Montreal, Quebec, Canada
----------------------------------------------------------------------
#!/local/paths/perl -wT
#
# file: dbm2txt.pl
#
# 2000/08/30 Sylvain Robitaille: Quick hack to extract text password
# file from DBM file.
my ($key, $value);
my ($db_file) = @ARGV;
if(!defined $db_file) {
die "Usage:\n $0 <filename>\n";
}
# Untaint input:
if( $db_file =~ m%^([^`\\<>|]+)$% ) {
$db_file = $1;
} else {
die "$db_file tainted\n";
}
dbmopen %PW, "$db_file", 0666 or die "can't dbmopen $db_file: $!\n";
open TXTPW, "> $db_file.txt" or die "can't open $db_file.txt: $!\n";
# Make sure we'll be writing to the output file:
my $oldfh = select TXTPW;
# translate the input:
while (($key,$value) = each %PW) {
$value =~ s/[\0\s]+/:/g;
$value =~ s/:$//g;
print "$value\n";
}
# Reset our stdout:
select $oldfh;
close TXTPW;
dbmclose %PW;
next prev parent reply other threads:[~2002-07-23 14:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-23 12:57 corrupt /etc/passwd Skaghk
2002-07-23 14:11 ` Sylvain Robitaille [this message]
2002-07-24 5:32 ` Nikola Milutinovic
2002-07-24 10:04 ` Craig Markwardt
2002-07-24 12:05 ` Stuart Fuller
2002-07-24 12:24 ` Skaghk
2002-07-30 14:19 ` Michael Joosten
2002-07-31 18:42 ` Sylvain Robitaille
2002-08-05 14:42 ` Michael Joosten
2002-07-24 17:01 ` Rich Alderson
2002-07-24 18:53 ` Paul A Sand
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox