Hi,
danke für dein Feedback ytwinky. Ich werde mir deine Anmerkungen mal ansehen, wenn ich Zeit finde.
Endlich mal jemand der wirklich testet und konstruktive Hinweise gibt!
Kudos!
So long,
Mega
Hi,
danke für dein Feedback ytwinky. Ich werde mir deine Anmerkungen mal ansehen, wenn ich Zeit finde.
Endlich mal jemand der wirklich testet und konstruktive Hinweise gibt!
Kudos!
So long,
Mega
HI,
zwei Kommentare, aber 0 Downloads.
Copy&Pase Freunde, hmmh?
So long,
Mega
Hi,
außedem ist eine Fehler in gtaspider's Code.
MsgBox(4+48, "OFFLINE" & @CRLF & @CRLF & "Möchten Sie die Einstellungen überprüfen?")
Allein diese MsgBox wird nicht funktionieren.
So long,
Mega
Hi,
ich habe eine Funktion geschrieben, die eine Ausführung der Skript.exe auf bestimmte Kriterien beschränkt. Dies bewirkt, dass eine aktivierte Skript.exe nach einer Kopie nicht auf anderen PCs / etc. ausgeführt werden kann.
Die UDF (user defined function) schreibt bei der Aktivierung einen generierten verschlüsselten Code in die Registry. Anschließend wird
dieser Code im Skript entschlüsselt und überprüft. Bei keiner Übereinstimmung wird das Skript beendet.
#include <String.au3>
; Added the option to specify whether it runs only on this windows, or this harddrive.
If _runOnlyOnThis("", "", -1, "test", 1) <> 1 Then Exit (0)
; Put your script code below here
[/autoit] [autoit][/autoit] [autoit]MsgBox(64, "Secured Program", "Yeah, the secured main-program started!" & _
@CRLF & @CRLF & "Thanks & and have fun!" & @CRLF & @CRLF & "Mega")
;===============================================================================
;
; Function Name: _runOnlyOnThis ...
; Description: Activation by parameter sets a unique registry key
; After a successful activation, checks for the regkey
; If correct go on, else Exit(0)
;
; Parameter(s): (Script) First time, the activation key
; (Func) $s_KeyName = RegKeyName
; $s_EncryptPassword = Encryption passphrase
; $i_EncryptLevel = Level (quantity)
; $s_ActivationKey = key which starts the func
; $i_Option (default =1)
;
; _runOnlyOnThis ... $i_Option
; 1 = Windows installtion (Date)
; 2 = HardDrive
;
; Return Value(s): On Success - Returns 1
; On Failure - Returns -1 RegWrite Problem,
; Returns -2 Not activated,
; Returns -3 Wrong registry key
; Returns -4 Couldn't DriveGetSerial
;
; Note(s): Basically useful to prevent user starting the script on
; non activated PCs
; String.au3 has to be included
;
; Author(s): Thorsten Meger
;
;===============================================================================
Func _runOnlyOnThis($s_KeyName, $s_EncryptPassword, $i_EncryptLevel, $s_ActivationKey, $i_option = 1)
If $s_KeyName = "" Then $s_KeyName = "Version"
If $s_EncryptPassword = "" Then $s_EncryptPassword = "thisPc"
If $i_EncryptLevel = -1 Then $i_EncryptLevel = 2
If $s_ActivationKey = "" Then $s_ActivationKey = "activate"
If $i_option <> 1 Or $i_option <> 2 Then $i_option = 1
If $i_option = 1 Then
Local $stringToCrypt = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "InstallDate")
ElseIf $i_option = 2 Then
Local $stringToCrypt = DriveGetSerial(StringLeft(@SystemDir, 3))
If @error = 1 Then Return -4
EndIf
Local $crypted = _StringEncrypt(1, $stringToCrypt, $s_EncryptPassword, $i_EncryptLevel)
If $cmdLine[0] > 0 And $cmdLine[1] = $s_ActivationKey Then
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\" & StringLeft(@ScriptName, StringLen(@ScriptName) - 4), $s_KeyName, "REG_SZ", _
StringTrimLeft($crypted, 4))
Return -1
ElseIf RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\" & StringLeft(@ScriptName, StringLen(@ScriptName) - 4), $s_KeyName) = "" Then
MsgBox(64, "Error", "You are not allowed to run this program!", 5)
Return -2
ElseIf RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\" & StringLeft(@ScriptName, StringLen(@ScriptName) - 4), $s_KeyName) <> _
(StringTrimLeft($crypted, 4)) Then
MsgBox(64, "Error", "You are not allowed to run this program on this computer!", 5)
Return -3
EndIf
Return 1
EndFunc ;==>_runOnlyOnThis
Aktivierungsskript:
_activateScript("RunOnlyOnThisPc.exe", "test")
[/autoit] [autoit][/autoit] [autoit];===============================================================================
;
; Function Name: _activateScript
; Description: Activates the script which is protected by _runOnlyOnThisPC
;
; Parameter(s): $s_programName = name (script.exe)
; $s_ActivationKey = key which starts the func
;
; Return Value(s): Non
;
; Note(s): Basically useful to start(activate) the _runOnlyOnThisPC
; protected script
; Should be on own script.exe in the same folder!
;
; Author(s): Thorsten Meger
;
;===============================================================================
Func _activateScript($s_programName, $s_ActivationKey)
Run(@ScriptDir & "\" & $s_programName & " " & $s_ActivationKey)
Local $cmdfile
FileDelete(@TempDir & "\scratch.cmd")
$cmdfile = ':loop' & @CRLF _
& 'del "' & @ScriptFullPath & '"' & @CRLF _
& 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
& 'del ' & @TempDir & '\scratch.cmd'
FileWrite(@TempDir & "\scratch.cmd", $cmdfile)
Run(@TempDir & "\scratch.cmd", @TempDir, @SW_HIDE)
EndFunc;==>_activateScript
Mit der Bitte um Feedback...
So long,
Mega
bernd670: Hab mal die PHP-Tags durch AutoIt-Tags ersetzt.
Hi,
kein Problem. Deshalb ist es ja ein Forum (Open) damit man davon provitieren kann.
So long,
Mega
Hi,
entweder 1024 * 768 TFT am Laptop 15,4" oder 1600 * 1200 am TFT - NEC 20,1"
So long,
Mega
Eine Frau mit Männer-Hobbys.
Hi,
für mich zur Spielerei, für Loginskripte, sowie Automatisierung von Standard-Prozessen.
So long,
Mega
England im Finale. Ich lach mich tot.
Die können froh sein, wenn sie unter die letzten 8 kommen.
Naja, träumen ist erlaubt.
So long,
Mega
Hi,
in Münster.
So long,
Mega
Hi,
weißt du was das Beste daran ist? Ich arbeite in NRW komme aber aus Niedersachsen. Do. ist Feiertag in NRW.
--> Ich kann erst mit 20.000 Leuten Fußball gucken, dann ne Mörderparty genießen, ausschlafen und meine Kumpels auf dem Heimweg mit nem schönen Wegruf in den Tag entlassen. :party3:
Ahhhhh,
So long,
Mega
Hi,
der Kühlschrank ist ja niedlich. Der reicht ja nicht mal mal für die erste Halbzeit.
*muhahahaha*
So long,
Mega
HI,
klar. Ich habe das Script ja nicht umsonst bei Sourceforge.net eingestellt. Wenn mir jemand einen Schub in Sachen Autoit-Programmierung geben kann, dann bin ich gern bereit diesen anzunehmen.
Porblem ist im Moment habe ich relativ wenig Zeit, weil ich a viel arbeiten muss und b begeisteter WM-Gucker bin.
Aber für sowas nehme ich mir einfach Zeit.
So long,
Mega
P.S.: Ich denke WAN wäre richtig cooool
Hi,
hast du das Script auch getestet? Weil du den gleichen Post bei beiden Scripten von mir geschrieben hast.
Trotzdem DANK!
So long,
Mega
Hi,
super danke! Das liegt einfach daran, dass ich mich bis vor 14 Tagen noch nie mit dem switch Konstrukt beschäftigt habe.
Ich wußte es einfach nicht besser. Aber ich werde es in Zuknuft besser machen versprochen.
So long,
Mega (ytwinky-Schüler)
HI,
ich bin mir sicher, der Computer macht alles so, wie man es ihn sagt, nur die Syntax des scripts stimmt wahrscheinlich nicht 100 %ig.
Na ja, weitermachen ...
So long,
Mega
Hi,
ich habe einen LoginWrapper geschrieben, der dazu dienen soll exe Dateien vor der Ausführung zu schützen. Es muss eine Authentifizierung durch Benutzername & Passwort erfolgen.
Vielleicht kann dies der eine oder andere ja gebrauchen.
Falls gewünscht, würde ich die Erklärung auch ins Deutsche übersetzen.
So long,
Mega
Scriptvorschau:
;
; AutoIt Version: 3.1.1 beta
; Author: Thorsten Meger
;
; Script Function: LoginWrapper / Security Check
;
; The script allows you to protect your script from starting by unauthenticated users.
; This scrips wrapps your script. After authenticated successfully, it "installs" your script hidden
; at the given location and starts it.
; If the "main-script" is closed, this script deletes the your Script.exe
; Wrapper.exe contains (your script)
; ------------------------------------------------------------------------------------------------------
; The script creates an (system/hidden) ini-File in the script-folder.
; The login.ini contains the encrypted usernames & passwords
; To add users who can authenticate successfully, start the script with the para defined
; in $createNewUser default(newuser)
; The login.ini contains one adminUser(InitialUser & InitialPassword)
; Change Initial - user & password to your needs
; ------------------------------------------------------------------------------------------------------
; **** Change this to your script.exe ******************************************************
[/autoit] [autoit][/autoit] [autoit]Dim $yourScriptExe = 'c:\MsgBox.exe'; your script.exe (I recommend c:\)
Dim $InitialUser = 'xxx' ; change this to your "admin" user
Dim $InitialPassword = 'xxx' ; change this to your "admin" password
Dim $iniPath = @WindowsDir & '\'; where to save the ini files
Dim $nameOfIni = 'login.ini' ; Login.ini should be renamed to the name of the wrapped mainScript. That will allow multiple wrapping
Dim $createNewUser = 'newuser' ; change this to secure creating new users (first parameter) e.g. : LoginWrapper.exe newuser
Dim $Sound = 1; Sound On/Off, 1 = On, 0 = Off
; FileInstall doesn't work with variables, so you have to type fullPath as a string!!!
; Example : FileInstall('c:\yourPath\yourScriptExe.exe', 'c:\yourScriptExe.exe', 1) ; 2nd para must be the same as in $yourScriptExe!
Func _FileInstall()
FileInstall('c:\Downloads\AutoIt-Skripte\Entwicklung\Wrapper\MsgBox.exe', 'c:\MsgBox.exe', 1) ; first ;!!!Change here!!!
FileSetAttrib($yourScriptExe, "+SH")
Sleep(20)
Run($yourScriptExe)
If @error = 1 Then MsgBox(0, "Error", "Couldn't find the main script!", 4)
check()
EndFunc ;==>_FileInstall
; ******************************************************************************************
#include <GUIConstants.au3>
#include <String.au3>
#include <File.au3>
Opt("RunErrorsFatal", 0)
; The GUI
$GUI = GUICreate("Security Check", 318, 223, 192, 125)
; Group
$main_G = GUICtrlCreateGroup("Credentials", 8, 56, 297, 153)
; Label
$username_L = GUICtrlCreateLabel("Username : ", 16, 80, 131, 17, $SS_SUNKEN)
$password_L = GUICtrlCreateLabel("Password : ", 16, 112, 131, 17, $SS_SUNKEN)
$status_L = GUICtrlCreateLabel("Status", 16, 176, 267, 17, $SS_SUNKEN)
$headline_L = GUICtrlCreateLabel("Login", 8, 18, 299, 33)
; Input
$username_I = GUICtrlCreateInput("", 160, 76, 121, 21, -1, $WS_EX_CLIENTEDGE)
$password_I = GUICtrlCreateInput("", 160, 110, 121, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
; Button
$button_B = GUICtrlCreateButton("Login", 16, 136, 131, 25, $BS_DEFPUSHBUTTON)
; CheckBox
$changePassword_C = GUICtrlCreateCheckbox("Change Password", 160, 136, 113, 25)
GUICtrlSetFont($headline_L, 18, -1, -1, "Arial")
GUICtrlSetColor($headline_L, "0xff0000")
; TrayTip
TrayTip("Security Check", "Please, authenticate with user & password", 2, 1)
GUISetState(@SW_SHOW)
;Variables
Dim $guiStatus = 0
Dim $exists = False
Dim $changeActivated = False
Dim $acceptedUser = ''
Dim $sectionArray = ''
; create Obj for speech
Dim $voice = ObjCreate("Sapi.SpVoice")
; You can change the elements which are used for encryption here
Dim $cryptArray = StringSplit("2we4rf,adfi8,i9lp,we2ay,9o0pw,asdc4,1209i,tz573,98m3,6tg5", ",")
Start()
[/autoit] [autoit][/autoit] [autoit]; Check at start, whether the ini file is there. If not create it with the initial credentials
Func Start()
;Check for password file
If Not FileExists($iniPath & $nameOfIni) Then
_FileCreate($iniPath & $nameOfIni)
Local $cryptWord = Random(0, 9, 1)
IniWrite($iniPath & $nameOfIni, '1', _StringEncrypt(1, $InitialUser, 'key', 2), _StringEncrypt(1, $InitialPassword, $cryptArray[$cryptWord], 2) & $cryptWord)
FileSetAttrib($iniPath & $nameOfIni, "+SH")
EndIf
EndFunc ;==>Start
; Changing GUI whether you want to login or create new users
If $cmdLine[0] > 0 Then
If $cmdLine[1] = $createNewUser Then
$guiStatus = 1
GUICtrlSetData($button_B, "Save")
GUICtrlSetData($headline_L, "New User")
GUICtrlSetData($status_L, "Ready ...")
GUICtrlSetState($changePassword_C, $GUI_HIDE)
EndIf
EndIf
; Func create new user
Func createNewUser()
Local $exists = False
$sectionArray = IniReadSection($iniPath & $nameOfIni, '1')
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $sectionArray[0][0]
If _StringEncrypt(0, $sectionArray[$i][0], 'key', 2) = GUICtrlRead($username_I) Then
GUICtrlSetData($status_L, "User already exists!")
If $Sound = 1 Then Speak("User already exists!")
$exists = True
Sleep(500)
GUICtrlSetData($status_L, "Ready...")
ExitLoop
EndIf
Next
If $exists = False Then
Local $cryptWord = Random(0, 9, 1)
IniWrite($iniPath & $nameOfIni, '1', _StringEncrypt(1, GUICtrlRead($username_I), 'key', 2), _StringEncrypt(1, GUICtrlRead($password_I), $cryptArray[$cryptWord], 2) & $cryptWord)
GUICtrlSetData($status_L, "New User created!")
If $Sound = 1 Then Speak("New User created!")
Sleep(500)
GUICtrlSetData($status_L, "Ready...")
EndIf
EndIf
EndFunc ;==>createNewUser
; check user and password
Func verifyUserAndPassword()
$exists = False
GUICtrlSetData($status_L, "Verifying User")
$sectionArray = IniReadSection($iniPath & $nameOfIni, '1')
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $sectionArray[0][0]
Local $user = _StringEncrypt(0, $sectionArray[$i][0], 'key', 2)
If $user = GUICtrlRead($username_I) Then
Local $cryptNr = StringRight($sectionArray[$i][1], 1)
Local $value = StringLeft($sectionArray[$i][1], StringLen($sectionArray[$i][1]) - 1)
If _StringEncrypt(0, $value, $cryptArray[$cryptNr], 2) = GUICtrlRead($password_I) Then
GUICtrlSetData($status_L, "Login accepted! Welcome! " & $user)
If $Sound = 1 Then Speak("Login accepted! Welcome! " & $user)
$exists = True
$acceptedUser = GUICtrlRead($username_I)
If Not BitAND(GUICtrlRead($changePassword_C), $GUI_CHECKED) Then
_FileInstall()
EndIf
EndIf
EndIf
Next
EndIf
If $exists = False Then
Sleep(200)
GUICtrlSetData($status_L, "Access denied!")
If $Sound = 1 Then Speak("Access denied!", 2, 100)
Sleep(500)
GUICtrlSetData($status_L, "Ready...")
EndIf
EndFunc ;==>verifyUserAndPassword
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $button_B
If (StringLen(GUICtrlRead($username_I)) < 3 Or StringLen(GUICtrlRead($password_I)) < 3) And $exists = False Then
GUICtrlSetData($status_L, "Minimum 3 letters")
If $Sound = 1 Then Speak("Minimum 3 letters")
Else
If $guiStatus = 0 And Not BitAND(GUICtrlRead($changePassword_C), $GUI_DISABLE) And $changeActivated = False Then
verifyUserAndPassword()
ElseIf $guiStatus = 1 And Not BitAND(GUICtrlRead($changePassword_C), $GUI_DISABLE) And $changeActivated = False Then
createNewUser()
EndIf
If $changeActivated = True Then
If GUICtrlRead($username_I) = GUICtrlRead($password_I) Then
For $i = 1 To $sectionArray[0][0]
If _StringEncrypt(0, $sectionArray[$i][0], 'key', 2) = $acceptedUser Then
Local $cryptWord = Random(0, 9, 1)
IniWrite($iniPath & $nameOfIni, '1', _StringEncrypt(1, $acceptedUser, 'key', 2), _StringEncrypt(1, GUICtrlRead($username_I), $cryptArray[$cryptWord], 2) & $cryptWord)
ExitLoop
EndIf
Next
If (StringLen(GUICtrlRead($username_I)) < 3 Or StringLen(GUICtrlRead($password_I)) < 3) Then
GUICtrlSetData($status_L, "Minimum 3 letters")
If $Sound = 1 Then Speak("Minimum 3 letters")
Else
GUICtrlSetData($status_L, "New password saved!")
If $Sound = 1 Then Speak("New password saved!")
Sleep(500)
GUICtrlSetData($status_L, "Program closes in 1 sec")
If $Sound = 1 Then Speak("Security Check closes ...")
Sleep(200)
check()
EndIf
Else
GUICtrlSetData($status_L, "New passwords dont't match!")
GUICtrlSetData($username_I, "")
GUICtrlSetData($password_I, "")
If $Sound = 1 Then Speak("New passwords dont't match!")
EndIf
EndIf
If BitAND(GUICtrlRead($changePassword_C), $GUI_CHECKED) And Not BitAND(GUICtrlRead($changePassword_C), $GUI_DISABLE) And $changeActivated = False Then
changePassword()
EndIf
EndIf
EndSelect
WEnd
; Preparing GUI for checking password
Func changePassword()
If $exists = True Then
$changeActivated = True
GUICtrlSetState($changePassword_C, $GUI_DISABLE)
_GuiCtrlEditChangePasswordChar($username_I)
_GuiCtrlEditChangePasswordChar($password_I)
GUICtrlSetData($status_L, "Please, enter new password")
GUICtrlSetData($username_L, "New password")
GUICtrlSetData($password_L, "Reenter password")
GUICtrlSetData($username_I, "")
GUICtrlSetData($password_I, "")
GUICtrlSetData($button_B, "Save new password")
GUICtrlSetState($username_I, $Gui_FOCUS)
Else
GUICtrlSetData($status_L, "Please, authenticate first!")
If $Sound = 1 Then Speak("Please, authorize first!")
EndIf
EndFunc ;==>changePassword
; Speak func
Func Speak($Text, $Rate = 2, $Vol = 100)
$voice.Rate = $Rate
$voice.Volume = $Vol
$voice.Speak ($Text)
EndFunc ;==>Speak
Func OnAutoItExit()
FileDelete($yourScriptExe)
EndFunc ;==>OnAutoItExit
Func check()
#NoTrayIcon
GUISetState(@SW_HIDE)
Dim $exe = StringSplit($yourScriptExe, "\")
Sleep(200) ; Sleep, before LoginWrapper starts to check whether the wrapped exe is running
While 1
If ProcessExists($exe[$exe[0]]) = 0 Then
FileDelete($yourScriptExe)
Exit (0)
EndIf
Sleep(2000)
WEnd
EndFunc ;==>check
; Func to set the username (which is clear) to mask the typed signs
Func _GuiCtrlEditChangePasswordChar(ByRef $h_edit, $s_newchar = '#')
Local Const $EM_SETPASSWORDCHAR = 0xCC
GUISetState(@SW_LOCK)
If StringInStr(@OSVersion, "WIN_XP") And @NumParams = 1 Then
Local $s_text = GUICtrlRead($h_edit)
Local $pos = ControlGetPos(WinGetTitle(""), "", $h_edit)
GUICtrlDelete($h_edit)
$h_edit = GUICtrlCreateInput($s_text, $pos[0], $pos[1], $pos[2], $pos[3], $ES_PASSWORD, $WS_EX_CLIENTEDGE)
Else
GUICtrlSetStyle($h_edit, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
GUICtrlSendMsg($h_edit, $EM_SETPASSWORDCHAR, Asc($s_newchar), 0)
EndIf
GUISetState(@SW_UNLOCK)
EndFunc ;==>_GuiCtrlEditChangePasswordChar
HI,
alles klar. Dann überleg' mal fleißig. :lol:
Den Tipp mit "Neues Spiel" werde ich in der nächsten Version beherzigen.
So long,
Mega