LogonUserViaSSPI

Security Briefs

Syndication

In my latest book, I had a code snippet that wasn't working properly with the RTM bits. I've fixed it in the online version, in case any of you were trying to use it. It was the code that used NegotiateStream to establish a logon for a user given her user name and password. You basically act out both sides of the negotiation, but in order to do this, you need to use a full duplex stream (my original code was using a MemoryStream, which isn't duplex). You also need asynchrony. Simply calling AuthenticateAsClient followed by AuthenticateAsServer won't work, because it's assumed these bits of code are running on different threads (usually in different processes on different machines, even!) To solve this, I use async sockets with TcpListener on the loopback address.

Hope this helps!


Posted Jan 13 2006, 06:36 AM by keith-brown
Filed under: ,

Comments

Prasanna Padmanabhan wrote re: LogonUserViaSSPI
on 01-13-2006 12:31 PM
I have a question regarding SSPI in general. Can SSPI be used to verify the client machine's identity? (not the user on the client machine, but the client machine itself).

Thanks,
Prasanna
Keith Brown wrote re: LogonUserViaSSPI
on 01-13-2006 1:08 PM
Prasanna,

Not at the same time as you're identifying the user. You see, SSPI will validate the origin of the request. If it originated from a program running under the user's credentials, you're authenticating the user. You might know the machine's IP address, but there's no proof she's really coming from that machine unless you're using IPSEC under the covers or some other VPN technique.

On the other hand, if the request originates from a program running as SYSTEM or Network Service on the client's machine (and only if you're running in a domain), then it's actually running using the machine's domain credentials, not the user's credentials. When you use SSPI to validate the caller's creds at this point, you'll see the user's machine account.
Prasanna Padmanabhan wrote re: LogonUserViaSSPI
on 01-13-2006 3:11 PM
Keith,

Thanks for the reply. So you are saying that having a process running as NETWORK SERVICE or SYSTEM on a machine (that is member of an AD Domain) be an SSPI client, is the indirect way of verifying the client machine identity. It makes sense to me thiking about it, because I suppose that how Windows (server) machines can get things such as Group Policy information from AD without a user ever logging on the machine.

Prasanna
Keith Brown wrote re: LogonUserViaSSPI
on 01-13-2006 4:45 PM
That's correct.
Christopher Steen wrote Link Listing - January 15, 2006
on 01-15-2006 8:22 PM
ASP.NET 2.0 and Web Standards - SiteMap Security
Trimming [Via: jlynch ]
BizTalk Web Resources ...
Matthew Reynolds wrote re: LogonUserViaSSPI
on 12-15-2008 5:19 PM

I am trying to do some testing around detecting the usage of LM and NTLMv1 auth on a network. The idea is to see what is relying on these before attempting to disable the same.

In order to validate my setup, It would be really nice to be able to generate arbitrary auth traffic using LM, NTLMv1 and NTLMv2. Does SSPI Workbench do this? If so how can a person obtain a copy?

Alternateively, do you know of any classes in .Net that would allow the same? If so I could try to put something together using powershell.

Thanks.

keith-brown wrote re: LogonUserViaSSPI
on 12-16-2008 8:00 AM

Matthew: I've not personally attempted to generate traffic for particular versions of NTLM or LM by itself, but if you send me email via my contact page (there's a link on the top of the nav bar on the right) I'd be happy to send you the workbench.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?