Custom Script Not Working

Hi all,

I’m writing a custom script that will detect if port tcp/22 is available and if a tcp handshake is ok.

I’ve setup Greenbone with docker-compose. I copied the script to a shared volume, and placed the script under /var/lib/openvas/plugins. I gvmd –rebuild but the script doesn’t show up.

Also not shure if it works here’s the script :

include(“global_settings.inc”);
include(“socket_func.inc”);
include(“ssh_func.inc”);
include(“plugin_feed_info.inc”);

if (description) {
script_id(10000123);
script_version(“1.0”);
script_cve_id(“”);
script_name(“SSH port 22 reachable and SSH login test”);
script_summary(“Check if TCP/22 is open and if an SSH session can be created.”);
script_family(“General”);
script_tag(name:“severity”, value:“Low”);
script_category(ACT_GATHER_INFO);
exit(0);
}

port_sock = open_sock_tcp(port:22, timeout:5);
if (port_sock == 0) {
security_warning(port:22, extra:“TCP port 22 is closed or filtered”);
exit(0);
}

security_message(port:22, extra:“TCP port 22 is open”);
ssh_sess = ssh_connect(socket:port_sock, port:22, timeout:10);

if (ssh_sess > 0) {
security_message(port:22,
extra:“SSH handshake succeeded – remote SSH service is reachable”);
ssh_disconnect(ssh_sess);
}
else {
security_warning(port:22,
extra:“SSH handshake failed – service may be filtered or require auth”);
}
close(port_sock);

Thanks in advanced for your help.

Using custom scripts is a functionality of the underlying software stack, highly depends on the install method or could be even not supported depending on that method. Thus moving into a better fitting category as the VTs category is only about discussing the content of VTs / .nasl scripts but not about how they are used within the software stack.

1 Like

This topic was automatically closed after 90 days. New replies are no longer allowed.