K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / usr / share / doc / python-pam / examples /
server ip : 172.67.156.115

your ip : 172.70.80.202

H O M E


Filename/usr/share/doc/python-pam/examples/pamtest.py
Size891
Permissionrwxr-xr-x
Ownerroot : root
Create time27-Apr-2025 09:56
Last modified11-Mar-2003 05:08
Last accessed07-Jul-2025 07:14
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
#!/usr/bin/env python

import sys
import PAM
from getpass import getpass

def pam_conv(auth, query_list, userData):

resp = []

for i in range(len(query_list)):
query, type = query_list[i]
if type == PAM.PAM_PROMPT_ECHO_ON:
val = raw_input(query)
resp.append((val, 0))
elif type == PAM.PAM_PROMPT_ECHO_OFF:
val = getpass(query)
resp.append((val, 0))
elif type == PAM.PAM_PROMPT_ERROR_MSG or type == PAM.PAM_PROMPT_TEXT_INFO:
print query
resp.append(('', 0))
else:
return None

return resp

service = 'passwd'

if len(sys.argv) == 2:
user = sys.argv[1]
else:
user = None

auth = PAM.pam()
auth.start(service)
if user != None:
auth.set_item(PAM.PAM_USER, user)
auth.set_item(PAM.PAM_CONV, pam_conv)
try:
auth.authenticate()
auth.acct_mgmt()
except PAM.error, resp:
print 'Go away! (%s)' % resp
except:
print 'Internal error'
else:
print 'Good to go!'