1
我遇到部分代碼遇到問題,我在底部添加了我的錯誤。問題出現在sqllite3.operationError部分。我試圖刪除它,但當我做了另一個錯誤發生的第68行'def getpath():',我不明白爲什麼錯誤顯示任何和所有的幫助表示讚賞,因爲總是感謝。我的代碼一般是採取登錄數據從我的數據庫,並在csv文件顯示ChromeSessionParser語法問題
import os
import sys
import sqlite3
try:
import win32crypt
except:
pass
import argparse
def args_parser():
parser = argparse.ArgumentParser(description="Retrieve Google Chrome Passwords")
parser.add_argument("--output", help="Output to csv file", action="store_true")
args = parser.parse_args()
if args.output:
csv(main())
else:
for data in main():
print (data)
def main():
info_list = []
path = getpath()
try:
connection = sqlite3.connect(path + "Login Data")
with connection:
cursor = connection.cursor()
v = cursor.execute('SELECT action_url, username_value, password_value FROM logins')
value = v.fetchall
for information in value:
if os.name == 'nt':
password = win32crypt.CryptUnprotectData(information[2], None, None, None, 0)[1]
if password:
info_list.append({
'origin_url': information[0],
'username': information[1],
'password': str(password)
})
except sqlite3.OperationalError as e:
e = str(e)
if (e == 'database is locked'):
print('[!] Make sure Google Chrome is not running in the background')
sys.exit(0)
elif (e == 'no such table: logins'):
print('[!] Something wrong with the database name')
sys.exit(0)
elif (e == 'unable to open database file'):
print('[!] Something wrong with the database path')
sys.exit(0)
else:
print (e)
sys.exit(0)
return info_list
def getpath():
if os.name == "nt":
# This is the Windows Path
PathName = os.getenv('localappdata') + '\\Google\\Chrome\\User Data\\Default\\'
if (os.path.isdir(PathName) == False):
print('[!] Chrome Doesn\'t exists')
sys.exit(0)
return PathName
def csv (info):
with open ('chromepass.csv', 'wb') as csv_file:
csv_file.write('origin_url,username,password \n' .encode('utf'))
for data in info:
csv_file.write(('%s, %s, %s \n' % (data['origin_url'], data['username'], data['password'])).encode('utf-8'))
print ("Data written to Chromepass.csv")
if __name__ == '__main__':
args_parser()
錯誤
Traceback (most recent call last):
File "C:/Users/Lewis Collins/Python Project/ChromeDB's/ChromeSessionParser.py", line 90, in <module>
args_parser()
File "C:/Users/Lewis Collins/Python Project/ChromeDB's/ChromeSessionParser.py", line 19, in args_parser
for data in main():
File "C:/Users/Lewis Collins/Python Project/ChromeDB's/ChromeSessionParser.py", line 35, in main
for information in value:
TypeError: 'builtin_function_or_method' object is not iterable
感謝您的幫助我知道這將是一個小的東西我錯了 – BoBBob123
我已經解決了這個問題,現在收到新的錯誤追溯(最近調用最後): 文件「C:/ Users/Lewis Collins/Python Project/ChromeDB's/ChromeSessionParser py 「爲,線90,在 args_parser() 文件 」C:/用戶/路易斯柯林斯/ Python的項目/ ChromeDB的/ ChromeSessionParser.py「,第19行,在args_parser 用於在main()數據: 文件」 C:/ Users/Lewis Collins/Python Project/ChromeDB's/ChromeSessionParser.py「,第35行,主要爲 ,其中的值爲: TypeError:'builtin_function_or_method'對象不可迭代 –
BoBBob123