Skip to content

sed & awk_ set root password in etc_shadow

TheGetch edited this page Jan 5, 2021 · 1 revision

sed & awk: set root password in etc/shadow

sed & awk: set root password in etc/shadow

You could do it with GNU sed like

sed -i -e "s/^root:[^:]\+:/root:$pass:/" etc/shadow

if $pass might have / characters in it you can use a different separator, like , if that won't be there. You can do that like:

sed -i -e "s,^root:[^:]\+:,root:$pass:," etc/shadow

if you do not have GNU sed you may not have -i or it may require an argument. You could also use awk to do this:

awk -F: "BEGIN {OFS=FS;} \$1 == \"root\" {\$2=\"$pass\"} 1" etc/shadow

if you have a recent version of GNU awk you can do it with the -i like so:

awk -i inplace -F: "BEGIN {OFS=FS;} \$1 == \"root\" {\$2=\"$pass\"} 1" etc/shadow

From https://stackoverflow.com/questions/30534693/linux-set-root-password-on-etc-shadow-file

_Sidebar

1. Recon

Ping Sweep

CIDR to IP

2. Enumeration

Services

05. HTTP (80,443,8080,8443,etc.)

3. Exploitation

4. Post Exploiation

5. High Value Information

Hashes

6. Reporting

7. Random Notes/Useful Tidbits

Clone this wiki locally