-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeneric_Conector.py
67 lines (57 loc) · 2.09 KB
/
Generic_Conector.py
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
67
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Script para usar con SecureCRT.
# GITHUB: https://github.com/kentron2019/SecureCRT_Integration_Keepass.git
# Version = 1.3
# Author = Karim Zin El Abidine El Alaoui.
# correo: kentron.dna@gmail.com
import sys
import os
from pathlib import Path
import keepasshttp
from keepasshttp import KeePassHTTP
def get_pass(recibir_todo):
Fichero = Path("./keepasshttp_key")
kph = KeePassHTTP(
#Genera la llave en la primera conexión hay que validar desde KeePass Password Safe
storage="./keepasshttp_key",
url="http://localhost:19455")
try:
kph._authenticate()
except: # Any other exception
print(kph)
print("type:", type(kph))
if Fichero.is_file():
# file exists
print("Fichero keepasshttp_key existe")
os.remove("./keepasshttp_key")
print("Fichero:keepasshttp_key, borrado para renovar la llave")
kph = KeePassHTTP(
#Genera la llave en la primera conexión hay que validar desde KeePass Password Safe
storage="./keepasshttp_key",
url="http://localhost:19455")
hey = kph.get( str(recibir_todo[0]) )
sys.exit(1)
finally: # Optional
#print("finally:")
kph = KeePassHTTP(
#Genera la llave en la primera conexión hay que validar desde KeePass Password Safe
storage="./keepasshttp_key",
url="http://localhost:19455")
hey = kph.get( str(recibir_todo[0]) )
#print("Resultado de hey.login", hey.login)
if str(recibir_todo[1]) =='LoginyPassword':
resultado = str(hey.login)+str("-")+str(hey.password)
print(resultado)
elif str(recibir_todo[1]) =='login':
print(hey.login)
elif str(recibir_todo[1]) =='password':
print(hey.password)
else:
print("error")
pass # Clean up
if __name__ == "__main__":
recibir_todo = sys.argv[1], sys.argv[2]
# [1] IP
# [2] Login o password.
get_pass(recibir_todo)