KEEPASS: mudanças entre as edições
Ir para navegação
Ir para pesquisar
(→Code) |
(→Code) |
||
Linha 13: | Linha 13: | ||
from pykeepass import PyKeePass | from pykeepass import PyKeePass | ||
import argparse | |||
class KeePass: | |||
def __init__(self,dbfile, dbkey): | |||
self.dbfile = dbfile | |||
self.dbkey = dbkey | |||
def extract(self): | |||
with PyKeePass(self.dbfile, password=self.dbkey) as kp: | |||
for entry in kp.entries: | |||
grupo = str(entry.group).replace("\n", "") | |||
path = str(entry.path).replace("\n", "") | |||
title = str(entry.title).replace("\n", "") | |||
notes = str(entry.notes).replace("\n", "") | |||
username = str(entry.username).replace("\n", "") | |||
password = str(entry.password).replace("\n", "") | |||
print("\"" + grupo + "\";\"" + path + "\";\"" + title + "\";\"" + notes + "\";\"" + username + "\";\"" + password + "\"") | |||
parser = argparse.ArgumentParser(description='KeePass extractor, By D´Amato') | |||
parser.add_argument('--dbfile', action='store', help='dbfile to extract') | |||
parser.add_argument('--dbkey', action='store', help='Secret t open dbfile') | |||
parser.parse_args([]) | |||
args = parser.parse_args() | |||
if args.dbfile is not None: | |||
if args.dbkey is not None: | |||
mykp = KeePass(dbfile=args.dbfile,dbkey=args.dbkey) | |||
mykp.extract() | |||
else: | |||
print("Error. use --help for more information") | |||
else: | |||
print("Error. use --help for more information") | |||
</syntaxhighlight> | </syntaxhighlight> |
Edição das 14h15min de 17 de outubro de 2019
Preparations
virtualenv -p $(which python3) kp
source kp/bin/activate
cd kp
touch kp.py
chmod +x kp.py
pip install pykeepass
Code
#!/usr/bin/env python
from pykeepass import PyKeePass
import argparse
class KeePass:
def __init__(self,dbfile, dbkey):
self.dbfile = dbfile
self.dbkey = dbkey
def extract(self):
with PyKeePass(self.dbfile, password=self.dbkey) as kp:
for entry in kp.entries:
grupo = str(entry.group).replace("\n", "")
path = str(entry.path).replace("\n", "")
title = str(entry.title).replace("\n", "")
notes = str(entry.notes).replace("\n", "")
username = str(entry.username).replace("\n", "")
password = str(entry.password).replace("\n", "")
print("\"" + grupo + "\";\"" + path + "\";\"" + title + "\";\"" + notes + "\";\"" + username + "\";\"" + password + "\"")
parser = argparse.ArgumentParser(description='KeePass extractor, By D´Amato')
parser.add_argument('--dbfile', action='store', help='dbfile to extract')
parser.add_argument('--dbkey', action='store', help='Secret t open dbfile')
parser.parse_args([])
args = parser.parse_args()
if args.dbfile is not None:
if args.dbkey is not None:
mykp = KeePass(dbfile=args.dbfile,dbkey=args.dbkey)
mykp.extract()
else:
print("Error. use --help for more information")
else:
print("Error. use --help for more information")