banner

[Rule] Rules  [Home] Main Forum  [Portal] Portal  
[Members] Member Listing  [Statistics] Statistics  [Search] Search  [Reading Room] Reading Room 
[Register] Register  
[Login] Loginhttp  | https  ]
 
Forum Index Thảo luận bảo mật Password bị mã hoá dạng decrypt password  XML
  [Question]   Password bị mã hoá dạng decrypt password 01/12/2011 14:30:51 (+0700) | #1 | 250551
minhtien001
Member

[Minus]    0    [Plus]
Joined: 30/03/2005 15:29:06
Messages: 30
Offline
[Profile] [PM]
Mình đang nghiên cứu 1 open source, sau khi cấu hình và cài đặt chạy thử thì ko thể login vào admin dc.

Mình kiểm tra phpmyadmin để xem pass như thế nào thì nó có dạng: qsnoweyMuNFQIyJzPRO2R2pKBspnwC
Mình thử đổi pass trong phpmyadmin và md5 1 lần, 2 lần đều không dc.

Mình kiểm tra file login.php thì thấy cấu trúc dạng mã hoá như sau:
Code:
if ( !$row['password'] ) return false;		
		$password = $crypt->decrypt_password($row['password'], $row['login_key'], 32);						
		if ($password != $tmp_password) return false;
		if (strcmp($row['username'], $tmp_username) <> 0 ) return false;


Qua dòng này:

Code:
$password = $crypt->decrypt_password($row['password'], $row['login_key'], 32);


password: qsnoweyMuNFQIyJzPRO2R2pKBspnwC
login_key: 9f6eg1jh7aejydlovnzoqzo24qijf5nm

Mình không hiểu dạng mã hoá decrypt password và có cách nào để thay đổi mã của nó trong phpmyadmin ko?

Chân thành cảm ơn
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 01/12/2011 15:11:44 (+0700) | #2 | 250556
[Avatar]
chiro8x
Member

[Minus]    0    [Plus]
Joined: 26/09/2010 00:38:37
Messages: 661
Location: /home/chiro8x
Offline
[Profile] [PM] [Yahoo!]
Bạn phải cho biết nó là cái gì chứ, thế này thì đánh đố người khác rồi. Vì tớ đâu có biết cái object $crypt nó có các function nào và các function được viết như thế nào đâu. Nêu mình chỉ có thể trả lời bạn một cách không có căn cứ thôi.

Password có 30 kí tự, login_key 32 kí tự. Nên password không phải là md5 rồi, nó là kết quả của cái hàm encrypt password kia. Bạn post suorce của $crypt object lên mới đc. Mình nghĩ là mật khẩu được mã hoá bằng md5 trước sau đó thì có thể rot13,v...v....
while(1){}
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 01/12/2011 19:12:00 (+0700) | #3 | 250564
minhtien001
Member

[Minus]    0    [Plus]
Joined: 30/03/2005 15:29:06
Messages: 30
Offline
[Profile] [PM]
Cảm ơn bạn

Nhưng không biết bạn cần những thông tin gì để có thể tìm hiểu và trả lời giúp mình

Đây là toàn bộ file login.php
Code:
<?php
/*------------------------------------
| LOGIN TO ADMIN PANEL
 ------------------------------------*/
 
// Check for Security
if ( !defined('HCR') )
{
	print "<h1>Incorrect Access</h1>";
	exit();
}

$cnt = new content;

class content
{
	public $text = "";
	public $title = "WEBSITE CONTROL PANEL";	
	private $process = "";
	private $frmValue = array(
								'password' => '',
								'username' => '',
						  	 );
	private $error = array(
								'username' => 0,
								'password' => 0,
							);
	private $warning = "";
	
	
	function __construct()
	{
		global $str, $sess, $lang, $panel;		
		if ($sess->member_id) $sess->destroy();		
		$this->get_input();
		$check_input = $this->check_input( $this->frmValue );
		
		if ( $this->process == "login" )
		{
			if ($check_input)
			{
				 if ($this->login($this->frmValue))
				 {
				  	  $str->goto_url('admp.php');
				 }
				 else
				 {
					  $this->warning = " <span class='span_err'>". $lang['login_notmatch'] ."</span><br/><br/>";
				 }
			}
			else
			{
				$this->warning = "<span class='span_err'>". $lang['login_error'] ."</span><br/><br/>";
			}
		}else
		{
			//Reset Error Array
			$this->error['username'] = 0;
			$this->error['password'] = 0;
		}
		
		$this->text = $this->warning ? "<div id='warning'><b><u>Lỗi nhập liệu</u></b> : " . $this->warning . "</div>" . $this->box_login() : $this->box_login();
	}
	
	
	/*---------------------------------------------
	 | GET INPUT DATA	
	+----------------------------------------------*/
	function get_input()
	{
		global $str;		
		$this->process = isset($_POST['process']) ? $str->input($_POST['process']) : "";		
		$this->frmValue['username'] = isset($_POST['username']) ? $str->input($_POST['username']) : "";
		$this->frmValue['password'] = isset($_POST['password']) ? $_POST['password'] : "";
	 }
	
	
	/*--------------------------------------------------
	 | CHECK INPUT DATA
	+--------------------------------------------------*/
	function check_input($frmValue)
	{
		global $frm, $main, $sess, $db, $str;		
		$no_error = true;		
		if ( !$frm->check_username($frmValue['username'], 3) )
		{
			$this->error['username'] = 1;
			$no_error = false;
		}
		
		if ( !$frm->check_password($frmValue['password'], 6, 32) )
		{
			$this->error['password'] = 1;
			$no_error = false;
		}
		
		return $no_error;
	}
	
	
	/*-------------------------------------------
	  | CHECK INFOS AND AUTHENTICATE FOR LOGIN
	+--------------------------------------------*/
	function login($frmValue)
	{
		global $str, $frm, $db, $sess, $lang, $crypt, $main;
		
		if ( $sess->member_id ) $sess->destroy();
		
		$tmp_username = stripslashes($frmValue['username']);
		$tmp_password = stripslashes($frmValue['password']);
				
		
		$query = $db->simple_select("username, password, login_key, id, groups", "adm_members", "username = '". mysql_real_escape_string($tmp_username) ."' AND active = 1");
		$result = $db->query($query);
		$row = $db->fetch_array($result);
		
		if ( !$row['password'] ) return false;		
		$password = $crypt->decrypt_password($row['password'], $row['login_key'], 32);						
		if ($password != $tmp_password) return false;
		if (strcmp($row['username'], $tmp_username) <> 0 ) return false;
		
		// Update to session
		$sess->member_id = $row['id'];
		$sess->username = $frmValue['username'];
		$sess->groups_id = $row['groups'];
				
		$arr = array( 
						'username' => $sess->username,
						'member_id' => $sess->member_id,
						'groups_id' => $sess->groups_id,
					);
		$db->do_update("session", $arr, "id = '". $sess->sess_id ."'");
						
		// Update last visit
		$arr = array( 'last_visit'  => $sess->now );
		$db->do_update("adm_members", $arr, "id = ". $sess->member_id);
		
		return true;
	}
	
	/*------------------------------------------------
	 | SHOW LOGIN BOX
	--------------------------------------------------*/
	function box_login()
	{
		global $lang, $frm, $dsp;
		
		$text  = $frm->draw_form("", "", 2, "POST");
		$text .= $frm->draw_hidden("process", "login");
			$text .= "<center><fieldset style='border:#0066FF solid 1px; width:300px;'>
<legend style='font-weight:bold; font-size:0.9em; color:#333333'><img src='". ADMIN_IMG ."lock.png' align='absmiddle' width='20' /> Đăng nhập hệ thống</legend>";
			$text .= "<table border='0' width='300'>";
				$text .= "<tr><td height='5' colspan='2'></td></tr>";
				$text .= "<tr>";
					$text .= "<td width='70'>" . $lang['login_user'] . "</td>";
					$text .= "<td align='left'>" . $frm->draw_textfield("username", "", "field", "", "32") . "</td>";
				$text .= "</tr>";
				$text .= "<tr><td height='2' colspan='2'></td></tr>";
				$text .= "<tr>";
					$text .= "<td>" . $lang['login_pass'] . "</td>";
					$text .= "<td align='left'>" . $frm->draw_password("password", "field", "", "32") . "</td>";
				$text .= "</td></tr>";
				$text .= "<tr><td height='5' colspan='2'></td></tr>";
				$text .= "<tr><td colspan='2' align='center'>";
					$text .= "<input type='submit' value='Đăng nhập' style='background-color:#0F4B5D; color:#FFFFFF; border:#CCC solid 1x;' />";
				$text .= "</td></tr>";
				$text .= "<tr><td height='5' colspan='2'></td></tr>";
			$text .= "</table></fieldset></center>";
		$text .= '</form>';
		
		return $text;
	}
}

?>
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 01/12/2011 19:53:15 (+0700) | #4 | 250566
mr.khungxox
Member

[Minus]    0    [Plus]
Joined: 23/06/2007 13:43:16
Messages: 117
Offline
[Profile] [PM]
hihi cái đoạn quan trọng nhất là hàm decrypt_password thì không thấy post sao mà đoán đựoc chứ.
Mò mò trong source code cái class cùa đối tượng $crypt, tìm cái hàm decrypt_password rồi post lên đây đi bạn
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 01/12/2011 20:18:28 (+0700) | #5 | 250567
minhtien001
Member

[Minus]    0    [Plus]
Joined: 30/03/2005 15:29:06
Messages: 30
Offline
[Profile] [PM]
Thanks
Vì không biết chuỗi pass của nó làm sao để chỉnh trong phpmyadmin dc.

Đây là nội dung file crypt.php

Code:
<?php
/*----------------------------------------
| CLASS FOR CRYPT AND ENCRYPT
----------------------------------------*/
// Check for Security
if ( !defined('HCR') )
{
	print "<h1>Incorrect Access</h1>";
	exit();
}

class crypter
{
	private $secu_code_arr = array(
										"start" => "a",
										"end" => "z",
									);
	private $pass_min_length = 6;				
	private $key_length = 32;
	private $encode_key = "e9c495f4b4271113dc1e546cbf04224b";	//Not change
	private $encode_arr = array(								//Not change
							" ", "0", "1", "2", "3",
							"4", "5", "6", "7", "8",
							"9", "a", "b", "c", "d",
							"e", "f", "g", "h", "i",
							"j", "k", "l", "m", "n",
							"o", "p", "q", "r", "s",
							"t", "u", "v", "w", "x",
							"y", "z", "A", "B", "C",
							"D", "E", "F", "G", "H",
							"I", "J", "K", "L", "M",
							"N", "O", "P", "Q", "R",
							"S", "T", "U", "V", "W",
							"X", "Y", "Z", "@",
						);
						
	/*-----------------------------------------------------
	| CREATE RANDOM KEY
	+ ---------------------------------------------------*/
	function random_key($number)
	{
		$arr_sum = array();
		$arr_num = array();
		$arr_char = array();
		
		$arr_num = range("0", "9");
		$arr_char = range($this->secu_code_arr['start'], $this->secu_code_arr['end']);
		
		$arr_sum = array_merge($arr_num, $arr_char);

		$rand = '';
		for($i = 0; $i < $number; $i++)
		{
			$key = array_rand($arr_sum);
			$rand .= $arr_sum[$key];
		}
		
		return $rand;
	}
	
	/*-----------------------------------------------------
	| CREATE A SECURITY CODE
	+ ---------------------------------------------------*/
	function security_code($number)
	{
		// Lay ngau nhien tu 0-9, A-Z
		$this->secu_code_arr['start'] = "A";
		$this->secu_code_arr['end'] = "Z";
		
		return $this->random_key($number);
	}
	
	/*-----------------------------------------------------
	| COMPILE A SECURITY CODE TO PRINT IN SCREEN
	+ ---------------------------------------------------*/
	function print_screen($code)
	{
		$str_print = "";
		for($i = 0; $i < strlen($code); $i++)
		{
			$str = substr($code, $i,1);
			$str_print .= $str.'';
		}
		
		return $str_print;
	}
	
	/*-----------------------------------------------------
	| CREATE KEY FOR CRYPT A PASSWORD
	+ ---------------------------------------------------*/
	function set_key()
	{
		// Lay ngau nhien tu 0-9, a-z
		$this->secu_code_arr['start'] = "a";
		$this->secu_code_arr['end'] = "z";
		
		return $this->random_key($this->key_length);
	}
	
	/*-----------------------------------------------------
	| FILL IN MISSING CHAR BY RANDOM CHAR
	|
	| This help Vernam encrypt be true
	+ ---------------------------------------------------*/
	function get_true_vernam($text)
	{
		// Just encrypt chars in encode_arr
		$text_arr = str_split($text);
		$text = "";
		foreach ($text_arr as $k => $v)
		{
			$yes = false;
			foreach ($this->encode_arr as $value)
			{
				if ($v == $ $value)
				{
					$yes = true;
					break;
				}
			}
			
			if ($yes) $text .= $text_arr[$k];
		}
		
		// strlen($key) = strlen($password) = key_length
		if ( strlen($text) < $this->key_length)
		{
			$text .= "@";
			
			while ( strlen($text) < $this->key_length) $text .= $this->random_key(1);
			
			if ( strlen($text) > $this->key_length) $text = substr($text,0,$this->key_length);
		}
		
		return $text;
	}
	
	/*-----------------------------------------------------
	| ENCODE TEXT USING VERNAM ALGORITHM
	+ ---------------------------------------------------*/
	function vernam($text, $key)
	{
		// Be sure $text and $key are valid
		$text = $this->get_true_vernam($text);
		$key = $this->get_true_vernam($key);
		
		$text_arr = str_split($text);
		$key_arr = str_split($key);
		
		$code_text = "";
		
		
		for ($i = 0; $i < $this->key_length; $i++)
		{
			$text_int = 0;
			while ( ($text_arr[$i] != $this->encode_arr[$text_int]) && ($text_int < count($this->encode_arr)) ) $text_int++;
			
			$key_int = 0;
			while ( ($key_arr[$i] != $this->encode_arr[$key_int]) && ($key_int < count($this->encode_arr)) ) $key_int++;
			
	
			$code_int =  $text_int + $key_int;
			
			if ( $code_int > count($this->encode_arr) ) $code_int -= count($this->encode_arr);
			
			$code_text .= $this->encode_arr[$code_int];
		}
		
		return $code_text;
	}
	
	/*-----------------------------------------------------
	| DECODE TEXT HAD BEEN ENCODE WITH VERNAM ALGORITHM
	+ ---------------------------------------------------*/
	function devernam($text, $key)
	{
		
		$text = $this->get_true_vernam($text);
		$key = $this->get_true_vernam($key);
		
		$text_arr = str_split($text);
		$key_arr = str_split($key);
		
		$code_text = "";
		
		
		for ($i = 0; $i < $this->key_length; $i++) 
		{			
			$text_int = 0;
			while ( ($text_arr[$i] != $this->encode_arr[$text_int]) && ($text_int < count($this->encode_arr)) ) $text_int++;
			
			
			$key_int = 0;
			while ( ($key_arr[$i] != $this->encode_arr[$key_int]) && ($key_int < count($this->encode_arr)) ) $key_int++;
			
			
			$code_int =  $text_int - $key_int;
			
			if ( $code_int < 0 ) $code_int += count($this->encode_arr);
			
			$code_text .= $this->encode_arr[$code_int];
		}
		
		return $code_text;
	}
	
	/*-----------------------------------------------------
	| ENCODE PASSWORD BY VERNAM ALGORITHM
	+ ---------------------------------------------------*/
	function crypt_password($password, $key)
	{
		// Encode keyword
		$key = $this->vernam($key, $this->encode_key);
		
		// Encode password
		return $this->vernam($password, $key);
	}
	
	/*-----------------------------------------------------
	| DECODE PASSWORD HAD BEEN ENCODE BY VERNAM
	+ ---------------------------------------------------*/
	function decrypt_password($password, $key)
	{
		$key = $this->vernam($key, $this->encode_key);		
		$text = $this->devernam($password, $key);		
		$password_arr = explode("@", $text);
		return $password_arr[0];
	}
}
?>
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 02/12/2011 07:00:18 (+0700) | #6 | 250581
mr.khungxox
Member

[Minus]    0    [Plus]
Joined: 23/06/2007 13:43:16
Messages: 117
Offline
[Profile] [PM]
Ừ, thấy đoạn code nó viết lằng nhằng ghê, Thấy bọn nào làm cái này cũng rãnh thiệt ghê chứ.

Nhưng theo mô hình thì thế này ne:

+Khi đăng kí( hay tạo tài khoản) : người dùng nhập password --> chuơng trình sẽ mã hoá bằng hàm var Encrypted_Password= crypt_password($password, $key) , và sau đó tiến hành lưu giá trị password đã mã hoá và Key mã hoá vào trong database
+khi người dùng đăng nhập thì nó lấy password đã mã hoá và key trong database ra,sau đó so sánh với password mà người dùng nhập vào.

Theo như trên thì có 2 cách đế lấy lại password:
Cách 1: thêm 1 dòng dưới hàm : $password = $crypt->decrypt_password($row['password'], $row['login_key'], 32); ( trong file login.php, chỗ hàm function login($frmValue) đó bạn): dòng này làm nhiệm vụ in cái biến password ra file hoặc cái gì đó tuỳ theo bạn nghĩ là được
Cách 2: cách này thì mệt hơn 1 chút:
+Bước 1: vo trong database, lấy cái Key của user
+Bước 2: viết 1 hàm nhỏ nhỏ , truyền , sử dụng hàm function crypt_password($password, $key): đối số: password: mình tự đặt, key lấy ở bước 1.
+Bước 2: sau khi gọi hàm crypt_password, bạn sẽ có 1 cái password được mã hoá, lưu cái password mã hoá này vào trong database lại là xong à

Chào bạn hen.
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 02/12/2011 12:37:59 (+0700) | #7 | 250592
minhtien001
Member

[Minus]    0    [Plus]
Joined: 30/03/2005 15:29:06
Messages: 30
Offline
[Profile] [PM]
Cảm ơn bạn

Bạn có thể nói rõ hơn về cái hàm ở cách 1 dc ko? cụ thể với file login như trên mình có thể chèn hàm gì để nó xuất ra file password.

Chân thành cảm ơn !
[Up] [Print Copy]
  [Question]   Password bị mã hoá dạng decrypt password 04/12/2011 17:34:18 (+0700) | #8 | 250655
[Avatar]
chiro8x
Member

[Minus]    0    [Plus]
Joined: 26/09/2010 00:38:37
Messages: 661
Location: /home/chiro8x
Offline
[Profile] [PM] [Yahoo!]

minhtien001 wrote:
Cảm ơn bạn

Bạn có thể nói rõ hơn về cái hàm ở cách 1 dc ko? cụ thể với file login như trên mình có thể chèn hàm gì để nó xuất ra file password.

Chân thành cảm ơn ! 


Hack site người ta thì nói đi smilie). Cái source này dân Việt Nam nó mod lại rồi. Ông này chui vào web người ta làm bậy à ?.
while(1){}
[Up] [Print Copy]
[digg] [delicious] [google] [yahoo] [technorati] [reddit] [stumbleupon]
Go to: 
 Users currently in here 
1 Anonymous

Powered by JForum - Extended by HVAOnline
 hvaonline.net  |  hvaforum.net  |  hvazone.net  |  hvanews.net  |  vnhacker.org
1999 - 2013 © v2012|0504|218|