#!/usr/bin/perl -w use strict; use IO::Socket::INET; my $port = 12345; my $server = IO::Socket::INET->new( LocalAddr => '127.0.0.1', LocalPort => $port, Listen => 10, Reuse => 1, ) or die "failed to listen: $!"; my $client = $server->accept; my $cf = $client->fileno; open(STDIN, "<&$cf") || die "Couldn't dup client to stdin"; open(STDOUT, ">&$cf") || die "Couldn't dup client to stdout"; print "The client should see this message.\n"; close($client); #### #!/usr/bin/perl -w use strict; use IO::Socket::SSL; my $port = 12345; my $server = IO::Socket::SSL->new( LocalAddr => '127.0.0.1', LocalPort => $port, Listen => 10, Reuse => 1, SSL_cert_file => 'cert.pem', SSL_key_file => 'key.pem', ) or die "failed to listen: $!"; my $client = $server->accept; my $cf = $client->fileno; open(STDIN, "<&$cf") || die "Couldn't dup client to stdin"; open(STDOUT, ">&$cf") || die "Couldn't dup client to stdout"; print "The client should see this message.\n"; close($client); #### $ nc localhost 12345 The client should see this message. $ nc --ssl localhost 12345 #### #!/usr/bin/perl -w package NetServer; use strict; use base qw(Net::Server::Fork); sub process_request { my $self = shift; ### COMMAND PIPE print "Executing Command Pipe\n"; open DATA, "/usr/bin/echo ==== Command Pipe Successful|" or die "Couldn't open command: $!"; while (defined(my $line = )) { chomp($line); print "$line\n"; } close DATA; ### SYSTEM COMMAND print "Executing System Command\n"; system("/usr/bin/echo ==== System Command Successful"); ### EXEC COMMAND print "Executing Exec Command\n"; exec "/usr/bin/echo ==== Exec Command Successful" or die "Couldn't exec command: $!"; } NetServer->run(port=>12345); #### #!/usr/bin/perl -w package NetServer; use strict; use base qw(Net::Server::Fork); sub SSL_key_file { "key.pem" } sub SSL_cert_file { "cert.pem" } sub process_request { my $self = shift; ### COMMAND PIPE print "Executing Command Pipe\n"; open DATA, "/usr/bin/echo ==== Command Pipe Successful|" or die "Couldn't open command: $!"; while (defined(my $line = )) { chomp($line); print "$line\n"; } close DATA; ### SYSTEM COMMAND print "Executing System Command\n"; system("/usr/bin/echo ==== System Command Successful"); ### EXEC COMMAND print "Executing Exec Command\n"; exec "/usr/bin/echo ==== Exec Command Successful" or die "Couldn't exec command: $!"; } #NetServer->run(proto => 'ssl', port=>12345); NetServer->run(proto => 'ssleay', port=>12345); #### $ nc localhost 12345 Executing Command Pipe ==== Command Pipe Successful Executing System Command ==== System Command Successful Executing Exec Command ==== Exec Command Successful $ nc --ssl localhost 12345 Executing Command Pipe ==== Command Pipe Successful Executing System Command Executing Exec Command