Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.148.168.26
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python2.7/dist-packages/keyring/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/lib/python2.7/dist-packages/keyring/cli.py
#!/usr/bin/env python
"""Simple command line interface to get/set password from a keyring"""

from __future__ import print_function

import getpass
from optparse import OptionParser
import sys

from . import get_keyring, set_keyring, get_password, set_password, delete_password
from . import core


class CommandLineTool(object):
    def __init__(self):
        self.parser = OptionParser(
                        usage="%prog [get|set|del] SERVICE USERNAME")
        self.parser.add_option("-p", "--keyring-path",
                               dest="keyring_path", default=None,
                               help="Path to the keyring backend")
        self.parser.add_option("-b", "--keyring-backend",
                               dest="keyring_backend", default=None,
                               help="Name of the keyring backend")

    def run(self, argv):
        opts, args = self.parser.parse_args(argv)

        try:
            kind, service, username = args
        except ValueError:
            if len(args) == 0:
                # Be nice with the user if he just tries to launch the tool
                self.parser.print_help()
                return 1
            else:
                self.parser.error("Wrong number of arguments")

        if opts.keyring_backend is not None:
            try:
                if opts.keyring_path:
                    sys.path.insert(0, opts.keyring_path)
                backend = core.load_keyring(opts.keyring_backend)
                set_keyring(backend)
            except (Exception,):
                # Tons of things can go wrong here:
                #   ImportError when using "fjkljfljkl"
                #   AttributeError when using "os.path.bar"
                #   TypeError when using "__builtins__.str"
                # So, we play on the safe side, and catch everything.
                e = sys.exc_info()[1]
                self.parser.error("Unable to load specified keyring: %s" % e)

        if kind == 'get':
            password = get_password(service, username)
            if password is None:
                return 1

            self.output_password(password)
            return 0

        elif kind == 'set':
            password = self.input_password("Password for '%s' in '%s': " %
                                           (username, service))
            set_password(service, username, password)
            return 0

        elif kind == 'del':
            password = self.input_password("Deleting password for '%s' in '%s': " %
                                      (username, service))
            delete_password(service, username)
            return 0

        else:
            self.parser.error("You can only 'get', 'del' or 'set' a password.")
            pass

    def input_password(self, prompt):
        """Ask for a password to the user.

        This mostly exists to ease the testing process.
        """

        return getpass.getpass(prompt)

    def output_password(self, password):
        """Output the password to the user.

        This mostly exists to ease the testing process.
        """

        print(password, file=sys.stdout)


def main(argv=None):
    """Main command line interface."""

    if argv is None:
        argv = sys.argv[1:]

    cli = CommandLineTool()
    return cli.run(argv)


if __name__ == '__main__':
    sys.exit(main())

Anon7 - 2022
AnonSec Team