enumlib.cna 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # author REDMED-X
  2. beacon_command_register(
  3. "enumlib", "Find loaded module(s) in remote process(es)",
  4. "INFO:\nFind a specific loaded module in all processes OR list all loaded modules in a specific process.\n\nOPTIONS:\n[search]: find all processes that have loaded a specific module (e.g. winhttp.dll or ws2_32.dll).\n[list]: list all loaded modules in a remote process.\n\n" .
  5. "USAGE:\nenumlib search <module name>\nenumlib list <pid>\n\n");
  6. alias enumlib {
  7. $bid = $1;
  8. $option = $2;
  9. $target = $3;
  10. if ($option eq "") {
  11. berror($bid, "Please specify one of the following enumeration options: search | list\n");
  12. return;
  13. }
  14. if ($option eq "search" || $option eq "list") {
  15. if ($option eq "search" && $target eq "") {
  16. berror($bid, "Please specify a module name to search for\n");
  17. return;
  18. }
  19. if ($option eq "list" && $target eq "") {
  20. berror($bid, "Please specify the pid of the target process to enumerate\n");
  21. return;
  22. }
  23. }
  24. else {
  25. berror($bid, "This enumeration option isn't supported. Please specify one of the following enumeration options: search | list\n");
  26. return;
  27. }
  28. # Read in the right BOF file
  29. $handle = openf(script_resource("enumlib.o"));
  30. $data = readb($handle, -1);
  31. closef($handle);
  32. # Pack our arguments
  33. if ($option eq "search") {
  34. $arg_data = bof_pack($bid, "zz", $option, $target);
  35. }
  36. else {
  37. $arg_data = bof_pack($bid, "zi", $option, $target);
  38. }
  39. blog($bid, "Tasked to enumerate loaded modules..");
  40. beacon_inline_execute($bid, $data, "go", $arg_data);
  41. }