void test_regex() { test_regex_match(); test_regex_search(); test_regex_iterator(); test_regex_replace(); }
bool auth_caller_fun(SOCKET con_socket){ // new function was easier! int bytesSent; int bytesRecv = SOCKET_ERROR; std::string data_out = ""; int counter = 0; // test counter while (1){ //loop forever char recvbuf[1024] = ""; // zero the buffer bytesRecv = recv(con_socket, recvbuf, 1024, 0); // get receve and bytes if (bytesRecv == SOCKET_ERROR) { printf("Client probably disconnected error %ld.\n", WSAGetLastError()); break; } else { printf("Server: received %ld Bytes data is: %s\n", bytesRecv, recvbuf); counter++; // count our msgs if (test_regex_search(recvbuf, data_out, counter)) //Regex test { std::cout << "Counter is at: " << counter << "\n"; // setup our string to add the data std::string prebuf; prebuf = "HTTP/1.1 401 Unauthorized\n"; prebuf += "Server: CallThem/9 Bro/1.1.1\n"; prebuf += "Date: Thu, 1 Jan 1970 00:00:01 UTC\n"; prebuf += "WWW-Authenticate: NTLM " + data_out + "\n"; prebuf += "Content-type: text/html\n"; prebuf += "Content-Length: 0\n\n"; // our buffer to send char sendbuf[1024]; // copy the string to buffer strcpy_s(sendbuf, prebuf.c_str()); // send it!! bytesSent = send(con_socket, sendbuf, strlen(sendbuf), 0); } else { // the reply if no hash provided! char sendbuf[1024] = "HTTP/1.1 401 Unauthorized\n" "Server: CallThem/9 Bro/1.1.1\n" "Date: Thu, 1 Jan 1970 00:00:01 UTC\n" "WWW-Authenticate: NTLM\n" "Content-type: text/html\n" "Content-Length: 0\n\n"; // send it!! bytesSent = send(con_socket, sendbuf, strlen(sendbuf), 0); } } } return 1; }