User:Aaron Schulz/CheckUser2.0/whois.js

////////CLIENT SIDE CHECKUSER IP info retriever///////////// //security override HTTP request //ALSO, reduce IE security settings //For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ" //Basically, enable "signed.applets.codebase_principal_support" in about:config

addOnloadHook(WHOIScheck) function WHOIScheck { if (location.href.indexOf('Special:CheckUser') ==-1) return; var body=document.getElementById('bodyContent'); if (!body) return; addTab("javascript:CU_comprehensive", "WHOIS all IPs", "ca-checkall", "Check all IPs", ""); }

// function makeCURequestXML_DNS(type, url, parameters) {  if(window.XMLHttpRequest) { try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) {alert("Permission UniversalBrowserRead denied. Please enable 'signed.applets.codebase_principle_support' through 'about:config' in your browser."); } http_request = false; http_request = new XMLHttpRequest; if (!http_request) {alert('Cannot create XMLHTTP instance'); return false;} http_request.onreadystatechange = CU_comprehensive_check_WHOIS; http_request.open(type, url, true); http_request.send(parameters); } else if (window.ActiveXObject) {   try {http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {     try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){} } if (!http_request) {showError(ERROR_XML);} http_request.onreadystatechange = CU_comprehensive_check_WHOIS; http_request.open(type, url, true); http_request.send(parameters); } } //

// function makeCURequestXML_WHOIS(type, url, parameters) {  if(window.XMLHttpRequest) { try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); } catch (e) {alert("Permission UniversalBrowserRead denied. Please enable 'signed.applets.codebase_principle_support' through 'about:config' in your browser."); } http_request = false; http_request = new XMLHttpRequest; if (!http_request) {alert('Cannot create XMLHTTP instance'); return false;} http_request.onreadystatechange = CU_comprehensive_check_parse; http_request.open(type, url, true); http_request.send(parameters); } else if (window.ActiveXObject) {   try {http_request = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {     try {http_request = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){} } if (!http_request) {showError(ERROR_XML);} http_request.onreadystatechange = CU_comprehensive_check_parse; http_request.open(type, url, true); http_request.send(parameters); } } //

//IP/WHOIS for CU principle results// CU_li_index = 0; CU_li_ip_list = '|'; function CU_comprehensive { var results = document.getElementById('bodyContent').getElementsByTagName('ul')[0]; if (!results) {alert('There are no elements in this list.'); return;} if (!results.getElementsByTagName('li')[0]) {alert('There are no elements in this list.'); return;} var ls = results.getElementsByTagName('li'); if (!ls[0].getElementsByTagName('a')[0]) {alert('There are no expected elements in this list.'); return;} if (document.getElementById('contentSub').innerHTML.search(/Checking all IPs, please wait...|All data retrieved:/) != -1) {alert('Results already shown.'); return;} document.getElementById('contentSub').innerHTML += ' Checking all IPs, please wait...'; CU_comprehensive_check; }

function CU_comprehensive_check { var list = document.getElementById('bodyContent').getElementsByTagName('ul')[0]; if (list.getElementsByTagName('li')[CU_li_index] && list.getElementsByTagName('li')[CU_li_index].getElementsByTagName('a')[0]) { var link = list.getElementsByTagName('li')[CU_li_index].getElementsByTagName('a')[0].href; var name = list.getElementsByTagName('li')[CU_li_index].getElementsByTagName('a')[0].innerHTML; // Must be an IP address, and one that we didn't already do if (name.search(/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})$/) !=-1 && CU_li_ip_list.indexOf('|' + name + '|') ==-1) {   var URL = 'http://www.dnsstuff.com/tools/ipall.ch?domain=' + name; CU_li_ip_list += name + '|'; CU_comprehensive_check_DNS(URL); } else {CU_li_index+=1; CU_comprehensive_check;} } else if (list.getElementsByTagName('li')[CU_li_index]) {CU_li_index+=1; CU_comprehensive_check;} else { document.getElementById('contentSub').innerHTML = ' All data retrieved: DNS/WHOIS scan completed. '; } }

function CU_comprehensive_check_DNS(URL) { var list = document.getElementById('bodyContent').getElementsByTagName('ul')[0]; var name = list.getElementsByTagName('li')[CU_li_index].getElementsByTagName('a')[0].innerHTML; document.getElementById('contentSub').innerHTML = ' Retrieving DNS XML page data for ' + name + '... '; makeCURequestXML_DNS("GET",URL,null); }

function CU_comprehensive_check_WHOIS { if (http_request.readyState != 4) return; xml_DNS_user_CU = http_request.responseText; var list = document.getElementById('bodyContent').getElementsByTagName('ul')[0]; var name = list.getElementsByTagName('li')[CU_li_index].getElementsByTagName('a')[0].innerHTML; var URL = 'http://www.dnsstuff.com/tools/whois.ch?ip=' + name; document.getElementById('contentSub').innerHTML = ' Retrieving WHOIS XML page data for ' + name + '... '; makeCURequestXML_WHOIS("GET",URL,null); }

function CU_comprehensive_check_parse { if (http_request.readyState != 4) return; xml_WHOIS_CU = http_request.responseText; var list = document.getElementById('bodyContent').getElementsByTagName('ul')[0]; var name = list.getElementsByTagName('li')[CU_li_index].getElementsByTagName('a')[0].innerHTML; document.getElementById('contentSub').innerHTML = ' Parsing WHOIS XML page data for ' + name + '... '; //WHOIS //parse WHOIS results var OrgName=''; var Address=''; var City=''; var StateProv=''; var Country=''; var CIDR=''; var Location=''; // A data chunk may appear at the top // Get user location if( xml_WHOIS_CU.indexOf('Location:') !=-1) {Location += xml_WHOIS_CU.split('Location:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ']';} // Focus... if (xml_WHOIS_CU.indexOf('') !=-1) {xml_WHOIS_CU = http_request.responseText.split('')[1];} xml_WHOIS_CU = xml_WHOIS_CU.split('')[0].split('')[0]; // Get name if (xml_WHOIS_CU.indexOf('OrgName:') !=-1) {OrgName += xml_WHOIS_CU.split('OrgName:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} else if (xml_WHOIS_CU.indexOf('org-name:') !=-1) {OrgName += xml_WHOIS_CU.split('org-name:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} else if (xml_WHOIS_CU.indexOf('organisation:') !=-1) {OrgName += xml_WHOIS_CU.split('organisation:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} // Get address if (xml_WHOIS_CU.indexOf('Address:') !=-1) {Address += xml_WHOIS_CU.split('Address:')[1].split(/[\n\r]\w+:/)[0].split(']')[0] + ', ';} var address_lines = xml_WHOIS_CU.split('address:'); if (address_lines[1]) {Address += address_lines[1].split(/[\n\r]\w+:/)[0].split(']')[0] + ', ';} if (address_lines[2]) {Address += address_lines[2].split(/[\n\r]\w+:/)[0].split(']')[0] + ', ';} if (address_lines[3]) {Address += address_lines[3].split(/[\n\r]\w+:/)[0].split(']')[0] + ', ';} if (address_lines[4]) {Address += address_lines[4].split(/[\n\r]\w+:/)[0].split(']')[0] + ', ';} if (address_lines[5]) {Address += address_lines[5].split(/[\n\r]\w+:/)[0].split(']')[0] + ', ';} // Get city if ( City=='' && xml_WHOIS_CU.indexOf('city:') !=-1) {City += ' ' + xml_WHOIS_CU.split('city:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ' ' + ', ';} // Get state if (xml_WHOIS_CU.indexOf('StateProv:') !=-1) {StateProv += xml_WHOIS_CU.split('StateProv:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} else if (xml_WHOIS_CU.indexOf('stateprov:') !=-1) {StateProv += xml_WHOIS_CU.split('stateprov:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} // Get country if ( Country=='' && xml_WHOIS_CU.indexOf('Country:') !=-1) {Country += xml_WHOIS_CU.split('Country:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} else if ( Country=='' && xml_WHOIS_CU.indexOf('country:') !=-1) {Country += xml_WHOIS_CU.split('country:')[1].split('\n')[0].split('\r')[0].split(']')[0] + ', ';} // Get CIDR if (xml_WHOIS_CU.indexOf('CIDR:') !=-1) {CIDR = xml_WHOIS_CU.split('CIDR:')[1].split('\n')[0].split('\r')[0].split(']')[0];} else if (xml_WHOIS_CU.indexOf('route:') !=-1) {CIDR = xml_WHOIS_CU.split('route:')[1].split('\n')[0].split('\r')[0].split(']')[0];} else if (xml_WHOIS_CU.indexOf('inetnum:') !=-1) {CIDR = xml_WHOIS_CU.split('inetnum:')[1].split('\n')[0].split('\r')[0].split(']')[0];} // join them var output_IP_info = ' ' + OrgName + ' ' + Address + City + ' ' + StateProv + ' ' + ' + Country + '; // add CIDR if (CIDR !='') output_IP_info += ' CIDR: ' + CIDR; // Parse DNS items document.getElementById('contentSub').innerHTML = ' Parsing DNS XML page data for ' + name + '... '; if (xml_DNS_user_CU.indexOf('') != -1) {xml_DNS_user_CU = xml_DNS_user_CU.split('')[1].split('')[0];} var rev_DNS_info = ''; if (xml_DNS_user_CU.indexOf('Reverse DNS:') !=-1) {rev_DNS_info = ' ' + xml_DNS_user_CU.split('Reverse DNS:')[1].split('\n')[0].split('\r')[0] + ' ';} output_IP_info += ' RDNS :' + rev_DNS_info; output_IP_info = output_IP_info.replace(/Internet Assigned Numbers Authority/,'IANA'); // Add location if (Location !='') output_IP_info += ' Location: ' + Location; link = '(Full) '; list.getElementsByTagName('li')[CU_li_index].innerHTML += ' ' + link + output_IP_info + ' '; // CU_li_index += 1; CU_comprehensive_check; } //////////////

//