Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

RC4 Encryption


  • Please log in to reply
33 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


MikeG
  • Members
  • 34 posts
  • Last active: Jul 17 2011 05:13 AM
  • Joined: 23 Apr 2004
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?

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


d3m0n1x
  • Members
  • 16 posts
  • Last active: Jun 20 2005 07:52 PM
  • Joined: 04 May 2005
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:

$Numpad1::

  Send,\

      Sleep, 100

  Send, rcon password sv_players

return


d3m0n1x
  • Members
  • 16 posts
  • Last active: Jun 20 2005 07:52 PM
  • Joined: 04 May 2005
Well this is what I have done so far:

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.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


d3m0n1x
  • Members
  • 16 posts
  • Last active: Jun 20 2005 07:52 PM
  • Joined: 04 May 2005
Something like this :?:


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 :?: :?

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
i'm very bad at understanding other's codes, so here's some simple help:

; 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

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


d3m0n1x
  • Members
  • 16 posts
  • Last active: Jun 20 2005 07:52 PM
  • Joined: 04 May 2005
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

MIchael
  • Members
  • 59 posts
  • Last active: Dec 15 2006 01:05 PM
  • Joined: 02 Mar 2005
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

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
Try the new script

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


TeknoMusicMan
  • Members
  • 186 posts
  • Last active: Jan 17 2007 10:17 PM
  • Joined: 14 Apr 2005
Rajat did you update the actual encryption script or one of the reply's?
Posted Image
"Make it idiot-proof, and someone will make a better idiot."

MIchael
  • Members
  • 59 posts
  • Last active: Dec 15 2006 01:05 PM
  • Joined: 02 Mar 2005
He updated the encryption script!!!!!!!!!!!
:D :D :D
really cool
Thanks a lot!
MIchael

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
Yep, thanks for updating it Rajat.
It works great as a function too.

d3m0n1x
  • Members
  • 16 posts
  • Last active: Jun 20 2005 07:52 PM
  • Joined: 04 May 2005
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: