Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[VB.NET]Check Windows Password

originally posted on dotnet-snippets.com

Description:

This function checks a windows user password whether it is valid and matching to the given username.
Code
Private Declare Auto Function LogonUser Lib "advapi32.dll" ( _
    ByVal lpszUsername As String, _
    ByVal lpszDomain As String, _
    ByVal lpszPassword As String, _
    ByVal dwLogonType As LogonType, _
    ByVal dwLogonProvider As Integer, _
    ByRef phToken As IntPtr) _
As Integer

Private Declare Auto Function CloseHandle Lib "kernel32.dll" ( _
    ByVal hObject As IntPtr) _
As Boolean

Public Enum LogonType As Integer
    LOGON32_LOGON_INTERACTIVE = 2
    LOGON32_LOGON_NETWORK = 3
    LOGON32_LOGON_BATCH = 4
    LOGON32_LOGON_SERVICE = 5
    LOGON32_LOGON_UNLOCK = 7
    LOGON32_LOGON_NETWORK_CLEARTEXT = 8
    LOGON32_LOGON_NEW_CREDENTIALS = 9
End Enum

Public Function IsNTPasswordValid(ByVal Username As String, ByVal Password As String, Optional ByVal Domain As String = "") As Boolean
    Dim Token As New IntPtr
    LogonUser(Username, Domain, Password, LogonType.LOGON32_LOGON_INTERACTIVE, 0, Token)
    CloseHandle(Token)
    If Token.ToInt32 <> 0 Then Return True
End Function


If You Like this tutorial, please check out my other tutorials by clicking ==> H3R3
PHP & .NET Contributor.
But how do you get the info? I mean like saying it in a textbox?
Always PM me for business inquiries.

(May 2, 2010 06:48 AM).Nielz Wrote:  But how do you get the info? I mean like saying it in a textbox?
Up.

It interests me.
This could be useful for a fake logon. Say running an exe which requests login info. Useful for harvesting user/pass.
(May 6, 2010 11:49 AM)DeadCode Wrote:  This could be useful for a fake logon. Say running an exe which requests login info. Useful for harvesting user/pass.

well if you know what you are doomg... ot can be rewritten and uses in many different ways.
PHP & .NET Contributor.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Emre_Jan 12, 2021 11:16 PM 0 141 Jan 12, 2021 11:16 PM
Last Post: Emre_
[.NET] by pr0t0typ3Aug 29, 2010 02:24 PM 1 129 Aug 29, 2010 02:24 PM
Last Post: Zer0Fact0r
[.NET] by KingLilGSep 7, 2009 07:20 AM 22 218 Sep 7, 2009 07:20 AM
Last Post: MAD-DOG