141 size_t decodedLen = 0;
142 char helper_command[3];
157 SEND(
"BH illegal request received");
158 fprintf(stderr,
"ERROR: Illegal request received: '%s'\n", buf);
163 fprintf(stderr,
"No newline in '%s'\n", buf);
171 xstrncpy(helper_command, buf,
sizeof(helper_command));
172 debug(
"Got '%s' from Squid with data:\n", helper_command);
173 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
175 debug(
"Got '%s' from Squid\n", buf);
177 if (memcmp(buf,
"YR ", 3) == 0) {
179 if (!decodedLen && !
token_decode(&decodedLen, decoded, buf+3))
181 if (decodedLen <
sizeof(
ntlmhdr)) {
182 SEND(
"NA * Packet format error");
186 c = (
char *) SSP_MakeNegotiateBlob(decoded, decodedLen, &Done, &status, cred);
196 debug(
"sending 'AF' %s to squid with data:\n", cred);
198 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
200 fprintf(stderr,
"No data available.\n");
201 printf(
"AF %s %s\n", c, cred);
203 SEND3(
"AF %s %s", c, cred);
208 debug(
"sending 'TT' to squid with data:\n");
209 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
210 printf(
"TT %s\n", c);
217 SEND(
"BH can't obtain server blob");
220 if (memcmp(buf,
"KK ", 3) == 0) {
222 SEND(
"BH invalid server blob");
226 if (!decodedLen && !
token_decode(&decodedLen, decoded, buf+3))
228 if (decodedLen <
sizeof(
ntlmhdr)) {
229 SEND(
"NA * Packet format error");
233 c = (
char *) SSP_ValidateNegotiateCredentials(decoded, decodedLen, &Done, &status, cred);
236 const auto n = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
237 FORMAT_MESSAGE_IGNORE_INSERTS,
240 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
241 (LPTSTR) & ErrorMessage,
245 SEND2(
"NA * Windows error: %s", GetLastError());
248 if (ErrorMessage[strlen(ErrorMessage) - 1] ==
'\n')
249 ErrorMessage[strlen(ErrorMessage) - 1] =
'\0';
250 if (ErrorMessage[strlen(ErrorMessage) - 1] ==
'\r')
251 ErrorMessage[strlen(ErrorMessage) - 1] =
'\0';
252 SEND2(
"NA * %s", ErrorMessage);
253 LocalFree(ErrorMessage);
263 debug(
"sending 'AF' %s to squid with data:\n", cred);
265 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
267 fprintf(stderr,
"No data available.\n");
268 printf(
"AF %s %s\n", c, cred);
270 SEND3(
"AF %s %s", c, cred);
277 debug(
"sending 'TT' to squid with data:\n");
278 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
279 printf(
"TT %s\n", c);
286 SEND(
"BH illegal request received");
287 fprintf(stderr,
"Illegal request received: '%s'\n", buf);
290 SEND(
"BH detected protocol error");