Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Boelen <michael.boelen@cisofy.com>2016-05-05 18:49:41 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2016-05-05 18:49:41 +0300
commit788ab9999d43106d8457f5739f842a2921df40df (patch)
treec3f56f05fa58139903d515b8e19d579ae99ce40a /include
parent9f14495d707a0cf0592716562c401d085be11bac (diff)
Create a version 2 host ID
Diffstat (limited to 'include')
-rw-r--r--include/functions46
1 files changed, 40 insertions, 6 deletions
diff --git a/include/functions b/include/functions
index acd6c029..719f7f24 100644
--- a/include/functions
+++ b/include/functions
@@ -741,19 +741,16 @@
FIND=`${IFCONFIGBINARY} ${I} | grep ether | awk '{ if ($1=="ether") { print $2 }}'`
if [ ! "${SHA1SUMBINARY}" = "" ]; then
HOSTID=`echo ${FIND} | ${SHA1SUMBINARY} | awk '{ print $1 }'`
+ elif [ ! "${OPENSSLBINARY}" = "" ]; then
+ HOSTID=`echo ${FIND} | ${OPENSSLBINARY} sha -sha1 | awk '{ print $2 }'`
else
- if [ ! "${OPENSSLBINARY}" = "" ]; then
- HOSTID=`echo ${FIND} | ${OPENSSLBINARY} sha -sha1 | awk '{ print $2 }'`
- else
- ReportException "GetHostID" "Can not find sha1/sha1sum or openssl"
- fi
+ ReportException "GetHostID" "Can not find sha1/sha1sum or openssl"
fi
else
ReportException "GetHostID" "No interface found op Solaris to create HostID"
fi
;;
-
*)
ReportException "GetHostID" "Can't create HOSTID as OS is not supported yet by this function"
;;
@@ -805,6 +802,43 @@
fi
fi
+ # New style host ID
+ if [ "${HOSTID2}" = "" ]; then
+
+ LogText "Info: creating a HostID (version 2)"
+ FOUND=0
+ DATA_SSH=""
+ # Use public keys
+ SSH_KEY_FILES="ssh_host_ed25519_key.pub ssh_host_ecdsa_key.pub ssh_host_dsa_key.pub ssh_host_rsa_key.pub"
+ if [ -d /etc/ssh ]; then
+ for I in ${SSH_KEY_FILES}; do
+ if [ ${FOUND} -eq 0 ]; then
+ if [ -f /etc/ssh/${I} ]; then
+ LogText "Result: found file ${I} in /etc/ssh"
+ DATA_SSH=$(cat /etc/ssh/${I})
+ FOUND=1
+ fi
+ fi
+ done
+ else
+ LogText "Result: no /etc/ssh directory found, skipping"
+ fi
+
+ if [ ! "${DATA_SSH}" = "" ]; then
+ # Create hashes
+ if [ ! "${SHA256SUMBINARY}" = "" ]; then
+ HASH_SSH=$(echo ${DATA_SSH} | ${SHA256SUMBINARY} | awk '{ print $1 }')
+ HASH_HOSTNAME=$(echo ${HOSTNAME} | ${SHA256SUMBINARY} | awk '{ print $1 }')
+ elif [ ! "${OPENSSLBINARY}" = "" ]; then
+ HASH_SSH=$(echo ${DATA_SSH} | ${OPENSSLBINARY} sha -sha256 | awk '{ print $2 }')
+ HASH_HOSTNAME=$(echo ${HOSTNAME} | ${OPENSSLBINARY} sha -sha256 | awk '{ print $2 }')
+ fi
+ LogText "Hash (hostname): ${HASH_HOSTNAME}"
+ LogText "Hash (ssh): ${HASH_SSH}"
+ Report "hostid2=${HASH_HOSTNAME}-${HASH_SSH}"
+ fi
+ fi
+
# Show an exception if no HostID could be created, to ensure each system (and scan) has one
if [ "${HOSTID}" = "" ]; then
ReportException "GetHostID" "No unique host identifier could be created."