Finally, it is out :). I can do it before new year.
The new things since beta2 are (not including bug fixes)
- HTTP digest authentication
- SIP protocol
Happy new year ;)
Update (4 Jan 2011):
Sorry, I did a mistake again in binary. I included the wrong openssl file ("libssl32.dll" instead of "ssleay32.dll"). If you have a problem when starting my app. Try to download it again.
Thursday, December 30, 2010
Thursday, December 23, 2010
Excel RC4 Encryption Algorithm
I played a wargame. There is a protected xls file. I could not find a free tool to break it. When I tried to use their trial tools, there is a instant recovery feature. I wonder how they do it. I decided to read the encryption algorithm. I knew the default Office 2003 encryption algorithm is RC4. After some searching, I found the Microsoft Document
- http://msdn.microsoft.com/en-us/library/dd907466%28v=office.12%29.aspx
- http://msdn.microsoft.com/en-us/library/dd905723%28v=office.12%29.aspx
The first link is how the RC4 key is generated and what is stored in xls file. The second link is what contents to be encrypted.
After understanding the Excel password, I code the python for testing the password test_xls_pass.py. Here is the important part.
"salt", "verifier", and "verifierHash" can be extracted from FILEPASS record in Excel file. Can you see it? The "real_key" is only 5 bytes (40 bits). If you can find this key, no need to use password. The key space of real_key is 240. It is possible to do brute forcing. But is it easier than brute forcing password?
Compare it to alphanumeric password case insensitive. The key space of 8 characters is 368 = (32+4)8 = (25 + 4)8 > 240.
Another problem of brute forcing real_key, rc4 is slow compared to md5. I tried it with my simple C code. I get about 800,000 key/sec with 1 thread on Intel Core2 Q8300 2.5GHz. It takes about 16 days with 1 thread to try the whole key space. With GPUs, real_key is possible to be cracked in a few minutes.
What can we do when we get the real_key? There is the tool named guaexcel. The demo version allows you to use any real_key to decrypt any Excel file.
MS Word is the same as MS Excel. Just change the stream name from "Workbook" to "worddocument" stream. Then use tool named guaword to decrypt the Word file.
PS: If I have time, I will optimize the code and release it for free :). But do not expect it to be fast as commercial one.
- http://msdn.microsoft.com/en-us/library/dd907466%28v=office.12%29.aspx
- http://msdn.microsoft.com/en-us/library/dd905723%28v=office.12%29.aspx
The first link is how the RC4 key is generated and what is stored in xls file. The second link is what contents to be encrypted.
After understanding the Excel password, I code the python for testing the password test_xls_pass.py. Here is the important part.
def gen_excel_real_key(pwd, salt):
h0 = hashlib.md5(pwd).digest()
h1 = hashlib.md5((h0[:5] + salt) * 16).digest()
return h1[:5]
def test_pass(pwd, salt, verifier, verifierHash):
real_key = gen_excel_real_key(pwd, salt)
key = hashlib.md5(real_key + '\x00\x00\x00\x00').digest()
dec = rc4_crypt(key, verifier + verifierHash)
if hashlib.md5(dec[:16]).digest() == dec[16:]:
print "valid pass"
else:
print "invalid pass"
"salt", "verifier", and "verifierHash" can be extracted from FILEPASS record in Excel file. Can you see it? The "real_key" is only 5 bytes (40 bits). If you can find this key, no need to use password. The key space of real_key is 240. It is possible to do brute forcing. But is it easier than brute forcing password?
Compare it to alphanumeric password case insensitive. The key space of 8 characters is 368 = (32+4)8 = (25 + 4)8 > 240.
Another problem of brute forcing real_key, rc4 is slow compared to md5. I tried it with my simple C code. I get about 800,000 key/sec with 1 thread on Intel Core2 Q8300 2.5GHz. It takes about 16 days with 1 thread to try the whole key space. With GPUs, real_key is possible to be cracked in a few minutes.
What can we do when we get the real_key? There is the tool named guaexcel. The demo version allows you to use any real_key to decrypt any Excel file.
MS Word is the same as MS Excel. Just change the stream name from "Workbook" to "worddocument" stream. Then use tool named guaword to decrypt the Word file.
PS: If I have time, I will optimize the code and release it for free :). But do not expect it to be fast as commercial one.
Tuesday, December 7, 2010
Use OllyDbg to find ROP gadgets
I just tried writing a exploit with ROP technique. When I searched a tool to help me finding gadgets, I found only Immunity Debugger with pvefindaddr.
But I never used it. I am lazy to learn it now (I will later). I knew msfpescan with regex option can help me but it is too difficult. Then I tried with OllyDbg. I found a nice feature to help me finding gadgets. Here what I found
There is a search for sequence of commands when right click on CPU windows. Then it shows a dialog for typing assembly.
In this search dialog, we can use special commands and keywords. Below are what I excerpt from OllyDbg help "Search for a sequence of commands"
- R8, R16, R32 for any 8, 16, 32 bit register respectively.
- CONST for any constant
- JCC for any conditional jump
- ANY n for any 0..n commands
"Search for sequence of commands" find only one block. It is so inconvenient for us to choose a gadget. So I will show only "Search for all sequence" (the second red line of the first pic).
Let try with common gadget used for pivoting esp. I put "add esp,CONST;ANY 6;ret" to search "add esp" in ntdll.dll (on my Windows XP SP3). Here the results.
Assume We are interested "add esp, 74". Just double click it, we will see the assembly block like above pic. Then we can check if it is usable. As the above assembly code, we can use it if eax is zero.
I think this feature is nice. But I can search in only one executable module at a time :(. If someone know how to search in all modules, please tell me.;)
But I never used it. I am lazy to learn it now (I will later). I knew msfpescan with regex option can help me but it is too difficult. Then I tried with OllyDbg. I found a nice feature to help me finding gadgets. Here what I found
There is a search for sequence of commands when right click on CPU windows. Then it shows a dialog for typing assembly.
In this search dialog, we can use special commands and keywords. Below are what I excerpt from OllyDbg help "Search for a sequence of commands"
- R8, R16, R32 for any 8, 16, 32 bit register respectively.
- CONST for any constant
- JCC for any conditional jump
- ANY n for any 0..n commands
"Search for sequence of commands" find only one block. It is so inconvenient for us to choose a gadget. So I will show only "Search for all sequence" (the second red line of the first pic).
Let try with common gadget used for pivoting esp. I put "add esp,CONST;ANY 6;ret" to search "add esp" in ntdll.dll (on my Windows XP SP3). Here the results.
Assume We are interested "add esp, 74". Just double click it, we will see the assembly block like above pic. Then we can check if it is usable. As the above assembly code, we can use it if eax is zero.
I think this feature is nice. But I can search in only one executable module at a time :(. If someone know how to search in all modules, please tell me.;)
Sunday, November 21, 2010
Bruter 1.1 beta2 is out
Same as title, it is out. The new things (since 1.1 beta1) are
- SSH use less secure algorithm for key exchange (little faster)
- Able to use big wordlist file but still <2GB
- Save/Resume testing in "Save/Load config" (I'm lazy to add a new menu)
- Option to iterate passwords for each username (Password First)
I planned to add a new protocol on this version. But I change my mind because I'm lazy :S.
Have fun :)
Note on 23 Nov 2010:
Sorry for my mistake. I created the wrong directory name and zip filename "Bruter_1.2_beta2" (version 1.2 O_o). The actual name must be "Bruter_1.1_beta2". Fixed it.
- SSH use less secure algorithm for key exchange (little faster)
- Able to use big wordlist file but still <2GB
- Save/Resume testing in "Save/Load config" (I'm lazy to add a new menu)
- Option to iterate passwords for each username (Password First)
I planned to add a new protocol on this version. But I change my mind because I'm lazy :S.
Have fun :)
Note on 23 Nov 2010:
Sorry for my mistake. I created the wrong directory name and zip filename "Bruter_1.2_beta2" (version 1.2 O_o). The actual name must be "Bruter_1.1_beta2". Fixed it.
Saturday, September 11, 2010
LEET MORE CTF 2010 write up - Lottery
This is the second and last challenge that I had time to play. I solved it :).
The challenge random 39 digits and give you a number of participant. You have to put the correct random number to win this lottery. When you put a wrong number, you get the correct random number.
I had put a lot of wrong number to see random numbers.
Here is the result when a number of participant is 391441 - 391447
I also tried to make the next 2 digits as another part that is increased by one. But I saw
Then I tried the diff of each digits in last part (last 33 digits). I found they (first 5 digits of last part) are changed like "(prev + x[i]) mod 10" or "(prev + x[i] +1) mod 10". It looks like a sum up of previous number. Then I tried to diff them.
Then, I used
When the game end, hellman told the solution in IRC. Here is what he said
"in lottery random number generator was seeded with number of participants, and word 'uniform' points to erlangs random uniform, so just use erlang to guess the number"
The challenge random 39 digits and give you a number of participant. You have to put the correct random number to win this lottery. When you put a wrong number, you get the correct random number.
I had put a lot of wrong number to see random numbers.
Here is the result when a number of participant is 391441 - 391447
756883670921640125823051707628843433985 756982681967192314311352115314173149185 757081693012744351683925071170856026113 757180704058296540172225478856185741313 757279715103848577544798434712868618241 757378726149400614917371390569551495169 757477737194952803405671798254881210369Here is the result when a number of participant is 391449 - 391455
757675759286057029266545161796893802497 757774770331609066639118117653576679425 757873781377161104011691073510259556353 757972792422713745847173836681529786369 758071803468265329872564437052272148481 758170814513817971708047200223542378497 758269825559370009080620156080225255425With these numbers, I saw a pattern. Let me added some white-spaces.
7568 83 670921640125823051707628843433985 7569 82 681967192314311352115314173149185 7570 81 693012744351683925071170856026113 7571 80 704058296540172225478856185741313 7572 79 715103848577544798434712868618241 7573 78 726149400614917371390569551495169 7574 77 737194952803405671798254881210369See it? The first part (4 digits) is decreased by one. The second part (next 2 digits) is increased by one.
I also tried to make the next 2 digits as another part that is increased by one. But I saw
7576 75 759286057029266545161796893802497 7577 74 770331609066639118117653576679425It is increased by 2.
Then I tried the diff of each digits in last part (last 33 digits). I found they (first 5 digits of last part) are changed like "(prev + x[i]) mod 10" or "(prev + x[i] +1) mod 10". It looks like a sum up of previous number. Then I tried to diff them.
681967192314311352115314173149185 - 670921640125823051707628843433985 = 11045552188488300407685329715200 693012744351683925071170856026113 - 681967192314311352115314173149185 = 11045552037372572955856682876928 704058296540172225478856185741313 - 693012744351683925071170856026113 = 11045552188488300407685329715200 715103848577544798434712868618241 - 704058296540172225478856185741313 = 11045552037372572955856682876928 ...I got about 4 numbers from diffing them. But there are only 2 that I got very often. They are
11045552188488300407685329715200and
11045552037372572955856682876928.
Then, I used
11045552188488300407685329715200as my magic number and used the pattern I found for guessing. After a few tries, I got
You are realy lucky!! Congratulations!! You win, send this WMcode to your bank: "C988EC4DC91EA4864FAA6B7D65030961B218D19CD96CF29DE28166F59B606158"I won the lottery ;)
When the game end, hellman told the solution in IRC. Here is what he said
"in lottery random number generator was seeded with number of participants, and word 'uniform' points to erlangs random uniform, so just use erlang to guess the number"
LEET MORE CTF 2010 write up - Oh Those Admins!
This challenge is SQL injection. The line of problem is (I cannot remember the exact column and table name)
$r = mysql_query("SELECT login FROM admin WHERE password='" . md5($_GET['password'], true) . "'");
Normally, web sites keep the password hash as hex string. But this challenge keep raw hash (binary 16 bytes) in database. Binary can be string. So To bypass login, the output of md5 has to look like' or 1=1#The above string is what I thought first. But it is too long. To make the brute forcing fast, the required output string should be short. After checking from MySQL doc, I could make it shorter. Here is the list what I found
'or 1# <== no need for space after single quote, any non-zero number is TRUE '||1# <== || is same as OR, no need for space after ||Before writing the code for brute forcing, I remembered I can put non-printable characters in password using '%XX'. So 1 byte can be 256 values. No charset.
My code for brute forcing is http://pastebin.com/2xMG9rKi.
Ran it about 20 minutes on my slow windows pc, then got it.
password: 34b854c8 password: %34%b8%54%c8 result: c13e807082277c7c36231ed0dd34a863 result: ม>€p‚'||6# ะ4จc
Note: on linux, compile with "gcc -O2 -lssl -o prog prog.c" Note: If you want to see result from my program quick, run it with "./prog 4 4 200"
Submit it from url bar
url?password=%34%b8%54%c8,then got the real admin hash. It is "071CC0720D0ABD73F61A291224F248D6". But I could not reverse admin hash :( so poor me. When searched in google, I found it in hashkiller but it was not solved.
Below is not my solution
Before finished this post, I found other 2 writeups of this challenge. Very nice solutions. They found shorter SQL injection string.
First is http://cvk.posterous.com/sql-injection-with-raw-md5-hashes. The SQL injection string is
'||'Here is the modification of my code: http://pastebin.com/ThxBESPs. Got the result in a few minutes.
password: 2c55c819 password: %2c%55%c8%19 result: 3157e727097c7c27342e7dc2729f75ed result: 1W็' ||'4.}ยrŸuํSecond is http://blog.nibbles.fr/?p=2039. The SQL injection string is
'='Here is the modification of my code: http://pastebin.com/w5E54PNz. Got the result in a second.
password: 22a80f password: %22%a8%0f result: 047f1f9ed77f467a273d279d8e521422 result: žืFz'='ŽR "
Thursday, August 12, 2010
Hide OpenSSH Debian Distribution Version on Ubuntu
From the previous post about OpenSSH banner on Ubuntu, I just found the easy method to hide the distribution version in Ubuntu 10.04 by chance.
The Ubuntu 10.04 has the new option for sshd_config. That is "DebianBanner". You just have to add "DebianBanner no" line (without quotes) into sshd_config, then restart it. Your OpenSSH banner will change from "SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu3"
to
"SSH-2.0-OpenSSH_5.3p1"
Normally, Ubuntu ports code from Debian. So I checked the option in Debian as well. I found the option in Debian 6 as well.
PS: The option has been added since Ubuntu 10.04.
The Ubuntu 10.04 has the new option for sshd_config. That is "DebianBanner". You just have to add "DebianBanner no" line (without quotes) into sshd_config, then restart it. Your OpenSSH banner will change from "SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu3"
to
"SSH-2.0-OpenSSH_5.3p1"
Normally, Ubuntu ports code from Debian. So I checked the option in Debian as well. I found the option in Debian 6 as well.
PS: The option has been added since Ubuntu 10.04.
Subscribe to:
Posts (Atom)



