1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| import os
import sys
import sqlite3
import win32crypt
def getPath():
if os.name == "nt":
# windows path
path = os.getenv('localappdata') + '\\Google\\Chrome\\User Data\\Default\\'
if os.path.isdir(path) == False: # if directory doesn't exist, Chrome is not installed on the machine
print "Chrome isn't installed on this machine!"
sys.exit(0)
else:
return path
else:
print "Supporting only Windows Operating System!"
sys.exit(0)
def readData(dbPath):
"""
Fetches the datas from database file.
:param dbPath: Local path of the database file
:return: Database table records
"""
try:
cn = sqlite3.connect(dbPath + "Login Data") # Login Data is the database file name
cursor = cn.cursor()
r = cursor.execute('select action_url, username_value, password_value from logins')
rows = r.fetchall()
cn.close()
return rows
except sqlite3.OperationalError, err:
err = str(err)
if err == 'database is locked':
print "Can't get datas while Google Chrome is running!"
else:
print 'Error : ' + err
sys.exit(0)
def printList(authList):
"""
Prints the username-password list to the console
:param authList: List that contains username, password and url informations
"""
print '*' * 15 + str(len(authList)) + ' passwords found!' + '*' * 15
for authInfo in authList:
print 'Link : ' + authInfo['link']
print 'User name : ' + authInfo['username']
print 'Password : ' + authInfo['password']
print '*' * 30
def main():
dataList = readData(getPath())
authList = [] # result list
for data in dataList:
password = win32crypt.CryptUnprotectData(data[2], None, None, None, 0)[1] # decrypting the password
if password:
authList.append({'link': data[0], 'username': data[1], 'password': password})
if len(authList)>0:
printList(authList)
else:
print "Couldn't find a stored password on Google Chrome"
if __name__ == '__main__':
main() |
Partager