Files
poll-recruit/Recruit/Identification/phoneIdentityVerificationProcOkUrl.asp

242 lines
9.2 KiB
Plaintext

<%
'####################################################################################
'# 파일명 : okurl.asp
'# 작성일 : 2025.08
'# 용 도 : 휴대폰본인확인 okurl 페이지
'# 버 전 : 0001
'####################################################################################
'####################################################################################
'# MAC값 위변조를 확인하기 위해 SHA256 변환이 필요합니다.
'# 참고용으로 KISA 암호알고리즘 소스코드를 사용했으며,
'# 해당 소스코드를 사용하여 한글이 깨질 경우 아래 인코딩 코드를 포함하시길 권장합니다.
'####################################################################################
%>
<!-- #include file = "class.CryptSHA256.asp" -->
<%
'####################################################################################
'#인증 성공시 웹 페이지 전환으로 호출되는 페이지이며 가맹점에서 구현해야하는 화면입니다.
'# 암호화 사용시 필수 DLL
'# McashCipher.dll
'#
'# asp 에서 dll 사용하기 위한 설정
'# cmd 창에서 C:\regsvr32 McashCipher.dll
'####################################################################################
Dim Resultcd, Resultmsg, No, Name, Sex, Socialno, Tradeid, Svcid, Mobilid, Signdate, MSTR, Mac, key, shastr, result
Resultcd = Request("Resultcd") ' 결과코드
Resultmsg = Request("Resultmsg") ' 결과메세지
No = Request("No") ' 휴대폰번호(암호문)
Name = Request("Name") '이름:한글(euc-kr)(암호문)
Sex = Request("Sex") '성별(암호문)
Socialno = Request("Socialno") '생년월일(암호문)
Tradeid = Request("Tradeid") ' 상점거래번호
Svcid = Request("Svcid") ' 서비스아이디
Mobilid = Request("Mobilid") ' 모빌리언스 거래번호
Signdate = Request("Signdate") ' 결제일자
MSTR = Request("MSTR") ' 가맹점 전달 콜백변수
Mac = Request("Mac") ' 검증키
'####################################################################################
' 데이터 복호화
' 주) 고유KEY 설정 시 비밀키 : "가맹점 고유 KEY + CI_SVCID 앞 8자리" (16byte) // Keygb 1 or 2
'####################################################################################
' ### 암호화 오브젝트 생성 ###
Set McashCipher = Server.CreateObject("McashCipher.Confirm.1")
Dim keygb, keygb1, keygb2, cryptKey
keygb = "1" '# 사용하는 고유 키 인덱스값 0 or 1 or 2
keygb0 = "240226143538"
keygb1 = "KriPol24"
cryptKey = Left(keygb1, 8) & Left(keygb0, 8)
McashCipher.TradeId = cryptKey
McashCipher.InputData = Resultcd
retval = McashCipher.decodeString
Resultcd = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Resultmsg
retval = McashCipher.decodeString
Resultmsg = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = No
retval = McashCipher.decodeString
No = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Name
retval = McashCipher.decodeString
Name = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Sex
retval = McashCipher.decodeString
Sex = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Socialno
retval = McashCipher.decodeString
Socialno = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Tradeid
retval = McashCipher.decodeString
Tradeid = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Svcid
retval = McashCipher.decodeString
Svcid = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Mobilid
retval = McashCipher.decodeString
Mobilid = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = Signdate
retval = McashCipher.decodeString
Signdate = McashCipher.outputData
McashCipher.TradeId = cryptKey
McashCipher.InputData = MSTR
retval = McashCipher.decodeString
MSTR = McashCipher.outputData
'####################################################################################
' Mac값 위변조 여부 확인 SHA256(Tradeid + Svcid + Mobilid + Signdate + cryptKey)
' Mac값과 SHA256으로 변환한 값을 비교하여 값이 불일치 할 경우 데이터 위·변조
'####################################################################################
Set SHAObj = New CryptSHA256
shastr = SHAObj.SHA256(Tradeid & Svcid & Mobilid & Signdate & cryptKey)
If StrComp(Mac, shastr, 0) = 0 Then
result = "데이터가 정상입니다."
Else
result = "데이터가 위·변조되었습니다."
End If
'####################################################################################
' 아래는 결과를 단순히 출력하는 샘플입니다.
' 가맹점에서는 부모창 전환등 스크립트 처리등을 하시면 됩니다.
'####################################################################################
%>
<%
dim source
source = Request.QueryString("source")
%>
<html>
<head>
<meta charset="euc-kr">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>KG모빌리언스</title>
</head>
<body>
<!--#include virtual="/Include/js.asp"-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/encoding-japanese/1.0.30/encoding.min.js"></script>
<script charset='euc-kr'>
var Resultcd = "<%=Resultcd%>";
var Resultmsg = "<%=Resultmsg%>";
var No = "<%=No%>";
var Name = "<%=Name%>";
var Sex = "<%=Sex%>";
var Socialno = "<%=Socialno%>";
if (Resultcd == "0000") {
/*
console.log('Resultcd : ' + Resultcd);
console.log('Resultmsg : ' + Resultmsg);
console.log('Cryptyn : ' + Cryptyn);
console.log('Keygb : ' + Keygb);
console.log('Mobilid : ' + Mobilid);
console.log('Signdate : ' + Signdate);
console.log('Tradeid : ' + Tradeid);
console.log('Name : ' + Name);
console.log('No : ' + No);
console.log('Commid : ' + Commid);
console.log('Socialno : ' + Socialno);
console.log('Sex : ' + Sex);
console.log('Foreigner : ' + Foreigner);
console.log('Ci : ' + Ci);
console.log('Di : ' + Di);
console.log('CI_Mode : ' + CI_Mode);
console.log('MSTR : ' + MSTR);
console.log('Mac : ' + Mac);
*/
//console.log('myMac : ' + myMac);
//console.log('-----------------------------------------');
// 인증 성공 시 부모창 폼에 값 세팅
var openerDoc = opener.document;
$("#r_phone", openerDoc).val(No);
$("#r_name", openerDoc).val(Name);
$("#r_gender", openerDoc).val(Sex == "M" ? "1" : "2");
if (Sex == "M") {
$("a[data-toggle='r_gender'][data-title='1']", openerDoc).removeClass("notActive").addClass("active");
$("a[data-toggle='r_gender'][data-title='2']", openerDoc).removeClass("active").addClass("notActive");
} else {
$("a[data-toggle='r_gender'][data-title='1']", openerDoc).removeClass("active").addClass("notActive");
$("a[data-toggle='r_gender'][data-title='2']", openerDoc).removeClass("notActive").addClass("active"); // 오타 수정: "Active" → "active"
}
$("#r_birth", openerDoc).val(Socialno);
$("#chk", openerDoc).val("1");
$("#r_chk", openerDoc).hide();
<% If source = "signin" Then %>
// source가 signin인 경우 DB와 대조
$.ajax({
url: "/Ajax/AjaxMobileCheck.asp",
type: "POST",
data: {
"gubun": "check",
"r_name": $("#r_id", openerDoc).val(),
"r_phone": $("#r_pw", openerDoc).val(),
"chk": "on"
},
success: function (res) {
if (res === "nouser") {
alert("휴대폰 본인인증 결과와 일치하지 않는 정보입니다.\n다시 입력해주세요.");
} else if (res === "complete") {
/*
if (window.opener && !window.opener.closed) {
window.opener.document.getElementById("mobileVerified").value = "Y";
window.opener.document.getElementById("LoginOk").disabled = false;
}
*/
alert("본인인증이 완료되었습니다.");
$("#LoginOk", openerDoc).click();
window.open("about:blank", "_self").close();
} else {
alert("System Error\n관리자 문의");
}
},
error: function () {
alert("System Error\n관리자 문의");
}
//window.open("about:blank", "_self").close();
});
<% Else %>
// source가 signup 등인 경우
alert("본인인증이 완료되었습니다.");
window.open("about:blank", "_self").close();
<% End If %>
} else {
// 인증 실패 시 처리
alert("본인인증에 실패했습니다.\n사유: " + Resultmsg);
window.open("about:blank", "_self").close();
}
</script>
</body>
</html>