By Aung Khant
—
Last update
Jul 1, 2008
—
Installed
172 times.
// ==UserScript==
// @name WebPageFingerPrint
// @namespace yehg.net
// @description WebPageFingerPrinting script without having to view html source. Firebug is required. Sometimes, clicking each in WebDeveloper Toolbar is tedious.I'd like to read a summerized view of current web page first. Here this script comes in.
// @author Aung Khant (http://yehg.net/lab)
// @include *
// ==/UserScript==
var invalidext = /(js|vbs|jpg|jpeg|gif|png|css|txt)$/;
var printdata = "<h3>YEHG WebPage FingerPrint Result <span target='_blank' style='color:yellow!important;text-decoration:none;cursor:pointer;' onclick='document.getElementById(\"yehgfingerprint\").style.display=\"none\";document.getElementById(\"yehgfingerprint2\").style.display=\"\";'>[x]</span></h3><br>";
if(!invalidext.test(document.URL))
{
unsafeWindow.yehgupx = 0;
unsafeWindow.yehgshowFingerprint = function()
{
if(unsafeWindow.document.getElementById("yehgfingerprint"))
{
unsafeWindow.document.getElementById("yehgfingerprint").style.display = '';
unsafeWindow.document.getElementById("yehgfingerprint").style.opacity = "0." + unsafeWindow.yehgupx;
unsafeWindow.yehgupx++;
if(printdata.length<233 || unsafeWindow.yehgupx==8)
{
unsafeWindow.yehgupx=0;clearTimeout(unsafeWindow.yehgsfg);
}
}
}
//unsafeWindow.yehgsfg = setInterval("yehgshowFingerprint()",80);
for(var i=0;i<=document.getElementsByTagName("meta").length-1;i++)
{
var item = document.getElementsByTagName("meta")[i];
if(item.name.match(/generator/i))
{
if(item.content!="")printdata += "Generated by => <a style='color:yellow!important;text-decoration:underline;' title='Find it in Google' target='_blank' href='http://www.google.com/search?q=" + item.content + "'>"+item.content+"</a> [<a style='color:yellow!important;text-decoration:underline;' title='Find its vulnerabilities in Google' target='_blank' href='http://www.google.com/search?q=" + item.content + " vulnerabilities'>Vuln Search</a>]<br>";
}
if(item.name.match(/robots/i))
{
if(item.content!="")printdata += "Robot => " + item.content + "<br>";
}
if(item.name.match(/description/i))
{
if(item.content!="")printdata += "Description => " + item.content + "<br>";
}
if(item.name.match(/author/i))
{
if(item.content!="")printdata += "Author => <a style='color:yellow!important;text-decoration:underline;' title='Find it in Google' target='_blank' href='http://www.google.com/search?q=" + item.content + "'>"+item.content+"</a><br>";
}
if(item.name.match(/ProgId/i))
{
if(item.content!="")printdata += "<br>ProgId => <a style='color:yellow!important;text-decoration:underline;' title='Find it in Google' target='_blank' href='http://www.google.com/search?q=" + item.content + "'>"+item.content+"</a><br>";
}
}
bodystr = document.body.innerHTML;
if(bodystr.indexOf("Powered by")!=-1)
{
bodystr = bodystr.substring(bodystr.indexOf("Powered by")+10,bodystr.indexOf("Powered by")+100 );
pow="";
for(i=0;bodystr.length>i;i++)
{
if(bodystr[i]=="<")break;
if(i<(bodystr.length-1))
{
pow += bodystr[i];
}
}
printdata += "Powered by: <a style='color:yellow!important;text-decoration:underline;' title='Find it in Google' target='_blank' href='http://www.google.com/search?q=" + pow + "'>"+pow+"</a><br>";
}
bodystr = document.body.innerHTML;
if(bodystr.indexOf("Hosted by")!=-1)
{
bodystr = bodystr.substring(bodystr.indexOf("Hosted by")+10,bodystr.indexOf("Hosted by")+100 );
hos="";
for(i=0;bodystr.length>i;i++)
{
if(bodystr[i]=="<")break;
if(i<(bodystr.length-1))
{
hos+= bodystr[i];
}
}
printdata += "Hosted by: <a style='color:yellow!important;text-decoration:underline;' title='Find it in Google' target='_blank' href='http://www.google.com/search?q=" + hos + "'>"+hos+"</a><br>";
}
stat = "";
showstat = 0;
stat += "<br><b>[Stat]</b><br><br>";
stat += " Total Form: "+ document.getElementsByTagName("form").length+"<br>";
stat += " Total Link: "+ document.getElementsByTagName("a").length+"<br>";
if(document.getElementsByTagName("a").length>0 || document.getElementsByTagName("form").length >0)
{
showstat = 1;
}
if(showstat==1){printdata += stat;}
fuzzlink = "<br><b>[Fuzzable Links]</b><br>";
hasfuzzlink = 0;
for(var i=0;i<=document.getElementsByTagName("a").length-1;i++)
{
if(document.getElementsByTagName("a")[i].href.indexOf("?")>0)
{
var href = document.getElementsByTagName("a")[i].href+"";
fuzzlink +="<br><a target='_blank' style='color:yellow!important;text-decoration:underline;' href='" + href + "'>"+ document.getElementsByTagName("a")[i].href+ "</a><br>";
hasfuzzlink=1;
}
}
if(hasfuzzlink==1){printdata+=fuzzlink;}
// Print Window Object & Form Elements in Firebug Log
hasform = 0;
formsdata = "<br><b>[Form Data]</b><br><br>";
for(var f=0;f<=unsafeWindow.document.getElementsByTagName("form").length-1;f++)
{
hasform=1;
formsdata += "\n<i>Form " + f + ":</i><br>";
formsdata += "name: "+document.getElementsByTagName("form")[f].name+"<br>";
formsdata += "action: <a style='color:yellow!important;text-decoration:underline;' target='_blank' href='" + document.getElementsByTagName("form")[f].action + "'>"+ document.getElementsByTagName("form")[f].action +"</a><br>";
formsdata += "method: "+document.getElementsByTagName("form")[f].method+"<br>";
formsdata += "<br><i>Form " + f + " Elements:</i><br>";
for(var e=0;e<=unsafeWindow.document.getElementsByTagName("form")[f].elements.length;e++)
{
if(unsafeWindow.document.getElementsByTagName("form")[f].elements[e]!= null && document.getElementsByTagName("form")[f].elements[e]!= "undefined")
{
if(unsafeWindow.document.getElementsByTagName("form")[f].elements[e]!="undefined")
{
if(unsafeWindow.document.getElementsByTagName("form")[f].elements[e].type=="hidden")
{
formsdata += "No. " + e + " . " + unsafeWindow.document.getElementsByTagName("form")[f].elements[e].name+" [type=" +unsafeWindow.document.getElementsByTagName("form")[f].elements[e].type+"] [value=<a target='_blank' style='color:yellow!important;text-decoration:underline;' href='http://h4k.in/encoding/?outputtext="+ unsafeWindow.document.getElementsByTagName("form")[f].elements[e].value +"'>" + unsafeWindow.document.getElementsByTagName("form")[f].elements[e].value + "</a>]<br>"
}
else
{
formsdata += "No. " + e + " . " + unsafeWindow.document.getElementsByTagName("form")[f].elements[e].name+" [type=" +unsafeWindow.document.getElementsByTagName("form")[f].elements[e].type+"] [value=" + unsafeWindow.document.getElementsByTagName("form")[f].elements[e].value + "]<br>"
}
;
}
}
}
}
if(hasform==1){printdata += formsdata;}
//alert(typeof(unsafeWindow.getCookie));
scriptsrc = "<br><b>[Script Source]</b><br><br>";
hasscriptsrc=0;
for(var s=0;s<=unsafeWindow.document.getElementsByTagName("script").length-1;s++)
{
hasscriptsrc=1;
if(unsafeWindow.document.getElementsByTagName("script")[s].src!="")
{
scriptsrc += "<a target='_blank' style='color:yellow!important;text-decoration:underline;' href='" + unsafeWindow.document.getElementsByTagName("script")[s].src + "'>"+unsafeWindow.document.getElementsByTagName("script")[s].src+"</a><br>";
}
}
if(hasscriptsrc==1){printdata+=scriptsrc;}
var nativeObj = /^(getInterface|window|yehgsfg|yehgshowFingerprint|yehgupx|console|document|addEventListener|__firebug__|location|navigator|Packages|sun|java|netscape|XPCNativeWrapper|GeckoActiveXObject|Components|parent|removeEventListener|top|scrollbars|name|scrollX|scrollY|scrollTo|scrollBy|getSelection|scrollByLines|scrollByPages|sizeToContent|prompt|dump|setTimeout|setInterval|clearTimeout|clearInterval|setResizable|captureEvents|releaseEvents|routeEvent|enableExternalCapture|disableExternalCapture|open|openDialog|frames|find|self|screen|history|content|menubar|toolbar|locationbar|personalbar|statusbar|directories|closed|crypto|pkcs11|controllers|opener|status|defaultStatus|innerWidth|innerHeight|outerWidth|outerHeight|screenX|screenY|pageXOffset|pageYOffset|scrollMaxX|scrollMaxY|length|fullScreen|alert|confirm|focus|blur|back|forward|home|stop|print|moveTo|moveBy|resizeTo|resizeBy|scroll|close|updateCommands|atob|btoa|frameElement|dispatchEvent|getComputedStyle|sessionStorage|globalStorage)$/;
var hasCusObj=0;
cusObj = "<br><b>[Custom JS Objects]</b><br><br>";
unsafeWindow.console.log("");
unsafeWindow.console.log("[Objects]");
unsafeWindow.console.log("");
unsafeWindow.console.log("");
for(w in unsafeWindow.window)
{
if(!nativeObj.test(w))
{
if(typeof(eval("unsafeWindow."+w)) == "object")
{
cusObj += "=>"+w+" " + eval("unsafeWindow."+w)+"<br>";
unsafeWindow.console.log("");
unsafeWindow.console.log("=>"+w+" " + eval("unsafeWindow."+w)+"");
unsafeWindow.console.dir(eval("unsafeWindow."+w));
unsafeWindow.console.log("");
unsafeWindow.console.log("");
hasCusObj=1;
}
}
}
cusObj += "<br><b>[Custom JS Variables]</b><br><br>";
unsafeWindow.console.log("");
unsafeWindow.console.log("");
unsafeWindow.console.log("[Variables]");
unsafeWindow.console.log("");
for(w in unsafeWindow.window)
{
if(!nativeObj.test(w))
{
if(typeof(eval("unsafeWindow."+w)) != "function" && typeof(eval("unsafeWindow."+w)) != "object")
{
ev = eval("unsafeWindow."+w)+"";
ev=ev.replace(/</i,"<");
ev=ev.replace(/>/i,">");
cusObj += "=>"+w+" [type=" + typeof(eval("unsafeWindow."+w))+"] [value=" + ev + "]<br>";
unsafeWindow.console.log("");
unsafeWindow.console.log("=>"+w+" [type=" + typeof(eval("unsafeWindow."+w))+"]");
unsafeWindow.console.dir(eval("unsafeWindow."+w));
unsafeWindow.console.log("");
unsafeWindow.console.log("");
hasCusObj=1;
}
}
}
cusObj += "<br><b>[Custom JS Functions] <a style='color:yellow!important;text-decoration:underline;' href='javascript:var cus=prompt(\"Enter function name\",\"Function name\",\"Function to Execute\");if(cus!=null&&cus!=\"\"&&cus!=\"Function name\"){eval(cus);}'>Execute</a></b><br><br>";
unsafeWindow.console.log("");
unsafeWindow.console.log("");
unsafeWindow.console.log("[Functions]");
unsafeWindow.console.log("");
for(w in unsafeWindow.window)
{
if(!nativeObj.test(w))
{
if(typeof(eval("unsafeWindow."+w)) == "function")
{
cusObj += "=><a style='color:yellow!important;text-decoration:underline;' href='javascript:alert("+w+")'>" + w + "()</a><br>";
unsafeWindow.console.log("");
unsafeWindow.console.log("=>"+w);
unsafeWindow.console.dir(eval("unsafeWindow."+w));
unsafeWindow.console.log("");
unsafeWindow.console.log("");
hasCusObj=1;
//cusObj += "<pre>" + eval("unsafeWindow."+w)+"</pre><br><br>";
}
}
}
if(hasCusObj==1){printdata += cusObj;}
var div = document.createElement("div");
div.setAttribute("id","yehgfingerprint");
div.setAttribute("style","display:none;-moz-opacity:0;position:absolute;left:10%;right:10%;padding:1% 1% 1% 1%;top:1%;text-align:left;background-color:navy;color:yellow;float:right;border:1px outset;");
div.innerHTML ="<a name='yehgfingerprint'></a>"+printdata+"<br>";
var div2 = document.createElement("div");
div2.setAttribute("id","yehgfingerprint2");
div2.setAttribute("style","-moz-opacity:0.6;position:fixed;top:1%;left:85%");
div2.innerHTML = "<span style='background-color:navy;color:yellow;float:right;;border:1px outset black;cursor:pointer;text-decoration:none;' onclick='yehgsfg=setInterval(\"yehgshowFingerprint()\",80);document.getElementById(\"yehgfingerprint2\").style.display=\"none\";window.location=\"#yehgfingerprint\"'>FingerPrint!</span>";
if(printdata.length>284){document.body.appendChild(div);document.body.appendChild(div2);}
} //if(!invalidext.test(document.URL))