How to use show_password method in tempest

Best Python code snippet using tempest_python

main.py

Source:main.py Github

copy

Full Screen

1from flask import Flask, redirect, render_template, request, session2from flask_session import Session3from tempfile import mkdtemp4import app_solar_calculation5import sqlite36from flask import g7# import init_db8from datetime import datetime9from werkzeug.security import check_password_hash, generate_password_hash10app = Flask(__name__)11# Ensure templates are auto-reloaded12app.config["TEMPLATES_AUTO_RELOAD"] = True13DATABASE = 'database.db'14def get_db():15 """Connect to the db"""16 conn = sqlite3.connect('database.db')17 conn.row_factory = sqlite3.Row18 return conn19@app.teardown_appcontext20def close_connection(exception):21 db = getattr(g, '_database', None)22 if db is not None:23 db.close()24def query_db(query, args=(), one=False):25 cur = get_db().execute(query, args)26 rv = cur.fetchall()27 cur.close()28 return (rv[0] if rv else None) if one else rv29def insert_db(query, args=()):30 con = sqlite3.connect('database.db')31 cur = con.cursor()32 cur.execute(query, args)33 con.commit()34 con.close()35 return36# Ensure responses aren't cached37@app.after_request38def after_request(response):39 response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"40 response.headers["Expires"] = 041 response.headers["Pragma"] = "no-cache"42 return response43# Configure session to use filesystem (instead of signed cookies)44app.config["SESSION_FILE_DIR"] = mkdtemp()45app.config["SESSION_PERMANENT"] = False46app.config["SESSION_TYPE"] = "filesystem"47Session(app)48@app.route('/', methods=["GET", "POST"])49def homepage():50 if request.method == "GET":51 return render_template("index.html")52 # If "Calculate" button is clicked53 if request.method == "POST":54 # Get raw values (strings) from form55 lat_in = request.form.get('coord_y')56 long_in = request.form.get('coord_x')57 rotate_in = request.form.get('rotation')58 surface_type = request.form.get('surface')59 year = request.form.get('year')60 location_name, today, version, loc, surface_type, rotation, rounded_tilts, historical_year = \61 app_solar_calculation.run(lat_in, long_in, rotate_in, surface_type, year)62 lat = str(lat_in)63 long = str(long_in)64 return render_template("results.html", location_name=location_name, today=today, version=version, lat_in=lat,65 loc=loc, long_in=long, surface_type=surface_type, rotation=rotation, rounded_tilts=rounded_tilts,66 historical_year=historical_year)67@app.route("/signup", methods=["GET", "POST"])68def signup():69 """Register user"""70 # User reached route via POST (as by submitting a form via POST)71 if request.method == "POST":72 # Ensure username was submitted73 if not request.form.get("username"):74 show_username = "block"75 show_password = "none"76 show_pw_match = "none"77 show_exists = "none"78 # print("error_username")79 return render_template("signup.html", show_username=show_username, show_password=show_password,80 show_pw_match=show_pw_match, show_exists=show_exists)81 # Ensure password was submitted82 elif not request.form.get("password"):83 show_username = "none"84 show_password = "block"85 show_pw_match = "none"86 show_exists = "none"87 # print("error_password")88 return render_template("signup.html", show_username=show_username, show_password=show_password,89 show_pw_match=show_pw_match, show_exists=show_exists)90 # Ensure passwords match91 elif request.form.get("password") != request.form.get("confirmation"):92 show_username = "none"93 show_password = "none"94 show_pw_match = "block"95 show_exists = "none"96 # print("error_match")97 return render_template("signup.html", show_username=show_username, show_password=show_password,98 show_pw_match=show_pw_match, show_exists=show_exists)99 username = request.form.get("username")100 # Query database for username101 rows = query_db("SELECT * FROM users WHERE username = ?", (username,))102 # print(len(rows))103 if len(rows) != 0:104 show_username = "none"105 show_password = "none"106 show_pw_match = "none"107 show_exists = "block"108 # print("error_exists")109 return render_template("signup.html", show_username=show_username, show_password=show_password,110 show_pw_match=show_pw_match, show_exists=show_exists)111 # hash password to store in db rather than actual password112 hash = generate_password_hash(request.form.get("password"))113 insert_db("INSERT INTO users (username, hash) VALUES(?, ?);", (username, hash))114 # Redirect user to home page115 return render_template("index.html")116 # User reached route via GET (as by clicking a link or via redirect)117 else:118 show_username = "none"119 show_password = "none"120 show_pw_match = "none"121 show_exists = "none"122 return render_template("signup.html", show_username=show_username, show_password=show_password,123 show_pw_match=show_pw_match, show_exists=show_exists)124@app.route("/login", methods=["GET", "POST"])125def login():126 """Log user in"""127 # Forget any user_id128 session.clear()129 # User reached route via POST (as by submitting a form via POST)130 if request.method == "POST":131 # Ensure username was submitted132 if not request.form.get("username"):133 show_username = "block"134 show_password = "none"135 show_match = "none"136 # print("error_username")137 return render_template("login.html", show_username=show_username, show_password=show_password,138 show_match=show_match)139 # Ensure password was submitted140 elif not request.form.get("password"):141 show_username = "none"142 show_password = "block"143 show_match = "none"144 # print("error_password")145 return render_template("login.html", show_username=show_username, show_password=show_password,146 show_match=show_match)147 username = request.form.get("username")148 password = request.form.get("password")149 rows = query_db("SELECT * FROM users WHERE username = ?", (username,))150 # print(len(rows))151 # Ensure username exists and password is correct152 if len(rows) != 1 or not check_password_hash(rows[0]["hash"], password):153 show_username = "none"154 show_password = "none"155 show_match = "block"156 # print("error_match")157 return render_template("login.html", show_username=show_username, show_password=show_password,158 show_match=show_match)159 # Remember which user has logged in160 session["user_id"] = rows[0]["id"]161 # print(session["user_id"])162 # Redirect user to home page163 return render_template("index.html")164 # User reached route via GET (as by clicking a link or via redirect)165 # else:166 if request.method == "GET":167 show_username = "none"168 show_password = "none"169 show_match = "none"170 return render_template("login.html", show_username=show_username, show_password=show_password,171 show_match=show_match)172@app.route("/logout")173def logout():174 """Log user out"""175 # Forget any user_id176 session.clear()177 # Redirect user to login form178 return redirect("/")179@app.route("/userfeedback", methods=["GET", "POST"])180def feedback():181 """Get user feedback"""182 if request.method == "GET":183 show = "none"184 return render_template("user_feedback.html", show=show)185 if request.method == "POST":186 fb = []187 # get all values from form in string format188 for i in range(1,6):189 # print(i)190 val = "rating" + str(i)191 if request.form.get(val) is not None:192 fb.append(int(request.form.get(val)))193 # If not all 5 mandatory elements are filled in, re-render template with warning194 else:195 show = "block"196 return render_template("user_feedback.html", show=show)197 if request.form.get('further') is not None:198 comment = request.form.get('further')199 else:200 comment = "-"201 # print(fb)202 # print(comment)203 # Add feedback to database204 insert_db("INSERT INTO feedback (q1, q2, q3, q4, q5, comment) VALUES (?, ?, ?, ?, ?, ?);",205 (fb[0], fb[1], fb[2], fb[3], fb[4], comment))206 # Query overall satisfaction and count207 result = query_db("SELECT AVG(q1) FROM feedback;", one=True)208 overall_sat = int(result[0])209 result2 = query_db("SELECT count(*) FROM feedback;", one=True)210 count = int(result2[0])211 return render_template("thanks.html", overall_rating=overall_sat, count_submissions=count)212@app.route("/about", methods=["GET"])213def about():214 """load page with information about the project"""215 if request.method == "GET":216 return render_template("about.html")217@app.route("/savedsearches", methods=["GET", "POST"])218def saved():219 """load page with information about the project"""220 if request.method == "POST":221 search_id = request.form.get('redo')222 # print(search_id)223 search_params = query_db("SELECT * FROM savedSearches WHERE id = ?;", (search_id,), one=True)224 # Get individual values225 lat_in = search_params['lat_in']226 long_in = search_params['long_in']227 rotate_in = search_params['rotate_in']228 surface_type = search_params['surface_type']229 year = search_params['year']230 location_name, today, version, loc, surface_type, rotation, rounded_tilts, historical_year = \231 app_solar_calculation.run(lat_in, long_in, rotate_in, surface_type, year)232 lat = str(lat_in)233 long = str(long_in)234 return render_template("results.html", location_name=location_name, today=today, version=version, lat_in=lat,235 loc=loc, long_in=long, surface_type=surface_type, rotation=rotation,236 rounded_tilts=rounded_tilts,237 historical_year=historical_year)238 if request.method == "GET":239 user_id = int(session["user_id"])240 user_searches = query_db("SELECT * FROM savedSearches WHERE user_id = ?;", (user_id,))241 return render_template("savedsearches.html", user_searches=user_searches)242@app.route("/results", methods=["POST"])243def save():244 """ save current search to db"""245 if request.method == "POST":246 # get time and date as string247 now = datetime.now()248 now_string = now.strftime("%d/%m/%Y %H:%M:%S")249 # print(f"now = {str(now_string)}")250 # user ID from session251 user_id = int(session["user_id"])252 # print(f"session id = {str(user_id)}")253 loc_name = request.form.get('loc_name')254 lat_in = request.form.get('lat_in')255 long_in = request.form.get('long_in')256 rotate_in = request.form.get('rotate_in')257 surface_type = request.form.get('surface_type')258 year = request.form.get('year')259 # print(f"loc_name = {str(loc_name)}")260 insert_db("INSERT INTO savedSearches (user_id, date, loc_name, lat_in, long_in, rotate_in, surface_type, "261 "year) VALUES (?, ?, ?, ?, ?, ?, ?, ?);", (user_id, now_string, loc_name, lat_in, long_in, rotate_in,262 surface_type, year))263 user_searches = query_db("SELECT * FROM savedSearches WHERE user_id = ?;", (user_id,))264 return render_template("savedsearches.html", user_searches=user_searches)265if __name__ == '__main__':266 app.run(host='0.0.0.0')...

Full Screen

Full Screen

wifiPasswdRus.py

Source:wifiPasswdRus.py Github

copy

Full Screen

1import subprocess2import re3try:4 output = []5 clean_profiles = []6 passwd = ''7 separator = '='*208 class colors:9 MAGENTA = '\033[95m'10 CYAN = '\033[96m'11 RED = '\033[91m'12 ENDC = '\033[0m'13 profiles = subprocess.check_output(['powershell', 'netsh wlan show profiles| Select-String "Все профили пользователей"'])14 profiles = str(profiles)15 profiles = profiles.replace('\\r','')16 profiles = profiles.replace('\\n','')17 profiles = profiles.replace("'",'')18 profiles = profiles.replace("Все профили пользователей",'')19 profiles = profiles.split(" : ")20 profiles.pop(0)21 for i in profiles:22 i = i.strip()23 clean_profiles.append(i)24 for ssid in clean_profiles:25 try:26 get_password = 'netsh wlan show profiles name="' + ssid + '" key=clear | Select-String "Содержимое ключа"'27 show_password = subprocess.check_output(['powershell', get_password])28 show_password = str(show_password)29 show_password = show_password.replace('\\r','')30 show_password = show_password.replace('\\n','')31 show_password = re.findall("[^']",show_password)32 show_password = "".join(show_password)33 show_password = show_password.split(':')34 show_password.pop(0)35 for i in show_password:36 passwd += i37 passwd = passwd.strip()38 output.append(colors.CYAN + "Имя сети: " + ssid + "\nПароль: " + passwd + "\n" + colors.MAGENTA + colors.ENDC + separator)39 except:40 #BUG: Возможен пустой пароль. Сделать проверку на пустой пароль 41 output.append(colors.CYAN + "Имя сети: " + ssid + colors.RED + "\nПароль: не найден/ без пароля\n" + colors.ENDC + separator)42 passwd = ''43 for i in output:44 print(i)45 input("Нажмите ENTER для выхода")46except:...

Full Screen

Full Screen

wifiPasswd.py

Source:wifiPasswd.py Github

copy

Full Screen

1# REVIEW: (netsh wlan show profiles) | Select-String "\:(.+)$" 2# FIXME: TRy using the command above to avoid manual cleaning on ssid names3# NOTE: read https://codeby.net/threads/powershell-dlja-xakera-chast-ix-voruem-soxranennye-paroli-ot-wifi.60401/ 4import subprocess5import re6try:7 output = []8 clean_profiles = []9 passwd = ''10 separator = '='*2011 class colors:12 MAGENTA = '\033[95m'13 CYAN = '\033[96m'14 RED = '\033[91m'15 ENDC = '\033[0m'16 profiles = subprocess.check_output(['powershell', 'netsh wlan show profiles| find "All User Profile"'])17 profiles = str(profiles)18 profiles = profiles.replace('\\r','')19 profiles = profiles.replace('\\n','')20 profiles = profiles.replace("'",'')21 profiles = profiles.replace("All User Profile",'')22 profiles = profiles.split(" : ")23 profiles.pop(0)24 for i in profiles:25 i = i.strip()26 clean_profiles.append(i)27 for ssid in clean_profiles:28 try:29 get_password = 'netsh wlan show profiles name="' + ssid + '" key=clear | find "Key Content"'30 show_password = subprocess.check_output(['powershell', get_password])31 show_password = str(show_password)32 show_password = show_password.replace('\\r','')33 show_password = show_password.replace('\\n','')34 show_password = re.findall("[^']",show_password)35 show_password = "".join(show_password)36 show_password = show_password.split(':')37 show_password.pop(0)38 for i in show_password:39 passwd += i40 passwd = passwd.strip()41 output.append(colors.CYAN + "SSID: " + ssid + "\nPASSWORD: " + passwd + "\n" + colors.MAGENTA + colors.ENDC + separator)42 except:43 output.append(colors.CYAN + "SSID: " + ssid + colors.RED + "\nPASSWORD: No Password/ Empty\n" + colors.ENDC + separator)44 passwd = ''45 for i in output:46 print(i)47 input("Press ENTER to exit")48except:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful