我正在尝试使用以下代码使用伪tty进行FTP。 在数据包捕获中,我可以看到代码在请求命令用户中发送用户名root但它没有发送密码(即请求命令中没有发送请求参数:PASS)。有什么建议吗?
#!/usr/bin/perl
use warnings;
use strict;
use Net::Telnet;
use IO::Pty;
use POSIX 'setsid';
use Getopt::Long;
my $host = "192.168.1.121";
my $user = "root";
my $ssh = do_cmd('ftp',$host);
my $shell = Net::Telnet -> new(Fhopen => $ssh);
$shell -> binmode(1);
$shell -> cmd(String => 'root', Prompt => '/[a-z]/');
$shell -> cmd(String => 'password', Prompt => '/[a-z]/');
my @lines = $shell->cmd(String => 'ls', Prompt => '/[a-z]/');
print @lines;
print "\n";
sub do_cmd{
my ($cmd,@args) = @_;
my $pty = IO::Pty -> new;
defined (my $child = fork);
return $pty if $child;
setsid();
my $tty = $pty -> slave;
close $pty;
STDIN -> fdopen($tty,"<");
STDOUT -> fdopen($tty,">");
STDERR -> fdopen ($tty, ">");
close $tty;
$| = 1;
exec $cmd,@args;
}