diff --git a/nse_libssh2.cc b/nse_libssh2.cc
index 753d0f042..418ac379a 100644
--- a/nse_libssh2.cc
+++ b/nse_libssh2.cc
@@ -786,8 +786,13 @@ static int channel_request (lua_State *L, int status, lua_KContext ctx) {
static int l_channel_request (lua_State *L) {
request_context *ctx = (request_context *)safe_zalloc(sizeof(request_context));
ctx->channel = (LIBSSH2_CHANNEL *) lua_touserdata(L, 2);
- ctx->request = luaL_checklstring(L, 3, &ctx->request_len);
+ ctx->request = lua_tolstring(L, 3, &ctx->request_len);
ctx->message = lua_tolstring(L, 4, &ctx->message_len);
+ /* Convenience: if no extra args, treat it as libssh2_channel_shell */
+ if (ctx->request == NULL) {
+ ctx->request = "shell";
+ ctx->request_len = sizeof("shell") - 1;
+ }
return channel_request(L, 0, (lua_KContext)ctx);
}
@@ -948,6 +953,7 @@ static const struct luaL_Reg libssh2[] = {
{ "channel_read_stderr", l_channel_read_stderr},
{ "channel_write", l_channel_write},
{ "channel_exec", l_channel_exec},
+ { "channel_shell", l_channel_request},
{ "channel_send_eof", l_channel_send_eof},
{ "channel_eof", l_channel_eof},
{ "channel_close", l_channel_close},
diff --git a/nselib/libssh2.luadoc b/nselib/libssh2.luadoc
index 8630e2e16..b725f0d5a 100644
--- a/nselib/libssh2.luadoc
+++ b/nselib/libssh2.luadoc
@@ -95,10 +95,10 @@ function channel_write(session, channel, buffer)
--- Sends a request on libssh2 channel.
--
--- For example, request a shell with
--- channel_request(s, c, "shell"). The equivalent of
--- channel_request(s, c, "exec", cmd)
--- is channel_exec(s, c, cmd).
+-- Examples:
+-- * request a shell: channel_request(s, c, "shell") (equivalent to channel_shell(s, c)channel_request(s, c, "exec", cmd) (equivalent to channel_exec(s, c, cmd)).
+-- * open a subsystem: channel_request(s, c, "subsystem", "sftp")
-- @param session Authenticated libssh2 session
-- @param channel Open libssh2 channel
-- @param request String identifier for the request, e.g. "shell", "exec", "subsystem"
@@ -124,6 +124,11 @@ function channel_request_pty_ex(session, channel, term, modes,
-- @param cmd String containing command to execute
function channel_exec(session, channel, cmd)
+--- Requests a shell on libssh2 channel
+-- @param session Authenticated libssh2 session
+-- @param channel Open libssh2 channel
+function channel_shell(session, channel)
+
--- Sends EOF on libssh2 channel. Note that the server may continue to send data
-- until it sends its own EOF (which can be checked with channel_eof()
-- @param session Authenticated libssh2 session