Jump to content

password protection


Recommended Posts

ok hi

im sure this has been asked b4 but i went through three search pages looking for this but too no avail

i have this script:

#include <GuiConstants.au3>
; GUI
$passwd = InputBox("Security Check", "Enter your password.", "", "*")
if $passwd = "qwerty" Then 
    MsgBox (0,"","Greatings") 
Else 
    Exit
EndIf   

GuiCreate("Wireless Policy Deleter", 225, 50)
$Button_1 = GUICtrlCreateButton ("Delete the Wireless Policy", 0, 0, 225)

$password = "qwerty"

; MENU 
GuiCtrlCreateMenu("File")
GUISetState () 

Do
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case $msg = $Button_1
RegDelete ("HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Wireless"); Delte Reg
EndSelect

; GUI MESSAGE LOOP
GuiSetState()
Until GuiGetMsg() = $GUI_EVENT_CLOSE

wat i want is it to retrive the password from a seperate file or if possible from a online source but seperate file seems liek it would work well

p.s i give credits to the creator of the above script it is not mine if it was yours please tell me and i will put credits in

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

You could use an INI file to save it in.

$Ini = @ScriptDir & "\PW.ini"
$passwd = InputBox("Security Check", "Enter your password.", "", "*")
if $passwd = INIRead($Ini, "Security", "Password, "No Set") Then 
   If $passwd = "Not Set" Then Exit 
   MsgBox (0,"","Greatings") 
Else 
    Exit
EndIf

Edit: Syntax Error

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You could use an INI file to save it in.

$Ini = @ScriptDir & "\PW.ini"
$passwd = InputBox("Security Check", "Enter your password.", "", "*")
if $passwd = INIRead($Ini, "Security", "Password, "No Set") Then 
   If $passwd = "Not Set" Then Exit 
   MsgBox (0,"","Greatings") 
Else 
    Exit
EndIf

Edit: Syntax Error

ok i was thinking along the lines of and ini file but im new to ini files could u or someone please take me through step by step

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

ok i was thinking along the lines of and ini file but im new to ini files could u or someone please take me through step by step

cheers C.W

At some point you have to write the INI file either using a script or manually creating it. It's really a simple text file that follows a given format. I've already given you the code to read an INI entry so Here is the breakdown

$Ini is the file name of the INI file

[security] is the section name and appears as I show it here.

password is the key name and will appear as

password=

In this case I made the default value to be "not set" so if that was actually written to the Ini file then the line as shown above would read

password=not set

If the key does not exist then it will use the default value. That's why I added the Line

If $passwd = "Not Set" Then Exit

There is good information in the help file about the standard INI file structure. You will also find how to write to the ini file in there.

Once you feel comfortable with the ini file (read as "after reading the help file") I can show you a quick and easy method to force the user to enter a password the first time. That's a simple variation on what I already gave you.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

At some point you have to write the INI file either using a script or manually creating it. It's really a simple text file that follows a given format. I've already given you the code to read an INI entry so Here is the breakdown

$Ini is the file name of the INI file

[security] is the section name and appears as I show it here.

password is the key name and will appear as

password=

In this case I made the default value to be "not set" so if that was actually written to the Ini file then the line as shown above would read

password=not set

If the key does not exist then it will use the default value. That's why I added the Line

If $passwd = "Not Set" Then Exit

There is good information in the help file about the standard INI file structure. You will also find how to write to the ini file in there.

Once you feel comfortable with the ini file (read as "after reading the help file") I can show you a quick and easy method to force the user to enter a password the first time. That's a simple variation on what I already gave you.

ok i would would create a file called PW.ini

then in ti would be

[security]

password=watever

and then i click save as PW.ini

and put it in the same directory as the program u wrote above?

am i correct

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

ok i would would create a file called PW.ini

then in ti would be

[security]

password=watever

and then i click save as PW.ini

and put it in the same directory as the program u wrote above?

am i correct

cheers C.W

Yes. But have you read the INI functions in the help file??? Because there is a slightly better method and that method involves NOT creating the file.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Yes. But have you read the INI functions in the help file??? Because there is a slightly better method and that method involves NOT creating the file.

yep m8 thnx

i just read the help file but i did nto find anything about not needing a ini file if im correct my method that i first posted in code did not need a file of any kind is that what u mean?

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

yep m8 thnx

i just read the help file but i did nto find anything about not needing a ini file if im correct my method that i first posted in code did not need a file of any kind is that what u mean?

cheers C.W

No. Here is what you want to do

Global $Ini = @ScriptDir & "\PW.ini"
If Not FileExists($Ini) Then
   _SetPass(1)
Else
   $passwd = InputBox("Security Check", "Enter your password.", "", "*")
   if $passwd = INIRead($Ini, "Security", "Password", "") Then 
      If $passwd = "" Then Exit
      MsgBox (0,"","Greetings") 
   Else 
      Exit
   EndIf
EndIf

Func _SetPass($atmpt)
    If $atmpt = 3 Then Exit;;; Change this to set how many attempts are allowed.
    $iPass = InputBox("Security Check", "Enter your password.", "", "*")
    If StringLen($iPass) <4 Then
      MsgBox(4096, "Error", "Your password must be at least 4 characters")
      _SetPass($atmpt)
    EndIf
    $cPass = InputBox("Security Check", "Re-enter your password.", "", "*")

    If $iPass <> $cPass Then
       $atmpt += 1
       _SetPass($atmpt)
   Else
      IniWrite($Ini, , "Security", "Password", $cPass)
   EndIf
EndFunc

When you first run the script the file will not exist (if you created one then delete it) so It jumps to The _SetPass() function and allows them 3 attempts at setting a proper password. If they fail the script will exit otherwise the INI is created with the proper password. I didn't test this but I think I have it right.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Here is one that does the same thing without the extra function

If Not FileExists($Ini) Then
   For $I = 1 to 4
      If $I = 4 Then Exit
      $iPass = InputBox("Security Check", "Enter your password.", "", "*")
      If StringLen($iPass) <4 Then
         MsgBox(4096, "Error", "Your password must be at least 4 characters")
         ContinueLoop
      EndIf
      $cPass = InputBox("Security Check", "Re-enter your password.", "", "*")
      If $iPass <> $cPass Then
         ContinueLoop
      Else
         IniWrite($Ini, , "Security", "Password", $cPass)
         ExitLoop
   Next
Else
   $passwd = InputBox("Security Check", "Enter your password.", "", "*")
   if $passwd = INIRead($Ini, "Security", "Password", "") Then 
      If $passwd = "" Then Exit
      MsgBox (0,"","Greetings") 
   Else 
      Exit
   EndIf
EndIf
Again untested but should be right Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Here is one that does the same thing without the extra function

If Not FileExists($Ini) Then
   For $I = 1 to 4
      If $I = 4 Then Exit
      $iPass = InputBox("Security Check", "Enter your password.", "", "*")
      If StringLen($iPass) <4 Then
         MsgBox(4096, "Error", "Your password must be at least 4 characters")
         ContinueLoop
      EndIf
      $cPass = InputBox("Security Check", "Re-enter your password.", "", "*")
      If $iPass <> $cPass Then
         ContinueLoop
      Else
         IniWrite($Ini, , "Security", "Password", $cPass)
         ExitLoop
   Next
Else
   $passwd = InputBox("Security Check", "Enter your password.", "", "*")
   if $passwd = INIRead($Ini, "Security", "Password", "") Then 
      If $passwd = "" Then Exit
      MsgBox (0,"","Greetings") 
   Else 
      Exit
   EndIf
EndIf
Again untested but should be right
second 1 has problems first works fine

ohhh i see what u mean u mean it prompts u to make a password when uf irst run the program

i just have 1 more question how do i stop somone from just opening the file reading the password then running program and accessing whats there?

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

second 1 has problems first works fine

ohhh i see what u mean u mean it prompts u to make a password when uf irst run the program

i just have 1 more question how do i stop somone from just opening the file reading the password then running program and accessing whats there?

cheers C.W

That's the drawback to using an INI. However if it is the same user that set it then it doesn't matter. That can also be solved but I'm getting to tired to think about it right now.

What problem did you have with the second? I may have messed up the syntax but I don't see it right now.

EDIT: actually I do know how to secure it but like I said I'm getting tired and I'm sure to mess it up. I'll work on it later but the idea is to use _StringEncrypt().

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

There are 2 ways to do that.

1) Use windows filerights, but then u can't use autoit :)

2) encrypt the text in there. You could simply do that by replacement or so

$encrypted = "" ; Fill with nothing a.k.a. make the var
$text = "inputtext" ; Fill the variable
For $i = 1 To StringLen($text) Step 1 ; Loop from 1 to the length of $text and increase $i by 1 every loop
    $encrypted = $encrypted & Asc(StringLeft($text, 1)) + Asc($i) & "|" ; Every loop add to the $encrypted variable and make an ascii character from the most left inputed character and add the ascii char of the number of loops after that. Adds the pipe symbol (|) between every looped addition.
    $text = StringTrimLeft($text, 1) ; remove the left character from the variable
Next ; loop the loop :)
msgbox(0, "encrypted?", $encrypted) ; show the output :P

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

one word encryption?

ok i see if one user but wat if its a univesal program that anyone can grab?

if its on a usb

cheers C.W

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

There are 2 ways to do that.

1) Use windows filerights, but then u can't use autoit :)

2) encrypt the text in there. You could simply do that by replacement or so

$encrypted = ""; Fill with nothing a.k.a. make the var
$text = "inputtext"; Fill the variable
For $i = 1 To StringLen($text) Step 1; Loop from 1 to the length of $text and increase $i by 1 every loop
    $encrypted = $encrypted & Asc(StringLeft($text, 1)) + Asc($i) & "|"; Every loop add to the $encrypted variable and make an ascii character from the most left inputed character and add the ascii char of the number of loops after that. Adds the pipe symbol (|) between every looped addition.
    $text = StringTrimLeft($text, 1); remove the left character from the variable
Next; loop the loop :)
msgbox(0, "encrypted?", $encrypted); show the output :p
There is already a simple _StringEncrypt() function in the UDFs that will encrypt/decrypt the password in the INI and you can set the encryption level.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

#include <constants.au3>

Global $Ini = @ScriptDir & "\PW.ini"
If Not FileExists($Ini) then
    _setuser(1)
   _SetPass(1)
Else
    $username = InputBox("security check","enter your username.","")
    if $username = IniRead($Ini,"security","username","") Then
        if $username = "" then exit
   $passwd = InputBox("Security Check", "Enter your password.", "", "*")
   if $passwd = INIRead($Ini, "Security", "Password", "") Then 
      If $passwd = "" Then Exit
      MsgBox (0,"","Greetings") 
   Else 
      Exit
   EndIf
EndIf
Func _Setuser($atmpt)
    If $atmpt = 1 Then Exit;;; Change this to set how many attempts are allowed.
    $PPass = InputBox("Security Check", "Enter your username.", "")
    If StringLen($PPass) <5 Then
      MsgBox(4096, "Error", "Your username must be at least 5 characters")
      _Setuser($atmpt)
    EndIf
    $BPass = InputBox("Security Check", "Re-enter your username.", "")

    If $PPass <> $BPass Then
       $atmpt += 1
       _Setuser($atmpt)
   Else
      IniWrite($Ini,  "Security", "username", $BPass)
   EndIf
EndFunc

Func _SetPass($atmpt)
    If $atmpt = 3 Then Exit;;; Change this to set how many attempts are allowed.
    $iPass = InputBox("Security Check", "Enter your password.", "", "*")
    If StringLen($iPass) <4 Then
      MsgBox(4096, "Error", "Your password must be at least 4 characters")
      _SetPass($atmpt)
    EndIf
    $cPass = InputBox("Security Check", "Re-enter your password.", "", "*")

    If $iPass <> $cPass Then
       $atmpt += 1
       _SetPass($atmpt)
   Else
      IniWrite($Ini,  "Security", "Password", $cPass)
   EndIf
EndFunc

would that work for username and pass but it seems nto to work for me?

ok so i muct encrypt and decrypt with in this program by putitng that in hmmm smart

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

#include <constants.au3>

Global $Ini = @ScriptDir & "\PW.ini"
If Not FileExists($Ini) then
    _setuser(1)
   _SetPass(1)
Else
    $username = InputBox("security check","enter your username.","")
    if $username = IniRead($Ini,"security","username","") Then
        if $username = "" then exit
   $passwd = InputBox("Security Check", "Enter your password.", "", "*")
   if $passwd = INIRead($Ini, "Security", "Password", "") Then 
      If $passwd = "" Then Exit
      MsgBox (0,"","Greetings") 
   Else 
      Exit
   EndIf
EndIf
Func _Setuser($atmpt)
    If $atmpt = 1 Then Exit;;; Change this to set how many attempts are allowed.
    $PPass = InputBox("Security Check", "Enter your username.", "")
    If StringLen($PPass) <5 Then
      MsgBox(4096, "Error", "Your username must be at least 5 characters")
      _Setuser($atmpt)
    EndIf
    $BPass = InputBox("Security Check", "Re-enter your username.", "")

    If $PPass <> $BPass Then
       $atmpt += 1
       _Setuser($atmpt)
   Else
      IniWrite($Ini,  "Security", "username", $BPass)
   EndIf
EndFunc

Func _SetPass($atmpt)
    If $atmpt = 3 Then Exit;;; Change this to set how many attempts are allowed.
    $iPass = InputBox("Security Check", "Enter your password.", "", "*")
    If StringLen($iPass) <4 Then
      MsgBox(4096, "Error", "Your password must be at least 4 characters")
      _SetPass($atmpt)
    EndIf
    $cPass = InputBox("Security Check", "Re-enter your password.", "", "*")

    If $iPass <> $cPass Then
       $atmpt += 1
       _SetPass($atmpt)
   Else
      IniWrite($Ini,  "Security", "Password", $cPass)
   EndIf
EndFunc

why doesnt that work?

anyone know?

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

#include <constants.au3>

Global $Ini = @ScriptDir & "\PW.ini"
If Not FileExists($Ini) then
    _setuser(1)
   _SetPass(1)
Else
    $username = InputBox("security check","enter your username.","")
    if $username = IniRead($Ini,"security","username","") Then
        if $username = "" then exit
   $passwd = InputBox("Security Check", "Enter your password.", "", "*")
   if $passwd = INIRead($Ini, "Security", "Password", "") Then 
      If $passwd = "" Then Exit
      MsgBox (0,"","Greetings") 
   Else 
      Exit
   EndIf
EndIf
Func _Setuser($atmpt)
    If $atmpt = 1 Then Exit;;; Change this to set how many attempts are allowed.
    $PPass = InputBox("Security Check", "Enter your username.", "")
    If StringLen($PPass) <5 Then
      MsgBox(4096, "Error", "Your username must be at least 5 characters")
      _Setuser($atmpt)
    EndIf
    $BPass = InputBox("Security Check", "Re-enter your username.", "")

    If $PPass <> $BPass Then
       $atmpt += 1
       _Setuser($atmpt)
   Else
      IniWrite($Ini,  "Security", "username", $BPass)
   EndIf
EndFunc

Func _SetPass($atmpt)
    If $atmpt = 3 Then Exit;;; Change this to set how many attempts are allowed.
    $iPass = InputBox("Security Check", "Enter your password.", "", "*")
    If StringLen($iPass) <4 Then
      MsgBox(4096, "Error", "Your password must be at least 4 characters")
      _SetPass($atmpt)
    EndIf
    $cPass = InputBox("Security Check", "Re-enter your password.", "", "*")

    If $iPass <> $cPass Then
       $atmpt += 1
       _SetPass($atmpt)
   Else
      IniWrite($Ini,  "Security", "Password", $cPass)
   EndIf
EndFunc

why doesnt that work?

anyone know?

ive tried everything from re writing the script but to no succes

all i get is

line 27 (file ":\doucment and settings\fred\mydocuments\scripts\halfdone\passwords\passini.au3"):

next

error:"next" statement with no matching "for" statement

any ideas?

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

Link to comment
Share on other sites

you need to put a "For" before your "next" where it is nessasary...check the helpfile for help with that

yet i cant even find the "next" statement

and now tis saying

line 20 blah blah blah

func_setuser($atmpt)

error:"if"statement has no matching "endif" statement

ice avtually trid this and ti does have a end if wth is wrong with auto it

Edited by corey822

C.Wnew rules:1.dont use plz in a post or title use please instead2.always use help file as it is now muchly over rated3. dont think where not watching u4.please wait 24 hours after last post ot bump XD i use to make that mistake

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...