Showing posts with label IT. Show all posts
Showing posts with label IT. Show all posts

What to do when CryptAcquireContext() fails

I’m using CryptoAPI to do encryption and encountering an error on Win2008 Terminal Server which enforces Mandatory Profiles. CryptAcquireContext() fails with a message of either “keyset not found” or “The profile for the user is a temporary profile”.

I’ve tried the same test on WinXP using a guest account and got the same thing.

So, what gives?

Well, this blog post (RSACryptoServiceProvider fails when used with mandatory profiles) way back in 2007 by @alejacma explains:

CryptAcquireContext will fail with NTE_TEMPORARY_PROFILE error when called from a mandatory profile.

Mandatory profiles are read-only user profiles. Since changes to the mandatory profile cannot be saved, PKI design doesn't allow this operation, and CryptAcquireContext prevents this scenario by failing.

The moral of this story is: RSA sucks, and I am now Rijndael’s new biggest fan.

By the way, troubleshooting this problem had given me the chance to learn a few more WinDbg commands:

.sympath srv*http://msdl.microsoft.com/downloads/symbols
.sympath+ c:\localsymbols
.reload –f
bm /a advapi32!CryptAcquireContext*

Vundo disabled Norton 360

I had a full day of battle with Vundo.H Trojan last Sunday trying to get my dad’s infected computer cleaned up.  The parasite was occasionally popping this message:

“Your system is infected with dangerous virus! Note: Strongly recommend to install antispyware program to clean your system and avoid total crash of your computer!”system-error

As well, it’s the root cause of a subsequent DoS (more later).

One of the registry keys that was infected was the  AppInit_DLLs key, which Raymond Chen once wrote about in a blog entry aptly entitled  AppInit_DLLs should be renamed Deadlock_Or_Crash_Randomly_DLLs.

Anyway,  kudos to Malwarebytes' Anti-Malware for being a very useful tool.  But for a while there, as I sat and watched explorer.exe puts back this registry value no sooner than I deleted it, I felt like I was in the late 80s, early 90s, where viruses freely infected MS-DOS in similar manners.  I finally woke up and demoted my dad to non-administrative user level, which brings me to the next point about  antivirus.

In addition to the annoying popup, Vundo also messed up the antivirus software.  My dad had Norton 360 installed on his system, with at least 30 days remaining in his update subscription.  Yet, Vundo managed to sneak through, and somehow confused it enough to DoS my attempt to access the Internet—not only port 80, but all ports were being blocked.  One note of interest: for a while there it was refusing Firefox but lets IE through, but after a while, even IE was returning the  “Web page cannot be found” message.  Anyway,  I uninstalled Norton after cleaning Vundo and was then able to surf the web again.

 

There seems to be some controversy about using antivirus software over running Windows under a  non-admin account.  Apparently, over 92% of Windows security vulnerabilities reported last year could have been prevented if users were not using admin accounts.

I know that for me, running as a non-admin user will probably never fly in a software development environment where running a build requires elevated privilege in order to do COM registrations. As for my dad, non-admin account might suffice for now, but I wonder if it will prevent him from inadvertently falling victim to  phishing scams, which some antivirus software is able to prevent.

spamc.exe hangs

For the past several weeks, our ESA Sink has been clogging up once in a while. This is because spamc.exe, the SpamAssassin client program spawned by ESA, simply hung (probably due to a particularly large email).

I was thinking of rewriting spamc using Uwe Keim's ZetaSpamAssassin Wrapper, but that's probably a weekend type of project that I might entertain in the future. In the mean time, I wrote this simple little Windows service that occasionally checks and reaps stale spamc.exe processes, allowing the filter to continue. Source code (C#) and binary are available here.

svn over putty over http (over proxy)

A while ago, someone asked me about accessing their svn server from inside a customer network, which blocks everything except port 80. I didn't have an answer at the time. Then, I was at a customer site last week and ran into a similar problem. This is how I overcame it:

  1. Set up your HTTP server to proxy SSH. See here.

  2. Tunnel the svn port through PuTTY. See here.

  3. Add an entry to your %windir%\system32\drivers\etc\hosts file:

    # SVN Server
    127.0.0.1 svnhost.mycompany.com

    This is done so that you don't have to change your current SVN client settings.

  4. If the customer network happens to use a web proxy, enter the proxy settings in the PuTTY's Connection\Proxy panel.

Ctrl-Alt-Del via Remote Desktop Connection

Ever wonder how you could issue a Ctrl-Alt-Delete command to your remote desktop connection? Try Ctrl-Alt-End.

SSH proxying via Apache

Been working out of a customer site in the past few weeks and their firewall is a bit finicky. One day it would let me ssh into my office fine and the next day it would just kick me out right after the initial handshake. It doesn't actually refuse the connection at the onset. It would connect and then immediately drop the connection. Their IT guys tried to tell me it's my server, not their firewall that was the culprit. Hey, I'm an IT guy too, buddy! (amongst other things). If I can connect fine from my home network and two other guys can also connect from their home, I'm no Sherlock but something tells me it ain't my server. As improbable as it may be, because I know you think your firewall is perfect and that you haven't made any change to it that might cause this. My friend, I'd hate to tell you this but, it's your firewall! ;-)

Right. Next time, you try telling your customer's IT guy that his network firewall is faulty. See if that will get you anywhere.

Oh well. At least this gave me the chance to look into enabling our web server to allow SSH proxying. Found a useful article here: Tunneling SSH over HTTP(S).

This is essentially what you need to add to your httpd.conf on the Appache server:


# HTTP Proxy for SSH
AllowCONNECT 22
ProxyVia On
<ProxyMatch (192.168.1.1)> # Internal IP of your SSH server
Order deny,allow
Deny from all
### External (customer) sites allowed to connect
Allow from 199.243.1.61
Allow from 74.100.102.21
</ProxyMatch>


Then, to connect from the remote site, configure your PuTTY Connection host name to 192.168.1.1 (the internal IP address of your SSH server), set Connection>>Proxy setting to use HTTP proxy, enter in the public hostname and port of your Apache server.
That's it. Painless.

A slight diversion from real work, but this will come in handy the next time I'm at a customer site that blocks out all ports except port 80. I need my network to follow me everywhere I go. I'm effectively crippled without it.

Unless...I wonder, what would happen if the customer's network itself uses a proxy server to get out to the Internet...
Oh well. Not my problem to worry about right now. Will deal with it when I run into it.