hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2025.06.16. 20:41



Jelenlévő felhasználók

Jelenleg 373 felhasználó van jelen :: 2 regisztrált, 0 rejtett és 371 vendég

A legtöbb felhasználó (2761 fő) 2025.01.09. 20:06-kor tartózkodott itt.

Regisztrált felhasználók: Bing [Bot], Google [Bot]az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása Hozzászólás a témához  [19 hozzászólás ]  OldalElőző12
Szerző Üzenet
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.16. 08:37 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Hát, akkor leírom nagyjából.

Nézd meg hogy az a portal rendszer hogy titkosít regisztrációnál.

Ha simán md5 akkor nincs semmi gond. Játékba ha regisztrál simán berakod md5-re, s úgy küldöd fel adatbázisba.
Még loginnál arra kell figyelni, hogy a beírt jelszót, tegye át md5-re, s utána csekkolja le, hogy a két md5, a beírt, és ami az adatbázisban van egyezik e, s ha igen akkor lépjen be.

Ha nem md5, akkor kérlek írd le hogy mi, mármint arra gondolok, hogy előszeretettel használnak még bonyolultabb titkosítást, például nem a pwből alkotja az md5öt, hanem mondjuk username+pw-ből csinál egy md5öt, és loginnál is egybeteszi a beírt usert és a pwt, lekódólja md5be, s úgy csekkolja.

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.16. 09:03 
Offline
Fórum Moderátor
Avatar

Csatlakozott:2014.05.01. 13:18
Hozzászólások:628
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 105 alkalommal
Nem szimpla md5-öt használ, hanem kicsit megkavarja.
De elmagyarázom, hogy szerintem mit is csinál, meg be is másolom a bejelentkezéses php-t.

A lényeg az, hogy van benne egy olyan rész, ami a régen használt kódolási módokat leszedi a jelszóról és ad neki egy újat, ezt úgy kell érteni, hogy teszem azt régen md5-öt meg md5+salt, vagy akármi mást használt, de mostanra az egész rendszert átírták, és hogy senkinek ne legyen kára abból ha felfrissíti weblapját erre akkor ne kelljen újra regisztrálni hanem csak átírja a jelszavakat az új kódolásba a bejelentkezés előtt.
Ez tuti működik, mert mikor cs1.6-os szerveren a regisztrációs rendszerben md5-öt csináltam és megpróbáltam bejelentkezni weben fel dobott, egy ablakot, hogy a jelszó ellenőrzés megváltozott írjam be újra a jelszavam. Mihelyt beírtam megnézem phpmyadmin-ban maga a kódolt jelszó több karakterből állt és 1.6-on sem engedett bejelentkezni.

Bemásolom a kódot, tekerjétek a 262. sorhoz. Ott is van egy érdekes ellenőrzés, amiről fogalmam se nincsen, hogy mit is akar most kezdeni vele.
De a valódi csekkolás a 299. sorban látszik, mikor a lekérdezett jelszó != a beírt, de már átkódolt jelszóval.

SMA Forráskód: [ Mindet kijelol ]
  1. <?php
  2.  
  3. /**
  4.  * Simple Machines Forum (SMF)
  5.  *
  6.  * @package SMF
  7.  * @author Simple Machines http://www.simplemachines.org
  8.  * @copyright 2011 Simple Machines
  9.  *
  10.  * @version 2.0.7
  11.  */
  12.  
  13. if (!defined('SMF'))
  14. die('Hacking attempt...');
  15.  
  16. /* This file is concerned pretty entirely, as you see from its name, with
  17. logging in and out members, and the validation of that. It contains:
  18.  
  19. void Login()
  20. - shows a page for the user to type in their username and password.
  21. - caches the referring URL in $_SESSION['login_url'].
  22. - uses the Login template and language file with the login sub
  23. template.
  24. - if you are using a wireless device, uses the protocol_login sub
  25. template in the Wireless template.
  26. - accessed from ?action=login.
  27.  
  28. void Login2()
  29. - actually logs you in and checks that login was successful.
  30. - employs protection against a specific IP or user trying to brute
  31. force a login to an account.
  32. - on error, uses the same templates Login() uses.
  33. - upgrades password encryption on login, if necessary.
  34. - after successful login, redirects you to $_SESSION['login_url'].
  35. - accessed from ?action=login2, by forms.
  36.  
  37. void Logout(bool internal = false)
  38. - logs the current user out of their account.
  39. - requires that the session hash is sent as well, to prevent automatic
  40. logouts by images or javascript.
  41. - doesn't check the session if internal is true.
  42. - redirects back to $_SESSION['logout_url'], if it exists.
  43. - accessed via ?action=logout;session_var=...
  44.  
  45. string md5_hmac(string data, string key)
  46. - old style SMF 1.0.x/YaBB SE 1.5.x hashing.
  47. - returns the HMAC MD5 of data with key.
  48.  
  49. string phpBB3_password_check(string passwd, string passwd_hash)
  50. - custom encryption for phpBB3 based passwords.
  51.  
  52. void validatePasswordFlood(id_member, password_flood_value = false, was_correct = false)
  53. - this function helps protect against brute force attacks on a member's password.
  54. */
  55.  
  56. // Ask them for their login information.
  57. function Login()
  58. {
  59. global $txt, $context, $scripturl;
  60.  
  61. // In wireless? If so, use the correct sub template.
  62. if (WIRELESS)
  63. $context['sub_template'] = WIRELESS_PROTOCOL . '_login';
  64. // Otherwise, we need to load the Login template/language file.
  65. else
  66. {
  67. loadLanguage('Login');
  68. loadTemplate('Login');
  69. $context['sub_template'] = 'login';
  70. }
  71.  
  72. // Get the template ready.... not really much else to do.
  73. $context['page_title'] = $txt['login'];
  74. $context['default_username'] = &$_REQUEST['u'];
  75. $context['default_password'] = '';
  76. $context['never_expire'] = false;
  77.  
  78. // Add the login chain to the link tree.
  79. $context['linktree'][] = array(
  80. 'url' => $scripturl . '?action=login',
  81. 'name' => $txt['login'],
  82. );
  83.  
  84. // Set the login URL - will be used when the login process is done (but careful not to send us to an attachment).
  85. if (isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
  86. $_SESSION['login_url'] = $_SESSION['old_url'];
  87. else
  88. unset($_SESSION['login_url']);
  89. }
  90.  
  91. // Perform the actual logging-in.
  92. function Login2()
  93. {
  94. global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
  95. global $cookiename, $maintenance, $modSettings, $context, $sc, $sourcedir;
  96.  
  97. // Load cookie authentication stuff.
  98. require_once($sourcedir . '/Subs-Auth.php');
  99.  
  100. if (isset($_GET['sa']) && $_GET['sa'] == 'salt' && !$user_info['is_guest'])
  101. {
  102. if (isset($_COOKIE[$cookiename]) && preg_match('~^a:[34]:\{i:0;(i:\d{1,6}|s:[1-8]:"\d{1,8}");i:1;s:(0|40):"([a-fA-F0-9]{40})?";i:2;[id]:\d{1,14};(i:3;i:\d;)?\}$~', $_COOKIE[$cookiename]) === 1)
  103. list (, , $timeout) = @unserialize($_COOKIE[$cookiename]);
  104. elseif (isset($_SESSION['login_' . $cookiename]))
  105. list (, , $timeout) = @unserialize($_SESSION['login_' . $cookiename]);
  106. else
  107. trigger_error('Login2(): Cannot be logged in without a session or cookie', E_USER_ERROR);
  108.  
  109. $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
  110. updateMemberData($user_info['id'], array('password_salt' => $user_settings['password_salt']));
  111.  
  112. setLoginCookie($timeout - time(), $user_info['id'], sha1($user_settings['passwd'] . $user_settings['password_salt']));
  113.  
  114. redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
  115. }
  116. // Double check the cookie...
  117. elseif (isset($_GET['sa']) && $_GET['sa'] == 'check')
  118. {
  119. // Strike! You're outta there!
  120. if ($_GET['member'] != $user_info['id'])
  121. fatal_lang_error('login_cookie_error', false);
  122.  
  123. // Some whitelisting for login_url...
  124. if (empty($_SESSION['login_url']))
  125. redirectexit();
  126. else
  127. {
  128. // Best not to clutter the session data too much...
  129. $temp = $_SESSION['login_url'];
  130. unset($_SESSION['login_url']);
  131.  
  132. redirectexit($temp);
  133. }
  134. }
  135.  
  136. // Beyond this point you are assumed to be a guest trying to login.
  137. if (!$user_info['is_guest'])
  138. redirectexit();
  139.  
  140. // Are you guessing with a script?
  141. spamProtection('login');
  142.  
  143. // Set the login_url if it's not already set (but careful not to send us to an attachment).
  144. if (empty($_SESSION['login_url']) && isset($_SESSION['old_url']) && strpos($_SESSION['old_url'], 'dlattach') === false && preg_match('~(board|topic)[=,]~', $_SESSION['old_url']) != 0)
  145. $_SESSION['login_url'] = $_SESSION['old_url'];
  146.  
  147. // Been guessing a lot, haven't we?
  148. if (isset($_SESSION['failed_login']) && $_SESSION['failed_login'] >= $modSettings['failed_login_threshold'] * 3)
  149. fatal_lang_error('login_threshold_fail', 'critical');
  150.  
  151. // Set up the cookie length. (if it's invalid, just fall through and use the default.)
  152. if (isset($_POST['cookieneverexp']) || (!empty($_POST['cookielength']) && $_POST['cookielength'] == -1))
  153. $modSettings['cookieTime'] = 3153600;
  154. elseif (!empty($_POST['cookielength']) && ($_POST['cookielength'] >= 1 || $_POST['cookielength'] <= 525600))
  155. $modSettings['cookieTime'] = (int) $_POST['cookielength'];
  156.  
  157. loadLanguage('Login');
  158. // Load the template stuff - wireless or normal.
  159. if (WIRELESS)
  160. $context['sub_template'] = WIRELESS_PROTOCOL . '_login';
  161. else
  162. {
  163. loadTemplate('Login');
  164. $context['sub_template'] = 'login';
  165. }
  166.  
  167. // Set up the default/fallback stuff.
  168. $context['default_username'] = isset($_POST['user']) ? preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($_POST['user'])) : '';
  169. $context['default_password'] = '';
  170. $context['never_expire'] = $modSettings['cookieTime'] == 525600 || $modSettings['cookieTime'] == 3153600;
  171. $context['login_errors'] = array($txt['error_occured']);
  172. $context['page_title'] = $txt['login'];
  173.  
  174. // Add the login chain to the link tree.
  175. $context['linktree'][] = array(
  176. 'url' => $scripturl . '?action=login',
  177. 'name' => $txt['login'],
  178. );
  179.  
  180. if (!empty($_POST['openid_identifier']) && !empty($modSettings['enableOpenID']))
  181. {
  182. require_once($sourcedir . '/Subs-OpenID.php');
  183. if (($open_id = smf_openID_validate($_POST['openid_identifier'])) !== 'no_data')
  184. return $open_id;
  185. }
  186.  
  187. // You forgot to type your username, dummy!
  188. if (!isset($_POST['user']) || $_POST['user'] == '')
  189. {
  190. $context['login_errors'] = array($txt['need_username']);
  191. return;
  192. }
  193.  
  194. // Hmm... maybe 'admin' will login with no password. Uhh... NO!
  195. if ((!isset($_POST['passwrd']) || $_POST['passwrd'] == '') && (!isset($_POST['hash_passwrd']) || strlen($_POST['hash_passwrd']) != 40))
  196. {
  197. $context['login_errors'] = array($txt['no_password']);
  198. return;
  199. }
  200.  
  201. // No funky symbols either.
  202. if (preg_match('~[<>&"\'=\\\]~', preg_replace('~(&#(\\d{1,7}|x[0-9a-fA-F]{1,6});)~', '', $_POST['user'])) != 0)
  203. {
  204. $context['login_errors'] = array($txt['error_invalid_characters_username']);
  205. return;
  206. }
  207.  
  208. // And if it's too long, trim it back.
  209. if ($smcFunc['strlen']($_POST['user']) > 80)
  210. {
  211. $_POST['user'] = $smcFunc['substr']($_POST['user'], 0, 79);
  212. $context['default_username'] = preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', $smcFunc['htmlspecialchars']($_POST['user']));
  213. }
  214.  
  215. // Are we using any sort of integration to validate the login?
  216. if (in_array('retry', call_integration_hook('integrate_validate_login', array($_POST['user'], isset($_POST['hash_passwrd']) && strlen($_POST['hash_passwrd']) == 40 ? $_POST['hash_passwrd'] : null, $modSettings['cookieTime'])), true))
  217. {
  218. $context['login_errors'] = array($txt['login_hash_error']);
  219. $context['disable_login_hashing'] = true;
  220. return;
  221. }
  222.  
  223. // Load the data up!
  224. $request = $smcFunc['db_query']('', '
  225. SELECT passwd, id_member, id_group, lngfile, is_activated, email_address, additional_groups, member_name, password_salt,
  226. openid_uri, passwd_flood
  227. FROM {db_prefix}members
  228. WHERE ' . ($smcFunc['db_case_sensitive'] ? 'LOWER(member_name) = LOWER({string:user_name})' : 'member_name = {string:user_name}') . '
  229. LIMIT 1',
  230. array(
  231. 'user_name' => $smcFunc['db_case_sensitive'] ? strtolower($_POST['user']) : $_POST['user'],
  232. )
  233. );
  234. // Probably mistyped or their email, try it as an email address. (member_name first, though!)
  235. if ($smcFunc['db_num_rows']($request) == 0)
  236. {
  237. $smcFunc['db_free_result']($request);
  238.  
  239. $request = $smcFunc['db_query']('', '
  240. SELECT passwd, id_member, id_group, lngfile, is_activated, email_address, additional_groups, member_name, password_salt, openid_uri,
  241. passwd_flood
  242. FROM {db_prefix}members
  243. WHERE email_address = {string:user_name}
  244. LIMIT 1',
  245. array(
  246. 'user_name' => $_POST['user'],
  247. )
  248. );
  249. // Let them try again, it didn't match anything...
  250. if ($smcFunc['db_num_rows']($request) == 0)
  251. {
  252. $context['login_errors'] = array($txt['username_no_exist']);
  253. return;
  254. }
  255. }
  256.  
  257. $user_settings = $smcFunc['db_fetch_assoc']($request);
  258. $smcFunc['db_free_result']($request);
  259.  
  260. // Figure out the password using SMF's encryption - if what they typed is right.
  261. if (isset($_POST['hash_passwrd']) && strlen($_POST['hash_passwrd']) == 40)
  262. {
  263. // Needs upgrading?
  264. if (strlen($user_settings['passwd']) != 40)
  265. {
  266. $context['login_errors'] = array($txt['login_hash_error']);
  267. $context['disable_login_hashing'] = true;
  268. unset($user_settings);
  269. return;
  270. }
  271. // Challenge passed.
  272. elseif ($_POST['hash_passwrd'] == sha1($user_settings['passwd'] . $sc))
  273. $sha_passwd = $user_settings['passwd'];
  274. else
  275. {
  276. // Don't allow this!
  277. validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood']);
  278.  
  279. $_SESSION['failed_login'] = @$_SESSION['failed_login'] + 1;
  280.  
  281. if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
  282. redirectexit('action=reminder');
  283. else
  284. {
  285. log_error($txt['incorrect_password'] . ' - <span class="remove">' . $user_settings['member_name'] . '</span>', 'user');
  286.  
  287. $context['disable_login_hashing'] = true;
  288. $context['login_errors'] = array($txt['incorrect_password']);
  289. unset($user_settings);
  290. return;
  291. }
  292. }
  293. }
  294. else
  295. $sha_passwd = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
  296.  
  297. // Bad password! Thought you could fool the database?!
  298. if ($user_settings['passwd'] != $sha_passwd)
  299. {
  300. // Let's be cautious, no hacking please. thanx.
  301. validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood']);
  302.  
  303. // Maybe we were too hasty... let's try some other authentication methods.
  304. $other_passwords = array();
  305.  
  306. // None of the below cases will be used most of the time (because the salt is normally set.)
  307. if ($user_settings['password_salt'] == '')
  308. {
  309. // YaBB SE, Discus, MD5 (used a lot), SHA-1 (used some), SMF 1.0.x, IkonBoard, and none at all.
  310. $other_passwords[] = crypt($_POST['passwrd'], substr($_POST['passwrd'], 0, 2));
  311. $other_passwords[] = crypt($_POST['passwrd'], substr($user_settings['passwd'], 0, 2));
  312. $other_passwords[] = md5($_POST['passwrd']);
  313. $other_passwords[] = sha1($_POST['passwrd']);
  314. $other_passwords[] = md5_hmac($_POST['passwrd'], strtolower($user_settings['member_name']));
  315. $other_passwords[] = md5($_POST['passwrd'] . strtolower($user_settings['member_name']));
  316. $other_passwords[] = md5(md5($_POST['passwrd']));
  317. $other_passwords[] = $_POST['passwrd'];
  318.  
  319. // This one is a strange one... MyPHP, crypt() on the MD5 hash.
  320. $other_passwords[] = crypt(md5($_POST['passwrd']), md5($_POST['passwrd']));
  321.  
  322. // Snitz style - SHA-256. Technically, this is a downgrade, but most PHP configurations don't support sha256 anyway.
  323. if (strlen($user_settings['passwd']) == 64 && function_exists('mhash') && defined('MHASH_SHA256'))
  324. $other_passwords[] = bin2hex(mhash(MHASH_SHA256, $_POST['passwrd']));
  325.  
  326. // phpBB3 users new hashing. We now support it as well <!-- s;) --><img src=\"{SMILIES_PATH}/icon_e_wink.gif\" alt=\";)\" title=\"kacsintás\" /><!-- s;) -->.
  327. $other_passwords[] = phpBB3_password_check($_POST['passwrd'], $user_settings['passwd']);
  328.  
  329. // APBoard 2 Login Method.
  330. $other_passwords[] = md5(crypt($_POST['passwrd'], 'CRYPT_MD5'));
  331. }
  332. // The hash should be 40 if it's SHA-1, so we're safe with more here too.
  333. elseif (strlen($user_settings['passwd']) == 32)
  334. {
  335. // vBulletin 3 style hashing? Let's welcome them with open arms \o/.
  336. $other_passwords[] = md5(md5($_POST['passwrd']) . $user_settings['password_salt']);
  337.  
  338. // Hmm.. p'raps it's Invision 2 style?
  339. $other_passwords[] = md5(md5($user_settings['password_salt']) . md5($_POST['passwrd']));
  340.  
  341. // Some common md5 ones.
  342. $other_passwords[] = md5($user_settings['password_salt'] . $_POST['passwrd']);
  343. $other_passwords[] = md5($_POST['passwrd'] . $user_settings['password_salt']);
  344. }
  345. elseif (strlen($user_settings['passwd']) == 40)
  346. {
  347. // Maybe they are using a hash from before the password fix.
  348. $other_passwords[] = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
  349.  
  350. // BurningBoard3 style of hashing.
  351. $other_passwords[] = sha1($user_settings['password_salt'] . sha1($user_settings['password_salt'] . sha1($_POST['passwrd'])));
  352.  
  353. // Perhaps we converted to UTF-8 and have a valid password being hashed differently.
  354. if ($context['character_set'] == 'utf8' && !empty($modSettings['previousCharacterSet']) && $modSettings['previousCharacterSet'] != 'utf8')
  355. {
  356. // Try iconv first, for no particular reason.
  357. if (function_exists('iconv'))
  358. $other_passwords['iconv'] = sha1(strtolower(iconv('UTF-8', $modSettings['previousCharacterSet'], $user_settings['member_name'])) . un_htmlspecialchars(iconv('UTF-8', $modSettings['previousCharacterSet'], $_POST['passwrd'])));
  359.  
  360. // Say it aint so, iconv failed!
  361. if (empty($other_passwords['iconv']) && function_exists('mb_convert_encoding'))
  362. $other_passwords[] = sha1(strtolower(mb_convert_encoding($user_settings['member_name'], 'UTF-8', $modSettings['previousCharacterSet'])) . un_htmlspecialchars(mb_convert_encoding($_POST['passwrd'], 'UTF-8', $modSettings['previousCharacterSet'])));
  363. }
  364. }
  365.  
  366. // SMF's sha1 function can give a funny result on Linux (Not our fault!). If we've now got the real one let the old one be valid!
  367. if (strpos(strtolower(PHP_OS), 'win') !== 0)
  368. {
  369. require_once($sourcedir . '/Subs-Compat.php');
  370. $other_passwords[] = sha1_smf(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));
  371. }
  372.  
  373. // Whichever encryption it was using, let's make it use SMF's now <!-- s;) --><img src=\"{SMILIES_PATH}/icon_e_wink.gif\" alt=\";)\" title=\"kacsintás\" /><!-- s;) -->.
  374. if (in_array($user_settings['passwd'], $other_passwords))
  375. {
  376. $user_settings['passwd'] = $sha_passwd;
  377. $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
  378.  
  379. // Update the password and set up the hash.
  380. updateMemberData($user_settings['id_member'], array('passwd' => $user_settings['passwd'], 'password_salt' => $user_settings['password_salt'], 'passwd_flood' => ''));
  381. }
  382. // Okay, they for sure didn't enter the password!
  383. else
  384. {
  385. // They've messed up again - keep a count to see if they need a hand.
  386. $_SESSION['failed_login'] = @$_SESSION['failed_login'] + 1;
  387.  
  388. // Hmm... don't remember it, do you? Here, try the password reminder <!-- s;) --><img src=\"{SMILIES_PATH}/icon_e_wink.gif\" alt=\";)\" title=\"kacsintás\" /><!-- s;) -->.
  389. if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
  390. redirectexit('action=reminder');
  391. // We'll give you another chance...
  392. else
  393. {
  394. // Log an error so we know that it didn't go well in the error log.
  395. log_error($txt['incorrect_password'] . ' - <span class="remove">' . $user_settings['member_name'] . '</span>', 'user');
  396.  
  397. $context['login_errors'] = array($txt['incorrect_password']);
  398. return;
  399. }
  400. }
  401. }
  402. elseif (!empty($user_settings['passwd_flood']))
  403. {
  404. // Let's be sure they weren't a little hacker.
  405. validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood'], true);
  406.  
  407. // If we got here then we can reset the flood counter.
  408. updateMemberData($user_settings['id_member'], array('passwd_flood' => ''));
  409. }
  410.  
  411. // Correct password, but they've got no salt; fix it!
  412. if ($user_settings['password_salt'] == '')
  413. {
  414. $user_settings['password_salt'] = substr(md5(mt_rand()), 0, 4);
  415. updateMemberData($user_settings['id_member'], array('password_salt' => $user_settings['password_salt']));
  416. }
  417.  
  418. // Check their activation status.
  419. if (!checkActivation())
  420. return;
  421.  
  422. DoLogin();
  423. }
  424.  
  425. function checkActivation()
  426. {
  427. global $context, $txt, $scripturl, $user_settings, $modSettings;
  428.  
  429. if (!isset($context['login_errors']))
  430. $context['login_errors'] = array();
  431.  
  432. // What is the true activation status of this account?
  433. $activation_status = $user_settings['is_activated'] > 10 ? $user_settings['is_activated'] - 10 : $user_settings['is_activated'];
  434.  
  435. // Check if the account is activated - COPPA first...
  436. if ($activation_status == 5)
  437. {
  438. $context['login_errors'][] = $txt['coppa_no_concent'] . ' <a href="' . $scripturl . '?action=coppa;member=' . $user_settings['id_member'] . '">' . $txt['coppa_need_more_details'] . '</a>';
  439. return false;
  440. }
  441. // Awaiting approval still?
  442. elseif ($activation_status == 3)
  443. fatal_lang_error('still_awaiting_approval', 'user');
  444. // Awaiting deletion, changed their mind?
  445. elseif ($activation_status == 4)
  446. {
  447. if (isset($_REQUEST['undelete']))
  448. {
  449. updateMemberData($user_settings['id_member'], array('is_activated' => 1));
  450. updateSettings(array('unapprovedMembers' => ($modSettings['unapprovedMembers'] > 0 ? $modSettings['unapprovedMembers'] - 1 : 0)));
  451. }
  452. else
  453. {
  454. $context['disable_login_hashing'] = true;
  455. $context['login_errors'][] = $txt['awaiting_delete_account'];
  456. $context['login_show_undelete'] = true;
  457. return false;
  458. }
  459. }
  460. // Standard activation?
  461. elseif ($activation_status != 1)
  462. {
  463. log_error($txt['activate_not_completed1'] . ' - <span class="remove">' . $user_settings['member_name'] . '</span>', false);
  464.  
  465. $context['login_errors'][] = $txt['activate_not_completed1'] . ' <a href="' . $scripturl . '?action=activate;sa=resend;u=' . $user_settings['id_member'] . '">' . $txt['activate_not_completed2'] . '</a>';
  466. return false;
  467. }
  468. return true;
  469. }
  470.  
  471. function DoLogin()
  472. {
  473. global $txt, $scripturl, $user_info, $user_settings, $smcFunc;
  474. global $cookiename, $maintenance, $modSettings, $context, $sourcedir;
  475.  
  476. // Load cookie authentication stuff.
  477. require_once($sourcedir . '/Subs-Auth.php');
  478.  
  479. // Call login integration functions.
  480. call_integration_hook('integrate_login', array($user_settings['member_name'], isset($_POST['hash_passwrd']) && strlen($_POST['hash_passwrd']) == 40 ? $_POST['hash_passwrd'] : null, $modSettings['cookieTime']));
  481.  
  482. // Get ready to set the cookie...
  483. $username = $user_settings['member_name'];
  484. $user_info['id'] = $user_settings['id_member'];
  485.  
  486. // Bam! Cookie set. A session too, just in case.
  487. setLoginCookie(60 * $modSettings['cookieTime'], $user_settings['id_member'], sha1($user_settings['passwd'] . $user_settings['password_salt']));
  488.  
  489. // Reset the login threshold.
  490. if (isset($_SESSION['failed_login']))
  491. unset($_SESSION['failed_login']);
  492.  
  493. $user_info['is_guest'] = false;
  494. $user_settings['additional_groups'] = explode(',', $user_settings['additional_groups']);
  495. $user_info['is_admin'] = $user_settings['id_group'] == 1 || in_array(1, $user_settings['additional_groups']);
  496.  
  497. // Are you banned?
  498. is_not_banned(true);
  499.  
  500. // An administrator, set up the login so they don't have to type it again.
  501. if ($user_info['is_admin'] && isset($user_settings['openid_uri']) && empty($user_settings['openid_uri']))
  502. {
  503. $_SESSION['admin_time'] = time();
  504. unset($_SESSION['just_registered']);
  505. }
  506.  
  507. // Don't stick the language or theme after this point.
  508. unset($_SESSION['language'], $_SESSION['id_theme']);
  509.  
  510. // First login?
  511. $request = $smcFunc['db_query']('', '
  512. SELECT last_login
  513. FROM {db_prefix}members
  514. WHERE id_member = {int:id_member}
  515. AND last_login = 0',
  516. array(
  517. 'id_member' => $user_info['id'],
  518. )
  519. );
  520. if ($smcFunc['db_num_rows']($request) == 1)
  521. $_SESSION['first_login'] = true;
  522. else
  523. unset($_SESSION['first_login']);
  524. $smcFunc['db_free_result']($request);
  525.  
  526. // You've logged in, haven't you?
  527. updateMemberData($user_info['id'], array('last_login' => time(), 'member_ip' => $user_info['ip'], 'member_ip2' => $_SERVER['BAN_CHECK_IP']));
  528.  
  529. // Get rid of the online entry for that old guest....
  530. $smcFunc['db_query']('', '
  531. DELETE FROM {db_prefix}log_online
  532. WHERE session = {string:session}',
  533. array(
  534. 'session' => 'ip' . $user_info['ip'],
  535. )
  536. );
  537. $_SESSION['log_time'] = 0;
  538.  
  539. // Just log you back out if it's in maintenance mode and you AREN'T an admin.
  540. if (empty($maintenance) || allowedTo('admin_forum'))
  541. redirectexit('action=login2;sa=check;member=' . $user_info['id'], $context['server']['needs_login_fix']);
  542. else
  543. redirectexit('action=logout;' . $context['session_var'] . '=' . $context['session_id'], $context['server']['needs_login_fix']);
  544. }
  545.  
  546. // Log the user out.
  547. function Logout($internal = false, $redirect = true)
  548. {
  549. global $sourcedir, $user_info, $user_settings, $context, $modSettings, $smcFunc;
  550.  
  551. // Make sure they aren't being auto-logged out.
  552. if (!$internal)
  553. checkSession('get');
  554.  
  555. require_once($sourcedir . '/Subs-Auth.php');
  556.  
  557. if (isset($_SESSION['pack_ftp']))
  558. $_SESSION['pack_ftp'] = null;
  559.  
  560. // They cannot be open ID verified any longer.
  561. if (isset($_SESSION['openid']))
  562. unset($_SESSION['openid']);
  563.  
  564. // It won't be first login anymore.
  565. unset($_SESSION['first_login']);
  566.  
  567. // Just ensure they aren't a guest!
  568. if (!$user_info['is_guest'])
  569. {
  570. // Pass the logout information to integrations.
  571. call_integration_hook('integrate_logout', array($user_settings['member_name']));
  572.  
  573. // If you log out, you aren't online anymore <!-- s:P --><img src=\"{SMILIES_PATH}/icon_razz.gif\" alt=\":P\" title=\"vicces\" /><!-- s:P -->.
  574. $smcFunc['db_query']('', '
  575. DELETE FROM {db_prefix}log_online
  576. WHERE id_member = {int:current_member}',
  577. array(
  578. 'current_member' => $user_info['id'],
  579. )
  580. );
  581. }
  582.  
  583. $_SESSION['log_time'] = 0;
  584.  
  585. // Empty the cookie! (set it in the past, and for id_member = 0)
  586. setLoginCookie(-3600, 0);
  587.  
  588. // And some other housekeeping while we're at it.
  589. session_destroy();
  590. if (!empty($user_info['id']))
  591. updateMemberData($user_info['id'], array('password_salt' => substr(md5(mt_rand()), 0, 4)));
  592.  
  593. // Off to the merry board index we go!
  594. if ($redirect)
  595. {
  596. if (empty($_SESSION['logout_url']))
  597. redirectexit('', $context['server']['needs_login_fix']);
  598. else
  599. {
  600. $temp = $_SESSION['logout_url'];
  601. unset($_SESSION['logout_url']);
  602.  
  603. redirectexit($temp, $context['server']['needs_login_fix']);
  604. }
  605. }
  606. }
  607.  
  608. // MD5 Encryption used for older passwords.
  609. function md5_hmac($data, $key)
  610. {
  611. $key = str_pad(strlen($key) <= 64 ? $key : pack('H*', md5($key)), 64, chr(0x00));
  612. return md5(($key ^ str_repeat(chr(0x5c), 64)) . pack('H*', md5(($key ^ str_repeat(chr(0x36), 64)) . $data)));
  613. }
  614.  
  615. // Special encryption used by phpBB3.
  616. function phpBB3_password_check($passwd, $passwd_hash)
  617. {
  618. // Too long or too short?
  619. if (strlen($passwd_hash) != 34)
  620. return;
  621.  
  622. // Range of characters allowed.
  623. $range = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
  624.  
  625. // Tests
  626. $strpos = strpos($range, $passwd_hash[3]);
  627. $count = 1 << $strpos;
  628. $count2 = $count;
  629. $salt = substr($passwd_hash, 4, 8);
  630.  
  631. // Things are done differently for PHP 5.
  632. if (@version_compare(PHP_VERSION, '5') >= 0)
  633. {
  634. $hash = md5($salt . $passwd, true);
  635. for (; $count != 0; --$count)
  636. $hash = md5($hash . $passwd, true);
  637. }
  638. else
  639. {
  640. $hash = pack('H*', md5($salt . $passwd));
  641. for (; $count != 0; --$count)
  642. $hash = pack('H*', md5($hash . $passwd));
  643. }
  644.  
  645. $output = substr($passwd_hash, 0, 12);
  646. $i = 0;
  647. while ($i < 16)
  648. {
  649. $value = ord($hash[$i++]);
  650. $output .= $range[$value & 0x3f];
  651.  
  652. if ($i < 16)
  653. $value |= ord($hash[$i]) << 8;
  654.  
  655. $output .= $range[($value >> 6) & 0x3f];
  656.  
  657. if ($i++ >= 16)
  658. break;
  659.  
  660. if ($i < 16)
  661. $value |= ord($hash[$i]) << 16;
  662.  
  663. $output .= $range[($value >> 12) & 0x3f];
  664.  
  665. if ($i++ >= 16)
  666. break;
  667.  
  668. $output .= $range[($value >> 18) & 0x3f];
  669. }
  670.  
  671. // Return now.
  672. return $output;
  673. }
  674.  
  675. // This protects against brute force attacks on a member's password. Importantly even if the password was right we DON'T TELL THEM!
  676. function validatePasswordFlood($id_member, $password_flood_value = false, $was_correct = false)
  677. {
  678. global $smcFunc, $cookiename, $sourcedir;
  679.  
  680. // As this is only brute protection, we allow 5 attempts every 10 seconds.
  681.  
  682. // Destroy any session or cookie data about this member, as they validated wrong.
  683. require_once($sourcedir . '/Subs-Auth.php');
  684. setLoginCookie(-3600, 0);
  685.  
  686. if (isset($_SESSION['login_' . $cookiename]))
  687. unset($_SESSION['login_' . $cookiename]);
  688.  
  689. // We need a member!
  690. if (!$id_member)
  691. {
  692. // Redirect back!
  693. redirectexit();
  694.  
  695. // Probably not needed, but still make sure...
  696. fatal_lang_error('no_access', false);
  697. }
  698.  
  699. // Right, have we got a flood value?
  700. if ($password_flood_value !== false)
  701. @list ($time_stamp, $number_tries) = explode('|', $password_flood_value);
  702.  
  703. // Timestamp or number of tries invalid?
  704. if (empty($number_tries) || empty($time_stamp))
  705. {
  706. $number_tries = 0;
  707. $time_stamp = time();
  708. }
  709.  
  710. // They've failed logging in already
  711. if (!empty($number_tries))
  712. {
  713. // Give them less chances if they failed before
  714. $number_tries = $time_stamp < time() - 20 ? 2 : $number_tries;
  715.  
  716. // They are trying too fast, make them wait longer
  717. if ($time_stamp < time() - 10)
  718. $time_stamp = time();
  719. }
  720.  
  721. $number_tries++;
  722.  
  723. // Broken the law?
  724. if ($number_tries > 5)
  725. fatal_lang_error('login_threshold_brute_fail', 'critical');
  726.  
  727. // Otherwise set the members data. If they correct on their first attempt then we actually clear it, otherwise we set it!
  728. updateMemberData($id_member, array('passwd_flood' => $was_correct && $number_tries == 1 ? '' : $time_stamp . '|' . $number_tries));
  729.  
  730. }
  731.  
  732. ?>


Nekem csak az md5 kódolást kellene ellenőriznie, és nem kellene, hogy frissítse az új kódolásra.


A hozzászólást 1 alkalommal szerkesztették, utoljára kiki 2015.07.16. 09:09-kor.
átttettem smara, látszódjon a sorszám


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.16. 09:22 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Hát, ami itt történik:

$sha_passwd = sha1(strtolower($user_settings['member_name']) . un_htmlspecialchars($_POST['passwrd']));

A $sha_passwd értéke egy sha1 kód lesz, amit az usernévből, (kisbetűkből), illetve a beírt jelszóból generál, majd ezt a váltózót nézi meg az adatbázisban találhatóval.


De van benne még egy két érdekes dolog számomra, htmlt tudsz mutatni, ami ehez a fájlhoz tartozik?

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.16. 09:48 
Offline
Fórum Moderátor
Avatar

Csatlakozott:2014.05.01. 13:18
Hozzászólások:628
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 105 alkalommal
Most mire gondolsz? html-en? Egy oldal kell ahová felraktam, vagy vagy még olyan hogy az oldal témája, ami viszont nem html, hanem szint úgy php.

Ha ezekre gondolsz akkor tessék egy web: http://www.bbcsystem.16mb.com

Ez pedig a téma:
Kód:
<?php
/**
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines
 * @copyright 2011 Simple Machines
 * @license http://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.0
 */

// This is just the basic "login" form.
function template_login()
{
   global $context, $settings, $options, $scripturl, $modSettings, $txt;

   echo '
      <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>

      <form action="', $scripturl, '?action=login2" name="frmLogin" id="frmLogin" method="post" accept-charset="', $context['character_set'], '" ', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
      <div class="tborder login">
         <div class="cat_bar">
            <h3 class="catbg">
               <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/login_sm.gif" alt="" class="icon" /> ', $txt['login'], '</span>
            </h3>
         </div>
         <span class="upperframe"><span></span></span>
         <div class="roundframe"><br class="clear" />';

   // Did they make a mistake last time?
   if (!empty($context['login_errors']))
      foreach ($context['login_errors'] as $error)
         echo '
            <p class="error">', $error, '</p>';

   // Or perhaps there's some special description for this time?
   if (isset($context['description']))
      echo '
            <p class="description">', $context['description'], '</p>';

   // Now just get the basic information - username, password, etc.
   echo '
            <dl>
               <dt>', $txt['username'], ':</dt>
               <dd><input type="text" name="user" size="20" value="', $context['default_username'], '" class="input_text" /></dd>
               <dt>', $txt['password'], ':</dt>
               <dd><input type="password" name="passwrd" value="', $context['default_password'], '" size="20" class="input_password" /></dd>
            </dl>';

   if (!empty($modSettings['enableOpenID']))
      echo '<p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
            <dl>
               <dt>', $txt['openid'], ':</dt>
               <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17" />&nbsp;<em><a href="', $scripturl, '?action=helpadmin;help=register_openid" onclick="return reqWin(this.href);" class="help">(?)</a></em></dd>
            </dl><hr />';

   echo '
            <dl>
               <dt>', $txt['mins_logged_in'], ':</dt>
               <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '"', $context['never_expire'] ? ' disabled="disabled"' : '', ' class="input_text" /></dd>
               <dt>', $txt['always_logged_in'], ':</dt>
               <dd><input type="checkbox" name="cookieneverexp"', $context['never_expire'] ? ' checked="checked"' : '', ' class="input_check" onclick="this.form.cookielength.disabled = this.checked;" /></dd>';
   // If they have deleted their account, give them a chance to change their mind.
   if (isset($context['login_show_undelete']))
      echo '
               <dt class="alert">', $txt['undelete_account'], ':</dt>
               <dd><input type="checkbox" name="undelete" class="input_check" /></dd>';
   echo '
            </dl>
            <p><input type="submit" value="', $txt['login'], '" class="button_submit" /></p>
            <p class="smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
            <input type="hidden" name="hash_passwrd" value="" />
         </div>
         <span class="lowerframe"><span></span></span>
      </div></form>';

   // Focus on the correct input - username or password.
   echo '
      <script type="text/javascript"><!-- // --><![CDATA[
         document.forms.frmLogin.', isset($context['default_username']) && $context['default_username'] != '' ? 'passwrd' : 'user', '.focus();
      // ]]></script>';
}

// Tell a guest to get lost or login!
function template_kick_guest()
{
   global $context, $settings, $options, $scripturl, $modSettings, $txt;

   // This isn't that much... just like normal login but with a message at the top.
   echo '
   <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
   <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" name="frmLogin" id="frmLogin"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
      <div class="tborder login">
         <div class="cat_bar">
            <h3 class="catbg">', $txt['warning'], '</h3>
         </div>';

   // Show the message or default message.
   echo '
         <p class="information centertext">
            ', empty($context['kick_message']) ? $txt['only_members_can_access'] : $context['kick_message'], '<br />
            ', $txt['login_below'], ' <a href="', $scripturl, '?action=register">', $txt['register_an_account'], '</a> ', sprintf($txt['login_with_forum'], $context['forum_name_html_safe']), '
         </p>';

   // And now the login information.
   echo '
         <div class="cat_bar">
            <h3 class="catbg">
               <img src="', $settings['images_url'], '/icons/login_sm.gif" alt="" class="icon" /> ', $txt['login'], '
            </h3>
         </div>
         <span class="upperframe"><span></span></span>
         <div class="roundframe">
            <dl>
               <dt>', $txt['username'], ':</dt>
               <dd><input type="text" name="user" size="20" class="input_text" /></dd>
               <dt>', $txt['password'], ':</dt>
               <dd><input type="password" name="passwrd" size="20" class="input_password" /></dd>';

   if (!empty($modSettings['enableOpenID']))
      echo '
            </dl>
            <p><strong>&mdash;', $txt['or'], '&mdash;</strong></p>
            <dl>
               <dt>', $txt['openid'], ':</dt>
               <dd><input type="text" name="openid_identifier" class="input_text openid_login" size="17" /></dd>
            </dl>
            <hr />
            <dl>';

   echo '
               <dt>', $txt['mins_logged_in'], ':</dt>
               <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text" /></dd>
               <dt>', $txt['always_logged_in'], ':</dt>
               <dd><input type="checkbox" name="cookieneverexp" class="input_check" onclick="this.form.cookielength.disabled = this.checked;" /></dd>
            </dl>
            <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit" /></p>
            <p class="centertext smalltext"><a href="', $scripturl, '?action=reminder">', $txt['forgot_your_password'], '</a></p>
         </div>
         <span class="lowerframe"><span></span></span>
         <input type="hidden" name="hash_passwrd" value="" />
      </div>
   </form>';

   // Do the focus thing...
   echo '
      <script type="text/javascript"><!-- // --><![CDATA[
         document.forms.frmLogin.user.focus();
      // ]]></script>';
}

// This is for maintenance mode.
function template_maintenance()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   // Display the administrator's message at the top.
   echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>
<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
   <div class="tborder login" id="maintenance_mode">
      <div class="cat_bar">
         <h3 class="catbg">', $context['title'], '</h3>
      </div>
      <p class="description">
         <img class="floatleft" src="', $settings['images_url'], '/construction.png" width="40" height="40" alt="', $txt['in_maintain_mode'], '" />
         ', $context['description'], '<br class="clear" />
      </p>
      <div class="title_bar">
         <h4 class="titlebg">', $txt['admin_login'], '</h4>
      </div>
      <span class="upperframe"><span></span></span>
      <div class="roundframe">
         <dl>
            <dt>', $txt['username'], ':</dt>
            <dd><input type="text" name="user" size="20" class="input_text" /></dd>
            <dt>', $txt['password'], ':</dt>
            <dd><input type="password" name="passwrd" size="20" class="input_password" /></dd>
            <dt>', $txt['mins_logged_in'], ':</dt>
            <dd><input type="text" name="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" class="input_text" /></dd>
            <dt>', $txt['always_logged_in'], ':</dt>
            <dd><input type="checkbox" name="cookieneverexp" class="input_check" /></dd>
         </dl>
         <p class="centertext"><input type="submit" value="', $txt['login'], '" class="button_submit" /></p>
      </div>
      <span class="lowerframe"><span></span></span>
      <input type="hidden" name="hash_passwrd" value="" />
   </div>
</form>';
}

// This is for the security stuff - makes administrators login every so often.
function template_admin_login()
{
   global $context, $settings, $options, $scripturl, $txt;

   // Since this should redirect to whatever they were doing, send all the get data.
   echo '
<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/sha1.js"></script>

<form action="', $scripturl, $context['get_data'], '" method="post" accept-charset="', $context['character_set'], '" name="frmLogin" id="frmLogin" onsubmit="hashAdminPassword(this, \'', $context['user']['username'], '\', \'', $context['session_id'], '\');">
   <div class="tborder login" id="admin_login">
      <div class="cat_bar">
         <h3 class="catbg">
            <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/login_sm.gif" alt="" class="icon" /> ', $txt['login'], '</span>
         </h3>
      </div>
      <span class="upperframe"><span></span></span>
      <div class="roundframe centertext">';

   if (!empty($context['incorrect_password']))
      echo '
         <div class="error">', $txt['admin_incorrect_password'], '</div>';

   echo '
         <strong>', $txt['password'], ':</strong>
         <input type="password" name="admin_pass" size="24" class="input_password" />
         <a href="', $scripturl, '?action=helpadmin;help=securityDisable_why" onclick="return reqWin(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics.gif" alt="', $txt['help'], '" /></a><br />
         <input type="submit" style="margin-top: 1em;" value="', $txt['login'], '" class="button_submit" />';

   // Make sure to output all the old post data.
   echo $context['post_data'], '
      </div>
      <span class="lowerframe"><span></span></span>
   </div>
   <input type="hidden" name="admin_hash_pass" value="" />
</form>';

   // Focus on the password box.
   echo '
<script type="text/javascript"><!-- // --><![CDATA[
   document.forms.frmLogin.admin_pass.focus();
// ]]></script>';
}

// Activate your account manually?
function template_retry_activate()
{
   global $context, $settings, $options, $txt, $scripturl;

   // Just ask them for their code so they can try it again...
   echo '
      <form action="', $scripturl, '?action=activate;u=', $context['member_id'], '" method="post" accept-charset="', $context['character_set'], '">
         <div class="title_bar">
            <h3 class="titlebg">', $context['page_title'], '</h3>
         </div>
         <span class="upperframe"><span></span></span>
         <div class="roundframe">';

   // You didn't even have an ID?
   if (empty($context['member_id']))
      echo '
            <dl>
               <dt>', $txt['invalid_activation_username'], ':</dt>
               <dd><input type="text" name="user" size="30" class="input_text" /></dd>';

   echo '
               <dt>', $txt['invalid_activation_retry'], ':</dt>
               <dd><input type="text" name="code" size="30" class="input_text" /></dd>
            </dl>
            <p><input type="submit" value="', $txt['invalid_activation_submit'], '" class="button_submit" /></p>
         </div>
         <span class="lowerframe"><span></span></span>
      </form>';
}

// Activate your account manually?
function template_resend()
{
   global $context, $settings, $options, $txt, $scripturl;

   // Just ask them for their code so they can try it again...
   echo '
      <form action="', $scripturl, '?action=activate;sa=resend" method="post" accept-charset="', $context['character_set'], '">
         <div class="title_bar">
            <h3 class="titlebg">', $context['page_title'], '</h3>
         </div>
         <span class="upperframe"><span></span></span>
         <div class="roundframe">
            <dl>
               <dt>', $txt['invalid_activation_username'], ':</dt>
               <dd><input type="text" name="user" size="40" value="', $context['default_username'], '" class="input_text" /></dd>
            </dl>
            <p>', $txt['invalid_activation_new'], '</p>
            <dl>
               <dt>', $txt['invalid_activation_new_email'], ':</dt>
               <dd><input type="text" name="new_email" size="40" class="input_text" /></dd>
               <dt>', $txt['invalid_activation_password'], ':</dt>
               <dd><input type="password" name="passwd" size="30" class="input_password" /></dd>
            </dl>';

   if ($context['can_activate'])
      echo '
            <p>', $txt['invalid_activation_known'], '</p>
            <dl>
               <dt>', $txt['invalid_activation_retry'], ':</dt>
               <dd><input type="text" name="code" size="30" class="input_text" /></dd>
            </dl>';

   echo '
            <p><input type="submit" value="', $txt['invalid_activation_resend'], '" class="button_submit" /></p>
         </div>
         <span class="lowerframe"><span></span></span>
      </form>';
}

?>


Habár nem tudom hogy ezek közül kell-e valamelyik.
Ugye a 296. sorban lévő részt nem elég átírni az előtte lévőkkel is kezdeni kell valamit, mert ha nem sha1 a jelszó az adatbázisban, akkor át akarja majd alakítani arra.


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.16. 10:20 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Bonyolultak az ilyen rendszerek, átlehet írni ezt is, de szerintem sokkal egyszerűbb, ha magad csinálsz egy weboldalt ilyen célra. És ez még csak a login, a regisztrációt is átkellene ahoz írni.

Igen, érdekes hogy itt a téma is phpba van.

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.18. 10:05 
Offline
Fórum Moderátor
Avatar

Csatlakozott:2014.05.01. 13:18
Hozzászólások:628
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 105 alkalommal
Valakinek biztosan egyszerűbb lenne egy sajátot készíteni, de ez nekem azért lenne megfelelő mert könnyen tudnám kezelni. Ugyebár ha megnézted az oldalt amit küldtem ott már láthattad, hogy mennyire ki van dolgozva.
Az az érdekes, hogy ezt a részt leblokkoltam:
SMA Forráskód: [ Mindet kijelol ]
  1. if (isset($_POST['hash_passwrd']) && strlen($_POST['hash_passwrd']) == 40)
  2. {
  3. // Needs upgrading?
  4. if (strlen($user_settings['passwd']) != 40)
  5. {
  6. $context['login_errors'] = array($txt['login_hash_error']);
  7. $context['disable_login_hashing'] = true;
  8. unset($user_settings);
  9. return;
  10. }
  11. // Challenge passed.
  12. elseif ($_POST['hash_passwrd'] == sha1($user_settings['passwd'] . $sc))
  13. $sha_passwd = $user_settings['passwd'];
  14. else
  15. {
  16. // Don't allow this!
  17. validatePasswordFlood($user_settings['id_member'], $user_settings['passwd_flood']);
  18.  
  19. $_SESSION['failed_login'] = @$_SESSION['failed_login'] + 1;
  20.  
  21. if ($_SESSION['failed_login'] >= $modSettings['failed_login_threshold'])
  22. redirectexit('action=reminder');
  23. else
  24. {
  25. log_error($txt['incorrect_password'] . ' - <span class="remove">' . $user_settings['member_name'] . '</span>', 'user');
  26.  
  27. $context['disable_login_hashing'] = true;
  28. $context['login_errors'] = array($txt['incorrect_password']);
  29. unset($user_settings);
  30. return;
  31. }
  32. }
  33. }
  34. else


És csak ennyi maradt:
SMA Forráskód: [ Mindet kijelol ]
  1. $sha_passwd = $_POST['passwrd'];


De, valamiért Hibás Jelszót jelez, pedig ha fejben lepróbáljuk vezetni elvileg jónak kellene lenni, habár nem értek ehhez a php-hoz azt gondoltam, hogy így jónak kellene lennie.

Ötleted nincs, hogy mi lehet még?


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.22. 07:10 
Offline
Fórum Moderátor
Avatar

Csatlakozott:2014.05.01. 13:18
Hozzászólások:628
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 105 alkalommal
Visszatérve, hogy már ne nyissak új témát.
Észrevettem egy olyat, hogy az állítólagos beírt jelszót nem tudom megjeleníteni.

$_POST['passwrd'] elvileg azért nem tudom összehasonlítani e lekérdezettel, mert ezt üresnek jelzi.
És akkor itt jön a kérdés. Ha ez üres, akkor a sha1-et hogy csinálja belőle?


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.22. 10:15 
Offline
Developer
Avatar

Csatlakozott:2011.06.01. 21:11
Hozzászólások:7966
Megköszönt másnak: 295 alkalommal
Megköszönték neki: 537 alkalommal
Előző elötti hszre a válasz:

$sha_passwd = $_POST['passwrd'];

itt a változóba sha kódólásba kéne betenni, de az $_POST['passwrd']; simán kódólás nélkül van.

Előzőre: elvileg nem lehet üres, ha kitöltöd.


Nos akkor kezdjük előről, mit szeretnél elérni? Steamed van?

_________________
http://www.easyrankup.eu


Hozzászólás jelentése
Vissza a tetejére
   
 Hozzászólás témája: Re: SHA1
HozzászólásElküldve:2015.07.23. 23:02 
Offline
Fórum Moderátor
Avatar

Csatlakozott:2014.05.01. 13:18
Hozzászólások:628
Megköszönt másnak: 61 alkalommal
Megköszönték neki: 105 alkalommal
Elküldtem Pm-ben, amúgy ez tényleg érdekes, mert most úgy próbáltam megoldani, hogy a begépelt jelszót bejelentkezés illetve regisztráció esetén feltöltetem vele egy új oszlopba és akkor azt már kódolás nélkül. Így meg lesz a SHA1 a weblaphoz illetve a sima, kód nélküli a szerverhez.

Ám, de jelentkezett egy hiba, ami meg magyarázta, hogy miért nem volt jó az előzőkben, amikor simán a begépelt kódot akarta összevetetni a lekérdezettel, a lényeg az, hogy mind két esetben a begépelt mezű üres. Erre akkor jöttem rá, amikor fel akartam tölteni vele és láttam hogy semmit írt a mezőbe. A feltöltés tuti sikeres volt, ezt meg abból tudom, hogy utána próbáltam egy 'asd352as42' szöveget feltölteni vele és azt engedte. Ha nem lenne érthető, a feltöltéskor nem a $POST... ot adtam meg hanem 'azt a szöveget'.


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése: Rendezés 
Új téma nyitása Hozzászólás a témához  [19 hozzászólás ]  OldalElőző12


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 17 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole