mirror of
https://github.com/ValdikSS/GoodbyeDPI.git
synced 2024-12-22 14:26:08 +00:00
Handle Host header after User-Agent header in the HTTP packet. Fixes #29.
Most browsers would put Host header as early as they could, but not Microsoft Edge.
This commit is contained in:
parent
ee665ee3bd
commit
4c13435ee3
23
goodbyedpi.c
23
goodbyedpi.c
@ -352,9 +352,7 @@ int main(int argc, char *argv[]) {
|
|||||||
*/
|
*/
|
||||||
host_len = data_addr_rn - host_addr;
|
host_len = data_addr_rn - host_addr;
|
||||||
useragent_addr = find_useragent_header(packet_data, packet_dataLen);
|
useragent_addr = find_useragent_header(packet_data, packet_dataLen);
|
||||||
if (host_len <= 253 && useragent_addr && useragent_addr > host_addr) {
|
if (host_len <= 253 && useragent_addr) {
|
||||||
/* Performing action only if User-Agent header goes after Host */
|
|
||||||
|
|
||||||
useragent_addr += strlen(http_useragent_find);
|
useragent_addr += strlen(http_useragent_find);
|
||||||
/* useragent_addr is in the beginning of User-Agent value */
|
/* useragent_addr is in the beginning of User-Agent value */
|
||||||
|
|
||||||
@ -364,16 +362,31 @@ int main(int argc, char *argv[]) {
|
|||||||
/* data_addr_rn is in the end of User-Agent value */
|
/* data_addr_rn is in the end of User-Agent value */
|
||||||
|
|
||||||
if (data_addr_rn) {
|
if (data_addr_rn) {
|
||||||
|
if (useragent_addr > host_addr) {
|
||||||
|
/* User-Agent goes AFTER Host header */
|
||||||
data_len = (PVOID)data_addr_rn - (PVOID)host_addr;
|
data_len = (PVOID)data_addr_rn - (PVOID)host_addr;
|
||||||
|
|
||||||
/* Move one byte to the left from "Host:"
|
/* Move one byte to the LEFT from "Host:"
|
||||||
* to the end of User-Agen
|
* to the end of User-Agent
|
||||||
*/
|
*/
|
||||||
memmove(host_addr - 1, host_addr, data_len);
|
memmove(host_addr - 1, host_addr, data_len);
|
||||||
/* Put space in the end of User-Agent header */
|
/* Put space in the end of User-Agent header */
|
||||||
*(char*)(data_addr_rn - 1) = ' ';
|
*(char*)(data_addr_rn - 1) = ' ';
|
||||||
//printf("Replaced Host header!\n");
|
//printf("Replaced Host header!\n");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* User-Agent goes BEFORE Host header */
|
||||||
|
data_len = (PVOID)host_addr - (PVOID)data_addr_rn - 1;
|
||||||
|
|
||||||
|
/* Move one byte to the RIGHT from the end of User-Agent
|
||||||
|
* to the "Host:"
|
||||||
|
*/
|
||||||
|
memmove(data_addr_rn + 1, data_addr_rn, data_len);
|
||||||
|
/* Put space in the end of User-Agent header */
|
||||||
|
*(char*)(data_addr_rn) = ' ';
|
||||||
|
//printf("Replaced Host header!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user