• 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

    • Google Workspace brings 10 free AI features for nonprofit organizations by Aditya Tiwari Google has announced several updates for nonprofit and charitable organizations that use its products and services. For starters, the search giant is expanding the Google for Nonprofits program to more than 100 countries globally. Google for Nonprofits has been around for over a decade, offering products and services to eligible nonprofits for free or at discounted rates. One of its verticals is Workspace for Nonprofits, a paid tier that provides nonprofits with no-cost access to Gmail, Calendar, Meet, and its AI apps, such as Gemini and NotebookLM. Google is bringing ten new AI features to the Workspace for Nonprofits tier as part of its new updates. The company surveyed over 9,000 nonprofit organizations earlier this year and said that about nine out of ten nonprofits reported positive productivity gains when using AI apps and features. However, only one out of five reported that at least half of their organization uses AI. That said, these are the new features coming to Workspace for Nonprofits without paying any money: Gems Audio Overviews in Gemini app Image generation with people in Gemini app Canvas and quizzes in Gemini app Deep Research in Gemini app Google Vids with custom video clips powered by Veo 2 Two-way conversations with Gemini Live NotebookLM with Summaries, Audio Overviews (50+ languages and length adjustment) and Q&A Mind Maps in NotebookLM Discover Sources in NotebookLM Most of these features are available in other Workspace plans intended for regular businesses. Google's Nonprofits tier supports up to 2,000 employees or volunteers at $0/user/month, who can have professional email addresses, take part in 150-participant video meetings, and share a pooled cloud storage capacity of 1TB. Additionally, nonprofits can also place ads in Google Maps to connect with people at a local level. The company said that it's "expanding Ad Grants to run on eligible Google Maps placements in Performance Max campaigns free of charge." These ads in Google Maps can appear above, below or beside search results.
    • Have a ton of the Beach Boys on USB that I play while cruising in the car in my avatar.  Good times music. Very sad to hear of his passing. 😪
    • Haha, that didn't take long. On the bright side, that one is a fix for more issues...we'll see if anything major pops-up in the coming weeks.
    • Something like this https://www.neowin.net/news/wi...ashes-when-launching-games/ you mean?
    • Valerion StreamMaster Plus2 4K Dolby Vision gaming projector is $300 off with promo coupon by Sayan Sen If you are in the market for a premium projector, you should have a look at the Valerion StreamMaster Plus2 4K Gaming Projector. The product is designed primarily for gaming and multimedia use and promises an excellent "smoother streaming experience" compared to other projectors in its class. The projector supports "true" 4K Ultra HD, which should provide clear images for detailed gaming environments and media playback. The brightness level of 2000 lumens intends to make the device usable in various ambient lighting conditions, from dim gaming rooms to brighter living areas. And in terms of audio, it packs an S/PDIF for digital audio out. The key technical specifications of the Valerion StreamMaster Plus2 4K Gaming Projector are given below: Brightness: 2000 ISO Lumens Light Source: RGB triple laser Contrast Ratio: 10000:1 with EBL Mode (EBL = enhanced black level) Color Gamut: 110% Rec.2020 Throw Ratio: Fixed 1.2:1 (supports screen sizes up to 300 inches) Dynamic Tone Mapping: Enabled HDR and 3D Support: Supports IMAX Enhanced, Dolby Vision, HDR10+, Active 3D, Filmmaker Mode Google TV OS AI-SoC MT9618, 4 GB RAM and 128 GB ROM Input Lag: 4ms at 1080P@240Hz, 8ms at 1080P@120Hz, 15ms at 4K@60Hz Wi-Fi 6e, Bluetooth 5.2 Typically, it is listed at $1999. However, the projector is currently available for $1699, thanks to a special promo code, making it an attractive option for those looking to upgrade their gaming or home cinema setup. Get it at the link below: StreamMaster Plus2 4K Gaming Projector - 300" IMAX Enhanced Home Theater, 3D & Dolby Vision, HDR10+: $1999 + $300 off with promo code "VALERION" at checkout => $1699.00 (Shipped by Amazon, Sold by Valerion) This Amazon deal is US-specific and not available in other regions unless specified. If you don't like it or want to look at more options, check out the Amazon US deals page here. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
  • Recent Achievements

    • Apprentice
      Cole Multipass went up a rank
      Apprentice
    • Posting Machine
      David Uzondu earned a badge
      Posting Machine
    • One Month Later
      Stokenking earned a badge
      One Month Later
    • One Month Later
      Kevin Jones earned a badge
      One Month Later
    • Week One Done
      Kevin Jones earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      534
    2. 2
      ATLien_0
      263
    3. 3
      +Edouard
      195
    4. 4
      +FloatingFatMan
      183
    5. 5
      snowy owl
      135
  • Tell a friend

    Love Neowin? Tell a friend!