diff options
| author | mo khan <mo.khan@gmail.com> | 2019-10-01 19:19:43 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2019-10-01 19:19:43 -0600 |
| commit | a89061ab6bdc2a6941aae2745b58f4f0482e1498 (patch) | |
| tree | 73d18c58757da32e5eceb73db77372e1b4001dcb | |
| parent | acadf7749ae6469f9d0fb946b4cb5cc5dcf17940 (diff) | |
Detect OS to use proper grep options
| -rw-r--r-- | README.md | 8 | ||||
| -rwxr-xr-x | bin/uid-zero | 8 |
2 files changed, 12 insertions, 4 deletions
@@ -1129,9 +1129,13 @@ Rootly Powers and Processes a. Find entries that have UID 0. ```bash - #!/bin/sh + #!/bin/bash - cat /etc/passwd | grep -P '^\w+:[x]:\d+:0.*$' + if [[ "$OSTYPE" == "darwin"* ]]; then + cat /etc/passwd | cut -d: -f1,3 | grep ':0' + else + cat /etc/passwd | grep -P '^\w+:[x]:\d+:0.*$' + fi ``` b. Find entries that have that have no password (needs /etc/shadow). diff --git a/bin/uid-zero b/bin/uid-zero index 129d587..2976cbb 100755 --- a/bin/uid-zero +++ b/bin/uid-zero @@ -1,3 +1,7 @@ -#!/bin/sh +#!/bin/bash -cat /etc/passwd | grep -P '^\w+:[x]:\d+:0.*$' +if [[ "$OSTYPE" == "darwin"* ]]; then + cat /etc/passwd | cut -d: -f1,3 | grep ':0' +else + cat /etc/passwd | grep -P '^\w+:[x]:\d+:0.*$' +fi |
