File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # "embedded-device netstat"
4
+ #
5
+ # embNetstat.sh
6
+ # watered-down version of netstat for when
7
+ # netstat, lsof, etc are not available
8
+ #
9
+ # ./embNetstat.sh [tcp | udp]
10
+ #
11
+ # giving credit where credit is due, i adopted this from andreisid. he has good milk:
12
+ # https://www.commandlinefu.com/commands/view/15313/check-open-ports-without-netstat-or-lsof
13
+ # https://www.commandlinefu.com/commands/by/andreisid
14
+ #
15
+ # **************
16
+ # * escollapse *
17
+ # * CISSP, PT+ *
18
+ # * 20200204 *
19
+ # **************
20
+ #
21
+
22
+ case " $1 " in
23
+ " tcp" )
24
+ echo " Open TCP Ports:"
25
+ declare -a array=($( tail -n +2 /proc/net/$1 | cut -d' :' -f3 | cut -d' ' -f1) )\
26
+ && (( for port in ${array[@]} ; do echo $((0 x$port )) ; done) | sort -n)
27
+ ;;
28
+ " udp" )
29
+ echo " Open UDP Ports:"
30
+ declare -a array=($( tail -n +2 /proc/net/$1 | cut -d' :' -f3 | cut -d' ' -f1) )\
31
+ && (( for port in ${array[@]} ; do echo $((0 x$port )) ; done) | sort -n)
32
+ ;;
33
+ * )
34
+ echo " Usage: $0 [tcp | udp]"
35
+ ;;
36
+ esac
You can’t perform that action at this time.
0 commit comments