Hello,
I have been investigating tools to generate UDP with checksums of zero for
software testing. This is legal in IPv4 but unwise due to inability to verify
the data has not been corrupted.
I found that mausezahn was not able to create these packets due despite being
able to create incorrect UDP checksums.
The code does not distinguish set to zero and unset.
Regards
Mark
Patch:
diff --git a/staging/layer4.c b/staging/layer4.c
index ca4d229..15be0f6 100644
--- a/staging/layer4.c
+++ b/staging/layer4.c
@@ -146,6 +146,7 @@ libnet_ptag_t create_udp_packet (libnet_t *l)
char argval[MAX_PAYLOAD_SIZE];
int T; // only an abbreviation for tx.packet_mode
int i;
+ int udp_sum_set = 0;
/////////////////////////////
// Default UDP header fields
@@ -215,6 +216,7 @@ libnet_ptag_t create_udp_packet (libnet_t *l)
if (getarg(tx.arg_string,"udp_
sum", argval)==1)
{
+ udp_sum_set = 1;
tx.udp_sum = (u_int16_t) str2int(argval);
}
@@ -277,7 +279,7 @@ libnet_ptag_t create_udp_packet (libnet_t *l)
0);
// Checksum overwrite? Libnet IPv6 checksum calculation can't deal with exte
- libnet_toggle_checksum(l, t, (tx.udp_sum || ipv6_mode) ? LIBNET_OFF : LIBNET
+ libnet_toggle_checksum(l, t, (udp_sum_set || ipv6_mode) ? LIBNET_OFF : LIBNE
if (t == -1)
{
Tests:
Results as seen by wireshark (UDP checksum verification enabled)
mausezahn eth0 -A 192.168.0.105 -B 192.168.0.104 -t udp "sp=32452,dp=1024" -P
Hello
UDP checksum is automatically set to the valid value.
mausezahn eth0 -A 192.168.0.105 -B 192.168.0.104 -t udp
"sp=32452,dp=1024,udp_sum=1" -P Hello
UDP checksum is set to 1 (which is invalid and highlighted by wireshark).
mausezahn eth0 -A 192.168.0.105 -B 192.168.0.104 -t udp
"sp=32452,dp=1024,udp_sum=0" -P Hello
Before patch the checksum was set to the valid value.
After patch the checksum was sent to zero.
--
You received this message because you are subscribed to the Google Groups
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.