Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

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


  • Please log in to reply
103 replies to this topic

#1 Ward

Ward

    Prodigy

  • Active Members
  • PipPipPip
  • 162 posts

Posted 28 July 2008 - 04:34 PM

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)
Attached File  SHA1_MD5_RC4_BASE64_CRC32.zip   7.95KB   2267 downloads
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.
Attached File  SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip   9.31KB   1485 downloads
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.
Attached File  SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip   9.39KB   1097 downloads
2008/09/27 Update Note:
Optimize machine code in _Base64Encode() and _Base64Decode().
Fix _Base64Encode() crash problem. Thanks to trancexx.
Attached File  SHA1_MD5_RC4_BASE64_CRC32_XXTEA.zip   9.35KB   12863 downloads

Edited by Ward, 26 September 2008 - 08:43 PM.








#2 spyrorocks

spyrorocks

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 728 posts

Posted 28 July 2008 - 08:18 PM

VERY nice.

This will come in very handy to me.

#3 wraithdu

wraithdu

    this noise inside my head

  • MVPs
  • 2,413 posts

Posted 29 July 2008 - 01:34 AM

Very nice!

#4 rasim

rasim

    Gray Scripter

  • Active Members
  • PipPipPipPipPipPip
  • 1,708 posts

Posted 29 July 2008 - 06:11 AM

Ward
Very useful! Thank you! :P
OS: Windows XP SP3, AutoIt version: 3.3.0.0Posted Image My Projects: Free_Resources | Splitter | wgetGUI | UnRARIt | USBMon | CDROM-Control | Volume Serial Changer | WinTrayPosted Image My UDFs: _ScreenSetting | ListView_Progress | ContextHelp | ToolTip_UDF | UnRAR | Zip32 | BassMod | ShellTreeView | GuiHotKey | 7ZipPosted Image My Examples: TrayIcon_Click | SystemTray_Refresh | _ListView_Sort | CPUmonLike above scripts? Please rate the topic Posted Image

#5 Lazycat

Lazycat

    Coding cat

  • MVPs
  • 1,174 posts

Posted 29 July 2008 - 07:30 AM

Thanks fot this things done, especially for MD5 and BASE64!
Koda homepage (http://www.autoitscript.com/fileman/users/lookfar/formdesign.html) (Bug Tracker)My Autoit script page (http://www.autoitscript.com/fileman/users/Lazycat/)

#6 JRSmile

JRSmile

    MCSE 2012R2

  • Active Members
  • PipPipPipPipPipPip
  • 461 posts

Posted 29 July 2008 - 07:43 AM

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:-)

#7 tehhahn

tehhahn

    Seeker

  • Active Members
  • 11 posts

Posted 29 July 2008 - 11:08 AM

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"

#8 SkinnyWhiteGuy

SkinnyWhiteGuy

    Feed the bunny!

  • Active Members
  • PipPipPipPipPipPip
  • 421 posts

Posted 29 July 2008 - 01:05 PM

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.

#9 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 29 July 2008 - 04:20 PM

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 :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#10 ptrex

ptrex

    Universalist

  • MVPs
  • 2,420 posts

Posted 31 July 2008 - 02:14 PM

@Ward

This is REAAAALLY fast !! :P

Very nice.

Thanks

regards

ptrex

#11 WeMartiansAreFriendly

WeMartiansAreFriendly

    Where's the kaboom?

  • Active Members
  • PipPipPipPipPipPip
  • 1,245 posts

Posted 31 July 2008 - 02:46 PM

That's just awesome. The functions are amazingly small too.

Maybe you could implement more algorithms just for fun (suggested by tehhahn, and SkinnyWhiteGuy) ?
Posted ImageDon't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

#12 Ward

Ward

    Prodigy

  • Active Members
  • PipPipPip
  • 162 posts

Posted 02 August 2008 - 04:16 PM

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.

#13 Ward

Ward

    Prodigy

  • Active Members
  • PipPipPip
  • 162 posts

Posted 02 August 2008 - 04:29 PM

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.

#14 smartee

smartee

    Hippies.They're everywhere.

  • Active Members
  • PipPipPipPipPipPip
  • 661 posts

Posted 02 August 2008 - 09:07 PM

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

#15 Ward

Ward

    Prodigy

  • Active Members
  • PipPipPip
  • 162 posts

Posted 03 August 2008 - 06:21 PM

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.

#16 mikeytown2

mikeytown2

    Polymath

  • Active Members
  • PipPipPipPip
  • 212 posts

Posted 03 August 2008 - 07:48 PM

Sweet Code!!!

Using the old Base64 code it took 6.344 seconds to encode a 1.3mb file on my computer. Using this it took 0.092 seconds.
:P Well done!

#17 slayerz

slayerz

    Prodigy

  • Active Members
  • PipPipPip
  • 160 posts

Posted 04 August 2008 - 06:45 AM

Good job Ward, it' really fast. Thanks 4 sharing :P
AUTOIT I'm lovin' it!

#18 spyrorocks

spyrorocks

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 728 posts

Posted 06 August 2008 - 03:02 AM

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, 06 August 2008 - 03:39 AM.


#19 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 581 posts

Posted 06 August 2008 - 09:21 AM

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 :

  • Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here

#20 SxyfrG

SxyfrG

    Adventurer

  • Active Members
  • PipPip
  • 129 posts

Posted 07 August 2008 - 03:13 AM

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




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users