Skip to content

Commit

Permalink
Fix for Windows auditing, the 'net use' command was removed (somehow?…
Browse files Browse the repository at this point in the history
…) for the copy_from_windows function. There is no config->base_path, use ROOTPATH instead.
  • Loading branch information
mark-unwin committed Aug 20, 2024
1 parent 68544b4 commit aa292c3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/Helpers/wmi_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ function execute_windows(string $ip = '', object $credentials = null, string $co

if (php_uname('s') == 'Windows NT') {
$password = str_replace('"', '\"', $credentials->credentials->password);
$command_string = $instance->config->base_path . '\\other\\paexec.exe \\\\' . $ip . ' -s -noname -u ' . $credentials->credentials->username . ' -p "' . $password . '" cmd /c "' . $command . '"';
$log->command = $instance->config->base_path . '\\other\\paexec.exe \\\\' . $ip . ' -s -noname -u ' . $credentials->credentials->username . ' -p "' . '*******' . '" cmd /c "' . $command . '"';
$command_string = ROOTPATH . '\\other\\paexec.exe \\\\' . $ip . ' -s -noname -u ' . $credentials->credentials->username . ' -p "' . $password . '" cmd /c "' . $command . '"';
$log->command = ROOTPATH . '\\other\\paexec.exe \\\\' . $ip . ' -s -noname -u ' . $credentials->credentials->username . ' -p "' . '*******' . '" cmd /c "' . $command . '"';
exec($command_string, $output, $return_var);
$log->message = 'Running command script on ' . $ip;
$log->command_output = json_encode($output);
Expand Down Expand Up @@ -693,6 +693,11 @@ function copy_from_windows(string $ip = '', object $credentials = null, string $

if (php_uname('s') == 'Windows NT') {
$password = str_replace('"', '\"', $credentials->credentials->password);
$username = $credentials->credentials->username;

$command = 'net use "\\\\' . $ip . '\\admin$" /u:' . $username . ' "' . $password . '"';
$log->command = 'net use "\\\\' . $ip . '\\admin$" /u:' . $username . ' "' . '*******' . '"';
$output = '';

exec($command, $output, $return_var);
$log->command_status = 'fail';
Expand Down

0 comments on commit aa292c3

Please sign in to comment.