天天看點

nmap -- [nse - scripts] - http-title

[email聽protected]:~/nmap/scripts# nmap -Pn -sS -p 80 --script /home/offensive/nmap/script/http-title.nse www.baidu.com

Starting Nmap 6.47 ( http://nmap.org ) at 2014-10-08 22:44 EDT

Nmap scan report for www.baidu.com (119.75.217.56)

Host is up (0.0047s latency).

Other addresses for www.baidu.com (not scanned): 119.75.218.77

PORT聽聽 STATE SERVICE

80/tcp open聽 http

| http-title:

|聽聽 body: <!DOCTYPE html>

| <html>

| <head>

| <meta charset="gbk">

| <title>\xB0\xD9\xB6\xC8--\xC4\xFA\xB5\xC4\xB7\xC3\xCE\xCA\xB3\xF6\xB4\xED\xC1\xCB</title>

| <style type="text/css">

| 聽聽 聽body{margin:0;padding:0;font-size:14px;font-family:"\xCB\xCE\xCC\xE5",Arial, Helvetica, sans-serif;}

| 聽聽 聽img,ul,li,form,h2,ol{border:0;padding:0;margin:0;list-style:none;}

| 聽聽 聽.cl{clear:both;height:0px;line-height:0px;font-size:0px;overflow:hidden;}

| 聽聽 聽input{vertical-align:middle;}

| 聽聽 聽a:link{color:#0033cc}

| 聽聽 聽a:visited{color:#800080;}

| 聽聽 聽a:hover{color:#800080;}

| 聽聽 聽a:actived{color:#800080;}

| 聽聽 聽#content{width:95%;align:center;margin:0 auto聽 0;}

| 聽聽 聽.logo{float:left;width:141px;margin:10px 0 0 0;}

| 聽聽 聽.title{float:right;width:;line-height:24px;background:#e5ecf9;margin:20px 0 0 0;padding-left:8px;}

| 聽聽 聽.title a{margin-left:320px;}

| 聽聽 聽.tip{font-size:18px;margin:25px 0 25px 5px;*margin:25px 0 25px 5px;}

| 聽聽 聽.reason{margin:25px 0 33px 5px;*margin:25px 0 30px 5px;}

| 聽聽 聽.reason li{line-height:24px;height:24px;}

| 聽聽 聽.searchbox{margin:0 0 40px 8px;*margin:0 0 40px 8px;}

| 聽聽 聽.help{margin:0 0 100px 5px;}

| 聽聽 聽.footer{margin:50px 0 20px 0;*margin:50px 0 20px 0;text-align:center;color:#666666;}

| 聽聽 聽.footer a{color:#666666;}

| </style>

| </head>

| <body>

| <table width="95%" align="center">

| 聽聽 聽<tr height="60">

| 聽聽 聽聽聽 聽<td height="65" valign="top" width="141"><a href="http://www.baidu.com/" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" ><img src="http://www.baidu.com/search/img/logo.gif" alt="\xB5\xBD\xB0\xD9\xB6\xC8\xCA\xD7\xD2\xB3" /></a></td>

| 聽聽 聽聽聽 聽<td valign="bottom">

| 聽聽 聽聽聽 聽聽聽 聽<table cellspacing="0" cellpadding="0" width="100%">

| 聽聽 聽聽聽 聽聽聽 聽聽聽 聽<tr bgcolor="#e5ecf9">

| 聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽<td height="24">&nbsp;<b class="p1">\xC4\xFA\xB5\xC4\xB7\xC3\xCE\xCA\xB3\xF6\xB4\xED\xC1\xCB</b></td>

| 聽聽 聽聽聽 聽聽聽 聽聽聽 聽聽聽 聽<td class="p2" height="24"><div align="right"><a href="http://www.baidu.com/" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" >\xB0\xD9\xB6\xC8\xCA\xD7\xD2\xB3</a>聽 |聽 <a href="http://www.baidu.com/search/jiqiao.html" target="_blank" rel="external nofollow" >\xB0\xEF\xD6\xFA\xD6\xD0\xD0\xC4</a> &nbsp;</div></td>

| 聽聽 聽聽聽 聽聽聽 聽聽聽 聽</tr>

| 聽聽 聽聽聽 聽聽聽 聽聽聽 聽<tr><td class="p2" height="20" colspan="2"></td></tr>

| 聽聽 聽聽聽 聽聽聽 聽</table>

| 聽聽 聽聽聽 聽</td>

| 聽聽 聽</tr>

| </table>

| <div id="content">

| 聽聽 聽<h2 class="tip" style="padding-left:144px"><p>\xBA\xDC\xB1\xA7\xC7\xB8\xA3\xAC\xC4\xFA\xD2\xAA\xB7\xC3\xCE\xCA\xB5\xC4\xD2\xB3\xC3\xE6\xB2\xBB\xB4\xE6\xD4\xDA!<br><br></p><hr color="#dddddd" size="1"></h2>

| </div>

| <div id="content">

| <ol class="reason" style="padding-left:144px">

|聽聽聽 聽聽聽 聽<li> 1. \xC7\xEB\xBC\xEC\xB2\xE9\xC4\xFA\xB7\xC3\xCE\xCA\xB5\xC4\xCD\xF8\xD6\xB7\xCA\xC7\xB7\xF1\xD5\xFD\xC8\xB7\xA1\xA3</li><br>

|聽聽聽聽聽聽聽聽 <li> 2. \xC8\xE7\xB9\xFB\xC4\xFA\xB2\xBB\xC4\xDC\xC8\xB7\xC8\xCF\xB7\xC3\xCE\xCA\xB5\xC4\xCD\xF8\xD6\xB7\xA3\xAC\xC7\xEB\xE4\xAF\xC0\xC0<a href="http://www.baidu.com/more/index.html" target="_blank" rel="external nofollow" >\xB0\xD9\xB6\xC8\xB8\xFC\xB6\xE0</a>\xD2\xB3\xC3\xE6\xB2\xE9\xBF\xB4\xB8\xFC\xB6\xE0\xCD\xF8\xD6\xB7\xA1\xA3</li><br>

|聽聽聽聽聽聽聽聽 <li> 3. \xD6\xB1\xBD\xD3\xCB\xD1\xCB\xF7\xD2\xAA\xB2\xE9\xD5\xD2\xB5\xC4\xC4\xDA\xC8\xDD\xA3\xBA</li>

|聽聽聽聽 <li class="searchbox"><br>

|聽聽聽 聽聽聽 聽<form action="http://www.baidu.com/s" name="f">

|聽聽聽聽聽聽聽 聽聽聽 聽<input type="text" name="wd" size="35" maxlength="100"><input type="hidden" name="cl" value="3"><input type="hidden" name="tn" value="baiduerr"><input type="submit" value="\xB0\xD9\xB6\xC8\xD2\xBB\xCF\xC2">

| 聽聽 聽聽 </form></li>

|聽聽聽聽 <li class="help">

|聽聽聽聽聽聽 4.\xC8\xE7\xD3\xD0\xC8\xCE\xBA\xCE\xD2\xE2\xBC\xFB\xBB\xF2\xBD\xA8\xD2\xE9\xA3\xAC\xC7\xEB\xBC\xB0\xCA\xB1<a href="http://qingting.baidu.com/" target="_blank" rel="external nofollow" >\xB7\xB4\xC0\xA1\xB8\xF8\xCE\xD2\xC3\xC7</a>\xA1\xA3

|聽聽聽聽聽聽聽聽 <br><br><br>

|聽聽聽聽聽聽聽聽 <b>\xCD\xC6\xBC\xF6\xC4\xFA\xB7\xC3\xCE\xCA\xA3\xBA</b><a href="http://news.baidu.com/" target="_blank" rel="external nofollow" >\xD0\xC2\xCE\xC5</a>\xA1\xA1<a href="http://tieba.baidu.com/" target="_blank" rel="external nofollow" >\xCC\xF9\xB0\xC9</a>\xA1\xA1<a href="http://zhidao.baidu.com/" target="_blank" rel="external nofollow" >\xD6\xAA\xB5\xC0</a>\xA1\xA1<a href="http://music.baidu.com/" target="_blank" rel="external nofollow" >\xD2\xF4\xC0\xD6</a>\xA1\xA1<a href="http://image.baidu.com/" target="_blank" rel="external nofollow" >\xCD\xBC\xC6\xAC</a>\xA1\xA1<a href="http://video.baidu.com/" target="_blank" rel="external nofollow" >\xCA\xD3\xC6\xB5</a>\xA1\xA1<a href="http://map.baidu.com/" target="_blank" rel="external nofollow" >\xB5\xD8\xCD\xBC</a>\xA1\xA1<a href="http://baike.baidu.com/" target="_blank" rel="external nofollow" >\xB0\xD9\xBF\xC6</a>\xA1\xA1<a href="http://wenku.baidu.com/" target="_blank" rel="external nofollow" >\xCE\xC4\xBF\xE2</a>\xA1\xA1<a href="http://www.hao123.com/" target="_blank" rel="external nofollow" >hao123</a>

|聽聽聽聽 </li>\xA1\xA1</ol>

|

|聽聽聽聽 <div class="footer">&#169; 2014 Baidu&nbsp;<a href="http://www.baidu.com/duty/index.html" target="_blank" rel="external nofollow" >\xC3\xE2\xD4\xF0\xC9\xF9\xC3\xF7</a></div>

| </div>

| </body>

| </html>

|聽聽 header:

|聽聽聽聽 cache-control: max-age=86400

|聽聽聽聽 server: Apache

|聽聽聽聽 content-type: text/html

|聽聽聽聽 last-modified: Tue, 31 Dec 2013 07:53:50 GMT

|聽聽聽聽 connection: Close

|聽聽聽聽 expires: Fri, 10 Oct 2014 02:44:54 GMT

|聽聽聽聽 vary: Accept-Encoding,User-Agent

|聽聽聽聽 date: Thu, 09 Oct 2014 02:44:54 GMT

|聽聽聽聽 content-length: 3349

|聽聽聽聽 set-cookie: BAIDUID=9EE14A69D1C859B9E344E25F35B37D37:FG=1; expires=Fri, 09-Oct-15 02:44:54 GMT; max-age=31536000; path=/; domain=.baidu.com; version=1

|聽聽聽聽 etag: "d15-4eecfdc639f80"

|聽聽聽聽 p3p: CP=" OTI DSP COR IVA OUR IND COM "

|聽聽聽聽 accept-ranges: bytes

|聽聽 status: 200

|聽聽 ssl: false

|聽聽 location:

|聽聽聽聽 http://www.baidu.com/search/error.html

|聽聽 cookies:

|聽聽聽 聽

|聽聽聽聽聽聽 path: /

|聽聽聽聽聽聽 value: 9EE14A69D1C859B9E344E25F35B37D37:FG=1

|聽聽聽聽聽聽 domain: .baidu.com

|聽聽聽聽聽聽 expires: Fri, 09-Oct-15 02:44:54 GMT

|聽聽聽聽聽聽 name: BAIDUID

|聽聽聽聽聽聽 max-age: 31536000

|聽聽聽聽聽聽 version: 1

|聽聽 rawheader:

|聽聽聽聽 Date: Thu, 09 Oct 2014 02:44:54 GMT

|聽聽聽聽 Server: Apache

|聽聽聽聽 P3P: CP=" OTI DSP COR IVA OUR IND COM "

|聽聽聽聽 Set-Cookie: BAIDUID=9EE14A69D1C859B9E344E25F35B37D37:FG=1; expires=Fri, 09-Oct-15 02:44:54 GMT; max-age=31536000; path=/; domain=.baidu.com; version=1

|聽聽聽聽 Last-Modified: Tue, 31 Dec 2013 07:53:50 GMT

|聽聽聽聽 ETag: "d15-4eecfdc639f80"

|聽聽聽聽 Accept-Ranges: bytes

|聽聽聽聽 Content-Length: 3349

|聽聽聽聽 Cache-Control: max-age=86400

|聽聽聽聽 Expires: Fri, 10 Oct 2014 02:44:54 GMT

|聽聽聽聽 Vary: Accept-Encoding,User-Agent

|聽聽聽聽 Connection: Close

|聽聽聽聽 Content-Type: text/html

|聽聽聽 聽

|_聽 status-line: HTTP/1.1 200 OK

Nmap done: 1 IP address (1 host up) scanned in 0.81 seconds

-- The Head Section --

description = [[

Shows the title of the default page of a web server.

The script will follow no more than one HTTP redirect, and only if the

redirection leads to the same host. The script may send a DNS query to

determine whether the host the redirect leads to has the same IP address as

the original target.

]]

author = "Diman Todorov"

license = "Same as Nmap--See http://nmap.org/book/man-legal.html"

categories = {"default", "discovery", "safe"}

local http = require "http"

local nmap = require "nmap"

local shortport = require "shortport"

local stdnse = require "stdnse"

local string = require "string"

-- The Rule Section --

portrule = shortport.http

-- The Action Section --

action = function(host, port)

聽聽聽 local response, redirect_url, status, title

聽聽聽 local url = "/index.html"

聽聽聽 response = http.get(host, port, url)

聽聽聽 -- check for a redirect

聽聽聽 -- return response.header["server"]聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽 -- return response.status-line -- Error

聽聽聽 if response.location then

聽聽聽聽聽聽聽 redirect_url = response.location[#response.location]

聽聽聽聽聽聽聽 status = response.status

聽聽聽聽聽聽聽 if status and tostring(status):match("30%d") then

聽聽聽聽聽聽聽聽聽聽聽 return {redirect_url = redirect_url}, ("Did you follow redirect to %s"):format(redirect_url)

聽聽聽聽聽聽聽 end

聽聽聽 end

聽聽聽 if (not(response.body)) then

聽聽聽聽聽聽聽 return

聽聽聽 end

聽聽聽 -- try and match title tags

聽聽聽 --聽 <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

聽聽聽 title = response.body:match("<[Tt][Ii][Tt][Ll][Ee][^>]*>([^<]*)</[Tt][Ii][Tt][Ll][Ee]>")

聽聽聽 local display_title = title

聽聽聽 if display_title and display_title ~= "" then

聽聽聽聽聽聽聽 display_title = string.gsub(display_title, "[\n\r\t]", "")

聽聽聽聽聽聽聽 if #display_title > 65 then

聽聽聽聽聽聽聽聽聽聽聽 display_title = string.sub(display_title, 1, 62) .. "..."

聽聽聽聽聽聽聽 end

聽聽聽 else

聽聽聽聽聽聽聽 display_title = "Site doesn't have a title"

聽聽聽聽聽聽聽 if (response.header and response.header["content-type"]) then

聽聽聽聽聽聽聽聽聽聽聽 display_title = display_title .. (" (%s) ."):format(response.header["content-type"])

聽聽聽聽聽聽聽 else

聽聽聽聽聽聽聽聽聽聽聽 display_title = display_title .. "."

聽聽聽聽聽聽聽 end

聽聽聽 end

聽聽聽 local output_tab = stdnse.output_table()

聽聽聽 output_tab.title = title

聽聽聽 output_tab.redirect_url = redirect_url

聽聽聽 local output_str = display_title

聽聽聽 if redirect_url then

聽聽聽聽聽聽聽 output_str = output_str .. "\n" .. ("Requested resource was %s"):format(redirect_url)

聽聽聽 end

聽聽聽 return output_tab, output_str

end

local response = http.get(host, port, url)

response.body

response.header

response.status

response.ssl

response.location

response.cookies

response.rawheader

response.status-line