what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

NetProx_pl.txt

NetProx_pl.txt
Posted Apr 28, 2006
Authored by AdityaSood | Site rxlabs.metaeye.org

NetProx Proxy Redirector - a proxy redirector written in PERL for connection redirection between remote machines.

tags | remote, perl
systems | unix
SHA-256 | 7bb571bfb44fe6f5af0880fd8cc2ca70bcb72f15d7bc2483d40bae54f239f0f2

NetProx_pl.txt

Change Mirror Download

printf STDOUT "\t\tNetProx Port Redirector\n";
printf STDOUT "\t\t-----====[NP]====------\n\n\n";
printf STDOUT "\t\t--==[CODED BY:-ZeroKnock]==--\n";
printf STDOUT "\t\t-----====[PERL]====-----\n\n";
printf STDOUT "USAGE: NetProx [ --remote host ] [ --local interface ] [ --service service ]\n";

use strict;
use Getopt::Long;
use Net::hostent;
use IO::Socket;
use POSIX ":sys_wait_h";

my (
%Children,
$REMOTE,
$LOCAL,
$SERVICE,
$proxy_server,
$ME,
);

($ME = $0) =~ s,.*/,,;
check_args();
start_proxy();
service_clients();
die "NOT REACHED";



sub check_args {
GetOptions(
"remote=s" => \$REMOTE,
"local=s" => \$LOCAL,
"service=s" => \$SERVICE,
) or die <<EOUSAGE;
usage: $0 [ --remote host ] [ --local interface ] [ --service service ]
EOUSAGE
die "[-]Need Remote Host!\n" unless $REMOTE;
die "[-]Need Local or Service\n" unless $LOCAL || $SERVICE;
}



sub start_proxy
{
my @proxy_server_config = (
Proto => 'tcp',
Reuse => 1,
Listen => SOMAXCONN,
);

push @proxy_server_config, LocalPort => $SERVICE if $SERVICE;
push @proxy_server_config, LocalAddr => $LOCAL if $LOCAL;
$proxy_server = IO::Socket::INET->new(@proxy_server_config)

or die "Can't create proxy server: $@";
print "[Proxy server on ", ($LOCAL || $SERVICE), " initialized.]\n";
}



sub service_clients {
my (
$local_client, # someone internal wanting out
$lc_info, # local client's name/port information
$remote_server, # the socket for escaping out
@rs_config, # temp array for remote socket options
$rs_info, # remote server's name/port information
$kidpid, # spawned child for each connection
);

$SIG{CHLD} = \&REAPER; # harvest the moribund

accepting();


while ($local_client = $proxy_server->accept())
{
$lc_info = peerinfo($local_client);
set_state("servicing local $lc_info");
printf "[Connect from $lc_info]\n";

@rs_config = (
Proto => 'tcp',
PeerAddr => $REMOTE,
);
push(@rs_config, PeerPort => $SERVICE) if $SERVICE;

print "[Connecting to $REMOTE...";
set_state("connecting to $REMOTE"); # see below
$remote_server = IO::Socket::INET->new(@rs_config)
or die "remote server: $@";
print "done]\n";

$rs_info = peerinfo($remote_server);
set_state("connected to $rs_info");

$kidpid = fork();
die "Cannot fork" unless defined $kidpid;
if ($kidpid) {
$Children{$kidpid} = time();
close $remote_server;
close $local_client;
next;
}


close $proxy_server;
$kidpid = fork();
die "Cannot fork" unless defined $kidpid;


if ($kidpid) {
set_state("$rs_info --> $lc_info");
select($local_client); $| = 1;
print while <$remote_server>;
kill('TERM', $kidpid); # kill my twin cause we're done
}
# this is the fork's child, the master's grandchild
else {
set_state("$rs_info <-- $lc_info");
select($remote_server); $| = 1;
print while <$local_client>;
printf "\n";
# kill('TERM', getppid());
}
exit;
} continue {
accepting();
}
}

sub peerinfo
{
my $sock = shift;
my $hostinfo = gethostbyaddr($sock->peeraddr);
return sprintf("%s:%s",
$hostinfo->name || $sock->peerhost,
$sock->peerport);
}

sub set_state { $0 = "$ME [@_]" }

sub accepting
{
set_state("[*]Accepting Proxy For " . ($REMOTE || $SERVICE));
}

sub REAPER
{
my $child;
my $start;
while (($child = waitpid(-1,WNOHANG)) > 0) {
if ($start = $Children{$child}) {
my $runtime = time() - $start;
printf "Child $child ran %dm%ss\n",
$runtime / 60, $runtime % 60;
delete $Children{$child};
} else {
print "Bizarre kid $child exited $?\n";
}
}
$SIG{CHLD} = \&REAPER;
};
Login or Register to add favorites

File Archive:

May 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    44 Files
  • 2
    May 2nd
    5 Files
  • 3
    May 3rd
    11 Files
  • 4
    May 4th
    0 Files
  • 5
    May 5th
    0 Files
  • 6
    May 6th
    28 Files
  • 7
    May 7th
    3 Files
  • 8
    May 8th
    4 Files
  • 9
    May 9th
    54 Files
  • 10
    May 10th
    12 Files
  • 11
    May 11th
    0 Files
  • 12
    May 12th
    0 Files
  • 13
    May 13th
    18 Files
  • 14
    May 14th
    11 Files
  • 15
    May 15th
    17 Files
  • 16
    May 16th
    13 Files
  • 17
    May 17th
    22 Files
  • 18
    May 18th
    0 Files
  • 19
    May 19th
    0 Files
  • 20
    May 20th
    17 Files
  • 21
    May 21st
    18 Files
  • 22
    May 22nd
    7 Files
  • 23
    May 23rd
    111 Files
  • 24
    May 24th
    27 Files
  • 25
    May 25th
    0 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    6 Files
  • 28
    May 28th
    12 Files
  • 29
    May 29th
    31 Files
  • 30
    May 30th
    22 Files
  • 31
    May 31st
    18 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close