search

If you need points-free download of csdn, point-free download of pudn, or point-free 51cto, please go to http://www.itziy.com/
and execute it from the command line. Direct php call will display the usage method
Function description
1. Support agent
2. Supports setting the number of recursive checks
3. Supports output type control and check content control

Function:
主要代替肉眼尽量多的抓取可能的请求包及url地址等,方便渗透测试
  1. error_reporting(E_ERROR | E_WARNING | E_PARSE);
  2. ini_set('memory_limit','1024M');
  3. set_time_limit(0);
  4. define('CHECK_A_TAG', false);
  5. define('CHECK_JS_TAG', true);
  6. define('CHECK_URL', true);
  7. define('SAVE_ERROR', true);
  8. $checkArr = array(
  9. '$.load',
  10. '.ajax',
  11. '$.post',
  12. '$.get',
  13. '.getJSON'
  14. );
  15. if ($argc die(showerror('sorry, parameter error', array('example: php debug.php url num filename header proxy', 'detail information:', 'url: target url address which you want to check it', 'num: The number of pages of recursive,default 3', 'filename: output filename default name ret.txt', 'header: The request header file default null', 'proxy: if you want to use proxy set it here default no use proxy')));
  16. if (!check_extension())
  17. die(showerror('extension curl not support', 'please open php curl extension support'));
  18. //global variable
  19. $url = trim($argv[1]);
  20. if (stripos($url, 'http') === false)
  21. $url = 'http://'.$url;
  22. $num = isset($argv[2]) ? intval($argv[2]) : 3;
  23. $output = isset($argv[3]) ? trim(str_replace("\", '/', $argv[3])) : str_replace("\", '/', dirname(__FILE__)).'/ret.txt';
  24. $header = null;
  25. $proxy = null;
  26. $host = null;
  27. if (isset($argv[4]))
  28. {
  29. $header = trim(str_replace("\", '/', $argv[4]));
  30. if (file_exists($header))
  31. $header = array_filter(explode("n", str_replace("r", '', file_get_contents($header))));
  32. else
  33. {
  34. $file = str_replace("\", '/', dirname(__FILE__)).'/'.$header;
  35. if (file_exists($file))
  36. $header = array_filter(explode("n", str_replace("r", '', file_get_contents($file))));
  37. else
  38. $header = null;
  39. }
  40. }
  41. if (isset($argv[5]))
  42. $proxy = trim($argv[5]);
  43. if (!is_array($header) || empty($header))
  44. $header = null;
  45. $result = check_valid_url($url);
  46. $outputArr = array();
  47. if (!empty($result))
  48. {
  49. $result = str_replace("r", '', $result);
  50. $result = str_replace("n", '', $result);
  51. $tmpArr = parse_url($url);
  52. if (!isset($tmpArr['host']))
  53. die(showerror('parse url error', 'can not get host form url: '.$url));
  54. $host = $tmpArr['host'];
  55. if (stripos($host, 'http') === false)
  56. $host = 'http://'.$host;
  57. unset($tmpArr);
  58. //check for current page
  59. if (!isset($outputArr[md5($url)]))
  60. {
  61. $outputArr[md5($url)] = $url;
  62. file_put_contents($output, $url."n", FILE_APPEND);
  63. echo 'url: ',$url,' find ajax require so save it',PHP_EOL;
  64. }
  65. work($result);
  66. }
  67. echo 'run finish',PHP_EOL;
  68. function work($result, $reverse = false)
  69. {
  70. global $num, $host, $outputArr, $checkArr, $output;
  71. if (!$result)
  72. return;
  73. $result = str_replace("r", '', $result);
  74. $result = str_replace("n", '', $result);
  75. while ($num > 0)
  76. {
  77. echo 'remain: ',$num,' now start to check for url address',PHP_EOL,PHP_EOL;
  78. preg_match_all('//i', $result, $match);
  79. if (CHECK_A_TAG && isset($match[2]) && !empty($match[2]))
  80. {
  81. foreach ($match[2] as $mc)
  82. {
  83. $mc = trim($mc);
  84. if ($mc == '#')
  85. continue;
  86. if (stripos($mc, 'http') === false)
  87. $mc = $host.$mc;
  88. if (($ret = check_valid_url($mc)))
  89. {
  90. if (!isset($outputArr[md5($mc)]))
  91. {
  92. $outputArr[md5($mc)] = $mc;
  93. file_put_contents($output, $mc."n", FILE_APPEND);
  94. echo 'url: ',$mc,' find ajax require so save it',PHP_EOL;
  95. }
  96. }
  97. }
  98. }
  99. //check for page url
  100. echo 'remain: ',$num,' now start to check for page url',PHP_EOL,PHP_EOL;
  101. preg_match_all('/(https?|ftp|mms)://([A-z0-9]+[_-]?[A-z0-9]+.)*[A-z0-9]+-?[A-z0-9]+.[A-z]{2,}(/.*)*/?/i', $result, $match);
  102. if (CHECK_URL && isset($match[2]) && !empty($match[2]))
  103. {
  104. foreach ($match[2] as $mc)
  105. {
  106. $mc = trim($mc);
  107. if ($mc == '#')
  108. continue;
  109. if (stripos($mc, 'http') === false)
  110. $mc = $host.$mc;
  111. if (($ret = check_valid_url($mc)))
  112. {
  113. if (!isset($outputArr[md5($mc)]))
  114. {
  115. $outputArr[md5($mc)] = $mc;
  116. file_put_contents($output, $mc."n", FILE_APPEND);
  117. echo 'url: ',$mc,' find ajax require so save it',PHP_EOL;
  118. }
  119. }
  120. }
  121. }
  122. //check for javascript ajax require
  123. echo 'remain: ',$num,' now start to check for javascript ajax require',PHP_EOL,PHP_EOL;
  124. preg_match_all('//i', $result, $match);
  125. if (CHECK_JS_TAG && isset($match[2]) && !empty($match[2]))
  126. {
  127. foreach ($match[2] as $mc)
  128. {
  129. $mc = trim($mc);
  130. if ($mc == '#')
  131. continue;
  132. if (stripos($mc, 'http') === false)
  133. $mc = $host.$mc;
  134. if (($ret = check_valid_url($mc)))
  135. {
  136. //check for current page
  137. foreach ($checkArr as $ck)
  138. {
  139. if (!isset($outputArr[md5($mc)]) && strpos($ret, $ck) !== false)
  140. {
  141. $outputArr[md5($mc)] = $mc;
  142. file_put_contents($output, $mc."n", FILE_APPEND);
  143. echo 'url: ',$mc,' find ajax require so save it',PHP_EOL;
  144. break;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. if ($reverse)
  151. return;
  152. //check for next page
  153. preg_match_all('//i', $result, $match);
  154. if (isset($match[2]) && !empty($match[2]))
  155. {
  156. echo 'check for next page, remain page counts: ',$num,PHP_EOL;
  157. foreach ($match[2] as $mc)
  158. {
  159. $mc = trim($mc);
  160. if ($mc == '#')
  161. continue;
  162. if (stripos($mc, 'http') === false)
  163. $mc = $host.$mc;
  164. echo 'check for next page: ',$mc,PHP_EOL;
  165. work(check_valid_url($mc), true);
  166. }
  167. }
  168. $num--;
  169. sleep(3);
  170. }
  171. }
  172. function check_valid_url($url)
  173. {
  174. if (stripos($url, 'http') === false)
  175. $url = 'http://'.$url;
  176. $ch = curl_init();
  177. curl_setopt($ch, CURLOPT_URL, $url);
  178. curl_setopt($ch, CURLOPT_HEADER, true);
  179. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  180. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  181. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
  182. if (!is_null($header))
  183. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  184. if (!is_null($proxy))
  185. curl_setopt($ch, CURLOPT_PROXY, $proxy);
  186. $ret = curl_exec($ch);
  187. $errinfo = curl_error($ch);
  188. curl_close($ch);
  189. unset($ch);
  190. if (!empty($errinfo) || ((strpos($ret, '200 OK') === false) && (strpos($ret, '302 Moved') === false)) || strpos($ret, '114so.cn') !== false)
  191. {
  192. showerror('check url: '.$url. ' find some errors', array($errinfo, $ret));
  193. if (SAVE_ERROR)
  194. file_put_contents(dirname(__FILE__).'/error.txt', $url."n", FILE_APPEND);
  195. return false;
  196. }
  197. return $ret;
  198. }
  199. function check_extension()
  200. {
  201. if (!function_exists('curl_init') || !extension_loaded('curl'))
  202. return false;
  203. return true;
  204. }
  205. function showerror($t, $c)
  206. {
  207. $str = "#########################################################################n";
  208. $str .= "# ".$t."n";
  209. if (is_string($c))
  210. $str .= "# ".$c;
  211. elseif (is_array($c) && !empty($c))
  212. {
  213. foreach ($c as $c1)
  214. $str .= "# ".$c1."n";
  215. }
  216. $str .= "n#########################################################################n";
  217. echo $str;
  218. unset($str);
  219. }
复制代码


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you modify data stored in a PHP session?How do you modify data stored in a PHP session?Apr 27, 2025 am 12:23 AM

TomodifydatainaPHPsession,startthesessionwithsession_start(),thenuse$_SESSIONtoset,modify,orremovevariables.1)Startthesession.2)Setormodifysessionvariablesusing$_SESSION.3)Removevariableswithunset().4)Clearallvariableswithsession_unset().5)Destroythe

Give an example of storing an array in a PHP session.Give an example of storing an array in a PHP session.Apr 27, 2025 am 12:20 AM

Arrays can be stored in PHP sessions. 1. Start the session and use session_start(). 2. Create an array and store it in $_SESSION. 3. Retrieve the array through $_SESSION. 4. Optimize session data to improve performance.

How does garbage collection work for PHP sessions?How does garbage collection work for PHP sessions?Apr 27, 2025 am 12:19 AM

PHP session garbage collection is triggered through a probability mechanism to clean up expired session data. 1) Set the trigger probability and session life cycle in the configuration file; 2) You can use cron tasks to optimize high-load applications; 3) You need to balance the garbage collection frequency and performance to avoid data loss.

How can you trace session activity in PHP?How can you trace session activity in PHP?Apr 27, 2025 am 12:10 AM

Tracking user session activities in PHP is implemented through session management. 1) Use session_start() to start the session. 2) Store and access data through the $_SESSION array. 3) Call session_destroy() to end the session. Session tracking is used for user behavior analysis, security monitoring, and performance optimization.

How can you use a database to store PHP session data?How can you use a database to store PHP session data?Apr 27, 2025 am 12:02 AM

Using databases to store PHP session data can improve performance and scalability. 1) Configure MySQL to store session data: Set up the session processor in php.ini or PHP code. 2) Implement custom session processor: define open, close, read, write and other functions to interact with the database. 3) Optimization and best practices: Use indexing, caching, data compression and distributed storage to improve performance.

Explain the concept of a PHP session in simple terms.Explain the concept of a PHP session in simple terms.Apr 26, 2025 am 12:09 AM

PHPsessionstrackuserdataacrossmultiplepagerequestsusingauniqueIDstoredinacookie.Here'showtomanagethemeffectively:1)Startasessionwithsession_start()andstoredatain$_SESSION.2)RegeneratethesessionIDafterloginwithsession_regenerate_id(true)topreventsessi

How do you loop through all the values stored in a PHP session?How do you loop through all the values stored in a PHP session?Apr 26, 2025 am 12:06 AM

In PHP, iterating through session data can be achieved through the following steps: 1. Start the session using session_start(). 2. Iterate through foreach loop through all key-value pairs in the $_SESSION array. 3. When processing complex data structures, use is_array() or is_object() functions and use print_r() to output detailed information. 4. When optimizing traversal, paging can be used to avoid processing large amounts of data at one time. This will help you manage and use PHP session data more efficiently in your actual project.

Explain how to use sessions for user authentication.Explain how to use sessions for user authentication.Apr 26, 2025 am 12:04 AM

The session realizes user authentication through the server-side state management mechanism. 1) Session creation and generation of unique IDs, 2) IDs are passed through cookies, 3) Server stores and accesses session data through IDs, 4) User authentication and status management are realized, improving application security and user experience.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!