Sign in to follow this  
Followers 0
Skitty

Secure your files with command line rar.exe

2 posts in this topic

#1 ·  Posted (edited)

So I heard that winrar's encryption is so good that it's next to impossible to recover an archives contents without having the password. So I made this little script that basically automates rar.exe and unrar.exe so you can enter a password that will literally take ten trillion years to find via bruit force attacks as described by a supposed rarlabs cryptologist that say that's what it takes if you use a password longer than 45-50 characters so that's why I made the script also encrypt your astonishingly random and Pentagon like password and save it to an ini file in the same directory, just make sure you DON'T LOOSE THAT KEY cause I really doubt you're gonna remember a 40--100 character password. So All you have to do is randomly beat your keyboard and make sure you also hit shift in order to get those precious non-alphanumeric characters into play! Remember that the mentioned executables are part of winrar's software pack. You will need these files in order to get this script to work. It turns out that UnRAR.exe is actually freeware but Rar.exe is not. You can just download Winrar or if you already have winrar then go to C:\Program Files\Winrar and copy them to the directory C:\W7 that you previously created.

Edit: Never-mind about the comment saying "its next to impossible to recover an archive contents w/o password"

This guy, " Alexander Roshal" says its impossible, not next to it.Posted Image

After compiling along with "Command line rar"

Do

Step #1: Start the program, and press F2 which is the how key I set.

Step #2: When a box comes up, type in "create" and a file will be created with the icon you have in C:\W7 and remember to rename the icon ".ico" to look like "lock.ico"

Step #3: After filling the File titled archive with your files, press F2 once more and type in "Lock" and enter a password between 35-55 random characters. Any character except Chinese. Eg, pressing shift while banging your keyboard.

Step #4: If you wan't to unlock the archive, just type in "UnLock" and choose the archive and the ini file when it ask's you. Just remember not to rename the archive ever. then you can just type in "kill" and it will stop its process which is nearly nothing.

Any way, tell me what you think!

#RequireAdmin
#include<Misc.au3>
#include<File.au3>
#include <String.au3>
HotKeySet("{F2}","_Select");Set your hot key
If _Singleton(@ScriptName,1) = 0 Then
    Exit
EndIf

While 1
    Sleep(360000)
WEnd

Func _Select()
    Local $I = InputBox("Command Center", " ", "", "", 200, 100)
    Switch $I
    Case "kill", "exit", "stop", "Kill", "Exit", "Stop", "KILL", "EXIT", "STOP"
        ProcessClose("UnRAR.exe")
        ProcessClose("Rar.exe")
        Exit
    Case "create", "Create", "CREATE"
        _create()
    Case "lock", "Lock", "LOCK"
        _lock()
    Case "unlock", "Unlock", "UNLOCK", "un-lock", "Un-lock", "UN-LOCK", _
        "un lock", "Un lock", "UN LOCK", "Un Lock", "Un-Lock"
        _unlock()
    Case Else
        MsgBox(0, "Syntax error", "'" & $I & "'" & " is not recognized as an internal or external command." & _
            @LF & "*Password size should be between 25-50 random characters*" & _
            @LF & "----Commands are as follows-----" & @LF & @LF & "Create - Creates a folder" & @LF & "Lock - Super encrypt a folder" & _
            @LF & "UnLock - UnLock an encrypted archive" & @LF & @LF & 'This program uses "Rar.exe" and "UnRAR.exe" by winrar.' & _
            @LF & "ProTip- The file $~settings.ini contains your encrypted password and you will need it to open an archive." & _
            @LF & "Unless you have good memory, you will need that file. To open an archive, Select it in the popup after typing" & _
            @LF & '"UnLock", then select your ini file and there you have it! Winrar states that it is next to impossible to' & _
            @LF & "unencrypt an encrypted archive without a password." & _
            @LF & "P.s- Do not rename the archive or the ini file will not work for you. You can encrypt any number of archives" & _
            @LF & "and have all the encrypted passwords in the same  ini file. Just make sure that you have your ini file in the same directory.")
    EndSwitch
EndFunc


Func _create()
$KB1 = @ScriptDir & "\Archive"
DirCreate(@ScriptDir & "\Archive")
_FileCreate(@ScriptDir & "\Archive\desktop.ini")
FileInstall("C:\W7\lock.ico",@ScriptDir & "\Archive\lock.ico");Choose an Icon that will be displayd for the folder. Like a lock or something.
IniWriteSection($KB1 & "\" & "Desktop.ini", ".ShellClassInfo", _
"IconFile=" & "lock.ico" & @LF & _
"IconIndex=0" & @LF & _
"InfoTip=Folder ready for archiving!")
FileSetAttrib($KB1 & "\" & "Desktop.ini", "+HS")
FileSetAttrib($KB1, "+R")
FileSetAttrib($KB1 & "\lock.ico", "+SHR")
EndFunc

Func _lock()
$KB43 = InputBox("Enter password"," ","","*",200,75)
$HIDF353 = _StringEncrypt(1, $KB43 , " ", 7)
FileInstall("C:\W7\Rar.exe",@TempDir & "\Rar.exe")
FileChangeDir(@TempDir)
RunWait("rar a Data.rar -k -ow -dw -m5 -hp" & $KB43 & " " & @ScriptDir & "\Archive",@TempDir,@SW_HIDE)
$FH337 = _TempFile(@ScriptDir, "DATA_", ".rar", 7)
FileMove(@TempDir & "\Data.rar",$FH337)
If FileExists(@ScriptDir & "\$~settings.ini") Then
    iniWriteSection(@ScriptDir & "\$~settings.ini", ( _KB238 ( $FH337 )),"KB29=" & $HIDF353)
Else
    _FileCreate(@ScriptDir & "\$~settings.ini")
    iniWriteSection(@ScriptDir & "\$~settings.ini", ( _KB238 ( $FH337 )),"KB29=" & $HIDF353)
EndIf
EndFunc

Func _unlock()
$KB283 = FileOpenDialog("Select your archive file.", @WindowsDir & "\", "Archives (*.rar)", 1 + 4 )
If @error Then
    MsgBox(4096,"","No File(s) chosen")
    Exit
Else
    $KB283 = StringReplace($KB283, "|", @CRLF)
EndIf
$KB383 = FileOpenDialog("Select your ini file.", @WindowsDir & "\", "Images (*.ini)", 1 + 4 )
If @error Then
    MsgBox(4096,"","No File(s) chosen")
    Exit
Else
FileInstall("C:\W7\UnRAR.exe",@TempDir & "\UnRAR.exe")
DirCreate(@ScriptDir & "\Data")
FileChangeDir(@TempDir)
RunWait("unrar e -y -p" & _StringEncrypt(0, IniRead ( StringReplace($KB383, "|", @CRLF), _
( _KB238 ( $KB283 )), "KB29", " " ), " ", 7) & " " & _
$KB283 & " " & @ScriptDir & "\Data",@TempDir,@SW_HIDE)
EndIf
EndFunc

Func _KB238 ( $KB281 )
    If Not FileExists ( $KB281 ) Then Return 0
    $KB282 = StringSplit ( $KB281, '\' )
    Return $KB282[$KB282[0]]
EndFunc

The code below double encrypts an archive but it won't work. read post below..

#RequireAdmin
#include<Misc.au3>
#include<Crypt.au3>
#include<File.au3>
#include <String.au3>

HotKeySet("{F2}","_Select");Set your hot key
If _Singleton(@ScriptName,1) = 0 Then
    Exit
EndIf

While 1
    Sleep(360000)
WEnd

Func _Select()
    Local $I = InputBox("Command Center", " ", "", "", 200, 100)
    Switch $I
    Case "kill", "exit", "stop", "Kill", "Exit", "Stop", "KILL", "EXIT", "STOP"
        ProcessClose("UnRAR.exe")
        ProcessClose("Rar.exe")
        Exit
    Case "create", "Create", "CREATE"
        _create()
    Case "lock", "Lock", "LOCK"
        ProcessClose("Rar.exe")
        _lock()
    Case "unlock", "Unlock", "UNLOCK", "un-lock", "Un-lock", "UN-LOCK", _
        "un lock", "Un lock", "UN LOCK", "Un Lock", "Un-Lock"
        ProcessClose("UnRAR.exe")
        _unlock()
    Case Else
        MsgBox(0, "Syntax error", "'" & $I & "'" & " is not recognized as an internal or external command." & _
            @LF & "*Password size should be between 25-50 random characters*" & _
            @LF & "----Commands are as follows-----" & @LF & @LF & "Create - Creates a folder" & @LF & "Lock - Super encrypt a folder" & _
            @LF & "UnLock - UnLock an encrypted archive" & @LF & @LF & 'This program uses "Rar.exe" and "UnRAR.exe" by winrar.' & _
            @LF & "ProTip- The file $~settings.ini contains your encrypted password and you will need it to open an archive." & _
            @LF & "Unless you have good memory, you will need that file. To open an archive, Select it in the popup after typing" & _
            @LF & '"UnLock", then select your ini file and there you have it! Winrar states that it is next to impossible to' & _
            @LF & "unencrypt an encrypted archive without a password." & _
            @LF & "P.s- Do not rename the archive or the ini file will not work for you. You can encrypt any number of archives" & _
            @LF & "and have all the encrypted passwords in the same  ini file. Just make sure that you have your ini file in the same directory.")
    EndSwitch
EndFunc


Func _create()
$KB1 = @ScriptDir & "\Archive"
DirCreate(@ScriptDir & "\Archive")
_FileCreate(@ScriptDir & "\Archive\desktop.ini")
FileInstall("C:\W7\lock.ico",@ScriptDir & "\Archive\lock.ico");Choose an Icon that will be displayd for the folder. Like a lock or something.
IniWriteSection($KB1 & "\" & "Desktop.ini", ".ShellClassInfo", _
"IconFile=" & "lock.ico" & @LF & _
"IconIndex=0" & @LF & _
"InfoTip=Folder ready for archiving!")
FileSetAttrib($KB1 & "\" & "Desktop.ini", "+HS")
FileSetAttrib($KB1, "+R")
FileSetAttrib($KB1 & "\lock.ico", "+SHR")
EndFunc

Func _lock()
DirCreate(@ScriptDir & "\~Processing")
$Passwd23 = InputBox("Enter password"," ","","*",200,75)
$Passwd22 = _StringEncrypt(1, $Passwd23 , "", 7)
FileInstall("C:\W7\Rar.exe",@TempDir & "\Rar.exe")
FileChangeDir(@TempDir)
RunWait("rar a Data.rar -k -ow -m5 -hp" & $Passwd23 & " " & @ScriptDir & "\Archive",@TempDir,@SW_HIDE)
FileChangeDir(@ScriptDir)
$Newname = _TempFile(@ScriptDir, "DATA_", ".RAR", 7)
FileMove(@TempDir & "\Data.rar",$Newname)
If FileExists(@ScriptDir & "\$~settings.ini") Then
    iniWriteSection(@ScriptDir & "\$~settings.ini", ( _KB238 ( $Newname )),"KB29=" & $Passwd22)
Else
    _FileCreate(@ScriptDir & "\$~settings.ini")
    iniWriteSection(@ScriptDir & "\$~settings.ini", ( _KB238 ( $Newname )),"KB29=" & $Passwd22)
EndIf
$TF = _TempFile(@ScriptDir, "CRYP.", ".CRYP", 7)
FileMove($Newname,@ScriptDir & "\~Processing\" & ( _KB238 ( $Newname )))
FileChangeDir(@ScriptDir & "\~Processing")
$0 = FileFindFirstFile("*.rar")
If $0 = -1 Then
    Exit
EndIf
$1 = FileFindNextFile($0)
If @error Then Exit
_Crypt_EncryptFile($1,$TF, "",$CALG_3DES)
IniWriteSection(@ScriptDir & "\$~settings.ini", ( _KB238 ( $TF )),"KB28=" & $1)
FileChangeDir(@ScriptDir)
DirRemove(@ScriptDir & "\~Processing",1)
FileClose($0)
EndFunc

Func _unlock()
$encrypt = FileOpenDialog("Select your Encrypted archive.", @WindowsDir & "\", "CRYP files (*.CRYP)", 1 + 4 )
If @error Then
    MsgBox(4096,"","No File chosen")
    Exit
Else
    $encrypted = StringReplace($encrypt, "|", @CRLF)
EndIf

$KB383 = FileOpenDialog("Select your ini file.", @WindowsDir & "\", "Images (*.ini)", 1 + 4 )
If @error Then
    MsgBox(4096,"","No File chosen")
    Exit
Else
    $4 = StringReplace($KB383, "|", @CRLF)
    $KB3 = IniReadSection($4, ( _KB238 ( $encrypted )))
If @error Then
    MsgBox(4096, "",StringReplace($KB383, "|", @CRLF))
Else
    For $i = 1 To $KB3[0][0]
        $5 = $KB3[$i][1]
        _Crypt_DecryptFile($encrypted, $5, "",$CALG_3DES)
    Next
EndIf

FileInstall("C:\W7\UnRAR.exe",@TempDir & "\UnRAR.exe")
DirCreate(@ScriptDir & "\Data")
FileChangeDir(@TempDir)
RunWait("unrar e -y -p" & _StringEncrypt(0, IniRead ( StringReplace($KB383, "|", @CRLF), _
$5, "KB29", " " ), "", 7) & " " & @ScriptDir & "\" & $5 & " " & @ScriptDir & "\Data",@TempDir,@SW_HIDE)
EndIf
EndFunc

Func _KB238 ( $KB281 )
    If Not FileExists ( $KB281 ) Then Return 0
    $KB282 = StringSplit ( $KB281, '\' )
    Return $KB282[$KB282[0]]
EndFunc
Edited by xJSLRx

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Here's the link to UnRAR.exe.

you should already know how to get rar.exe

I've made a better version now that I can script fluently but I don't think any one's even interested.

Might post later after misc improves.

Edited by System238

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
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
Sign in to follow this  
Followers 0