利用Python Sqlite3模块提起Firefox Cookie数据库信息
2022/5/23 2:02:49
本文主要是介绍利用Python Sqlite3模块提起Firefox Cookie数据库信息,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
由于Firefox利用Sqlite存储各种上网数据,比如表单数据,Cookie数据,历史记录等,因此可用Python第三方模块Sqlite3对数据库进行操作,提取出响应的表的信息。
1 import sqlite3 2 import optparse 3 import sys 4 import os 5 6 class FirefoxCookies: 7 def __init__(self) -> None: 8 self.filename = self.get_params() 9 self.tablename = 'moz_cookies' 10 11 def get_params(self): 12 parser = optparse.OptionParser('Usage: <Program> -f sqlite db filename') 13 parser.add_option('-f', '--filename', dest='filename', type='string', help='Specify database filenamme') 14 options, args = parser.parse_args() 15 if options.filename is None: 16 print(parser.usage) 17 sys.exit(0) 18 if not os.path.exists(options.filename): 19 print('[-] The file does not exist') 20 sys.exit(0) 21 return options.filename 22 23 def cookie_extractor(self): 24 try: 25 conn = sqlite3.connect(self.filename) 26 cursor = conn.cursor() 27 sql = 'select name,value from {};'.format(self.tablename) 28 cursor.execute(sql) 29 for row in cursor: 30 print(row[0],":", row[1]) 31 except Exception as e: 32 print(e) 33 sys.exit() 34 35 36 if __name__ == "__main__": 37 fc = FirefoxCookies() 38 fc.cookie_extractor()
这篇关于利用Python Sqlite3模块提起Firefox Cookie数据库信息的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python