Skip to content

Commit

Permalink
new functions and alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 29, 2024
1 parent 2824102 commit ec547c3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
13 changes: 10 additions & 3 deletions home/.dot/.bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,11 @@ alias docker_rm_all_volumes='docker volume ls -q | xargs --no-run-if-empty docke

# remove all orphaned docker volumes
alias docker_rm_all_orphaned_volumes='docker volume ls -qf dangling=true | xargs --no-run-if-empty docker volume rm'



#show all container with internal IP
alias docker_net_info='sudo docker ps -q | xargs -n 1 sudo docker inspect --format "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}} {{ .Name }}" | sed "s/ \// /"'


###########################
# Docker Compose shortcuts
###########################
Expand Down Expand Up @@ -807,4 +810,8 @@ alias nmap_scanNetwork="scanNetwork_nmap"
alias scanNetwork_arp="arp -a"

#Host-Discovery mit ARP-scan
alias scanNetwork_arpScan="arp-scan --localnet"
alias scanNetwork_arpScan="arp-scan --localnet"

#influx get infos about the hdd size per measurment
alas influx_hdd_measurment = "sudo influx_inspect report-disk -detailed /data/var/lib/influxdb/ "
alas influx_hdd_measurment_save = "sudo influx_inspect report-disk -detailed /data/var/lib/influxdb/ > data.json "
53 changes: 53 additions & 0 deletions home/.dot/.bash_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2885,6 +2885,59 @@ function portscan_parallel (){
time seq 65535 | parallel -k --joblog portscan -j9 --pipe --cat -j200% -n9000 --tagstring '\033[30;3{=$_=++$::color%8=}m' 'nc -vz localhost $(head -n1 {})-$(tail -n1 {})'
}

function portsD() {
if ! command -v netstat &> /dev/null; then
echo "Error: netstat is not installed. Please install it using your package manager."
return 1 # Exit the function with an error code
fi

# Define a list of ports to ignore
IGNORE_PORTS=(53)

echo "Processing netstat output and appending program paths and working directories..."

# Print header with fixed column widths
printf "%-22s %-25s %-45s %-s\n" "Local Address" "PID/Program Name" "Program Path" "Working Directory"

# Run netstat command and process the output
sudo netstat -lnpt4e | while read -r line; do
# Skip the header line
if [[ "$line" == *"Proto Recv-Q Send-Q"* ]]; then
continue
fi

# Only process lines where state is LISTEN
if [[ "$line" == *LISTEN* ]]; then
# Extract the port number from Local Address
local_addr=$(echo "$line" | awk '{print $4}')
port=$(echo "$local_addr" | awk -F: '{print $NF}')

# Check if the port is in the ignore list
if [[ " ${IGNORE_PORTS[@]} " =~ " $port " ]]; then
continue
fi

# Extract PID/Program Name
pid_prog=$(echo "$line" | awk '{print $9}')

# Extract PID from PID/Program Name
pid=$(echo "$pid_prog" | cut -d'/' -f1)
program_path="Unknown"
working_dir="Unknown"

# Retrieve the full path of the program using the PID
if [[ "$pid" =~ ^[0-9]+$ ]]; then
program_path=$(sudo readlink -f /proc/$pid/exe 2>/dev/null || echo "Unknown")
working_dir=$(sudo readlink -f /proc/$pid/cwd 2>/dev/null || echo "Unknown")
fi

# Print formatted output with fixed column widths
printf "%-22s %-25s %-45s %-s\n" "$local_addr" "$pid_prog" "$program_path" "$working_dir"
fi
done
}


#mural
function corganwashere(){
tput setaf 1;tput rev;h=$(tput lines);w=$[$(tput cols)/6];c=$(seq -ws '_____|' $[$w+1]|tr -d "0-9");for a in $(seq $[$h/2]);do echo $c;echo ${c//|___/___|};done;tput cup 0;toilet -t -f bigmono12 "?Corganwashere";tput cup $h
Expand Down
2 changes: 1 addition & 1 deletion home/.profile
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ fi
#[ ! -s ~/.plesk_banner ] || . ~/.plesk_banner


export PATH="$HOME/.cargo/bin:$PATH"
. "$HOME/.cargo/env"

0 comments on commit ec547c3

Please sign in to comment.