弱口令检测感想

前言

最近一直再写弱口令检测插件 对于最近写过的几个服务简单说明一下
以下是写插件时随手记的 可能会有些混乱
其实这些弱口令的识别都不算复杂 只要仔细阅读文档 就很容易找到配置和检测方法

vsftp

介绍

VSFTP是一个基于GPL发布的类Unix系统上使用的FTP服务器软件,它的全称是Very Secure FTP 从此名称可以看出来,编制者的初衷是代码的安全。

关于VsFtp用户登录的几种认证方式
http://www.voidcn.com/article/p-gtzxjzlu-bba.html
https://security.appspot.com/vsftpd/vsftpd_conf.html
dockerfile https://github.com/fauria/docker-vsftpd/blob/master/run-vsftpd.sh

认证方式

匿名登录

配置文件/etc/vsftpd/vsftpd.conf
https://security.appspot.com/vsftpd/vsftpd_conf.html
是否允许匿名登录FTP服务器,默认设置为YES允许
用户可使用用户名ftp或anonymous进行ftp登录,口令为用户的E-mail地址。
如不允许匿名访问则设置为NO
anonymous_enable=YES

检测

解析配置文件拿到键值

本地用户登录

在默认情况下允许系统账户(/etc/passwd)使用,使用系统账户登录存在很大的安全问题。
是否允许本地用户(即linux系统中的用户帐号)登录FTP服务器,默认设置为YES允许本地用户登录后会进入用户主目录,而匿名用户登录后进入匿名用户的下载目录/var/ftp/pub
若只允许匿名用户访问,前面加上#注释掉即可阻止本地用户访问FTP服务器 local_enable=YES
密码似乎最多为8位

检测

解析配置文件拿到键值

通过本地数据文件实现虚拟用户的访问

db_load -T -t hash -f loguser.txt /etc/vsftpd/virtual_users.db
chmod 600 /etc/vsftpd/virtual_users.db
修改PAM认证文件/etc/pam.d/vsftpd
auth required /lib/security/pam_userdb.so db=/etc/vsftpd/virtual_users
account required /lib/security/pam_userdb.so db=/etc/vsftpd/virtual_users

使用db_dump -d a /etc/vsftpd/virtual_users.db 可以查看其中的密码

检测

pam_service_name=vsftpd_virtual 解析配置文件拿到键值 cat /etc/pam.d/vsftpd_virtual 通过正则找到db db=/etc/vsftpd/virtual_users db_dump -d a /etc/vsftpd/virtual_users.db 继续正则读取用户名密码

通过Mysql实现虚拟用户访问

1:修改/etc/vsftpd/vsftpd.conf

anonymous_enable=NO
local_enable=YES  PAM方式此处必须为YES,如果不是将出现错误
guest_enable=YES 
guest_username=vsftpd 这两行的意思是采用虚拟用户形式 
virtual_use_local_privs=YES 虚拟用户和本地用户权限相同

2:建立数据库和表,授权一个用户

mysql>create table user(name char(20),passwd char(20)); 
mysql>insert user values('test1',password'(12345)');
mysql>insert user values ('test2',password'(54321)');
mysql>grant select on ftpd.user to ftpd@localhost identified by '123456'; 

3:修改PAM认证文件/etc/pam.d/vsftpd

auth required /lib/security/pam_mysql.so user=ftpd passwd=123456 host=localhost db=ftpd table=user usercolumn=name passwdcolumn=passwd crypt=2
account required /lib/security/pam_mysql.so user=ftpd passwd=123456 host=localhost db=ftpd table=user usercolumn=name passwdcolumn=passwd crypt=2
检测

暂不检测

jekins

介绍

Jenkins是一个开源软件项目,是基于Java开发的一种持续集成工具,用于监控持续重复的工作,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能。

认证方式

配置文件

Jenkins初始化后会自动生成密码 之后要求用户创建新用户并设置密码 用户密码存放在jenins_home/users/xxx/config.xml中 使用BCrypt hash后存储
https://www.jianshu.com/p/2b131bfc2f10
https://coolshell.cn/articles/2078.html/comment-page-2#comments

检测

解析XML拿到['user']['properties']['hudson.security.HudsonPrivateSecurityRealm_-Details']['passwordHash']
通过bcrypt_compare_hash_and_password与字典中的密码比对

Redis

介绍

Redis(Remote Dictionary Server ),即远程字典服务,是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。从2010年3月15日起,Redis的开发工作由VMware主持。从2013年5月开始,Redis的开发由Pivotal赞助。

认证方式

–requirepass 指定口令

redis-server /etc/redis555 --requirepass 654321 这种情况 即使配置文件中存在requirepass
参数的配置会优先生效 而不是配置文件

使用docker镜像时alpine版本镜像才可以识别到cmdline

–config 指定配置文件

检测

读取cmdline 和配置文件
查看requirepass的值

rsync

介绍

官网 rsync-⁠一种快速,通用,远程(和本地)文件复制工具

文档

https://download.samba.org/pub/rsync/rsync.1 https://download.samba.org/pub/rsync/rsyncd.conf.5

认证方式

配置文件/etc/rsyncd.conf中的secrets file

secrets file This parameter specifies the name of a file that contains the username:password and/or @groupname:password pairs used for authenticating this module. This file is only consulted if the “auth users” parameter is specified. The file is line-based and contains one name:password pair per line. Any line has a hash (#) as the very first character on the line is considered a comment and is skipped. The passwords can contain any characters but be warned that many operating systems limit the length of passwords that can be typed at the client end, so you may find that passwords longer than 8 characters don’t work.

The use of group-specific lines are only relevant when the module is being authorized using a matching “@groupname” rule. When that happens, the user can be authorized via either their “username:password” line or the “@groupname:password” line for the group that triggered the authentication.

It is up to you what kind of password entries you want to include, either users, groups, or both. The use of group rules in “auth users” does not require that you specify a group password if you do not want to use shared passwords.

There is no default for the “secrets file” parameter, you must choose a name (such as /etc/rsyncd.secrets). The file must normally not be readable by “other”; see “strict modes”. If the file is not found or is rejected, no logins for a “user auth” module will be possible.

secret file 中的密码为明文username:password

检测

读取config 拿到secret file的路径 再读取文件

相关连接

Rsync >=3.0 弱口令 PoC

##


© 2021. All rights reserved.

本站总访问量 Web Analytics

Powered by Hydejack v9.1.2 & Moded by ZYA