14 #include <sys/types.h> 15 #include <openssl/sha.h> 34 #define PPTP_GRE_PROTO 0x880B 35 #define PPTP_GRE_VER 0x1 37 #define PPTP_GRE_IS_C(f) ((f) & 0x80) 38 #define PPTP_GRE_IS_R(f) ((f) & 0x40) 39 #define PPTP_GRE_IS_K(f) ((f) & 0x20) 40 #define PPTP_GRE_IS_S(f) ((f) & 0x10) 41 #define PPTP_GRE_IS_A(f) ((f) & 0x80) 49 #define PPP_PROTO_CHAP 0xc223 57 #define PPP_CHAP_CODE_CHALLENGE 1 58 #define PPP_CHAP_CODE_RESPONSE 2 95 u_char *p, name[64], digest[SHA_DIGEST_LENGTH];
101 if (len < (pghlen =
sizeof(*pgh)))
116 pghlen -=
sizeof(pgh->
ack);
126 ((u_char *)ppp +
sizeof(proto));
129 proto = ntohs(ppp->
proto);
135 switch (chap->
code) {
140 if (chapch->
size == 8) {
145 else if (chapch->
size == 16) {
150 else save_challenge.
version = 0;
154 if (save_challenge.
version == 0)
158 i = ntohs(chap->
length) - 54;
160 memcpy(name, (u_char *)chap + 54, i);
165 if (save_challenge.
version == 1) {
166 for (i = 0; i < 8; i++) {
172 for (i = 0; i < 24; i++) {
178 for (i = 0; i < 24; i++) {
184 else if (save_challenge.
version == 2) {
186 if ((p = strchr(name,
'\\')) == NULL)
191 SHA1_Update(&ctx, save_challenge.
challenge, 16);
192 SHA1_Update(&ctx, p, strlen(p));
193 SHA1_Final(digest, &ctx);
195 for (i = 0; i < 8; i++) {
196 buf_putf(&outbuf,
"%02X", digest[i]);
198 buf_putf(&outbuf,
":000000000000000000000000000000000000000000000000:");
199 for (i = 0; i < 24; i++) {