AutoHotkey Community

It is currently May 26th, 2012, 2:15 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: RC4 Encryption
PostPosted: August 10th, 2004, 11:22 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
This script will perform actual RC4 encryption.

Give it 'pw' and 'data' and 'Gosub Rc4'.

'Result' contains en(de)crypted data.

I optimised it a lot compared to original and now its much faster.

Script

_________________
Image


Last edited by Rajat on June 19th, 2005, 9:12 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject: limitations?
PostPosted: August 23rd, 2004, 12:39 pm 
Offline

Joined: April 23rd, 2004, 4:38 am
Posts: 34
Location: Adelaide, South Australia
Hi Rajat,
I haven't fully examined the logic of this but it seems only to work for small amounts of data. The limit varies but is only a few hundred bytes, after which the data remains as cyphertext. Or perhaps are certain characters having unexpected effects?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2004, 4:51 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
i've checked it only for small text snippets. i use it at a couple of places but only for small text portions, for complete files or drives etc. i use specialesed tools.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 9th, 2005, 9:11 pm 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
cool script. was wondering if u could help me. I needed a script that would encrypt a password & save it 2 a different file then decrypt it when i ran commands that used the password. :roll:

Example of command:
Code:
   

$Numpad1::

  Send,\

      Sleep, 100

  Send, rcon password sv_players

return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2005, 12:53 am 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
Well this is what I have done so far:

Code:
NoPassFound = RCON
EnterPass = Please enter Password.

iniread, RemRCONPass, RCONPASS.INI,Remember,RCONPass,0
iniread, RCONPass, RCONPASS.INI, DATA, RCONPass, 00
iniread, RemPassState, RCONPASS.INI, Remember, PassState, 1
iniread, PassState, RCONPASS.INI, DATA, PassState, 1

ifnotexist RCONPASS.INI

ifequal, RCONPass, 00
   RCONPass =

start:

Gui, Add, Checkbox, x185 y82 w20 h20 vPassState Checked%PassState%
Gui, Add, Text, x45 y10 w145 h20, %EnterPass%
ifequal, PassState, 1
Gui, Add, Edit, x20 y35 w160 h20 vRCONPass Password, %RCONPass%
ifequal, PassState, 0
Gui, Add, Edit, x20 y40 w160 h20 vRCONPass, %RCONPass%
Gui, Add, Button, x35 y70 w50 h20, OK
Gui, Add, Button, x120 y70 w50 h20, Cancel
ifequal, DialogCaption, 0
gui, -caption
Gui, Show, h100 w200, %NoPassFound%
Return

GuiClose:
ButtonCancel:
gui, submit
gui, destroy
 
ButtonOK:
Gui, submit
gui, destroy
ifequal, RemRCONPass, 0
   iniwrite, %RCONPass%, RCONPASS.INI, DATA, RCONPass
ifequal, RemPassState, 1
iniwrite, %PassState%, RCONPASS.INI, DATA, PassState
return


How do i make it so that when i click the "CheckBox" it will toggle show/hide password? while im in the gui :?:
Now I need 2 edit it so it encrypts pass b4 saving & decrypts it when i use RCON command.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2005, 6:12 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
the idea is to fill the vars 'text' & 'pw' and do 'gosub crypt'. text will contain encrypted text. to crypt pwd u'll have to put that into the 'text' var.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2005, 8:19 pm 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
Something like this :?:

Code:

NoRCONPassFound = RCON
EnterRCONPass = Please enter New Password.


iniread, RemRCONPass, SETTINGS.INI,Remember,RCONPass,0
iniread, RCONPass, SETTINGS.INI, DATA, RCONPass, 00
iniread, RemRCONPassState, SETTINGS.INI, Remember, RCONPassState, 1
iniread, RCONPassState, SETTINGS.INI, DATA, RCONPassState, 1

ifexist SETTINGS.INI
return

ifnotexist SETTINGS.INI

ifequal, RCONPass, 00
   RCONPass =

start:

Gui, Add, Checkbox, x185 y82 w20 h20 vRCONPassState Checked%RCONPassState%
Gui, Add, Text, x30 y10 w145 h20, %EnterRCONPass%
ifequal, RCONPassState, 1
Gui, Add, Edit, x20 y35 w160 h20 vRCONPass Password
ifequal, RCONPassState, 0
Gui, Add, Edit, x20 y40 w160 h20 vRCONPass
Gui, Add, Button, x35 y70 w50 h20, OK
Gui, Add, Button, x120 y70 w50 h20, Cancel
ifequal, DialogCaption, 0
gui, -caption
Gui, Show, h100 w200, %NoRCONPassFound%
Return

GuiClose:
ButtonCancel:
gui, submit
gui, destroy
return
 
ButtonOK:
Gui, submit
gui, destroy

Text = %RCONPass%
msgbox, %text%
pw = psw

Gosub, Crypt
msgbox, %Cipher%


Text = %Cipher%
pw = psw

;Gosub, Crypt
;msgbox, %Cipher%

ifequal, RemRCONPass, 0
   iniwrite, %Cipher%, SETTINGS.INI, DATA, RCONPass
ifequal, RemRCONPassState, 1
iniwrite, %RCONPassState%, SETTINGS.INI, DATA, RCONPassState

Crypt:

        BLines = %A_BatchLines%
        SetBatchLines, -1
        AutoTrim, Off

        StringLen, PWLen, PW
        Cipher =
        Loop, 256
        {
                A = %A_Index%
                A -= 1
               
                Transform, Mod, Mod, %A%, %PWLen%
                Mod += 1
               
                StringMid, Chr, PW, %MOD%, 1
                Transform, ASC, asc, %Chr%
                Key%A% = %ASC%
                sbox%A% = %A%
        }
       
        B = 0
        Loop, 256
        {
                A = %A_Index%
                A -= 1

                StringTrimRight, tempsa, sbox%A%, 0
                StringTrimRight, tempka, Key%A%, 0

                tempB = %B%
                tempB += %tempsa%
                tempB += %tempka%
               
                Transform, B, Mod, %tempB%, 256
               
                StringTrimRight, tempsb, sbox%B%, 0
               
                sbox%A% = %tempsb%
                sbox%B% = %tempsa%
        }
       
        tempI =
        J =
        StringLen, TLen, Text
        Loop, %TLen%
        {
                A = %A_Index%

                tempI ++
                Transform, I, Mod, %tempI%, 256
               
                StringTrimRight, tempsi, sbox%I%, 0

                Divd = %tempsi%
                Divd += %J%
                Transform, J, Mod, %Divd%, 256
               
                StringTrimRight, tempsj, sbox%J%, 0

                Divd = %tempsi%
                Divd += %tempsj%
                Transform, Mod, Mod, %Divd%, 256
               
                StringTrimRight, K, sbox%Mod%, 0
               
                StringMid, Chr, Text, %A%, 1
                Transform, ASC, asc, %Chr%
               
                Transform, CipherBy, bitxor, %Asc%, %K%
                Transform, out, chr, %CipherBy%
                Cipher = %Cipher%%out%
        }
        SetBatchLines, %BLines%
Return

$Numpad1::

Text = %RCONPass%
;msgbox, %text%
pw = psw

Gosub, Crypt
;msgbox, %Cipher%


Text = %Cipher%
pw = psw

;Gosub, Crypt
;msgbox, %Cipher%

Send,\
Sleep, 100
Send, rcon %Cipher% sv_players
return



Its not fully functional + its just missing a small portion of the code now I think but was wondering if u could tell me if I was on the right track & what u thought of the code so far.

I used yr Encryption formula, hope u dont mind. Couldn't have done it without yr help or without this great program. :!: :D Also got bits & pieces of the code from other sources & am sorry if I didn't mention u in this or any other post. :(

PS: Still can't get the checkbox thing 2 work right.Can't toggle hide/show Password while gui is loaded.U know how 2 fix it :?: :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 10th, 2005, 9:16 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
i'm very bad at understanding other's codes, so here's some simple help:

Code:
; Generated using SmartGUI Creator 3.5

Gui, Add, Edit, x6 y17 w130 h20,
Gui, Add, Checkbox, x6 y47 w20 h30 g1 vstat,
Gui, Show, x158 y110 h85 w144, Generated using SmartGUI Creator 3.5
Return

1:
   gui, submit, nohide
   ifequal, stat, 1
      guicontrol, +password, edit1
   else
      guicontrol, -password, edit1
return
      
GuiClose:
ExitApp

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 11th, 2005, 9:08 pm 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
Tx :!: This code came in handy & it works.
Although u still have 2 click on the Edit Box after clicking CheckBox 4 it 2 Show/Hide Password it's still better than b4. :D


Report this post
Top
 Profile  
Reply with quote  
PostPosted: June 14th, 2005, 1:36 pm 
Offline

Joined: March 2nd, 2005, 10:59 am
Posts: 59
Hello rajat
your script is exactly what I need, but it only functions on small portions of text or files.
cant you alter it a bit to function on files of the size lets say 1 kbyte? or 700byte?
pleeeeeezzzze :)
Im too dumb to do it :cry:
ciao
MIchael


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2005, 6:53 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
Try the new script

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2005, 4:42 pm 
Offline

Joined: April 14th, 2005, 11:11 am
Posts: 186
Location: Wisconsin, USA
Rajat did you update the actual encryption script or one of the reply's?

_________________
Image
"Make it idiot-proof, and someone will make a better idiot."


Report this post
Top
 Profile  
Reply with quote  
 Post subject: enc
PostPosted: June 15th, 2005, 5:23 pm 
Offline

Joined: March 2nd, 2005, 10:59 am
Posts: 59
He updated the encryption script!!!!!!!!!!!
:D :D :D
really cool
Thanks a lot!
MIchael


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2005, 5:27 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Yep, thanks for updating it Rajat.
It works great as a function too.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 17th, 2005, 1:36 am 
Offline

Joined: May 4th, 2005, 7:07 pm
Posts: 16
I used the last version of the encryption code & added Gui's so I could save it already encrypted in a *.ini file + change the password from time to time.

I made 1 gui to type in & then through that gui encrypt/save the password the 1st time the aplication is run & another gui to decrypt/view/Change password.

My Problem is I mannaged 2 get it working with last version of the code but am having trouble with this version.

Can some1 help me plz?Tx :roll:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 34 posts ]  Go to page 1, 2, 3  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group