jcpunk has asked for the wisdom of the Perl Monks concerning the following question:
as you can tell from my code I am sending everything up until the cat'ing of /etc/passwd to /dev/null but that doesnt stop my output from looking like this:#!/usr/bin/perl -w use strict; use Expect; |++; print "Content-type: text/html\n\n<html>"; my $username="testuser"; my $password="password"; my $host="localhost"; my $timeout=7; my $exp = new Expect; # create our important expet object telnet_login($username,$password,$host,\$exp); $exp->expect($timeout, ['ncorrect', sub { print "<center>ERROR:<br>Login Incorre +ct, check username or password</center>\n"; &html_stop; die; } ], [timeout => sub { $exp->log_file("/dev/null"); $exp->send("/bin/sh\n"); $exp->send("/usr/bin/last -10 $username\n"); $exp->log_file(\&formatoutput); $exp->send("/bin/cat /etc/passwd\n"); } ], ); $exp->soft_close(); #gentially close this object, it has been nice to +us we hope sub formatoutput { my $input = shift; chomp($input); $input =~ tr/\r//; $input =~ s/\n/<br>/g; unless( ($input eq "\$ ") || ($input eq "\/") || ($input eq "bin/sh") || ($input eq "bin\/sh") || ($input eq "/bin/sh") || ($input eq "/bin/sh ") ) # things not to print go in this ^ statement { print"<b>${input}</b><p>\n"; } } sub telnet_login { my ($username, $password, $host, $exp) = @_; my $TELNET = "/usr/bin/telnet"; my $timeout = 7; $$exp->raw_pty(1); #treat this terminal as a raw file $$exp->log_stdout(0); #do not show terminal output to STD Out $$exp->spawn("$TELNET $host") || die "Cannot open telnet\n"; # try + to startup $TELNET $$exp->expect($timeout, ['ogin:', sub { $$exp->send("$username\n"); exp_conti +nue; } ], ['assword:', sub { $$exp->send("$password\n"); } ], [timeout => sub { die "<center>ERROR: <BR>A timeout h +ast occured at login</center>\n"; } ], ); } </html>
any thoughts as to why I get both the bin/sh and the last sent to my output?bin/sh testuser pts/5 localhost Mon Jun 16 09:16 still logged in testuser pts/5 localhost Mon Jun 16 09:14 - 09:15 (00:00) testuser pts/5 localhost Mon Jun 16 09:09 - 09:09 (00:00) testuser pts/5 localhost Mon Jun 16 09:08 - 09:08 (00:00) testuser pts/6 localhost Mon Jun 16 09:07 - 09:08 (00:00) testuser pts/5 localhost Mon Jun 16 09:07 - 09:07 (00:00) testuser pts/5 testuser Fri Jun 13 15:54 - 15:55 (00:00) testuser pts/5 testuser Fri Jun 13 15:53 - 15:54 (00:00) testuser pts/5 testuser Fri Jun 13 15:52 - 15:53 (00:00) testuser pts/5 testuser Fri Jun 13 15:52 - 15:52 (00:00) root:x:0:1::/:/sbin/sh daemon:x:1:1::/: bin:x:2:2::/usr/bin: sys:x:3:3::/: adm:x:4:4:Admin:/var/adm: lp:x:71:8:Line Printer Admin:/usr/spool/lp: uucp:x:5:5:uucp Admin:/usr/lib/uucp: nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico listen:x:37:4:Network Admin:/usr/net/nls: nobody:x:60001:60001:Nobody:/: noaccess:x:60002:60002:No Access User:/: nobody4:x:65534:65534:SunOS 4.x Nobody:/: fast:x:204:1:FastTrack Server:/web:/bin/sh postfix:x:100:1:postfix:/dev/null:/bin/false vscan:x:1001:10:Amavis User:/usr/local/encap/amavis-perl-11:/bin/sh sshd:x:22000:22000:SSHD privsep User:/var/empty:/bin/false
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: phantom log from hell?
by pzbagel (Chaplain) on Jun 16, 2003 at 15:20 UTC | |
by jcpunk (Friar) on Jun 16, 2003 at 15:32 UTC | |
|
Re: phantom log from hell?
by monsieur_champs (Curate) on Jun 16, 2003 at 15:25 UTC | |
by jcpunk (Friar) on Jun 16, 2003 at 15:46 UTC | |
|
Re: phantom log from hell?
by bbfu (Curate) on Jun 17, 2003 at 00:32 UTC | |
by jcpunk (Friar) on Jun 17, 2003 at 14:42 UTC | |
|
Re: phantom log from hell?
by pzbagel (Chaplain) on Jun 16, 2003 at 17:24 UTC | |
by jcpunk (Friar) on Jun 16, 2003 at 18:17 UTC | |
by pzbagel (Chaplain) on Jun 16, 2003 at 19:38 UTC | |
by jcpunk (Friar) on Jun 16, 2003 at 19:45 UTC |