Re: Determining the encryption used

From: Peter Kosinar (goober@ksp.sk)
Date: Thu May 11 2006 - 20:04:30 EDT


Hello,

> While doing a pen-test I came across a database with
> encrypted fields and I was curious to try and see what
> I would do with it.

Could you provide an example of such an (possibly) encrypted field?

> Is it possible to determine the encryption used by
> "looking" at the encrypted results or lenght ?

Sometimes. Very much depends on the structure of the data -- for example,
if all the "encrypted" values (in one column of the database) have the
same length, it might be some kind of hash, used for authentication
purposes. Some applications store their passwords hashed either using
crypt() or some variation of MD5; structure of the latter is quite
easy-to-recognize. It's also often quite helpful to find out what
application creates / uses those encrypted fields, it might provide some
clues as of what kind of encryption/hashing is used.

If nothing obvious appears at the first and second glance, it might be
useful to look if the values seem to have some additional structure -- for
example, are there some repeating patterns at the beginning/end? If so,
the values might represent some textual data, these are quite often
reduntant and repeating.

> I know that with Base64 it's pretty easy because of
> the "==" at the end.

This is not completely true, "=" characters are used as padding in Base64
encoding. If the length of the original text is a multiple of 3, there
won't be any ='s at the end, otherwise you should find one or two of them.

In general, if the field looks too much letter/number-ish, it's most
likely some kind of ASCII-armor used to store binary data while avoiding
problems with different encodings/codepages or such. I've also seen MD5
sums stored in a database in textual form (in general, fields consisting
purely of [0-9A-F] are usually just hexadecimal descriptions of some
other data).

> Also if there are any tools besides openssl that you
> found usefull to try all the cipher, consecutively
> with a passphrase/keyword against a file/string

Depending on the kind of cipher (if it is some kind of password-hash), you
might find tools like John the Ripper much faster for dictionary-style
attacks.

Peter

-- 
[Name] Peter Kosinar   [Quote] 2B | ~2B = exp(i*PI)   [ICQ] 134813278
------------------------------------------------------------------------------
This List Sponsored by: Cenzic
Concerned about Web Application Security? 
Why not go with the #1 solution - Cenzic, the only one to win the Analyst's 
Choice Award from eWeek. As attacks through web applications continue to rise, 
you need to proactively protect your applications from hackers. Cenzic has the 
most comprehensive solutions to meet your application security penetration 
testing and vulnerability management needs. You have an option to go with a 
managed service (Cenzic ClickToSecure) or an enterprise software 
(Cenzic Hailstorm). Download FREE whitepaper on how a managed service can 
help you: http://www.cenzic.com/news_events/wpappsec.php 
And, now for a limited time we can do a FREE audit for you to confirm your 
results from other product. Contact us at request@cenzic.com for details.
------------------------------------------------------------------------------


This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:55:56 EDT