LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Bash script to reset admin password with chntpw (https://www.linuxquestions.org/questions/programming-9/bash-script-to-reset-admin-password-with-chntpw-690570/)

hal8000b 12-14-2008 04:36 PM

Bash script to reset admin password with chntpw
 
I'm trying to write a script that will automatically reset or blank a windows admin password.

The idea is to use chntpw point it at a SAM file and run
chntpw -l SAM
to list users, grep the admin or Administrator account and automaticly append an "*" to reset the password.

However, I dont think its possible to redirect an input into chntpw as
the command requires several y and n input responses, not just a single input.

Is there any way to pass multiple inputs into the chntpw command? Thanks in advance.

unSpawn 12-14-2008 05:22 PM

Quote:

Originally Posted by hal8000b (Post 3375473)
Is there any way to pass multiple inputs into the chntpw command?

Best chance would be an "expect" script AFAIK. Searching LQ for "expect script" should turn up some threads.


Quote:

Originally Posted by hal8000b (Post 3375473)
I'm trying to write a script that will automatically reset or blank a windows admin password.

That's a nasty tool. Please make sure you build in some safeguard so it doesn't get used in anger easily :-]

hal8000b 12-15-2008 02:47 AM

Thank you, I found the expect home page, and good point, in the wrong hands it could be dangerous, so I'll include some sort of password or other security measure.


All times are GMT -5. The time now is 11:51 PM.