PortalForumsAwardsSearchClubsDonateRegister Today!



Go Back   Sakurahana > Sakura's Avenue > Tech Department > File Encryption

Tech Department
Discuss latest technology here, anything related to Tech topics, news, about softwares, codes, etc. Source providing the news about gadgets, technology, phones, mobile, news, reviews and more. No download links allowed here, No Warez!

Post New Thread  Reply
 
Thread Tools Display Modes
Old 08-28-2008, 06:06 PM   #1 (permalink)
風紀委員
 
xibo's Avatar
 
Group: Takara
Join Date: Jul 2008
Location: my dream world
Posts: 3,281
Gender: Male Baka
Reputation Points: 184
xibo has a spectacular aura aboutxibo has a spectacular aura about
Guideicond File Encryption

My first tutorial

Bit background:

There are circumstances where people might want to encrypt one or multiple files, or even a complete filesystem, most probably in order to prevent thirds to access your data. Much unlike preventing unwanted people to get your data by removing them from their ability to read the file per file access permissions encrypting will secure the file even if the unwanted user managed to overcome user management restrictions, commonly by abusing a bug or sniffing the network, though just stealing the hard disk containing the file is also an quite effective option.
If we consider the situation that someone unwanted already has the file he shouldn t be having, the only way to prevent him to make use of it is by having changed the data the file contains. Two options exist to acchieve this efficiently, namely
  1. (en)coding
  2. (en)crypting
the files.
A coding is the application of a logic function to the data, e.g. inversing the data ( each bit 'set' (=1) becomes unset(=0) and the other way around ) or just adding a certain value to each byte, word, or whatever .
A crypt is the application of an encoding that uses a or multiple keys to modify the data.
Both will immediately render the data useless to process that is expecting unsecured input, but encrypting is more secure then encoding...
different encoding and encryption algorithms have been developed in the past that are differently well in preventing to be brute forced ( brute force = generating any permutation and try if it is correct, generally the only approach to crack passwords ). Usually en- and de-coding happens transparently by some hardware device ( i.e. military communications between ww1 and the first iraq war were encoded ). However, the problem with coding is that once the algorithm is known to the 'spy', he can just apply it to decode the data.
With encrypted, not only the algorithm the original data was encrypted with has to be known , but also the key it was encrypted with. Encryption nowadays takes place in computer networks, namely ipv6 internet ( since it prevents the secret service from reading data unless they catch the complete transmission INCLUDING the crypt key that is transmitted in forward ipv6 is not widespread yet ), but also in most other kinds of telecommunication, too. The weakness of encryption compared to encoding is that encryption requires more complex 'programmable' logic - while basic encoding can be done with a chain of 2 transistors (=1 ic) the even most basic encrypt will require several thousands...

rather more practice now

Ok, since i saw people thinking to have security problems with their files on MU over here, and - in fact more by - [Only registered users can see links. ] , i wrote this useless programm that will apply __crypt_name_[1] on any files you give it via parameter. keep in mind that you canNOT use the files while they are encrypted.

Spoiler for vista 32 binary

Spoiler for source code


Professional ( = costs money in theory ) software to do this job exists and is alot better but this one is for free

the program is command line only, which means you have to execute it via ms-dos command line or from a xterm, and name the files to be en or decrypted by arguments.
since the algorithm ( like, in fact all data encryption algrorithms ) is bijective ( = reversible ) it doesn t play a role whether you apply the crypt with the encoding or decoding algorithm, however you always have to use the opposite one in order to restore the data.

how to call:
Code:
# i will refer to the exe with encrypt ( the exe part can be dropped on windows and didn t ever exist in *x to begin with )
crypt --encrypt --passwd=test textfile.txt
# will encrypt the file textfile.txt in the same directory with the key 'test'
crypt --decrypt --passwd=test textfile.txt
# will decrypt the file textfile.txt in the same directory with the key 'test'.
# 
#
crypt --encrypt --passfn=test.txt textfile.txt image.svg
# will encrypt textfile.txt and image.svg in the same directory with the key that is readt out of test.txt (the key is ANY data in the file, it does not require to be text - in fact i tested it with an png image as key). it s still not smart to store passwords in text files though ....
crypt --decrypt --passfn=test.txt textfile.txt image.svg
# again, textfile.txt and image.svg will be decoded, with the content of test.txt
crypt --verbose blah
# will do the same as crypt blah but give more output
crypt --version
# is a very important functionallity, that will print my name on the screen and exit afterwards >_<
crypt --help
# will print all options and exit afterwards
Spoiler!


once again, the file is NOT useable while encrypted, and the key is NOT stored anywhere. if you forget the key you can go ahead and delete the file as it s not more then disk-space-taker any more.
the files given as input will be overwritten with their encrypted counterparts ( they have exactly the same size and by overwriting the originals the ability to restore the original files with fsck or chkdsk is removed ) without farter questioning. if you manage to cause the encryption program to encrypt itself delete it and download/compile again.
... again, "encrypt" and "decrypt" are just function names. you can use the "decrypt" function to encrypt something, but then you will have to use the "encrypt" one to decrypt it again.

Foreseeable Questions:

Q: I typoed on the password and the file got en/decrypted with the wrong key. what shall i do?
A: Since the algorithms are bijective, de/encrypt ( the opposite of what you just did ) with the TYPOED key, and use the correct one afterwards

Q: Someone crypted something with a non-ascii unicode key like 'パッスウオードなのだ!' but my dos command line doesn t let me type that in
A: that is why there is the ability to read passwords out of files. Keep in mind the files have to be encoded the same way as the key that was used to encrypt the data ( 'パッスウオードなのだ!' can be sjis, jis7, utf8 and utf16 ).

Q: I forgot to supply a key but the files got encrypted nevertheless, why didn t it abort?
A: It's not a bug, it's a feature! If you don t supply a key or the file that is supposed to contain it can t be opened, 0 ( zero ) is used as key, which causes the first octet in the file to remain same, the second to be incremented by 1, the next by 2, ... which is quite obvious, therefore supply a key >.<
Decrypt it without a key again to remove the encode.

Q: Whats the maximal length of a key?
A: (2^16) - 10 as argument, anything that can be loaded into your memory when loading it from a file. ~2^16 is probably more then any key you want to type by hand anyway, even if non-ascii characters are two and some kanji 3 octets long

Q: What characters are allowed in the keyword?
A: While reading out of a file *everything* is allowed. When given via argument it has to be ONE argument, so no spaces, tabs, linebreaks, cariage returns or stuff like that. See the --help help >_^

Q: RAR files also offer the ability to encrypt their content, however i can still open the rar and see the content without knowing the key. Why doesn t your programm offer the same functionality for e.g. ZIP or BZ2 files?
A: because i encrypt *all* the file, including the headers or signatures. ZIP and BZ2 formats offer encryption by themselves so if you need to be able to browse the content without the key use those instead

Q: What s the maximal file size of a file to be encrypted?
A: That depends highly on what you have running in background. I think it's safe to say half your system's RAM is the maximal size - data is read completely into ram and only started to be written again once it got en/decrypted.

Q: How long can i expect the encryption to take?
A: O(n) in theory, in practice my (raided ak1000s@ich9 running ntfs) system encrypts a gigabyte sized file on vista 64 sp1 in 17 seconds, and in 11 seconds on linux 2.6.26, but that is highly limited to the speed of your disks.

Q: How do i encrypt a whole directory at once?
A: Directories cannot be encrypted without the filesystem supporting it. Directories are virtual files. If you encrypt a directory the filesystem driver can t browse it any more and the next run of fsck/chkdsk will either regenerate the original directory or delete the directory with all thereby illegal-becoming data ( it's contents ). If you require a tree structure use TAR or a similar archive format to put all files in first.

So... Spam comments and crits ||>_<//

[1] __crypt_name_ it's a quite famous basic encryption algorithm named by a french mathematician, but i forgot his/her name

EDIT:

hmmm... it didn t become a tutorial -.-


2009-01 uploads:
☆akasaka
☆haruka naru toki no naka de - hachiyoushou
☆haruka naru toki no naka de - kurenai no tsuki
☆haruka naru toki no naka de - maihito yo
☆telepathy shoujo ran

★all of marimite that gets released by chihiro
★all of zoku natsume yuujinchou that gets released by bss
☆akichan once the last two episodes get subbed

Last edited by xibo; 08-28-2008 at 06:31 PM..
 
Reply With Quote Scroll up!
Reply Post New Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

All times are GMT -7. The time now is 03:43 PM.

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Sakurahana.com Anime Network - Anime, Manga, and Hentai Discussion and Downloads.
Creative Commons License
Sakurahana's Skin by Misuzu is licensed under a Creative Commons License 3.0 .
Sakurahana.com is a nonprofit organization
40 41 42 43 44 45 46 47 49 50 51 52 53 54 55 56 57 58 59 62 63 64 65 70 71 72 73 74 75 76 77 78 79 80 82 83 84 85 87 91 93 94 95 96 97 99 100 101 102 103 104 105 107 108 109 110 111 112