top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

password protect file in python

0 votes
885 views

I was wondering if there was a couple of words or things i could add to the top of my python script to password protect it so that it asks user for the password and then after three tries it locks them out or says "access denied" and closes/ends the script but if they get it wright it proceeds on to the next line of the script total noob here any help appreciated

posted Jul 1, 2013 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
0 votes

I am trying to use mitmproxy behind a company proxy that requires a user/password login.

The setup is: Local PC's browser -> mitmproxy (on local PC) -> company proxy -> internet.

Based on this SO thread, this is how you use mitmproxy within a Python program. This example works fine when there's no proxy.

from mitmproxy.options import Options
from mitmproxy.proxy.config import ProxyConfig
from mitmproxy.proxy.server import ProxyServer
from mitmproxy.tools.dump import DumpMaster

class Addon(object):
    def __init__(self):
        pass

    def request(self, flow):
        # examine request here 
        pass

    def response(self, flow):
        # examine response here
        pass


if __name__ == "__main__":

    options = Options(listen_host='0.0.0.0', listen_port=8080, http2=True)
    m = DumpMaster(options, with_termlog=False, with_dumper=False)
    config = ProxyConfig(options)

    m.server = ProxyServer(config)
    m.addons.add(Addon())

    try:
        print('starting mitmproxy')
        m.run()
    except KeyboardInterrupt:
        m.shutdown()

Assuming the company proxy is at IP "1.2.3.4" port 3128 and requires a login USER and PASSWORD, how can I change this script to have mitproxy use that proxy instead of going to the internet directly?

Addition info: I am not using mitmdump with the script-parameter to run this script. The goal is to run this from Python 3.8 with a pip-installed mitmproxy

+1 vote

Is there a way to make python script that connects to mySQL DB ask for a password on the:

conn = mdb.connect(host, user)
+2 votes

Iam on python 2.7 and linux .I need to know if we need to place the modules in a particular or it doesn't matter at all while writing the program.

For Example

import os
import shlex
import subprocess
import time
import sys
import logging
import plaftform.cluster
from util import run

def main():
 """ ---MAIN--- """

if __name__ == '__main__':
 main()

In the above example :

I am guessing may be the python modules like os , shlex etc come first and later the user defined modules like import plaftform.cluster etc

Sorry if my question sounds dump , I was running pep8 and don't see its bothered much about it

...