工具原理很简单:读取位于用户工作目录下的Addresses.cdb提取相关的账号密码信息。
代码如下:
import os import re import sys import tkinter import tkinter.messagebox userdir=os.path.expanduser('~') file=userdir+'\\AppData\\Roaming\\Mikrotik\\Winbox\\Addresses.cdb' try: fo=open(file, mode='rb') except FileNotFoundError: tkinter.messagebox.showerror('错误','Addresses.cdb文件不存在') exit() data=fo.read() #print(data) fo.close() data=str(data) #print(text) s = re.sub(r'M2', '', data) s = re.sub(r'\\x.[a-zA-Z0-9]{0,1}', '', s) s = re.sub(r'!', ' ', s) s = re.sub(r'\\r', '', s) s = re.sub(r'b\'', '', s) s = re.sub(r'\\n\\t\\t\\t', '\n', s) s = re.sub(r'\\t\s', '', s) s = re.sub(r'\\t', '', s) s = re.sub(r'\\n', '', s) s = re.sub(r'\s\s<own>\s', '', s) s = s.strip('\'') s = s.strip() s = s.split('\n') #print(s) #print(len(s)) for x in s: #print(x) #print(x.split()) x = x.split() add= x[-1] user=x[-2] if (len(x))>=1: note=x[1] else: tkinter.messagebox.showerror('错误','解析Note字段出错') exit() passw=x[0] f=open('a.txt',mode='a') text='ROS地址:'+add+' 用户名:'+user+' 密码:'+passw+' Note:'+note f.write(text+'\n') f.close()
未经允许不得转载:运维大虾 » winbox本地密码提取|ros密码查看工具