每天都要加油哦!    ------2024-01-18  11:16:55


[NSSRound#16 Basic]RCE但是没有完全RCE


<?php

error_reporting(0);

highlight_file(__file__);

include('level2.php');

if (isset($_GET['md5_1']) && isset($_GET['md5_2'])) {

    if ((string)$_GET['md5_1'] !== (string)$_GET['md5_2'] && md5($_GET['md5_1']) === md5($_GET['md5_2'])) {

        if (isset($_POST['md5_3'])&&md5($_POST['md5_3']) == md5($_POST['md5_3'])) {

            echo $level2;

        } else {

            echo "您!!!!!那么现在阁下又该如何应对呢";

        }

    } else {

        echo "还在用传统方法????";

    }

} else {

    echo "来做做熟悉的MD5~";

}

来做做熟悉的MD5~

这道题要md5_1和md5_2的string后的值要强不等于一样,并且他们的md5值要一样

参考这篇文章https://blog.csdn.net/qq_19980431/article/details/83018232

成功过去。其中md5_3没有任何限制,什么都行。

进入3z_RC3.


<?php

error_reporting(0);

highlight_file(__FILE__);

$shell = $_POST['shell'];

$cmd = $_GET['cmd'];

if(preg_match('/f|l|a|g|\*|\?/i',$cmd)){

    die("Hacker!!!!!!!!");

}

eval($shell($cmd));

cmd中不能有flag。会执行我们输入的语句。

进行目录穿越,可以得到根目录有个flag.使用通配符绕过。

得到flag:NSSCTF{79575ef9-a587-4557-8d5f-99074758ba48} 


[NSSRound#16 Basic]了解过PHP特性吗

<?php

error_reporting(0);

highlight_file(__FILE__);

include("rce.php");

$checker_1 = FALSE;

$checker_2 = FALSE;

$checker_3 = FALSE;

$checker_4 = FALSE;

$num = $_GET['num'];

if (preg_match("/[0-9]/", $num)) {

    die("no!!");

}

if (intval($num)) {

    $checker_1 = TRUE;

}

if (isset($_POST['ctype']) && isset($_POST['is_num'])) {

    $ctype = strrev($_POST['ctype']);

    $is_num = strrev($_POST['is_num']);

    if (ctype_alpha($ctype) && is_numeric($is_num) && md5($ctype) == md5($is_num)) {

        $checker_2 = TRUE;

    }

}

$_114 = $_GET['114'];

$_514 = $_POST['514'];

if (isset($_114) && intval($_114) > 114514 && strlen($_114) <= 3) {

    if (!is_numeric($_514) && $_514 > 9999999) {

        $checker_3 = TRUE;

    }

}

$arr4y = $_POST['arr4y'];

if (is_array($arr4y)) {

    for ($i = 0; $i < count($arr4y); $i++) {

        if ($arr4y[$i] === "NSS") {

            die("no!");

        }

        $arr4y[$i] = intval($arr4y[$i]);

    }

    if (array_search("NSS", $arr4y) === 0) {

        $checker_4 = TRUE;

    }

}

if ($checker_1 && $checker_2 && $checker_3 && $checker_4) {

    echo $rce;

}

当num是一个数组时,preg_match会将它转化为bool类型,而使整个句子返回false;

intval当遇到非空数组时,会返回true

第二个绕过

PHP 的弱类型比较;QNKCDZO 和 240610708 进行 md5 后加密的数值为 0e 开头,在 PHP 中会被识别为科学计数法,所有 0e 开头的数据进行弱类型比较皆为 True

第三个,search默认第三个参数是false类型。弱比较,输入0,NSS0,NSS1都行。

绕过后会提示你去别的地方

这里就是一个简单的create_function注入。shell变量对应的是新建匿名函数的参数列表,nss变量对应的是函数体。这里给shell变量传一个空值,这样这个新建的匿名函数就能在没有参数的情况下执行。
create_function注入原理见

https://www.cnblogs.com/-chenxs/p/11459374.html

https://www.cnblogs.com/GTL-JU/p/16831601.html

类似于sql注入的闭合,只不过这个是闭合}。

flag:shell=&nss=1;}system("cat /flag");/*


[NSSRound#16 Basic]pr

原题:

from Crypto.Util.number import *
import random flag=plaintext = 'NSSCTF{****************}'
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
padding_length = 100 - len(plaintext) for _ in range(padding_length):
plaintext += random.choice(charset) public_exponent = 31413537523
message = bytes_to_long(plaintext.encode())
assert message > (1 << 512)
assert message < (1 << 1024) prime_p = getPrime(512)
prime_q = getPrime(512)
prime_r = getPrime(512)
n1 = prime_p * prime_q
n2 = prime_q * prime_r
ciphertext1 = pow(message, public_exponent, n1)
ciphertext2 = pow(message, public_exponent, n2)
print('c1=', ciphertext1)
print('c2=', ciphertext2)
print('p=', prime_p)
print('r=', prime_r) '''
c1= 36918910341116680090654563538246204134840776220077189276689868322808977412566781872132517635399441578464309667998925236488280867210758507758915311644529399878185776345227817559234605958783077866016808605942558810445187434690812992072238407431218047312484354859724174751718700409405142819140636116559320641695
c2= 15601788304485903964195122196382181273808496834343051747331984997977255326224514191280515875796224074672957848566506948553165091090701291545031857563686815297483181025074113978465751897596411324331847008870832527695258040104858667684793196948970048750296571273364559767074262996595282324974180754813257013752
p= 12101696894052331138951718202838643670037274599483776996203693662637821825873973767235442427190607145999472731101517998719984942030184683388441121181962123
r= 10199001137987151966640837133782537428248507382360655526592866939552984259171772190788036403425837649697437126360866173688083643144865107648483668545682383
'''

c1≡me​(mod n1​)   等价与 me ​≡c1(mod n1​)  

c2≡me​(mod n2​)      等价于 me ​≡c2(mod n1​)  

因为n1=p*q,n2=q*r,把上式子分解。

me ​≡c1(mod p​)  

me ​≡c1(mod r​)  

已知e,c1,c2,p,r.可以把m求出来。

用中国剩余定理将两者结合在一起。

以下是解题代码:

# -*- coding:utf-8 -*-
"""
作者:Wang Xinwei
日期:2024年01月21日
"""
from Crypto.Util.number import *
from gmpy2 import *
from functools import reduce
import sympy
def chinese_remainder(a, n):
sum = 0
prod = reduce(lambda a, b: a * b, n)
for n_i, a_i in zip(n, a):
p = prod // n_i
sum += a_i * sympy.invert(p, n_i) * p
return int(sum % prod)
c1 = 36918910341116680090654563538246204134840776220077189276689868322808977412566781872132517635399441578464309667998925236488280867210758507758915311644529399878185776345227817559234605958783077866016808605942558810445187434690812992072238407431218047312484354859724174751718700409405142819140636116559320641695
c2 = 15601788304485903964195122196382181273808496834343051747331984997977255326224514191280515875796224074672957848566506948553165091090701291545031857563686815297483181025074113978465751897596411324331847008870832527695258040104858667684793196948970048750296571273364559767074262996595282324974180754813257013752
p = 12101696894052331138951718202838643670037274599483776996203693662637821825873973767235442427190607145999472731101517998719984942030184683388441121181962123
r = 10199001137987151966640837133782537428248507382360655526592866939552984259171772190788036403425837649697437126360866173688083643144865107648483668545682383
e = 31413537523
c_p=c1%p
c_r=c2%r
c=chinese_remainder([c_p,c_r],[p,r])
phi=(p-1)*(r-1)
d=inverse(e,phi)
m=pow(c,d,p*r)
print(long_to_bytes(m))

得到flag:NSSCTF{yUanshEnx1ncHun2o23!}

【NSSCTF-Round#16】 Web和Crypto详细完整WP的更多相关文章

  1. Grunt搭建自动化web前端开发环境--完整流程

    Grunt搭建自动化web前端开发环境-完整流程 jQuery在使用grunt,bootstrap在使用grunt,百度UEditor在使用grunt,你没有理由不学.不用! 1. 前言 各位web前 ...

  2. Office web app server2013详细的安装和部署

    转自:http://blog.csdn.net/u011355311/article/details/9360293 SharePoint 2013集成Office web apps server20 ...

  3. [Educational Codeforces Round 16]E. Generate a String

    [Educational Codeforces Round 16]E. Generate a String 试题描述 zscoder wants to generate an input file f ...

  4. [Educational Codeforces Round 16]D. Two Arithmetic Progressions

    [Educational Codeforces Round 16]D. Two Arithmetic Progressions 试题描述 You are given two arithmetic pr ...

  5. [Educational Codeforces Round 16]C. Magic Odd Square

    [Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...

  6. [Educational Codeforces Round 16]B. Optimal Point on a Line

    [Educational Codeforces Round 16]B. Optimal Point on a Line 试题描述 You are given n points on a line wi ...

  7. [Educational Codeforces Round 16]A. King Moves

    [Educational Codeforces Round 16]A. King Moves 试题描述 The only king stands on the standard chess board ...

  8. BestCoder Round #16

    BestCoder Round #16 题目链接 这场挫掉了,3挂2,都是非常sb的错误 23333 QAQ A:每一个数字.左边个数乘上右边个数,就是能够组成的区间个数,然后乘的过程注意取模不然会爆 ...

  9. Windows + Ubuntu 16.04 双系统安装详细教程

    Windows + Ubuntu 16.04 双系统安装详细教程 2018年01月28日 16:43:19 flyyufenfei 阅读数:165619   发现了一篇好教程,果断转载了,以后用得着时 ...

  10. Codeforces Beta Round #16 (Div. 2 Only)

    Codeforces Beta Round #16 (Div. 2 Only) http://codeforces.com/contest/16 A 水题 #include<bits/stdc+ ...

随机推荐

  1. GIS常用npm包:GeoJSON文件合并与元素过滤\属性过滤\图形合并

    GeoJSON文件合并 普通的geoJSON文件合并,只需geojson-merge插件就够了,https://www.npmjs.com/package/@mapbox/geojson-merge ...

  2. appuploader不是开发者账号

    Appuploader是一款可以帮助开发者上传iOS应用到Apple App Store的工具.很多开发者都知道,在上传应用到App Store之前,需要创建开发者账号并获得苹果官方的认证才能进行上传 ...

  3. 火山引擎 DataTester:5 个优化思路,构建高性能 A/B 实验平台

    导读:DataTester 是由火山引擎推出的 A/B 测试平台,覆盖推荐.广告.搜索.UI.产品功能等业务应用场景,提供从 A/B 实验设计.实验创建.指标计算.统计分析到最终评估上线等贯穿整个 A ...

  4. 接通率维持 66% 以上,为什么火山引擎 VeDI 能让企业智能外呼不再难?

    更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 智能机器人在企业级市场的应用更加深入了. 随着人工智能技术的进一步发展,包括智能外呼.财务审核.自助客服等在内的智 ...

  5. Hyper-V CentOS Linux 硬盘扩容

    同一物理盘进行扩容(非挂载),首先在虚机内将硬盘空间扩大, Hyper-V 需要将检查点删除 查看物理卷和卷组,并将物理卷加入到卷组 #将剩余空间添加到逻辑卷 /dev/centos/root lve ...

  6. Bug定级实例

    *1级,**系统崩溃* *定义:*严重阻碍测试和开发工作 *对应**优先级**:**最高* *具体可分为:* 1.功能完全没有实现 2.应用闪退/崩溃无法运行 3*.应用必现安全模式,无法运行* 4. ...

  7. 精细化边缘安全防护:如何防止CDN域名被恶意刷量?

    越是数字化时代,越要做好基建"安全"的顶层设计 随着消费及产业互联网的不断发展,数字化将实现全场景覆盖,人类的生活和生产方式也随之不断改变. 内容分发网络CDN(Content D ...

  8. CMake 禁用 MSVC 编译警告 C4819

    warning C4819:该文件包含不能在当前代码页(936)中表示的字符.请将该文件保存为 Unicode 格式以防止数据丢失 if (win32) add_complie_options(/W4 ...

  9. PySpark 入门:通过JDBC连接数据库(DataFrame)

    这里以关系数据库MySQL为例.首先,本博客教程(Ubuntu 20.04 安装MySQL 8.X),在Linux系统中安装好MySQL数据库.这里假设你已经成功安装了MySQL数据库.下面我们要新建 ...

  10. C#设计模式15——观察者模式的写法

    是什么: 观察者模式是一种设计模式,它定义了对象之间的一种一对多的依赖关系,使得当一个对象状态发生改变时,它的所有依赖者都能够得到相应的通知并作出相应的反应.观察者模式也被称为发布-订阅模式. 为什么 ...