162 lines
4.5 KiB
C
162 lines
4.5 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "streecmp.h"
|
|
|
|
// SRC: en.wikipedia.org/wiki/List_of_HTTP_header_fields
|
|
char *strs = "A-IM\n"
|
|
"Accept\n"
|
|
"Accept-Charset\n"
|
|
"Accept-Datetime\n"
|
|
"Accept-Encoding\n"
|
|
"Accept-Language\n"
|
|
"Access-Control-Request-Method\n"
|
|
"Access-Control-Request-Headers\n"
|
|
"Authorization\n"
|
|
"Cache-Control\n"
|
|
"Connection\n"
|
|
"Content-Encoding\n"
|
|
"Content-Length\n"
|
|
"Content-MD5\n"
|
|
"Content-Type\n"
|
|
"Cookie\n"
|
|
"Date\n"
|
|
"Expect\n"
|
|
"Forwarded\n"
|
|
"From\n"
|
|
"Host\n"
|
|
"HTTP2-Settings\n"
|
|
"If-Match\n"
|
|
"If-Modified-Since\n"
|
|
"If-None-Match\n"
|
|
"If-Range\n"
|
|
"If-Unmodified-Since\n"
|
|
"Max-Forwards\n"
|
|
"Origin\n"
|
|
"Pragma\n"
|
|
"Prefer\n"
|
|
"Proxy-Authorization\n"
|
|
"Range\n"
|
|
"Referer\n"
|
|
"TE\n"
|
|
"Trailer\n"
|
|
"Transfer-Encoding\n"
|
|
"User-Agent\n"
|
|
"Upgrade\n"
|
|
"Via\n"
|
|
"Warning\n"
|
|
"Upgrade-Insecure-Requests\n"
|
|
"X-Requested-With\n"
|
|
"DNT\n"
|
|
"X-Forwarded-For\n"
|
|
"X-Forwarded-Host\n"
|
|
"X-Forwarded-Proto\n"
|
|
"Front-End-Https\n"
|
|
"X-Http-Method-Override\n"
|
|
"X-ATT-DeviceID\n"
|
|
"X-Wap-Profile\n"
|
|
"Proxy-Connection\n"
|
|
"X-UIDH\n"
|
|
"X-Csrf-Token\n"
|
|
"X-Request-ID\n"
|
|
"X-Correlation-ID\n"
|
|
"Correlation-ID\n"
|
|
"Save-Data\n"
|
|
"Sec-GPC\n"
|
|
"Accept-CH\n"
|
|
"Access-Control-Allow-Origin\n"
|
|
"Access-Control-Allow-Credentials\n"
|
|
"Access-Control-Expose-Headers\n"
|
|
"Access-Control-Max-Age\n"
|
|
"Access-Control-Allow-Methods\n"
|
|
"Access-Control-Allow-Headers\n"
|
|
"Accept-Patch\n"
|
|
"Accept-Ranges\n"
|
|
"Age\n"
|
|
"Allow\n"
|
|
"Alt-Svc\n"
|
|
"Content-Disposition\n"
|
|
"Content-Language\n"
|
|
"Content-Location\n"
|
|
"Content-Range\n"
|
|
"Delta-Base\n"
|
|
"ETag\n"
|
|
"Expires\n"
|
|
"IM\n"
|
|
"Last-Modified\n"
|
|
"Link\n"
|
|
"Location\n"
|
|
"P3P\n"
|
|
"Preference-Applied\n"
|
|
"Proxy-Authenticate\n"
|
|
"Public-Key-Pins\n"
|
|
"Retry-After\n"
|
|
"Server\n"
|
|
"Set-Cookie\n"
|
|
"Strict-Transport-Security\n"
|
|
"Tk\n"
|
|
"Vary\n"
|
|
"WWW-Authenticate\n"
|
|
"X-Frame-Options\n"
|
|
"Content-Security-Policy\n"
|
|
"Expect-CT\n"
|
|
"NEL\n"
|
|
"Permissions-Policy\n"
|
|
"Refresh\n"
|
|
"Report-To\n"
|
|
"Status\n"
|
|
"Timing-Allow-Origin\n"
|
|
"X-Content-Duration\n"
|
|
"X-Content-Type-Options\n"
|
|
"X-Powered-By\n"
|
|
"X-Redirect-By\n"
|
|
"X-UA-Compatible\n"
|
|
"X-XSS-Protection";
|
|
|
|
int main(void) {
|
|
int ret;
|
|
struct nod *rot = allocnod();
|
|
if (rot == NULL) {
|
|
fprintf(stderr, "[-] Failed: not enough dynamic memory\n");
|
|
return -1;
|
|
}
|
|
|
|
char *strs_cpy = strdup(strs);
|
|
if (strs_cpy == NULL) {
|
|
fprintf(stderr, "[-] Failed: not enough dynamic memory\n");
|
|
return -1;
|
|
}
|
|
|
|
ret = gentree(rot, strs, NULL);
|
|
if (ret < 0) {
|
|
fprintf(stderr, "[-] Failed: could not generate tree\n");
|
|
return -1;
|
|
}
|
|
|
|
fprintf(stdout, "------------------------\n");
|
|
|
|
int cnt = 1;
|
|
for (char *tok = strtok(strs_cpy, "\n"); tok != NULL; tok
|
|
= strtok(NULL, "\n")) {
|
|
int found = streecmp(rot, tok);
|
|
if (found == cnt) {
|
|
fprintf(stdout, "[+][%d/%d] Success: could find"
|
|
" '%s' in tree\n", cnt, found, tok);
|
|
cnt++;
|
|
} else {
|
|
fprintf(stderr, "[-][%d/%d] Error: could not find"
|
|
" '%s' in tree\n", cnt, found, tok);
|
|
}
|
|
}
|
|
|
|
fprintf(stdout, "------------------------\n");
|
|
|
|
free(strs_cpy);
|
|
frenod(rot);
|
|
|
|
fprintf(stdout, "[+] Freed all memory in use\n");
|
|
fprintf(stdout, "[f] Finished\n");
|
|
|
|
return 0;
|
|
}
|