At 16:49 04-09-99 +0700, you wrote:
>>dan kayaknya baris berikut di modul Expect harus dibenerin:
>> exec($cmd);
>>jadi
>> exec(@_);
>
>udah dilakukan yang gini di expect.pm tapi masih tetap gagal di
>"kagak ada new unix password\n" nih di user biasa kenapa ya ?
>udah diset rws-r-s-r-x root.root di passwd.pl
di saya jalan. script anda akhirnya jadi gini di tangan saya.
kalo mau beberapa statement 'sleep' yang ada bisa dicabut:
>>>>>
#!/usr/bin/perl
$|++;
use Expect;
$ENV{PATH}=$ENV{BASH_ENV}='';
($user)=$ARGV[0]=~/(.*)/; # untaint buta...
($password)=$ARGV[1]=~/(.*)/; # untaint buta...
$<=$>;
print"uid=$< euid=$>\n";
$t=Expect->spawn('/usr/bin/passwd', $user) || die "gagal passwd\n";
$t->debug(3); $t->log_stdout(1);
sleep 1;
$unknown=$t->expect(5,'-re','.*Unknown.*');
if ($unknown) {die "unknown\n";}
sleep 1;
$t->expect(5,'password: ') || die "kagak ada new unix password\n";
print $t "$password\r";
sleep 1;
$t->expect(5,'password: ') || die "gagal retype\n";
print $t "$password\r";
$t->expect(5,'successfully') || die "tidak sukses\n";
$t->soft_close;
<<<<<
ini dump hasilnya. saya coba: ./script jinny 1
('jinny' tentu saja user account yang udah ada di sistem).
agak 'bawel' karena debug + log ke stdout saya nyalain.
>>>>>
uid=0 euid=0
Beginning expect from spawn id(3).
Accumulator: ''
Expect timeout time: 5 seconds.
expect: Pty=spawn id(3), time=936574929, loop_time=5
expect: handle spawn id(3) ready.
expect: read 53 byte(s) from spawn id(3).
Changing password for user jinny
New UNIX password: Returning from expect unsuccessfully. Error: 1:TIMEOUT.
Accumulator: 'Changing password for user jinny\r\nNew UNIX password: '
Beginning expect from spawn id(3).
Accumulator: 'Changing password for user jinny\r\nNew UNIX password: '
Expect timeout time: 5 seconds.
expect: Pty=spawn id(3), time=936574935, loop_time=5
Matched pattern 1 ('password: ')!
Before match string: 'Changing password for user jinny\r\nNew UNIX '
Match string: 'password: '
After match string: ''
Returning from expect successfully.
Accumulator: ''
Beginning expect from spawn id(3).
Accumulator: ''
Expect timeout time: 5 seconds.
expect: Pty=spawn id(3), time=936574936, loop_time=5
expect: handle spawn id(3) ready.
expect: read 62 byte(s) from spawn id(3).
BAD PASSWORD: it's WAY too short
Retype new UNIX password: Matched pattern 1 ('password: ')!
Before match string: '\r\nBAD PASSWORD: it\'s WAY too short\r\nRetype new
UNIX '
Match string: 'password: '
After match string: ''
Returning from expect successfully.
Accumulator: ''
Beginning expect from spawn id(3).
Accumulator: ''
Expect timeout time: 5 seconds.
expect: Pty=spawn id(3), time=936574936, loop_time=5
expect: handle spawn id(3) ready.
expect: read 2 byte(s) from spawn id(3).
expect: handle spawn id(3) ready.
expect: read 56 byte(s) from spawn id(3).
passwd: all authentication tokens updated successfully
Matched pattern 1 ('successfully')!
Before match string: '\r\npasswd: all authentication tokens updated '
Match string: 'successfully'
After match string: '\r\n'
Returning from expect successfully.
Accumulator: '\r\n'
Closing spawn id(3).
Got EOF from spawn id(3).
spawn id(3) closed.
Pid 818 of spawn id(3) exited, Status: 0
<<<<<
- di-set chown root.root, chmod ug+s
- RedHat 6.0, program passwd standar/bawaan
- perl 5.00502, ngompile sendiri (tapi ini ngga begitu relevan)
- modul Expect 1.07, tetep di-patch seperti sebelumnya:
exec($cmd) -> exec(@_)
note: pastikan Expect.pm *yang anda pake* yang di-patch.
coba liat lokasinya dengan mengetikkan baris ini di shell
di direktori yang sama dengan script anda:
perl -MExpect -le'print $INC{Expect.pm}'
good luck :)
>>ada masalah lagi (ini berhubungan dengan PAM?). kalo password yang
>>kita masukkan terlalu pendek atau 'based on a dictionary word',
>>dan kita confirm password yang sama di prompt berikutnya, 'token
>>manipulation' gagal. (sementara kalo kita jalanin sebagai root/
>>bukan suid root, berhasil).
>
>ini salah tulis bukan nih ?
>bukan suid root "berhasil" jadi user biasa "berhasil"?
>jadi kalo suid root "gak berhasil passwd dengan gampang" ?
>soalnya menurut percobaan saya sih kalo root pasti "password
>bermasalah" sukses, tapi kalo user biasa passwd macem macem masalah
>mulai dari too short, too simple, doesnt enough different characcter,
>based on dictionary word.
>nah kalo suid root bisa "segampang" root bener gak ?
maksudnya, bukan suid root, tapi benar2 sebagai root.
cuma barusan saya coba lagi script suidroot ini (lihat
di atas) udah "segampang" root. entah waktu itu saya
salah/lupa ngeset apa/lagi ngantuk kali...
>itu yakin nih chpasswd ngak bisa suid root ?
ngga yakin :)
makanya di-tes lagi dong...
--
mailto:[EMAIL PROTECTED]
http://steven.haryan.to
Bandung Perl Mongers: http://bandung.pm.org
--------------------------------------------------------------------------------
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3
Pengelola dapat dihubungi lewat [EMAIL PROTECTED]
Hosted by http://www.Indoglobal.com