mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-22 02:56:06 +02:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
beea7648bd | ||
|
|
e92273d8b6 |
@@ -33,10 +33,10 @@ plugins=(... systemadmin)
|
|||||||
| killit | Kills any process that matches a regular expression passed to it |
|
| killit | Kills any process that matches a regular expression passed to it |
|
||||||
| tree | List contents of directories in a tree-like format (if tree isn't installed) |
|
| tree | List contents of directories in a tree-like format (if tree isn't installed) |
|
||||||
| sortcons | Sort connections by state |
|
| sortcons | Sort connections by state |
|
||||||
| con80 | View all 80 Port Connections |
|
| con80 | View all connections on ports 80 and 443, or on the ports given as arguments (`con80 8080`) |
|
||||||
| sortconip | On the connected IP sorted by the number of connections |
|
| sortconip | On the connected IP sorted by the number of connections |
|
||||||
| req20 | List the top 20 requests on port 80 |
|
| req20 | List the top 20 requests on ports 80 and 443, or on the ports given as arguments (`req20 8080`) |
|
||||||
| http20 | List the top 20 connections to port 80 based on tcpdump data |
|
| http20 | List the top 20 connections to ports 80 and 443 based on tcpdump data, or to the ports given as arguments |
|
||||||
| timewait20 | List the top 20 time_wait connections |
|
| timewait20 | List the top 20 time_wait connections |
|
||||||
| syn20 | List the top 20 SYN connections |
|
| syn20 | List the top 20 SYN connections |
|
||||||
| port_pro | Output all processes according to the port number |
|
| port_pro | Output all processes according to the port number |
|
||||||
|
|||||||
@@ -65,60 +65,77 @@ fi
|
|||||||
|
|
||||||
# Sort connection state
|
# Sort connection state
|
||||||
function sortcons() {
|
function sortcons() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -nat | awk 'NR > 1 {print $1}' \
|
LANG= ss -nat | awk 'NR > 1 {print $1}'
|
||||||
|| LANG= netstat -nat | awk 'NR > 2 {print $6}'
|
else
|
||||||
} | sort | uniq -c | sort -rn
|
LANG= netstat -nat | awk 'NR > 2 {print $6}'
|
||||||
|
fi | sort | uniq -c | sort -rn
|
||||||
}
|
}
|
||||||
|
|
||||||
# View all 80 Port Connections
|
# View all connections on the given ports (default 80 and 443)
|
||||||
function con80() {
|
function con80() {
|
||||||
{
|
local -a ports=($@)
|
||||||
LANG= ss -nat || LANG= netstat -nat
|
(( $# )) || ports=(80 443)
|
||||||
} | grep -E ":80[^0-9]" | wc -l
|
if (( $+commands[ss] )); then
|
||||||
|
LANG= ss -nat
|
||||||
|
else
|
||||||
|
LANG= netstat -nat
|
||||||
|
fi | grep -E ":(${(j:|:)ports})[^0-9]" | wc -l
|
||||||
}
|
}
|
||||||
|
|
||||||
# On the connected IP sorted by the number of connections
|
# On the connected IP sorted by the number of connections
|
||||||
function sortconip() {
|
function sortconip() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -ntu | awk 'NR > 1 {print $6}' \
|
LANG= ss -ntu | awk 'NR > 1 {print $6}'
|
||||||
|| LANG= netstat -ntu | awk 'NR > 2 {print $5}'
|
else
|
||||||
} | cut -d: -f1 | sort | uniq -c | sort -n
|
LANG= netstat -ntu | awk 'NR > 2 {print $5}'
|
||||||
|
fi | cut -d: -f1 | sort | uniq -c | sort -n
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find the number of requests on 80 port
|
# top20 of Find the number of requests on the given ports (default 80 and 443)
|
||||||
function req20() {
|
function req20() {
|
||||||
{
|
local -a ports=($@)
|
||||||
LANG= ss -tn | awk '$4 ~ /:80$/ {print $5}' \
|
(( $# )) || ports=(80 443)
|
||||||
|| LANG= netstat -tn | awk '$4 ~ /:80$/ {print $5}'
|
if (( $+commands[ss] )); then
|
||||||
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n 20
|
LANG= ss -tn
|
||||||
|
else
|
||||||
|
LANG= netstat -tn
|
||||||
|
fi | awk -v ports="${(j:|:)ports}" '$4 ~ ":("ports")$" {print $5}' \
|
||||||
|
| awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Using tcpdump port 80 access to view
|
# top20 of Using tcpdump to view access to the given ports (default 80 and 443)
|
||||||
function http20() {
|
function http20() {
|
||||||
sudo tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 20
|
local -a ports=($@)
|
||||||
|
(( $# )) || ports=(80 443)
|
||||||
|
sudo tcpdump -i eth0 -tnn -c 1000 "dst port ${(j: or :)ports}" | awk -F"." '{print $1"."$2"."$3"."$4}' | sort | uniq -c | sort -nr | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find time_wait connection
|
# top20 of Find time_wait connection
|
||||||
function timewait20() {
|
function timewait20() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -nat | awk 'NR > 1 && /TIME-WAIT/ {print $5}' \
|
LANG= ss -nat
|
||||||
|| LANG= netstat -nat | awk 'NR > 2 && /TIME_WAIT/ {print $5}'
|
else
|
||||||
} | sort | uniq -c | sort -rn | head -n 20
|
LANG= netstat -nat
|
||||||
|
fi | awk '/TIME[-_]WAIT/ {print $5}' | sort | uniq -c | sort -rn | head -n 20
|
||||||
}
|
}
|
||||||
|
|
||||||
# top20 of Find SYN connection
|
# top20 of Find SYN connection
|
||||||
function syn20() {
|
function syn20() {
|
||||||
{
|
if (( $+commands[ss] )); then
|
||||||
LANG= ss -an | awk '/SYN/ {print $5}' \
|
LANG= ss -an
|
||||||
|| LANG= netstat -an | awk '/SYN/ {print $5}'
|
else
|
||||||
} | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
|
LANG= netstat -an
|
||||||
|
fi | awk '/SYN/ {print $5}' | awk -F: '{print $1}' | sort | uniq -c | sort -nr | head -n20
|
||||||
}
|
}
|
||||||
|
|
||||||
# Printing process according to the port number
|
# Printing process according to the port number
|
||||||
function port_pro() {
|
function port_pro() {
|
||||||
LANG= ss -ntlp | awk "NR > 1 && /:${1:-}/ {print \$6}" | sed 's/.*pid=\([^,]*\).*/\1/' \
|
if (( $+commands[ss] )); then
|
||||||
|| LANG= netstat -ntlp | awk "NR > 2 && /:${1:-}/ {print \$7}" | cut -d/ -f1
|
LANG= ss -ntlp | awk "NR > 1 && /:${1:-}/ {print \$6}" | sed 's/.*pid=\([^,]*\).*/\1/'
|
||||||
|
else
|
||||||
|
LANG= netstat -ntlp | awk "NR > 2 && /:${1:-}/ {print \$7}" | cut -d/ -f1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# top10 of gain access to the ip address
|
# top10 of gain access to the ip address
|
||||||
|
|||||||
Reference in New Issue
Block a user