最近略微有点无聊,记事狗的东东还有以后我发文章的规范

2013-01-11 17:42:00 35 6912


今天下午突然觉得没神马好的资料学习了所以就略微说一下
php代码审计我知道很多人都在玩,所以写一个略微吐槽的东西
RIPS Notepad++ 插件 和 xdebug 还有那个Code V4 And more php黑盒
想必都是现在 进阶或入门阶段的主流工具
而现在直接利用的基本很少了 很多都是隐藏较深的二阶利用
表面上首先会用静态软件扫所有的代码 但是那些引擎非常有局限性 V4的还好但是免费版限制1w行代码 然后丢到黑盒里面去Fuzz  dbbug(bug库) 大量的去Fuzz POST GET HEAD 最后去看错误日志
上面的就是不那么重要的一个小过程时间大概10分钟配置就可以自己完成剩下过程
正式进入分析阶段了首先是funtion 文件结构 调用方式
Funton 我认为是分析阶段的基础 花点时间 然后回溯回去是十分有效的一种挖掘方式
一般比较短技巧就是可以用 V4
PHP中一般会减少变量的数量 但是传参过程难免出现问题但是从代码上并不能直观的发现所以需要配合xdebug
这时候 Notepad++ 插件 配合 xdebug 设置断点 观察变量具体出现了什么变化 然后依照这种变化回溯传递过程个个函数做了什么
之所以叫二阶 是因为 传入 储存 触发 输出 的过程中第一阶段无法达到目的但是在后面的阶段发生了问题程序员也未必能注意到 效率就是直观 和细致的了解
即使不debug 也可以使用变量输出函数。

然后是我以后规范 首先代码审计的研究学习过程也就是分析过程 我是不收费的不加密欢迎交流 但不会明确表示怎么利用 这部分转载 版权我打算给T00ls
我不在乎个人 我打算一一个群体的方式出现 比较php比较火了 也符合白帽子的规范
但是另外一部分 我觉得要有自己的灵魂 利用方面 为了不转载不扩散 同时实现自己自由的原则 加密+设置购买 可以也可以使用各种方式来取得exp
不知道t00ls怎么想毕竟我觉得还是需要大家的赞同

然后这里是例子 渣渣0day 原创的 不愿意看代码的直接翻到底部

记事狗 3.6.6 xss 0day
=======================================================
/modules/pm.mod.php
========================++2013/1/9/10:00++>
Funtion

filter()


function filter(&$string, $verify=1, $replace=1,$shield=0)  
{  
         static $filter = null;  
   
         $rets = array();  
   
                 $string=trim($string);  
         if($string) {  
                 if(false!==strpos($string,'<')) {  
                         $string=strip_selected_tags($string,"<script><iframe><style><link><meta>");  
                         $string=remove_xss($string);  
                 }  
   
                 if($filter===null) {  
                         $filter = (array) ConfigHandler::get('filter');  
                 }  
   
                 if(!$filter['enable']) {  
                         return false;  
                 }  
   
                                 if($replace && $filter['replace_list'])  
                 {  
                         foreach($filter['replace_list'] as $search=>$replace)  
                         {  
                                 $strpos = jstrpos($string, $search);  
   
                                 if($strpos!==false)  
                                 {  
                                         $string = str_replace($search, $replace, $string);  
                                 }  
                         }  
                 }  
   
                                 if(!empty($filter['keywords']))  
                 {  
                         if($filter['keyword_list']===null)  
                         {  
                                 $filter['keyword_list'] =  explode("|",str_replace(array("\r\n","\r","\n","\t","\\|"),"|",trim($filter['keywords'])));  
                         }  
   
                         foreach ($filter['keyword_list'] as $keyword)  
                         {  
                                 $strpos = jstrpos($string, $keyword);  
   
                                 if($strpos!==false)  
                                 {  
                                         $rets['error'] = 1;  
                                         $rets['type'] = 'filter';  
                                         $rets['keyword'] = $keyword;  
                                         $rets['msg'] = .($filter['keyword_disable'] ? "" : " {$keyword} ").;  
   
                                         return $rets;  
                                 }  
                         }  
                 }  
   
                                 if($verify && $filter['verify_list'])  
                 {  
                         foreach($filter['verify_list'] as $keyword)  
                         {  
                                 $strpos = jstrpos($string, $keyword);  
   
                                 if($strpos!==false)  
                                 {  
                                         $rets['verify'] = 1;  
                                         $rets['type'] = 'verify';  
                                         $rets['keyword'] = $keyword;  
                                         $rets['msg'] = .($filter['keyword_disable'] ? "" : " {$keyword} ")..MEMBER_ID.;  
   
                                         return $rets;  
                                 }  
                         }  
                 }  
   
                 if($shield && $shield!=0 && $filter['shield_list']){  
                         foreach($filter['shield_list'] as $keyword)  
                         {  
                                 $strpos = jstrpos($string, $keyword);  
   
                                 if($strpos!==false)  
                                 {  
                                         $rets['shield'] = 1;  
                                         $rets['type'] = 'shield';  
                                         $rets['keyword'] = $keyword;  
                                         $rets['msg'] = .($filter['keyword_disable'] ? "" : " {$keyword} ");  
   
                                         return $rets;  
                                 }  
                         }  
                 }  
         }  
   
         return false;  
}  
==================================
function sendAgain(){
                $pmid = (int) $this->Get['pmid'];
                $pm_list = array();
                $query = $this->DatabaseHandler->Query("select * FROM ".TABLE_PREFIX."pms WHERE pmid = '$pmid'");
                $pm_list = $query->GetRow();
                if($pm_list){
                        $this->DatabaseHandler->Query("delete from ".TABLE_PREFIX."pms where pmid = '$pmid' ");
                        $this->Post['to_user'] = $pm_list['tonickname'];
                        $this->Post['message'] = $pm_list['message'];
                       
                        $this->DoSend('outbox');
                }else{
                        $this->Messager("私信不存在或已删除");
                }
        }
==============================================
   
F:\PHPnow-1.5.6\htdocs\jsg\include\logic
======================================
function pmSend($post,$suid=MEMBER_ID,$susername=MEMBER_NAME,$snickname=MEMBER_NICKNAME){  
                 if($suid == MEMBER_ID) {  
                                                 $MemberHandler = & Obj::registry('MemberHandler');  
                         if($MemberHandler && $MemberHandler->HasPermission('pm','send')==false) {  
                                 return 6;  
                         }  
                 }  
                  
                 $this->noticeConfig = ConfigHandler::get('email_notice');  
                 $to_user_list=array();  
                 $f_rets = filter($post['message']);  
                 if($f_rets)  
                 {  
                         if($f_rets['error'])  
                         {  
                                 return $f_rets['msg'];  
                         }  
                 }  
                 $post['subject']=htmlspecialchars(trim($post['subject']));  
                 if($post['message']=='')  
                 {  
                         return 1;  
                 }  
                 if ($post['buddy_list']==false && $post['to_user']=="")  
                 {  
                         return 2;  
                 }  
   
                 if(trim($post['to_user'])!='')  
                 {  
   
                         $in=$this->DatabaseHandler->BuildIn($post['to_user'],"nickname");  
                                                 $sql="
                         SELECT  
                                 uid,username,nickname,notice_pm,email,newpm  
                         FROM  
                                 ".TABLE_PREFIX.'members'."  
                         WHERE  
                                 $in";
                         $query = $this->DatabaseHandler->Query($sql);  
   
                         while($row=$query->GetRow())  
                         {  
                                                                 if($suid == MEMBER_ID){  
                                         if(is_blacklist($suid,$row['uid'])){  
                                                 return .$row['nickname'].;  
                                         }  
                                 }  
                                                                 $rets = jsg_role_check_allow('sendpm', $row['uid'], $suid);  
                                 if($rets && $rets['error']) {  
                                         return $rets['error'];  
                                 } else {  
                                         $to_user_list[$row['uid']]=$row;  
                                 }  
                         }  
                 }  
                 $to_user_list+=(array)$post['buddy_list'];  
                 if($to_user_list==false)  
                 {  
                         return 3;  
                 }  
                                   
                 $time = time();  
                 $post['message'] = strstr($post['message'],"\\") ? $post['message'] : addslashes($post['message']);  
                                 foreach($to_user_list as $to_user_id => $to_user_name)  
                 {  
                         $data=array(  
                         "msgfrom"         =>$susername,  
                         "msgnickname"=>$snickname,  
                         "msgfromid"  =>$suid,                                                                  "msgto" => $to_user_name['username'],                                        "tonickname" => $to_user_name['nickname'],                                "msgtoid"   => $to_user_id,                                                                "subject"   => $post['subject'],  
                         "message"   => $post['message'],  
                         "new"=>'1',  
                         "dateline"=>$time,  
                         );  
   
                         if($post["save_to_outbox"])  
                         {  
                                 $data['folder']="outbox";  
                                 $msg=;  
                         }  
                                                 $uids = '';  
                         if($suid > $to_user_id){  
                                 $uids = $to_user_id.",".$suid;  
                         }else{  
                                 $uids = $suid.",".$to_user_id;  
                         }  
   
                         $plid = 0;  
                                                                         if(!$msg){  
                                                                 $lastmessage = addslashes(serialize($data));  
                                 $plid = $this->DatabaseHandler->ResultFirst("select plid from ".TABLE_PREFIX."pms_index where uids = '$uids'");  
   
                                 if($plid == 0){  
                                                                                 $this->DatabaseHandler->Query("insert into ".TABLE_PREFIX."pms_index (uids) values('$uids')");  
                                         $plid = $this->DatabaseHandler->Insert_ID();  
                                         if(0 != $plid){  
                                                                                                 $this->DatabaseHandler->Query("insert into ".TABLE_PREFIX."pms_list (plid,uid,pmnum,dateline,lastmessage) values('$plid','".$suid."',1,'$time','$lastmessage')");  
                                                 if($suid != $to_user_id){  
                                                         $this->DatabaseHandler->Query("insert into ".TABLE_PREFIX."pms_list (plid,uid,pmnum,dateline,lastmessage,is_new) values('$plid','$to_user_id',1,'$time','$lastmessage',1)");  
                                                 }  
                                         }  
                                 }else{  
                                                                                 $this->DatabaseHandler->Query("update ".TABLE_PREFIX."pms_list set pmnum = pmnum + 1,dateline = '$time',lastmessage = '$lastmessage',is_new = 1 where plid = '$plid' and uid = '$to_user_id' ");  
                                         if($suid != $to_user_id){  
                                                 $this->DatabaseHandler->Query("update ".TABLE_PREFIX."pms_list set pmnum = pmnum + 1,dateline = '$time',lastmessage = '$lastmessage',is_new = 0 where plid = '$plid' and uid = '$suid' ");  
                                         }  
                                 }  
                         }  
   
                         $data['plid'] = $plid;  
   
                         DB::insert('pms',$data);  
                                         }  
   
                 if($msg){  
                         return 4;  
                 }  
   
                 $num=$post["save_to_outbox"]?0:1;  
                 if($num > 0){  
                                                 $_tmps=array_keys($to_user_list);  
                         $to_user_id_list = array();  
                         foreach($_tmps as $_tmp) {  
                                 $_tmp = (int) $_tmp;  
                                 if($_tmp > 0) {  
                                         $to_user_id_list[$_tmp] = $_tmp;  
                                 }  
                         }  
========================================================
代码其实无需看
思路过程是Funtion 里
(这这句<$string=strip_selected_tags($string,"<script><iframe><style><link><meta>");  >)这里已经发现问题标签过滤不完整
>查找调用文件 回溯到短消息发送文件($f_rets = filter($post['message']);)虽然知道这里是浮云 $num=$post["save_to_outbox"]
> 查看上下 sendAgain() $this->Post['message'] = $pm_list['message']; 无过滤
一个是直接过滤入库 另外一个是直接入库
========================================================
EXP链接:https://www.t00ls.com/thread-21639-1-1.html
========================================================

休息一段时间看看是否有愿意一起来的朋友

看情况在放等 也许其他人会放出 版本太新用的人价值不高呵呵
不代表任何组织个人 只是在t00ls这个平台交流的一个小群体
我的思想就是 开放+利用 既有你想研究的 也有你想做的 这就是自由的灵魂无论善恶exp都有它纯在的意义 我认为的灰色和低调

关于作者

anlfi55篇文章3289篇回复

评论35次

要评论?请先  登录  或  注册
  • 35楼
    2023-9-10 23:49

    这 都是寻找志同道合的人来安全发家致富哦

  • 34楼
    2023-8-31 19:39

    不错的,学到了,师傅

  • 33楼
    2023-7-16 00:49

    我想说,乱糟糟的

  • 32楼
    2017-6-22 06:01

    有一个一个t00ls平台交流的小群体真好,做为一个学xi者真心期待加入,如果时间允许一定积极参加,若有什么关于学xi方面的一切随时联络一定积极参与,随时有学xi交流活动或者需要我的地方可随时@谢谢.

  • 31楼
    2016-10-12 23:05

    现在像你这样乐意分享的代码牛已经不多了,赞一下,私聊个联xi方式,以后好向anlfi牛请教。

  • 30楼
    2015-5-28 02:08
    anlfi

    早上看代码 下午去国外论坛学xi到处翻资料然后晚上各种你懂的所以晚上都有时间不得不说国外的挖起来比国内轻松 也不是国外弱因为国外有比较齐全的资料分析你可以顺着人家的思路继续拓展学xi欢迎交流

    1

    求分享点国外论坛

  • 29楼
    2014-10-17 02:54

    好复杂的说 难

  • 28楼
    2014-2-16 12:46

    学xi如何挖洞。。

  • 27楼
    2013-5-10 04:43

    好像很厉害的样子 好神奇哦

  • 26楼
    2013-5-4 21:49

    不知道怎么说好,但是现在坏境不错,很多人都在研究代码审计你可以找到更多的文章。 基础比较广泛了但是都不难 最起码要有点编程基础了 然后花个1-2小时看一下php手册就好了 兴趣最重要,说多了没意思,学xi就是积累的过程 你可以多看看国外http://packetstormsecurity.com/公布的一些漏洞 有些是没有详情的 做到还原 分解 分析 最后自己写出exp 同时也有对方分析的0day 有些东西掌握了就变得很简单了 但是如何教我不怎么在行╮(╯▽╰)╭ 其实很多人起步都是2009年 但是编程却是玩了很多年了 开始虽然懂的不多 但后面的基本都是google baidu 自己研究 练手的话可以用wordpress的插件 学xi都是要付出时间的代价 最后设立一个较大的目标 比如dz 分析 取样 建模 模拟 修正 实现 复模 怎样研究还是跟大学里面一样只要有计划就不会白费 提问的话尽量问细节吧 基础说实话只要能读懂代码即可 其他diy方法可以慢慢去研究

  • 25楼
    2013-5-4 15:07

    今天第一开始进来就看到这么好的帖子,实在不错,xi望以后和大家多多学xi

  • 24楼
    2013-5-4 14:28

    挖php的洞,要具备哪些基础?楼主看了请务必回复!感谢

  • 23楼
    2013-4-26 12:06

    前来研究学xi!

  • 22楼
    2013-4-21 01:34

    他日必成大器!

  • 21楼
    2013-4-12 11:22

    搞基吗,暗恋你很久了

  • 20楼
    2013-3-23 21:23

    学xi挖洞。求带啊

  • 19楼
    2013-3-2 21:24

    能否带队挖洞,求公布一个简单的挖洞过程

  • 18楼
    2013-2-3 17:34

    求带!求学xi。

  • 17楼
    2013-2-3 16:28

    非常牛逼的人,霸气侧漏……

  • 16楼
    2013-1-26 13:00

    真性情