ps -aux – visible credentials of wmic command
- This topic has 2 replies, 2 voices, and was last updated 1 year, 1 month ago by admin.
- AuthorPosts
- 2021-10-31 at 5:16 AM #553MietekNParticipant
When you run ps -aux while the wmic command is running, all the credentials are visible
e.g.:
root 29 0.2 0.0 23740 2992 tty1 S 20:12 0:00 wmic -U adminuser%password //192.168.0.22 select * from Win32_ComputerSystemSo I created a little code fix to hide the credentials and now it looks like this:
root 29 0.2 0.0 23740 2992 tty1 S 20:12 0:00 wmic -U ****************** //192.168.0.22 select * from Win32_ComputerSystemThe patch code is below:
--- wmic.c.old 2010-04-15 17:49:39.000000000 +0200 +++ wmic.c 2021-10-30 11:19:57.334508330 +0200 @@ -54,6 +54,7 @@ int argc_new; char **argv_new; + int mu; struct poptOption long_options[] = { POPT_AUTOHELP @@ -68,6 +69,14 @@ POPT_TABLEEND }; + void wipe(char *s) + { + while(*s) { + *s = '*'; + s++; + } + } + pc = poptGetContext("wmi", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); @@ -89,6 +98,27 @@ } } + mu = 0; + if (argc > 1) for(i = 1; i < argc; i++) { + if(mu) { + wipe(argv); + mu = 0; + } else { + if(!strncmp(argv, "-U", 2) + || !strncmp(argv, "-A", 2) + || !strncmp(argv, "-k", 2) + || !strncmp(argv, "--user", 6) + || !strncmp(argv, "--authentication-file", 21) + || !strncmp(argv, "--kerbedos", 10) + ) mu = 1; + else if(!strncmp(argv, "--password", 10) + || !strncmp(argv, "-N", 2) + || !strncmp(argv, "--no-pass", 9) + || !strncmp(argv, "--use-security-mechanisms", 25) + ) wipe(argv); + } + } + if (argc_new != 3 || strncmp(argv_new[1], "//", 2) != 0) { poptPrintUsage(pc, stdout, 0);
2021-10-31 at 6:16 PM #558adminKeymasterThis is great. However, we are going to keep having problems with wmic unless it is fixed properly.
wmic needs a rebuild. I have no idea if you are able to do such a thing but let us know.
Please see this post https://edcint.co.nz/checkwmiplus/long-term-fix-for-wmic-keeping-check-wmi-plus-alive/
2022-07-02 at 8:55 AM #703adminKeymasterThis new version of Check WMI Plus will fix all your issues
- AuthorPosts
- You must be logged in to reply to this topic.