140 size_t decodedLen = 0;
141 char helper_command[3];
156 SEND(
"BH illegal request received");
157 fprintf(stderr,
"ERROR: Illegal request received: '%s'\n", buf);
162 fprintf(stderr,
"No newline in '%s'\n", buf);
170 xstrncpy(helper_command, buf,
sizeof(helper_command));
171 debug(
"Got '%s' from Squid with data:\n", helper_command);
172 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
174 debug(
"Got '%s' from Squid\n", buf);
176 if (memcmp(buf,
"YR ", 3) == 0) {
178 if (!decodedLen && !
token_decode(&decodedLen, decoded, buf+3))
180 if (decodedLen <
sizeof(
ntlmhdr)) {
181 SEND(
"NA * Packet format error");
185 c = (
char *) SSP_MakeNegotiateBlob(decoded, decodedLen, &Done, &status, cred);
195 debug(
"sending 'AF' %s to squid with data:\n", cred);
197 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
199 fprintf(stderr,
"No data available.\n");
200 printf(
"AF %s %s\n", c, cred);
202 SEND3(
"AF %s %s", c, cred);
207 debug(
"sending 'TT' to squid with data:\n");
208 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
209 printf(
"TT %s\n", c);
216 SEND(
"BH can't obtain server blob");
219 if (memcmp(buf,
"KK ", 3) == 0) {
221 SEND(
"BH invalid server blob");
225 if (!decodedLen && !
token_decode(&decodedLen, decoded, buf+3))
227 if (decodedLen <
sizeof(
ntlmhdr)) {
228 SEND(
"NA * Packet format error");
232 c = (
char *) SSP_ValidateNegotiateCredentials(decoded, decodedLen, &Done, &status, cred);
235 const auto n = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
236 FORMAT_MESSAGE_IGNORE_INSERTS,
239 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
240 (LPTSTR) & ErrorMessage,
244 SEND2(
"NA * Windows error: %s", GetLastError());
247 if (ErrorMessage[strlen(ErrorMessage) - 1] ==
'\n')
248 ErrorMessage[strlen(ErrorMessage) - 1] =
'\0';
249 if (ErrorMessage[strlen(ErrorMessage) - 1] ==
'\r')
250 ErrorMessage[strlen(ErrorMessage) - 1] =
'\0';
251 SEND2(
"NA * %s", ErrorMessage);
252 LocalFree(ErrorMessage);
262 debug(
"sending 'AF' %s to squid with data:\n", cred);
264 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
266 fprintf(stderr,
"No data available.\n");
267 printf(
"AF %s %s\n", c, cred);
269 SEND3(
"AF %s %s", c, cred);
276 debug(
"sending 'TT' to squid with data:\n");
277 hex_dump(
reinterpret_cast<unsigned char*
>(decoded), decodedLen);
278 printf(
"TT %s\n", c);
285 SEND(
"BH illegal request received");
286 fprintf(stderr,
"Illegal request received: '%s'\n", buf);
289 SEND(
"BH detected protocol error");