[NOTE] SQL与sqlmap

[NOTE] SQL与sqlmap

SQL语法

order by

  • 对查询结果排序
  • ASC:升序(默认)、DESC:降序
  • SQL注入中多在成功查询之后添加order by i来猜解回显的字段数
  • XXX/?id=1' order by 3 %23

limit

  • select * from tableName limit i,n
  • tableName:表名
  • i:查询结果的索引值(默认从0开始),当i=0时可省略i
  • n:查询结果返回的数量
  • i与n之间使用英文逗号","隔开
    • 查询10条数据,索引从0到9,第1条记录到第10条记录
    • select * from t_user limit 10
    • select * from t_user limit 0,10
  • 查询第6条数据
    • select * from t_user limit 5,1

union

  • union操作符可以合并多个select结果作为一个查询结果返回
  • union内部的每个select必须拥有相同的列
  • 列也必须拥有相似的数据类型
  • 可以用来查找显错的字段(让前一个select语句为false,后一个select 1,2,3等)
  • 例如输入了1’ union select 1,2 #,回显:
    在这里插入图片描述

information_schema(重要)

希望不会挂

sys数据库

里面有一些视图可能会暴露敏感信息

  • innodb_buffer_stats_by_schema
    通过数据库统计innodb引擎的innodb缓存
    有数据库名字段
  • innodb_buffer_stats_by_table
    通过每个表innodb引擎的innodb缓存
    有数据库名和表名字段
  • host_summary
    主机概要
    有host、unique_users(主机唯一用户数)等字段
  • host_summary_by_statement_type
    主机语句执行概要
    有statement(最后的语句时间名称)字段
  • latest_file_io
    记录着最近的文件I/O操作
    有文件路径名、操作类型等字段
  • schema_auto_increment_columns
    记录着数据库中自增的字段
    有库名、表名、自增列的数据类型等
  • user_summary

一些函数

直接获取信息

  • database():当前数据库
  • user():当前用户
  • system_user():操作系统用户
  • session_user():连接数据库的用户
  • version():当前数据库版本
  • @@basedir:当前数据库绝对路径
  • @@version_compile_os:操作系统版本

辅助与计算

  • length():计算字段长度
  • count(*):计算返回结果的数量
  • substr(string, start, length):返回string从位置start开始length长度的子字符串
  • mid():与substr()类似
  • ascii(char):计算char对应的ASCII码

整理输出

  • concat_ws(separator,str1,str2,…):以第一个参数为分隔符,返回拼接后的字符串
  • group_concat(column_name):对返回的特定分组(常为某一列的数据)的字符串进行拼接

sqlmap

目标与探测级别

  • -r:从文件中加载HTTP请求

  • -p XXX:选择注入参数

  • –level=LEVEL(1-5): 探测级别

  • –risk=RISK(1-3):探测风险

全局信息查询

  • –current-user:查询当前数据库用户
  • –current-db:查询当前数据库
  • –hostname:查询目标主机名
  • –users:枚举所有用户
  • –is-dba:判断当前用户是否为DBA
  • –passwords:枚举所有用户的密码(可能会结合爆破/hash爆破)
  • –privileges:查询当前用户权限
  • –roles:查询当前用户角色

具体数据查询

  • -dbs:枚举所有数据库
  • –dump-all:导出所有数据库的所有内容
  • -D DATABASE:指定数据库
  • –dump:导出数据库的所有内容
  • –tables:枚举所有表
  • -T TABLE:指定表
  • –schema:查询表的结构
  • –colums:枚举所有列
  • -C COLUM:指定列

系统操作(需要挂马)

As an AI language model, I do not have the capability to run SQLmap shell. However, I can provide you with information on SQLmap and how to use it. SQLmap is a tool used for automated SQL injection and database takeover. It can detect and exploit various vulnerabilities in a website or web application. With its powerful features, SQLmap can extract sensitive data, dump database tables, and even gain administrative access to the target system. To use SQLmap, you need to have a basic understanding of SQL injection and how it works. You also need to have Python installed on your system, as SQLmap is written in Python. Here are the basic steps to use SQLmap: 1. Download SQLmap from its official website or GitHub repository. 2. Open a terminal window and navigate to the location where SQLmap is installed. 3. Use the following command to start SQLmap: ``` python sqlmap.py ``` 4. Next, you need to provide the target URL or IP address of the website or web application you want to test. Use the following command: ``` python sqlmap.py -u <target_url> ``` 5. SQLmap will start scanning the target for SQL injection vulnerabilities. Once it finds a vulnerability, it will prompt you to confirm whether you want to exploit it. 6. If you choose to exploit the vulnerability, SQLmap will start extracting data from the target database. You can use various options and commands to customize the data extraction process. 7. Once SQLmap has extracted the data, you can save it to a file or view it in the terminal. Note that SQLmap is a powerful tool that can cause damage if used improperly. It is important to use it ethically and with permission from the target website or web application owner.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值