Hi Laszlo!
I'm writing a new Script and it seems like your Encryption scrambles the Data after 164 chars (+ 4 A_Tab).
Basicly, my script creates 2 random-generated Passphrases (64 Chars).
The first Passphrase (salt) is encrypted with a Space Char (A_Space) and the second (password) is encrypted with the first.
Then on a Username are 5 Characters Attached (salt, char 1-5) and are encrypted with the password
The Password for the username (pwd) has also 5 chars attached (salt, char 10-15) and is encrypted with the password.
Furthermore, a URL is encrypted with the password.
All Data are seperated with a Char (can be `n, A_Space, A_Tab, ...) and then the entire String is encrypted again with a Space Char to obfuscate which data belongs to which part of the login.
password has 64 characters and will be encrypted 128 chars long, aswell as salt will be.
in my example the username has 10 chars, and will be encrypted 30 chars long
my password has 16 chars and will be encrypted 42 chars long.
then, my host-adress has originally 15 chars, but will be encrypted to 30 chars (which belongs to the 10 of the username) and finally, the entire string has 362 chars and is encrypted 725 chars long.
I assume you'll need some code, so there we go:
Thats the Loginfile-Creator
Code:
#Include, %A_ScriptDir%
#Include, rc4hex.ahk
Gui, Margin, 5, 5
Gui, Add, Text, xm ym w125 h20 , DynDNS Benutzername:
Gui, Add, Edit, xm+130 yp w230 hp vddns_user, abcdefghij
Gui, Add, Text, xm yp+25 w125 hp , DynDNS Passwort:
Gui, Add, Edit, xm+130 yp w230 hp vddns_passwd , 4rIYy|B\`%A0@?)rC
Gui, Add, Text, xm yp+25 w125 hp , DynDNS Host:
Gui, Add, Edit, xm+130 yp w230 hp vddns_host, xxxx.dyndns.org
Gui, Add, Text, xm yp+25 w125 hp , Speicherort:
Gui, Add, Edit, xm+130 yp w195 hp vfile ReadOnly, %A_ScriptDir%\masterplan
Gui, Add, Button, xp+200 yp w30 hp gChooseFile, ...
Gui, Add, Button, xm+130 yp+30 w110 h30 gGenerate Default, Generieren
Gui, Add, Button, xp+120 yp wp hp gCloseGUI, Beenden
Gui, Show, Center AutoSize, Remotedesktop Logincreator 0.1a
GuiControl, Focus, ddns_user
Return
CloseGUI:
GuiEscape:
GuiClose:
ExitApp
Generate:
Gui +OwnDialogs
Gui, Submit, NoHide
salt := GenerateRandomPasswd(64, "abcdefghijklmnopqrstuvwxyz"
. "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
. "0123456789äöüÄÖÜ!?-+._")
enc_passwd := GenerateRandomPasswd(64)
auth := RC4txt2hex( RC4txt2hex(salt, A_Space) "`n"
. RC4txt2hex(enc_passwd, salt) "`n"
. RC4txt2hex(ddns_user SubStr(salt, 1, 5), enc_passwd) "`n"
. RC4txt2hex(ddns_passwd SubStr(salt, 10, 5), enc_passwd) "`n"
. RC4txt2hex(ddns_host, enc_passwd), A_Space)
Msgbox, % liste := RC4txt2hex(salt, A_Space) "`n"
. RC4txt2hex(enc_passwd, salt) "`n"
. RC4txt2hex(ddns_user SubStr(salt, 1, 5), enc_passwd) "`n"
. RC4txt2hex(ddns_passwd SubStr(salt, 10, 5), enc_passwd) "`n"
. RC4txt2hex(ddns_host, enc_passwd)
Msgbox, % StrLen(liste)
authblock := CreateBlocks(auth, 64)
If FileExist(file)
FileDelete, %file%
FileAppend, %authblock%, %file%
Msgbox, 64, Info, Das Loginfile wurde erstellt...
Return
ChooseFile:
Gui +OwnDialogs
FileSelectFile, file, S, , Bitte Speicherort angeben...
If Errorlevel
Return
GuiControl, , file, %file%
Return
GenerateRandomPasswd(len, chars = "") {
If !chars
charset := "abcdefghijklmnopqrstuvwxyz"
. "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
. "0123456789äöüÄÖÜ@<({[/=\]})"
. ">!?$&#*-+.,;:_"
Else
charset := chars
Loop, %len% {
Random, r, 1, % StrLen(charset)
pass .= SubStr(charset, r, 1)
}
Return, pass
}
CreateBlocks(str, blocklenght){
blocked := ""
len := Strlen(str)
loop, % len / blocklenght
blocked .= SubStr(str, ((A_index - 1) * blocklenght) + 1, blocklenght) "`n"
blocked .= SubStr(str, len - Mod(len, blocklenght))
return blocked
}
And a little test-authenticate-Script:
Code:
#Include, %A_ScriptDir%
#Include, rc4hex.ahk
; Authenticate
file := A_ScriptDir "\masterplan"
FileRead, encrypted, %file%
encrypted := RegExReplace(encrypted, "\R")
; Msgbox, %encrypted% ; CHECK
decrypted_auth := RC4hex2txt(encrypted, A_Space)
;Msgbox, %decrypted_auth%
StringSplit, encrypted_data, decrypted_auth, `n
Msgbox, %encrypted_data0%`n`n%encrypted_data1%`n`n%encrypted_data2%`n`n%encrypted_data3%`n`n%encrypted_data4%`n`n%encrypted_data5%
decrypted_salt := RC4hex2txt(encrypted_data1, A_Space)
decrypted_passwd := RC4hex2txt(encrypted_data2, decrypted_salt)
decrypted_user := SubStr(RC4hex2txt(encrypted_data3, decrypted_passwd), 1, -5)
decrypted_pass := SubStr(RC4hex2txt(encrypted_data4, decrypted_passwd), 1, -5)
decrypted_host := RC4hex2txt(encrypted_data5, decrypted_passwd)
Msgbox, % "Salt = " decrypted_salt " - " StrLen(decrypted_salt) "`n"
. "Passwort = " decrypted_passwd " - " StrLen(decrypted_passwd) "`n"
. "Benutzer = " decrypted_user " - " StrLen(decrypted_user) "`n"
. "Passwort = " decrypted_pass " - " StrLen(decrypted_pass) "`n"
. "Host = " decrypted_host " - " StrLen(decrypted_host)
ExitApp
PS.: I scrambled all login data, but the length is the same.
A first error was that the tecnique I used before was buggy, so IsNull helped me out with the new CreateBlocks()-Function.
Before that change, not even the first password was decrypted...
So may you can help me out. I think it has something to do with your Encryption, but after trying your example I'm not so sure anymore.
But it's definitely weired that this error happens exactly after 164 chars plaintext.
PPS.: I'm using the latest version of AHK-Basic.
THXIA
EDIT: Hi again. Theres no error with your code, the mistake was the Block-Function.
Thanks to the guys from the german Forum (which I posted earlier) the error was found.
Code:
;authblock := CreateBlocks(auth, 64)
L := 64, P := 1 - L
While (P <= StrLen(auth))
authblock .= SubStr(auth, P += L, L) . "`n"
It seems like that the Function duplicated a char while creating the blocked code so that the decryption cant work.
Thanks anyway.