def main() -> None: """Run the post hooks.""" print(""" ######################### # Post generation hooks # #########################""") password_store = passpy.Store() configure_github_repository(password_store) clean_unwanted_directories()
def download(self): """Main entry point for downloader """ # url's for access WEBANK_ROOT = 'https://www.webank.it' WEBANK_LOGIN = WEBANK_ROOT + '/webankpub/wbresp/home.do' WEBANK_LOGIN_KEY = WEBANK_ROOT + '/WEBWB/jsp/ht/loginKey.jsp' WEBANK_SET_OTP_MODE = WEBANK_ROOT + '/WEBWB/cambioStatoOperazioneDaAutorizzare.do' WEBANK_CHECK_OTP_MODE = WEBANK_ROOT + '/WEBWB/statoOperazioneDaAutorizzare.do' WEBANK_OTP_LOGIN_ESITO = WEBANK_ROOT + '/WEBWB/otpLoginEsito.do' WEBANK_MAIN = WEBANK_ROOT + '/WEBWB/homepage.do' WEBANK_HOME = WEBANK_ROOT + '/WEBEXT/wbOnetoone/fpMyHome.action' WEBANK_STATEMENTS = WEBANK_ROOT + '/WEBWB/cc/movimentiConto.xls' WEBANK_LOGOUT = WEBANK_ROOT + '/WEBWB/logout.do' # get credentials if self.useZX2C4pass: if os.name == 'nt': store = passpy.Store(gpg_bin='gpg.exe') else: store = passpy.Store() key = store.get_key(self.ZX2C4passname).split('\n') pwd = key[0] for k in key: if "login: "******"login: "******"") break else: user = input("User: "******"j_password"] = pwd mech["j_username"] = user mech["loginKey"] = login_key response = mech.submit() # Get hashOtp formcount=0 for frm in mech.forms(): if str(frm.attrs["id"])=="otpLoginEsito": break formcount=formcount+1 mech.select_form(nr=formcount) mech.set_all_readonly(False) hashOtp=mech.find_control(name="hashOtp", nr=0).value # poll on autorization url to check if auth is ok. auth_ok = False attempts = 15 while auth_ok == False and attempts > 0: time.sleep(1) response = mech.open(WEBANK_CHECK_OTP_MODE+'?hashOtp='+hashOtp) response_str = response.read().decode('utf-8') if '"esito" : "VP"' in response_str: auth_ok = True # open main page mech.open(WEBANK_MAIN) mech.select_form(nr=formcount) mech.set_all_readonly(False) response = mech.submit() attempts = attempts - 1 # if timeout is expired use manual authorization if not auth_ok: print("App authorization failed, use generated OTP code..") OTPCode = input("Insert OTP Code: ") response = mech.open(WEBANK_SET_OTP_MODE+'?hashOtp='+hashOtp) response = mech.open(WEBANK_CHECK_OTP_MODE+'?hashOtp='+hashOtp) # open main page response = mech.open(WEBANK_MAIN) mech.select_form(nr=formcount) mech.set_all_readonly(False) mech["codiceOTP"] = OTPCode response = mech.submit() response_str = response.read().decode('cp1252') if "Codice errore:" not in response_str: auth_ok = True if auth_ok: # open movement page xls_url = WEBANK_STATEMENTS +\ '?&tipoIntervallo=periodo&dataInizio=' +\ "%2F".join(self.start_date.split("/")) +\ '&dataFine=' + "%2F".join(self.end_date.split("/")) +\ '&ultimiMovimenti=400' response = mech.open(xls_url) # Write xls file results = response.read() f = open(self.filename, 'wb') f.write(results) f.close() # Logout response = mech.open(WEBANK_LOGOUT) else: # Logout response = mech.open(WEBANK_LOGOUT) raise DownloadError("Authorization denied")
#!/usr/bin/env python3 # Using imapidle from https://github.com/gumblex/imapidle/ from imapidle import imaplib import passpy from passpy_dict import password_dict import os runcmd = ["emacsclient -e '(mu4e-update-mail-and-index 1)'"] # ["notify-send 'Email received' 'Ping for email received", if __name__ == '__main__': pass_store = passpy.Store() # Assumes GPG key is unlocked already pwdict = password_dict("jiby.tech/fastmail/emacs_hally", pass_store) m = imaplib.IMAP4_SSL(pwdict["host"]) m.login(pwdict["user"], pwdict["password"]) m.select() for uid, msg in m.idle(): if msg == b"EXISTS": print("Ding!") for cmd in runcmd: os.system(cmd)
import passpy def show(e): key = store.get_key(e).split('\n', 1)[0] print(e + '\t' + key) def sub(d): (dirs, entries) = store.list_dir(d) for _d in dirs: sub(_d) for e in entries: show(e) store = passpy.Store() sub('.')
def download(self): """Main entry point for downloader """ # url's for access FINECO_ROOT = 'https://finecobank.com' FINECO_LOGIN = FINECO_ROOT + '/portalelogin' FINECO_0 = FINECO_ROOT + '/conto-e-carte/movimenti/movimenti-conto' FINECO_AUTH_1 = FINECO_ROOT + '/myfineco-auth/sca/consents?r=rmvc' FINECO_AUTH_2 = FINECO_ROOT + '/myfineco-auth/sca/consents/inizia-transazione' FINECO_AUTH_3 = FINECO_ROOT + '/myfineco-auth/sca/consents/verifica-stato-transazione' FINECO_AUTH_4 = FINECO_ROOT + '/myfineco-auth/sca/consents/confirm' FINECO_AUTH_OFFL_1 = FINECO_ROOT + '/myfineco-auth/overlays/ovl-transazione?isOtpInOverlay=true' FINECO_AUTH_OFFL_2 = FINECO_ROOT + '/myfineco-auth/sca/consents/conferma-transazione-offline' FINECO_XLS = FINECO_ROOT + '/conto-e-carte/movimenti/movimenti-conto/excel' FINECO_LOGOUT = FINECO_ROOT + '/public/logout' # get credentials if self.useZX2C4pass: if os.name == 'nt': store = passpy.Store(gpg_bin='gpg.exe') else: store = passpy.Store() key = store.get_key(self.ZX2C4passname).split('\n') pwd = key[0] for k in key: if "login: "******"login: "******"") break else: user = input("User: "******"loginForm" (no "name" attrib.) mech.select_form(nr=0) mech["LOGIN"] = user mech["PASSWD"] = pwd mech.submit() # compile browser header to generate an XHR request header_XHR = { 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0', 'Referer': FINECO_0, 'X-Requested-With': 'XMLHttpRequest' } # Auth Step 1 url = FINECO_AUTH_1 + '&_=' + str(int(time.time() * 1000)) req = mechanize.Request(url, headers=header_XHR, method='GET') response = mech.open(req) # Auth Step 2 url = FINECO_AUTH_2 req = mechanize.Request(url, headers=header_XHR, method='POST') response = mech.open(req) # Auth Step 3 # poll on autorization url to check if auth is ok. auth_ok = False attempts = 15 url = FINECO_AUTH_3 req = mechanize.Request(url, headers=header_XHR, method='POST') while auth_ok == False and attempts > 0: time.sleep(1) response = mech.open(req) response_str = response.read().decode('utf-8') if '"stato":"confirmed"' in response_str: auth_ok = True attempts = attempts - 1 # if timeout is expired use manual authorization if not auth_ok: print( "App authorization failed, use PIN and mobile generated code.." ) # submit PIN code url = FINECO_AUTH_OFFL_1 response = mech.open(url) mech.select_form("pinOfflineForm") mech.set_all_readonly(False) mech["PIN"] = input("Insert PIN: ") response = mech.submit() response_str = response.read().decode('utf-8') if '"PIN":"OK"' in response_str: # submit generated code url = FINECO_AUTH_OFFL_2 mobile_generated_pin = input("Insert generated code: ") params = {'PIN': mobile_generated_pin} data = urllib.parse.urlencode(params) req = mechanize.Request(url, headers=header_XHR, method='POST') response = mech.open(req, data=data) response_str = response.read().decode('utf-8') print(response_str) if '"stato":"confirmed"' in response_str: auth_ok = True if auth_ok: # Auth Step 4 url = FINECO_AUTH_4 req = mechanize.Request(url, headers=header_XHR, method='POST') response = mech.open(req) # Open movement page response = mech.open(FINECO_0) # select form twice to enable custom search mech.select_form("frmKeywordSearch") response = mech.submit() mech.select_form("frmKeywordSearch") mech["dataDal"] = self.start_date mech["dataAl"] = self.end_date response = mech.submit() # Get xls file response = mech.open(FINECO_XLS) # Write xls file results = response.read() f = open(self.filename, 'wb') f.write(results) f.close() # Logout response = mech.open(FINECO_LOGOUT) else: # Logout response = mech.open(FINECO_LOGOUT) raise DownloadError("Authorization denied")