• 0

[VB.NET] Encrypting password in MD5


Question

I'm working on an Oscar client.. basically, I send the server a request for an "auth key" and the server sends the "auth key" which should be used to encrypt the password in MD5.

(to server) auth key please!

(to client) heres your auth key (in decimal): 50 54 49 50 54 48 55 57 55

(to server) here's my encrypted password: xxxxxxxxxx (how do i get this?)

Because there are no official Oscar protocol specs, I don't understand how I'm supposed to use MD5 to encrypt the password with this "auth key".

The reference I'm looking at is here: http://iserverd1.khstu.ru/oscar/snac_17_02.html

  Quote
You'll need password (note: I have that), authkey from SNAC(17,07) (note: I have that) and RFC 1321 md5 routines:

  #define AIM_MD5_STRING "AOL Instant Messenger (SM)"

  /* first we need md5-hash of our password */

  md5_init(&state);

  md5_append(&state, (const md5_byte_t *)passwd, strlen(passwd));

  md5_finish(&state, (md5_byte_t *)pass_hash);

  /* calculate md5-hash to send to server */

  md5_init(&state);

  md5_append(&state, (const md5_byte_t *)authkey, strlen(authkey));

  md5_append(&state, (const md5_byte_t *)pass_hash, sizeof(pass_hash));

  md5_append(&state, (const md5_byte_t *)AIM_MD5_STRING, strlen(AIM_MD5_STRING));

  md5_finish(&state, (md5_byte_t *)auth_hash);

  /* Now we ready send to server auth_hash array (16 bytes long) */

Obviously, this is in C (or c++ .. i dont know).. but appearantly, that's how you create the end result, but I can't make heads or tails of it.. how would I do it in vb.net?

Link to comment
https://www.neowin.net/forum/topic/240845-vbnet-encrypting-password-in-md5/
Share on other sites

5 answers to this question

Recommended Posts

  • 0

An oscar client? You are a brave my friend.

Public Shared Function MD5(ByVal stringIn As String) As Byte()
     ' You will need to make sure this is the encoding the server is expecting
     Dim bytesIn() As Byte = System.Text.Encoding.ASCII.GetBytes(stringIn)
     Dim bytesOut() As Byte = New System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(bytesIn)
     Return bytesOut
End Function

Remember MD5 isnt encryption, it's just a one-way hash algorithm.

  • 0

I was expecting a function that took two parameters (password, authkey).. for the most part, I couldve come up with that.. what I didnt understand in the original code was appending the authkey and password hash (as opposed to just concatenating the two strings), and how that changed the result.. so this doesnt help too much, but thanks anyway :) If you know how to do this though with appending, it will help a lot :yes:

do you have experience with the oscar protocol?

  • 0

Ah I see, you are going to need to do something like:

Dim passwordBytes() As Byte = MD5(myPassword)
Dim authBytes() As Byte = ' However you get this
Dim sendBytes(passwordBytes.Length + authBytes.Length - 1) As Byte
Array.Copy(passwordBytes, 0, sendBytes, 0, passwordBytes.Length)
Array.Copy(authBytes, 0, sendBytes, passwordBytes.Length, authBytes.Length)

  • 0

I don't know if this is correct. I'm not familiar with md5_append. Does it hash what's being stored?

Please note that this is just an example, not a full solution. I don't do those, unless I'm getting paid. ;)

	 Dim authkey_hash As Byte() =  {50, 54, 49, 50, 54, 48, 55, 57, 55}
 	 Const AIM_MD5_STRING As String = "AOL Instant Messenger (SM)"
 	 Dim data As Byte() = ASCIIEncoding.ASCII.GetBytes(textBox1.Text)
 	 Dim md5 As MD5 = New MD5CryptoServiceProvider
 	 Dim pass_hash As Byte() = md5.ComputeHash(data)
 	 Dim AIM_MD5_HASH As Byte() = ASCIIEncoding.ASCII.GetBytes(AIM_MD5_STRING)
 	 Dim auth_hash(pass_hash.Length + authkey_hash.Length + AIM_MD5_HASH.Length) As Byte
 	 Array.Copy(authkey_hash, 0, auth_hash, 0, authkey_hash.Length)
 	 Array.Copy(pass_hash, 0, auth_hash, authkey_hash.Length - 1, pass_hash.Length)
 	 Array.Copy(AIM_MD5_HASH, 0, auth_hash, (authkey_hash.Length - 1) + (pass_hash.Length - 1), AIM_MD5_HASH.Length)
 	 md5 = New MD5CryptoServiceProvider
 	 Dim send_hash As Byte() = md5.ComputeHash(auth_hash)
 	 textBox2.Text = ASCIIEncoding.ASCII.GetString(send_hash)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I always disable animations in Windows using sysdm.cpl and yes, it feels faster. I have also reduced animations in my android phone using dev options.
    • Neowin's servers (hosted in the UK).
    • MacOS isn't Linux, but Proton is modified WINE, and WINE runs on MacOS. They would just need to add something like Box86 or Rosetta support.
    • PicPick 7.4.0 by Razvan Serea PicPick is user friendly and full of features for creating your image, suitable for software developers, graphic designers and the home user. It is an all-in-one program that provides a full-featured screen capture tool, intuitive image editor, color picker, color palette, pixel ruler, protractor, crosshair and even whiteboard. It not only has everything that you need, but it loads fast, and sits quietly in the system tray until needed. This software is provided as freeware for personal use only. In this case, you are granted the right to use this program free of charge. Otherwise, you need to pay for a license for commercial use. PicPick key features: For All Windows (Fully support Windows 11, 10, 8.1, 8, 7, Vista and XP both 32-bit and 64-bit) Multi-language is supported. (MORE 28+) All functions are fully supported on a dual screen environment. No Registry, No access to System folder (you can copy these files to portable USB) Screen Capture Auto-scroll, dual monitors and sound effect are supported Various output to File, Printer, Office programs, External program Sharing to FTP, Web, E-mail, Facebook and Twitter are supported as well Full Screen Active Window Window Control Scrolling Window Region, Fixed Region FreeHand Repeat Last Capture Image Editor Intuitive User Interface Windows Ribbon style Standard drawing, shapes, arrows, lines, text, and etc. Blur, sharpen, hue, contrast, brightness, pixelate, rotate, flip, frame effect and etc. Color Picker and Color Palette various color code type (RGB, HTML, C++, Delphi) Photoshop style RGB/HSV conversion is supported. Pick and Save your favorite color! Screen Pixel Ruler Horizontal and vertical orientation various units (Pixels, Inches, Centimeters) DPI setting (72, 96, 120, 300) colorful gradient skins You don't have to install any other screen ruler softwares. Screen Magnifier Zoom 2x to 10x option Stay on top, smooth display, and sizeable window Screen Protractor Have you seen any screen protractor function in other software? Screen Crosshair For aligning objects in graphics or design applications For calculating relative coordinates on screen Some prefer to use this tool than a pixel-ruler. Whiteboard For giving a presentation or just drawing something on screen PicPick 7.4.0 changelog: Added support for saving in WebP file format Added horizontal scrolling in the Image Editor with Shift and mouse wheel Fixed control capture failing to detect specific windows Fixed focus loss during delayed active-window captures. Download: PicPick 7.4.0 | 74.9 MB (Free for personal use only) Download: Portable PicPick 7.4.0 | 73.3 MB View: PicPick Home page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Stellarium 25.2 by Razvan Serea Stellarium is a free open source planetarium for your computer. It shows a realistic sky in 3D, just like what you see with the naked eye, binoculars or a telescope. It is being used in planetarium projectors. Just set your coordinates and go. Stellarium key features: Realistic simulation of the sky, sunrise and sunset Default catalogue of over 600,000 stars Downloadable additional catalogues for up to 210 million stars Catalog data for all New General Catalogue (NGC) objects Images of almost all Messier objects and the Milky Way Artistic illustrations for all 88 modern constellations More than a dozen different cultures with their constellations Solar and lunar eclipse simulation Photorealistic landscapes (more are available on the website) Scripting support with ECMAScript (a few demo scripts are included) Extendable with plug-ins: 8 plug-ins installed by default, including: artificial satellites plug-in (updated from an on-line TLE database) ocular simulation plug-in (shows how objects look like in a given ocular) Solar System editor plug-in (imports comet and asteroid data from the MPC) telescope control plug-in (Meade LX200 and Celestron NexStar compatible) The major changes of this version: Many changes in support of sky cultures Added 2 new plugins: Mosaic Camera and Custom Nebula Textures Many improvements in Core Updates in sky cultures (include new one) [full release notes] Download: Stellarium 25.2 (64-bit) | 361.0 MB (Open Source) View: Stellarium Home Page | Other Operating Systems | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • First Post
      Johnny Mrkvička earned a badge
      First Post
    • Week One Done
      viraltui earned a badge
      Week One Done
    • One Month Later
      serfegyed earned a badge
      One Month Later
    • Dedicated
      firey earned a badge
      Dedicated
    • Dedicated
      fettermanj earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      649
    2. 2
      Michael Scrip
      224
    3. 3
      ATLien_0
      222
    4. 4
      Xenon
      146
    5. 5
      +FloatingFatMan
      143
  • Tell a friend

    Love Neowin? Tell a friend!