当前位置:网站首页>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
边栏推荐
- "PHP Basics" uses echo statements to output information
- What is the real HTAP? (1) Background article
- ERP生产作业控制 华夏
- [target detection] yolov6 theoretical interpretation + practical test visdrone data set
- Lua iterator
- Prevent cookies from modifying ID to cheat login
- Data extraction 1
- 数据提取1
- [golang] golang develops wechat official account web page authorization function
- Notes in "PHP Basics" PHP
猜你喜欢

Design and development of GUI programming for fixed-point one click query

"PHP Basics" PHP statements and statement blocks

Grandson's questions are difficult, and his son's invigilation is strict. I can't do it. Pay back my school money

Lua迭代器

一段平平无奇的秋招经历

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

如何更新pip3?和Running pip as the ‘root‘ user can result in broken permissions and conflicting behaviour

浅谈数据安全
![[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL](/img/05/41f48160fa7895bc9e4f314ec570c5.png)
[resolved] SSO forwarding succeeded, and there was an unexpected error (type=internal server error, status=500) caused by parameters in the forwarding URL

Lu Xun: I don't remember saying it, or you can check it yourself!
随机推荐
如何获取广告服务流量变现数据,助力广告效果分析?
服务器网络测试的方法
Lua iterator
物联网工业级UART串口转WiFi转有线网口转以太网网关WiFi模块选型
The response of the database interface is very slow
How does slf4j configure logback?
Promise详解
1024 | in the fourth year officially called Menon, the original intention is still there, and continue to move forward
Harbor正确密码登录不上去
C语言:随机生成数+插入排序
Dormitory access control system made by imitating the boss (III)
Notes in "PHP Basics" PHP
Stored procedure test 1 -- first acquaintance of love
Demo submit a program and obtain ALV data of the program
redis配置文件下载
Do me a favor ~ don't pay attention, don't log in, a questionnaire in less than a minute
Internet of things industrial UART serial port to WiFi to wired network port to Ethernet Gateway WiFi module selection
ERP生产作业控制 华夏
My senior
Data extraction 1