#!/bin/sh # gethostinfo - collect info about a host # author : dave w capella dave@grox.net # date : Wed Mar 16 10:51:44 EST 2005 # platform : Linux frick.grammatech.com. 2.4.25-1-686-smp #2 SMP Wed Apr 14 23:04:13 EST 2004 i686 GNU/Linux # # bugs: as of 3/16/05, linux-specific # # ------------------------------------------------------------ # # Copyright (c) 2005 dave w capella All rights reserved. # # May be freely distributed and used provided the above copyright # notice is retained and all modifications are clearly indicated. # # Provided without warranty of any kind. # # The author makes no promise of technical support, but bug reports # suggestions, questions, and comments are welcome. All will be # answered via electronic mail as time allows. # ############################################################ PRG=`basename $0` NOW=`date` DIV="-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/X11R6/bin LOGFILE=/tmp/$PRG.log usage () { cat <&1 exec 4>&2 exec >$LOGFILE exec 2>$LOGFILE ############################################################# # data collection # basic info about architecture heading Basic Information echo -n "host: " hostname -f echo -n "domain: " domainname echo -n "nis domain: " nisdomainname echo uname -a # if linux, which distro? heading GNU/Linux Distribution if [ -f /etc/redhat-release ] ; then cat /etc/redhat-release echo rpm -qa fi if [ -f /etc/debian_version ] ; then cat /etc/debian_version echo dpkg -l fi if [ -f /etc/SuSE-release ] ; then cat /etc/SuSE-release rpm -qa fi if [ -f /etc/slackware-version ] ; then cat /etc/slackware-version ls /var/adm/packages fi # cpu heading CPU cat /proc/cpuinfo # memory heading Memory cat /proc/meminfo # disk heading Disks fdisk -l echo echo "/etc/fstab" cat /etc/fstab echo echo "df..." df -h echo echo "mount..." mount # hardware heading Hardware echo "dmesg:" dmesg echo echo "interrupts:" cat /proc/interrupts echo "IO memory:" cat /proc/iomem echo "devices:" cat /proc/devices echo "misc:" cat /proc/misc echo "filesystems:" cat /proc/filesystems echo "PCI info:" cat /proc/pci echo "SCSI info:" cat /proc/scsi/scsi echo "USB info:" cat /proc/bus/usb/devices # auth config heading Authorization Configuration echo "passwd group shadow..." ls -l /etc/passwd /etc/group /etc/shadow echo "/etc/nsswitch.conf" echo cat /etc/nsswitch.conf echo "pam..." echo echo "/etc/pamd.conf:" cat /etc/pamd.conf echo echo "/etc/pam.d:" ls -l /etc/pam.d echo echo "ssh_config..." cat `locate ssh_config | egrep /etc/.*fig$` echo "sshd_config..." cat `locate sshd_config | egrep /etc/.*fig$` # kernel echo "modules..." heading Kernel lsmod # batch jobs heading Batch Jobs echo "/var/spool/at..." find /var/spool/at* -ls echo "/var/spool/cron..." echo "/var/spool/cron..." find /var/spool/cron* -ls echo "/etc/cron..." find /etc/cron* -ls echo "root crontab..." crontab -l # processes heading Processes ps aux # daemons and network services heading Daemons chkconfig --list echo echo "inetd.conf" egrep -v '^#|^$' /etc/inetd.conf echo echo "xinetd..." cat /etc/xinetd.conf echo "enabled services for xinetd..." egrep -i 'disable.*no|enable.*yes' /etc/xinetd.d/* # network heading Network Configuration ifconfig -a echo echo "network connections (including daemons)" netstat -a echo "processes for network connections" netstat -pa echo "routing tables" netstat -r heading TCP Wrappers echo "hosts.allow/deny" cat /etc/hosts.allow echo cat /etc/hosts.deny if lsmod|grep -q chain >/dev/null 2>/dev/null ; then heading ipchains echo "modules..." lsmod | grep ipchain echo "settings..." ipchains -L else echo "ipchains not active." fi if lsmod|grep -q iptable >/dev/null 2>/dev/null ; then heading iptables echo "modules..." lsmod iptable echo "settings..." iptables -L else echo "iptables not active." fi heading Printing for f in /etc/printcap* ; do echo $f cat $f echo done heading Samba cat `locate smb.conf | egrep '/etc/.*smb.conf$'` echo testparm -s echo smbstatus ############################################################# # end: data collection # all done. turn the terminal back on # and let the user know. # exec 1>&3 exec 2>&4 cat <<-EOM $DIV Audit complete. Information saved to $LOGFILE. Would you like to view the file now?[y/N] $DIV EOM read ANS case $ANS in y|Y) less $LOGFILE ;; esac exit 0 ###################################################################### # eof: gethostinfo