Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newer systems don't have netstat by default #7

Open
bornhorstj opened this issue Aug 19, 2020 · 1 comment
Open

newer systems don't have netstat by default #7

bornhorstj opened this issue Aug 19, 2020 · 1 comment

Comments

@bornhorstj
Copy link

bornhorstj commented Aug 19, 2020

netstat missing

you might want to update to us SS -ano if netstat is missing

if [[ -x "$(command -v netstat)" ]]; then

    if [[ $(netstat -ano | grep LISTEN | grep 1234) ]]; then
    listening_port=true
    echo "[*] Listening on port 1234"
    fi
fi

if [[ -x "$(command -v ss)" ]]; then

    if [[ $(ss -ano | grep LISTEN | grep 1234) ]]; then
    listening_port=true
    echo "[*] Listening on port 1234"
    fi
fi
@PenelopeFudd
Copy link

Skip ss and netstat entirely:

if grep -q '00000000:04D2 [0:]* 0A ' /proc/net/tcp*; then
  listening_port=true
  echo "[*] Listening on port 1234 (ipv4 or ipv6)"
fi

if grep ':04D2 ' /proc/net/tcp* | grep -v ' 00000000*:0000 0A'; then
  echo "[*] Active connection on port 1234 (ipv4 or ipv6)"
fi

Explanation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants