mirror of
https://github.com/nmap/nmap.git
synced 2026-01-03 21:29:01 +00:00
Convenience function to request shell on SSH2 channel
This commit is contained in:
@@ -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},
|
||||
|
||||
Reference in New Issue
Block a user