postgresql 弱口令检测
2017-05-10 14:44
169 查看
import socket import binascii import hashlib def make_response(buf,username,password,salt): pu=hashlib.md5(password+username).hexdigest() buf=hashlib.md5(pu+salt).hexdigest() return 'md5'+buf def check(host,port,username,password,timeout): try: socket.setdefaulttimeout(timeout) sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) address=(host,port) sock.connect(address) packet_length = len(username) + 7 +len("\x03user database postgres application_name psql client_encoding UTF8 ") print "%c"%(packet_length) p="%c%c%c%c%c\x03%c%cuser%c%s%cdatabase%cpostgres%capplication_name%cpsql%cclient_encoding%cUTF8%c%c"%( 0,0,0,packet_length,0,0,0,0,username,0,0,0,0,0,0,0,0) print [p] d = "\x00\x00\x00\x54\x00\x03\x00\x00\x75\x73\x65\x72\x00\x70\x6f\x73\x74\x67\x72\x65\x73\x00\x64\x61\x74\x61\x62\x61\x73\x65\x00\x70\x6f\x73\x74\x67\x72\x65\x73\x00\x61\x70\x70\x6c\x69\x63\x61\x74\x69\x6f\x6e\x5f\x6e\x61\x6d\x65\x00\x70\x73\x71\x6c\x00\x63\x6c\x69\x65\x6e\x74\x5f\x65\x6e\x63\x6f\x64\x69\x6e\x67\x00\x55\x54\x46\x38\x00\x00" sock.send(d) packet = sock.recv(1024) print packet psql_salt=[] if packet[0]=='R': print "postgresql" a=str([packet[4]]) b=int(a[4:6],16) authentication_type=str([packet[8]]) c=int(authentication_type[4:6],16) if c==5: psql_salt=packet[9:] buf=[] salt = psql_salt lmd5= make_response(buf,username,password,salt) packet_length1=len(lmd5)+5+len('p') pp='p%c%c%c%c%s%c'%(0,0,0,packet_length1 - 1,lmd5,0) sock.send(pp) packet1 = sock.recv(1024) if "R\x00\x00\x00" in packet1: print 'yes' else: print "username or password is wrong " except Exception,e: print e if __name__ == '__main__': host = '127.0.0.1' port = 5432 username = 'postgres1' password = '123456' timeout = 5 check(host,port,username,password,timeout)协议分析
相关文章推荐
- 弱口令检测——John the Ripper
- 使用john弱口令检测破解用户密码步骤
- 国外远程桌面弱口令检测工具 RDP ForcerX
- zabbix弱口令批量检测
- windows下PostgreSQL打开psql.exe提示口令无法进入
- linux安全---系统更新+弱口令检测工具+nmap扫描工具
- postgresql 弱口令 UDF 攻击
- 利用postgresql进行缓冲区内对象检测过程中遇到的sql查询效率问题解决方案记录
- 基于端口的弱口令检测工具--iscan
- Windows下PostgreSQL的用户口令问题
- 防扫描配置与弱口令利用,检测和防御
- 国外3389远程桌面弱口令检测工具 xTSCrack – RDP AuditTool
- John the Ripper-弱口令检测
- JAVA里面读取PostgreSQL数据库最近80条温度检测记录,并用Highcharts展示在网站上
- 使用JR检测系统弱口令
- 弱口令检测、端口扫描
- Linux通过Joth the Ripper实现弱口令检测
- vc6操作PostgreSQL增加错误检测和现实链接属性
- postgreSQL进程检测与数据库备份脚本
- linux系统安全及应用——弱口令检测