Compare commits
8 Commits
7b390ba2a3
...
ae40d1a433
Author | SHA1 | Date |
---|---|---|
SashaXser | ae40d1a433 | |
SashaXser | bcfa72dbac | |
SashaXser | e3937e4188 | |
SashaXser | bcc78bdf7a | |
SashaXser | 069a4d3e30 | |
SashaXser | e98f20bfdc | |
SashaXser | b259a82144 | |
SashaXser | 3dff8c4841 |
|
@ -428,22 +428,27 @@ static inline void change_window_size(const PWINDIVERT_TCPHDR ppTcpHdr, unsigned
|
|||
/* HTTP method end without trailing space */
|
||||
static PVOID find_http_method_end(const char *pkt, unsigned int http_frag, int *is_fragmented) {
|
||||
unsigned int i;
|
||||
unsigned int pkt_length = strlen(pkt);
|
||||
for (i = 0; i<(sizeof(http_methods) / sizeof(*http_methods)); i++) {
|
||||
unsigned int method_length = strlen(http_methods[i]);
|
||||
if (memcmp(pkt, http_methods[i], method_length) == 0) {
|
||||
if (is_fragmented)
|
||||
*is_fragmented = 0;
|
||||
return (char*)pkt + method_length - 1;
|
||||
char *end = strchr(pkt + method_length, ' ');
|
||||
if (end != NULL && end - pkt <= pkt_length)
|
||||
return end;
|
||||
}
|
||||
/* Try to find HTTP method in a second part of fragmented packet */
|
||||
if ((http_frag == 1 || http_frag == 2) &&
|
||||
memcmp(pkt, http_methods[i] + http_frag,
|
||||
method_length - http_frag) == 0
|
||||
method_length - http_frag) == 0
|
||||
)
|
||||
{
|
||||
if (is_fragmented)
|
||||
*is_fragmented = 1;
|
||||
return (char*)pkt + method_length - http_frag - 1;
|
||||
char *end = strchr(pkt + method_length - http_frag, ' ');
|
||||
if (end != NULL && end - pkt <= pkt_length)
|
||||
return end;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -451,6 +456,7 @@ static PVOID find_http_method_end(const char *pkt, unsigned int http_frag, int *
|
|||
|
||||
|
||||
|
||||
|
||||
/** Fragment and send the packet.
|
||||
*
|
||||
* This function cuts off the end of the packet (step=0) or
|
||||
|
@ -807,15 +813,17 @@ int main(int argc, char *argv[]) {
|
|||
char *autottl_copy = strdup(optarg);
|
||||
if (strchr(autottl_copy, '-')) {
|
||||
// token "-" found, start X-Y parser
|
||||
char *autottl_current = strtok(autottl_copy, "-");
|
||||
char *autottl_current;
|
||||
char *saveptr; // declare a pointer to store the state of strtok_r
|
||||
autottl_current = strtok_r(autottl_copy, "-", &saveptr);
|
||||
auto_ttl_1 = atoub(autottl_current, "Set Auto TTL parameter error!");
|
||||
autottl_current = strtok(NULL, "-");
|
||||
autottl_current = strtok_r(NULL, "-", &saveptr);
|
||||
if (!autottl_current) {
|
||||
puts("Set Auto TTL parameter error!");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
auto_ttl_2 = atoub(autottl_current, "Set Auto TTL parameter error!");
|
||||
autottl_current = strtok(NULL, "-");
|
||||
autottl_current = strtok_r(NULL, "-", &saveptr);
|
||||
if (!autottl_current) {
|
||||
puts("Set Auto TTL parameter error!");
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
Loading…
Reference in New Issue