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

Add nasl functions for dumping icmp packets #609

Merged
merged 3 commits into from
Oct 20, 2020

Conversation

ArnoStiefvater
Copy link
Member

What:

Add nasl functions for dumping icmp packets.

Why:

TCP/IP/UDP ... already allow dumping of packets.

How:

ICMPv4
sudo openvas-nasl -i /plugins/folder -X -B -d -t example.com icmp.nasl

if(description) {
  script_oid("1.2.3");
  exit(0);
}

include("dump.inc");
ownip = this_host();
targetip = get_host_ip();

ip_packet = forge_ip_packet(ip_hl:  5,
                            ip_v:   4,
                            ip_tos: 0,
                            ip_id:  rand(),
                            ip_off: IP_DF,
                            ip_ttl: 64,
                            ip_p:   IPPROTO_TCP,
                            ip_sum: 0,
                            ip_src: ownip,
                            ip_dst: targetip);

imcp_packet = forge_icmp_packet(
  ip: ip_packet,
  data: "test data"
);

display("Crafted IP packet:");
dump_ip_packet(ip_packet);

display("Crafted ICMP packet:");
dump_icmp_packet(imcp_packet);

ICMPv6
sudo openvas-nasl -i /plugins/folder -X -B -d -t ::1 icmpv6.nasl

if(description) {
  script_oid("1.2.3");
  exit(0);
}

include("dump.inc");

ownip = this_host();
targetip = get_host_ip();

ip6_packet = forge_ipv6_packet( ip6_v:IP6_v,
                                ip6_p:IP6_P,
                                ip6_plen:20,
                                ip6_hlim:IP6_HLIM,
                                ip6_src:myhost,
                                ip6_dst:get_host_ip() );

icmp = forge_icmp_v6_packet( ip6:ip6_packet,
                              icmp_type:128,
                              icmp_code:0,
                              icmp_seq:0,
                              icmp_id:ICMP_ID,
                              icmp_cksum:-1,
                              data:"some test data" );

display("Crafted IP packet:");
dump_ipv6_packet(ip6_packet);

display("Crafted ICMP packet:");
dump_icmp_v6_packet(icmp);

Checklist:

@ArnoStiefvater ArnoStiefvater merged commit 474ece7 into greenbone:master Oct 20, 2020
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.

2 participants