Skip to content

Commit

Permalink
Add: scheduling scan to scannerctl
Browse files Browse the repository at this point in the history
Usage: `scannerctl execute scan [OPTIONS] --path <FILE> [json]`

This is in a very early state. We need to add storage options for ports
or the whole scan to look them up when running.

We additionally need to add a alive checks that will set the required
parameter.

The script_dependency check is also not enabled for now.
  • Loading branch information
nichtsfrei committed Jun 24, 2024
1 parent bae71e8 commit 61d861b
Show file tree
Hide file tree
Showing 18 changed files with 672 additions and 65 deletions.
4 changes: 1 addition & 3 deletions rust/examples/feed/nasl/1.nasl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ if (description)
script_tag(name:"qod_type", value:"remote_banner");
script_family("Product detection");
script_copyright("Copyright (C) 2023 Greenbone AG");
script_require_ports("Services/www", 6262);
script_exclude_keys("Settings/disable_cgi_scanning");
script_tag(name:"summary", value:"HTTP AS detection");
script_xref(name:"URL", value:"https://greenbone.net");
exit(0);
}
exit(42);
exit(0);
18 changes: 18 additions & 0 deletions rust/examples/feed/nasl/2.nasl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if (description)
{
script_oid("0.0.0.0.0.0.0.0.0.2");
script_version("2023-02-23T13:33:44+0000");
script_tag(name:"last_modification", value:"2020-12-07 13:33:44 +0000 (Mon, 07 Dec 2020)");
script_tag(name:"creation_date", value:"2009-05-12 22:04:51 +0200 (Tue, 12 May 2009)");
script_tag(name:"cvss_base_vector", value:"AV:N/AC:L/Au:N/C:N/I:N/A:N");
script_name("Application Server Detection (HTTP)");
script_category(ACT_GATHER_INFO);
script_tag(name:"qod_type", value:"remote_banner");
script_family("Product detection");
script_copyright("Copyright (C) 2023 Greenbone AG");
script_tag(name:"summary", value:"HTTP AS detection");
script_xref(name:"URL", value:"https://greenbone.net");
script_dependencies("1.nasl");
exit(0);
}
exit(42);
5 changes: 4 additions & 1 deletion rust/examples/feed/nasl/sha256sums
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
e39d088df5527aad59ac29cdad03e80abc0033de9f19cce0a8235e8e502adc39 1.nasl
1685505110659defb2d310f54950128fa5cc8867f89ff35cb647228e091e87e9 ./1.nasl
2e21d3f6973e02e74ebc10dcc4ca77e7fbe414d6a8b985b2e0cda0111199a6aa ./plugin_feed_info.inc
dd086316af60a82f1e4a8fe4fc8a92885a81bc538a55df1528cc509bc3e13c72 ./sha256sums
88924cd3cbec2b070afd45fcd4aabd9096763379eb816c200b3dc4abfae96b08 ./2.nasl
32 changes: 32 additions & 0 deletions rust/examples/openvasd/example-feed-scan.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"target": {
"hosts": [
"127.0.0.1"
],
"ports": [
{
"range": [
{
"end": 22,
"start": 22
}
],
"protocol": "tcp"
}
],
"alive_test_methods": [
"icmp",
"tcp_syn",
"tcp_ack",
"arp"
],
"credentials": []
},
"scanner_preferences": [],
"vts": [
{
"oid": "0.0.0.0.0.0.0.0.0.2",
"parameters": []
}
]
}
2 changes: 1 addition & 1 deletion rust/feed/src/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ where
if let Err(e) = k.verify() {
return Some(Err(e.into()));
}

let mut filename = k.get_filename();
if filename.starts_with("./") {
// sha256sums may start with ./ so we have to remove those as dependencies
Expand Down
8 changes: 8 additions & 0 deletions rust/models/src/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: GPL-2.0-or-later WITH x11vnc-openssl-exception

use std::fmt::Display;

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(
feature = "serde_support",
Expand All @@ -14,3 +16,9 @@ pub struct Parameter {
/// The value of the parameter.
pub value: String,
}

impl Display for Parameter {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.id, self.value)
}
}
2 changes: 2 additions & 0 deletions rust/nasl-interpreter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod include;
mod interpreter;
mod loop_extension;
mod operator;
mod scan_interpreter;
pub mod scheduling;

pub use error::FunctionError;
Expand All @@ -23,6 +24,7 @@ pub use error::InterpretErrorKind;
pub use fork_interpreter::*;
pub use interpreter::ContextLifeTimeCapture;
pub use interpreter::Interpreter;
pub use scan_interpreter::*;

// we expose the other libraries to allow users to use them without having to import them
pub use nasl_builtin_std::{nasl_std_functions, ContextFactory, RegisterBuilder};
Expand Down
Loading

0 comments on commit 61d861b

Please sign in to comment.