From 570c93d4a4259f5976da2415f9726e64070ba59d Mon Sep 17 00:00:00 2001 From: AGSTR <144728914+agstrxyz@users.noreply.github.com> Date: Wed, 24 Jul 2024 22:40:43 +0700 Subject: [PATCH] Update radius.php menambahkan metode otentikasi CHAP --- radius.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/radius.php b/radius.php index b6b46586..c47a1578 100644 --- a/radius.php +++ b/radius.php @@ -68,12 +68,31 @@ try { $username = _req('username'); $password = _req('password'); $isVoucher = ($username == $password); + $real = _req('CHAPassword'); + $challenge = _req('CHAPchallenge'); + if (!empty($real)) { //aktif hanya kalo chappasword ada isinya + $dd = ORM::for_table('tbl_customers')->select('password')->where('username', $username)->find_one(); + $pwd = $dd['password']; //ambil password text + $challenger = hex2bin(substr($challenge, 2)); //buang 0x + $realr = substr($real, 2); //buang 0x lagi + $chapid = substr($realr, 0, 2); //ambil chap-id dari chap-pass + $chapidr = hex2bin($chapid); //konvert chap-id + $result = $chapidr . $pwd . $challenger; //mix semua + $response = $chapid.md5($result); //enkripsi lagi hasilnya trus di mix sama chap id + if ($response != $realr) { //begal kalo hasil gak sama + show_radius_result(['Reply-Message' => 'Username or Password is wrong'], 401); + } + + //if ($response == $realr) { echo 'ok betul 100'; }else{ echo 'salah'; } // untuk keperluan debug + } else { //kalo chappassword kosong brrti eksekusi yg ini + if (empty($username) || empty($password)) { show_radius_result([ "control:Auth-Type" => "Reject", "reply:Reply-Message" => 'Login invalid......' ], 401); - } + } + } $tur = ORM::for_table('tbl_user_recharges')->where('username', $username)->find_one(); if ($tur) { if (!$isVoucher) {