Python实现AD域认证
Python 通过ldap进行ad域账号的校验。
首先需要安装python-ldap的模块 http://www.python-ldap.org/。 在这里用的是windows系统,当然比较容易,下载地址 http://pypi.python.org/pypi/python-ldap/。
安装后在python 的交互环境里输入import ldap 如果没有问题就说明安装成功了。
Windows 无法安装 python-ldap 时,详见:https://xiexianbin.cn/python/2018/04/23/pip-install-python-ldap
python-ldap 3行集成域认证
import ldap
conn = ldap.initialize('ldap://host')
conn.simple_bind_s('domain\username', 'password')
注意验证时传空值验证也是可以通过的,注意要对password进行检查。
ldap3
from ldap3 import Server,Connection,ALL,NTLM
server = Server('192.168.10.1',get_info=ALL)
conn = Connection(server,user='Domain\\user', password='xxxxxxx',auto_bind=True,authentication='NTLM')
2019-02-14 11:43 Bypass