Skip to content

Commit

Permalink
Fix bug with pastseq and frag-sni-faked
Browse files Browse the repository at this point in the history
  • Loading branch information
Waujito committed Aug 21, 2024
1 parent e62d76e commit c103939
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 5 additions & 2 deletions logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
#define lgdebugmsg(msg, ...) \
(LOG_LEVEL >= VERBOSE_DEBUG ? printf(msg "\n", ##__VA_ARGS__) : 0)

#define lgtracemsg(msg, ...) \
(LOG_LEVEL >= VERBOSE_TRACE ? printf(msg "\n", ##__VA_ARGS__) : 0)

#define lgtrace(msg, ...) \
(LOG_LEVEL >= VERBOSE_TRACE ? printf(msg, ##__VA_ARGS__) : 0)

#define lgtracemsg(msg, ...) lgtrace(msg "\n", __VA_ARGS__)

#define lgtrace_start(msg, ...) \
(LOG_LEVEL >= VERBOSE_TRACE ? printf("[TRACE] " msg " ( ", ##__VA_ARGS__) : 0)
Expand Down
9 changes: 9 additions & 0 deletions mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ int send_tcp4_frags(const uint8_t *packet, uint32_t pktlen, const uint32_t *pose
}
memcpy(fake_pad, frag2, iphfl + tcphfl);
memset(fake_pad + iphfl + tcphfl, 0, f2len - iphfl - tcphfl);
struct tcphdr *fakethdr = (void *)(fake_pad + iphfl);
if (config.faking_strategy == FAKE_STRAT_PAST_SEQ) {
lgtrace("frag fake sent with %d -> ", ntohl(fakethdr->seq));
fakethdr->seq = htonl(ntohl(fakethdr->seq) - dvs);
lgtrace("%d\n", ntohl(fakethdr->seq));
}
ret = fail4_packet(fake_pad, f2len);
if (ret < 0) {
lgerror("Failed to fail packet", ret);
Expand Down Expand Up @@ -752,7 +758,10 @@ int fail4_packet(uint8_t *payload, uint32_t plen) {
tcph->ack_seq = random();
#endif
} else if (config.faking_strategy == FAKE_STRAT_PAST_SEQ) {
lgtrace("fake sent with %d -> ", ntohl(tcph->seq));
tcph->seq = htonl(ntohl(tcph->seq) - dlen);
lgtrace("%d\n", ntohl(tcph->seq));

} else if (config.faking_strategy == FAKE_STRAT_TTL) {
iph->ttl = config.faking_ttl;
}
Expand Down

0 comments on commit c103939

Please sign in to comment.