天天看点

Sqlmap远程连接Mysql,报错(2003)

环境:Windows,Kali linux。

工具:Sqlmap,Mysql,PyMySQL。

使用sqlmap连接本地mysql时报错,检查发现少个python库PyMySQL,github上有最新下载,

解压PyMySQL-master,

安装执行python setup.py install,

重启下mysql服务,

sqlmap目录下执行

<span style="font-size:18px;">python sqlmap.py -d mysql://root:[email protected]:3306/mysql</span>
           

搞定!继续测试远程是否可用,继续无法连接(10061),关闭防火墙继续尝试,还是失败。最终找到问题:Kali中Mysql访问权限问题。

<span style="font-size:18px;">[email protected]:~# cd /etc/mysql/mysql.conf.d/
[email protected]:/etc/mysql/mysql.conf.d# ls
mysqld.cnf  mysqld_safe_syslog.cnf   :q
<span style="color:#ff0000;">[email protected]:/etc/mysql/mysql.conf.d# vi mysqld.cnf</span> </span>
           
</pre><p></p><p><span style="font-size:18px;"><span style="white-space:pre">	</span>找到这一行,将最后一行注释掉。</span></p><p></p><pre name="code" class="html"><span style="font-size:18px;"># Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address           = 127.0.0.1
</span>
           

:wq保存退出,接着修改权限。

登陆mysql

<span style="font-size:18px;color:#ff0000;">grant all on *.* to 用户名@"%" identified by "密码"
</span>
           
<pre name="code" class="html"><pre name="code" class="html"><span style="font-size:18px;"><span style="color:#ff0000;">flush privileges;</span>
exit</span>
           

重启下mysql

service mysql restart
           

最后测试下

python sqlmap.py -d mysql://root:[email protected]:3306/mysql
           

搞定!