"headers": { "X-AMP-Version": "([\\d.]+)\\;version:\\1", "Set-Cookie": "^AMP=" },
特别注意:html全文匹配的规则一定要谨慎编写"html": [ "<div class=\"[^\"]*parbase", "_jcr_content", "/etc/designs/", "/etc/clientlibs/" ]
"url": "/cgi-bin/UCEditor\\?(?:.*&)?merchantid=."
"meta": { "generator": "webEdition", "DC.title": "webEdition" }
"script": [ "angular(?:\\-|\\.)([\\d.]*\\d)[^/]*\\.js\\;version:\\1", "/([\\d.]+(\\-?rc[.\\d]*)*)/angular(\\.min)?\\.js\\;version:\\1", "angular.*\\.js" ]
cpan -i WWW::Wappalyzer
clone https://github.com/tanjiti/FingerPrint.git
返回结果perl FingerPrint.pl www.xxx.com<uri 必选> tanjiti.json[指纹规则文件,可选]
(2) 从文件读取url列表进行批量指纹识别,并将结果输出到文件中{
"www.xxx.com": {
"blogs": [
"WordPress"
],
"web-servers": [
"Nginx"
],
"cdn": [
"CloudFlare"
],
"cms": [
"WordPress"
],
"font-scripts": [
"Google Font API"
],
"javascript-frameworks": [
"jQuery"
],
"javascript-graphics": [
"Javascript Infovis Toolkit"
]
}
}
perl FingerPrint.pl url.txt<uri 文件路径 必选> tanjiti.json[指纹规则文件,可选]
结果输出到 url.txt__fingerprint 文件里
指纹规则文件编写示例:
more tanjiti.json
"apps": {
"Discuz!":{
"website": "www.discuz.net/forum.php",
"cats": [ 1 ],
"meta": { "generator": "Discuz"},
"headers": {"Set-Cookie": "_lastact.*_sid|_sid.*_lastact|_sid.*smile|smile.*_sid"},
"url": "/uc_server[/$]|uc_client[/$]",
"html": "Powered by (?:Discuz!|<a href=\"http://www\\.discuz\\.net/\"|UCenter)",
"implies": "php"
},
"PHP": {
"website": "php.net",
"cats": [ 27 ],
"headers": { "Server": "php/?([\\d.]+)?\\;confidence:40\\;version:\\1", "X-Powered-By": "php/?([\\d.]+)?\\;confidence:40\\;version:\\1", "Set-Cookie": "PHPSESSID" },
"url": "\\.php(?:$|\\?)"
}
}
apt-get install php5-dev php-pear build-essential libv8-dev php5-curl
pecl install channel://pecl.php.net/v8js-0.1.3
echo extension=v8js.so >> /etc/php5/cli/php.ini
cp -R Wappalyzer/drivers/php/* .
cp Wappalyzer/share/js/wappalyzer.js js/
php版指纹识别程序结构如下:cp Wappalyzer/share/apps.json . (指纹规则文件) 该规则文件的正则编写的有问题,所以我使用的以前版本的规则文件
cp /usr/lib/perl5/WWW/apps.json .
php index.php www.tanjiti.com
接下来的优化输出为json格式与批量处理uri同perl版本。CloudFlare, , 100%, cdn
Javascript Infovis Toolkit, , 100%, javascript-graphics
jQuery, , 100%, javascript-frameworks
Nginx, , 100%, web-servers
PHP, 5.5.9, 100%, programming-languages
Ubuntu, , 100%, operating-systems
WordPress, 4.0, 100%, cms, blogs
vim test.js
var name = "tanjiti"
print(name," ",name.length, " characters")
vim testV8.php
运行<?php
$start = microtime(true);
$v8 = new V8Js();
try{
$file = "test.js";
$result = $v8->executeString(file_get_contents($file),$file);
} catch (Exception $e){
print $e->getMessage()."\n";
exit;
}
$end = microtime(true);
$duration = $end - $start;
echo "\n$duration us\n";
?>
php testV8.php
tanjiti 7 characters
0.018015146255493 us
vim testCurl.php
运行<?php
if ( php_sapi_name() !== 'cli' ) {
exit('Run me from the command line');
}
$url = !empty($argv[1]) ? $argv[1] : '';
if ( !$url ) {
echo "Usage: php {$argv[0]} <url>\n";
exit(0);
}
$result = curl($url);
var_dump($result);
function curl($url)
{
echo 'cURL request: ' . $url . "\n";
$ch = curl_init($url); //初始化
curl_setopt_array($ch, array(//设置选项
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_MAXREDIRS => 3, //重定向
CURLOPT_TIMEOUT => 5, //超时时间,单位s
CURLOPT_USERAGENT => 'Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1' //User-Agent
));
$response = curl_exec($ch);
if ( curl_errno($ch) !== 0 ) {
throw new Exception('cURL error: ' . curl_error($ch));
}
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ( $httpCode != 200 ) {
throw new Exception('cURL request returned HTTP code ' . $httpCode);
}
$result = new stdClass();
$result->url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$result->host = parse_url($result->url, PHP_URL_HOST);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$result->html = substr($response, $headerSize);
$result->html = mb_check_encoding($result->html, 'UTF-8') ? $result->html : utf8_encode($result->html);
$headers = trim(substr($response, 0, $headerSize));
$headers = preg_split('/^\s*$/m', $headers);
$headers = end($headers);
$lines = array_slice(explode("\r\n", $headers), 1);
foreach ( $lines as $line ) {
if ( strpos(trim($line), ': ') !== false ) {
list($key, $value) = explode(': ', $line);
$result->headers[strtolower($key)] = $value;
}
}
return $result;
}
?>
(3)正则php testCurl.php www.tanjiti.com/xss.php?a=lala
cURL request: www.tanjiti.com/xss.php?a=lala
object(stdClass)#1 (4) {
["url"]=>
string(37) "HTTP://www.tanjiti.com/xss.php?a=lala"
["host"]=>
string(15) "www.tanjiti.com"
["html"]=>
string(4) "lala"
["headers"]=>
array(11) {
["date"]=>
string(29) "Fri, 31 Oct 2014 10:08:50 GMT"
["content-type"]=>
string(9) "text/html"
["transfer-encoding"]=>
string(7) "chunked"
["connection"]=>
string(10) "keep-alive"
["set-cookie"]=>
string(133) "__cfduid=db05b3ccf4d2b4db66bb46b1058c616831414750130574; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.tanjiti.com; HttpOnly"
["x-powered-by"]=>
string(20) "PHP/5.5.9-1ubuntu4.4"
["x-content-type-options"]=>
string(7) "nosniff"
["x-frame-options"]=>
string(10) "sameorigin"
["x-xss-protection"]=>
string(12) "1;mode=block"
["server"]=>
string(16) "cloudflare-nginx"
["cf-ray"]=>
string(20) "181f0dbc131a036e-LAX"
}
}