Jump to content
31290

[SOLVED] Decrypt a password

Recommended Posts

Hi everyone, 

I'm building some script that will encrypt some user password and store it in an ini file.
I'd like to recall the password in a putty session but I can't figure out how to decrypt it:

So far, I have:

Global $Images = "C:\SAC_IS\ATL_Laptop\Resources\Images\"
Global $WorkingDir = "C:\SAC_IS\Switches_Toolbox\"
Global $Settings = $WorkingDir & "\Settings.ini"

DirCreate ($WorkingDir)

_FirstRun()

While 1
    Sleep(10)
WEnd

Func _FirstRun()
If FileExists ("C:\SAC_IS\Switches_Toolbox\Settings.ini") Then
_LoginfoGUI()
Else
MsgBox (64, "PUTTY EXECUTABLE", "First, select PUTTY.EXE path")
Global $PuttyPath = FileOpenDialog("Please indicate putty.exe path", @HomeDrive, "exe (*.exe)")
_LoginfoGUI()
If @Error Then
Global $Error = MsgBox(21, "Error!", "Can't find PUTTY.EXE!"& @CRLF & "Click Retry or Cancel to Quit")
If $Error = $IDRETRY Then
_FirstRun()
Else
_Exit()
EndIf
Else
FileInstall ("C:\Users\h74033\Desktop\Scirpts\Switches\Settings.ini", $WorkingDir & "\Settings.ini", 1)
IniWrite ($Settings, "Putty", "Path", $PuttyPath)
EndIf
EndIf
; SwitchesToolboxGui()

Endfunc

Func _Exit()
    Exit
EndFunc 

Func _LoginfoGUI()
Global $LoginfoGUI = GUICreate("Switches Toolbox Configuration", 300, 300, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit", $LoginfoGUI)
    GUICtrlCreatePic ($Images & "\SAClogo.jpg", 30, 10, 240, 80)
    GUISetBkColor ($Color_White)
    GUICtrlCreateLabel("-- SWITCHES TOOLBOX --", 85, 100, 150, 25)
    GUICtrlSetFont (-1, 8.5, 700, 0)
    GUICtrlCreateLabel("Please provide required information:", 10, 130, 250, 25)
    GUICtrlCreateLabel("-Global ID:", 10, 170, 60, 30)
    GUICtrlSetFont (-1, 8.5, 700, 0)
    GUICtrlCreateLabel("-Password:", 10, 210, 70, 30)
    GUICtrlSetFont (-1, 8.5, 700, 0)
    Global $GIDInput = GUICtrlCreateInput("", 90, 168, 80, 20)
    Global $PassInput = GUICtrlCreateInput("", 90, 205, 150, 20, $ES_PASSWORD)
    GUICtrlCreateButton ("Submit", 100, 245, 100, 25)
    GUICtrlSetOnEvent(-1, "_Submit")
    GUISetState(@SW_SHOW)
EndFunc

Func _Submit()
Global $GID = GuiCtrlRead($GIDInput)
Global $EncryptedPwd = _Crypt_HashData (GuiCtrlRead($PassInput), $CALG_MD2)

IniWrite ($Settings, "Username", "Gid", $Gid)
IniWrite ($Settings, "Encryption", "Password", $EncryptedPwd)
;MsgBox(0, "re", $EncryptedPwd)

EndFunc

How can I achieve that please?

Thanks in advance :)
 

Edited by 31290
Solved

~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites

The UDF _Crypt_HashData() does not encrypt a string but creates an hash which you can later use to compare to another string by using the same functions.

So this is a safe way for example to verify a typed in password without being able to restore the original password.

Jos 
 


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Thanks to both of you for your answers.

@Jfish I took a look at the function you pointed out but I don't understand the "$vCryptKey" parameter. Can you please provide an example upon the script I made?

Thanks :)

EDIT: I found the solution. Thanks again for your help :)

  

 

Edited by 31290
Solution found.

~~~ Doom Shall Never Die, Only The Players ~~~

Share this post


Link to post
Share on other sites

@Jfish I took a look at the function you pointed out but I don't understand the "$vCryptKey" parameter. Can you please provide an example upon the script I made?

  

 

Isn't there an example in the example? Would be the obvious place I would look


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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

  • Similar Content

    • By nacerbaaziz
      hello all, and welcome to this tool
      the NB-Password_generator is a small tool which allow you to create a strong passwords
      with this tool you can create a random passwords using :
      1. capital letters
      2. small letters
      3. numbers
      4. symbols
      be sure that you can check any option that  you want and uncheck what you don't want to use
      this tool allow you to create a password from 6 letters to 150 lettersNB-Password_generator.zip
      at the end please accept my greetings
      am waiting for your commants
    • By nooneclose
      I am sure you guys know of a simple solution but I am still kind of new to AutoIt and its special functions. I want my code to be able to know how to encrypt and decrypt "A" and "a" as two different chars.
      my code is very long so here is just a snippet/example of it.  
      ;Encode== Global $charAA = "" ; ( Capital letter A ) = Global 184 = ¸ ( Cedilla ) $charAA = $charAA & Chr(65) Global $chara = "" ; ( Lowercase letter a ) = Global 251 = û ( û Latin Small Letter U With Circumflex ) $chara = $chara & Chr(97) ;Decode== Global $ch184 = "" ;( Copyright symbol ) = $charAA $ch184 = $ch184 & Chr(184) Global $ch251 = "" ;( û Latin Small Letter U With Circumflex ) = $chara $ch251 = $ch251 & Chr(251) ;Encode== stringreplace($test_String, $charAA, $ch184) stringreplace($test_String, $chara, $ch251) ;Decode== stringreplace($$new_String, $ch184, $charAA) stringreplace($$new_String, $ch251, $chara) ( NOTE: my stringreplace function is nested in my actual code. I only separated them here for readability. )

      I know there are better ways to Encrypt and Decrypt a message but I'm doing this as a fun side project for me and a select group of friends to enjoy. 
      Again My code is not encrypting or decrypting capitals and lower case properly even though I use their ANSI codes. 
       
      Example: Input "A a B b"  Encrypt: ". . $ $"  Decrypt: "A A B B"
      Any and all help will be greatly appreciated.  
    • By SC0U7
      Hello i have a text file which contain over 600KB of BASE64 strings like :
      TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
      Now what i need is divide this long string as autoit variable each max lenght (4000characters per line) example:
      Local $var
      $var &=  TVqQAAMAAAAEAAA..
      $var &=  VbAmejwqqqAACEE..
      and then how to i add encrypt function on every line ? how to i can xor it? example final will be :
      $var &=  XorEnc(TVqQAAMAAAAEAAA..)
      $var &=  XorEncVbAmejwqqqAACEE..)
       
      Thanks for any help and ideas 
    • By Gowrisankar
      Dear members of the forum,
      I need to open excel files that may or may not need a password and finally move the files that needs password to manual queue.
      Is there a fastest way to do this?
       
      PS: I have a huge respect for the rules of this forum. I am not asking assistance to override any security measure. I just need to segregate the files that needs passwords.
×
×
  • Create New...