使用apache mod_rewrite方法随机提供payloads

简介: 本文讲的是使用apache mod_rewrite方法随机提供payloads,本文中讲述的方法更适用于真实渗透测试环境中,因为电子邮件钓鱼往往是威胁到整个公司,而不是只威胁到红队的测试环境。因为电子邮件钓鱼具有高针对性,并且手动设置攻击载荷对攻击来说也是很麻烦的。
本文讲的是 使用apache mod_rewrite方法随机提供payloads本文中讲述的方法更适用于真实渗透测试环境中,因为电子邮件钓鱼往往是威胁到整个公司,而不是只威胁到红队的测试环境。因为电子邮件钓鱼具有高针对性,并且手动设置攻击载荷对攻击来说也是很麻烦的。所以请阅读这篇文章,我会通过设置一个apache重定向器或者直接设置一个服务器,通过RewrieMap从预定义的攻击payload列表中随机选取payload进行提供。

apache中RewriteMap方法允许外部的程序比如脚本,数据库,文本文件等映射到服务器内部。在官方文档中使用最多的例子:如果一家网店的url结构想从item-1234到iphone-7-white,那么网站管理员无需更改任何硬编码的代码,只需当访问item-1234时,apache来提供iphone-7-white这一url。RewriteMap提供了大量修改这些资源的方法。我们会使用RewriteMap从一个文本文档中提取的payload转换为URI,并且当被访问时,进行302跳转,使目标能够访问到我们随机的payload文件。

下图就是攻击的主要内容:

使用apache mod_rewrite方法随机提供payloads

环境配置

apache环境需要更改一些设置以便服务器环境支持mod_rewrite以及RewriteMap方法。这些设置的详细信息都在我之前的一篇文章中写过。长话短说,打开位于/etc/apache2/的apache2.conf文件,通过增加以下代码重写htaccess文件:

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

如果你的重定向器的网站根目录不是默认的/var/www,你需要去更改一下AllowOverride的响应目录。

在配置服务器的文档中,我们需要在底部添加:

RewriteMap payloads "rnd:/var/www/payloads.txt"

这一行代码就告诉mod_rewrite方法,当我们使用RewriteMap调用payload变量时,就会从/var/www/payloads.txt提取。apache用户必须具有读取这一文件的权限。并且应该储存在web根目录之外,比如在这个例子中,就是在/var/www/html目录之外。

创建/var/www/payloads.txt文件,并且在文件中写入如下内容:

windows payload.lnk|payload.hta|payload.exe

上述代码中windows就是触发的key,以及payload.link,payload.hta,payload.exe则是变量。当RewriteMap函数被调用时,此时就会提供windows这个Key,然后通过管道符号分割的变量就会随机选取一个。我们可以增加多次payload名字,以便它可以更大概率的输出。这个文件可以立即更新,所以修改这个文件之后无需重启apache服务。如果你确定有的payload不起作用了,你完全可以在payload.txt中删除。

通过以下命令开启依赖的mod_rewrite模块,重启apache服务。

a2enmod rewrite proxy proxy_http && service apache2 restart

启动的最后一步就是创建htaccess文件,比如在/var/www/html/.htaccess文件写入如下内容:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/payload/?$
RewriteRule ^.*$ /${payloads:windows} [L,R=302]
RewriteCond %{REQUEST_URI} ^/payload.(exe|lnk|hta)
RewriteRule ^.*$ http://192.168.188.134%{REQUEST_URI} [P]

以下是规则的详细划分:Enable the rewrite engine

If the request’s URI starts with ‘payload’ with an optional trailing slash at the end of the URI,
rewrite the entire request to a random value pulled from the RewriteMap file linked to "payloads" with the key "windows" This is a temporary redirect and the last rule that should be evaluated/applied to the request.
If the request’s URI starts with ‘payload’ and ends with the file extension exe, lnk, or hta,
rewrite the entire request to serve the request URI from IP 192.168.188.134 (the payload server IP), and keep the user's address bar the same (obscure the teamserver's IP).

现在,服务端已经完全配置好了。

当用户连续两次访问http://spoofdomain.com/payload时,第一次会提供可执行文件,第二次会提供html 应用程序(HTA)。

使用apache mod_rewrite方法随机提供payloads

总结

Apache mod_rewrite为渗透测试人员以及红队提供了丰富的选择,这一方法加强了他们的攻击范围以及钓鱼攻击的成功率。这个技术可以和别的技术结合起来,会获得更大的效果。用户点击后可以尽可能的收集更多的信息。




原文发布时间为:2017年6月17日
本文作者:xnianq
本文来自云栖社区合作伙伴嘶吼,了解相关信息可以关注嘶吼网站。
目录
相关文章
|
4月前
|
消息中间件 Kafka Apache
Apache Flink消费Kafka数据时,可以通过设置`StreamTask.setInvokingTaskNumber`方法来实现限流
Apache Flink消费Kafka数据时,可以通过设置`StreamTask.setInvokingTaskNumber`方法来实现限流
71 1
|
Apache
给Apache虚拟主机增加端口的方法
给Apache虚拟主机增加端口的方法
105 0
|
云安全 消息中间件 监控
Apache Log4j2 高危漏洞应急响应处置方法汇总整理
Apache Log4j2 高危漏洞应急响应处置方法汇总整理
482 0
Apache Log4j2 高危漏洞应急响应处置方法汇总整理
|
Apache
org.apache.commons.lang.StringUtils的常用方法
org.apache.commons.lang.StringUtils的常用方法
875 0
Apache httpclient的execute方法调试
Apache httpclient的execute方法调试
Apache httpclient的execute方法调试
|
Apache
Apache httpclient的execute方法调试
Apache httpclient的execute方法调试
115 0
Apache httpclient的execute方法调试
|
关系型数据库 MySQL Linux
在CentOS上安装搭建PHP+Apache+Mysql的服务器环境方法
本篇给大家分享一下在CentOS上安装搭建PHP+Apache+Mysql的服务器环境方法,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。Yum(全称为 Yellow dog Updater, Modified)是一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器。
|
Web App开发 测试技术 Linux
centos下安装与配置Apache方法
下面以httpd-2.0.55.tar.gz版本为例,介绍Apache在Linux中的安装过程:1、解压和解包安装文件:gzip -d httpd-2.0.55.tar.gztar xvf httpd-2.0.55.tar2、配置:cd httpd-2.0.55./configure --prefix=/usr3、编译:make4、安装:make install5、配置:vi /usr/conf/httpd.conf将文件中“#ServerName www.example.com:80”这一行中的“#”删掉,并将www.example.com 改为linux本机的IP地址。
881 0
|
关系型数据库 MySQL Linux
Linux下将Mysql和Apache加入到系统服务里的方法
Apache加入到系统服务里面:   cp /安装目录下/apache/bin/apachectl /etc/rc.d/init.d/httpd   修改httpd   在文件头部加入如下内容:   ###   # Comments to support chkconfig on RedHat Li...
671 0

热门文章

最新文章

推荐镜像

更多