Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ICMP handling in probe modules #470

Merged
merged 47 commits into from
Aug 3, 2021
Merged

Conversation

zakird
Copy link
Member

@zakird zakird commented Sep 16, 2017

This PR represents the effort to standardize ICMP handling across all of our probe modules.

Fixes #655
Fixes #354

@zakird
Copy link
Member Author

zakird commented Nov 9, 2017

This branch solely handles ICMP validation and does not output any of the data. However, it's already a giant PR, so we might as well get through this one first.

@zakird zakird requested review from dadrian and paul-pearce November 9, 2017 13:41
@ajholland
Copy link
Contributor

@zakird I'd be happy to take this over if you'd like, do you have an idea of what still needs to be done? Otherwise, I can just go through and figure out what was already done and proceed from there.

@zakird
Copy link
Member Author

zakird commented May 20, 2018

If you want to take over and finish it off, that'd be amazing. I haven't had the time to look at this in quite a while. The idea of the PR was originally just to make sure that we included ICMP output consistently in all of our probe modules. This also meant cleaning up how we validated ICMP packets in all of the modules.

As I started through this, I found that we had a bunch of duplicated code in all of the probe modules and I tried to pull all of these out into helper functions such that our probe modules looked sane. I think that a lot of what's there is OK, but there hasn't been much testing of the code (I wrote all of it on a transatlantic flight without Internet).

I think that looking through diffs will probably drive you insane given how much has changed. I'd probably just start by getting it to compile (which I think should be pretty easily fixed) and then starting to run some scans and seeing what starts to come out. I'd probably start with the TCP module.

fs_add_null_icmp(fs);
} else if (ip_hdr->ip_p == IPPROTO_ICMP) {
// tcp
fs_add_null(fs, "sport");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is adding sport, dport, and classification here and in fs_populate_icmp_from_iphdr intentional? If not, I'll fix that.

@ajholland
Copy link
Contributor

I did a tcp synscan (port 80) using this branch to see what I'd find. I didn't find any icmp_unreach classifications in a 5%.

I added an exit(1) condition to validate packet and process packet if the packet wasn't a tcp packet (just for santity checking), and redid a 5% scan. Zmap didn't exit, so no non-tcp packets found. I think my next step is to attempt to send non-tcp packets to a running zmap process and see what happens.

Any thoughts/am I barking up the wrong tree?

@zakird
Copy link
Member Author

zakird commented Jul 18, 2018 via email

@zakird zakird removed the request for review from paul-pearce August 2, 2021 22:20
@@ -34,7 +33,6 @@ extern probe_module_t module_bacnet;
probe_module_t *probe_modules[] = {
&module_tcp_synscan, &module_tcp_synackscan, &module_icmp_echo,
&module_icmp_echo_time, &module_udp, &module_ntp, &module_upnp, &module_dns,
//&module_tcp_cisco_backdoor,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to move this to //examples

return (struct icmp *)((char *)ip_hdr + 4 * ip_hdr->ip_hl);
}

static inline char *get_udp_payload(const struct udphdr *udp,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do uint8_t instead of char, since we think of it as a byte array, not a string.

static inline struct tcphdr *get_tcp_header(const struct ip *ip_hdr,
uint32_t len)
{
// buf not large enough to contain expected udp header
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

return (struct tcphdr *)((char *)ip_hdr + 4 * ip_hdr->ip_hl);
}

static inline struct udphdr *get_udp_header(const struct ip *ip_hdr,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there UDP options that influence the length of the header?

src/probe_modules/packet.h Outdated Show resolved Hide resolved
src/probe_modules/packet.c Outdated Show resolved Hide resolved
src/probe_modules/packet.c Outdated Show resolved Hide resolved
src/probe_modules/module_upnp.c Outdated Show resolved Hide resolved
src/probe_modules/module_udp.c Outdated Show resolved Hide resolved
src/probe_modules/module_upnp.c Show resolved Hide resolved
@zakird zakird merged commit aa749ee into main Aug 3, 2021
@zakird zakird deleted the icmp-validation-abstraction branch August 3, 2021 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to filter for unsuccessful ICMPs Inconsistent ICMP Handling
3 participants