声明:该公众号分享的安全工具和项目均来源于网络,仅供安全研究与学习之用,如用于其他用途,由使用者承担全部法律及连带责任,与工具作者和本公众号无关
现在只对常读和星标的公众号才展示大图推送,建议大家把猫蛋儿安全“设为星标”,否则可能看不到了!
使用教程
下载
官网下载速度较慢,
使用迅雷下载,约3h可下载完成。下载地址为:
[https://www.camolabs.io/Downloads/Dejavu15/Console_VMDK.zip]
[https://www.camolabs.io/Downloads/Dejavu15/Engine_VMDK.zip]
安装
Vitral Box安装有很多坑,建议使用VMWare。安装教程参考:
[https://raw.githubusercontent.com/bhdresh/Dejavu/master/Console_ESXI.pdf]
[https://raw.githubusercontent.com/bhdresh/Dejavu/master/Engine_ESXI.pdf]
命令行登录:administrator / changepassword
网页登录用户名和密码都是admin
Console设置
网络设置为桥接模式,更改ip为192.168.1.167
添加防火墙规则,允许http。
访问成功
Engine设置
VMware Fusion 添加网卡。虚拟机——设置——添加设备——网络适配器。
网卡1设置桥接,网卡2设置host-only。
为eth1开启dhcp服务。命令:`sudo dhclient eth1` 。此时eth1获取到的ip是 192.168.67.3,与主机是通过 `bridge100` 相连的。
可以尝试网页中,添加子网。但是先不添加了
Engine连接Console
Console - Key Management - 得到Key
Engine - Setting - Connection & Logging - UPDATE API Key,之后设置Console IP,上面出现绿字,就是连接成功了。
虚拟机使用docker开启了3项服务
Web服务:(http://192.168.67.4:8080/)
测试ssh服务 ssh [email protected]
Console可以查看相关的攻击日志及流量。
网络架构为:
主机ip:192.168.1.107
默认ip:192.168.56.102(需要更改)
Console ip:192.168.1.167
Engine ip:192.168.1.234
攻击案例
场景1:扫描
主机扫描对应日志
端口扫描对应日志
场景2: 中间人攻击
选择SMB服务,ip地址为192.168.67.5。
使用Responder进行LLMNR毒化。使用攻击代码:https://github.com/SpiderLabs/Responder
具体攻击的实现可参考:https://blog.csdn.net/wxh0000mm/article/details/105735032,此处不再赘述。
源码分析
查看add-server-decoys.php文件。核心代码如下:
网络设置:
if ($SSH == 'on' || $RDP == 'on' || $TFTP == 'on' || $VNC == 'on' || $MSSQL == 'on' || $TELNET == 'on' || $SMB == 'on' || $FTP == 'on' || $MYSQL == 'on' || $WEB == 'on' || $MODBUS == 'on' || $SNMP == 'on' || $S7COMM == 'on' || $HONEYCOMB == 'on')
{
// 备份DNS解析器的配置文件
exec('sudo /bin/cp -f /etc/resolv.conf /etc/resolv.conf.bkp',$outputdns,$resultdns);
// 返回获取虚拟网络接口的编号
exec('sudo /sbin/ifconfig | egrep -i virtual[0-9]+ |awk -F "virtual" '{print$2}' |awk -F ":" '{print$1}'|sort -r| head -1|xargs|egrep -o "[0-9]+"',$output,$result);
$current_if_count=$output[0];
if ($current_if_count == false)
{
$current_if_count="999";
}
$new_if_count=$current_if_count + 1;
if (!empty($mac))
{
......
}
exec("sudo /sbin/ifconfig virtual$new_if_count up",$outputconfig,$result);
exec("sudo /bin/ip link set promisc on dev virtual$new_if_count",$outputpromisc,$resultpromisc);
if ($ip_type == 'DHCP')
{
......
}
//后续代码功能:
// 检查新的网络接口,是否正确配置并获取了IP地址
// 配置网络路由和DNS设置
// 在decoys表中插入一条新的记录,记录了一个新的网络接口的相关信息。
以SMB服务为例,如下代码的主要作用是在Docker环境中运行一个SMB服务,并在数据库中更新相关信息。
if ($SMB == 'on') {$dockerip = trim(' ');
#生成一个50字节的随机密码并存储在$password变量中
$password = bin2hex(openssl_random_pseudo_bytes(50));
if (!empty($ipa)) {
#使用Docker运行一个SMB服务, 将$ipa上的139和445端口映射到Docker容器的相应端口上, 并限制其内存使用量为256MB。
exec("sudo /usr/bin/docker run -d --hostname $decoyname --name $decoyname"_smbd" -p $ipa:139:139 -p $ipa:445:445 --memory="256m" -d smbd", $output2, $result);
#使用while循环检查Docker容器的IP地址是否已经获取到
$dockeripcheck = 0;
while ($dockeripcheck == 0) {
global $dockeripcheck;
exec("sudo /usr/bin/docker inspect $decoyname"_smbd" | grep -iw "ipaddress"|head -1|awk -F "\"" '{print$4}'", $outputsmb7, $resultsmb);
$dockerip = $outputsmb7[0];
$dockeripcheck = preg_match('/^[0-9]+.[0-9]+.[0-9]+.[0-9]+/', $outputsmb7[0], $out);
}
#更新基于策略的路由表
exec("sudo /bin/ip rule add from $dockerip/32 table $new_if_count priority 11", $outputadd3, $result);
//
}
exec("sudo /bin/sh ./pipework.sh --direct-phys virtual$new_if_count $decoyname"_smbd" $ipa/$mask@$GW", $output6, $result);
#使用Docker的inspect命令获取日志文件的路径, 并存储在$output3变量中。
exec("sudo /usr/bin/docker inspect $decoyname"_smbd"| grep -i "LogPath"|awk -F "\"" '{print$4}'|sed "s/$//g"", $output3, $result);
#如果$smbdecoyfile为true, 那么获取Docker容器的合并目录, 并在该目录下的 / tmp / files路径解压$smbdecoyfile文件。
if ($smbdecoyfile == true) {
exec("sudo /usr/bin/docker inspect $decoyname"_smbd"| grep -i "MergedDir"|awk -F "\"" '{print$4}'|sed "s/$//g"", $outputsmb10, $resultsmb);
exec("sudo /bin/sh -c "cd $outputsmb10[0]/tmp/files; unzip -o /var/dejavufiles/uploads/$smbdecoyfile"", $outputsmb11, $resultsmb);
}
//
$mysqli = db_connect();
#连接数据库, 更新decoys表中的services字段, 将 'SMB; '
#添加到现有的服务列表中, 并更新smbdecoyfile字段为$smbdecoyfile的值。
$stmt = $mysqli - > prepare("UPDATE decoys set services=CONCAT(services,'SMB; '), smbdecoyfile=? where decoyname=?");
if (!$stmt) {
throw new Exception('Error in preparing statement: '.$mysqli - > error);
}
$stmt - > bind_param("ss", $smbdecoyfile, $decoyname);
$stmt - > execute();
$stmt - > close();
#在decoydetails表中插入一条新的记录, 记录了Docker容器的名称、 服务名、 内部IP地址、 路由表编号和日志文件的路径。
$stmt2 = $mysqli - > prepare("INSERT into decoydetails (decoyname,decoyservicename,decoyinternalip,decoyroutetable,decoylogfile) VALUES(?,'smbd',?,?,?)");
if (!$stmt2) {
throw new Exception('Error in preparing statement: '.$mysqli - > error);
}
$stmt2 - > bind_param("ssss", $decoyname, $dockerip, $new_if_count, $output3[0]);
$stmt2 - > execute();
$stmt2 - > close();
#使用nohup命令在后台运行一个shell脚本 / etc / log.sh, 并将一些参数传递给它。
exec("sudo /usr/bin/nohup /bin/sh /etc/log.sh "smbd" "$output3[0]" "$decoyname" "$decoygroup" "$ipa" "$decoy_type" > /dev/null 2>&1 &", $output, $result);
}
启动服务
各种服务启动docker容器的代码如下:
#SMBexec("sudo /usr/bin/docker run -d --hostname $decoyname --name $decoyname"_smbd" -p $ipa:139:139 -p $ipa:445:445 --memory="256m" -d smbd",$output2,$result);
#FTP
exec("sudo /usr/bin/docker run -d --name $decoyname"_ftpd" -p $ipa:21:21 --memory="256m" -e FTP_USER=$password -e FTP_PASS=$password -e FTP_BANNER='vsFTPd 2.2.2' ftpd",$output2,$result);
#TELNET
exec("sudo /usr/bin/docker run -d --name $decoyname"_telnet" -p $ipa:23:23 --memory="256m" honeyserver",$outputtelnet2,$resulttelnet2);
#MYSQL
exec("sudo /usr/bin/docker run -d --name $decoyname"_mssql" -p $ipa:1433:1433 --memory="256m" honeyserver",$outputmssql2,$resultmssql2);
#RDP
exec("sudo /usr/bin/docker run -d --name $decoyname"_$rdpdecoyimage" -p $ipa:3389:3389 --memory="500m" $rdpdecoyimage $realRDPIP",$outputrdp2,$resultrdp2);
#VNC
exec("sudo /usr/bin/docker run -d --name $decoyname"_vnc" -p $ipa:5000:5000 --memory="256m" honeyserver",$outputvnc2,$resultvnc2);
#TFTP
exec("sudo /usr/bin/docker run -d --name $decoyname"_tftp" -p $ipa:69:69/UDP --memory="256m" honeyserver",$outputtftp2,$resulttftp2);
#SSH
exec("sudo /usr/bin/docker run -d --hostname $decoyname --name $decoyname"_$sshdecoyimage" -p $ipa:22:$sshport --memory="256m" $sshdecoyimage",$outputssh2,$resultssh2);
#HONEYCOMB
exec("sudo /usr/bin/docker run -d --name $decoyname"_honeycomb" -p $ipa:80:80 -p $ipa:443:443 --memory="256m" honeycomb",$outputhoneycomb2,$resulthoneycomb2);
#MYSQL
exec("sudo /usr/bin/docker run -d --name $decoyname"_mysql" -p $ipa:3306:3306 --memory="256m" honeyserver",$outputmysql2,$resultmysql2);
#WEB_tomcat
exec("sudo /usr/bin/docker run -d --name $decoyname"_tomcat" -p $ipa:8080:8080 --memory="256m" tomcat",$outputtomcat2,$resulttomcat2);
#WEB_apache
exec("sudo /usr/bin/docker run -d --name $decoyname"_apache" -p $ipa:80:80 -p $ipa:443:443 --memory="256m" httpd /usr/sbin/apache2ctl -D FOREGROUND",$outputapache2,$resultapache2);
#WEB_iis
exec("sudo /usr/bin/docker run -d --name $decoyname"_iis" -p $ipa:80:80 -p $ipa:443:443 --memory="256m" iis /usr/sbin/apache2ctl -D FOREGROUND",$outputiis2,$resultiis2);
#WEB_basicauth
exec("sudo /usr/bin/docker run -d --name $decoyname"_basicauth" -p $ipa:8080:8080 --memory="256m" basicauth python2.7 /etc/bap.py",$outputbasicauth2,$resultbasicauth2);
#SNMP
exec("sudo /usr/bin/docker run -d --name $decoyname"_snmp" -p $ipa:161:161/udp --memory="256m" ics conpot -f --template default",$outputsnmp2,$resultsnmp2);
关闭服务
manage-decpy.php中,关闭服务
exec("sudo /usr/bin/docker stop $decoyfullname",$output1,$result1);
exec("sudo /usr/bin/docker rm $decoyfullname",$output2,$result2);
exec("sudo /bin/ip rule del from $decoyinternalip table $decoyroutetable",$output3,$result3);
exec("sudo /bin/ip link del virtual$decoyroutetable",$output4,$result4);
exec("sudo /bin/kill -9 `ps auxx| grep -i "$decoylogfile" |awk -F " " '{print$2}'`",$output5,$result5);
Engine下的add-client-decoys-back.php 其主要是进行备份。该项目的github页面上指出其具有多种攻击防御方式,后续会对每种攻击在该系统中的实现进行详细分析。
(Attack) : Port Scan/Enumeration
(Defense) : Fake Services spread out throughout the network
(Attack) : Password Spray/ Brute Force Attack
(Defense) : Deploy multiple common services, attempts on two/more decoys potentially a password spray attempt
(Attack) : Attacker targeting low hanging fruits - Tomcat/MSSQL/Jenkins
(Defense) : Deploy common platforms attackers look for initial foothold
(Attack) : Responsder/ LLMNR Poisoning
(Defense) : NBNS client side decoys to detect MITM attacks
(Attack) : Bloodhound/Similar tools to identify attack path
(Defense) : DNS Records Manipulation and fake servers
(Attack) : Lateral Movement - Pass the Hash
(Defense) : Fake Sessions and Injecting Memory Credentials Tokens
(Attack) : Kerberoast attack
(Defense) : Kerberoasting Service Accounts Honey Tokens
(Attack) : Data Ex-filtration
(Defense) : Honeyfiles to detect ex-filtration occurrences
参考:
项目地址:https://github.com/bhdresh/Dejavu
其他公众号介绍:[https://mp.weixin.qq.com/s/7b8nVOj3omGF6LayHdfMbg](https://mp.weixin.qq.com/s/7b8nVOj3omGF6LayHdfMbg)
2021使用说明:[https://www.youtube.com/watch?v=FhF6fT8OHjA](https://www.youtube.com/watch?v=FhF6fT8OHjA)
2018年blackhat:[https://www.blackhat.com/us-18/arsenal.html#dejavu-an-open-source-deception-framework](https://www.blackhat.com/us-18/arsenal.html#dejavu-an-open-source-deception-framework)
2018DEFCON:[https://defcon.org/html/defcon-26/dc-26-demolabs.html#DejaVU](https://defcon.org/html/defcon-26/dc-26-demolabs.html#DejaVU)
2021年blackhat演讲视频:[https://www.youtube.com/watch?v=CtyTs9KbTOU](https://www.youtube.com/watch?v=CtyTs9KbTOU)
总体描述:可以在云和内网部署。控制台可以显示多个诱饵系统的信息。
Blackhat Europe 指出,可以用诱骗技术去检测攻击手法和技术。[https://www.youtube.com/watch?v=CtyTs9KbTOU](https://www.youtube.com/watch?v=CtyTs9KbTOU)
关于我们
持续更新前沿的研究文章
点击下方名片进入公众号,欢迎关注!
点个小赞你最好看
原文始发于微信公众号(猫蛋儿安全):【深度研究】Dejavy:一款开源诱饵部署平台
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论