Jump to content

One function in my script is not working...


Recommended Posts

So.. I have my script here ;)

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Array.au3>
#include <Marquee.au3>

#region ### START Koda GUI section ### Form=d:\projekty au3\blockar\2ndgui.kxf
$Form1_1 = GUICreate("Lanucher by Undefined-VaR", 500, 334, 260, 225)
GUISetBkColor(0x000000)
$man_login = GUICtrlCreateInput("", 128, 204, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$man_password = GUICtrlCreateInput("", 128, 232, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT, $ES_PASSWORD))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$man_login_label = GUICtrlCreateLabel("Login:", 62, 202, 64, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$man_password_label = GUICtrlCreateLabel("Password:", 32, 232, 94, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$create_user_login_input = GUICtrlCreateInput("", 128, 204, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$create_user_password_input = GUICtrlCreateInput("", 128, 232, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT, $ES_PASSWORD))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$PROGRAMS = GUICtrlCreateGroup("", 268, 14, 211, 121)
GUICtrlSetColor(-1, 0xFF0000)
$programs_list = GUICtrlCreateCombo("", 280, 36, 189, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$lanuch_button = GUICtrlCreateButton("Launch", 280, 100, 75, 25, $BS_CENTER)
$domain = GUICtrlCreateCombo("", 280, 66, 145, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$create_user_login_label = GUICtrlCreateLabel("Login:", 62, 202, 64, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$create_user_password_label = GUICtrlCreateLabel("Password:", 32, 232, 94, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$Create_button = GUICtrlCreateButton("Create_button", 176, 260, 75, 25)
$self_user_list = GUICtrlCreateCombo("", 104, 172, 145, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Group1 = GUICtrlCreateGroup("", 12, 14, 237, 111)
$own_pass_radio = GUICtrlCreateRadio("Own pass", 22, 30, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
$user_list_radio = GUICtrlCreateRadio("User List", 22, 52, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
$create_user_radio = GUICtrlCreateRadio("Create User", 22, 74, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
$delete_user_radio = GUICtrlCreateRadio("Delete User", 22, 96, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$user_create_comunicate = GUICtrlCreateLabel("", 15, 297, 238, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x3399FF)
;$Pic1 = GUICtrlCreatePic("", 260, 162, 229, 150)
;_GUICtrlPic_SetImage($Pic1, "yolo.gif")
$user_delete_combo = GUICtrlCreateCombo("", 104, 204, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$user_delete_button = GUICtrlCreateButton("Delete", 176, 230, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

#cs
    Case $use_own_acc_box
    Case $user_create_box
    Case $user_pick_box
#ce

Global $array[20][4]
Global $debug = 1
;/========================================================
If Not FileExists("config.cfg") Then IniWrite("config.cfg", "Users", "0x9095D4FA2C07525628591BED75E3195F", "0x9095D4FA2C07525628591BED75E3195F")


;======================== PROGRAMS & Domain================================
GUICtrlSetData($programs_list, "CMD")
GUICtrlSetData($domain, "Local|Wena")
;==================================================================

;========================================================================
;###########            HIDE GUI PARTS                        ###########


Sh($man_login)
Sh($man_password)
Sh($man_login_label)
Sh($man_password_label)

Sh($self_user_list)

Sh($create_user_login_input)
Sh($create_user_password_input)
Sh($create_user_login_label)
Sh($create_user_password_label)
Sh($Create_button)
Sh($user_delete_combo)
Sh($user_delete_button)
;========================================================================

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $create_user_radio
            Sh($man_login)
            Sh($man_password)
            Sh($man_login_label)
            Sh($man_password_label)
            Sh($self_user_list)
            Sh($user_delete_combo)
            Sh($user_delete_button)

            Sh($create_user_login_input, "y")
            Sh($create_user_password_input, "y")
            Sh($create_user_login_label, "y")
            Sh($create_user_password_label, "y")
            Sh($Create_button, "y")


        Case $user_list_radio
            load_list()
            Sh($man_login)
            Sh($man_password)
            Sh($man_login_label)
            Sh($man_password_label)
            Sh($self_user_list)
            Sh($user_delete_combo)
            Sh($user_delete_button)

            Sh($create_user_login_input)
            Sh($create_user_password_input)
            Sh($create_user_login_label)
            Sh($create_user_password_label)
            Sh($Create_button)

            Sh($self_user_list, "y")

        Case $own_pass_radio
            ;
            Sh($create_user_login_input)
            Sh($create_user_password_input)
            Sh($create_user_login_label)
            Sh($create_user_password_label)
            Sh($Create_button)
            Sh($self_user_list)
            Sh($user_delete_combo)
            Sh($user_delete_button)

            Sh($man_login, "y")
            Sh($man_password, "y")
            Sh($man_login_label, "y")
            Sh($man_password_label, "y")
        Case $delete_user_radio
            load_list($user_delete_combo)
            Sh($create_user_login_input)
            Sh($create_user_password_input)
            Sh($create_user_login_label)
            Sh($create_user_password_label)
            Sh($Create_button)
            Sh($self_user_list)
            Sh($man_login)
            Sh($man_password)
            Sh($man_login_label)
            Sh($man_password_label)

            Sh($user_delete_combo, 'y')
            Sh($user_delete_button, 'y')
        Case $Create_button
            _CreateUser(GUICtrlRead($create_user_login_input), GUICtrlRead($create_user_password_input))
        Case $lanuch_button
            _poweron()
        Case $user_delete_button
            Delete_user()
    EndSwitch


WEnd

Func Sh($element, $show = '') ; $show = yes/no
    Local $set
    If $show = '' Then $set = $GUI_HIDE
    If $show = 'y' Then $set = $GUI_SHOW

    GUICtrlSetState($element, $set)
EndFunc   ;==>Sh

Func _CreateUser($login, $Password)

    Local $cfg = "config.cfg"
    If $login <> "" And $Password <> "" Then
        ;check is there a place to save a new user
        If IniRead($cfg, "Users", "", "NoData") = "NoData" Or IniRead($cfg, "Users", "", "NoData") = "" Then IniWrite($cfg, "Users", _Crypt($login), _Crypt($Password))
        de_str('Successfully created user!', 0x00FF00)
    Else
        de_str('Noob!', 0xff0000)

    EndIf
EndFunc   ;==>_CreateUser

Func _Crypt($strig)
    Local $password_for_crypt = "0045922@059939@00559$069949$395959$"
    Local $bAlgorithm = $CALG_AES_256

    $done_password = _Crypt_EncryptData($strig, $password_for_crypt, $bAlgorithm)

    Return $done_password

EndFunc   ;==>_Crypt

Func Decrypt_to_real($string)
    Local $password_to_decrypt = "0045922@059939@00559$069949$395959$"
    Local $bAlgorithm = $CALG_AES_256

    $done_password = _Crypt_DecryptData($string, $password_to_decrypt, $bAlgorithm)
    $done_password = BinaryToString($done_password)
    Return $done_password
EndFunc   ;==>Decrypt_to_real

Func load_list($part = '')

    Local $cfg = "config.cfg"

    $read = IniReadSection($cfg, "Users")
    ;_ArrayDisplay($read)

    For $i = 0 To $read[0][0]
        $array[$i][0] = $read[$i][0] ; Users | Crypted
        $array[$i][1] = Decrypt_to_real($read[$i][0]) ; Users | Decrypted
        $array[$i][2] = $read[$i][1] ; Passwords | Crypted
        $array[$i][3] = Decrypt_to_real($read[$i][1]) ; Passwords | Decrypted
    Next
    ;
    For $m = 1 To $array[0][0]
        If $part <> '' Then
            If $array[$m][1] <> "made by" Then GUICtrlSetData($part, $array[$m][1])
        Else
            If $array[$m][1] <> "made by" Then GUICtrlSetData($self_user_list, $array[$m][1])
        EndIf
    Next
    ;_ArrayDisplay($array)
EndFunc   ;==>load_list

Func de_str($text, $color = '')

    GUICtrlSetColor($user_create_comunicate, $color)

    For $i = 1 To 3 Step 1
        GUICtrlSetData($user_create_comunicate, $text)
        Sleep(250)
        GUICtrlSetData($user_create_comunicate, "")
        Sleep(250)
        GUICtrlSetData($user_create_comunicate, $text)
        Sleep(250)
        GUICtrlSetData($user_create_comunicate, "")
    Next

EndFunc   ;==>de_str

Func _poweron()

    If GUICtrlRead($user_list_radio) = $GUI_CHECKED Then
        If GUICtrlRead($self_user_list) = "" Then
            MsgBox(0, "Error", "Select User!")
        Else
            $username = GUICtrlRead($self_user_list)
            $userID = rai($array, $username) ;return array index ;)
            $Password = $array[$userID][3] ; Password of user with ID returned from name and index
            Sleep(25)
            $program = GUICtrlRead($programs_list)
            $domain = GUICtrlRead($domain)
            If $program <> "" And $domain <> "" Then
                RunAs($username, $domain, $Password, 0, $program, "", @SW_SHOW)
                If $debug = 1 Then MsgBox(0, "", "Username: " & $username & @CRLF & "UserID: " & $userID & @CRLF & "Password: " & $Password)
            EndIf
        EndIf
    EndIf

    If GUICtrlRead($own_pass_radio) = $GUI_CHECKED Then
        $username = GUICtrlRead($man_login)
        $Password = GUICtrlRead($man_password)
        $program = GUICtrlRead($programs_list)
        $domain = GUICtrlRead($domain)
        If $program <> "" And $domain <> "" Then
            RunAs($username, $domain, $Password, 0, $program, "", @SW_SHOW)
            If $debug = 1 And $username <> "" And $Password <> "" Then MsgBox(0, "", "Username_man: " & $username & @CRLF & " Password_man: " & $Password)
        EndIf
    EndIf

    ;RunAs($username, $domain, $password, "", $Program)

EndFunc   ;==>_poweron

Func Delete_user()
    $user = GUICtrlRead($user_delete_combo)

    If $user <> "" Then
        $key = _ArraySearch($array, $user, 0, 0, 0, 1)
        $del = $array[$key][0]
        MsgBox(0, "", $del & "key: " & $key)
        IniDelete("config.cfg", "Users", $del)
        Dfa($array, $array[$key][0], $array[$key][1], $array[$key][2], $array[$key][3])
        GUICtrlSetData($user_delete_combo, "")
        load_list($user_delete_combo)
    EndIf
EndFunc   ;==>Delete_user

Func Dfa($sarray, $element1, $element2, $element3, $element4)

    _ArrayDelete($sarray, $element1)
    _ArrayDelete($sarray, $element2)
    _ArrayDelete($sarray, $element3)
    _ArrayDelete($sarray, $element4)
EndFunc   ;==>Dfa

Func rai($sarray, $item) ;return array index ;)
    $search = _ArraySearch($sarray, $item, 0, 0, 0, 1)
    Return $search ; return index of searching element
EndFunc   ;==>rai

Script is running great but ... when I want to launch program it's starting, ok but when I want to change roles, and start program as user from list it's not starting...
It's like... turn on, only once. 
 
Any Ideas how to repair this ? Idk maybe I'm just dumb or I fucked up something...

Thanks for help!  :D

Edited by UndefinedVar
Link to comment
Share on other sites

Try and narrow it down to see if RunAs is the issue.

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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

My motto is "If at first you don't succeed, try and rebuild!" 

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 parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Solved the issue by setting a different var as the result of reading $domain,

you were reading $domain (the combo field), and set the value as $domain,

then in the next run, it gave an error/returned 0.

$domain2 = GUICtrlRead($domain)
            ConsoleWrite($domain2&@CRLF) ;here we can see the value, this is how i saw it was giving zero.
            If $program <> "" And $domain2 <> "" Then
                RunAs($username, $domain2, $Password, 0, $program, "", @SW_SHOW)
Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

 

Can you please explain this line to me?

$userID = rai($array, $username) ;return array index ;)

 

I need that to return the password for  username picked

watch this...

$array[$i][0] = $read[$i][0] ; Users | Crypted
        $array[$i][1] = Decrypt_to_real($read[$i][0]) ; Users | Decrypted
        $array[$i][2] = $read[$i][1] ; Passwords | Crypted
        $array[$i][3] = Decrypt_to_real($read[$i][1]) ; Passwords | Decrypted

So if you pick the user from list, script will automatically pick needed password... 

I don't really know how to explain that to you... if you don't understand it.

Edited by UndefinedVar
Link to comment
Share on other sites

Ok I will repost my repaired code, just for prove that you pointed a good way to repair that.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Crypt.au3>
#include <Array.au3>
#include <Marquee.au3>
#include "_GUIResourcePic.au3"

#region ### START Koda GUI section ### Form=d:\projekty au3\blockar\2ndgui.kxf
$Form1_1 = GUICreate("Lanucher by Undefined-VaR", 500, 334, 260, 225)
GUISetBkColor(0x000000)
$man_login = GUICtrlCreateInput("", 128, 204, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$man_password = GUICtrlCreateInput("", 128, 232, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT, $ES_PASSWORD))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$man_login_label = GUICtrlCreateLabel("Login:", 62, 202, 64, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$man_password_label = GUICtrlCreateLabel("Password:", 32, 232, 94, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$create_user_login_input = GUICtrlCreateInput("", 128, 204, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$create_user_password_input = GUICtrlCreateInput("", 128, 232, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_LEFT, $ES_PASSWORD))
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$PROGRAMS = GUICtrlCreateGroup("", 268, 14, 211, 121)
GUICtrlSetColor(-1, 0xFF0000)
$programs_list = GUICtrlCreateCombo("", 280, 36, 189, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$lanuch_button = GUICtrlCreateButton("Launch", 280, 100, 75, 25, $BS_CENTER)
$domain = GUICtrlCreateCombo("", 280, 66, 145, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$create_user_login_label = GUICtrlCreateLabel("Login:", 62, 202, 64, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$create_user_password_label = GUICtrlCreateLabel("Password:", 32, 232, 94, 26)
GUICtrlSetFont(-1, 14, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x00FF00)
$Create_button = GUICtrlCreateButton("Create_button", 176, 260, 75, 25)
$self_user_list = GUICtrlCreateCombo("", 104, 172, 145, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Group1 = GUICtrlCreateGroup("", 12, 14, 237, 111)
$own_pass_radio = GUICtrlCreateRadio("Own pass", 22, 30, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
$user_list_radio = GUICtrlCreateRadio("User List", 22, 52, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
$create_user_radio = GUICtrlCreateRadio("Create User", 22, 74, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
$delete_user_radio = GUICtrlCreateRadio("Delete User", 22, 96, 225, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0x808080)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$user_create_comunicate = GUICtrlCreateLabel("", 15, 297, 238, 23)
GUICtrlSetFont(-1, 12, 800, 0, "Consolas")
GUICtrlSetColor(-1, 0x3399FF)
;$Pic1 = GUICtrlCreatePic("", 260, 162, 229, 150)
;_GUICtrlPic_SetImage($Pic1, "yolo.gif")
$user_delete_combo = GUICtrlCreateCombo("", 104, 204, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$user_delete_button = GUICtrlCreateButton("Delete", 176, 230, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

#cs
    Case $use_own_acc_box
    Case $user_create_box
    Case $user_pick_box
#ce
Global $Orun = 0
Global $array[20][4]
Global $debug = 0
;/========================================================
If Not FileExists("config.cfg") Then IniWrite("config.cfg", "Users", "0x9095D4FA2C07525628591BED75E3195F", "0x9095D4FA2C07525628591BED75E3195F")


;======================== PROGRAMS & Domain================================
GUICtrlSetData($programs_list, "CMD")
GUICtrlSetData($domain, "Local|Wena")
;==================================================================

;========================================================================
;###########            HIDE GUI PARTS                        ###########


Sh($man_login)
Sh($man_password)
Sh($man_login_label)
Sh($man_password_label)

Sh($self_user_list)

Sh($create_user_login_input)
Sh($create_user_password_input)
Sh($create_user_login_label)
Sh($create_user_password_label)
Sh($Create_button)
Sh($user_delete_combo)
Sh($user_delete_button)
;========================================================================

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $create_user_radio
            Sh($man_login)
            Sh($man_password)
            Sh($man_login_label)
            Sh($man_password_label)
            Sh($self_user_list)
            Sh($user_delete_combo)
            Sh($user_delete_button)

            Sh($create_user_login_input, "y")
            Sh($create_user_password_input, "y")
            Sh($create_user_login_label, "y")
            Sh($create_user_password_label, "y")
            Sh($Create_button, "y")


        Case $user_list_radio
            load_list()
            $Orun = 1
            Sh($man_login)
            Sh($man_password)
            Sh($man_login_label)
            Sh($man_password_label)
            Sh($self_user_list)
            Sh($user_delete_combo)
            Sh($user_delete_button)

            Sh($create_user_login_input)
            Sh($create_user_password_input)
            Sh($create_user_login_label)
            Sh($create_user_password_label)
            Sh($Create_button)

            Sh($self_user_list, "y")

        Case $own_pass_radio
            $Orun = 2
            Sh($create_user_login_input)
            Sh($create_user_password_input)
            Sh($create_user_login_label)
            Sh($create_user_password_label)
            Sh($Create_button)
            Sh($self_user_list)
            Sh($user_delete_combo)
            Sh($user_delete_button)

            Sh($man_login, "y")
            Sh($man_password, "y")
            Sh($man_login_label, "y")
            Sh($man_password_label, "y")
        Case $delete_user_radio
            load_list($user_delete_combo)
            Sh($create_user_login_input)
            Sh($create_user_password_input)
            Sh($create_user_login_label)
            Sh($create_user_password_label)
            Sh($Create_button)
            Sh($self_user_list)
            Sh($man_login)
            Sh($man_password)
            Sh($man_login_label)
            Sh($man_password_label)

            Sh($user_delete_combo, 'y')
            Sh($user_delete_button, 'y')
        Case $Create_button
            _CreateUser(GUICtrlRead($create_user_login_input), GUICtrlRead($create_user_password_input))
        Case $lanuch_button
            if $Orun = 1 Then
                _poweron(1)
            Else
                _poweron(2)
            EndIf
        Case $user_delete_button
            Delete_user()
    EndSwitch


WEnd

Func Sh($element, $show = '') ; $show = yes/no
    Local $set
    If $show = '' Then $set = $GUI_HIDE
    If $show = 'y' Then $set = $GUI_SHOW

    GUICtrlSetState($element, $set)
EndFunc   ;==>Sh

Func _CreateUser($login, $Password)

    Local $cfg = "config.cfg"
    If $login <> "" And $Password <> "" Then
        ;check is there a place to save a new user
        If IniRead($cfg, "Users", "", "NoData") = "NoData" Or IniRead($cfg, "Users", "", "NoData") = "" Then IniWrite($cfg, "Users", _Crypt($login), _Crypt($Password))
        de_str('Successfully created user!', 0x00FF00)
    Else
        de_str('Noob!', 0xff0000)

    EndIf
EndFunc   ;==>_CreateUser

Func _Crypt($strig)
    Local $password_for_crypt = "0045922@059939@00559$069949$395959$"
    Local $bAlgorithm = $CALG_AES_256

    $done_password = _Crypt_EncryptData($strig, $password_for_crypt, $bAlgorithm)

    Return $done_password

EndFunc   ;==>_Crypt

Func Decrypt_to_real($string)
    Local $password_to_decrypt = "0045922@059939@00559$069949$395959$"
    Local $bAlgorithm = $CALG_AES_256

    $done_password = _Crypt_DecryptData($string, $password_to_decrypt, $bAlgorithm)
    $done_password = BinaryToString($done_password)
    Return $done_password
EndFunc   ;==>Decrypt_to_real

Func load_list($part = '')

    Local $cfg = "config.cfg"

    $read = IniReadSection($cfg, "Users")

    For $i = 0 To $read[0][0]
        $array[$i][0] = $read[$i][0] ; Users | Crypted
        $array[$i][1] = Decrypt_to_real($read[$i][0]) ; Users | Decrypted
        $array[$i][2] = $read[$i][1] ; Passwords | Crypted
        $array[$i][3] = Decrypt_to_real($read[$i][1]) ; Passwords | Decrypted
    Next
    ;
    For $m = 1 To $array[0][0]
        If $part <> '' Then
            If $array[$m][1] <> "made by" Then GUICtrlSetData($part, $array[$m][1])
        Else
            If $array[$m][1] <> "made by" Then GUICtrlSetData($self_user_list, $array[$m][1])
        EndIf
    Next
    ;_ArrayDisplay($array)
EndFunc   ;==>load_list

Func de_str($text, $color = '')

    GUICtrlSetColor($user_create_comunicate, $color)

    For $i = 1 To 3 Step 1
        GUICtrlSetData($user_create_comunicate, $text)
        Sleep(250)
        GUICtrlSetData($user_create_comunicate, "")
        Sleep(250)
        GUICtrlSetData($user_create_comunicate, $text)
        Sleep(250)
        GUICtrlSetData($user_create_comunicate, "")
    Next

EndFunc   ;==>de_str

Func _poweron($var)
    Switch($var)
        case 1
        Local   $username = GUICtrlRead($self_user_list)
        Local   $userID = rai($array, $username) ;return array index ;)
        Local   $Password = $array[$userID][3] ; Password of user with ID returned from name and index
        Local   $program = GUICtrlRead($programs_list)
        Local   $domain = GUICtrlRead($domain)
        RunAs($username, $domain, $Password, 0, $program, "", @SW_SHOW)

        case 2
        Local   $username1 = GUICtrlRead($man_login)
        Local   $Password2 = GUICtrlRead($man_password)
        Local   $program3 = GUICtrlRead($programs_list)
        Local   $domain4 = GUICtrlRead($domain)
        RunAs($username1, $domain4, $Password2, 0, $program3, "", @SW_SHOW)
        case Else
            MsgBox(0, "", "ERROR")
    EndSwitch


EndFunc   ;==>_poweron

Func Delete_user()
    $user = GUICtrlRead($user_delete_combo)

    If $user <> "" Then
        $key = _ArraySearch($array, $user, 0, 0, 0, 1)
        $del = $array[$key][0]
        MsgBox(0, "", $del & "key: " & $key)
        IniDelete("config.cfg", "Users", $del)
        Dfa($array, $array[$key][0], $array[$key][1], $array[$key][2], $array[$key][3])
        GUICtrlSetData($user_delete_combo, "")
        load_list($user_delete_combo)
    EndIf
EndFunc   ;==>Delete_user

Func Dfa($sarray, $element1, $element2, $element3, $element4)

    _ArrayDelete($sarray, $element1)
    _ArrayDelete($sarray, $element2)
    _ArrayDelete($sarray, $element3)
    _ArrayDelete($sarray, $element4)
EndFunc   ;==>Dfa

Func rai($sarray, $item) ;return array index ;)
    $search = _ArraySearch($sarray, $item, 0, 0, 0, 1)
    Return $search ; return index of searching element
EndFunc   ;==>rai
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...