View Full Version : Another "permit once" suggestion - regsvr32.exe
gottadoit
March 24th, 2005, 09:55 AM
Just noticed that Gavin suggested that regsvr32 is a good candidate for run once permissions, it sounds like a good idea, so I thought I'd mention it here for anyone that was interested
The thread his comment is in is here (http://www.wilderssecurity.com/showthread.php?p=410961#post410961)
Another useful thing to do from time to time is to go to the Security tab in PG and sort by "Last Run" and have a look at what has been executed recently (and the time it ran), it might reveal something unexpected (even if it isn't a security issue...)
NB: If you have been running PG 3.x since last year you will have to ignore the date sorting bug as it doesn't take the year into account...
earth1
March 24th, 2005, 04:02 PM
Just a quick tip related to Gavin's suggestion (http://www.wilderssecurity.com/showthread.php?t=69328) about setting cmd.exe to Permit Once.
I resisted changing cmd.exe to Permit Once because it was used in numerous script files (in loops even). I later realized I could rename a copy of cmd.exe and put it in an obscure location. Now cmd.exe is set to Permit Once and my script files call the obscure copy which is set to Permit Always. An obvious solution, but it took me so long to think of it I wanted to mention it just in case...
gottadoit
March 25th, 2005, 09:17 AM
FWIW,
I also have a renamed copy of regedit with permit always (for the same reason, because I download and apply registry settings via a batch job)
jon_fl
March 29th, 2005, 01:43 AM
-{ Quote: "Just a quick tip related to Gavin's suggestion (http://www.wilderssecurity.com/showthread.php?t=69328) about setting cmd.exe to Permit Once.
I resisted changing cmd.exe to Permit Once because it was used in numerous script files (in loops even). I later realized I could rename a copy of cmd.exe and put it in an obscure location. Now cmd.exe is set to Permit Once and my script files call the obscure copy which is set to Permit Always. An obvious solution, but it took me so long to think of it I wanted to mention it just in case..." }-
Could you explain exactly how you did that? :-\
earth1
March 29th, 2005, 04:25 AM
-{ Quote: "Could you explain exactly how you did that? :-\" }-First, choose (or create) the directory where you want to "hide" the cmd-clone. Let's say you've created "c:\innocent\dir". Now copy cmd.exe (from C:\WINDOWS or C:\WINNT) to c:\innocent\dir, and rename the copy to something less obvious, let's say pgCommand.exe. Next, start pgCommand.exe and tell PG to "Permit Always". Finally, change PG's Security on your original cmd.exe to be "Permit Once". That's it!
In batch files, you can now replace:
cmd /c doSomething.bat
with:
c:\innocent\dir\pgCommand /c doSomething.bat
Since pgCommand is "Permit Always" you won't be bothered everytime a script invokes it. The advantage, of course, is that if malware tries to use cmd.exe to run a script, you will be alerted. It seems unlikely that any malware will try to run a script using c:\innocent\dir\pgCommand.exe. If you're really paranoid, you can add some extra bytes to the end of the cloned copy so that it would appear to be a different file. If you're somewhat less paranoid, you can add c:\innocent\dir to your PATH and invoke pgCommand by name only.
jon_fl
March 29th, 2005, 08:53 AM
Thanks ;). Do you have any other suggestions with any other files etc.?
gottadoit
March 29th, 2005, 10:11 AM
Most if not all of the other suggestions have been included in Andreas1's writeup, its certainly worth a read
See A detailed discussion paper on ProcessGuard by Andreas (http://www.wilderssecurity.com/showthread.php?t=56848)
jon_fl
March 30th, 2005, 01:31 AM
-{ Quote: "First, choose (or create) the directory where you want to "hide" the cmd-clone. Let's say you've created "c:\innocent\dir". Now copy cmd.exe (from C:\WINDOWS or C:\WINNT) to c:\innocent\dir, and rename the copy to something less obvious, let's say pgCommand.exe. Next, start pgCommand.exe and tell PG to "Permit Always". Finally, change PG's Security on your original cmd.exe to be "Permit Once". That's it!
In batch files, you can now replace:
cmd /c doSomething.bat
with:
c:\innocent\dir\pgCommand /c doSomething.bat
Since pgCommand is "Permit Always" you won't be bothered everytime a script invokes it. The advantage, of course, is that if malware tries to use cmd.exe to run a script, you will be alerted. It seems unlikely that any malware will try to run a script using c:\innocent\dir\pgCommand.exe. If you're really paranoid, you can add some extra bytes to the end of the cloned copy so that it would appear to be a different file. If you're somewhat less paranoid, you can add c:\innocent\dir to your PATH and invoke pgCommand by name only." }-
I did all of this, replaced the batch file as instructed and it still goes through cmd.exe instead of going through the cmd-clone I made in another folder. ???
earth1
March 30th, 2005, 01:35 AM
-{ Quote: "I did all of this, replaced the batch file as instructed and it still goes through cmd.exe instead of going through the cmd-clone I made in another folder. ???" }-Can you provide more information? Perhaps put the relevant command(s) in a code box. Anything that may help me guess what you are seeing and what might be happening.
jon_fl
March 30th, 2005, 11:11 AM
Original batch file: "C:\Program Files\doSomething\DS.EXE" /tasks:abcd
Made a new folder with the clone-cmd.exe and changed to:
C:\innocent\pgCommand /"C:\Program Files\doSomething\DS.EXE" /tasks:abcd
earth1
March 30th, 2005, 02:48 PM
-{ Quote: "Original batch file: "C:\Program Files\doSomething\DS.EXE" /tasks:abcd
Made a new folder with the clone-cmd.exe and changed to:
C:\innocent\pgCommand /"C:\Program Files\doSomething\DS.EXE" /tasks:abcd" }-I'm still not sure where cmd.exe was getting called before (and presumably is still getting called now). The one line from the original batch file (?) does not seem to be using cmd.exe, but is just invoking an executable.
Also, there may be an idiom in my example that was misunderstood. The "/c" switch is used to tell cmd.exe to exit (close its console window) immediately after performing the command specified on the command line. It's often used to perform a DOS command from inside an executable or from a non-DOS script language. In this case it's used to specify your alternate version of the DOS interpeter.
The second half of your example (maybe a typo?) looks like you have only a "slash" where I would have expected a "slash-'c'-space". It looks like the .EXE name is immediately after the "slash" as opposed to
cmd-clone /c "EXE-name" EXE-parameters
My best guess is that cmd.exe is being called from somewhere other than where you tried using the cmd-clone copy. If this is in a batch file, try using ECHO statements to figure out whether cmd.exe is being invoked somewhere other than where you think it is being invoked. If you're still stuck, you could put the whole batch file in a "code box" (the pound-sign icon) and explain how the batch file is called.
HTH
jon_fl
March 30th, 2005, 05:40 PM
earth1, I sent you a PM. Thanks.
vBulletin® Copyright ©2000-2012, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2012, Wilders Security Forums