Linux Sistem Bilgisi Toplayan Bash Script
Penetration testlerinizde yada gerektiginde günlük kullanımlarda faydalanabileceğiniz bir script.
#!/bin/bash # linuxsysinfo.sh - Linux isletim sistemi uzerinde bilgilerin alinmasini amaclamakta. # By savas saygili LSB=/usr/bin/lsb_release function pause(){ local message="$@" [ -z $message ] && message="Devam etmek icin [Enter] basiniz..." read -p "$message" readEnterKey } function show_menu(){ date echo "---------------------------" echo "| Ana Menu |" echo "---------------------------" echo "1. isletim sistem bilgisi" echo "2. Hostname ve dns bilgisi" echo "3. Network bilgisi" echo "4. Mevcut oturumu olan kullanicilar" echo "5. En son oturum acmis kullanicilar" echo "6. bosta ve kullanilmakta olan memory bilgisi" echo "7. rapor olustur" echo "8. exit" } function write_header(){ local h="$@" echo "---------------------------------------------------------------" echo " ${h}" echo "---------------------------------------------------------------" } function os_info(){ write_header " Isletim Sistem Bilgisi " echo "Isletim Sistemi : $(uname)" [ -x $LSB ] && $LSB -a || echo "$LSB sistemde yuklu degil (set \$LSB variable)" pause } function host_info(){ local dnsips=$(sed -e '/^$/d' /etc/resolv.conf | awk '{if (tolower($1)=="nameserver") print $2}') write_header " Hostname ve DNS bilgisi " echo "Hostname : $(hostname -s)" echo "DNS ismi : $(hostname -d)" echo "FQDN : $(hostname -f)" echo "Network adresi (IP) : $(hostname -i)" echo "DNS name server adresi (DNS IP) : ${dnsips}" pause } function net_info(){ devices=$(netstat -i | cut -d" " -f1 | egrep -v "^Kernel|Iface|lo") write_header " Network Bilgisi " echo "Toplam network kartlari : $(wc -w <<<${devices})" echo "*** IP Adres Bilgileri ***" ip -4 address show echo "***********************" echo "*** Network routing ***" echo "***********************" netstat -nr echo "**************************************" echo "********** Network Trafigi **********" echo "**************************************" netstat -i pause } function user_info(){ local cmd="$1" case "$cmd" in who) write_header " Mevcut oturumu olan kullanicilar "; who -H; pause ;; last) write_header " En Son Oturum Acmis Kullanicilar "; last ; pause ;; esac } function report_gen () { echo "Pc adi">full_report.txt echo "----------------------------------------------">>full_report.txt /bin/hostname >>full_report.txt echo -e "|\033[31mpc adi kopyalandi\033[0m|\n" echo "----------------------------------------------">>full_report.txt echo "whoami">>full_report.txt echo "----------------------------------------------">>full_report.txt /usr/bin/whoami >>full_report.txt echo -e "|\033[31mwhoami kopyalandi\033[0m|\n" echo "----------------------------------------------">>full_report.txt echo "network interface">>full_report.txt echo "----------------------------------------------">>full_report.txt /sbin/ifconfig -a >>full_report.txt echo -e "|\033[31mNetwork interface kopyalandi\033[0m|\n" echo "/etc/apache2/apache2.conf>">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/apache2/apache2.conf>>full_report.txt echo -e "|\033[31mapache2.conf kopyalandi\033[0m|\n" echo "cat /etc/apache2/ports.conf">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/apache2/ports.conf>>full_report.txt echo -e "|\033[31mports.conf kopyalandi\033[0m|\n" echo "/etc/ca-certificates.conf">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/ca-certificates.conf>>full_report.txt echo -e "|\033[31mca-certificates.conf kopyalandi\033[0m|\n" echo "/etc/fstab ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/fstab>>full_report.txt echo -e "|\033[31mfstab kopyalandi\033[0m|\n" echo "/etc/hosts ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/hosts>>full_report.txt echo -e "|\033[31mhosts kopyalandi\033[0m|\n" echo "/etc/mysql/my.cnf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/mysql/my.cnf>>full_report.txt echo -e "|\033[31mmysql.conf kopyalandi\033[0m|\n" echo "/etc/passwd ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/passwd>>full_report.txt echo -e "|\033[31mpasswd kopyalandi\033[0m|\n" echo "/etc/proxychains.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/proxychains.conf>>full_report.txt echo -e "|\033[31mproxychains.conf kopyalandi\033[0m|\n" echo "/etc/rkhunter.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/rkhunter.conf>>full_report.txt echo -e "|\033[31mrkhunter.conf kopyalandi\033[0m|\n" echo "/etc/resolv.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/resolv.conf>>full_report.txt echo -e "|\033[31mresolve.conf kopyalandi\033[0m|\n" echo "/etc/rpc ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/rpc>>full_report.txt echo -e "|\033[31mrpc kopyalandi\033[0m|\n" echo "/etc/samba/smb.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/samba/smb.conf>>full_report.txt echo -e "|\033[31msmb.conf kopyalandi\033[0m|\n" echo "/etc/security/access.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/security/access.conf>>full_report.txt echo -e "|\033[31maccess.conf kopyalandi\033[0m|\n" echo "/etc/security/sepermit.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/security/sepermit.conf>>full_report.txt echo -e "|\033[31msepermit.conf kopyalandi\033[0m|\n" echo " /etc/shadow ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/shadow>>full_report.txt echo -e "|\033[31mshadow kopyalandi\033[0m|\n" echo "/etc/shells ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/shells>>full_report.txt echo -e "|\033[31mshells kopyalandi\033[0m|\n" echo "/etc/snort/snort.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/snort/snort.conf>>full_report.txt echo -e "|\033[31msnort.conf kopyalandi\033[0m|\n" echo "/etc/ssh/sshd_config ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/ssh/sshd_config>>full_report.txt echo -e "|\033[31msshd_config kopyalandi\033[0m|\n" echo "/etc/sudoers ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/sudoers>>full_report.txt echo -e "|\033[31msudoers kopyalandi\033[0m|\n" echo "/etc/sysctl.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/sysctl.conf>>full_report.txt echo -e "|\033[31metc/sysctl.conf kopyalandi\033[0m|\n" echo "/etc/ufw/sysctl.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/ufw/sysctl.conf>>full_report.txt echo -e "|\033[31msysctl.conf kopyalandi\033[0m|\n" echo "/etc/ufw/ufw.conf ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /etc/ufw/ufw.conf>>full_report.txt echo -e "|\033[31mufw.conf kopyalandi\033[0m|\n" echo "/root/.bash_history ">>full_report.txt echo "----------------------------------------------">>full_report.txt cat /root/.bash_history>>full_report.txt echo -e "|\033[31mbash_history kopyalandi\033[0m|\n" pause } function mem_info(){ write_header " Bosta ve kullanilmakta olan memory " free -m echo "*********************************" echo "* Virtual memory istatistikleri *" echo "*********************************" vmstat echo "***********************************" echo "** Top 5 memory Tuketen process **" echo "***********************************" ps auxf | sort -nr -k 4 | head -5 pause } # Purpose - Get input via the keyboard and make a decision using case..esac function read_input(){ local c read -p "Lutfen Seciminizi yapiniz [ 1 - 8 ] " c case $c in 1) os_info ;; 2) host_info ;; 3) net_info ;; 4) user_info "who" ;; 5) user_info "last" ;; 6) mem_info ;; 7) report_gen;; 8) echo "Efendim gene bekleriz :) "; exit 0 ;; *) echo "Lutfen 1 ila 8 arasinda secim yapiniz." pause esac } trap '' SIGINT SIGQUIT SIGTSTP while true do clear show_menu read_input done