Jump to content

MD5,SHA1,CRC32,RC4,BASE64,XXTEA machine code version


Ward
 Share

Recommended Posts

Thanks to Lazycat's great idea. He told us how to use the CallWindowProc API to run machine code.

So I wrote some codes in Sphinx C--, and run them in AutoIt.

 

Here are MD5, SHA1, CRC32, RC4, and BASE64 algorithm in the attachment. (My CRC32 Code is a bit faster then Lazycat's version)

SHA1_MD5_RC4_BASE64_CRC32.zip

If someone needs other algorithm, please let me know, and I will try my best.

If you are looking for SHA2 or AES, here and here.

 

2008/08/02 Update Note:

Corrected Block TEA (XXTEA) block cipher is added. Take a look at Wikipedia for detail.

SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip

2008/08/24 Update Note:

Add a parameter $LineBreak to _Base64Encode(). This function will break output line in every 76 characters by default. Thanks to trancexx.

SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip

2008/09/27 Update Note:

Optimize machine code in _Base64Encode() and _Base64Decode().

Fix _Base64Encode() crash problem. Thanks to trancexx.

SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip

Edited by Ward

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Link to comment
Share on other sites

Marvelous. *thumbs up*

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

Great functions, Ward! Thank you very much!

I have one question: The Base64 and the RC4 functions do return the same hashes. I am not an expert and do not have very much knowledge about cryptography, but is that correct? Do Base64 and RC4 base on the same algorithm, or what?

Some more algorithms you (maybe) want to implement:

"MD2", "MD4", "SHA256", "SHA384", "SHA512", "HAVAL128", "HAVAL160", "HAVAL192", "HAVAL224", "HAVAL256", "GHOST", "TIGER128", "TIGER160", "TIGER192", "RIPE-MD128", "RIPE-MD160", "CRC16", "ARC-CRC"

Link to comment
Share on other sites

Thanks for this Ward, I have been playing with translating a lot of these functions to regular AutoIt Code, but this solution is faster, and works just as well. I may continue playing with mine just to learn how they all work on the inside.

As a reference, the sourceforge project rehash has all the hashing algorithms you posted, as well as several other good ones, in C++ code, for you to look at. Wasn't sure how the brand of C you used would compare with these, but from what I've seen of the code, it should be very easy to translate it and use it for similar purposes.

Link to comment
Share on other sites

oh man was dreaming of it. How did you get the machine code version ?

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

Great functions, Ward! Thank you very much!

I have one question: The Base64 and the RC4 functions do return the same hashes. I am not an expert and do not have very much knowledge about cryptography, but is that correct? Do Base64 and RC4 base on the same algorithm, or what?

What did you mean "return the same hashes"?

Base64 and RC4 have different functions. Base64 is an scheme to encode binary data to ASCII string, however, RC4 is a stream chiper to encrypt your data with a private key.

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Link to comment
Share on other sites

oh man was dreaming of it. How did you get the machine code version ?

You can find a lot of source code in C about these algorithm, but almost all of them need some modifications to be used. The biggest problem is you can't use the static reference. So some assembly knowledge is very helpful.

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Link to comment
Share on other sites

nice script and all but how can i make a standalone app to check its own MD5?

You can add the MD5 hash to the end of the exe. When you check the hash, omit the last 16 bytes.

If you worry about it is too easy to be broken, maybe RC4 or XXTEA can be use to encrypt the hash.

新版 _ArrayAdd 的白痴作者,不管是誰,去死一死好了

 

Link to comment
Share on other sites

Is it just me, or do some of these functions like sha1 crash on windows server 2003?

EDIT: Yes, I am right, they all crash on windows server 2003. Tested using current release of autoit and tested using newest beta, they all crash.

WARD, or someone else with access to server 2003, id really appreciate it if you could fix this.

Edited by spyrorocks
Link to comment
Share on other sites

it takes the machine code from a compiled C-- program. C-- is an old language so maybe the machine code generated can't be interpreted by win2003 and more.

-- Arck System _ Soon -- Ideas make everything

"La critique est facile, l'art est difficile"

Projects :

[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list]
Link to comment
Share on other sites

This is uber awesome Ward! :P

You know what would be an awesome addition? Some more encryption algo's :o

AES-256 (rijndael), Blowfish, Triple DES and any others you feel comfortable getting the machine code for :P

My scripts:AppLauncherTRAY - Awesome app launcher that runs from the system tray NEW VERSION! | Run Length Encoding - VERY simple compression in pure autoit | Simple Minesweeper Game - Fun little game :)My website

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...