I'm trying to connect to a server and earn the banner, but I'm not succeeding.
My script runs in theory as follows:
Get port and IP but I can use port e IP static on variables.
Execute the socket, with timeout 7
If connected
Wait the response e use the handle <> to get banner
Execute print to show banner.
use IO::Socket::INET
$myip = <stdin>; # $myip is the remote IP to connect
chomp($myip);
$myport = <stdin>; # $myport is the remote port to connect
chomp($myport);
# This part of data entry tends to use IP and URL frames, but it doesn't work either.
$sock=IO::Socket::INET‐>new("$myip:$myport");
if($sock){
$remote=IO::Socket::INET‐>new(
Proto=>"tcp",
PeerAddr=>$myip,
PeerPort=>$myport,
Timeout=>"7"
);
$line=<$remote>;
print $line;
}
When I run the code, the connection is executed, but I don't gain banner. I cannot find an error in this code. I looked for a solution on other websites, but I couldn't find it. It's always the same examples and they don't change.