Showing posts with label Browser. Show all posts
Showing posts with label Browser. Show all posts

Monday, 17 January 2022

Running JavaScript Before Any Other Scripts On A Page

Injecting A Script At The Top Of Your HTML Page


By Strictly-Software

If you are developing an extension for either Firefox, Opera or Chrome, Brave, Edge, and Chromium, then you might come across the need to be able to inject some code into the top of your HTML page so that it runs before any other code.

When developing extensions for Chromium based browsers such as Chrome, Brave and Edge, you will most likely do this from your content.js file which is one of the main files that holds code to be run at certain stages of a pages lifetime.

As the Chrome Knowledge Base says the property values for the "run_at" property include;

  • document_idle, the preferred setting where scripts are guaranteed to run after the DOM is complete and after the window.onload event has loaded all resources which can include other scripts.
  • document_end, content.js scripts are injected immediately after the DOM is complete, but before subresources like images and frames have loaded. So after the DOM is loaded but before window.onload has finished loading external resources.
  • document_start, ensures scripts are injected after any CSS files are loaded but before any other DOM is constructed or any other script is run.  
  • There is of course the "run_at" property in the manifest.json file, which can be set to "document_start", to enable the codes running before other code does. This is especially useful if you need to change header values before a web page loads so that modified values such as the Referer or User-Agent can be modified. However, there may also be a need for you to set up an object or variable that is inserted into the DOM for code within the HTML page to access.

    For example in a User-Agent switcher where you need to both overwrite the Navigator object in JavaScript and the Request header, you may want to create an object or variable that holds the original REAL navigator object or its user-agent so that any page you may create yourself or offer to your users the ability to see the REAL user-agent, browser, language, and other properties if they wanted to.

    For example, I have my own page that I use to show me the current user-agent and list the navigator properties

    However, if they have been modified by my own user-agent switcher extension I also offer up a variable holding the original REAL user-agent so that it can be shown and compared with the spoofed version to see what has changed. I also have a variable that holds the original navigator object in case I want to look at the properties.

    Therefore my HTML page may want to inspect this object if it exists with some code on the page.

    // check to see if I can access the original Navigator object and the user agent string
    if(typeof(origNavigator) !== 'undefined' && origUserAgent !== null)
    {
    	// get the real Browser name with my Detect Browser function using the original Navigator user-agent
    	let realBrowser = Browser.DetectBrowser(origUserAgent);
    
    	// output on the page in a DIV I have
    	G("#RealBrowser").innerHTML = "<b>Real Browser: " + realBrowser "</b>";
    }

    This code just uses a generic Browser detection function for taking a user-agent and finding the Browser name. It even detects Brave by ruling out other browsers and if it is Chrome at the end I check for the Brave properties or mention of the word in the string, which they used to have but newer versions have removed it. 

    However there is hope in the community that they will create a unique user-agent with the word Brave in as at the moment people are having to do object detection which is the better method, and as Brave tries to hide, there are plenty of query strings and other API calls which can be made to find out whether the result indicates Brave rather than Chrome.

    However, at the moment, I am just using a simple detection on the window.navigator object that if TRUE indicates that it is actually Brave NOT Chrome. 

    A later article shows a longer function I developed with fallbacks in case the objects do not exist anymore as there used to be a brave object on the window e.g window.brave that no longer exists, so did many objects for Chrome such as window.google and window.googletag that no longer exist. However, this article explains all that.

    This is just the one line test you can do, it ensures it is not FireFox with a test for a Mozilla only object window.mozInnerScreenX and then checks that it is a Chromium browser with tests for window.chrome and that it's also webkit with a test for window.webkitStorageInfo before some tests for navigator.brave and navigator.brave.isBrave to ensure it's Brave not Chrome e.g:

    // ensure that a Chrome user-agent is not actually Brave by checking some properties that seem to work to identify the browser at the moment anyway...
    let isBrave = !("mozInnerScreenX" in window) && ("chrome" in window && "webkitStorageInfo" in window && "brave" in navigator && "isBrave" in navigator.brave) ? true : false


    However, this article is more about injecting a script into the HEAD of your HTML so that code on the page can access any properties within it.

    As my extension offers an Original Navigator object and a string holding the original/real user-agent before I overwrite it, then I want this code to be the first piece of JavaScript on the page.

    This doesn't have to be limited to extensions and you may have code you want to inject in the HEAD when the DOMLoads before any other code.

    This is a function I wrote that attempts to place a string holding your JavaScript into a new Script block I create on the fly and then insert before any other SCRIPT in the document.head.

    However, if the page is malformed, or has no defined head area it falls back to just appending the script to the document.documentElement object.

    If you pass false in for the 2nd parameter which tells the function whether or not to remove the script after inserting it then if you view the generated source code for the page you will see the injected script code in the DOM.

    The code looks within the HEAD for another script block and if found it inserts it before the first one using insertBefore() however if there is NO script block in the HEAD then the function will just insert the script into the HEAD anyway using the appendChild() method.

    An example of the function in action with a simple bit of JavaScript that stores the original navigator object and user-agent is below. You might find multiple uses for such code in your own work.

    // store the JavaScript in a string
    var code = 'var origNavigator = window.navigator; var origUserAgent = origNavigator.userAgent;";
    
    // now call my function that will append the script in the head before any other and then remove it if required. For testing you may want to not remove it so you can view it in the generated DOM.
    appendScript(code,true);
    
    // function to append a script first in the DOM in the HEAD, with a true/false parameter that determines whether to remove it after sppending it.
    function appendScript(s,r=true){
    
    	// build script element up
    	var script = document.createElement('script');
    	script.type = 'text/javascript';
    	script.textContent = s;
    	
    	// we want our script to run 1st incase the page contains another script e.g we want our code that stores the orig navigator to run before we overwrite it
    
    	// check page has a head as it might be old badly written HTML
    	if(typeof(document.head) !== 'undefined' && document.head !== null)
    	{	
    		// get a reference to the document.head and also to any first script in the head
    		let head = document.head;
    		let scriptone = document.head.getElementsByTagName('script')[0];
    
    		// if a script exists then insert it before 1st one so we dont have code referencing navigator before we can overwrite it		
    		if(typeof(scriptone) !== 'undefined' && scriptone !== null){	
    			// add our script before the first script
    			head.insertBefore(script, scriptone);
    		// if no script exists then we insert it at the end of the head
    		}else{
    			// no script so just append to the HEAD object
    			document.head.appendChild(script);
    		}
    	// no HEAD so fall back to appending the code to the document.documentElement
    	}else{
    		// fallback for old HTML just append at end of document and hope no navigator reference is made before this runs
    		document.documentElement.appendChild(script);
    	}
    	// do we remove the script from the DOM
    	if(r){
    		// if so remove the script from the DOM
    		script.remove();
    	}
    }
    



    I find this function very useful for both writing extensions and also when I need to inject code on the fly and ensure it runs before any other scripts by using a onDOMLoad method.

    Let me know of any uses you find for it.

    Useful Resource: Content Scripts for Chrome Extension Development. 


    By Strictly-Software

    Friday, 11 May 2018

    Don't Fall For Trick Links - Use REL = NOOPENER and NOREFERRER in Browsers

    For the XSS Hole In Browers use NOOPENER and NOREFERRER

    By Strictly-Software

    As some of you might know the rel attribute in anchor tags can be used for more than just nofollow or as some stupid SEO gurus think "follow" which doesn't exist.

    It can also be used to trick users who click links that open pages and then run code that uses the window.opener object to change the page's HTML that you have just come from before closing.

    For example Chrome is good at protecting XSS attacks even from the same origin, however even it can fall victim to trick links. Adding into your rel attribute rel="noopener" should stop the opened page from being able to modify code on the page that opened it through the parent page through the window.opener object.

    However in some browsers this does not work too well, and you should be aware of this as some browsers like FireFox sometimes need an extra noreferrer value added to prevent the opened page from modifying your initial page.

    If you want to see an example of this in action then go to this link on my website www.strictly-software.com/test1.html.

    Try this in FireFox first as that is the browser which doesn't seem to respect the noopener attribute.

    Try it in your own personal browser of choice as well and play around with the code (copy and paste it to your local machine to tamper and run), to see if taking noopener or noreferrer out of the links work or not or whether a blank link with no rel attribute passes the object reference along at all.

    There are two links on the page, the first when clicked should change the page you are looking at to the top part of a Facebook login screen.

    If you can imagine getting a link in your messages, emails or on Facebook itself and clicking it to find that it seems you have been logged out.

    So you login again.

    Only now that the page is not Facebook but a page my trick link or window.open() page has made you think is Facebook. The link or window.open('tamper.html','win') has had it's HTML changed and the hacker is logging your email and password.

    In this example I have just used an image so their is no danger of having your details stolen.

    What the first page does is just offer the user a link to click. It might be from a friend or hacker but once clicked it will use target="_blank" to open a new window.

    As soon as the window is open an onload event is fired that uses the window.opener object to gain access to it's parent and change the HTML.

    I have used a basic example here and an image of Facebook but you can see the code in action.
    
    function RunScam(){
     window.opener.document.documentElement.innerHTML="<html><body><img style='width:1000px' src='FBTest.png' alt='Fake Facebook Page Example' /></body></html>";
     window.close();
    }
    


    I use an onload="RunScam()" function to call that code above.

    This function uses the window.opener object to reference the document.documentElement object and then innnerHTML to reformat the page before closing the new window.

    Remember I am just using an image here so there is no risk but the function could be extended to load in stylesheets, real inputs that record your passwords and look just as real as the site it is faking. It could be a bank, a social media site or any other kind of site people would want to get passwords for.

    Once you have checked the fake link out try the next one.

    It shouldn't do anything but open a blank window.

    Remember the link is at www.strictly-software.com/test1.html as you may have to go back from the fake Facebook page.

    So try this out in FireFox and then you will see the importance of adding noopener and the older workaround when FF didn't support noopener, noreferrer.

    Tuesday, 17 May 2016

    Stopping BOTS - A Multi Layered Approach

    Stopping BOTS - A Multi Layered Approach


    By Strictly Software

    Some people don't mind BOTS of all shapes and form roaming their sites but if you actually look into what they are doing should you be worried about their actions?

    Have you examined your log files lately to see what kind of BOTS are visiting and how much bandwidth they are using?

    Here are a few of the reasons you might want to care about the type of actions carried out by automated crawlers (BOTS):

    1. They eat bandwidth. Social media BOTS especially who jump onto any link you post on Twitter causing Twitter Rushes. This is where 50+ BOTS all hit your site at the same time and if you are not careful could use up all your memory and cause a frozen system if not configured properly. There are plenty of articles about Twitter Rushes on this site if you use the search option down the right hand side to find more details.

    2. Bandwidth costs money. If you are a one man band or don't want high server costs then why would you want social media BOTS, many that provide no benefit to you, costing you money just so they can provide their own end users with a service?

    3. Content theft. If a user-agent identifying itself as IE6 is hitting a page a second is it really a human using an old IE browser visiting that many pages? Of course not. However for some reason IE 6 is the most popular user-agent used by script kiddies, scrapers and hackers. Probably because they have just downloaded an old crawler script off the web and run it without the knowledge to edit the code and change the agent. Look for user-agents from the same IP hitting lots of pages per minute and ask yourself are they helping your business or just slowing your site down by not obeying your robots.txt crawl-delay command?

    4. Hacking. Automated hackbots scan the web looking for sites with old OS systems, old code and potential back doors. They then create a list of sites for their user and come back to penetrate these sites with SQL/XSS injection hacks. Some might show up in GET requests in the log file but if they are tampering with FORM elements then any POSTED data containing hack vectors won't show up. Hiding key response parameters such as your server brand and model and the scripting language you use are good simple measures to prevent your sites name ending up on this list of potential targets to hack and can easily be configured in config files on your system.

    Therefore you should have a defence against these type of automated BOTS. Of course you also have the human hacker who might find a sites contact form, view the source, tamper with the HTML and work out a way to modify it so he can send out mass emails from your server with a custom script. Again security measures should be implemented to stop this. I am not going to talk about the basics of security when it comes to preventing XSS/SQL injection but the site has many articles on the topic and basic input sanitation and database login security measures should stop these kinds of hack.

    So if you do want to stop automated BOTS from submitting forms, registering to your site, applying for jobs and anything else your site might do the following list might be helpful. It is just an off the head list I recently gave to someone on LinkedIn but could be helpful if expanded to your own requirements.

    On my own sites I use a multi pronged approach to stop BAD BOTS as well as bandwidth wasting social media BOTS, hack bots and even manual hackers tampering with the forms. It saves me money as well as increases performance by allowing legit users only to use the site. By banning over 50% of my traffic which is of no benefit to me I can give the 50% of useful traffic a better user experience.

    1) We log (using Javascript), whether the user has Javascript enabled e.g an AJAX call on the 1st page they hit that sets a session cookie using Javascript. As most BOTS don't use Javascript we can assume if they have Javascript enabled they are "probably" human.

    2) We also use Javascript (or the 1st page HTTP_ALL header in IE) to log whether Flash is enabled and the version. A combo of having Flash running and Javascript isbetter than just Javascript on it's own.

    3) I have my own logger DB that records browser fingerprints and IP's, Useragent, Javascript, Flash, HTTP settings, installed apps, browser extensions, Operating System and other features that can almost uniquely identify a user. The problem is of course an IP often changes either through DCHP or the use of proxies, VPN's and hired VPS boxes for an hour or two. However it does help in that I can use this combination data to look up in my historical visitor database to see what rating I gave them before e.g Human, BOT, SERP, Hacker, Spammer, Content Thief and so on. That way if the IP has changed but the majority of the browser finger print hasn't I can make an educated guess. If I am not 100%  sure however I will then go into "unsure mode" where security features such as CAPTCHAS and BOT TRAPS are introduced just in case. I can then use Session variables if cookies are enabled to store the current status of the user (Human, BOT, Unknown etc), or use my visitor table to log the browser footprint and current IP and do lookups on pages where I need to use defensive measures if cookies are not enabled.

    4) These Session/DB settings are then used to decide whether to increment banner hit counters, write out emails in images or with Javascript so that only humans can see them (to prevent BOT email scrapers), and other defensive measures. If I know they are 100% human then I may chose not to deploy these measures.

    5) On forms like contact forms I often use BOT Traps. These are input elements that are in the flow of the form with names like email_extra that are hidden with CSS only. If the BOT submits a value for this hidden input I don't submit the form, or I do but without carrying out the desired action and not let the BOT know that nothing happened.

    6) A lot of forms (especially contact forms) can be submitted by just entering an email address for all fields (name, email, password etc). Therefore I check that the field values are different e.g not the same value for an email AND password field. I also ensure the name matches a name pattern with a regular expression.

    7) I have built my own 2 stage CAPTCHA system which can be turned on or off on the fly for forms where I don't know if the user is 100% human OR I can decide to just always have it on. This is based around a maths question, where the numbers are in 3 automatically created images, grey and blurry like normal CAPTCHA's The user has to first extract the right numbers from the images then carry out an automated sum from those numbers e.g add number 1 to number 2 and deduct number 3. This works very well as it requires a human brain to interpret the question and not just use OCR techniques to extract the CAPTCHA image values. There are so many OCR breakers out there that a standard CAPTCHA where you enter the word on the picture can easily be cracked automatically now.

    8) If there is textarea on the form, contact, application etc, then I use my RUDE word table which has hundreds of variants of rude words and the regular expression next to it to detect them. This can obviously be updated to include pharmacy pill names, download movies, porn and other spam words.

    9) I also have a number of basic regular expressions if the user wants light detection that checks for certain strings such as "download your xxx now", "buy xxx for just $£", and words like MP3s, Films, Porn, Cialis and other common spam words that would have no place on a site not selling such goods.

    10) I always log any blocking so I can weed out any false positives and refine the regular expressions etc.

    11) I also have an incremental ban time so the 1st time anyone gets banned is for 1 hour, then 2, then 4 then a day etc etc.The more times they come back the longer they get banned.

    12) Sometimes I use JavaScript and AJAX to submit the form instead of standard submit buttons. As Javascript is so commonly used now (just look at Google), then most people have it enabled otherwise the majority of sites just wouldn't work or would have minimum features. It would require a human hacker to analyse your page to break it and then write a custom BOT just to hack the form when a technique like this is used. To get round this you can use a rolling random key created server side, inputted into a hidden element with Javascript on page load and then examined on form submission to ensure it is correct. If it's not then the person has tampered with the form by entering an old key not the new key and can be banned or blocked.

    13) Another good way to stop automatic hack BOTs (ones that just roam the web looking for forms to try and submit and break out of to send emails etc - contact forms), is to not use FORM tags in your server side code but have compressed and encrypted JavaScript that on page load converts the <div id="form">....</div> into a real FORM with an action, method etc. Anyone viewing the non generated source code like most BOTS, won't see a FORM there to try to hack. Only a generated HTML source view (once the page has loaded), would show them this, which most BOTS would not be able to view.

    14) Honeypots and Robots.txt logging is also useful e.g log any hit to the robots.txt file and for any BOTS that don't visit it before crawling your site. You can then make a decision to ban them for breaking your Terms Of Service for BOTS that should state they should obey your Robots.txt rules.

    15) As BAD BOTS usually use the links in the DISALLOW section of Robots.txt to crawl anyway. Then putting a fake page in the list of URLs is a good idea. This page should be linked to from your site in a way that humans cannot see the link and accidentally visit it (and if they do it should have a Javascript link on it to enable them to get back to the site). However BAD BOTS will see the link in the source and crawl it. As they have broken your TOS and followed a URL in your DISALLOW list they are being doubly "bad", so you have the right to send them off to a honeypot (many exist on the web that either put emails out for them to extract then wait for an email to be sent to that address to prove they are an email scrapper bot) OR they get sent to an unbreakable maze like system which auto generate pages on the fly so that the BOT just keeps going around in circles crawling page after page and getting nowhere. Basically wasting their own bandwidth.

    16) HTACCESS Rules in your .htaccess file should identify known bad bots as well as IE 6, 5 and 5.5 and send them off to a 403 page or a 404 so they don't realise they have been sprung. No-one in their right mind should be using these old IE browsers anymore however most downloadable crawlers used by script kiddies still use IE 6 as a user-agent for some reason. My guess is that they were written so long ago that the code hasn't changed or that people had to support IE 6 due to Intranets being built in that technology e.g using VBScript as the client side scripting language.

    By using IE 6 as a UA they get access to all systems due to sites having to support that ancient horrible browser. However I ban blank user-agents, user-agents less than 10 characters long, any that contain known XSS/SQL injection vectors and so on, There is a good PHP Wordpress plugin called Wordpress Firewall that if you turn on all the features and then examine the output in your .htaccess file will show you some useful rules such as banning image hot linking that you can then nick for your own file.

    17) Sending bad bots back to their own server is always a good trick so that they get no-where on your own site. Another good trick is to send them to a site that might scare the hell out of them once they realise they have been trying to hack or DDOS it https://www.fbi.gov/wanted/cyber or the METS Cyber Crime department.

    These are just a few of the security measures I use to stop BOTS. It is not a comprehensive list but a good starting point and these points can be expanded and automated depending on who you think is visiting your site.

    Remember most of these points are backed up with detailed articles on this site so have a search if anything spikes your interest.

    Hope this helps.

    By Strictly Software


    © 2016 Strictly Software

    Monday, 9 February 2015

    Speeding up Chrome can KILL IT!

    Speeding up Chrome can kill it!

    By Strictly-Software

    Lately I have been really disappointed with the performance of my preferred browser Chrome.

    I moved from FireFox to Chrome when the amount of plugins on FireFox made it too slow to work with however this was when Chrome was a clean, fast browser. Now it has just as many plugins available to install as FireFox and the performance has deteriorated constantly over the past few versions.

    I am a developer so having 20+ tabs open in my browser is not unusual however when they are all hanging for no reason with "resolving host" messages in the status bar something is wrong.

    I have even removed all my plugins that I had installed and decided to leave that to FireFox if I need to test different agents, hacking and so on. However even with a simple install the performance has been crap lately!

    Therefore looked up on the web for tips on speeding up Chrome and found this article:

    http://digiwonk.wonderhowto.com/how-to/10-speed-hacks-thatll-make-google-chrome-blazing-fast-your-computer-0155989/

    It basically tells you some tricks to speed up Chrome by modifying some settings by going to chrome://flags/ in your address bar.

    There is a warning at the top of the page that says:

    WARNING These experimental features may change, break or disappear at any time. We make absolutely no guarantees about what may happen if you turn one of these experiments on, and your browser may even spontaneously combust. Jokes aside, your browser may delete all your data or your security and privacy could be compromised in unexpected ways. Any experiments that you enable will be enabled for all users of this browser. Please proceed with caution. Interested in cool new Chrome features? Try our beta channel at chrome.com/beta.

    So these are all "experimental" features and from the sounds of it they could even make it's security and performance worse not better. Even a few of the tweaks suggested by the article had already disappeared from the settings page.

    I did what was still available and a few more tweaks after careful consideration and what happened?

    Well at first some pages seemed to load quicker but then I found that:

    • Some sites without a www. sub domain wouldn't load.
    • Some pages wouldn't load at all.
    • When I came into work today even though a Chrome process was running with 0 CPU usage nothing was displayed.
    I had to re-boot, and try 3 times to open Chrome before getting back to the chrome://flags/  page and restoring all the defaults. Since then everything has been okay.

    So if your going to tweak be careful - it could take down your whole browser!

    The best way to speed it up is to remove all the plugins and add-ons and leave that to FireFox. Turn off 3rd party cookies and any 3rd party services that involve constant lookups and try to keep it clean and simple.

    It seems that with the over usage of AJAX and sites like Facebook/LinkedIn/Google+ where as you type it constantly looks up the word to see if it matches a name or contact that this "API JIZZ" as I call it has really slowed down the web.

    Just by having Google+, Facebook and LinkedIn open at the same time can eat up your memory and I'm on a quad core 64 bit machine.

    In my opinion there should be settings to enable you to turn off the API JIZZ and flashy features that rely on lots of JavaScript and AJAX.

    It slows down your computer and is not needed most of the time. Having big database lookups on each keystroke is obviously going to use up lots of memory so it should be an option you can disable.

    Anyway that's down to the developers of all these social sites who seem to love AJAX for everything. A simple submit button would do in a lot of cases!


    Monday, 28 January 2013

    Accessing your computers external IP address from your computer without using a browser

    Access your computers external IP address from your desktop without using a browser

    Following on from yesterdays blog post about what can happen if you get given a new IP address and don't realise it, you might want a quick way to check your external IP address from your computer without having to open an Internet browser.

    There are many "What is my IP address" sites about that show you your IP address plus other request headers such as the user-agent but you might want a quick way of seeing your external IP without having to open a browser first.

    If you are using a LINUX computer it's pretty easy to use CURL or WGET to write a small script to scrape an IP checker page and return the HTML contents.

    For instance in a command prompt this will return you the IP address using CURL by scraping the contents of icanhazip.com.

    This site is good because it outputs the computers IP address that's accessing the URL in plain text so it means you don't have to do any reformatting at all.

    curl icanhazip.com

    However if you are on a Windows computer there is no simple way of getting your external IP address (the IP address your computer is seen on the outside world) without either installing Windows versions of CURL or WGET first or writing a script to do it for you using Microsoft objects.

    Of course it would be nice if you could just use ipconfig from the command prompt to show your external address as well as your internal network details but unfortunately you can't do that.

    As you're connected to the Internet through your router your PC isn't directly connected to the Internet.

    Therefore there is no easy way you can get the IP address your ISP has assigned to your computer without seeing it from another computer on the Internet.

    Therefore you can either use one of the many IP checker tools like whatismyip.com or icanhazip.com to get the details. Or you can even just click this link to search for "what is my IP address" and get Google to show you your IP address above the results.

    However if you do want to do it without a browser you can write a simple VBS script to do it for you and then you can access your external IP from your desktop with a simple double click of the mouse.

    How to make a VBS Script to get your computers external IP address.
    1. Open notepad.
    2. Copy and paste the following VBS code into a new notepad window. 
    3. Save the file as "whatismyip.vbs" on to your desktop.
    4. To view your IP address just double click the file icon and a Windows message box will open and show you the IP address.
    The script is very simple and all it does is scrape the plain text contents of the webpage at icanhazip.com and output it in a pop-up - simples!

    Option Explicit
    Dim objHTTP : Set objHTTP = WScript.CreateObject("MSXML2.ServerXmlHttp")
    objHTTP.Open "GET", "http://icanhazip.com", False
    objHTTP.Send
    Wscript.Echo objHTTP.ResponseText
    Set objHTTP  = Nothing

    If you really want to use this from the command line you can do it by following these steps.
    1. Open a command prompt.
    2. Type "cscript " leaving a space afterwards (and without the quotes!).
    3. Drag the whatismyip.vbs file to the command prompt so that you have a space between cscript and the path of the file e.g C:\Documents and Settings\myname>cscript "C:\Documents and Settings\myname\Desktop\whatismyip.vbs"
    4. Hit Enter.
    5. The IP address will appear after some guff about the Windows Script Host Version.


    The output should look something like this:

    C:\Documents and Settings\
    myname >cscript "C:\Documents and Settings\myname\Desktop\whatismyip.vbs"
    Microsoft (R) Windows Script Host Version 5.7
    Copyright (C) Microsoft Corporation. All rights reserved.
    89.42.212.239
    

    So there you go, a LINUX and WINDOWS way of accessing your external IP address from your desktop without having to open Chrome or FireFox.

    Wednesday, 12 December 2012

    HackBar Not Showing in Firefox

    How to display the HackBar in Firefox

    My preferred browser for the Internet is Google Chrome. I moved to Chrome because of it's speed and simplicity as well as the fact that like most people, when I got disillusioned with IE and moved to FireFox I installed so many plugins that it became so slow to load and has gone through periods of hanging and high CPU and memory usage.

    Therefore I have decided to use FireFox for certain development and debugging when I want to use plugins. Plugins such as the Colour Picker ColorZilla, the Web Developer Toolbar, the Modify Header plugin or any number of others I have installed. I then keep Chrome plugin free to keep it fast for browsing.

    I did try Chrome out with plugins when they first started supporting them but I soon decided I didn't want to turn Chrome into another FireFox by overloading it with plugin checking at start up which has happened with FireFox.

    So Chrome is plugin free and fast, FireFox is useful and handy, full of plugins and tools and good for development and although IE 9 is fast and probably just as good nowadays I am guessing most developers won't go back to it after Microsoft taking numerous versions to just standardise their code and CSS after years of complaining from the masses.

    One of the plugins I use on FireFox a lot is the HackBar.

    Not only is it useful for loading up long URL's, quickly Base64 decoding or encoding strings as well as URL Encoding and Decoding but it has numerous other features if you want to test your site out for XSS or SQL injection vulnerabilities.

    However I usually find I use it mostly for quickly encoding and decoding strings and sometimes I find myself having to put really long ones in the box and extending it so much the viewport becomes unusable. I then find myself disabling the add-on.

    However on more than a few occasions now when I come to re-enable the HackBar by right clicking in the menu bar and ticking the option for HackBar OR using the "View > HackBar" menu option. I then find that it doesn't display as expected and hunting around for it is of no use at all.

    You can try disabling it in the Add-ons section or even un-installing and re-installing it but even then it might not appear.

    However I have found that a quick hit of the F9 key will make it show. Simples!

    So if you are ever having issues trying to make toolbars or plugins show that you have de-activated try the F9 key first before anything else.

    Tuesday, 10 January 2012

    Problem with Google Chrome and Twitter

    Google Chrome 16.0 and Twitter Direct Message Problem

    First, I can't believe my version of Chrome is now on 16.0.912.75. It seems like only yesterday I had Chrome version 1 and it didn't change for a good while.

    Unlike Internet Explorer which refuses to force automatic updates on their browser users which mean developers still have to cater for IE 6 and non standard compliant code due to IE 9 not being available on Win Vista or XP. I do appreciate that they automatically upgrade the browser when required.

    However it does seem like FireFox (version 9.0.1 I am currently on now) and Chrome are in some kind of race to see who can get to version 100 first. I haven't exactly noticed many differences between all these nightly version changes so it must be bug fixing as if it isn't I have no idea what it is apart from security hole patches.

    Anyway, I recently got a new laptop for work (a DELL, 64bit, quad core i5 Win7) which is good APART from the horrible, horrible flat mouse pad which seems to go into sticky scroll mode a lot. You know when suddenly the mouse cursor turns from a pointer into cross-hairs and as you move the cursor the whole page scrolls with it.

    Tonight I noticed an issue with this and Twitter's new format for Direct Messages which open in a draggable DIV popup.

    I went to write a Direct Message and the cursor went into sticky mode. I couldn't remove the mouse cursor from the pop div as wherever it went so did the popup box. Very annoying.

    What was interesting was that as soon as this issue occurred my CPU and Memory for the Google Chrome.exe *32 process went shooting through the roof and my laptop turned into a helicopter. I honestly thought the machine was going to take off it was that loud from the hard-drive spinning away.

    The only solution was to move the cursor off the webpage to the toolbar and kill the page totally and as I did the CPU and Memory dropped like a stone from a cliff.

    This is obviously an issue with DELL's mousepad but it reminded me of an issue I had with my own HTML WYSIWYG editor which was a pop DIV you could drag about the screen.

    The editor had a couple of listboxes on it for selecting fonts and sizes etc but because I had a a drag event attached to a mousedown and mousemove event it meant that you could never actually open the list and scroll it down to the bottom as if you did all that happened was the Editor moved around the screen.

    It was a simple drag n drop solution which was fired by a mouse down event setting a flag so that when set any mouse move event moved the referenced DIV until a mouse up event set the flag off.

    I got round the problem at first by just making the top and bottom sections of the DIV container for the editor draggable which did fix the issue but in the end I settled for what is getting more common as a solution for the old pop up window, the lightbox.

    I don't know why Twitter need to make their new message pop div's draggable as they change the backgrounds opactity like a lightbox anyway so I don't see the point in the draggable effect at all.

    I know it would certainly help with my DELL's sticky mousepad problem!

    Wednesday, 31 August 2011

    Would you switch back to IE9 now that they have finally made a good browser?

    Now that IE9 is standards compliant and actually good will you switch back to using it?

    A few months ago I wrote an article about why I hated debugging in IE8 which revolved around their single threaded event model (window.event) and the delay it took before debug messages were outputted to the console.

    A member of the Microsoft team commented that he had run the test case I had created in IE9 and that it had run perfectly. No high CPU, no frozen console, no high memory usage or other performance problems at all.

    As you cannot install IE9 on WinXP, which is what I use on my home laptop (due to Vista being shite), I haven't had the pleasure of using Internet Explorer 9 a lot until I installed Windows 7 on my work PC.

    I have to say that Windows 7 is actually a great operating system and I especially love the way it has incorporated many of the features of clean up and performance tuning tools like Tune Up Utilities and CCleaner into the main OS.

    I also have to say that Internet Explorer 9 is the first IE browser I actually like.

    Not only is it blindingly fast they have finally listened to their customers who have been complaining for years and made their JavaScript engine standards compliant.

    Obviously this makes the Browser / Document mode spaghetti even harder to detect and I haven't been able to find a way as of yet to detect IE 9 browser mode running as IE 8 or 7 on 32 bit machines but that is not a major issue at all.

    What I am wondering though is that now that IE9 is actually a good browser, with a good inbuilt development console and element inspection tools, how many developers will actually return to using it either as their browser of choice for surfing the web or for their primary development.

    My browser development survey which I held before IE9 was released showed that developers would rather use Chrome or Firefox for surfing and would also always choose the development tools that those browsers bring than use IE 7 or 8.

    I know that I changed from using IE to Firefox as my browser of choice some eons back and I changed from Firefox to Chrome for both surfing (speed is key) and developing (no need for Firebug or any other plugin) the other year when Firefox started to suffer major performance problems.

    These performance problems are always either to do with having far too many plugins installed. Setting the browser up to check for new versions and any installed plugins on start up which cause long load times, Firebug issues and errors in the Chrome source. This is on top of all the constant problems that Flash seems to bring to any browser.

    I use Chrome for surfing due to it's speed but if I leave a few tabs open all night that contain pages running Flash videos then by morning my CPU has flat-lined and memory has leaked like the Titanic.

    This is more a problem with Flash than Chrome and I try to keep this browser for surfing as clean and as fast as possible by not installing plugins. Then if I need to hack around or do some hardcore web development I will use Firefox and all the great plugins when I need to.

    I don't think I could really get hacking with Chrome alone as when I am really getting stuck into a site I need my key plugins e.g the web developer toolbar, hackbar, header modifier, Request and Response inspectors e.g HTTP Fox, Firebug, ColorZilla, YSlow and all the Proxy plugins that are available.

    However for basic development, piping out messages to the console, inspecting the DOM and checking loaded elements and their responses then Chrome has everything Firebug has without all the JavaScript errors.

    In fact it's surprising how many developers don't even realise how much is possible with Chrome's inbuilt developer tools, speed tests, header inspectors, element inspectors and DOM modifiers and other great debugging tools that used to be the preserve of Firebug alone.

    Which leads me back to IE9.

    Yes it's fast and it's developer tools are okay with options to clear cookies, disable JavaScript, inspect the DOM and view the styles but it's no Chrome or Firebug yet;

    Therefore what I want to know is how many people (and by that I mean developers) will switch back to using Internet Explorer 9 for pure web surfing?

    For sure it's fast, supports the latest CSS standards and all the great HTML 5 features that we have all seen with floating fish tanks and the like. But is this enough for another browser switch?

    I have all the major browsers installed at work on Win7 including IE9, Firefox, Chrome, Opera, Safari, SeaMonkey and a number of others I cannot even remember the names of they are that obscure.

    Before upgrading I even had Lynx and Netscape Navigator 4 installed as I used to be so anal that any code such as floating DIV's had to work in the earliest browsers possible. However I only use these browsers for testing and I stick to Chrome (for surfing) and Firefox (for hacking) which leaves little room for IE9 at the moment.

    I know it's a good browser. It's standards compliant and it no longer crashes when I try to output anything to the console so why shouldn't I try it again.

    Maybe one of my readers can help me decide on the browser of choice for surfing and development and how IE9 fits into that toolset.

    Maybe I am missing some really cool features that I would use all the time but to be honest I am not into throwing sheep at randoms or constantly voting sites up and down and writing comments on them. Therefore for me to switch back from Chrome to another browser such as IE9 there has to be a really good reason for me to do so.

    So does anyone have any reason why I should re-consider using IE9 at work for my web surfing or development?

    Saturday, 22 May 2010

    Problems with LINUX, Apache and PHP

    LINUX Apache Server stopped serving up PHP pages

    By Strictly-Software

    When I logged into my hosted LINUX web server earlier tonight I was met with a message saying I should install a number of new packages.

    I usually ignore things like this until it gets to a point where someone forces me to do purely for reasons that will shortly become obvious.

    The packages were the following:
    • apache2.2-common
    • apache2-mpm-worker
    • apache2
    • usermin
    • libapt-pkg-perl
    • apt-show-versions
    • webmin
    • webmin-virtual-server
    I have no idea what most of them do but they had been sitting around for a long time waiting for me to install them and tonight was the night. These are always nights I dread!

    Shortly after doing the updates I noticed that my WordPress sites had stopped working and all the PHP files were being served up as file attachments with a content type of application/x-httpd-php instead of being parsed, executed and then delivered as text/html.

    At first I thought it was something to do with the SQL performance tweaks I was doing but I soon remembered about the updates and I went off hunting the web for a solution.

    It's nights like these that make me wish I was back doing carpet fitting, finishing the day at 3 pm and then going down the pub. Much more enjoyable than spending Friday nights scratching my head wondering what the hell I had done to bring down my websites at 3 am.

    To cap off the nightmare I had just spent ages writing a detailed message to post on an APACHE web forum only for my session to timeout and then for the site to refuse to log me in.

    They then decided to block me for failing 5 login attempts in a row. Obviously I couldn't get back my message so I was pretty pissed right now!

    For some reason APACHE had stopped recognising PHP file extensions and I still don't know what had happened under the covers but after a long hunt on Google I came across the solution.

    The libapache2-mod-php5 module had somehow disappeared so I had to re-install it with the following lines:

    sudo apt-get purge libapache2-mod-php5
    sudo apt-get install libapache2-mod-php5
    sudo a2enmod php5
    sudo /etc/init.d/apache2 restart
    I also added the following two lines to /etc/php5/apache2/php.ini

    AddHandler application/x-httpd-php .php
    LoadModule php5_module modules/libphp5.so
    I then cleared my browser cache and low and behold my site came back.

    Maybe this info might come in handy for anyone else about to upgrade packages on their server or serve as a reminder of what happens when you try to behave like a sysadmin and have no real idea what your doing!

    It also should make you glad that we live in the days where a Google search can provide almost any answer you are looking for. I doubt I would have owned, let alone found, a book that would have been of any use at 3am on a Saturday morning.

    So despite all their snooping, minority report advertising and links to the alphabet agencies they are good for something.

    Monday, 29 March 2010

    My Hundredth Article

    An overview of the last 102 articles

    I really can't believe that I have managed to write 102 articles for this blog in the last year and a bit. When I first started the blog I only imagined writing the odd bit here and there and saw the site purely as a place to make public some of my more useful coding tips. I never imagined that I could output this amount of content by myself.

    A hundred articles has come and gone pretty fast and as with all magazines, tv shows and bloggers stuck for an idea I thought I would celebrate my hundred and 2nd article by reviewing my work so far.

    Recovering from an SQL Injection Attack

    This was the article that started it all and it's one that still gets read quite a bit. It's a very detailed look at how to recover an infected system from an SQL Injection Attack and includes numerous ways of avoiding future attacks as well as quick sticking plasters, security tips and methods for cleaning up an infected database.

    Linked to this article is one of my most downloaded SQL scripts which helps identify injected strings inside a database as well as removing them. This article was written after a large site at work was hacked and I was tasked with cleaning up the mess so it all comes from experience.

    Performance Tuning Tips

    I have wrote quite a few articles on performance tuning systems both client and server side and some of my earliest articles were on top tips for tuning SQL Databases and ASP Classic sites. As well as general tips which can be applied to any system I have also delved into more detail regarding specific SQL queries for tuning SQL 2005 databases.

    Regarding network issues I also wrote an extensive how to guide on troubleshooting your PC and Internet connection which covered everything from TCP/IP settings to tips on the best tools for cleaning up your system and diagnosing issues. On top of that I collated a number of tweaks and configuration options which can speed up FireFox.


    Dealing with Hackers, Spammers and Bad Bots

    My job means that I have to deal with users trying to bring my systems down constantly and I have spent considerable time developing custom solutions to log, identify and automatically ban users that try to cause harm to my sites. Over the last year I have written about SQL Denial of Service attacks which involve users making use of web based search forms and long running queries to bring a database driven system to a halt. I have also investigated new hacking techniques such as the two stage injection technique, the case insensitive technique, methods of client side security and why its almost pointless as well as detailing bad bots such as Job Rapists and the 4 rules I employ when dealing with them.

    I have also detailed the various methods of using CAPTCHA's as well as ways to prevent bots from stealing your content and bandwidth through hot linking by using ISAPI rewriting rules.

    Issues with Browsers and Add-Ons

    I have also tried to bring up to date information on the latest issues with browsers and new version releases and have covered problems and bugs related to major upgrades of Firefox, Chrome, Opera and IE. When IE 8 was released I was one of the first bloggers to detail the various browser and document modes as well as techniques for identifying them through Javascript.

    I have also reported on current browser usage by revealing statistics taken from my network of 200+ large systems with regular updates every few months. This culminated in my Browser survey which I carried out over Christmas which looked at the browsers and add-ons that web developers themselves used.


    Scripts, Tools, Downloads and Free Code

    I have created a number of online tools, add-ons and scripts for download over the last year that range from C# to PHP and Javascript.

    Downloadable Scripts Include:

    SQL Scripts include:

    Search Engine Optimisation

    As well as writing about coding I also run a number of my own sites and have had to learn SEO the hard way. I have wrote about my experiences and the successful techniques I have found that worked in a couple of articles printed on the blog:
    So there you go an overview of the last year or so of Strictly-Software's technical blog. Hopefully you have found the site a good resource and maybe even used one or two of the scripts I have posted. Let me know whether you have enjoyed the blog or not.

    Saturday, 6 February 2010

    Browser Survey Results

    The results of the Strictly Software Browser Survey

    If you have visited my site in the last couple of months you may have noticed the survey on Browser usage that popped up. It was geared towards developers to gather information about their favourite browsers in terms of developing, debugging and features.

    I have let it run for a couple of months and now I am publishing the results. Thanks to everyone who took the time to answer the questions.


    Question 1: Which browser do you use when developing new code

    Firefox 56%
    Internet Explorer 21%
    Chrome 10%
    Opera 6%
    Safari 5%
    Other Option... 2%


    Question 2: Which browser has the best inbuilt features for developing

    Firefox 44%
    Chrome 19%
    Internet Explorer 17%
    Safari 8%
    Opera 8%
    Other Option... 3%


    Question 3: Which browser do you use for personal web surfing

    Firefox 50%
    Chrome 22%
    Internet Explorer 14%
    Opera 8%
    Safari 5%
    Other Option... 1%


    Question 4: Which developer tool do you consider has the best features

    Firebug 64%
    IE 8's developer toolbar 17%
    Webkit's Developer Tools 7%
    Other Option... 5% (the majority of which said Web-Developer add-on for FireFox)
    DragonFly 4%
    Firebug-Lite 2%


    Question 5: Which one feature could you not live without

    Element inspection 40%
    Dynamic DOM manipulation 20%
    View generated source 18%
    Clear cookies and cache 14%
    Disable Javascript 6%
    Other Option... 2%

    I don't think anything stood out for me as a major surprise in the answers I received. In any survey done over the last 10 years or so over the whole web surfing community Internet Explorer always comes out in top place for browsing but the majority of users questioned are not developers and a large percentage of those are still only using it because they actually believe the little blue e on their desktop IS the Internet.

    This is shown by a recent NetApps survey that found IE 8 has just taken the top spot from IE 6 and that Firefox 3.5 has taken 3rd place narrowly just beating IE 7. This is not much of a surprise to me as my own reports from the 200+ sites I run always show IE 6,7,8 taking the top 3 spots with over 75% of all usage between them.

    However when looking at browser usage for people in the industry i.e web developers and designers FireFox seems to always take top spot purely because of the numerous add-ons and built in features. However I also know from personal experience and from colleagues that within the year or so Chrome has been around it has built up quite an on-line following and for pure web surfing I personally don't think it can be beaten for speed, simplicity and usability and this seems to be proven by it taking 2nd place as the browser techies like to use when surfing.

    Anyway thanks for taking part.


    Sunday, 27 December 2009

    Reasons why Google Chrome is a great Browser

    A list of reasons why Google Chrome is a great Browser

    Ever since Google introduced Chrome I have been using it all the time for surfing the net. I had been using FireFox purely for the standards compliance, speed and features but then the more features that were added the slower it got.

    I still use FireFox for development and its rich library of plugins and you can speed it up by following the tweaks listed in my Increasing FireFox Performance article. However when I just want to surf the net, watch movies or read articles Chrome is the browser I choose. Here are some reasons why.

    • Reason 1 Chrome is great > It's simple to use and not full of features that are purely there for marketing but you never use. It does the job simply and it does it well.
    • Reason 2 Chrome is great > The Bookmark bar is great for storing quick links to your favourite sites.
    • Reason 3 Chrome is great > It's Fast. It's fast to startup and fast to load pages. It's JavaScript engine is also fast and solid its less forgiving than FireFox that could be considered a good thing or a bad thing depending on how sloppy your code is.
    • Reason 4 Chrome is great > It's Easy to surf in a semi private mode e.g Incognito browsing any cookies are destroyed after browsing and no download or browsing history is kept.
    • Reason 5 Chrome is great > The inbuilt developer tools are pretty good. The Developer console offers a good debugger, JavaScript console, DOM viewer and element inspector.
    • Reason 6 Chrome is great > Its standards compliant.
    • Reason 7 Chrome is great > It now has support for add-ons and plugins so can compete with FireFox for great features. Turn off adverts and flash by default to speed up load time even more. Read my article on Google Chrome plugins for more details.

    Thursday, 24 December 2009

    Performance Tuning your PC and Internet Connection

    How to performance tune your Computer and Internet Connection

    I recently had major issues with performance on my laptop and an intermittent slowdown which meant that I couldn't watch streamed movies (e.g YouTube) or remotely access my office computer due to the slow internet connection. Certain times of the day it was fine but at night it was generally bad. This article is based on the steps that I used to diagnose and overcome the problem. It can also be used by those of you who just wish to get the best performance out of your computers.

    Is the problem related to your Internet speed or overall computer performance?

    Are you only experiencing problems when you are on the Internet such as slow loading web pages, stuttering video streaming or videos just not playing. Or are you having problems running desktop applications such as programs that are slow to open or files that are slow to save. Is just navigating your PC a task in itself or are you experiencing popups all the time that you don't recognise asking you "To run performance checks", "Install this Spyware checker" or pages filled with adverts or links to advertisements that you don't know where they have come from?

    Computer Related Problems

    First thing is to ensure you don't have a virus, Trojan or Spyware on your PC.
    • If you use Internet Explorer to surf the Internet then there is a good chance you might have a virus as this browser is well known for its many security holes. Consider changing your browser to either Chrome or Firefox. Chrome is a very fast browser and Firefox is a favourite of developers due to the huge number of add-ons available for it.
    • If you use a PC Make sure you install any Windows updates as they reguarly contain patches for security vulnerabilities.
    • If you don't have a virus / spyware checker installed then download one of the good free ones e.g Malwarebytes Anti-Malware, Spybot Search and destroy, Ad-Aware or even better download multiple applications as its not uncommon for one app to find items that another one will not. Remember to always update the virus definitions before running it.
    • If your virus software doesn't find a virus it doesn't mean you don't have one it could just mean that its either a new virus that definitions haven't been created for or its already managed to take hold of your PC and block any virus checker from finding it. Try running a program such as Trend Micro's HijackThis which checks for suspicious looking processes and activity on your PC rather than looking for known virus definitions. If you are unsure about a flagged item you should send the outputted report to one of the recommend forums where specialists will analyse the report and give you detailed info on any action required such as running the Trojan removal tool SDFix.exe.
    Once spyware and viruses have been ruled out you should run some basic maintenance on your computer which can be done manually or by downloading one of the many optimiser tools that are available on the net. I have investigated many of these tools and by far the best one I have found is TuneUp Utilities which offers all the tools you need to clean and speed up your PC and browser with a very easy to use interface.

    TuneUp Utilities 2010

    It offers the ability to modify computer and browser settings to speed up your browsing, remove un-used programs, clean up and defrag your hard-drive and registry, speed up your PC by disabling a number of memory and CPU intensive operations that offer little benefit and much more. There is also a "One Click Optimiser" button which checks your system and offers the solutions. If you want to save a lot of time downloading numerous tool or doing it all by hand then this is the tool for you.

    Tuning up your PC Manually

    • Defrag your hard-drive. Over time your disk will get fragmented as new files are added and existing ones are edited or deleted. A heavily fragmented drive slows down file retrieval and saving. You can do this through the Accessories > System Tools > Disk Fragmenter option or you can download a tool like Defraggler to do this for you.
    • Remove old programs and shortcuts to those programs if you never use them any-more. You can use the Add-Remove programs option from the Control Panel to do this or download a program like CCleaner which offers a number of options to help clean up your computer.
    • Remove anything from your startup menu that you hardly use or don't require to be running when you start-up your computer.
    • Clean up your Registry. Often when files are installed or deleted keys are left in the registry that are no longer required. Like any database the more useless information it contains the slower the retrieval of useful info becomes. A tool like TuneUp Utilities or CCleaner offers you the ability to do this easily without having to trawl through the registry looking for keys by hand.
    • Disable memory and CPU intensive operations that run in the background when you require optimal performance. For example disk defragmentation or a full virus scan will slow down your PC when running. This is one of the good things about TuneUp Utilities Turbo Mode as it can be set on or off when required and will ensure that any CPU or Memory intensive operations can be disabled when you require optimal performance.
    • Configure the advanced settings in Control Panel > System > Advanced > Performance.
      1. Under the Visual Effects tab you should set the option to "Adjust for best performance".
      2. On the Advanced tab you should ensure Processor Scheduling and Memory Usage is set to Programs
      3. For Virtual Memory make sure both the initial and maximum size are set the same which according to Microsoft its recommended that this should be 1.5 times your system memory.
      4. Under the Data Execution Prevention tab you should set to"turn on DEP for all programs and services except those I select"
    • Clean up your temporary browser files. Make sure your cache and Internet history doesn't get too large so clean all temporary Internet files on a regular basis. The cache is great for helping sites you regularly visit load quickly but the larger it gets the slower page loads get for all sites.
    • Remove any add-ons that you never use anymore. In Firefox the more add-ons you have the slower the browser can be when loading and they can even cause errors. You will often have duplicate add-ons e.g different versions of Java which can be removed.
    • Install Advert and Flash blocker add-ons if your browser supports it (Firefox, Chrome). Without having to load Flash files and other adverts the page load times can be increased dramatically.
    • Disable JavaScript by default. Not only do most web delivered viruses use JavaScript to infect new PC's it can slow down page load times and make pages seem unresponsive during certain events e.g window, DOM load. All browsers will let you disable JavaScript and in IE VBScript from their inbuilt Options. However to make it easier to set which sites have it on and off you can install add-ons such as NoScript or the Web Developer toolbar. A lot of sites use JavaScript to display adverts, load flash or other videos, validate form fields and deliver other forms of content. Therefore you may find that by having JavaScript disabled you have reduced functionality on many sites. However pages should load a lot quicker and if you do trust the site or require the missing functionality you can always re-enable it.
    • Disable 3rd party cookies. These are cookies that are not set by the site you are visiting and are usually used by advertisers for tracking the sites you visit so that they can deliver more targeted advertisiments. Even Google uses these kinds of cookies now and many people consider them an invasion of their privacy which is why most Spyware tools identify them as items to be removed. This is how to disable 3rd party cookies in the top 3 browsers.
      1. Chrome you can do this by going to Tools > Options > Under The Hood > Privacy > Cookie Settings > Accept cookies only from sites I visit.
      2. Internet Explorer go to Tools > Internet Options > Privacy and then set your Privacy level to Medium high which will disable most 3rd party cookies and some 1st party ones. This will still allow you to login to sites but should prevent all the tracker and advert cookies that accumulate as you surf the net.
      3. Firefox removed the option to block 3rd party cookies in version 2 saying it was impossible to accomplish however you can still do this by either installing an add-on called CookieSafe or changing your user preferences by entering about:config in the address bar and then searching for network.cookie.cookieBehavior. The possible values are 0 which accepts all cookies, 1 only accept cookies from the same server and 2 disable all cookies. Set it to 1 to block 3rd party cookies.
    • Enable Popup blockers and disable any un-used toolbars e.g Google, Yahoo etc.
    • In FireFox disable Firebug and any other DOM manipulating add-ons and only enable them when required. Firebug has steadily got worse over the years in slowing down sites due to all the extra functionality that has been added to it. Therefore it should only be used when developing sites or when you need to use one of its features. The same goes for any other add-ons that you only use on certain sites or at certain times. Having less add-ons to load will increase page load times.
    • In Firefox tweak your config settings to improve performance. Read this article on which settings to tweak to get the best performance possible.
    Testing for Network Problems

    If you are having issues with slow loading pages when browsing or video streaming then you need to find out whether the problem is local to your home or a general network problem that you need to contact your ISP about.

    Before doing anything else you should get some basic details of your network if you don't know them already such as the IP address of your gateway to the internet. Open a command prompt window and type "ipconfig". You should note down the results e.g

    C:\Documents and Settings\me>ipconfig
    
    Windows IP Configuration
    
    Ethernet adapter Local Area Connection:
    
    Media State . . . . . . . . . . . : Media disconnected
    
    Ethernet adapter Wireless Network Connection:
    
    Connection-specific DNS Suffix  . :
    IP Address. . . . . . . . . . . . : 192.168.1.3
    Subnet Mask . . . . . . . . . . . : 255.255.255.0
    Default Gateway . . . . . . . . . : 192.168.1.1 


    Note down the IP address and the Default Gateway address. The IP Address is your computer and the default Gateway is your connection to the outside world. In this case its a wireless router which is then connected to the Virgin Cable box.

    We can now test whether the network problem is with my PC to the wireless or the main router or somewhere else by doing some PING tests.

    A "Ping" measures the time that passes between the initial send of the Ping, and the receival of the "Reply" by the machine you pinged. The amount of time that passes during a ping is slightly influenced by the amount of hardware the ping is passed trough, as each would have to relay the ping further. However, there is no set formula for this, as the ping speed also depends upon the speed of the network, how busy it is, and so on.

    • A ping to your default gateway should be very quick e.g 1-2 ms
    • A ping to other computers on your LAN should be between 1-10 MS (good)
    • Pings to external websites such as www.google.com take anything from 20 - 150 MS anything under 50ms is good to an external site.
    • Pings to sites on the other side of the world that go through many hops e.g from the UK to www.china.com should report times of <500ms if the network is good.
    So lets do some ping's, first to my gateway then to www.google.com and then to somewhere very far away e.g www.china.com.

    C:\Documents and Settings\me>ping 192.168.1.3
    
    PPinging 192.168.1.3 with 32 bytes of data:
    
    Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
    Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
    Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
    Reply from 192.168.1.3: bytes=32 time<1ms TTL=128
    
    Ping statistics for 192.168.1.3:
     Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
     Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\Documents and Settings\me>ping www.google.com
    
    Pinging www-tmmdi.l.google.com [216.239.59.103] with 32 bytes of data:
    
    Reply from 216.239.59.103: bytes=32 time=32ms TTL=52
    Reply from 216.239.59.103: bytes=32 time=28ms TTL=52
    Reply from 216.239.59.103: bytes=32 time=32ms TTL=52
    Reply from 216.239.59.103: bytes=32 time=30ms TTL=52
    
    Ping statistics for 216.239.59.103:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 28ms, Maximum = 32ms, Average = 30ms
    
    C:\Documents and Settings\me>ping www.china.com
    
    Pinging chcache.china.com [124.238.253.102] with 32 bytes of data:
    
    Reply from 124.238.253.102: bytes=32 time=606ms TTL=48
    Reply from 124.238.253.102: bytes=32 time=526ms TTL=48
    Reply from 124.238.253.102: bytes=32 time=446ms TTL=48
    Reply from 124.238.253.102: bytes=32 time=445ms TTL=48
    
    Ping statistics for 124.238.253.102:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 445ms, Maximum = 606ms, Average = 505ms

    If you are suffering packet loss or long delays then should investigate further.

    Another good test from the command prompt is either the tracert / traceroute command or pathping which will do a series of pings from your PC to the destination showing you the addresses of each router it has to pass through and any delay it suffers on the way.

    For example lets try a pathping to www.google.com.

    C:\Documents and Settings\me>pathping www.google.com
    
    Tracing route to www-tmmdi.l.google.com [216.239.59.99]
    over a maximum of 30 hops:
    0  strl03455wxp.domain.compname.co.uk [192.168.1.3]
    1  192.168.1.1
    2  10.129.132.1
    3  glfd-cam-1b-v111.network.virginmedia.net [80.4.30.233]
    4  glfd-core-1b-ge-115-0.network.virginmedia.net [195.182.181.237]
    5  gfd-bb-b-ge-220-0.network.virginmedia.net [213.105.175.89]
    6  man-bb-a-ae3-0.network.virginmedia.net [213.105.175.145]
    7  man-bb-b-ae0-0.network.virginmedia.net [62.253.187.178]
    8  tele-ic-3-ae0-0.network.virginmedia.net [212.43.163.70]
    9  158-14-250-212.static.virginmedia.com [212.250.14.158]
    10  209.85.255.175
    11  209.85.251.190
    12  66.249.95.169
    13  216.239.49.126
    14  gv-in-f99.1e100.net [216.239.59.99]
    
    Computing statistics for 350 seconds...
    Source to Here   This Node/Link
    Hop  RTT    Lost/Sent = Pct  Lost/Sent = Pct  Address
    0                                           strl03455wxp.domain.compname.co.uk
    [192.168.1.3]
                  0/ 100 =  0%   |
    1    0ms     1/ 100 =  1%     1/ 100 =  1%  192.168.1.1
                  0/ 100 =  0%   |
    2  ---     100/ 100 =100%   100/ 100 =100%  10.129.132.1
                  0/ 100 =  0%   |
    3   14ms     4/ 100 =  4%     4/ 100 =  4%  glfd-cam-1b-v111.network.virginmed
    ia.net [80.4.30.233]
                  0/ 100 =  0%   |
    4   16ms     2/ 100 =  2%     2/ 100 =  2%  glfd-core-1b-ge-115-0.network.virg
    inmedia.net [195.182.181.237]
                  0/ 100 =  0%   |
    5   14ms     2/ 100 =  2%     2/ 100 =  2%  gfd-bb-b-ge-220-0.network.virginme
    dia.net [213.105.175.89]
                  0/ 100 =  0%   |
    6   27ms     1/ 100 =  1%     1/ 100 =  1%  man-bb-a-ae3-0.network.virginmedia
    .net [213.105.175.145]
                  0/ 100 =  0%   |
    7   24ms     1/ 100 =  1%     1/ 100 =  1%  man-bb-b-ae0-0.network.virginmedia
    .net [62.253.187.178]
                  0/ 100 =  0%   |
    8   31ms     1/ 100 =  1%     1/ 100 =  1%  tele-ic-3-ae0-0.network.virginmedi
    a.net [212.43.163.70]
                  0/ 100 =  0%   |
    9   33ms     0/ 100 =  0%     0/ 100 =  0%  158-14-250-212.static.virginmedia.
    com [212.250.14.158]
                  0/ 100 =  0%   |
    10   25ms     1/ 100 =  1%     1/ 100 =  1%  209.85.255.175
                  0/ 100 =  0%   |
    11   37ms     1/ 100 =  1%     1/ 100 =  1%  209.85.251.190
                  0/ 100 =  0%   |
    12   39ms     1/ 100 =  1%     1/ 100 =  1%  66.249.95.169
                  0/ 100 =  0%   |
    13   41ms     0/ 100 =  0%     0/ 100 =  0%  216.239.49.126
                  0/ 100 =  0%   |
    14   35ms     0/ 100 =  0%     0/ 100 =  0%  gv-in-f99.1e100.net [216.239.59.99
    ]
    
    Trace complete.
    

    If you are suffering severe packet loss between routers then that could signify a problem or it may just be that the router is not set up to respond to pings and therefore any ping to that IP would report a time out.

    Another test is to compare whether the speeds promised by your broadband provider are actually being delivered to you. There are many speed test sites out there but I tend to use www.broadbandspeedchecker.co.uk OR www.speedtest.net which will measure your download and upload speeds.

    You should always do multiple tests and then take an average reading. When I was debugging the issue with my laptop and the wireless connection it had to my main PC and router I was alternating tests between both machines and recording the times to note any difference.

    Broadband providers never seem to deliver exactly what they promise but if you are currently getting anything over 2Mbps you shouldn't be getting video streaming issues unless its High Definition movies. Upload speeds will always be a lot less than download speeds so don't expect equality on those two measurments however if like me you were getting periods of the day where your download speed was measured less than 100Kbps then there is definitely something wrong somewhere.

    One thing you should remember when dealing with speeds on the net is that the measurements are different than those for disk space. 1Mb is one megabit and 1MB is one megabyte. You can always tell by the letter b as if its capitilised then its bytes and if its lower case its bits. Another thing to note is that a rate of one kilobyte per second (KBps) equals 1000 (not 1024) bytes per second.

    If your network problems are intermittent then you should download a tool like networx which allows you to monitor your bandwidth usage, show hourly, daily, monthly reports, set limits on usage and run diagnosis tools such as tracert and ping but in a visual manner.

    Run the bandwidth monitoring tool throughout the day and run hourly speed tests this should tell you whether your network problems happen at certain times of the day and provide you with evidence that you can then download as an XLS to provide to your ISP when you contact them to complain.

    Wireless Network Issues

    If like me you use a laptop that is connected to the main router by a wireless connection then you should rule out problems with the wireless set-up. Run some pings from your PC to the wireless router to check for any issues but ensure that your router is set-up to accept ping requests first.

    • Make sure you have the latest firmware, software and drivers in your router, modem and network adaptor. Communications and hardware companies are always updating the software inside their devices so you should make sure you have the most up to date drivers and other software for your equipment. You should be able to download this from the manufacturers website.
    • Tune your wireless access point. If you get substantially higher speeds when you connect directly to your broadband instead of using wireless networking, this can be due to interference from other Wi-Fi installations nearby, especially if you are in a city. Find out if there is a problem by plugging the network output from your broadband moden directly into the Ethernet port on your laptop or desktop and seeing if speeds improve. If so, try changing the channel of your wireless network: there'll be a setting in its configuration screen, which you can get to via your browser. Check your handbook for details of your router. You should also try moving your laptop around the house to see if you get a better or worse signal depending on where you are.
    • Make sure you are not getting electrical or radio interference from other devices in your house. Lots of gadgets including radios, media streamers, mobile phones and tools to send TV signals around the house use Wi-Fi and they're all sharing the same airwaves. Try turning off all electrical equipment to see if that improves the signal and then one by one turn them on again until you find the culprit. Even mains wiring that runs alongside telephone or network cables can cause a problem.
    • Whilst on the wireless network place your laptop right next to the main router and run some speed tests. If you are having issues with speed whilst directly next to the router then it maybe a problem with the wireless router itself or the wireless internet card your PC or laptop is using.
    TCP / IP Tuning

    Computers are shipped with default TCP / IP settings that are designed to work with all network speeds, dial ups, DSL and Cable. This means that you can tweak various settings so that they are optimal for your computer.

    There are various tools that can help you do this easily such as TuneUp Utilities or there are those such as DrTCP or TCP Optimizer that allow you to view and edit various settings such as your MTU Maximum Transmission Unit or maximum packet size and RWIN (TCP Recieve Window). Out of both these tools TCP Optimizer offers the more configuration options, a registry editor and some tests to calculate your MTU correctly.

    For those of you interested in what these values mean then the MTU is the maximum Ethernet packet size your PC will send. If a packet that is too large is sent then it will get split up into chunks (fragmented) and then re-assembled at the destination which obviously is not optimal. Therefore you want the MTU value to be the largest packet size that can be sent without becoming fragmented.

    Unless otherwise set, Windows defaults MTU to 1500, or a lower value of 576 for external networks. 1500 is OK unless you are running PPPoE, want to use IPSec (Secure VPNs) or both, then it's too big. 576 is not efficient for the broadband/Internet as it's too small. For Windows VISTA users it's recommended to leave this value alone as apparently it does a pretty good job of automatically calculating these settings anyway.

    You can calculate this yourself with the command prompt by doing the following tests.

    Windows 2000/XP users:

    ping -f -l 1472 www.google.com
    (That is a dash lower case "L," not a dash "1." Also note the spaces in between the sections.)

    Linux users:

    ping -s 1472 www.google.com

    OS X users:

    ping -D -s 1472 www.dslreports.com

    Linux and OS X commands are case sensitive.

    Press Enter. Then reduce 1472 by 10 until you no longer get the "packet needs to be fragmented" error message. Then increase by 1 until you are 1 less away from getting the "packet need to be fragmented" message again.

    Add 28 more to this (since you specified ping packet size, not including IP/ICMP header of 28 bytes), and this is your MaxMTU.

    If you can ping through with the number at 1472, you are done! Stop right there. Add 28 and your MaxMTU is 1500.

    For PPPoE, your MaxMTU should be no more than 1492 to allow space for the 8 byte PPPoE "wrapper," but again, experiment to find the optimal value. For PPPoE, the stakes are high as if you get your MTU wrong, you may not just be sub-optimal, things like uploading files or web pages may stall or not work at all.

    This example shows you how to do it by hand. If you you downloaded the TCP Optimizer tool go to the largest MTU tab and run the test. You will see that it does a similar test to the one below but obviously its automated to save you time.

    C:\Documents and Settings\me>ping -f -l 1472 www.google.com
    
    Pinging www-tmmdi.l.google.com [216.239.59.147] with 1472 bytes of data:
    
    Packet needs to be fragmented but DF set.
    Packet needs to be fragmented but DF set.
    Packet needs to be fragmented but DF set.
    Packet needs to be fragmented but DF set.
    
    Ping statistics for 216.239.59.147:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    
    C:\Documents and Settings\me>ping -f -l 1462 www.google.com
    
    Pinging www-tmmdi.l.google.com [216.239.59.147] with 1462 bytes of data:
    
    Reply from 216.239.59.147: bytes=64 (sent 1462) time=33ms TTL=52
    Reply from 216.239.59.147: bytes=64 (sent 1462) time=31ms TTL=52
    Reply from 216.239.59.147: bytes=64 (sent 1462) time=33ms TTL=52
    Reply from 216.239.59.147: bytes=64 (sent 1462) time=42ms TTL=52
    
    Ping statistics for 216.239.59.147:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 31ms, Maximum = 42ms, Average = 34ms
    
    C:\Documents and Settings\me>ping -f -l 1463 www.google.com
    
    Pinging www-tmmdi.l.google.com [216.239.59.147] with 1463 bytes of data:
    
    Reply from 216.239.59.147: bytes=64 (sent 1463) time=32ms TTL=52
    Reply from 216.239.59.147: bytes=64 (sent 1463) time=29ms TTL=52
    Reply from 216.239.59.147: bytes=64 (sent 1463) time=30ms TTL=52
    Reply from 216.239.59.147: bytes=64 (sent 1463) time=32ms TTL=52
    
    Ping statistics for 216.239.59.147:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
    Minimum = 29ms, Maximum = 32ms, Average = 30ms
    
    C:\Documents and Settings\me>ping -f -l 1465 www.google.com
    
    Pinging www-tmmdi.l.google.com [216.239.59.147] with 1465 bytes of data:
    
    Packet needs to be fragmented but DF set.
    Packet needs to be fragmented but DF set.
    Packet needs to be fragmented but DF set.
    Packet needs to be fragmented but DF set.
    
    Ping statistics for 216.239.59.147:
    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

    There you go the MTU is 1464 + 28 = 1492

    The other settings available in the TCP Optimizer tool are:

    Tcp1323Opts
    This parameter controls the use of RFC 1323 Timestamp and Window Scale TCP options. Explicit settings for timestamps and window scaling are manipulated with flag bits. Bit 0 controls window scaling, and bit 1 controls timestamps.

    GlobalMaxTcpWindowSize
    Description: The TcpWindowSize parameter can be used to set the receive window on a per-interface basis. This parameter can be used to set a global limit for the TCP window size on a system-wide basis.

    TCP Window size
    This parameter determines the maximum TCP receive window size offered. The receive window specifies the number of bytes that a sender can transmit without receiving an acknowledgment. In general, larger receive windows improve performance over high-delay, high-bandwidth networks. For greatest efficiency, the receive window should be an even multiple of the TCP Maximum Segment Size (MSS). This parameter is both a per-interface parameter and a global parameter, depending upon where the registry key is located. If there is a value for a specific interface, that value overrides the system-wide value. See also GobalMaxTcpWindowSize.

    Contact your ISP

    If you have cleaned and tuned your computer and browser and optimised all your settings to rule everything else out and you're still having problems related to network speed then contact your ISP. Provide them with as much information that you have gathered as possible to show that the problem is not related to your computer set-up. If you have intermittent speed issues show them the charts from networx that you can print out (by hour, by day) to show the problem. Do not give your ISP a chance to blame the issue on your own PC or setup a with most companies they will try and get out of paying for something if they possibly can. You never know they may offer you a new modem and raise you from 2Mbps to 20Mbps like they did to me. Funnily enough as soon as the new modem was plugged in all my network issues were solved instantly!

    Hopefully this article has been a good guide to performance tweaks and remember if you want to do it the easy way purchase TuneUp Utilities as it could save your a lot of time, effort and heartache. I don't often recommend software to buy but for only £29.99 you cannot really go wrong when compared with the amount of time you will save.



    TuneUp Utilities 2010