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

安全问题

  • sql注入
    http://www.xfocus.net/articles/200806/983.html
  • 用户弱口令
  • mysql 目录中的user.myd中储存用户与密码
  • 报错注入
  • 0day.....

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 ""
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
修改配置

存在漏洞

  • 暴力破解
    hydra -l root -P /root/password.txt 192.168.0.128 ssh
  • RC4 已经不再安全
    暴力破解RC4
    http://bbs.pediy.com/showthread.php?t=174969

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端口进行访问。

你可能感兴趣的:(Linux 服务 安全)