Implement proxy traversal (8): NT-Hash implementation

Source: Internet
Author: User

I have been busy recently. I have a lot of things, I have to live a lot, and I have to pay a lower salary. There is no time to read books. I will move some of my previous technical blogs here. NTLM studied for a while at the end of last year and at the beginning of this year and wrote a summary and example program. It involves many algorithms and has been checked online for a long time. (Below is the previous blog) recently I want to implement a network programming program through proxy, and summarize the relevant content. Many things come from network communism and should be rewarded for communism. This section describes the implementation of NT-hash. From the LM hash algorithm designed by IBM, Microsoft puts forward its own challenge response mechanism while maintaining backward compatibility. NTLM
Hash came into being. Assume that the plaintext password is "123456" and is first converted to a unicode string
The hash algorithm is different. You do not need to add 0x00 to supplement 14 bytes, And the hash algorithm is case sensitive. "123456"-> 310032003300340035003600. The SMB packet is being decoded. The standard ASCII code before 0x80 is converted to the Unicode code, which is simply from 0x ?? 0x00 ??. This
Standard ASCII string-
The endian order is converted to a unicode string, that is, 0x00 is simply added after each byte. Standard md4 unidirectional hash of the retrieved Unicode string, regardless of the number of data sources
If the number of bytes is small, md4 will generate a 128-bit hash value.
16-byte 310032003300340035003600-standard md4 unidirectional hash->
32ed87bdb5fdc5e9cba88547376818d4

The final NTLM hash: 32ed87bdb5fdc5e9cba88547376818d4 is obtained.

Static void Unicode (in char * SRC, in int src_len, out char * DST,
Out int * dst_len ){

Int I
;

For (I = 0;
I <src_len; I ++ ){


DST [2 * I] =
SRC [I];


DST [2 * I + 1]
= 0;

}

If (dst_len
! = NULL)


* Dst_len =
Src_len * 2;

}

Void nt_hash (in char * SRC, in int is_unicode, out unsigned char *
DST, out int * dst_len ){

Char *
Source = NULL;

Int Len =
Strlen (SRC );


If (! Is_unicode ){


Source =
(Char *) malloc (LEN * 2 );



Unicode (SRC, Len, source, & Len );

} Else {


Source =
SRC;

}

Md4string
(Source, Len, DST );

If (dst_len
! = NULL)


* Dst_len =
16;


If (! Is_unicode)



Free (source );

}

Call example:

Unsigned char DST [16];

Nt_hash ("123456", 0, DST, null)

 

Related Links: My network communication articles




NTLM implementation:

  • Proxy traversal (16): NTLM proxy Traversal

  • Proxy traversal (15): NTLM Session Security

  • Implement proxy traversal (14): NTLM type3 message
  • Implement proxy traversal (13): NTLM type2 message
  • Implement proxy traversal (12): NTLM type1 message
  • Proxy traversal (11): NTLMv2 session response
  • Implement proxy traversal (10): NTLMv2 response
  • Implement proxy traversal (9): ntlmv1 response
  • Implement proxy traversal (8): NT-Hash implementation
  • Proxy traversal (7): md4 and MD5
  • Implement proxy traversal (6): LM-Hash implementation
  • Implement proxy traversal (5): DES algorithm 3
  • Implement proxy traversal (4): DES algorithm 2
  • Implement proxy traversal (3): One of the des Algorithms
  • Proxy traversal (2): base64 Algorithm
  • Proxy traversal (1): process and NTLM Algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.