Following on from this, I'm going to spend some time trying to work out how they could be decrypted.
To start, refer to the encryption formula again:
Sum (char_position(char XOR 0x96))
Sadly, I never managed to finish my maths A-level, let alone a degree, so I am not a maths wizard by any means. Trying to figure out a way to reverse this using a simple formula is not proving easy. The best I could come up with was:
n = p1(c1 XOR 150) + p2(c2 XOR 150) + p3(c3 XOR 150)... up to p15(c15 XOR 150)
c = char, p = position, n = final result
Frankly, I have absolutely no idea how to get px or cx when you only have n. I don't even know if it can be reversed (I would guess not without either p or c). Any suggestions are most welcome!
So this means that I am not going to be able to decrypt the password - the only choice I have is to break the password.
Thinking again about the encryption routine, it is obvious that there are severe weaknesses in the encryption.
If we consider that all passwords shorter than 15 characters have filling characters from the string "BrianDavidHarry" appended to them before encryption.
If we encrypted the filling characters to calculate their values at each particular password length, we can remove this portion from the coded value of a password to ensure we are only left with the coded portion of the password that represents the actual password, thus:
Pw Length | Coded Portion | Code Value |
0 | BrianDavidHarry | 28304 (0x6E90) |
1 | BrianDavidHarr | 28012 (0x6D6C) |
2 | BrianDavidHar | 27657 (0x6C09) |
3 | BrianDavidHa | 27074 (0x69C2) |
4 | BrianDavidH | 25959 (0x6567) |
5 | BrianDavid | 24997 (0x61A5) |
6 | BrianDavi | 23493 (0x5BC5) |
7 | BrianDav | 21539 (0x5423) |
8 | BrianDa | 19826 (0x4D72) |
9 | BrianD | 17521 (0x4471) |
10 | Brian | 15561 (0x3CC9) |
11 | Bria | 12783 (0x31EF) |
12 | Bri | 9773 (0x262D) |
13 | Br | 6388 (0x18F4) |
14 | B | 3180 (0x0C6C) |
15 | 0 (0x0000) |
Consider our current administrator password "adad", which is coded to 0x6DAF (28079). For now, I will assume that I know the length of the password, but not the contents.
If I remove the filler coded portion of the password (which will be 25959 for a length 4 password), I am left with a value of 0x0848 (2120).
Double checking, I know that this is the correct value by working out how it would be encrypted:
Pos | Char Code | Code Value | Total |
1 | 65 (0x41) 'A' | 215 * 1 | 215 |
2 | 68 (0x44) 'D' | 210 * 2 = 420 | 635 (215 + 420) |
3 | 65 (0x41) 'A' | 215 * 3 = 645 | 1280 (635 + 645) |
4 | 68 (0x44) 'D' | 210 * 4 = 840 | 2120 (1280 + 840) |
So I know that 2120 is the correct value of the password portion of the code, but I have no idea what the actual characters are in it.
This doesn't actually matter though. I am not trying to decipher the original password, just figure out what I need to type into the login screen in SourceSafe to make it appear that I am typing in that users password.
For example, consider what happens if I enter the code 'KSNB':
Pos | Char Code | Code Value | Total |
1 | 75 (0x4B) 'K' | 221 * 1 | 221 |
2 | 83 (0x53) 'S' | 197 * 2 = 394 | 615 (221 + 394) |
3 | 78 (0x4E) 'N' | 216 * 3 = 657 | 1280 (615 + 657) |
4 | 66 (0x42) 'B' | 212 * 4 = 848 | 2120 (1272 + 848) |
No way! KSNB is the same password code as ADAD?!
Upon brining up SourceSafe Admin and tapping in KSNB I am very pleased to see that I am logged in as administrator.
I can even change the password for the admin user, using KSNB as the old password and whatever I feel like as the new one!
This is good news, because it means that if I obtain the coded portion of a password, I can work out a sequence of characters that will generate that code and it will code to the the same value as the real password.
However, how am I going to obtain the coded portion of a password when I don't know the length of the password?
Finding the length of the password is going to prove to be more troublesome, I'm sure...
1 comment:
Before append "BrianDavidHarry", password is converted to a big letter. (aaaa→AAAA)
Post a Comment