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 function to perform an alive test and get the amount of alive hosts. #495

Merged
merged 14 commits into from
May 12, 2021

Conversation

jjnicola
Copy link
Member

@jjnicola jjnicola commented May 6, 2021

What:
Add function to perform an alive test and get the amount of alive hosts.

Why:
There were just to ways to perform an alive scan, either using the client in which the results are printed in the stdout, or using the functions from the library which requires a redis kb and set preferences.
This function it is an hybrid between the both methods, which does not requires a kb, takes the preferences (port, alive test method) from prefs and which just return the amount of alive hosts.

How:
A small c program using the function:

sudo ./boreas_heartbeat 192.168.0.227

#include <glib.h>
#include <gvm/base/prefs.h> /* for prefs_get() */
#include <gvm/boreas/hostalivedetection.h>

void
main(int argc, char **argv)
{
  int alive = 0;
  boreas_error_t alive_test_err;
  
  prefs_set("ALIVE_TEST", "2");
  prefs_set("port_range", "80,137,587,3128,8081");

  alive_test_err = is_host_alive(argv[1], &alive);
  if (alive_test_err == NO_ERROR && alive > 0)
    g_message("Host %s alive", argv[1]);
  else
    g_message("Host %s dead", argv[1]);
 
}

Checklist:

@jjnicola jjnicola requested a review from a team as a code owner May 6, 2021 08:56
@jjnicola jjnicola changed the title Heartbeat master Add function to perform an alive test and get the amount of alive hosts. May 7, 2021
@jjnicola jjnicola merged commit 16c70f7 into greenbone:master May 12, 2021
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