Windows Server 2008 NTP

I was having issues with my 2008 servers clocks: they were running fast. After 30 days they were 2 minutes fast. 90 days they were 6 minutes. You can guess how fast they were after 120 days. Yay math!

In XP and 2000 one could simply open up the date and time control panel (or double click on the clock) and, through some tabbed Internet Time, select a predetermined NTP server. Maybe I’m just blind, but I couldn’t find the option in 2008 or vista. It could be one of my GPO’s blocking said option. In any case, my clients were all receiving this “fast” time. Not good.

To fix:
Open up an administrative command window (windows key + r works wonders for me)
Set the NTP server to time-nw.nist.gov
net time /setsntp:time-nw.nist.gov
Make sure that the NTP server has been saved
net time /querysntp
See where you’re grabbing your NTP information from (usually a domain controller)
net time
Actually corrects the time to your NTP server
w32tm /resync

RDP Connection Limit Windows Server 2003

One of the good things about Windows Server versus XP is the number of connections that you can have. XP is limited to 10 connections, Server is not limited. XP is limited to a single console connection and no RDP, Server is limited to a single console connection and two other RDP connections (total of 3).

One of the bad things is that in order to get your server to allow more than 3 simultaneous connections you need to install, and license, terminal server. Then you need to convert the server to run in Application Mode. Lots o’ fun. Our company made the mistake of installing a proof-of-concept of terminal server on a non-domain controller and non-production server. The server then died. And in order to retrieve the licenses, we’d have to contact the fine folk over at Microshaft and explain the situation, then get the new license keys, and then create the new server, and then configure the other servers to run in application mode. And hope it all works.

So I did it the easy way – hack the termsrv.dll file.

FYI hacking Microsoft files is a breach of the terms of service agreement and license agreements with Microsoft. Do so at your own risk.

First I will post how I went about “hacking” said file and how to implement in your own environment.
Unfortunately I can’t post the hacked file due to legal issues. So there is no “hey, here’s the file if you’re lazy”.

Now I’ve only tested this on Windows Server 2003 standard and enterprise, R2 and regular. ALL 32bit. I’m sure it’ll work on 64bit, but we have no needs to allow more than even the single console session on our 64bit servers.

Download the following files:
http://it.thelibrarie.com/utilities/vpatch32.exe
http://it.thelibrarie.com/utilities/2003tspatch.zip

Install the vpatch32 program (works on XP and Vista32/64)
Unzip the 2003tspatch.zip to find a PatchData.pat file
Copy the termsrv.dll file from your server’s WINDOWS\system32 folder to your desktop (easier to find, and you can’t patch an ‘in-use’ file)

Open vpatchprompt.exe located in %programfiles%\VPatch\
This will prompt you to find the PatchData.pat file you unzipped
Then it will prompt you to find the file you want to patch, in our case it’s the termsrv.dll residing on your desktop
Then choose a file name and the program will save the patched dll as this new name. I chose termsrvNEW.dll to keep it easy to locate.

Now the tricky part – because Windows has built-in protection for system files, we have to go about this in a trick-defeating manner.

On your server, locate the file in WINDOWS\system32\dllcache\termsrv.dll
Rename this file termsrvOLD.dll
Now locate the termsrv.dll file in WINDOWS\system32\
Rename this file termsrvOLD.dll as well
Copy the termsrvNEW.dll to WINDOWS\system32\
Rename this file to termsrv.dll

Windows will generally complain that a file has changed. Let the OS know who’s boss and that you want to keep the file. Now, reboot.

Test – if anything breaks you can always undo the files by using your old one again. If it all goes as planned, you can now have unlimited RDP connections to your server.

Yay!

***EDIT***
If you change the files and Windows changes them back, that’s the built-in security DEP of Windows. You may have to start in Safe-Mode (F8 before the black Windows Screen but after the BIOS) in order to edit these files.

***EDIT PT 2***
Before I could respond to a comment left by an anonymous internet troll, I did some extra research into the matter.
http://www.remkoweijnen.nl/blog/2008/12/09/windows-2003-x64-terminal-server-patch/ <--- apparently that will work on 64bit SP2 or R2 of Win2k3. I haven't tested it, so I won't comment further unless I need to apply this patch as well.

Backing Up A Linux Box

I finally came across a need to backup a linux box. Usually, in the past anyway, the linux box was such a strong contender that rarely if ever crashed that it seemed almost foolish to install AV and Backup software. Not that they crash more than they used to, but we rely on the systems so much more that we need viable backup solutions.

ClamAV, by the way, is a decent enough free solution to AntiVirus on a linux box.

Mondo is a great backup solution for a linux box.

I basically went to ftp://ftp.mondorescue.org/ and grabbed the three files I needed to get this running on a Debian 5.0 box.
(wget ftp://site/nameoffile)
File 1: mindi-busybox_1.7.3-1_i386.deb
File 2: mindi_2.0.6_i386.deb
File 3: mondo_2.2.8_i386.deb

Busybox is needed to install mindi, and mindi is needed to install mondo.

Install the applications:
Apt-get update
Apt-get upgrade
dpkg -i mindi-busybox_1.7.3-1_i386.deb
dpkg -i mindi_2.0.6_i386.deb
dpkg -i mondo_2.2.8_i386.deb

Create your bootable ISO rescue disk:
mindi
Select Yes for using your kernel for booting, and also Yes for creating an ISO of the CD.

Run your backup job:
mondoarchive

This will open up a window prompt wizard that allows you to choose where to backup your files.
Follow along with the wizard to finish your backup job.

Printer Showing As Offline

I had an issue of a printer showing up as offline even though it was most certainly online. I could ping it from the print server, and I could view the html pages for the configuration of said printer, but the print server was still listing it as offline. WTF, eh?

Then I came across a hotfix from Microsoft that says if the printer uses SNMP for certain communication that if it goes offline at any time there is a possibility that the printer will show offline even if all other communication works. The fix is as follows:

ON THE PRINT SERVER/HOST:
Open Regedit
start > run > regedit
Locate the Print key container
HKLM\SYSTEM\CurrentControlSet\Control\Print
Add a DWORD value to the print key container
Right-click and add DWORD Value
Give the DWORD key the name of SNMPLegacy
Set the SNMPLegacy key to 1
Close out of the registry editor

Now reset the print spooler service:
Start > run > services.msc
Find print spooler, right click, restart service
Test

Logging What Users Do In BASH

I like the BASH Shell – it’s fun and the default shell, so pretty much everyone can use it. And since I like the Ubuntu/Debian, the following steps apply to these systems – and you can probably figure out how to get them to work with BSD or another *nix flavor.

Finding out what people do with their access, on the other hand, is a little more difficult.

Sure, you can lookup their bash_history file, but that only goes back 15 to 25 commands (unless setup to a non-standard logging).
nano /home/username/.bash_history

Then I was turned onto Accounting Management:
apt-get install acct

That’s it! Easy, right?
Well, to see the information you have to know which commands to type.

LastComm shows the last command by a certain user, or when the command last matches your variable:
lastcomm username
lastcomm PID/Process

AC
ac
ac -d
ac -p

PSExec

In case you haven’t noticed, I like to use free tools that allow me to manage systems remotely. I also ran an internal forum board with this exact information. But due to potential problems, I am disbanding the internal and only relying on this site.

MMC is built into Windows
SSH is mostly built into Linux
SSH is mostly built into Macintosh

PSTools Suite is probably the best I’ve come across – free and is now updated by Microsoft.

Pslist and Pskill are both very useful, but Psexec takes the cake. Pslist shows all running programs on a system:
pslist \\computername
Pskill will kill remote programs (or PIDs) on any system assuming the system isn’t locked up beyond the system services functionality.
pskill \\computername PID_or_Processname

Here are some simple commands I use every day:
Analyze remote system’s HD to see if it needs to be defragged
psexec \\somemachine -s -d defrag.exe c: -a
Force remote system’s HD to defrag
psexec \\somemachine -s -d defrag.exe c: -f
Run Internet Explorer and open it.thelibrarie.com website
psexec \\somemachine -i -d "C:\program files\internet explorer\iexplore.exe" http://it.thelibrarie.com
Install an MSI program
psexec -s -i \\somemachine msiexec -i c:\locationofmsi.msi
Open the Add/Remove Programs Applet
psexec -i -s \\somemachine control.exe appwiz.cpl

***EDIT***
Looks like this really doesn’t work much on Windows 7 due to security restrictions. I end up using pslist \\computername to list the running processes, and then taskkill /S computername /PID processID /F to actually kill the running process.