home *** CD-ROM | disk | FTP | other *** search
Wrap
//#define DEBUG /****************************************************************************\ * * * Intrabot.jfm -- Given a range of ip addresses to check, this bot checks * * each machine in that range to see if it has an HTTP server running. * * If it does, it queries the server to find out what kind of server * * it is. * * * * Intrabot.jfm is part of the web utilities solution application. It is meant* * to be used by systems administrators who would like to index their site. * * Used in conjunction with the crawler it is possible to detect which * * machines are running an http server(using intrabot), and then what pages * * are on those servers (using crawler). These utilities are a powerful * * combination and should only be run by trusted users. * * * * * * Dependencies: reqstUrl.dll * * hosts.qry * * * * * * * * * Links to: ibapps/guest.db * * * * Updated 11/12/96 by IntraBuilder Samples Group * * $Revision: 1.6 $ * * * * Copyright (c) 1996, Borland International, Inc. All rights reserved. * * * \****************************************************************************/ extern char* requestHead(char* /*url*/)"reqstURL.dll"; extern boolean hasHTTPServer(char*/*ip address*/, unsigned int /*port*/, unsigned int /*time to wait for resonse*/)"reqstURL.dll"; extern void DoMessages()"reqstURL.dll"; #define mainPage 1; #define proceedPage 2; #define errorPage 3; #define helpPage 4; // {End Header} Do not remove this comment// // Generated on 11/12/96 // var f = new IntraBotForm(); f.open(); class IntraBotForm extends Form { _sys.scripts.load(_sys.env.home() + "APPS\\SHARED\\CONTROLS.CC") with (this) { onServerSubmit = class::form_onServerSubmit; onServerLoad = class::Form_onServerLoad; onServerUnload = class::Form_onServerUnload; color = "white"; height = 14; left = 0; top = 0; width = 78; title = "IntraBot Server Locator"; } with (this.hosts1 = new Query()){ left = 58; top = 5; sql = "@hosts.qry"; active = true; with (rowset) { } } with (this.range1 = new Query()){ left = 58; top = 3; sql = "@range.qry"; active = true; with (rowset) { } } with (this.rule1 = new Rule(this)){ left = 76; top = 4; size = 2; right = 0; pageno = 0; } with (this.rule2 = new Rule(this)){ top = 12.5; size = 2; right = 76; pageno = 0; } with (this.Low = new Text(this)){ left = 24; top = 6; width = 24; value = ""; } with (this.High = new Text(this)){ left = 24; top = 7; width = 24; value = ""; } with (this.HTML1 = new HTML(this)){ height = 1; top = 4.5; width = 76; color = "black"; text = "Enter the IP addresses you would like to search between. (e.g. 123.123.123.123)"; } with (this.HTML2 = new HTML(this)){ height = 1; top = 6; width = 23; color = "black"; alignVertical = 1; alignHorizontal = 2; text = "From:"; } with (this.HTML3 = new HTML(this)){ height = 1; top = 7; width = 23; color = "black"; alignVertical = 1; alignHorizontal = 2; text = "To:"; } with (this.TimeOut = new Text(this)){ left = 24; top = 8; width = 16; value = "250"; } with (this.HTML4 = new HTML(this)){ height = 1; top = 8; width = 23; color = "black"; alignVertical = 1; alignHorizontal = 2; text = "Time out (milliseconds):"; } with (this.HTML5 = new HTML(this)){ height = 2; left = 12; width = 64; color = "804040"; text = "<U><B><H1>IntraBot</H1></B></U>"; pageno = 0; } with (this.button1 = new Button(this)){ onServerClick = class::BeginProbeButton_onServerClick; top = 10.5; width = 20; text = "Begin Probe"; } with (this.estimatedTimeHTML = new HTML(this)){ height = 2; top = 5; width = 76; color = "black"; text = "Estimated time to complete in minutes:"; pageno = 2; } with (this.okButton = new Button(this)){ onClick = class::okButton_onClick; top = 9; width = 12; text = "Launch"; pageno = 2; } with (this.backButtonPage2 = new Button(this)){ onServerClick = class::backButtonPage2_onServerClick; left = 16; top = 9; width = 12; text = "Back"; pageno = 2; } with (this.errorHTML = new HTML(this)){ height = 5; top = 5; width = 76; color = "black"; text = "Error"; pageno = 3; } with (this.button2 = new Button(this)){ onServerClick = class::button2_onServerClick; top = 13; width = 20; text = " OK "; pageno = 3; } with (this.HTML6 = new HTML(this)){ height = 1; top = 4.5; width = 76; color = "black"; text = "Enter the IP addresses you would like to search between. (e.g. 123.123.123.123)"; pageno = 4; } with (this.HTML7 = new HTML(this)){ height = 0.75; top = 6; width = 11; color = "black"; alignHorizontal = 2; text = "From:"; pageno = 4; } with (this.HTML9 = new HTML(this)){ height = 0.75; top = 6.75; width = 11; color = "black"; alignHorizontal = 2; text = "To:"; pageno = 4; } with (this.HTML10 = new HTML(this)){ height = 1; top = 8; width = 11; color = "black"; alignHorizontal = 2; text = "Time out:"; pageno = 4; } with (this.html1 = new HTML(this)){ height = 2; left = 12; top = 8; width = 64; color = "blue"; text = "This is the amount of time you want to pause at each computer. If you make this value larger you are less likely to miss a computer that has a server on it. However it will take longer to scan your network this way."; pageno = 4; } with (this.html2 = new HTML(this)){ height = 2; left = 12; top = 6; width = 64; color = "blue"; text = "The systems administrator should know what addresses have been granted to your network. Fill in the largest and smallest here."; pageno = 4; } with (this.helpButton = new Button(this)){ onServerClick = class::helpButton_onServerClick; left = 24; top = 10.5; width = 20; text = " Help "; } with (this.backButton = new Button(this)){ onServerClick = class::backButton_onServerClick; top = 11; width = 12; text = " Back "; pageno = 4; } with (this.secondsCountField = new Hidden(this)){ left = 86; top = 3; value = "0"; pageno = 2; } with (this.html3 = new HTML(this)){ height = 1; top = 7; width = 16; color = "black"; text = "Elapsed time:"; pageno = 2; } with (this.timerText = new Text(this)){ left = 16; top = 7; width = 12; value = "0:0"; pageno = 2; } with (this.image1 = new Image(this)){ height = 3.4167; width = 10.25; dataSource = "filename WEBSRC11.JPG"; alignment = 4; pageno = 0; } with (this.portHTML = new HTML(this)){ height = 1; top = 9; width = 23; color = "black"; alignVertical = 1; alignHorizontal = 2; text = "Port:"; } with (this.portField = new Text(this)){ left = 24; top = 9; width = 16; value = "80"; } with (this.HTML11 = new HTML(this)){ height = 1; top = 10; width = 11; color = "black"; alignHorizontal = 2; text = "Port:"; pageno = 4; } with (this.portHelpHTML = new HTML(this)){ height = 1; left = 12; top = 10; width = 64; color = "blue"; text = "Specifies which port to probe (usually 80)."; pageno = 4; } with (this.html4 = new HTML(this)){ height = 1; left = 12; top = 2; width = 60; color = "black"; text = "<H3>will find web servers on the intranet</H3>"; } with (this.html5 = new HTML(this)){ height = 1.2083; left = 12; top = 2; width = 64; color = "black"; text = "<H3>will find web servers on the intranet</H3>"; pageno = 4; } with (this.GeneratedHTML1 = new GeneratedHTML(this)){ height = 1; top = 13; width = 76; pageno = 0; } this.rowset = this.hosts1.rowset; function BeginProbeButton_onServerClick() { var ipLow=new IpAddress(form.Low.value); var ipHigh= new IpAddress(form.High.value); var errorString=new String(); var errors=false; numMachinesToCheck= (ipHigh.toDecimal()-ipLow.toDecimal())+1; form.timerText.value="0:0"; form.hosts1.rowset.first(); //empty the tables before we start while(!(form.hosts1.rowset.endOfSet)){ form.hosts1.rowset.delete(); } while(!(form.range1.rowset.endOfSet)){ form.range1.rowset.delete(); } //check for bad data in fields errors=form.validateFields(errorString); if (errors){ form.errorHTML.text=errorString; form.pageno=errorPage; //turn to the error page return; }else{ var totalTime=numMachinesToCheck*(parseInt(form.TimeOut.value)+250)+3000; var totalSeconds=totalTime/1000; var minutes= Math.int(totalSeconds/60); var seconds=0; if (minutes>0){ seconds=parseInt(Math.int(totalSeconds%60)); }else{ seconds=parseInt(Math.int(totalSeconds)); } if (seconds<10){ seconds="0"+seconds; //make 6 into 06 so it looks like a digital clock } var outString=new String(); outString= ""+ minutes+ ":" +seconds; form.estimatedTimeHTML.text="Estimated time to complete probe is "+outString form.range1.rowset.beginAppend(); form.range1.rowset.fields["low IP"].value=ipLow.text; form.range1.rowset.fields["high IP"].value=ipHigh.text; form.range1.rowset.save(); form.pageno=proceedPage; //turn to the proceed with caution page return; } } function validateFields(errorString) { //this function checks each field for a reasonable value //if it finds a bad value it sets errorString to an error //message and returns var errors=false; var partsLow=new Array(4); var partsHigh=new Array(4); errorString=""; //Since this function is called by BeginProbeButton_onServerClick() //we can see it's variables if(ipLow.isValid==false){ errorString+="Error: Low IP address is not valid.<br>"; errors=true; } if(ipHigh.isValid==false){ errorString+="Error: High IP address is not valid.<br>"; errors=true; } var timeOutVal=parseInt(form.TimeOut.value); if (timeOutVal<250){ errorString+="Error:TimeOut must be at least 250 milliseconds\n"; errors=true; } numMachinesToCheck= (ipHigh.toDecimal()-ipLow.toDecimal())+1; if (numMachinesToCheck<=0){ errorString+="Error: Low IP address must be a smaller number than the high.<br>" errors=true; }//endif return errors; } function Form_onServerLoad() { _sys.scripts.load("netClass"); //load the internet classes loadExternalFunctions(); //must call this immediately after loading internet classes. with (this){ pageno=mainPage; cancel=false; } this.submit=this.onServerSubmit; //This is a workaround to call onServerSubmit when form.submit() is called this.currentIP=new IpAddress(""); this.ticker=new String(); this.running=true; //keep track of when the form is running } function form_onServerSubmit() { this.cancel=false; this.pageno=2; var ipLow=new IpAddress(this.Low.value); var ipHigh= new IpAddress(this.High.value); var ipToCheck =new IpAddress(""); var infoReturned; var timeToWait=parseInt(this.TimeOut.value); var result; var numMachinesToCheck=0; var startTime=new Date(); var min= ipLow.toDecimal(); var max= ipHigh.toDecimal(); var portNum=parseInt(form.portField.value); #ifdef DEBUG _sys.scriptOut.writeln("ip Low="+ipLow.text); _sys.scriptOut.writeln("ip High="+ipHigh.text); #endif for(var i=min;i<=max && this.running==true;i++) { ipToCheck.decimalToIp(i); #ifdef DEBUG _sys.scriptOut.writeln("address= "+ ipToCheck.text); #endif var currentTime=new Date(); millisecondsEllapsed=currentTime.getTime()-startTime.getTime(); if ((millisecondsEllapsed%1000)>700) { //update the clock only 1 time per second form.timerText.value=timeDiff(millisecondsEllapsed); } result= hasHTTPServer(ipToCheck.text,portNum,timeToWait); if (result==true){ var u=new Url("http://"+ ipToCheck.text +"/"); infoReturned=new HeadResponse(u); this.hosts1.rowset.beginAppend(); this.hosts1.rowset.fields["ip address"].value=ipToCheck.text; this.hosts1.rowset.fields["Server name"].value=ipToCheck.getName(); this.hosts1.rowset.fields["server type"].value=infoReturned.headerFile.server; this.hosts1.rowset.fields["port"].value=portNum; this.hosts1.rowset.save(); }//endif }//endfor _sys.reports.run("intrabot") } function button2_onServerClick() { form.pageno=mainPage; //turn to main page } function backButtonPage2_onServerClick() { form.pageno=mainPage; //turn to main page } function helpButton_onServerClick() { form.pageno=helpPage; //turn to help page } function backButton_onServerClick() { form.pageno=mainPage; //turn to main page } function Form_onServerUnload() { this.running=false; //keep track of when the form is running _sys.scripts.unload("netClass.js"); //unload the scripts } function okButton_onClick() { setTimeout("tick()",1000); this.form.submit(); } function tick() { // {Export} This comment causes this function body to be sent to the client var totalSeconds=parseInt(document.forms[0].secondsCountField.value) +1; document.forms[0].secondsCountField.value = totalSeconds; var minutes= Math.floor(totalSeconds/60); var seconds=0; if (minutes>0){ seconds=totalSeconds%60; }else{ seconds=totalSeconds; } if (seconds<10){ seconds="0"+seconds; //make 6 into 06 so it looks like a digital clock } var outString=new String(); outString= ""+ minutes+ ":" +seconds; document.forms[0].timerText.value=outString; setTimeout("tick()",1000); //call this function again in 1 second } } function timeDiff( millisecondsEllapsed){ var seconds=0; var totalSeconds=parseInt(millisecondsEllapsed/1000); var minutes=parseInt(Math.floor(totalSeconds/60) ); var outString=new String(); if (minutes>0){ seconds=parseInt(totalSeconds%60); }else{ seconds=totalSeconds; }//endif if (seconds<10){ seconds="0"+seconds; //make 6 into 06 so it looks like a digital clock }//endif outString= ""+ minutes+ ":" +seconds; return outString; } function setTimeout(functionToCall,timeoutValue) { return; }