=========================================================
yum install epel-release
yum install google-authenticator
google-authenticator
큐알코드 찍기
다음 모두 y
너무커서 안되면 (vmware 안에서 진행하세요)
*** 파일이 생성되서 저장되는 위치 잘 확인할것)
=========================================================
sshd 설정
PasswordAuthentication yes
ChallengeResponseAuthentication yes <=======요부분만 YES로 수정
UsePAM yes
=========================================================
pam 설정
모든사용자 vi /etc/pam.d/sshd
auth required pam_sepermit.so
auth required password-auth
auth required pam_google_authenticator.so nullok secret=${HOME}/.google_authenticator
<<<<< 파일 생성되는 위치 잘확인
=========================================================
pam 설정
OTP사용자만 vi /etc/pam.d/sshd
auth required pam_sepermit.so
auth required password-auth
auth required pam_google_authenticator.so secret=${HOME}/.google_authenticator <<<<< 파일 생성되는 위치 잘확인
=========================================================
mini 에서 실행
yum install epel-release.noarch
yum localinstall http://dist.linotp.org/rpm/el7/linotp/x86_64/Packages/LinOTP_repos-1.3-1.el7.x86_64.rpm
yum install mariadb-server
yum install LinOTP
yum install LinOTP_mariadb
yum install LinOTP_apache
service httpd restart
service mariadb restart
systemctl enable httpd
systemctl enable mariadb
***DB 한글설정 ***
vi /etc/my.cnf
[mysqld]
character_set_server=utf8
[client]
default-character-set=utf8
service mariadb restart
mysql -u root -p
\s ( UTF-8 확인)
=========================================================
*** LINOTP 서버설정 ***
cd /etc/linotp2
cp -a linotp.ini.example linotp.ini
linotp-create-mariadb
mysql_secure_installation"? [Y/n] y [보안설정]
Enter current password for root (enter for none):[엔터]
Set root password? [Y/n] n [ root 비번 ]
Remove anonymous users? [Y/n] Y [익명사용자 삭제여부]
Disallow root login remotely? y [원격루트 제한]
Remove test database and access to it? [Y/n] y [testDB삭제여부]
Reload privilege tables now? [Y/n] y [적용하시겠습니까?]
Would you like to start MariaDB at server startup? [Y/n] y
[서버 재시작 ]
Please enter in the next line the MariaDB root password!
Enter password: [root 비번 설정안했으면 엔터 ]
***DB인스톨****
paster setup-app /etc/linotp2/linotp.ini
(잘만들어지는거 확인할것 2번실행 주르륵 나옴 실패)
**암호화키생성**
dd if=/dev/urandom of=/etc/linotp2/enckey bs=1 count=96
linotp-create-enckey -f /etc/linotp2/linotp.ini
**방화벽해제**
systemctl stop firewalld
systemctl disable firewalld
*** 구동 ***
paster serve /etc/linotp2/linotp.ini
*** 웹브라우저 ***
http://192.168.10.200:5001/manage 확인
=========================================================
LINOTP 웹페이지
LinOTP Config => UserIdResolvers => +NEW => SQL =>
Resolver name : 아무거나
Driver: mysql
Server: 192.168.10.100
port : 3306
Database : sevas
User : master
Password : asd123
Database Table : class
attribute mapping
{ "userid":"c_no", "username": "id","password" : "pw" }
Test SQL connection 누르고 OK 확인하세요. (192.168.10.100의 웹페이지에서 계정 등록해둘것)
**Reams 설정 **
sevas => set default
userIdResolvers
Realms
user View 카테고리에 ID뜨는거 확인
=========================================================
PIN = abcd
불러오기코드
PIN abcd OTP코드 753483 계정 sevas
http://192.168.10.30:5001/validate/check?pass=abcd[otp값]&user=admin[만든 계정중에서]
{
"version": "LinOTP 2.12.6",
"jsonrpc": "2.0802",
"result": {
"status": true,
"value": true
},
"id": 0
}
vi /proc/login_proc.php
==> 페이지 수정
<?php
$id=$_POST['id'];
$pw=$_POST['pw'];
$hidden=$_POST['hidden'];
$otp=$_POST['otp'];
#$id = preg_replace("/[\r\n\s\t\'\;\"\=\-\-\#\/*]+/","", $id);
#$pw = preg_replace("/[\r\n\s\t\'\;\"\=\-\-\#\/*]+/","", $pw);
#if(preg_match('/(union|select|from|where)/i', $id))
#{
# echo "No SQL-Injection!!!!<br>";
# echo "<a href=/login.html> 되돌아가기 </a>";
# exit;
#}
#echo "$id<br>";
#echo "$pw<br>";
#echo "$hidden<br>";
session_start();
$connection = mysqli_connect("db.sevas10.com", "master", "asd123");
$connection or die ("NET 연결오류");
echo "connect success<br>";
mysqli_select_db($connection,"sevas") or die ("DB 연결실패");
echo "Connect DB<br>";
$sql="select id,pw from class where id='$id' and pw='$pw'";
$exec=mysqli_query($connection,$sql);
$result=mysqli_fetch_array($exec) or die ("Login Fail<br>
<form method=POST action=/login.html>
<input type=submit value='다시로그인'>
</form>"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://192.168.10.30:5001/validate/check?pass=abcd$otp&user=$id");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$c=curl_exec ($ch);
curl_close ($ch);
if (preg_match("/true\\s/i", $c)) {
# $result = "ok".$c.")";
echo "OK";
echo "Login success";
session_start();
$_SESSION['LoginID']=$id;
header("location:/index.php");
} else {
echo "실패";
# $result = "FAILED".$c.")";
}
#echo $result;
?>
vi login.html
==> otp 칸 만들기
<td> OTP </td>
<td> <input type=password name=otp> </td>
</tr>
==> 추가
웹 페이지에서 로그인 할때 otp 이용해서 로그인 해보기
'보안 국비 용 > 보안 10월' 카테고리의 다른 글
보안 과정 형 평가 71일차 (2024.11.12) (0) | 2024.11.12 |
---|---|
보안 과정 형 평가 68일차 (2024.11.07) (0) | 2024.11.07 |