4 Replies - 1357 Views - Last Post: 09 October 2012 - 10:59 AM Rate Topic: -----

#1 davers  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 07-April 11

Convert LDAP binary attribute returns weird characters

Posted 09 October 2012 - 07:24 AM

Hi Guys! I've been working on a tool to change a users attributes, and I'd like to be able to reset the password. I'm able to decode the attribute, it's binary, but it seems to be coded in some way. The below code does give me the values of other binary attributes, just not the password:

            PropertyValueCollection propCol = de.Properties["Password"];

            byte[] data = (byte[])propCol.Value;

            System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding();
            string str = enc.GetString((System.Byte[])propCol.Value);

            string hex = BitConverter.ToString(data);



So this attribute value: 10 09 B5 7B CD 23 D1 91 00 44 F3 B6 61 3A BE 2A 00
should decode to the digits, 22220, but it doesn't. I get these weird characters. Some look like a cross, or a triangle with a question mark. I've tried all the different encodings that I have available, UTF32, UTF7, ASCII, but nothing seems to work. Can anyone lend a hand?

Thanks for any help!

Dave

Is This A Good Question/Topic? 0
  • +

Replies To: Convert LDAP binary attribute returns weird characters

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3631
  • View blog
  • Posts: 11,327
  • Joined: 05-May 12

Re: Convert LDAP binary attribute returns weird characters

Posted 09 October 2012 - 10:07 AM

Are you sure those bytes are a text encoding of the password? Most modern secure systems don't actually store a password, but rather the results of a one way hash (and the salt used for the hash). This is to ensure that people can't just query the container the contains the passwords and call a function to reverse the encoding like you are trying to do. The one way hash forces the bad guy to try every combination until they get a value that matches the hash.
Was This Post Helpful? 1
  • +
  • -

#3 davers  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 07-April 11

Re: Convert LDAP binary attribute returns weird characters

Posted 09 October 2012 - 10:38 AM

Argh! That would mean I need to know what they used to encode it so I can decode it? Too much work as far as I'm concerned! :dontgetit:

Thanks for the reply Skydiver!!

Dave
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3631
  • View blog
  • Posts: 11,327
  • Joined: 05-May 12

Re: Convert LDAP binary attribute returns weird characters

Posted 09 October 2012 - 10:50 AM

The point of a one way hash is so that you can't decode it. You can't stick the output of the hash into another function and get th original input to the first function. Chances are that they used one of the well known hash algorithms: http://en.wikipedia....c_hash_function
Was This Post Helpful? 1
  • +
  • -

#5 davers  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 62
  • Joined: 07-April 11

Re: Convert LDAP binary attribute returns weird characters

Posted 09 October 2012 - 10:59 AM

Thanks again Skydiver!!

Dave
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1