1. 程式人生 > 其它 >PWN保護機制詳解

PWN保護機制詳解

1、統計出/etc/passwd檔案中其預設shell為非/sbin/nologin的使用者個數,並將使用者都顯示出來

echo "/etc/passwd檔案中其預設shell為非/sbin/nologin的使用者個數:"`cat /etc/passwd |grep -v -c '/sbin/nologin$'`&&cat /etc/passwd |grep -v '/sbin/nologin$' | cut -d ":" -f 1

2、查出使用者UID最大值的使用者名稱、UID及shell型別

cat /etc/passwd | cut -d: -f 1,3,7 | sort -nrt: -k2 | head -1
或者cat /etc/passwd | cut -d: -f 1,3,7 | sort -nt: -k2 | tail -1

3、統計當前連線本機的每個遠端主機IP的連線數,並按從大到小排序

who | tr -s " " |cut -d" " -f 5 |uniq -c | sort -nt" "

4、編寫指令碼disk.sh,顯示當前硬碟分割槽中空間利用率最大的值

1、vim bash.sh
2、df| tr -s ' ' '%'|cut -d% -f5|sort -nr|head -1

3、 bash -n bash.sh
4、bash bash.sh

5、編寫指令碼 systeminfo.sh,顯示當前主機系統資訊,包括:主機名,IPv4地址,作業系統版本,核心版本,CPU型號,記憶體大小,硬碟大小

vim systeminfo.sh

#!/bin/bash
HOSTNAME=`hostname`
IPADDR=`ip a|grep "ens33" |grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|head -n 1`
Sysversion=`cat /etc/redhat-release`
KERNEL=`uname -r`
CPUTYPE=`lscpu|grep 'Model name'|head -1|tr -s " " |cut -d " " -f3-9`
MEMSIZE=`free -h|grep Mem|tr -s " " :|cut -d: -f2`
DISKSIZE=`lsblk |grep ^sd|tr -s " "|cut -d " " -f4`
echo "主機名:${HOSTNAME}"
echo "IPv4地址:${IPADDR}"
echo "作業系統版本:${Sysversion}"
echo "核心版本:${KERNEL}"
echo "CPU型號:${CPUTYPE}"
echo "記憶體大小:${MEMSIZE}"
echo "硬碟大小:${DISKSIZE}"