C:/fscan/HTTPCore/Authentication/ntlm.cpp File Reference

#include "../Build.h"
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <string.h>
#include "ntlm.h"

Include dependency graph for ntlm.cpp:

Go to the source code of this file.

Defines

#define RW_PCVAL(read, inbuf, outbuf, len)
#define RW_PIVAL(read, big_endian, inbuf, outbuf, len)
#define RW_PSVAL(read, big_endian, inbuf, outbuf, len)
#define RW_CVAL(read, inbuf, outbuf, offset)
#define RW_IVAL(read, big_endian, inbuf, outbuf, offset)
#define RW_SVAL(read, big_endian, inbuf, outbuf, offset)
#define CAREFUL_ALIGNMENT   1
#define CVAL(buf, pos)   (((unsigned char *)(buf))[pos])
#define PVAL(buf, pos)   ((unsigned)CVAL(buf,pos))
#define SCVAL(buf, pos, val)   (CVAL(buf,pos) = (val))
#define SVAL(buf, pos)   (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
#define IVAL(buf, pos)   (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
#define SSVALX(buf, pos, val)   (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
#define SIVALX(buf, pos, val)   (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
#define SVALS(buf, pos)   ((int16)SVAL(buf,pos))
#define IVALS(buf, pos)   ((int32)IVAL(buf,pos))
#define SSVAL(buf, pos, val)   SSVALX((buf),(pos),((uint16)(val)))
#define SIVAL(buf, pos, val)   SIVALX((buf),(pos),((uint32)(val)))
#define SSVALS(buf, pos, val)   SSVALX((buf),(pos),((int16)(val)))
#define SIVALS(buf, pos, val)   SIVALX((buf),(pos),((int32)(val)))
#define SMBMACRO(macro, buf, pos, val, len, size)   { int l; for (l = 0; l < (len); l++) (val)[l] = macro((buf), (pos) + (size)*l); }
#define SSMBMACRO(macro, buf, pos, val, len, size)   { int l; for (l = 0; l < (len); l++) macro((buf), (pos) + (size)*l, (val)[l]); }
#define PCVAL(buf, pos, val, len)   SMBMACRO(CVAL,buf,pos,val,len,1)
#define PSVAL(buf, pos, val, len)   SMBMACRO(SVAL,buf,pos,val,len,2)
#define PIVAL(buf, pos, val, len)   SMBMACRO(IVAL,buf,pos,val,len,4)
#define PCVALS(buf, pos, val, len)   SMBMACRO(CVALS,buf,pos,val,len,1)
#define PSVALS(buf, pos, val, len)   SMBMACRO(SVALS,buf,pos,val,len,2)
#define PIVALS(buf, pos, val, len)   SMBMACRO(IVALS,buf,pos,val,len,4)
#define PSCVAL(buf, pos, val, len)   SSMBMACRO(SCVAL,buf,pos,val,len,1)
#define PSSVAL(buf, pos, val, len)   SSMBMACRO(SSVAL,buf,pos,val,len,2)
#define PSIVAL(buf, pos, val, len)   SSMBMACRO(SIVAL,buf,pos,val,len,4)
#define PSCVALS(buf, pos, val, len)   SSMBMACRO(SCVALS,buf,pos,val,len,1)
#define PSSVALS(buf, pos, val, len)   SSMBMACRO(SSVALS,buf,pos,val,len,2)
#define PSIVALS(buf, pos, val, len)   SSMBMACRO(SIVALS,buf,pos,val,len,4)
#define SREV(x)   ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
#define IREV(x)   ((SREV(x)<<16) | (SREV((x)>>16)))
#define RSVAL(buf, pos)   SREV(SVAL(buf,pos))
#define RSVALS(buf, pos)   SREV(SVALS(buf,pos))
#define RIVAL(buf, pos)   IREV(IVAL(buf,pos))
#define RIVALS(buf, pos)   IREV(IVALS(buf,pos))
#define RSSVAL(buf, pos, val)   SSVAL(buf,pos,SREV(val))
#define RSSVALS(buf, pos, val)   SSVALS(buf,pos,SREV(val))
#define RSIVAL(buf, pos, val)   SIVAL(buf,pos,IREV(val))
#define RSIVALS(buf, pos, val)   SIVALS(buf,pos,IREV(val))
#define RPSVAL(buf, pos, val, len)   SMBMACRO(RSVAL,buf,pos,val,len,2)
#define RPIVAL(buf, pos, val, len)   SMBMACRO(RIVAL,buf,pos,val,len,4)
#define RPSVALS(buf, pos, val, len)   SMBMACRO(RSVALS,buf,pos,val,len,2)
#define RPIVALS(buf, pos, val, len)   SMBMACRO(RIVALS,buf,pos,val,len,4)
#define RPSSVAL(buf, pos, val, len)   SSMBMACRO(RSSVAL,buf,pos,val,len,2)
#define RPSIVAL(buf, pos, val, len)   SSMBMACRO(RSIVAL,buf,pos,val,len,4)
#define RPSSVALS(buf, pos, val, len)   SSMBMACRO(RSSVALS,buf,pos,val,len,2)
#define RPSIVALS(buf, pos, val, len)   SSMBMACRO(RSIVALS,buf,pos,val,len,4)
#define DBG_RW_PCVAL(charmode, string, depth, base, read, inbuf, outbuf, len)
#define DBG_RW_PSVAL(charmode, string, depth, base, read, big_endian, inbuf, outbuf, len)
#define DBG_RW_PIVAL(charmode, string, depth, base, read, big_endian, inbuf, outbuf, len)
#define DBG_RW_CVAL(string, depth, base, read, inbuf, outbuf)
#define DBG_RW_SVAL(string, depth, base, read, big_endian, inbuf, outbuf)
#define DBG_RW_IVAL(string, depth, base, read, big_endian, inbuf, outbuf)
#define ROUND1(a, b, c, d, k, s)   a = lshift(a + F(b,c,d) + X[k], s)
#define ROUND2(a, b, c, d, k, s)   a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s)
#define ROUND3(a, b, c, d, k, s)   a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)
#define uchar   unsigned char
#define int16   signed short
#define False   0
#define True   1
#define DEBUG(a, b)   ;
#define AddBytes(ptr, header, buf, count)
#define AddString(ptr, header, string)
#define AddUnicodeString(ptr, header, string)
#define GetUnicodeString(structPtr, header)   unicodeToString(((char*)structPtr) + IVAL(&structPtr->header.offset,0) , SVAL(&structPtr->header.len,0)/2)
#define GetString(structPtr, header)   toString((((char *)structPtr) + IVAL(&structPtr->header.offset,0)), SVAL(&structPtr->header.len,0))
#define DumpBuffer(fp, structPtr, header)   dumpRaw(fp,((unsigned char*)structPtr)+IVAL(&structPtr->header.offset,0),SVAL(&structPtr->header.len,0))
#define BAD   -1
#define DECODE64(c)   (isascii(c) ? base64val[c] : BAD)

Functions

static uint32 F (uint32 X, uint32 Y, uint32 Z)
static uint32 G (uint32 X, uint32 Y, uint32 Z)
static uint32 H (uint32 X, uint32 Y, uint32 Z)
static uint32 lshift (uint32 x, int s)
static void mdfour64 (uint32 *M)
static void copy64 (uint32 *M, unsigned char *in)
static void copy4 (unsigned char *out, uint32 x)
void mdfour (unsigned char *out, unsigned char *in, int n)
static void permute (char *out, char *in, uchar *p, int n)
static void l_shift (char *d, int count, int n)
static void concat (char *out, char *in1, char *in2, int l1, int l2)
static void xorfunction (char *out, char *in1, char *in2, int n)
static void dohash (char *out, char *in, char *key, int forw)
static void str_to_key (unsigned char *str, unsigned char *key)
static void smbhash (unsigned char *out, unsigned char *in, unsigned char *key, int forw)
void E_P16 (unsigned char *p14, unsigned char *p16)
void E_P24 (unsigned char *p21, unsigned char *c8, unsigned char *p24)
void D_P16 (unsigned char *p14, unsigned char *in, unsigned char *out)
void E_old_pw_hash (unsigned char *p14, unsigned char *in, unsigned char *out)
void cred_hash1 (unsigned char *out, unsigned char *in, unsigned char *key)
void cred_hash2 (unsigned char *out, unsigned char *in, unsigned char *key)
void cred_hash3 (unsigned char *out, unsigned char *in, unsigned char *key, int forw)
void SamOEMhash (unsigned char *data, unsigned char *key, int val)
char * StrnCpy (char *dest, const char *src, size_t n)
size_t skip_multibyte_char (char c)
char * safe_strcpy (char *dest, const char *src, size_t maxlength)
void strupper (char *s)
void SMBOWFencrypt (uchar passwd[16], uchar *c8, uchar p24[24])
void SMBencrypt (uchar *passwd, uchar *c8, uchar *p24)
static int _my_wcslen (int16 *str)
static int _my_mbstowcs (int16 *dst, uchar *src, int len)
void E_md4hash (uchar *passwd, uchar *p16)
void nt_lm_owf_gen (char *pwd, uchar nt_p16[16], uchar p16[16])
void NTLMSSPOWFencrypt (uchar passwd[8], uchar *ntlmchalresp, uchar p24[24])
void SMBNTencrypt (uchar *passwd, uchar *c8, uchar *p24)
static void dumpRaw (FILE *fp, unsigned char *buf, size_t len)
static char * unicodeToString (char *p, size_t len)
static unsigned char * strToUnicode (char *p)
static unsigned char * toString (char *p, size_t len)
void BuildAuthRequest (tSmbNtlmAuthRequest *request, long flags, char *host, char *domain)
void buildAuthResponse (tSmbNtlmAuthChallenge *challenge, tSmbNtlmAuthResponse *response, long flags, char *user, char *password, char *domainname, char *host)
void dumpAuthRequest (FILE *fp, tSmbNtlmAuthRequest *request)
void dumpAuthChallenge (FILE *fp, tSmbNtlmAuthChallenge *challenge)
void dumpAuthResponse (FILE *fp, tSmbNtlmAuthResponse *response)
void to64frombits (unsigned char *out, const unsigned char *in, int inlen)
int from64tobits (char *out, const char *in)

Variables

static uint32 A
static uint32 B
static uint32 C
static uint32 D
static uchar perm1 [56]
static uchar perm2 [48]
static uchar perm3 [64]
static uchar perm4 [48]
static uchar perm5 [32]
static uchar perm6 [64]
static uchar sc [16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1}
static uchar sbox [8][4][16]
static const char base64digits []
static const char base64val []


Define Documentation

#define AddBytes ( ptr,
header,
buf,
count   ) 

Value:

{ \
if (buf && count) \
  { \
  SSVAL(&ptr->header.len,0,count); \
  SSVAL(&ptr->header.maxlen,0,count); \
  SIVAL(&ptr->header.offset,0,((ptr->buffer - ((uint8*)ptr)) + ptr->bufIndex)); \
  memcpy(ptr->buffer+ptr->bufIndex, buf, count); \
  ptr->bufIndex += count; \
  } \
else \
  { \
  ptr->header.len = \
  ptr->header.maxlen = 0; \
  SIVAL(&ptr->header.offset,0,ptr->bufIndex); \
  } \
}

Definition at line 1113 of file ntlm.cpp.

#define AddString ( ptr,
header,
string   ) 

Value:

{ \
char *p = string; \
int len = 0; \
if (p) len = strlen(p); \
AddBytes(ptr, header, ((unsigned char*)p), len); \
}

Definition at line 1131 of file ntlm.cpp.

#define AddUnicodeString ( ptr,
header,
string   ) 

Value:

{ \
char *p = string; \
unsigned char *b = NULL; \
int len = 0; \
if (p) \
  { \
  len = strlen(p); \
  b = strToUnicode(p); \
  } \
AddBytes(ptr, header, b, len*2); \
}

Definition at line 1139 of file ntlm.cpp.

#define BAD   -1

Definition at line 1362 of file ntlm.cpp.

#define CAREFUL_ALIGNMENT   1

Definition at line 164 of file ntlm.cpp.

#define CVAL ( buf,
pos   )     (((unsigned char *)(buf))[pos])

Definition at line 167 of file ntlm.cpp.

#define DBG_RW_CVAL ( string,
depth,
base,
read,
inbuf,
outbuf   ) 

Value:

{ RW_CVAL(read,inbuf,outbuf,0) \
        DEBUG(5,("%s%04x %s: %02x\n", \
             tab_depth(depth), base, string, outbuf)); }

Definition at line 277 of file ntlm.cpp.

#define DBG_RW_IVAL ( string,
depth,
base,
read,
big_endian,
inbuf,
outbuf   ) 

Value:

{ RW_IVAL(read,big_endian,inbuf,outbuf,0) \
        DEBUG(5,("%s%04x %s: %08x\n", \
             tab_depth(depth), base, string, outbuf)); }

Definition at line 287 of file ntlm.cpp.

#define DBG_RW_PCVAL ( charmode,
string,
depth,
base,
read,
inbuf,
outbuf,
len   ) 

Value:

{ RW_PCVAL(read,inbuf,outbuf,len) \
        DEBUG(5,("%s%04x %s: ", \
             tab_depth(depth), base,string)); \
    if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \
        { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \
        DEBUG(5,("\n")); }

Definition at line 253 of file ntlm.cpp.

#define DBG_RW_PIVAL ( charmode,
string,
depth,
base,
read,
big_endian,
inbuf,
outbuf,
len   ) 

Value:

{ RW_PIVAL(read,big_endian,inbuf,outbuf,len) \
        DEBUG(5,("%s%04x %s: ", \
             tab_depth(depth), base,string)); \
    if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \
        { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \
        DEBUG(5,("\n")); }

Definition at line 269 of file ntlm.cpp.

#define DBG_RW_PSVAL ( charmode,
string,
depth,
base,
read,
big_endian,
inbuf,
outbuf,
len   ) 

Value:

{ RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
        DEBUG(5,("%s%04x %s: ", \
             tab_depth(depth), base,string)); \
    if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \
        { int idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \
        DEBUG(5,("\n")); }

Definition at line 261 of file ntlm.cpp.

#define DBG_RW_SVAL ( string,
depth,
base,
read,
big_endian,
inbuf,
outbuf   ) 

Value:

{ RW_SVAL(read,big_endian,inbuf,outbuf,0) \
        DEBUG(5,("%s%04x %s: %04x\n", \
             tab_depth(depth), base, string, outbuf)); }

Definition at line 282 of file ntlm.cpp.

#define DEBUG ( a,
 )     ;

Definition at line 830 of file ntlm.cpp.

Referenced by safe_strcpy(), and SMBencrypt().

#define DECODE64 (  )     (isascii(c) ? base64val[c] : BAD)

Definition at line 1373 of file ntlm.cpp.

#define DumpBuffer ( fp,
structPtr,
header   )     dumpRaw(fp,((unsigned char*)structPtr)+IVAL(&structPtr->header.offset,0),SVAL(&structPtr->header.len,0))

Definition at line 1157 of file ntlm.cpp.

#define False   0

Definition at line 447 of file ntlm.cpp.

#define GetString ( structPtr,
header   )     toString((((char *)structPtr) + IVAL(&structPtr->header.offset,0)), SVAL(&structPtr->header.len,0))

Definition at line 1155 of file ntlm.cpp.

#define GetUnicodeString ( structPtr,
header   )     unicodeToString(((char*)structPtr) + IVAL(&structPtr->header.offset,0) , SVAL(&structPtr->header.len,0)/2)

Definition at line 1153 of file ntlm.cpp.

#define int16   signed short

Definition at line 445 of file ntlm.cpp.

Referenced by _my_mbstowcs(), and E_md4hash().

#define IREV (  )     ((SREV(x)<<16) | (SREV((x)>>16)))

Definition at line 230 of file ntlm.cpp.

#define IVAL ( buf,
pos   )     (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)

Definition at line 175 of file ntlm.cpp.

#define IVALS ( buf,
pos   )     ((int32)IVAL(buf,pos))

Definition at line 179 of file ntlm.cpp.

#define PCVAL ( buf,
pos,
val,
len   )     SMBMACRO(CVAL,buf,pos,val,len,1)

Definition at line 212 of file ntlm.cpp.

#define PCVALS ( buf,
pos,
val,
len   )     SMBMACRO(CVALS,buf,pos,val,len,1)

Definition at line 215 of file ntlm.cpp.

#define PIVAL ( buf,
pos,
val,
len   )     SMBMACRO(IVAL,buf,pos,val,len,4)

Definition at line 214 of file ntlm.cpp.

#define PIVALS ( buf,
pos,
val,
len   )     SMBMACRO(IVALS,buf,pos,val,len,4)

Definition at line 217 of file ntlm.cpp.

#define PSCVAL ( buf,
pos,
val,
len   )     SSMBMACRO(SCVAL,buf,pos,val,len,1)

Definition at line 220 of file ntlm.cpp.

#define PSCVALS ( buf,
pos,
val,
len   )     SSMBMACRO(SCVALS,buf,pos,val,len,1)

Definition at line 223 of file ntlm.cpp.

#define PSIVAL ( buf,
pos,
val,
len   )     SSMBMACRO(SIVAL,buf,pos,val,len,4)

Definition at line 222 of file ntlm.cpp.

#define PSIVALS ( buf,
pos,
val,
len   )     SSMBMACRO(SIVALS,buf,pos,val,len,4)

Definition at line 225 of file ntlm.cpp.

#define PSSVAL ( buf,
pos,
val,
len   )     SSMBMACRO(SSVAL,buf,pos,val,len,2)

Definition at line 221 of file ntlm.cpp.

#define PSSVALS ( buf,
pos,
val,
len   )     SSMBMACRO(SSVALS,buf,pos,val,len,2)

Definition at line 224 of file ntlm.cpp.

#define PSVAL ( buf,
pos,
val,
len   )     SMBMACRO(SVAL,buf,pos,val,len,2)

Definition at line 213 of file ntlm.cpp.

#define PSVALS ( buf,
pos,
val,
len   )     SMBMACRO(SVALS,buf,pos,val,len,2)

Definition at line 216 of file ntlm.cpp.

#define PVAL ( buf,
pos   )     ((unsigned)CVAL(buf,pos))

Definition at line 168 of file ntlm.cpp.

#define RIVAL ( buf,
pos   )     IREV(IVAL(buf,pos))

Definition at line 234 of file ntlm.cpp.

#define RIVALS ( buf,
pos   )     IREV(IVALS(buf,pos))

Definition at line 235 of file ntlm.cpp.

#define ROUND1 ( a,
b,
c,
d,
k,
 )     a = lshift(a + F(b,c,d) + X[k], s)

Definition at line 324 of file ntlm.cpp.

Referenced by mdfour64().

#define ROUND2 ( a,
b,
c,
d,
k,
 )     a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s)

Definition at line 325 of file ntlm.cpp.

Referenced by mdfour64().

#define ROUND3 ( a,
b,
c,
d,
k,
 )     a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)

Definition at line 326 of file ntlm.cpp.

Referenced by mdfour64().

#define RPIVAL ( buf,
pos,
val,
len   )     SMBMACRO(RIVAL,buf,pos,val,len,4)

Definition at line 243 of file ntlm.cpp.

#define RPIVALS ( buf,
pos,
val,
len   )     SMBMACRO(RIVALS,buf,pos,val,len,4)

Definition at line 245 of file ntlm.cpp.

#define RPSIVAL ( buf,
pos,
val,
len   )     SSMBMACRO(RSIVAL,buf,pos,val,len,4)

Definition at line 249 of file ntlm.cpp.

#define RPSIVALS ( buf,
pos,
val,
len   )     SSMBMACRO(RSIVALS,buf,pos,val,len,4)

Definition at line 251 of file ntlm.cpp.

#define RPSSVAL ( buf,
pos,
val,
len   )     SSMBMACRO(RSSVAL,buf,pos,val,len,2)

Definition at line 248 of file ntlm.cpp.

#define RPSSVALS ( buf,
pos,
val,
len   )     SSMBMACRO(RSSVALS,buf,pos,val,len,2)

Definition at line 250 of file ntlm.cpp.

#define RPSVAL ( buf,
pos,
val,
len   )     SMBMACRO(RSVAL,buf,pos,val,len,2)

Definition at line 242 of file ntlm.cpp.

#define RPSVALS ( buf,
pos,
val,
len   )     SMBMACRO(RSVALS,buf,pos,val,len,2)

Definition at line 244 of file ntlm.cpp.

#define RSIVAL ( buf,
pos,
val   )     SIVAL(buf,pos,IREV(val))

Definition at line 238 of file ntlm.cpp.

#define RSIVALS ( buf,
pos,
val   )     SIVALS(buf,pos,IREV(val))

Definition at line 239 of file ntlm.cpp.

#define RSSVAL ( buf,
pos,
val   )     SSVAL(buf,pos,SREV(val))

Definition at line 236 of file ntlm.cpp.

#define RSSVALS ( buf,
pos,
val   )     SSVALS(buf,pos,SREV(val))

Definition at line 237 of file ntlm.cpp.

#define RSVAL ( buf,
pos   )     SREV(SVAL(buf,pos))

Definition at line 232 of file ntlm.cpp.

#define RSVALS ( buf,
pos   )     SREV(SVALS(buf,pos))

Definition at line 233 of file ntlm.cpp.

#define RW_CVAL ( read,
inbuf,
outbuf,
offset   ) 

Value:

{ if (read) { (outbuf) = CVAL (inbuf,offset); } \
        else      { SCVAL(inbuf,offset,outbuf); } }

Definition at line 143 of file ntlm.cpp.

#define RW_IVAL ( read,
big_endian,
inbuf,
outbuf,
offset   ) 

Value:

{ if (read) { (outbuf) = ((big_endian) ? RIVAL(inbuf,offset) : IVAL (inbuf,offset)); } \
        else      { if (big_endian) { RSIVAL(inbuf,offset,outbuf); } else { SIVAL(inbuf,offset,outbuf); } } }

Definition at line 147 of file ntlm.cpp.

#define RW_PCVAL ( read,
inbuf,
outbuf,
len   ) 

Value:

{ if (read) { PCVAL (inbuf,0,outbuf,len); } \
        else      { PSCVAL(inbuf,0,outbuf,len); } }

Definition at line 131 of file ntlm.cpp.

#define RW_PIVAL ( read,
big_endian,
inbuf,
outbuf,
len   ) 

Value:

{ if (read) { if (big_endian) { RPIVAL(inbuf,0,outbuf,len); } else { PIVAL(inbuf,0,outbuf,len); } } \
        else      { if (big_endian) { RPSIVAL(inbuf,0,outbuf,len); } else { PSIVAL(inbuf,0,outbuf,len); } } }

Definition at line 135 of file ntlm.cpp.

#define RW_PSVAL ( read,
big_endian,
inbuf,
outbuf,
len   ) 

Value:

{ if (read) { if (big_endian) { RPSVAL(inbuf,0,outbuf,len); } else { PSVAL(inbuf,0,outbuf,len); } } \
        else      { if (big_endian) { RPSSVAL(inbuf,0,outbuf,len); } else { PSSVAL(inbuf,0,outbuf,len); } } }

Definition at line 139 of file ntlm.cpp.

#define RW_SVAL ( read,
big_endian,
inbuf,
outbuf,
offset   ) 

Value:

{ if (read) { (outbuf) = ((big_endian) ? RSVAL(inbuf,offset) : SVAL (inbuf,offset)); } \
        else      { if (big_endian) { RSSVAL(inbuf,offset,outbuf); } else { SSVAL(inbuf,offset,outbuf); } } }

Definition at line 151 of file ntlm.cpp.

#define SCVAL ( buf,
pos,
val   )     (CVAL(buf,pos) = (val))

Definition at line 169 of file ntlm.cpp.

#define SIVAL ( buf,
pos,
val   )     SIVALX((buf),(pos),((uint32)(val)))

Definition at line 181 of file ntlm.cpp.

#define SIVALS ( buf,
pos,
val   )     SIVALX((buf),(pos),((int32)(val)))

Definition at line 183 of file ntlm.cpp.

#define SIVALX ( buf,
pos,
val   )     (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))

Definition at line 177 of file ntlm.cpp.

#define SMBMACRO ( macro,
buf,
pos,
val,
len,
size   )     { int l; for (l = 0; l < (len); l++) (val)[l] = macro((buf), (pos) + (size)*l); }

Definition at line 205 of file ntlm.cpp.

#define SREV (  )     ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))

Definition at line 229 of file ntlm.cpp.

#define SSMBMACRO ( macro,
buf,
pos,
val,
len,
size   )     { int l; for (l = 0; l < (len); l++) macro((buf), (pos) + (size)*l, (val)[l]); }

Definition at line 208 of file ntlm.cpp.

#define SSVAL ( buf,
pos,
val   )     SSVALX((buf),(pos),((uint16)(val)))

Definition at line 180 of file ntlm.cpp.

Referenced by _my_mbstowcs().

#define SSVALS ( buf,
pos,
val   )     SSVALX((buf),(pos),((int16)(val)))

Definition at line 182 of file ntlm.cpp.

#define SSVALX ( buf,
pos,
val   )     (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)

Definition at line 176 of file ntlm.cpp.

#define SVAL ( buf,
pos   )     (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)

Definition at line 174 of file ntlm.cpp.

#define SVALS ( buf,
pos   )     ((int16)SVAL(buf,pos))

Definition at line 178 of file ntlm.cpp.

#define True   1

Definition at line 448 of file ntlm.cpp.

#define uchar   unsigned char

Definition at line 444 of file ntlm.cpp.

Referenced by SMBencrypt().


Function Documentation

static int _my_mbstowcs ( int16 *  dst,
uchar *  src,
int  len 
) [static]

Definition at line 922 of file ntlm.cpp.

References int16, and SSVAL.

Referenced by E_md4hash().

static int _my_wcslen ( int16 *  str  )  [static]

Definition at line 907 of file ntlm.cpp.

Referenced by E_md4hash().

void BuildAuthRequest ( tSmbNtlmAuthRequest request,
long  flags,
char *  host,
char *  domain 
)

Definition at line 1217 of file ntlm.cpp.

Referenced by SendHttpRequest().

void buildAuthResponse ( tSmbNtlmAuthChallenge challenge,
tSmbNtlmAuthResponse response,
long  flags,
char *  user,
char *  password,
char *  domainname,
char *  host 
)

Definition at line 1247 of file ntlm.cpp.

Referenced by SendHttpRequest().

static void concat ( char *  out,
char *  in1,
char *  in2,
int  l1,
int  l2 
) [static]

Definition at line 566 of file ntlm.cpp.

static void copy4 ( unsigned char *  out,
uint32  x 
) [static]

Definition at line 385 of file ntlm.cpp.

static void copy64 ( uint32 M,
unsigned char *  in 
) [static]

Definition at line 376 of file ntlm.cpp.

void cred_hash1 ( unsigned char *  out,
unsigned char *  in,
unsigned char *  key 
)

Definition at line 732 of file ntlm.cpp.

References smbhash().

Here is the call graph for this function:

void cred_hash2 ( unsigned char *  out,
unsigned char *  in,
unsigned char *  key 
)

Definition at line 740 of file ntlm.cpp.

void cred_hash3 ( unsigned char *  out,
unsigned char *  in,
unsigned char *  key,
int  forw 
)

Definition at line 750 of file ntlm.cpp.

void D_P16 ( unsigned char *  p14,
unsigned char *  in,
unsigned char *  out 
)

Definition at line 720 of file ntlm.cpp.

static void dohash ( char *  out,
char *  in,
char *  key,
int  forw 
) [static]

Definition at line 581 of file ntlm.cpp.

void dumpAuthChallenge ( FILE *  fp,
tSmbNtlmAuthChallenge challenge 
)

Definition at line 1313 of file ntlm.cpp.

Referenced by SendHttpRequest().

void dumpAuthRequest ( FILE *  fp,
tSmbNtlmAuthRequest request 
)

Definition at line 1303 of file ntlm.cpp.

void dumpAuthResponse ( FILE *  fp,
tSmbNtlmAuthResponse response 
)

Definition at line 1324 of file ntlm.cpp.

static void dumpRaw ( FILE *  fp,
unsigned char *  buf,
size_t  len 
) [static]

Definition at line 1161 of file ntlm.cpp.

void E_md4hash ( uchar *  passwd,
uchar *  p16 
)

Definition at line 942 of file ntlm.cpp.

References _my_mbstowcs(), _my_wcslen(), and int16.

Here is the call graph for this function:

void E_old_pw_hash ( unsigned char *  p14,
unsigned char *  in,
unsigned char *  out 
)

Definition at line 726 of file ntlm.cpp.

References smbhash().

Here is the call graph for this function:

void E_P16 ( unsigned char *  p14,
unsigned char *  p16 
)

Definition at line 706 of file ntlm.cpp.

Referenced by SMBencrypt().

void E_P24 ( unsigned char *  p21,
unsigned char *  c8,
unsigned char *  p24 
)

Definition at line 713 of file ntlm.cpp.

static uint32 F ( uint32  X,
uint32  Y,
uint32  Z 
) [static]

Definition at line 303 of file ntlm.cpp.

int from64tobits ( char *  out,
const char *  in 
)

Definition at line 1401 of file ntlm.cpp.

Referenced by SendHttpRequest().

static uint32 G ( uint32  X,
uint32  Y,
uint32  Z 
) [static]

Definition at line 308 of file ntlm.cpp.

References F.

static uint32 H ( uint32  X,
uint32  Y,
uint32  Z 
) [static]

Definition at line 313 of file ntlm.cpp.

static void l_shift ( char *  d,
int  count,
int  n 
) [static]

Definition at line 556 of file ntlm.cpp.

static uint32 lshift ( uint32  x,
int  s 
) [static]

Definition at line 318 of file ntlm.cpp.

void mdfour ( unsigned char *  out,
unsigned char *  in,
int  n 
)

Definition at line 394 of file ntlm.cpp.

static void mdfour64 ( uint32 M  )  [static]

Definition at line 329 of file ntlm.cpp.

References A, B, C, D, ROUND1, ROUND2, ROUND3, and uint32.

void nt_lm_owf_gen ( char *  pwd,
uchar  nt_p16[16],
uchar  p16[16] 
)

Definition at line 961 of file ntlm.cpp.

void NTLMSSPOWFencrypt ( uchar  passwd[8],
uchar *  ntlmchalresp,
uchar  p24[24] 
)

Definition at line 1008 of file ntlm.cpp.

static void permute ( char *  out,
char *  in,
uchar *  p,
int  n 
) [static]

Definition at line 549 of file ntlm.cpp.

char* safe_strcpy ( char *  dest,
const char *  src,
size_t  maxlength 
)

Definition at line 831 of file ntlm.cpp.

References DEBUG.

void SamOEMhash ( unsigned char *  data,
unsigned char *  key,
int  val 
)

Definition at line 759 of file ntlm.cpp.

size_t skip_multibyte_char ( char  c  ) 

Definition at line 820 of file ntlm.cpp.

void SMBencrypt ( uchar *  passwd,
uchar *  c8,
uchar *  p24 
)

Definition at line 885 of file ntlm.cpp.

References DEBUG, E_P16(), SMBOWFencrypt(), StrnCpy(), strupper(), and uchar.

Here is the call graph for this function:

static void smbhash ( unsigned char *  out,
unsigned char *  in,
unsigned char *  key,
int  forw 
) [static]

Definition at line 678 of file ntlm.cpp.

Referenced by cred_hash1(), and E_old_pw_hash().

void SMBNTencrypt ( uchar *  passwd,
uchar *  c8,
uchar *  p24 
)

Definition at line 1028 of file ntlm.cpp.

void SMBOWFencrypt ( uchar  passwd[16],
uchar *  c8,
uchar  p24[24] 
)

Definition at line 997 of file ntlm.cpp.

Referenced by SMBencrypt().

static void str_to_key ( unsigned char *  str,
unsigned char *  key 
) [static]

Definition at line 660 of file ntlm.cpp.

char* StrnCpy ( char *  dest,
const char *  src,
size_t  n 
)

Definition at line 807 of file ntlm.cpp.

Referenced by SMBencrypt().

static unsigned char* strToUnicode ( char *  p  )  [static]

Definition at line 1188 of file ntlm.cpp.

void strupper ( char *  s  ) 

Definition at line 859 of file ntlm.cpp.

Referenced by SMBencrypt().

void to64frombits ( unsigned char *  out,
const unsigned char *  in,
int  inlen 
)

Definition at line 1375 of file ntlm.cpp.

Referenced by SendHttpRequest().

static unsigned char* toString ( char *  p,
size_t  len 
) [static]

Definition at line 1205 of file ntlm.cpp.

static char* unicodeToString ( char *  p,
size_t  len 
) [static]

Definition at line 1171 of file ntlm.cpp.

static void xorfunction ( char *  out,
char *  in1,
char *  in2,
int  n 
) [static]

Definition at line 574 of file ntlm.cpp.


Variable Documentation

uint32 A [static]

Definition at line 301 of file ntlm.cpp.

Referenced by md5_process(), and mdfour64().

uint32 B [static]

Definition at line 301 of file ntlm.cpp.

Referenced by md5_process(), and mdfour64().

const char base64digits[] [static]

Initial value:

   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

Definition at line 1359 of file ntlm.cpp.

const char base64val[] [static]

Initial value:

 {
    BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
    BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD,
    BAD,BAD,BAD,BAD, BAD,BAD,BAD,BAD, BAD,BAD,BAD, 62, BAD,BAD,BAD, 63,
     52, 53, 54, 55,  56, 57, 58, 59,  60, 61,BAD,BAD, BAD,BAD,BAD,BAD,
    BAD,  0,  1,  2,   3,  4,  5,  6,   7,  8,  9, 10,  11, 12, 13, 14,
     15, 16, 17, 18,  19, 20, 21, 22,  23, 24, 25,BAD, BAD,BAD,BAD,BAD,
    BAD, 26, 27, 28,  29, 30, 31, 32,  33, 34, 35, 36,  37, 38, 39, 40,
     41, 42, 43, 44,  45, 46, 47, 48,  49, 50, 51,BAD, BAD,BAD,BAD,BAD
}

Definition at line 1363 of file ntlm.cpp.

uint32 C [static]

Definition at line 301 of file ntlm.cpp.

Referenced by md5_process(), and mdfour64().

uint32 D [static]

Definition at line 301 of file ntlm.cpp.

Referenced by md5_process(), and mdfour64().

uchar perm1[56] [static]

Initial value:

 {57, 49, 41, 33, 25, 17,  9,
                         1, 58, 50, 42, 34, 26, 18,
                        10,  2, 59, 51, 43, 35, 27,
                        19, 11,  3, 60, 52, 44, 36,
                        63, 55, 47, 39, 31, 23, 15,
                         7, 62, 54, 46, 38, 30, 22,
                        14,  6, 61, 53, 45, 37, 29,
                        21, 13,  5, 28, 20, 12,  4}

Definition at line 450 of file ntlm.cpp.

uchar perm2[48] [static]

Initial value:

 {14, 17, 11, 24,  1,  5,
                         3, 28, 15,  6, 21, 10,
                        23, 19, 12,  4, 26,  8,
                        16,  7, 27, 20, 13,  2,
                        41, 52, 31, 37, 47, 55,
                        30, 40, 51, 45, 33, 48,
                        44, 49, 39, 56, 34, 53,
                        46, 42, 50, 36, 29, 32}

Definition at line 459 of file ntlm.cpp.

uchar perm3[64] [static]

Initial value:

 {58, 50, 42, 34, 26, 18, 10,  2,
                        60, 52, 44, 36, 28, 20, 12,  4,
                        62, 54, 46, 38, 30, 22, 14,  6,
                        64, 56, 48, 40, 32, 24, 16,  8,
                        57, 49, 41, 33, 25, 17,  9,  1,
                        59, 51, 43, 35, 27, 19, 11,  3,
                        61, 53, 45, 37, 29, 21, 13,  5,
                        63, 55, 47, 39, 31, 23, 15,  7}

Definition at line 468 of file ntlm.cpp.

uchar perm4[48] [static]

Initial value:

 {   32,  1,  2,  3,  4,  5,
                            4,  5,  6,  7,  8,  9,
                            8,  9, 10, 11, 12, 13,
                           12, 13, 14, 15, 16, 17,
                           16, 17, 18, 19, 20, 21,
                           20, 21, 22, 23, 24, 25,
                           24, 25, 26, 27, 28, 29,
                           28, 29, 30, 31, 32,  1}

Definition at line 477 of file ntlm.cpp.

uchar perm5[32] [static]

Initial value:

 {      16,  7, 20, 21,
                              29, 12, 28, 17,
                               1, 15, 23, 26,
                               5, 18, 31, 10,
                               2,  8, 24, 14,
                              32, 27,  3,  9,
                              19, 13, 30,  6,
                              22, 11,  4, 25}

Definition at line 486 of file ntlm.cpp.

uchar perm6[64] [static]

Initial value:

{ 40,  8, 48, 16, 56, 24, 64, 32,
                        39,  7, 47, 15, 55, 23, 63, 31,
                        38,  6, 46, 14, 54, 22, 62, 30,
                        37,  5, 45, 13, 53, 21, 61, 29,
                        36,  4, 44, 12, 52, 20, 60, 28,
                        35,  3, 43, 11, 51, 19, 59, 27,
                        34,  2, 42, 10, 50, 18, 58, 26,
                        33,  1, 41,  9, 49, 17, 57, 25}

Definition at line 496 of file ntlm.cpp.

uchar sbox[8][4][16] [static]

Definition at line 508 of file ntlm.cpp.

uchar sc[16] = {1, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1} [static]

Definition at line 506 of file ntlm.cpp.


Generated on Sun Jan 18 00:32:04 2009 for Fast HTTP Vulnerability Scanner by  doxygen 1.5.4