-
Notifications
You must be signed in to change notification settings - Fork 1
/
baseline_check.sh
executable file
·62 lines (52 loc) · 1.63 KB
/
baseline_check.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
###############################################################################
# Brief: Linux baseline check.
# Time: 2016/04/21
# Update: 2016/06/08
#
# Author: xyang
#
# Referer: http://drops.wooyun.org/tips/2621
###############################################################################
VERSION=0.02
OS=`uname`
if [ -f "/etc/redhat-release" ]; then
OS_NAME=`cat /etc/redhat-release`
PLATFORM=`uname -i`
elif [ -f "/etc/lsb-release" ]; then
OS_NAME=`cat /etc/lsb-release | grep "DISTRIB_DESCRIPTION" | awk -F "\"" '{print $2}'`
PLATFORM=`arch`
elif [ -f "/etc/issue.net" ]; then
OS_NAME=`cat /etc/issue.net`
PLATFORM=`uname -i`
else
OS_NAME="localhost"
PLATFORM=`unknown`
fi
HOST_NAME=`hostname`
## 系统基本信息
echo
echo "--------------------------------------------------------------------------"
echo " Operating system: ${OS}"
echo " Operating system version: ${OS_NAME}"
echo " Hardware platform: ${PLATFORM}"
echo " Hostname: ${HOST_NAME}"
echo "--------------------------------------------------------------------------"
echo
## 基线检测
LOGFILE="./log/$(cat /etc/hostname)-$(date '+%Y%m%d%H%M%S').log"
PLUGINDIR="./plugins/"
PROBLEM_COUNT=0
# load common functions
. ./include/*.sh
# search plugins & load plugins
FIND_PLUGINS=$(find ${PLUGINDIR} -type f -name "plugin_[a-z_]*\.sh" | sort)
for PLUGIN_FILE in ${FIND_PLUGINS}; do
Show ${SECTION}"Found plugin file: ${PLUGIN_FILE}"${NORMAL}
if [ -f ${PLUGIN_FILE} ]; then
. ${PLUGIN_FILE}
fi
done
# result
echo
Show "${PROBLEM_COUNT} total problems found"