I got this plugin on the Internet that can connect to a server via SSH and
run a command in Linux, in this case, the command "ls" (list directory).

My OS is Ubuntu 10.04 and Server CentOS 5.5.

 But unfortunately it is running.

 I like to learn via example source code, someone would please an example
where I connect via SSH on the target and execute a command of the target
OS?

ssh_func.inc

ssh_func.inc open the file and found that this is just to check include SSH
on port 22. In the case and could copy and rename to ssh_func.inc for
ssh_func_port_3333.inc (a port other than 3333 and reconfigured in some
other servers kept the port 22) and make the call in the NASL script that I
create?

 Thanks

Code:

if(description)
{
script_id(91709);
script_version("1.0");
name["english"] = "command ls in Remote Server via port 22";
desc["english"] = "ls command in Remote Server via port 22 This script logs
on the remote machine and list the files in the directory.
Risk factor: None";
script_description(english:desc["english"]);
script_name(english:name["english"]);
family["english"] = "SSH-Auth";

script_family(english:family["english"]);
summary["english"] = "ls command in Remote Server via port 22 This script
logs on the remote machine and list the files in the directory";
script_summary(english:summary["english"]);
script_dependencie("find_service2.nasl");
script_category(ACT_INIT);
exit(0);
}
include("misc_func.inc");
include("ssh_func.inc");
include("global_settings.inc");
account = "root";
password = "123456";

display("login remote servern");
#login as user
soc = open_sock_tcp(22);
if ( soc )
{
    ret = ssh_login(socket:soc, login:account, password:password);
    buf=ssh_cmd(socket:soc, cmd:"ls");
    display(buf);
    close(soc);
}

Cheers.

_______________________________________________
Openvas-plugins mailing list
[email protected]
http://lists.wald.intevation.org/mailman/listinfo/openvas-plugins

Reply via email to