100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > python打开chrome浏览器登录用户名密码_[工具]Python获取Chrome浏览器已保存的所有账号密码...

python打开chrome浏览器登录用户名密码_[工具]Python获取Chrome浏览器已保存的所有账号密码...

时间:2020-02-03 09:33:05

相关推荐

python打开chrome浏览器登录用户名密码_[工具]Python获取Chrome浏览器已保存的所有账号密码...

Chrome浏览器已保存的密码都保存在一个sqlite3数据库文件中,和Cookies数据库在同一个文件夹,类似:

C:\Users\Lucas Lee\AppData\Local\Google\Chrome\User Data\Default\Login Data

使用CryptUnprotectData函数解密数据库中的密码字段,即可还原密码,只需要User权限,并且只能是User权限。

为了防止出现读写出错,建议先把数据库临时拷贝到当前目录。

程序会读出所有的账号、密码、网站,写入文件夹下ChromePass.txt文件

代码如下:

importos,sys

importshutil

importsqlite3

importwin32crypt

outFile_path=os.path.join(os.path.dirname(sys.executable),

'ChromePass.txt')

ifos.path.exists(outFile_path):

os.remove(outFile_path)

db_file_path=os.path.join(os.environ['LOCALAPPDATA'],

r'Google\Chrome\UserData\Default\LoginData')

tmp_file=os.path.join(os.path.dirname(sys.executable),'tmp_tmp_tmp')

ifos.path.exists(tmp_file):

os.remove(tmp_file)

shutil.copyfile(db_file_path,tmp_file)#Incasefilelocked

conn=sqlite3.connect(tmp_file)

forrowinconn.execute('selectusername_value,password_value,signon_realmfromlogins'):

pwdHash=str(row[1])

try:

ret=win32crypt.CryptUnprotectData(pwdHash,None,None,None,0)

except:

print'Failtodecryptchromepasswords'

sys.exit(-1)

withopen(outFile_path,'a+')asoutFile:

outFile.write('UserName:{0:<20}Password:{1:<20}Site:{2}\n\n'.format(

row[0].encode('gbk'),ret[1].encode('gbk'),row[2].encode('gbk')))

conn.close()

print'AllChromepasswordssavedto:\n'+outFile_path

os.remove(tmp_file)#Removetempfile

chromePass.zip Windows版本 win7测试通过

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。