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 function sftp_enabled_check() #853

Merged
merged 3 commits into from Sep 1, 2021
Merged

Conversation

jjnicola
Copy link
Member

What:
Add nasl function sftp_enabled_check() to check if sftp subsystem is enabled in the target

Jira: SC-376

Why:
To check if sftp subsystem is enabled in the target

How:
Create the following nasl script sftp_test.nasl:

port = 22;
user = 'user';
pass = 'pass';

#Socket

soc1 = open_sock_tcp( port );
if( ! soc1 ) exit( 0 );
display ("socket opened:",soc1);

# New session
sess1 = ssh_connect( socket:soc1 );
display("session1: ", sess1);

# User auth.
ssh_userauth(sess1, login:user, password:pass);

#Check SFTP
ret = sftp_enabled_check (sess1);

display("SFTP: ", ret);

# Close session
a = ssh_disconnect(sess1);

Disable SFTP subsystem in the target

  • Comment out sftp support in sshd_config and of course restart sshd:
    #Subsystem sftp /usr/lib/openssh/sftp-server

Run the script:
openvas-nasl -X -B -d -i /path/to/var/lib/openvas/plugins -t <TARGET> sftp_test.nasl

Re-enable SFTP and re run the test.

Checklist:

@jjnicola jjnicola requested a review from a team as a code owner August 31, 2021 14:25
To check if sftp subsystem is enabled in the target

Jira: SC-376
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
nasl/nasl_ssh.c Outdated Show resolved Hide resolved
nasl/nasl_ssh.c Show resolved Hide resolved
nasl/nasl_ssh.c Show resolved Hide resolved
@jjnicola jjnicola merged commit 914de6a into greenbone:master Sep 1, 2021
@jjnicola jjnicola deleted the sftp branch September 1, 2021 07:45
y0urself added a commit that referenced this pull request Sep 1, 2021
Add nasl function sftp_enabled_check() (backport #853)
jjnicola added a commit that referenced this pull request Sep 1, 2021
Add nasl function sftp_enabled_check() (backport #853)
@jjnicola jjnicola mentioned this pull request Sep 6, 2021
2 tasks
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.

None yet

4 participants