trumso02 Posted April 22, 2016 Share Posted April 22, 2016 I write a sample code below for my work, this is original version before compile, I am kind a noob about AutoIT and I wonder if I can set up password for my script so when I type in the correct password the script start working. Can anyone help me with this, please? I am appreciated for any help! Combine Auto.au3 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 22, 2016 Moderators Share Posted April 22, 2016 (edited) @trumso02 welcome to the forum. There are a couple of ways you can do this, as long as you keep in mind that you are never going to keep a determined person out of your script. If it is for your own personal comfort, you could do one of the following: Simple: Add an InputBox with blocked out characters. If the password doesn't match, exit: #include <MsgBoxConstants.au3> $sPass = InputBox("My Script", "Enter Master Password", "", "@") If $sPass <> "My Name is Bobby" Then Exit(MsgBox($MB_OK, "My Script", "You blew it!")) A little more complex, add a command-line parameter that you have to call the executable with in order for it to work (compiled scripts only): #include <MsgBoxConstants.au3> If Not StringInStr($cmdlineRaw, "/My Name is Bobby") Then Exit(MsgBox($MB_OK, "My Script", "You blew it!")) MsgBox($MB_OK, "", "Test") I am sure others will have more suggestions for you. Edited April 22, 2016 by JLogan3o13 trumso02 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
trumso02 Posted April 22, 2016 Author Share Posted April 22, 2016 Lovely, thank you so much for the help, I been looking for this. Link to comment Share on other sites More sharing options...
trumso02 Posted April 22, 2016 Author Share Posted April 22, 2016 Also, how can I make the script run only on the machines with the list of specific ip address? Like example: Only machine with these ip address can run script 192.168.100.1 192.168.100.2 192.168.100.3 192.168.100.5 and this ip 192.168.100.4 not allow to run the script. Thank you! Link to comment Share on other sites More sharing options...
alien4u Posted April 22, 2016 Share Posted April 22, 2016 Look at _GetIP() on help file and base on Result do your needed check. Regards Alien. trumso02 1 Link to comment Share on other sites More sharing options...
RTFC Posted April 23, 2016 Share Posted April 23, 2016 Check out my CodeCrypter (link in my sig), it supports user password (key ID 1) plus additional concurrent environment checks (use the multiple encryption keys option, user-defined in MCFinclude.au3, in array $CCkey). Allowing a subset of IPs will probably require you to write a little lookup function (producing versions that each validate a single IP directly would be more secure though). trumso02 1 My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
Trong Posted April 23, 2016 Share Posted April 23, 2016 (edited) Try this: Bạn này làm điện thoại đây Bạn cho mấy dòng này ở trên đầu kịch bản nhé: (đổi mật khẩu và IP theo ý bạn), IP phân cách bởi dấu | Global $ListIP = "192.168.1.168|192.168.1.200|192.168.1.2" ;Bat buoc phai co dau | hay them tu 2 IP tro len Global $MatKhau = "khongdangchokhach" Local $aArray = StringSplit($ListIP, "|") If IsArray($aArray) Then For $X = 1 To UBound($aArray) - 1 If $aArray[$X] = @IPAddress1 Then $sPass = InputBox("Dr.Tung", "Nhap mat khau", "", "$") If $sPass <> $MatKhau Then Exit (MsgBox(48, "Loi cmn roi!", "Sai Mat Khau roi baby!", 5)) ExitLoop EndIf Next Else ;~ $sPass = InputBox("Dr.Tung", "Nhap mat khau", "", "$") ;~ If $sPass <> $MatKhau Then Exit (MsgBox(48, "Loi cmn roi!", "Sai Mat Khau roi baby!", 5)) Exit EndIf Edited April 23, 2016 by VIP Regards, Link to comment Share on other sites More sharing options...
trumso02 Posted May 2, 2016 Author Share Posted May 2, 2016 Thank VIP for enlightenment me with the ip lock, however, for some reason, while I try to add your code into my scripts, the pc with ip that not including in my scripts can run my scrips at easy, but those pc with the ip including has to type in password. This is opposite with how I want. Is there anyway I can fix to make my script run only on those pc that has IPs address including in my scrips? Here is my scrips General.au3 Link to comment Share on other sites More sharing options...
alien4u Posted May 2, 2016 Share Posted May 2, 2016 1 hour ago, trumso02 said: Thank VIP for enlightenment me with the ip lock, however, for some reason, while I try to add your code into my scripts, the pc with ip that not including in my scripts can run my scrips at easy, but those pc with the ip including has to type in password. This is opposite with how I want. Is there anyway I can fix to make my script run only on those pc that has IPs address including in my scrips? Here is my scrips General.au3 Just add a simple Else to @VIP code and should work like you wish, something like this: Global $ListIP = "192.168.1.168|192.168.1.200|192.168.1.2" ;Bat buoc phai co dau | hay them tu 2 IP tro len Global $MatKhau = "khongdangchokhach" Local $aArray = StringSplit($ListIP, "|") If IsArray($aArray) Then For $X = 1 To UBound($aArray) - 1 If $aArray[$X] = @IPAddress1 Then $sPass = InputBox("Dr.Tung", "Nhap mat khau", "", "$") If $sPass <> $MatKhau Then Exit (MsgBox(48, "Loi cmn roi!", "Sai Mat Khau roi baby!", 5)) ExitLoop Else ; Added Else that if the IP is not on the list Exit Exit ; Exit Code EndIf Next Else ;~ $sPass = InputBox("Dr.Tung", "Nhap mat khau", "", "$") ;~ If $sPass <> $MatKhau Then Exit (MsgBox(48, "Loi cmn roi!", "Sai Mat Khau roi baby!", 5)) Exit EndIf Regards Alien. trumso02 1 Link to comment Share on other sites More sharing options...
Trong Posted May 2, 2016 Share Posted May 2, 2016 (edited) Put it on the top of your script! expandcollapse popup; Neu dung nhieu IP thi phan cach nhau boi dau | vd: "192.168.1.168|192.168.1.200|192.168.1.2" Global $ListIP = "192.168.1.168" ; De trong de khong kiem tra IP! Global $MatKhau = "dungchiase" Global $SoLanNhapSaiMK = 3 Local $OKbaby = False If StringStripWS($ListIP, 8) <> "" Then If StringInStr($ListIP, "|") Then Local $aArray = StringSplit($ListIP, "|") If IsArray($aArray) Then For $X = 1 To UBound($aArray) - 1 If $aArray[$X] = @IPAddress1 Then $OKbaby = True ExitLoop EndIf Next EndIf Else If $ListIP = @IPAddress1 Then $OKbaby = True EndIf Else $OKbaby = True EndIf If $OKbaby Then Local $NhapLai = 0 While 1 $NhapLai += 1 $sPass = InputBox("Dr.Tung", "Vui long nhap Mat Khau de su dung: ", "", "$", 300, 130) If @error Then Exit If $sPass <> $MatKhau Then If $NhapLai = $SoLanNhapSaiMK Then Exit (MsgBox(48, "Dr.Tung", "Ban da nhap sai mat khau qua so lan cho phep!", 5)) MsgBox(48, "Dr.Tung", "Ban da nhap sai mat khau roi." & @CRLF & "Vui long nhap lai!", 10) Else ExitLoop EndIf WEnd Else Exit (MsgBox(48, "Dr.Tung", "Phien ban nay khong danh cho may tinh nay!" & @CRLF & "Vui long lien he Dr.Tung de duoc ho tro!", 10)) EndIf Edited May 2, 2016 by VIP skip check ip if empty! Regards, Link to comment Share on other sites More sharing options...
trumso02 Posted May 4, 2016 Author Share Posted May 4, 2016 (edited) Thank you very much VIP, anyway, If I want to lock IP address only, or make the script available for only 5 minutes (for demo purpose only) how can I do that? Edited May 4, 2016 by trumso02 Link to comment Share on other sites More sharing options...
rudi Posted May 6, 2016 Share Posted May 6, 2016 Hi. Putting the Master Password "clear text" into your script is IMHO definitely not a good idea. So generate a HASH code of your password, and put that one in your script, then check the user input's hash against the hash stored "inside" your script. #include <Crypt.au3> #Region PasswdCheck $PWD = "" $PW_hash = "0x83CA415FC4A7FCE3163736F7BB472D7753070832" Do $PWD = InputBox("Special Access", "Your password, please", "", "*") Until $PWD <> "" _Crypt_Startup() $Hash_Input = _Crypt_HashData($PWD, $CALG_SHA1) If $Hash_Input <> $PW_hash Then MsgBox(64, "Wrong Password", "The password you specified is not valid!", 10) Exit EndIf _Crypt_Shutdown() #EndRegion PasswdCheck Note: Have a look to the constants block inside CRYPT.AU3, there you have even more choices you can use by uncommenting e.g. ; Global Const $CALG_SHA_256 = 0x0000800c regards, Rudi. trumso02 1 Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now