Archive for the 'Inner Geek' Category

Windows XP explorer.exe missing or corrupt

So here’s a new one, recently at work we have had a number of XP Pro machines login but failed to load up explorer. The first thing you would attempt would be to start task manager (Ctrl+Alt+Delete), start a new task and start explorer. Now when we did that we were getting an error saying that explorer was missing or corrupt. So we opened up CMD to browse the Windows directory only to find explorer was there and seemed fine…

We came across a fix to rename explorer to explorer2.exe and update the registry with regedit to point to the new explorer2.exe. This worked and proved there was nothing corrupt or missing but it wasn’t an ideal solution as it was quite long winded.

The problem started to appear with more and more PC’s on our network, this is no longer a coincidence. The problem is happening on different service packs of SP so we know its not an SP related issue. After doing a bit of searching around I found something called FixO. After running this and rebooting the PC explorer was now working great and it kept explorer as same name etc. You can get it here: FixO - Repair explorer.exe

Still this was a long way around script but at least it can be scripted into the login script. Anyway one of my work colleges found another solution, which seems to cure the problem but no idea why. It’s a simple one-line registry edit.

Open notepad and put the following in:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\explorer.exe]
"Debugger"=-

Save the file as a reg file. Then run this file in regedit, this simply removes the offending registry key that is causing problems. If you want you can just get the file here: Reg Fix - Fix No Desktop

So we still don’t know what’s causing this but we do have a temporary solution.

Javascript Same Height Div’s Update

A while back I posted my way of making same height div’s but came across and issue when padding was involved. Well I’ve modified my code to take into account padding. Now the obvious thing to do would be to be to check padding on a div and subtract it from the height, but it’s not that easy. You would have to check three things: padding, paddingTop and paddingBottom. For some reason when I was checking padding I couldn’t get a value from JavaScript, this had me really stumped but after a nights sleep I came up with a better and more simpler way of sorting the padding issue. This is to let the code run and let it re-height the div’s and let the padding mess things up then run the same thing again and check for height differences from last time we checked. Oooohhh look the height has gone up 10px from last time thanks to a padding of 5px on the div. Now we know there is 10px of padding lets remove it. Sorted!

JavaScript Code:

function sameHeight(divs) // Bring in an array of your divs
{
  var highest = 0;
  var heighttu = 0;
  for(i = 0; i < divs.length; i++) // Loop through the divs
  {
    // Check to see if this div is the highest?
    if(document.getElementById(divs[i]).offsetHeight > highest)
    {
      // Yes its the highest so set the highest value to this div's height
      highest = document.getElementById(divs[i]).offsetHeight;
    }
  }
  // Loop through divs and set their hieght all the same
  for(i = 0; i < divs.length; i++)
  {
    document.getElementById(divs[i]).style.height = highest+"px";
  }
  // now get offset hieght again and we may found we have gone higher this is because of padding
  if(document.getElementById(divs[0]).offsetHeight > highest)
  {
    // correct the height
    highest = highest - (document.getElementById(divs[0]).offsetHeight - highest);
    // Correct divs
    for(i = 0; i < divs.length; i++)
    {
      document.getElementById(divs[i]).style.height = highest+"px";
    }
  }
}

How Epcot foresees our future

So the first ride Dan and I went on when we entered Disney World Epcot was the ride in that big dome thing. So when we got on the ride as soon as you take off a camera takes a picture of you. At first we were like why take a picture as you are settings off. Well that became apparent towards the end of the ride. At the end of the ride there is a TV in front of you and you are asked a number of question which you are to answer. So we answered the questions and guess what we got?

We got this: Epcot - Our Future LOL.

Javascript Same Height Div’s

Recently I had to make some divs the same height. Usually I would just pad the bottom of a div with page breaks but I couldn’t do that this time round as the page content is dynamic and the height of the divs could change.

First thing I did was look online for answers and sure enough there were solutions but looking at them they seemed over complicated so I decided to write my own solution.

Javascript Code:

function sameHeight(divs) // Bring in an array of your divs
{
var highest = 0;
for(i = 0; i < divs.length; i++) // Loop through the divs
{
document.getElementById(divs[i]).style.height = "auto";
// Check to see if this div is the highest?
if(document.getElementById(divs[i]).offsetHeight > highest)
{
// Yes its the highest so set the highest value to this div's height
highest = document.getElementById(divs[i]).offsetHeight;
}
}
// Loop through all divs again
for(i = 0; i < divs.length; i++)
{
// Set all divs height to the highest value
document.getElementById(divs[i]).style.height = highest+"px";
}
}

Then to run this code:

window.onload=function()
{
	sameHeight(new Array('block_01','block_02','block_03'));
}

Simply pass an array of your divs to the function. Easy peasy….

Just an extra word of warning… Be aware of using padding on the blocks you pass to this function. If the paddings are different in each block then they may not end up being the same height. Although you could modify the function to check for the use of padding and alter the heights accordingly.

Getting Windows HDD usage with PHP and SNMP

At work a couple of months back I was faced with a problem that many of our servers would run out of hard drive space without us knowing and that would cause the server to hang and/or stop responding. So I did a bit of research and came across. This little utilility would run on the server in command line and tell you what drives were available and some info of the drives like space used and available. Well with this I would echo out the data to a text file and send that across to a common holding ground. Then from there get my web server to constantly scan this folder for new logs. This method worked but it had its issues.

Well yesterday at work I was playing around with SNMP and after finding a site with W2K MIBS I found lots of info you can pull from the server. Now I was already familiar with SNMP in PHP thanks to their documentation on their site. So using their snmpwalk function I was able to pull the relevant data to get HDD usage info.

$names = snmpwalk($row['ip'], "public", '.1.3.6.1.2.1.25.2.3.1.3');
$used = snmpwalk($row['ip'], "public", '.1.3.6.1.2.1.25.2.3.1.6');
$total = snmpwalk($row['ip'], "public", '.1.3.6.1.2.1.25.2.3.1.5');
$alloc = snmpwalk($row['ip'], "public", '.1.3.6.1.2.1.25.2.3.1.4');

Now that would give me an array of drive names, space used on those drives, total space available on those drives and the allocation units. Now the allocation units I didn’t realize I needed as I thought the numbers given in used and total were just measured in bytes but they aren’t. The numbers in used and total are how many blocks of allocation size (if that makes sense). So to get the true byte value from used and total you need to multiply them by the allocation size number.

25599569 * 4096 = 104855834624B = 97.65GB

So there you have it. Now you know how to get HDD usage from your server using PHP and SNMP.

Ain’t English Fun

Brady - singed minge fringe binge says:
yes it dont lie if u believe that rubish
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
doesnt*
Brady - singed minge fringe binge says:
dont*
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
doesn’t*
Brady - singed minge fringe binge says:
don’t
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
rubbish*
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
DOESN’T !
Brady - singed minge fringe binge says:
dont
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
doesnt
Brady - singed minge fringe binge says:
dont its a word
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
yes
Brady - singed minge fringe binge says:
go look it up
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
and supercalifragilisticoespialidoso
Brady - singed minge fringe binge says:
…… but ur wrong and im right
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
let me look it up
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
coz u are getting us mad
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
silly!
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
dont DOESN’T exist
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:

Brady - singed minge fringe binge says:
yes it does
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
dont tease us
Brady - singed minge fringe binge says:
doesnt tease us
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:

Brady - singed minge fringe binge says:
you just answered ur own question
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
we hate u
Jani - ***Nunca prometas nada que no vayas a cumplir*** says:
laura hates u
Brady - singed minge fringe binge says:
hahahaha Scott 1 Jani and Friend 0

PHP File Upload Progress Bar Part 2

After further investigation PHP 5.2.0 now allows you to use the APC (Alternative PHP Cache) addition with the ability to track the progress of uploads. Within windows it is as simply adding the dll extension to your php.ini and putting some configs there to. With Linux I’m not too sure how you add this extension as I don’t know Linux well. But anyway below is some nice and easy documentation on this.

PHP File Upload Progress Bar

PHP File Upload Progress Bar

As you may be aware in php it doesn’t have the functionality to report back the status of file uploads. For example upload percent complete, speed of upload and estimated time of completion. To be able to provide a progress bar the easiest way would be to use a perl script to do the uploading for you as perl has this functionality. Now I build a file uploader for the public and I looked at providing a perl uploader but because I know very little about the language of perl I couldn’t get any examples to work for me, but the ones that did work needed some server side changes. These server side changes would be no good for most of my downloader’s as many of them don’t have root access to their server.

There is another solution out there but once again it involves making server side changes which hacks php and adds the additional functions to track the upload progress of a file.

The above hack for PHP can be found at http://pecl.php.net/package/uploadprogress. There isn’t much documentation out there for it but if you do a Google search you will find one or two examples.

The above hack I’m thinking about putting it in my module so that those that have the modified php will be able to run my uploader with the progress bar but those without would not get the upload progress bar. The thing in to build my module to use this hack I need a server that is running the hacked version of php. Thing is I’m stuck with a shared hosting account and I don’t have access to modify php. So if there is anyone out there that can lend me some space for a short time and is running the above hack please contact me so I can’t continue building my file uploader script

Lets deface a website

The other day a guy I’ve known for a long time came to me and said I need help taking down a site. You know a website he wanted me to help hack it etc. Well as I know how etc and with him being a mate I helped in out. So anyway how do you go about finding a way into a website? I find it easy if the website has server side languages. Eg PHP ASP etc. If it doesn’t have those you are not going to get in. Secondly find on the site if it’s running any public CMS or module or script of some sort. At first glance the site was purely html but after closer look there was a chat script installed called Flash Chat.

Next job is to search for known exploits. Sure enough there was a known remote file include vulnerability on the version he was running. That’s it we know we are in :)

So what’s next what do you do?? Well with this vulnerability you have a way to run php code or another language on the victim’s website remotely. Firstly you need to create the script that you want to use on his site and upload it to your web server as a txt file. Then run the vulnerability including the file you have made and hey presto you have a script of your choice on the victims website. With the exploit I uploaded a custom made script to the person’s website so the file was local and gave the url to my friend. Was like; there you go knock yourself out. This script is called a shell. These shells are very powerful scripts that let you do a whole variety of things on some ones website. I’ll let you look them up for more details: P

I’d just like to say that I ain’t a leet hacker. I use methods that have been found by other people etc. The only thing I used of mine was my custom php script to upload the shell for my friend.

Head down and get on

Ok we have today of at university but I’ve decided to still go in. I will use this time to do some more work to get ahead and get everything out of the way.

When finishing college at York I said to myself that If I go to University I wouldn’t let it be like at college. At college I got into the habit of leaving everything to last minute and any spare time was wasted on doing nothing. I think everyone on the college course were the same? Put it this way there was 12 of us at the beginning of the course and only 2 of us got a grade at the end of it. Even my friend Dan didn’t make the grade. But not to worry, while I took the year out he went back to college to get his grade and now he is at Sheffield University

So anyway where am I with assignments?? Well the C programming assignment that is 22 questions I have already completed that. Now that was very easy but the rest that haven’t done any programming before are finding it hard. We have an advanced computer applications lesson which I’m doing well in that too. We have the first assignment that is worth 25% and already got half way through that. Next we have maths and we have 5 assignments to complete by Christmas. Well I have completed 2 of them so far and well into my 3rd. Felling quite proud of myself.

Next Page »