테스트 사이트 - 개발 중인 베타 버전입니다

그누보드 비밀번호 암호화 적용법 채택완료

rqwr 8년 전 조회 8,618

그누보드 검색해서 암호화 하는거를 찾았는데요.. 

https://sir.kr/g4_qa/215004">https://sir.kr/g4_qa/215004 


$password = mysql_real_escape_string($_POST['password']); 
insert into table set ps=PASSWORD('$password') ...  

이걸 적용시키라는데

$mb_id = $_POST['mb_id'];

$mb_password =  mysql_real_escape_string($_POST['mb_password']); 

$mb_name = $_POST['mb_name'];

$mb_nick = $_POST['mb_nick'];

$mb_email = $_POST['mb_email'];


$stmt = mysqli_prepare($con, "INSERT INTO g5_member  set mb_password=PASSWORD('$mb_password') VALUES (?, ?, ?, ?, ?)");

mysqli_stmt_bind_param($stmt, "sssss", $mb_id, $mb_password, $mb_name, $mb_nick, $mb_email);

mysqli_stmt_execute($statement);


$response = array();

$response["success"] = true;


echo json_encode($response);


이런식으로 해줬는데.. 값이 아예 안넘어가는데 혹시 틀린부분이 있는건가요??


 $mb_password = get_encrypt_string($mb_password);  이거쓸려면 

인클루드해서 써야하는건가요?



댓글을 작성하려면 로그인이 필요합니다.

답변 6개

채택된 답변
+20 포인트
플래토
8년 전

로직이 조금 이상하다고 생각되는 부분을 몇개 나열해보겠습니다.

해결되셨으면 패스~


1. 가입할때 password를 수신하는 부분이 있나요?

password 부분을 대입하는 부분도 동일하게 맞추는게 어떨까요?

</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_id = $_POST['mb_id'];</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_password = get_encrypt_string($mb_password);  <span style="font-size: 14.004px;">//비번을 수신받는 부분이 이상합니다.</span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_name = $_POST['mb_name'];</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_nick = $_POST['mb_nick'];</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_email = $_POST['mb_email'];</p><p>

이부분에서


</p><p><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_password = get_encrypt_string($_POST['mb_password']);   //비번을 수신받아야 할것 같은데요</span> </p><p><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">                                                                         // 상단에 있으면 패스</span></p><p><span style="font-family: 돋움, Dotum, sans-serif; color: rgb(80, 80, 80);"><span style="font-size: 14.004px;">




2. 가입하실때 컬럼이 이상합니다.

</p><p><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$stmtement = mysqli_prepare($con, " INSERT INTO g5_member VALUES (?, ?, ?, ?, ?) ");</span> </p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">mysqli_stmt_bind_param($stmtement, "sssss", $mb_id, $mb_password, $mb_name, $mb_nick, $mb_email);</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">mysqli_stmt_execute($stmtement);</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">

부분이 정상작동되나요?


</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">
</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$stmtement = mysqli_prepare($con, " INSERT INTO g5_member (mb_id, mb_password, mb_name, mb_nick, mb_email) VALUES (?, ?, ?, ?, ?) ");</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">mysqli_stmt_bind_param($stmtement, "sssss", $mb_id, $mb_password, $mb_name, $mb_nick, $mb_email);</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">mysqli_stmt_execute($stmtement);</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">

와 같이 g5_member (입력할컬럼명) values (입력할값)

또는

insert into g5_member

set column = value

;

되어야 정상작동으로 알고있습니다만..





3. 로그인하실때 로그인이 안된다하셨는데


가입할때와 같이 

로그인할 비번을 입력받아서 



</p><p style="font-size: 14.6667px;">$mb_id = $_POST['mb_id'];</p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$mb_password = get_encrypt_string($_POST['mb_password']); </span> </p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">
</span></p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">$valid_password = sql_fetch("select password from g5_member where mb_id = '$mb_id'");</span></p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">
</span></p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">if ($mb_password != $valid_password) {</span></p><p style="font-size: 14.6667px; margin-left: 40px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">alert('비번이다릅니다");</span></p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">}</span></p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">// 이하 로그인 로직</span></p><p style="font-size: 14.6667px;"><span style="color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;">
</span></p><p style="font-size: 14.6667px;"><span style="font-family: 돋움, Dotum, sans-serif; color: rgb(80, 80, 80);"><span style="font-size: 14.004px;">


이렇게 비교하는 로직이 정상적으로 존재하는 건가요? 

(되어있으면 패스)


해당부분에서 각각 변수/상태를  출력을 해보심이 좋을것 같습니다.




로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

1. include에 url은 넣으셔도 작동 안 합니다.

2. 그누보드 함수(get_encrypt_string)를 사용해야 하는 이유가 있나요?

이걸 include하려면 config.php 파일도 같이 include를 하셔야 합니다.

config.php 파일에 G5_STRING_ENCRYPT_FUNCTION 상수를 정의할 때 거기에 적힌 값을 참고해서 get_encrypt_string 이 함수를 작동시킵니다.

만약 그누보드를 운영 중이시라면 저 부분 설정을 md5로 바꾸기만 해도 문제가 발생할 겁니다.

기존 회원 테이블에 저장되어 있는 패스워드 암호화 체계가 달라지니까요.


$mb_password = md5($mb_password);

결론은 위에 쓰신 내용 코드에서 $mb_password 부분만 이렇게 바꾸셔도 아마 정상적으로 작동할 겁니다.

그 밑에 $response 변수는 왜 있는 건지 알 수 없지만요.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

r
rqwr
8년 전
그런데 가입을했는데 로그인이 비밀번호가 맞지 않다고 로그인이 안되네요..
왕계란
8년 전
include_once "경로/common.lib.php";
$mb_password = get_encrypt_string($_POST['mb_password']);
sql_query("INSERT INTO #테이블 mb_password = '".$mb_password."'");

근데 왜 디비 연결을 pdo class로 사용하시는 건가요?
그누보드 기본 함수 사용해서 그냥 쓰면 될 텐데 굳이 왜 저렇게 하시는지 이해가 안 갑니다.
그리고 이미 그누보드 사용 중이었고 회원 가입도 이전에 이미 되었다면 패스워드 저장된 체계가 다를 수가 있는데...
가장 좋은 방법은 그누보드에서 제공하는 sql_* 사용자 정의 함수 사용해서 비밀번호 세팅해 주세요.
r
rqwr
8년 전
죄송한데 쪽지확인점 ㅠㅠ

댓글을 작성하려면 로그인이 필요합니다.

r
8년 전

<?php


 include_once('http://도메인명/lib/common.lib.php">http://도메인명/lib/common.lib.php .php');

 

$con =  mysqli_connect("localhost", "아이디", "패스워드", "디비명");



$mb_id = $_POST['mb_id'];

$mb_password = get_encrypt_string($mb_password); 

$mb_name = $_POST['mb_name'];

$mb_nick = $_POST['mb_nick'];

$mb_email = $_POST['mb_email'];


 

$stmtement = mysqli_prepare($con, " INSERT INTO g5_member VALUES (?, ?, ?, ?, ?) ");

mysqli_stmt_bind_param($stmtement, "sssss", $mb_id, $mb_password, $mb_name, $mb_nick, $mb_email);

mysqli_stmt_execute($stmtement);


$response = array();

$response["success"] = true;


echo json_encode($response);


 

?>

이렇게 하는게 아닌가요? 조금이라도 도움좀 주세요..ㅠㅠ

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

스아이
8년 전

get_encrypt_string 함수는 common.lib.php 에 담겨있습니다. 


기본적으로 레이아웃 내부에 사용할때는 별도로 인클루드하실필요는 없습니다.


인클루드가 필요하다면

common.lib.php 파일을 인클루드하시길 바랍니다



도움이 되셨다면 채택바랍니다. 감사합니다.

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

r
rqwr
8년 전
경로/rg/register.php 일경우 인클루드 해야 되나요?
스아이
8년 전
rg 라는 폴더가 있나요?

bbs 폴더의 register.php 는 인클루드 할필요는 없습니다.
r
rqwr
8년 전
임의로 회원가입 페이지를 만들어야해서 따로 폴더를만들고 php를만들었습니다

댓글을 작성하려면 로그인이 필요합니다.

그누위즈
함수를 변수처럼 사용하려고 해서 그렇습니다<br />
$mb_password = $get_encrypt_string($mb_password); <br />
이게 아니라<br />
$mb_password = get_encrypt_string($mb_password); <br />
이렇게 사용해보세요
로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

r
rqwr
8년 전
그렇게 햇더니 페이지 오류가 떠버리네요..
제가 한곳은
경로에서 폴더하나 만든다음에 거기다가 regist.php따로만들어서 쓰고있습니다.

댓글을 작성하려면 로그인이 필요합니다.

r
8년 전

$mb_password = $get_encrypt_string($mb_password);  이렇게 햇더니 페이지가 응답오류 나버리네요 왜이런건가요?

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인