Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 41 guests and 1 member online
 
Advertisement

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Programmingarrow is it possible to reverse engineer a Java hash.
EH-Net
May 18, 2013, 01:44:41 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: is it possible to reverse engineer a Java hash.  (Read 4825 times)
0 Members and 1 Guest are viewing this topic.
wlandymore
Newbie
*
Offline Offline

Posts: 34


View Profile
« on: April 11, 2012, 10:13:29 AM »

Well it's probably possible, but I have an applet that is asking for a 6 digit password and then performing a function if the password is correct. I've been looking through the code (someone else wrote it) and I have found a hash in there around the 'passwordField' variable, etc.

S(aGd0ci0jNG9wc2d1dmRmaSY7MCswLURpaXV6Yik=)

Because this is just a simple 6 digit password it has to be a static value, so I figured the password has been hashed to keep it from appearing in the code as plain text. However, is there a way to reverse engineer that?
Logged
ajohnson
Recruiters
Hero Member
*
Offline Offline

Posts: 1056


aka dynamik


View Profile WWW
« Reply #1 on: April 11, 2012, 10:25:27 AM »

Since you have the code, you should be able to see what operations are being performed on the password that's submitted. Just write a loop from 000000 to 999999 that performs those same operations, compares that with the value you have, and prints out the value if there's a match. Of course, that is assuming what you posted is indeed the value that's used to validate the password.
Logged

WIP: GCFA | www.infosiege.net | @infosiege

The day you stop learning is the day you start becoming obsolete.
unicityd
Full Member
***
Offline Offline

Posts: 156

Bored IT Manager, Crypto Nerd


View Profile WWW
« Reply #2 on: April 11, 2012, 10:48:28 AM »

You need to know what hash algorithm was used.  Once you know that you can brute force it with something like this:

String realhash = \    
    "S(aGd0ci0jNG9wc2d1dmRmaSY7MCswLURpaXV6Yik=)";
for (Integer x=0; x<1000000; x++)
{
    String mypass = String.format(%06d", x);
    String myhash = hash(mypass);
    if myhash.equals(realhash)
    {
        System.out.println("The password is " + mypass);
    }
}

My syntax may be a little off (I'm not a Java programmer), but that code shows essentially what you need to do.
Logged

BS in IT, CISSP, MS in IS Management (in progress)
wlandymore
Newbie
*
Offline Offline

Posts: 34


View Profile
« Reply #3 on: April 11, 2012, 01:46:06 PM »

Hey guys,

Thanks for the ideas.

Yeah, I'm not a java programmer either which is why I'm finding it so hard. The code they have here is also very non-descript so I can see it making the box that has the numbers 0-9 and then the reference to the password field, but everything else is basically nameless variables. When I decompile the thing I can see SHA1-digest in a couple of spots....
Logged
wlandymore
Newbie
*
Offline Offline

Posts: 34


View Profile
« Reply #4 on: April 11, 2012, 01:52:09 PM »

it looks like the hash would be without the brackets as well. That kind of hash should be 40 chars I think so if the brackets were taken out of the original and just having the stuff between them you get:

aGd0ci0jNG9wc2d1dmRmaSY7MCswLURpaXV6Yik=

And that's the 40. Just need to reverse it....
Logged
ajohnson
Recruiters
Hero Member
*
Offline Offline

Posts: 1056


aka dynamik


View Profile WWW
« Reply #5 on: April 11, 2012, 02:03:28 PM »

Creating hashes that are not reversible and don't collide are the main objectives of a quality hashing algorithm. There's not going to be a simple way to reverse it.

You need to take a trial-and-error approach as I stated earlier and unicityd provided an actual example for.

Edit: Also, that appears to be base64 encoded, and it can be successfully base64-decoded. That's why you need to understand what is being done with the password string before you can code a comparison mechanism.
« Last Edit: April 11, 2012, 02:16:00 PM by ajohnson » Logged

WIP: GCFA | www.infosiege.net | @infosiege

The day you stop learning is the day you start becoming obsolete.
wlandymore
Newbie
*
Offline Offline

Posts: 34


View Profile
« Reply #6 on: April 11, 2012, 02:16:55 PM »

Okay, thanks for the help.

I wasn't really under the impression it would be 'easy' but at least what you guys have given me helps to narrow down the focus of my efforts.

Thanks again.
Logged
unicityd
Full Member
***
Offline Offline

Posts: 156

Bored IT Manager, Crypto Nerd


View Profile WWW
« Reply #7 on: April 11, 2012, 04:49:59 PM »

The hash you pasted in is too long for SHA-1 and too short for SHA-256.  Please double-check it and let me know if it's right.  I'm curious.

Logged

BS in IT, CISSP, MS in IS Management (in progress)
cd1zz
Hero Member
*****
Offline Offline

Posts: 561


View Profile WWW
« Reply #8 on: April 14, 2012, 01:10:19 PM »

Are you sure its a hash and not just base64 encoded? That looks very base64ish.  Decoded to text =

hgtr-#4opsguvdfi&;0+0-Diiuzb)
Logged

wlandymore
Newbie
*
Offline Offline

Posts: 34


View Profile
« Reply #9 on: April 17, 2012, 01:00:09 PM »

yeah, I've been messing around with this and I used a base64 to hex converter and got:

307FD8658A395B5F103654DE62181973A0F89D45ED71E4B3E77C1B58F9417B91C2E902E6E682D692188BDF64C068CF69C5B94230B64608E7ABB09A976CD6DC8CFA0A5766EF20CEAF2BCDE0EE55899983F6D61EAF3E6E28A749597DEDA0AB2DF5

Then I was trying something like padBuster which seemed to be making some progress but never finishes. It says it's decrypting some bytes but never makes it to the end.
Logged
wlandymore
Newbie
*
Offline Offline

Posts: 34


View Profile
« Reply #10 on: April 17, 2012, 05:22:29 PM »

hgtr-#4opsguvdfi&;0+0-Diiuzb) ... not a whole lot to go on. Smiley

I've been hunting through the class files to see if I can figure out how it got to that point so I can reverse it from there....
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.079 seconds with 23 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Advertisement

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.