Oops, this is the real credentials verify commit
This commit is contained in:
parent
f7b0efee99
commit
e289fc4e61
1 changed files with 20 additions and 2 deletions
22
nauta.py
22
nauta.py
|
@ -317,10 +317,28 @@ def cards(args):
|
||||||
expire_date(card, args.fresh, args.cached)
|
expire_date(card, args.fresh, args.cached)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
def verify(username, password):
|
||||||
|
session = requests.Session()
|
||||||
|
r = session.get("https://secure.etecsa.net:8443/")
|
||||||
|
soup = bs4.BeautifulSoup(r.text, 'html.parser')
|
||||||
|
|
||||||
|
form = get_inputs(soup)
|
||||||
|
action = "https://secure.etecsa.net:8443/EtecsaQueryServlet"
|
||||||
|
form['username'] = username
|
||||||
|
form['password'] = password
|
||||||
|
r = session.post(action, form)
|
||||||
|
soup = bs4.BeautifulSoup(r.text, 'html.parser')
|
||||||
|
exp_node = soup.find(string=re.compile("expiración"))
|
||||||
|
if not exp_node:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def cards_add(args):
|
def cards_add(args):
|
||||||
if not args.username:
|
username = args.username or input("Username: ")
|
||||||
username = input("Username: ")
|
|
||||||
password = input("Password: ")
|
password = input("Password: ")
|
||||||
|
if not verify(username, password):
|
||||||
|
print("Credentials seem incorrect")
|
||||||
|
return
|
||||||
with dbm.open(CARDS_DB, "c") as cards_db:
|
with dbm.open(CARDS_DB, "c") as cards_db:
|
||||||
cards_db[username] = json.dumps({
|
cards_db[username] = json.dumps({
|
||||||
'password': password,
|
'password': password,
|
||||||
|
|
Loading…
Reference in a new issue