Jump to content
Sign in to follow this  
Champak

Website Password Access

Recommended Posts

Champak

I know there are a couple of things like this, but I just didn't see anything that suited my needs.

1/ "Securely" encrypt passwords in the registry...i just don't like inis. One button press and access website. If the particular website requires the user and password on two separate pages it will be one button press and then press ctrl on keyboard.

2/ Password required to access app

3/ The only problem is this enters the info by ways of Send() function...wish I could do it with a controlsend or something.

4/ Use with Firefox or IE.

5/ Import/Export passwords, to do so you need the password used to access the app in the first place

How to use (simple):

Save Title user and password. Check the pause checkbox if user and password are entered on two separate pages.

Select the type of browser that you want to use from the menu. (which ever you use, you can only have one instance active)

When you want to enter the password on a site, select the title from the dropdown, put the cursor in the user input and hit enter on the app.

The only thing I see that I could have done that I didn't bother is to navigate to the page from the app.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=WebPass.exe
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <Array.au3>
#Include <File.au3>
#Include <Misc.au3>

Opt("WinTitleMatchMode", 2)
Opt("GUIOnEventMode", 1)

Global $REGLOCATION1 = "HKEY_CURRENT_USER\SOFTWARE\WebPass"
Global $REGLOCATION2 = "HKEY_CURRENT_USER\SOFTWARE\WebPass\Pass"
Global $sIni = @DesktopDir & "\WebPasswords.ini"
Global $Skip, $ComboArray, $CurrentBrowser
Global $Procede = 0

;#cs
If RegRead($REGLOCATION1, "_BrowserSelection") = "" Then
    $PassSet = InputBox("Access Password","Set password to access web passwords.", "", "", 250, 120)
    If @error = 1 Then Exit
    RegWrite($REGLOCATION1, "_Access", "REG_SZ", _RC4($PassSet, "The Key"))
    RegWrite($REGLOCATION1, "_BrowserSelection", "REG_SZ", "IE")
Else
    $Password = RegRead($REGLOCATION1, "_Access")
    $PassRead = _RC4(InputBox("Access Password","Enter password to retrieve web passwords.", "", "", 250, 120), "The Key")
    ;MsgBox(0,0,$Password & @CRLF & $PassRead)
    If $PassRead = 0 Then Exit
    If $Password <> $PassRead Then Exit
EndIf
;#ce

$GUI = GUICreate("Web Pass", 410, 190, @DesktopWidth - 425, @DesktopHeight - 290)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $GUI)
WinSetOnTop($GUI, "", 1)
#Region GUI
    $Retrieve = GUICtrlCreateCombo("", 10, 20, 120)
    GUICtrlSetFont(-1,12)
    
    _CreatePasswordCombo()

    $Enter = GUICtrlCreateButton("Enter", 140, 20, 50, 26)
    GUICtrlSetOnEvent($Enter, "_Find")

    $Delete = GUICtrlCreateButton("Delete", 10, 50, 50)
    GUICtrlSetOnEvent($Delete, "_Delete")


    GUICtrlCreateLabel("Title", 10, 95, 100)
    GUICtrlSetFont(-1,11)
    $Title = GUICtrlCreateInput("", 10, 110, 100)
    GUICtrlSetFont(-1,12)
    
    GUICtrlCreateLabel("Username", 120, 95, 100)
    GUICtrlSetFont(-1,11)
    $User = GUICtrlCreateInput("", 120, 110, 100)
    GUICtrlSetFont(-1,12)
    
    GUICtrlCreateLabel("Password", 230, 95, 100)
    GUICtrlSetFont(-1,11)
    $Pass = GUICtrlCreateInput("", 230, 110, 100)
    GUICtrlSetFont(-1,12)
    
    $Pause = GUICtrlCreateCheckbox("Pause", 340, 110, 100)
    GUICtrlSetFont(-1,11)

    $Save = GUICtrlCreateButton("Save", 10, 140, 50)
    GUICtrlSetOnEvent($Save, "_Save")

    $MENU_1 = GUICtrlCreateMenu("Browser")
    $MENU_FIREFOX = GUICtrlCreateMenuItem("Firefox", $MENU_1)
    GUICtrlSetOnEvent($MENU_FIREFOX, "_BrowserSelection")
    $MENU_IE = GUICtrlCreateMenuItem("IE", $MENU_1)
    GUICtrlSetOnEvent($MENU_IE, "_BrowserSelection")

    $BROWSER_SELECTION = RegRead($REGLOCATION1, "_BrowserSelection")
    If $BROWSER_SELECTION = "IE" Then
        GUICtrlSetState($MENU_FIREFOX, $GUI_CHECKED)
        GUICtrlSetState($MENU_IE, $GUI_UNCHECKED)
    EndIf
    If $BROWSER_SELECTION = "Firefox" Then
        GUICtrlSetState($MENU_FIREFOX, $GUI_UNCHECKED)
        GUICtrlSetState($MENU_IE, $GUI_CHECKED)
    EndIf

    $MENU_2 = GUICtrlCreateMenu("OnTheGo")
    $MENU_IMPORT = GUICtrlCreateMenuItem("Import", $MENU_2)
    GUICtrlSetOnEvent($MENU_IMPORT, "_Import")
    $MENU_EXPORT = GUICtrlCreateMenuItem("Export", $MENU_2)
    GUICtrlSetOnEvent($MENU_EXPORT, "_Export")
#EndRegion
GUISetState()

While 1

    Sleep(50)

WEnd

Func _Save()

    If GUICtrlRead($Pass) = "" Then
        RegWrite ( $REGLOCATION2, GUICtrlRead($Title) , "REG_SZ", _RC4(GUICtrlRead($User), "The Key") )
    Else
        If GUICtrlRead($Pause) = $GUI_CHECKED Then;If we need to pause to enter info in the next page
            RegWrite ( $REGLOCATION2, GUICtrlRead($Title) , "REG_MULTI_SZ", _RC4(GUICtrlRead($User), "The Key") & @LF & _RC4(GUICtrlRead($Pass), "The Key") & @LF & "Pause")
        Else
            RegWrite ( $REGLOCATION2, GUICtrlRead($Title) , "REG_MULTI_SZ", _RC4(GUICtrlRead($User), "The Key") & @LF & _RC4(GUICtrlRead($Pass), "The Key") )
        EndIf
    EndIf

    _GUICtrlComboBox_AddString($Retrieve, GUICtrlRead($Title))
    $ComboArray = _GUICtrlComboBox_GetListArray($Retrieve)
    _ArraySort($ComboArray)
    _GUICtrlComboBox_ResetContent($Retrieve)

    For $K = 1 To UBound($ComboArray) - 1
        _GUICtrlComboBox_AddString($Retrieve, $ComboArray[$K])
    Next

    GUICtrlSetData($Title, "")
    GUICtrlSetData($User, "")
    GUICtrlSetData($Pass, "")
    GUICtrlSetState($Pause, $GUI_UNCHECKED)

EndFunc

Func _Delete()

    RegDelete ( $REGLOCATION2, GUICtrlRead($Retrieve))
    $Index = _GUICtrlComboBox_FindStringExact($Retrieve, GUICtrlRead($Retrieve))
    _GUICtrlComboBox_DeleteString($Retrieve, $Index)
    _GUICtrlComboBox_SetEditText($Retrieve, "")

EndFunc

Func _Find()

    $CurrentBrowser = RegRead ( $REGLOCATION1, "_BrowserSelection" )
    $RegPass = RegRead ( $REGLOCATION2, GUICtrlRead($Retrieve) )
    $RegPassArray = StringSplit($RegPass,@LF)
    ;_ArrayDisplay($RegPassArray)

    _ActiveBrowser()

    If $RegPassArray[0] = 1 Then
        $Decrypt = _RC4($RegPassArray[1], "The Key")
        $FinalPass = BinaryToString($Decrypt)       
        Send($FinalPass)
    ElseIf $RegPassArray[0] = 2 Then
        $Decrypt = _RC4($RegPassArray[1], "The Key")
        $FinalPass = BinaryToString($Decrypt)           
        Send($FinalPass)
        Sleep(20)
        Send("{Tab}")
        Sleep(20)
        $Decrypt = _RC4($RegPassArray[2], "The Key")
        $FinalPass = BinaryToString($Decrypt)   
        Send($FinalPass)
    ElseIf $RegPassArray[0] = 3 Then
        $Decrypt = _RC4($RegPassArray[1], "The Key")
        $FinalPass = BinaryToString($Decrypt)           
        Send($FinalPass)
        Sleep(20)
        Send("{Enter}")
        
        Do
            ConsoleWrite("1")
            Sleep(50)
        Until _IsPressed("11")
        
        _ActiveBrowser()

        Sleep(20)
        $Decrypt = _RC4($RegPassArray[2], "The Key")
        $FinalPass = BinaryToString($Decrypt)   
        Send($FinalPass)
    EndIf

    Send("{Enter}")

EndFunc

Func _Import()

    $Password = RegRead($REGLOCATION1, "_Access")
    $PassRead = _RC4(InputBox("Access Password","Enter password to export web passwords.", "", "", 250, 120), "The Key")
    If $PassRead = 0 Then Exit
    If $Password <> $PassRead Then Exit

    $INIArray = IniReadSection($sIni, "Passwords")
    ;_ArrayDisplay($INIArray)
    
    ;Add passwords to array
    For $J = 1 To UBound($INIArray) - 1
    ;   If $var = "The system cannot find the file specified." & @CRLF Then ExitLoop
    ;   If $var = "No more data is available." & @CRLF Then ExitLoop
        RegWrite($REGLOCATION2, $INIArray[$J][0], "REG_MULTI_SZ", StringReplace($INIArray[$J][1], "----", @LF))
    ;   If @error <> 0 Then ExitLoop
    Next

    _GUICtrlComboBox_ResetContent($Retrieve)

    _CreatePasswordCombo()

    $DeleteIni = MsgBox(4+32, "Delete ini", "Would you like to delete the ini file?")
    If $DeleteIni = 6 Then
        FileDelete($sIni)
    EndIf

EndFunc

Func _Export()

    $Password = RegRead($REGLOCATION1, "_Access")
    $PassRead = _RC4(InputBox("Access Password","Enter password to export web passwords.", "", "", 250, 120), "The Key")
    If $PassRead = 0 Then Exit
    If $Password <> $PassRead Then Exit

    ;Add passwords to array
    Local $ComboArray2[UBound($ComboArray)][2]
    For $J = 1 To UBound($ComboArray) - 1
    ;   If $var = "The system cannot find the file specified." & @CRLF Then ExitLoop
    ;   If $var = "No more data is available." & @CRLF Then ExitLoop
        $var = RegEnumVal($REGLOCATION2, $J)
        $ComboArray2[$J][0] = $var
        $ComboArray2[$J][1] = StringReplace(RegRead($REGLOCATION2, $var), @LF, "----")
    ;   If @error <> 0 Then ExitLoop
    Next

    ;_ArrayDisplay($ComboArray2)
    IniWriteSection($sIni, "Passwords", $ComboArray2)   

EndFunc

Func _ActiveBrowser()

    If $CurrentBrowser = "IE" Then
        WinActivate("Windows Internet Explorer")
        WinWaitActive("Windows Internet Explorer")
    ;   ConsoleWrite("IE" & @CRLF)
    ElseIf $CurrentBrowser = "Firefox" Then
        WinActivate("Mozilla Firefox")
        WinWaitActive("Mozilla Firefox")
    ;   ConsoleWrite("Firefox" & @CRLF)
    EndIf

EndFunc

Func _BrowserSelection()

    If @GUI_CtrlId = $MENU_FIREFOX Then
        RegWrite($REGLOCATION1, "_BrowserSelection", "REG_SZ", "Firefox")
        GUICtrlSetState($MENU_FIREFOX, $GUI_CHECKED)
        GUICtrlSetState($MENU_IE, $GUI_UNCHECKED)
    ElseIf @GUI_CtrlId = $MENU_IE Then
        RegWrite($REGLOCATION1, "_BrowserSelection", "REG_SZ", "IE")
        GUICtrlSetState($MENU_FIREFOX, $GUI_UNCHECKED)
        GUICtrlSetState($MENU_IE, $GUI_CHECKED)
    EndIf

EndFunc

Func _CreatePasswordCombo()

    ;Get how many passwords are saved--( maxed at 100 )
    For $I = 1 To 100
        $var = RegEnumVal($REGLOCATION2, $i)
        If @error = -1 Then
            $Skip = 1
            ExitLoop
        EndIf
    Next
    
    If $Skip = 1 Then
        ;Create array to retrieve passwords
        Global $ComboArray[$I]
        
        ;Add passwords to array
        For $J = 1 To UBound($ComboArray) - 1
        ;   If $var = "The system cannot find the file specified." & @CRLF Then ExitLoop
        ;   If $var = "No more data is available." & @CRLF Then ExitLoop
            $var = RegEnumVal($REGLOCATION2, $J)
            $ComboArray[$J] = $var
        ;   If @error <> 0 Then ExitLoop
        Next

        ;_ArrayDisplay($ComboArray)
        _ArraySort($ComboArray)
        ;_ArrayDisplay($ComboArray)

        For $K = 1 To UBound($ComboArray) - 1
            _GUICtrlComboBox_AddString($Retrieve, $ComboArray[$K])
        Next
    EndIf
    
EndFunc

Func _RC4($Data, $Key)
    Local $Opcode = "0xC81001006A006A005356578B551031C989C84989D7F2AE484829C88945F085C00F84DC000000B90001000088C82C0188840DEFFEFFFFE2F38365F4008365FC00817DFC000100007D478B45FC31D2F775F0920345100FB6008B4DFC0FB68C0DF0FEFFFF01C80345F425FF0000008945F48B75FC8A8435F0FEFFFF8B7DF486843DF0FEFFFF888435F0FEFFFFFF45FCEBB08D9DF0FEFFFF31FF89FA39550C76638B85ECFEFFFF4025FF0000008985ECFEFFFF89D80385ECFEFFFF0FB6000385E8FEFFFF25FF0000008985E8FEFFFF89DE03B5ECFEFFFF8A0689DF03BDE8FEFFFF860788060FB60E0FB60701C181E1FF0000008A840DF0FEFFFF8B750801D6300642EB985F5E5BC9C21000"
    Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]")
    DllStructSetData($CodeBuffer, 1, $Opcode)

    Local $Buffer = DllStructCreate("byte[" & BinaryLen($Data) & "]")
    DllStructSetData($Buffer, 1, $Data)

    DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _
                                                    "ptr", DllStructGetPtr($Buffer), _
                                                    "int", BinaryLen($Data), _
                                                    "str", $Key, _
                                                    "int", 0)

    Local $Ret = DllStructGetData($Buffer, 1)
    $Buffer = 0
    $CodeBuffer = 0
    Return $Ret
EndFunc

Func _Exit()

    Exit

EndFunc

EDIT: Edited the script a little

Edited by Champak

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×