PhEmail简介
PhEmail是基于python编写的一款网络钓鱼邮件测试工具。PhEmail可以同时向多个用户发送钓鱼邮件,并记录点击的用户的邮箱和IP等信息。PhEmail可以通过Google收集邮箱,完成邮箱收集工作。该工具可以用于公司内部邮箱钓鱼测试,可结合beef使用。
PhEmail项目主页:
PhEmail钓鱼邮件工具
工具使用
PhEmail帮助
1 | PHishing EMAIL tool v0.13 |
收集邮箱后钓鱼邮件发送常用参数:
- -e 收件人邮箱列表(列表内邮箱必须为同一域名)
- -f 发件人邮箱地址(伪造的邮箱不能与收件人邮箱在同一域名下)
- -r 收件人回复邮件时的接收邮箱,可采用临时邮箱
- -s 伪造的邮件主题
- -b 伪造的邮件内容文件,采用html编码,模板中采用href=”{0}”来代替url地址
- -w 钓鱼网站url地址,发送后会自动添加index.php?email=等内容
记录邮箱的方式
钓鱼邮件中的url链接伪造时添加email地址并进行编码,通过钓鱼网站中php文件代码来识别email并记录log文件中。php可以进行重定向到其他网站。
实际使用需要修改的地方
BeautifulSoup问题
安装BeautifulSoup后,运行程序时会报BeautifulSoup问题。
- 可以将源代码中如下位置的注释切换
修改为如下:1
2
3
4
5try:
from BeautifulSoup import BeautifulSoup
#from bs4 import BeautifulSoup
except:
print "No BeautifulSoup installed" - 不修改注释,将所有调用BeautufulSoup的函数的修改为:
1
html = BeautifulSoup(xxx)
1
html = BeautifulSoup(xxx,'lxml')
中文乱码
邮件在使用中文时出现中文乱码,需要修改phemail.py内容进行调整。
邮件标题乱码
在导入包时添加如下内容1
2
3import sys
reload(sys)
sys.setdefaultencoding('utf8')
对邮件标题进行unicode编码,在发送邮件时添加如下代码1
2
3if not isinstance(SUBJECT):
SUBJECT = unicode(SUBJECT,unicode)
msg['subject'] = SUBJECT
邮件内容乱码
添加如下代码1
2msg["Accept-Language"]="zh-CN"
msg["Accept-Charset"]="ISO-8859-1,utf-8"
并将1
msgAlt.attach(MIMEText(body.format(url),'html'))
修改为1
msgAlt.attach(MIMEText(body.format(url),'html','utf-8'))
index.php内容修改
修改域名
修改位置在index.php中有提示:
将其中的dionach.com修改为收件人邮箱的域名。
修改重定向
在index.php末尾存在重定向方法,可以将此url改为你想要重定向的url,如www.baidu.com
修改记录log文件保存位置
index.php中将log文件保存在/tmp目录中,若使用windows搭建网站服务,则不存在/tmp目录,直接将log文件保存在当前目录,删除下面代码中的”/tmp/“
整理log日志
若收件人点击后php获取了如下一系列信息:
若存在多个文件,并想提取其中的email地址,并去重,于是写了一个小脚本进行提取email去重:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#-*- conding:utf-8 -*-
import sys
import re
import os
regex = r"([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)"
filepth = sys.argv[1]
file = os.listdir(filepth)
allinemail = []
for filename in file:
with open(filepth+filename,'r') as f:
emails = re.findall(regex,f.read())
allemail = list(set(emails))
for e in allemail:
if e not in allinemail:
allinemail.append(e)
f.close()
with open('email_result.txt','w') as w:
for email in allinemail:
w.write(email+'\n')
w.close()