当前位置:网站首页>CTFHub-rce
CTFHub-rce
2022-06-25 04:55:00 【Cn Sirius】
CTFHub-rce
rce: Remote code execution vulnerability
Divided into remote command execution ping And remote code execution evel.
In fact, this is an interface , It allows attackers to inject operating system commands or code directly into the background server , To control the background system , This is it. RCE Loophole . Equivalent to directly controlling the server computer cmd Command line ! High risk vulnerability !
eval perform
<?php
if(isset($_REQUEST['cmd'])){
eval($_REQUEST['cmd']);
}
else{
highlight_file(__FILE__);
}
?>
Pass the reference to cmd Come on eval
/?cmd=system("ls /");// There is no root directory here flag So look at the next level of directory
After finding Again cat /flag_****
File contains
Use here strpos function
strpos: Find where the string first appears
int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
Topic use
if(!strpos($_GET["file"],"flag")){
// nothing flag Characters to run
include $_GET["file"];
}
To include files , And the following shell.txt contain eval Loophole
So include it (shell.txt No, “flag” character So here strpos No influence )
adopt get( Include files ) post( The ginseng ) And used to get flag
php info
<?php
if (isset($_GET['file'])){
if ( substr($_GET["file"], 0, 6) === "php://" ) {
include($_GET["file"]);
}
else {
echo "Hacker!!!";
}}
else {
highlight_file(__FILE__);}?>
<hr>i don't have shell, how to get flag? <br><a href="phpinfo.php">phpinfo</a>
Click on phpinfo link You can see php Environmental Science
php://input
php:// — Access individual inputs / Output stream (I/O streams)
PHP Some miscellaneous inputs are provided / Output (IO) flow , allow access to PHP I / O stream 、 Standard I / O and error descriptors , In the memory 、 The temporary file stream of disk backup and the filter that can operate other read and write file resources .
php://input It's a read-only stream that can access the requested raw data .

Read source code
Look at the environment Can't use php://input
<?php
error_reporting(E_ALL);
if (isset($_GET['file'])) {
if ( substr($_GET["file"], 0, 6) === "php://" ) {
include($_GET["file"]);
} else {
echo "Hacker!!!";
}
} else {
highlight_file(__FILE__);
}
?>
But it must also be php:// start
php://filter


Remote contains
Same as phpinfo Do the same
Command injection
Enter the command
127.0.0.1;ls
then cat There was a problem
The output is limited
So the pipe symbol is used to limit the output base64
Get it and decode it

Filter cat
<?php
$res = FALSE;
if (isset($_GET['ip']) && $_GET['ip']) {
$ip = $_GET['ip'];
$m = [];
if (!preg_match_all("/cat/", $ip, $m)) {
/ It's filtered out cat
$cmd = "ping -c 4 {
$ip}";
exec($cmd, $res);
}
else {
$res = $m;
}
}
?>
<pre>
<?php
if ($res) {
print_r($res);
}
?>
</pre>
<?php
show_source(__FILE__);
?>
</body>
</html>
more
Linux more Command similar cat , But it will be displayed page by page , More convenient for users to read page by page , And the most basic command is to press the blank key (space) The next page shows , Press b The key will go back (back) One page shows , It also has the function of searching for strings ( And vi be similar ), Documentation in use , Please press h .
more [-dlfpcsu] [-num] [+/pattern] [+linenum] [fileNames..]

Filter space
stay linux Space available in < or ${IFS} Instead of

Filter operators
cat [file]|base64 You can also use base64 [file]
<?php
$res = FALSE;
if (isset($_GET['ip']) && $_GET['ip']) {
$ip = $_GET['ip'];
$m = [];
if (!preg_match_all("/(\||\&)/", $ip, $m)) {
$cmd = "ping -c 4 {
$ip}";
exec($cmd, $res);
} else {
$res = $m;
}
}
?>

Comprehensive practice
!preg_match_all("/(\||&|;| |\/|cat|flag|ctfhub)/", $ip
; It can be used %0a(url code ) cat use base64 flag Use regular f*** *lag etc. Space with ${IFS}



边栏推荐
- 绝了!自动点赞,我用 PyAutoGUI!
- How to use the Magic pig system reinstallation master
- Laravel Aurora push
- 《QDebug 2022年6月》
- 第九章 APP项目测试(2) 测试工具
- Join() in JSZ
- OOP stack class template (template +ds)
- Vscade setting clang format
- Cannot import name 'escape' from 'jinja2' [solved successfully]
- Leader: who can use redis expired monitoring to close orders and get out of here!
猜你喜欢

Which programming language is the most cumbersome to implement Hello world?

API interface management setup -eolinker4.0

ASEMI三相整流桥的工作原理

PHP calls map API

Kotlin compose perfect todo project surface rendering background and shadow

TeeChart Pro ActiveX 2022.1

Leader: who can use redis expired monitoring to close orders and get out of here!

MySQL concept and operation (III)

ThinkPHP 5 log management

Machine learning deep learning -- Vectorization
随机推荐
Join() in JSZ
台式电脑连不上wifi怎么办
基于Cortex-M3、M4的精准延时(系统定时器SysTick延时,可用于STM32、ADuCM4050等)
JS' sort() function
Web3 DAPP user experience best practices
DMA double buffer mode of stm32
JDBC (IV)
Web3 DApp用户体验最佳实践
Ranorex Studio 10.1 Crack
The SQL response is slow. What are your troubleshooting ideas?
buuctf(pwn)
Efficient NoSQL database service Amazon dynamodb experience sharing
【FLink】access closed classloader classloader. check-leaked-classloader
Upgrade PHP to php7 The impact of X (I). The problem of session retention. Keep login
In Net 6 using dotnet format formatting code
ASEMI三相整流桥的工作原理
Rce code execution & command execution (V)
[image fusion] image fusion based on MATLAB directional discrete cosine transform and principal component analysis [including Matlab source code 1907]
Mysql interactive_ Timeout and wait_ Timeout differences
Two hours to take you into the software testing industry (with a full set of software testing learning routes)