#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=26.ico
#AutoIt3Wrapper_Outfile=SavePass.exe
#AutoIt3Wrapper_OutFile_X64=SavePassX64.exe
; #AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=1.0.4.0
#AutoIt3Wrapper_Add_Constants=n
#AutoIt3Wrapper_Res_LegalCopyright=KL
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_Field=Version|1.0.4.0
#AutoIt3Wrapper_Res_Field=Build|2013.07.31
#AutoIt3Wrapper_Res_Field=Coded by|KL
#AutoIt3Wrapper_Res_Field=Compile date|%longdate% %time%
#AutoIt3Wrapper_Res_Field=AutoIt Version|%AutoItVer%
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/sf /sv /om /cs=0 /cn=0
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_Obfuscated.au3"
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
; #include <ListBoxConstants.au3>
#include <_ArrayAddEx.au3>
#include <_GUICtrlEdit_TogglePassChars.au3>
#include <Array.au3>
#include <Crypt.au3>
#include <EditConstants.au3>
#include <File.au3>
; #include <GUIConstantsEx.au3>
#include <GuiListBox.au3>
#include <RandomString.au3>
#include <WindowsConstants.au3>
#include <UserGUI.au3>
Opt("GUICloseOnESC", 0) ; Запрещает закрытие окон клавишей Esc
#NoTrayIcon ; Скрыть иконку скрипта в трее
Global $a[6], $Array_Enc[1], $Array_unEnc[1][5], $hAdd
Global $bd = @ScriptDir & '\BD.ps3'
$input = InputBox("Введите пароль", "Введите пароль для доступа к списку паролей", "", "*", -1, 140)
;$input = 'do5ita'
If $input Then
$shifr = "Relzgkbr1" & $input & BitOR(Hex(StringToBinary($input, 4)), 0x45454345)
If FileExists($bd) Then reload()
;================================
$GUI = GUICreate("SavePass v1.0.4 by KL", 511, 331, -1, -1, BitOR($WS_POPUP, $WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX))
Global $list = GUICtrlCreateList("", 10, 10, 180, 279, $LBS_SORT, $WS_EX_CLIENTEDGE)
For $i = 1 To UBound($Array_unEnc) - 1
If $Array_unEnc[$i][2] <> '' Then GUICtrlSetData(-1, $Array_unEnc[$i][2])
Next
$add = GUICtrlCreateButton("Добавить", 10, 290, 58, 30)
$edit = GUICtrlCreateButton("Изменить", 70, 290, 59, 30)
$del = GUICtrlCreateButton("Удалить", 130, 290, 61, 30)
$hide = GUICtrlCreateButton("Показать", 446, 131, 55, 19)
GUICtrlCreateLabel("Название:", 210, 10, 55, 15)
GUICtrlCreateLabel("Сайт:", 210, 40, 50, 15)
GUICtrlCreateLabel("Mail:", 210, 70, 50, 15)
GUICtrlCreateLabel("Логин:", 210, 100, 50, 15)
GUICtrlCreateLabel("Пароль:", 210, 130, 50, 15)
GUICtrlCreateLabel("Комментарии:", 210, 160, 81, 15)
$name = GUICtrlCreateInput("", 267, 10, 233, 20, 2048, 512)
$url = GUICtrlCreateInput("", 267, 40, 233, 20, 2048, 512)
$mail = GUICtrlCreateInput("", 267, 70, 233, 20, 2048, 512)
$login = GUICtrlCreateInput("", 267, 100, 233, 20, 2048, 512)
$pass = GUICtrlCreateInput("", 267, 130, 175, 20, 2048, 512)
$info = GUICtrlCreateEdit("", 210, 180, 291, 138, 2048)
GUISetBkColor(0x00E0FFFF)
GUICtrlSetBkColor($name, 0xFFFFFF)
GUICtrlSetBkColor($url, 0xFFFFFF)
GUICtrlSetBkColor($login, 0xFFFFFF)
GUICtrlSetBkColor($pass, 0xFFFFFF)
GUICtrlSetBkColor($mail, 0xFFFFFF)
GUICtrlSetBkColor($info, 0xFFFFFF)
GUICtrlSetState($edit, $GUI_DISABLE)
GUICtrlSetState($del, $GUI_DISABLE)
_GUICtrlEdit_TogglePassChars($GUI, $pass, -1, "9679")
GUICtrlSetTip($add, "Добавить новую запись")
GUICtrlSetTip($del, "Удалить выбранную запись")
GUICtrlSetTip($edit, "Изменить выбранную запись")
GUICtrlSetTip($hide, "Показать пароль")
GUISetState()
While 1
Switch GUIGetMsg()
Case $edit
edit()
Case $del
del()
Case $hide
hide()
Case $add
add()
Case $list
info()
Case $GUI_EVENT_CLOSE
GUIDelete($GUI)
ExitLoop
EndSwitch
WEnd
Else
MsgBox(0, "Ошибка", "Пароль не может быть пустым")
Exit
EndIf
Func del()
Local $idx, $list0
$list0 = GUICtrlRead($list) ; Типа чтение 1 раз
If $list0 Then
If MsgBox(4, "Внимание!", 'Вы действительно хотите удалить запись "' & $list0 & '"?', 0, $GUI) = 6 Then
$idx = _ArraySearch($Array_unEnc, $list0)
_FileWriteToLine($bd, $Array_unEnc[$idx][7], '', 1)
_GUICtrlListBox_DeleteString($list, _GUICtrlListBox_GetCaretIndex($list))
_ArrayDelete($Array_unEnc, $idx)
GUICtrlSetData($name, '')
GUICtrlSetData($url, '')
GUICtrlSetData($login, '')
GUICtrlSetData($pass, '')
GUICtrlSetData($info, '')
GUICtrlSetData($mail, '')
EndIf
Else
MsgBox(0, "Внимание!", "Выберите запись в списке", 0, $GUI)
EndIf
EndFunc ;==>del
Func hide()
_GUICtrlEdit_TogglePassChars($GUI, $pass, -1, "9679")
If GUICtrlRead($hide) = 'Показать' Then
GUICtrlSetData($hide, 'Скрыть')
GUICtrlSetTip($hide, "Скрыть пароль от любопытных глаз =)")
ElseIf GUICtrlRead($hide) = 'Скрыть' Then
GUICtrlSetData($hide, 'Показать')
GUICtrlSetTip($hide, "Показать пароль")
EndIf
EndFunc ;==>hide
Func info()
If GUICtrlRead($list) <> '' Then
GUICtrlSetState($edit, $GUI_ENABLE)
GUICtrlSetState($del, $GUI_ENABLE)
$Pos = _ArraySearch($Array_unEnc, GUICtrlRead($list))
GUICtrlSetData($name, $Array_unEnc[$Pos][2])
GUICtrlSetData($url, $Array_unEnc[$Pos][0])
GUICtrlSetData($login, $Array_unEnc[$Pos][4])
GUICtrlSetData($pass, $Array_unEnc[$Pos][5])
GUICtrlSetData($mail, $Array_unEnc[$Pos][6])
GUICtrlSetData($info, $Array_unEnc[$Pos][1])
EndIf
EndFunc ;==>info
Func reload()
_FileReadToArray($bd, $Array_Enc)
ReDim $Array_unEnc[1][8]
For $i = 1 To $Array_Enc[0]
_ArrayAddEx($Array_unEnc, BinaryToString(_Crypt_DecryptData(FileReadLine($bd, $i), StringToBinary($shifr), $CALG_AES_256)), $input, $i)
Next
EndFunc ;==>reload
Func add()
$iState = True
Local $hGen
; GUICtrlSetState($list, $GUI_DISABLE)
; $hAdd = GUICreate("", 280, 310, Default, Default, "$WS_CAPTION")
GUISetState(@SW_DISABLE, $GUI)
$GP = _GetChildCoor($GUI, 280, 280) ; Центрирует дочернее окно к родительскому
$hAdd = GUICreate('Добавить', $GP[0], $GP[1], $GP[2], $GP[3], BitOR($WS_CAPTION, $WS_SYSMENU, $WS_POPUP), -1, $GUI)
GUICtrlCreateLabel("Название:", 10, 12)
GUICtrlCreateLabel("Сайт:", 10, 35)
GUICtrlCreateLabel("Mail:", 10, 58)
GUICtrlCreateLabel("Логин:", 10, 81)
GUICtrlCreateLabel("Пароль:", 10, 104)
GUICtrlCreateLabel("Описание:", 10, 127)
$name_add = GUICtrlCreateInput("", 65, 10, 170)
$url_add = GUICtrlCreateInput("", 65, 33, 170)
$mail_add = GUICtrlCreateInput("", 65, 56, 170)
$login_add = GUICtrlCreateInput("", 65, 79, 170)
$pass_add = GUICtrlCreateInput("", 65, 102, 170)
$info_add = GUICtrlCreateEdit("", 10, 148, 250, 100, BitOR($ES_MULTILINE, $ES_WANTRETURN, $ES_AUTOVSCROLL))
$gen = GUICtrlCreateButton("Сгенерировать пароль", 110, 125, Default, 18)
$save = GUICtrlCreateButton("Сохранить", 10, 250, 120)
$cancel = GUICtrlCreateButton("Отмена", 130, 250, 130)
GUICtrlSetTip($gen, "Правый клик мышкой - показать настройки генератора")
GUISetState(@SW_SHOW, $hAdd)
While 1
$msg = GUIGetMsg()
$curs_info = GUIGetCursorInfo($hAdd)
Select
Case $curs_info[4] = $name_add
If $curs_info[2] Then
ToolTip("")
GUICtrlSetBkColor($name_add, 0xffffff)
EndIf
Case $curs_info[4] = $gen And $curs_info[3]
If $iState Then
$hGen = GUICreate("Генератор паролей", 150, 110, 280, -47, $WS_CAPTION, $WS_EX_MDICHILD, $hAdd)
$Checkbox1 = GUICtrlCreateCheckbox("Цифры", 16, 8)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Строчные буквы", 16, 32)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox3 = GUICtrlCreateCheckbox("Заглавные буквы", 16, 56)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label1 = GUICtrlCreateLabel("Длина пароля:", 17, 80)
$Input1 = GUICtrlCreateInput("8", 102, 77, 35, 21, $ES_READONLY)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 99, 1)
GUISetState(@SW_SHOW, $hGen)
$iState = False
EndIf
Case $msg = $gen
If $hGen Then
$Read1 = GUICtrlRead($Input1)
$Read3 = GUICtrlRead($Checkbox1)
$Read4 = GUICtrlRead($Checkbox2)
$Read5 = GUICtrlRead($Checkbox3)
$Flag1 = 0
$Flag2 = 0
$Flag3 = 0
If $Read3 = 1 Then $Flag1 = 1
If $Read4 = 1 Then $Flag2 = 4
If $Read5 = 1 Then $Flag3 = 2
GUICtrlSetData($pass_add, _Crypto_GetRandomString($Read1, BitOR($Flag1, $Flag2, $Flag3)))
Else
GUICtrlSetData($pass_add, _Crypto_GetRandomString(9, 15))
EndIf
Case $msg = $save
$w = WinGetPos($hAdd)
If GUICtrlRead($name_add) = '' Then
ToolTip('Поле "Название" обязательно должно быть заполнено', $w[0] + 100, $w[1] + 50, "", 3, 1)
ContinueLoop
EndIf
For $i = 1 To UBound($Array_unEnc) - 1
If $Array_unEnc[$i][2] = GUICtrlRead($name_add) Then
ToolTip("Такая запись уже существует", $w[0] + 100, $w[1] + 50, "", 3, 1)
GUICtrlSetBkColor($name_add, 0xff0000)
ContinueLoop (2)
EndIf
Next
$a[0] = GUICtrlRead($name_add)
$a[1] = GUICtrlRead($url_add)
$a[2] = GUICtrlRead($login_add)
$a[3] = GUICtrlRead($pass_add)
$a[4] = GUICtrlRead($info_add)
$a[5] = GUICtrlRead($mail_add)
$unEnc = $a[1] & '|' & $a[4] & '|' & $a[0] & '|' & $input & '|' & $a[2] & '|' & $a[3] & '|' & $a[5]
$hFile = FileOpen($bd, 1)
FileWriteLine($hFile, _Crypt_EncryptData($unEnc, StringToBinary($shifr), $CALG_AES_256) & @CRLF)
_GUICtrlListBox_AddString($list, $a[0])
FileClose($hFile)
reload()
GUISetState(@SW_ENABLE, $GUI)
GUIDelete($hAdd)
ExitLoop
Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
For $i = 0 To UBound($a) - 1
$a[$i] = ''
Next
ToolTip("")
GUISetState(@SW_ENABLE, $GUI)
GUIDelete($hAdd)
ExitLoop
EndSelect
WEnd
; GUICtrlSetState($list, $GUI_ENABLE)
EndFunc ;==>add
Func edit()
Local $hGen
If GUICtrlRead($list) Then
$iState = True
; GUICtrlSetState($list, $GUI_DISABLE)
; $hEdit = GUICreate("", 280, 310, Default, Default, $WS_CAPTION)
GUISetState(@SW_DISABLE, $GUI)
$GP = _GetChildCoor($GUI, 280, 280)
$hEdit = GUICreate('Изменить', $GP[0], $GP[1], $GP[2], $GP[3], BitOR($WS_CAPTION, $WS_SYSMENU, $WS_POPUP), -1, $GUI)
GUICtrlCreateLabel("Название:", 10, 12)
GUICtrlCreateLabel("Сайт:", 10, 35)
GUICtrlCreateLabel("Mail:", 10, 58)
GUICtrlCreateLabel("Логин:", 10, 81)
GUICtrlCreateLabel("Пароль:", 10, 104)
GUICtrlCreateLabel("Описание:", 10, 127)
$name_edit = GUICtrlCreateInput(GUICtrlRead($name), 65, 10, 170)
$url_edit = GUICtrlCreateInput(GUICtrlRead($url), 65, 33, 170)
$mail_edit = GUICtrlCreateInput(GUICtrlRead($mail), 65, 56, 170)
$login_edit = GUICtrlCreateInput(GUICtrlRead($login), 65, 79, 170)
$pass_edit = GUICtrlCreateInput(GUICtrlRead($pass), 65, 102, 170)
$info_edit = GUICtrlCreateEdit(GUICtrlRead($info), 10, 148, 250, 100, BitOR($ES_MULTILINE, $ES_WANTRETURN, $ES_AUTOVSCROLL))
$gen = GUICtrlCreateButton("Сгенерировать пароль", 105, 125, Default, 18)
$save = GUICtrlCreateButton("Сохранить", 10, 250, 120)
$cancel = GUICtrlCreateButton("Отмена", 130, 250, 130)
GUICtrlSetTip($gen, "Правый клик мышкой - показать настройки генератора")
GUISetState(@SW_SHOW, $hEdit)
While 1
$msg = GUIGetMsg()
$curs_info = GUIGetCursorInfo($hEdit)
Select
Case $curs_info[4] = $name_edit
If $curs_info[2] = 1 Then
ToolTip("")
GUICtrlSetBkColor($name_edit, 0xffffff)
EndIf
Case $curs_info[4] = $gen And $curs_info[3]
If $iState Then
$hGen = GUICreate("Генератор паролей", 150, 110, 280, -47, $WS_CAPTION, $WS_EX_MDICHILD, $hEdit)
$Checkbox1 = GUICtrlCreateCheckbox("Цифры", 16, 8)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox2 = GUICtrlCreateCheckbox("Строчные буквы", 16, 32)
GUICtrlSetState(-1, $GUI_CHECKED)
$Checkbox3 = GUICtrlCreateCheckbox("Заглавные буквы", 16, 56)
GUICtrlSetState(-1, $GUI_CHECKED)
$Label1 = GUICtrlCreateLabel("Длина пароля:", 17, 80)
$Input1 = GUICtrlCreateInput("8", 102, 77, 35, 21, $ES_READONLY)
GUICtrlCreateUpdown(-1)
GUICtrlSetLimit(-1, 99, 1)
GUISetState(@SW_SHOW, $hGen)
$iState = False
EndIf
Case $msg = $gen
If $hGen Then
$Read1 = GUICtrlRead($Input1)
$Read3 = GUICtrlRead($Checkbox1)
$Read4 = GUICtrlRead($Checkbox2)
$Read5 = GUICtrlRead($Checkbox3)
$Flag1 = 0
$Flag2 = 0
$Flag3 = 0
If $Read3 = 1 Then $Flag1 = 1
If $Read4 = 1 Then $Flag2 = 4
If $Read5 = 1 Then $Flag3 = 2
GUICtrlSetData($pass_edit, _Crypto_GetRandomString($Read1, BitOR($Flag1, $Flag2, $Flag3)))
Else
GUICtrlSetData($pass_edit, _Crypto_GetRandomString(9, 15))
EndIf
Case $msg = $save
If GUICtrlRead($name_edit) <> GUICtrlRead($list) Then
$w = WinGetPos($hEdit)
If GUICtrlRead($name_edit) = '' Then
ToolTip('Поле "Название" обязательно должно быть заполнено', $w[0] + 100, $w[1] + 50, "", 3, 1)
ContinueLoop
EndIf
For $i = 1 To UBound($Array_unEnc) - 1
If $Array_unEnc[$i][2] = GUICtrlRead($name_edit) Then
ToolTip("Такая запись уже существует", $w[0] + 100, $w[1] + 50, "", 3, 1)
GUICtrlSetBkColor($name_edit, 0xff0000)
ContinueLoop (2)
EndIf
Next
EndIf
$a[0] = GUICtrlRead($name_edit)
$a[1] = GUICtrlRead($url_edit)
$a[2] = GUICtrlRead($login_edit)
$a[3] = GUICtrlRead($pass_edit)
$a[4] = GUICtrlRead($info_edit)
$a[5] = GUICtrlRead($mail_edit)
$unEnc = $a[1] & '|' & $a[4] & '|' & $a[0] & '|' & $input & '|' & $a[2] & '|' & $a[3] & '|' & $a[5]
FileOpen($bd, 1)
$Pos2 = _ArraySearch($Array_unEnc, GUICtrlRead($list))
_FileWriteToLine($bd, $Array_unEnc[$Pos2][7], _Crypt_EncryptData($unEnc, StringToBinary($shifr), $CALG_AES_256), 1)
FileClose($bd)
_GUICtrlListBox_ReplaceString($list, _GUICtrlListBox_GetCaretIndex($list), $a[0])
; GUICtrlSetState($list, $GUI_ENABLE)
_GUICtrlListBox_ClickItem($list, _GUICtrlListBox_SelectString($list, $a[0]))
reload()
GUISetState(@SW_ENABLE, $GUI)
GUIDelete($hEdit)
ExitLoop
Case $msg = $cancel Or $msg = $GUI_EVENT_CLOSE
For $i = 1 To UBound($a) - 1
$a[$i] = ''
Next
ToolTip("")
GUISetState(@SW_ENABLE, $GUI)
GUIDelete($hEdit)
ExitLoop
EndSelect
WEnd
; GUICtrlSetState($list, $GUI_ENABLE)
Else
MsgBox(0, "Внимание!", "Выберите запись в списке", 0, $GUI)
EndIf
EndFunc ;==>edit