Python武器库开发-武器库篇之Mongodb未授权漏洞扫描器
import pymongo
from pymongo import MongoClient
from pprint import pprint
class MongoDbUnauthorizedScanner:
def __init__(self, host, port, dbname):
self.host = host
self.port = port
self.dbname = dbname
def scan(self):
try:
client = MongoClient(self.host, self.port)
dbs = client.list_database_names()
print("[+] Found the following databases: ", dbs)
except pymongo.errors.OperationFailure as e:
print("[!] Error: ", e)
if __name__ == "__main__":
scanner = MongoDbUnauthorizedScanner('localhost', 27017, 'admin')
scanner.scan()
这段代码使用了pymongo库来连接MongoDB服务,并尝试列出所有的数据库。如果连接失败,它会捕获异常并打印错误信息。这个简单的示例展示了如何使用Python进行MongoDB未授权访问扫描。
评论已关闭