PAM 인가 우회 (PAM Authorization Bypass)
PAM Authorization Bypass due to Incorrect Usage
Last updated
PAM Authorization Bypass due to Incorrect Usage
Last updated
from pam import PamHandle, PamConv
from ctypes import CDLL, c_int, byref
from ctypes.util import find_library
libpam = CDLL(find_library("pam"))
pam_authenticate = libpam.pam_authenticate
pam_authenticate.argtypes = [PamHandle, c_int]
pam_authenticate.restype = c_int
def authenticate(username, password, service='login'):
handle = PamHandle()
conv = PamConv(handle_conv, 0)
retval = pam_start(service, username, byref(conv), byref(handle))
# 인증만 수행 (보안 취약)
return pam_authenticate(handle, 0) == 0from pam import PamHandle, PamConv
from ctypes import CDLL, c_int, byref
from ctypes.util import find_library
libpam = CDLL(find_library("pam"))
pam_authenticate = libpam.pam_authenticate
pam_authenticate.argtypes = [PamHandle, c_int]
pam_authenticate.restype = c_int
pam_acct_mgmt = libpam.pam_acct_mgmt
pam_acct_mgmt.argtypes = [PamHandle, c_int]
pam_acct_mgmt.restype = c_int
def authenticate(username, password, service='login'):
handle = PamHandle()
conv = PamConv(handle_conv, 0)
retval = pam_start(service, username, byref(conv), byref(handle))
# 계정 상태 검증 추가 (안전)
return pam_authenticate(handle, 0) == 0 and pam_acct_mgmt(handle, 0) == 0