NTLM 网络安全认证编程实现(VC)

 

                                              NTLM 网络安全认证编程实现(VC)

                                                  深圳远客 (song_0962@sina.com)

   为什么你的基于TCP/IP的应用软件在开发调试时好好的,到了用户手上就有的就不行?原因是你的应用软件没法通过NTLM 认证。

  NTLM 是基于WindowNT 操作系统的网络安全认证管理机制的一种协议。随着网络资源的互访共享,网络安全问题被MS操作系统当作一项重要的任务在日溢加强,从早期的LM认证到NTLM 再到NTLMV2,NTLM网络安全认证也让网络访问的安全有最强的保障,于是很多公司,大企业都会采用基于NTLM 认证的服务器加强内部系统资源互访的安全。非法用户很难在非受权情况下进入系统,也不能访问外部资,比较流行的HTTP 代理服器就是应用广泛的例子 ,如果你公司网络管理员设置了代理服务器,那么你的任何网络访问都要经过代理服务器NTLM认证,当然在IExploer 中经过简单的设置你就可以上网了,因为IExploer内部也经有集成了NTLM模块(NT
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
HTTP PROXY中NTLM的客户端的C源代码。包含相关的DES等算法在内。Base64的算法,是通过网上共产主义获取,MD4,MD5,HMAC MD5的算法是RFC中提供的,其余的可以根据下面链接的步骤进行编写。我提供一个源代码的例子。其中arith_开头的相关算法,httppc_ntlmNTLM的type1、type2、type3消息的应答构成,test_httppc_connect是一个测试的例子,里面没有main函数,但是另外构造一个main函数,在wei_set_proxy_info之后,调用wei_httppc_connect就可以了。详细见http://blog.csdn.net/flowingflying/archive/2009/03/03/3952796.aspx 有朋友说少了头文件,我查了一下,不好意思,少了md.h。请参考下面。 /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. */ #ifdef __cplusplus extern "C" { #endif #ifndef WEI_MD_H #define WEI_MD_H #ifndef IN #define IN #endif #ifndef OUT #define OUT #endif /************************************ 算法:MD4和MD5 *********************************/ //从RFC1320 The MD4 Message-Digest Algorithm的附录 //从RFC1321 The MD5 Message-Digest Algorithm的附录 /* PROTOTYPES should be set to one if and only if the compiler supports function * argument prototyping.The following makes PROTOTYPES default to 0 if it has not * already been defined with C compiler flags. */ #ifndef PROTOTYPES #define PROTOTYPES 0 #endif /* POINTER defines a generic pointer type */ typedef unsigned char * POINTER; /* UINT2 defines a two byte word */ typedef unsigned short int UINT2; /* UINT4 defines a four byte word */ typedef unsigned long int UINT4; /* PROTO_LIST is defined depending on how PROTOTYPES is defined above.If using PROTOTYPES, * then PROTO_LIST returns the list, otherwise it returns an empty list. */ #if PROTOTYPES #define PROTO_LIST(list) list #else #define PROTO_LIST(list) () #endif /* MD4 context. */ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD4_CTX; void MD4Init PROTO_LIST ((MD4_CTX *)); void MD4Update PROTO_LIST ((MD4_CTX *, unsigned char *, unsigned int)); void MD4Final PROTO_LIST ((unsigned char [16], MD4_CTX *)); /* MD5 context. */ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ } MD5_CTX; void MD5Init PROTO_LIST ((MD5_CTX *)); void MD5Update PROTO_LIST ((MD5_CTX *, unsigned char *, unsigned int)); void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); #endif #ifdef __cplusplus } #endif 因为我没有认真地打包封装,而是从我的一个project中抽出了,有些遗漏,请大家原谅。今天又有网友来问PRIVATE在哪里定义。因为代码不在手头的机器上,没法仔细看,PRIVATE的定义如下 #define PRIVATE 定义为空,这是模仿C++的private,说明这个函数不会被其他文件引用,只用于本文件。 最近又收到网友的来信,说少了几个util文件。这个是不在ntlm的算法中,而是在验证例子test_httppc_connect.cpp中使用。查了一下,我确实没有放到网上。汗啊,因为验证例子是从某个程序中抽取出来,里面包含一个很简单的http的解析。我本来想update资源,没有找到 update的方法。需要说明的是这部分和真正的算法没有直接关系。放在这里,太长了,如果需要的网友,请到http://blog.csdn.net/flowingflying/archive/2009/03/03/3952796.aspx 那里下载。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值