在PHP服务器上使用JavaScript进行缓慢的Loris攻击[及其预防措施!]

Forget the post for a minute, let's begin with what this title is about! This is a web security-based article which will get into the basics about how HTTP works. We'll also look at a simple attack which exploits the way the HTTP protocol works.

暂时忘掉这个帖子,让我们从这个标题开始吧! 这是一篇基于Web安全的文章,将深入介绍HTTP的工作原理。 我们还将研究一种利用HTTP协议工作方式的简单攻击。

什么是HTTP? (What is HTTP?)

HTTP, HyperText Transfer Protocol, is the protocol used by the web for communication. Your device, when you use a browser, uses this particular protocol to send requests to remote servers to request data from them.

HTTP,超文本传输​​协议,是网络用于通信的协议。 您的设备在使用浏览器时,会使用此特定协议将请求发送到远程服务器,以从它们请求数据。

It's basically like you saying to your mom, "Hey mom, I need to eat the item in the fridge present at shelf 2, could you give it to me?"

基本上就像您对妈妈说:“嘿,妈妈,我需要把食物放在架子2上的冰箱里吃,能给我吗?”

And your mom says, "Sure, here you go", and sends you that item. Now, HTTP is the way you were able to communicate this information to your mom, more like the language you used for communication.

然后你妈妈说:“可以,你走了”,然后把那个东西寄给你。 现在,HTTP是您能够向妈妈传达此信息的方式,更像是您用于交流的语言。

HTTP如何工作 (How HTTP Works)

Here's a TL;DR video if you're a video person. Otherwise, proceed with the article:

如果您是视频人,这是TL; DR视频。 否则,请继续阅读本文:

HTTP (Layer 7) is built on the top of TCP protocol (Layer 4). We can use nc (netcat) utility to open a raw TCP socket to any website running on HTTP (usually port 80). See the following example on how we connect to HTTP port 80 for google.com using netcat:

HTTP(第7层)建立在TCP协议(第4层)的顶部。 我们可以使用nc (netcat)实用程序打开原始HTTP套接字,以打开任何在HTTP(通常为端口80)上运行的网站。 请参阅以下示例,了解我们如何使用netcat连接到google.com的HTTP端口80:

See the data we sent:

查看我们发送的数据:

GET / HTTP/1.1
Host: google.com
X-header-1: somemoredata
X-header-2: somemoredata
<empty line>

Ignore the extra X-header-* headers, they're just random headers you can send with your request. The important header to include in HTTP/1.1 spec is the Host header.

忽略多余的X-header-*标头,它们只是您可以随请求发送的随机标头。 要包含在HTTP / 1.1规范中的重要标头是Host标头。

And the response we got:

我们得到的回应是:

HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Tue, 01 Oct 2019 23:24:13 GMT
Expires: Thu, 31 Oct 2019 23:24:13 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 219
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Accept-Ranges: none
Via: HTTP/1.1 forward.http.proxy:3128
Connection: keep-alive<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>

Thus, HTTP is a plaintext protocol consisting of the request information sent by the client and the response as shown above.

因此,HTTP是一个纯文本协议,由客户端发送的请求信息和响应组成,如上所述。

懒猴攻击 (Slow Loris Attack)

A Slow Loris attack exploits the fact that I could make an HTTP request very very slowly. In other words, I can initiate an HTTP request to the server and keep sending data to the server very slowly in order to keep that connection alive. And at the same time, it never ends that connection and opens multiple such connections to exhaust the connection pool of the server.

Slow Loris攻击利用了我可以非常非常缓慢地发出HTTP请求的事实。 换句话说,我可以向服务器发起HTTP请求,并保持非常缓慢的速度向服务器发送数据,以保持连接状态。 同时,它永远不会终止该连接并打开多个此类连接以耗尽服务器的连接池。

Disclaimer - Penetration testing any online/offline service not owned by you without prior written permission is illegal and I'm not responsible for any damage caused. Use this content for educational purposes only.

免责声明 -未经事先书面许可,渗透测试不属于您的任何在线/离线服务是非法的 ,对于由此造成的任何损失,我不承担任何责任。 将此内容仅用于教育目的。

慢劳里斯示范: (Slow Loris Demonstration:)

This means, I could keep on sending additional data to the server in the form of headers. Now, I'll start a simple PHP development server on my machine:

这意味着,我可以继续以标头的形式向服务器发送其他数据。 现在,我将在计算机上启动一个简单PHP开发服务器:

And I use a simple Node script to perform what we discussed above on my local server:

我使用一个简单的Node脚本在本地服务器上执行我们上面讨论的内容:

You can find the Node script used here.

您可以在此处找到使用的Node脚本。

After some time, you'll see that our PHP server actually crashes!

一段时间后,您会看到我们PHP服务器实际上崩溃了!

This is because there are way too many open connections and PHP cannot handle any more open connections (due to memory/hardware limits).

这是因为存在太多的打开连接,而PHP无法处理任何更多的打开连接(由于内存/硬件限制)。

Now, of course this works flawlessly on a local development server. But if you're able to find a server which does not implement protections against slow loris attacks, it is a big problem for them.

现在,这当然可以在本地开发服务器上完美运行。 但是,如果您能够找到未对慢loris攻击实施保护的服务器,那么这对他们来说就是一个大问题。

防止Loris慢速攻击 (Protections against a Slow Loris attack)

  • Use solutions like Cloudflare in front of your servers to prevent DoS/DDoS

    在服务器前使用诸如Cloudflare之类的解决方案来防止DoS / DDoS

    Quoting from Cloudflare's site:

    从Cloudflare网站引用:

Cloudflare buffers incoming requests before starting to send anything to the origin server. As a result, “low and slow” attack traffic like Slowloris attacks never reach the intended target. Learn more about how Cloudflare's DDoS protection stops slowloris attacks.

Cloudflare在开始将任何内容发送到原始服务器之前会缓冲传入的请求 。 结果,像Slowloris攻击这样的“低速和慢速”攻击流量永远不会达到预期的目标。 详细了解Cloudflare的DDoS保护如何阻止慢速龙网攻击。

  • Rate limit number of simultaneous connections open by a particular IP address to a small number. This could be achieved using simple frontend reverse proxy servers like nginx using their leaky bucket algorithm implementation. How that works, is something for another day!

    通过特定IP地址打开的并发连接的速率限制数目很小。 这可以通过使用像nginx这样的简单前端反向代理服务器并使用其泄漏存储桶算法实现来实现。 如何运作,又是另一回事!
  • Increasing the server capacity - Now this might mitigate small attacks, but honestly attacker can and would scale/amplify the original attack quite easily due to the less bandwidth required to carry out such an attack.

    增加服务器容量-现在这可以缓解小型攻击,但老实地说,由于执行此类攻击所需的带宽较小,攻击者可以并且很容易扩展/放大原始攻击。

结论 (Conclusion)

A lot of servers (nginx/apache2 new versions) come with slow loris attack protections by default. But for a lot of internal services, servers might be vulnerable to this simple attack.

默认情况下,许多服务器(新版nginx / apache2)都具有慢loris攻击保护功能。 但是对于许多内部服务而言,服务器可能容易受到这种简单攻击的攻击。

You might want to check your services and implement the fixes. Web security is an exciting area, and I plan to do a web series on it on codedamn. You can connect with me on twitter for updates too. Till then, be safe!

您可能需要检查服务并实施修补程序。 网络安全是一个令人兴奋的领域,我计划在codedamn上进行网络系列开发 。 您也可以在Twitter上与我联系以获取更新。 到那时,要安全!

翻译自: https://www.freecodecamp.org/news/slow-loris-attack-using-javascript-on-php-server/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391334.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

三星为什么要卖芯片?手机干不过华为小米,半导体好挣钱!

据外媒DigiTimes报道&#xff0c;三星有意向其他手机厂商出售自家的Exynos芯片以扩大市场份额。知情人士透露&#xff0c;三星出售自家芯片旨在提高硅晶圆工厂的利用率&#xff0c;同时提高它们在全球手机处理器市场的份额&#xff0c;尤其是中端市场。 三星为什么要卖芯片&…

重学TCP协议(2) TCP 报文首部

1. TCP 报文首部 1.1 源端口和目标端口 每个TCP段都包含源端和目的端的端口号&#xff0c;用于寻找发端和收端应用进程。这两个值加上IP首部中的源端IP地址和目的端IP地址唯一确定一个TCP连接 端口号分类 熟知端口号&#xff08;well-known port&#xff09;已登记的端口&am…

linux:vim中全选复制

全选&#xff08;高亮显示&#xff09;&#xff1a;按esc后&#xff0c;然后ggvG或者ggVG 全部复制&#xff1a;按esc后&#xff0c;然后ggyG 全部删除&#xff1a;按esc后&#xff0c;然后dG 解析&#xff1a; gg&#xff1a;是让光标移到首行&#xff0c;在vim才有效&#xf…

机器学习 预测模型_使用机器学习模型预测心力衰竭的生存时间-第一部分

机器学习 预测模型数据科学 &#xff0c; 机器学习 (Data Science, Machine Learning) 前言 (Preface) Cardiovascular diseases are diseases of the heart and blood vessels and they typically include heart attacks, strokes, and heart failures [1]. According to the …

程序2:word count

本程序改变自&#xff1a;http://blog.csdn.net/zhixi1050/article/details/72718638 语言&#xff1a;C 编译环境&#xff1a;visual studio 2015 运行环境&#xff1a;Win10 做出修改的地方&#xff1a;在原码基础上修改了记录行数的功能&#xff0c;删去了不完整行数的记录&…

重学TCP协议(3) 端口号及MTU、MSS

1. 端口相关的命令 1.1 查看端口是否打开 使用 nc 和 telnet 这两个命令可以非常方便的查看到对方端口是否打开或者网络是否可达。如果对端端口没有打开&#xff0c;使用 telnet 和 nc 命令会出现 “Connection refused” 错误 1.2 查看监听端口的进程 使用 netstat sudo …

Diffie Hellman密钥交换

In short, the Diffie Hellman is a widely used technique for securely sending a symmetric encryption key to another party. Before proceeding, let’s discuss why we’d want to use something like the Diffie Hellman in the first place. When transmitting data o…

高效能程序猿的修炼

下载地址&#xff1a;http://download.csdn.net/detail/xiaole0313/8931785 高效能程序猿的修炼 《高效能程序猿的修炼是人民邮电出版社出版的图书。本书是coding horror博客中精华文章的集合。全书分为12章。涉及迈入职业门槛、高效能编程、应聘和招聘、团队协作、高效工作环境…

Spring 中的 LocalSessionFactoryBean和LocalContainerEntityManagerFactoryBean

Spring和Hibernate整合的时候我们经常会有如下的配置代码 1&#xff0c;非JPA支持的配置 <!-- 配置 Hibernate 的 SessionFactory 实例: 通过 Spring 提供的 LocalSessionFactoryBean 进行配置 --> <!-- FacotryBean 配置的时候返回的不是本身而是返回的FactoryBean 的…

如何通过建造餐厅来了解Scala差异

I understand that type variance is not fundamental to writing Scala code. Its been more or less a year since Ive been using Scala for my day-to-day job, and honestly, Ive never had to worry much about it. 我了解类型差异并不是编写Scala代码的基础。 自从我在日…

linux的/etc/passwd、/etc/shadow、/etc/group和/etc/gshadow

1./etc/passwd 存储用户信息 [rootoldboy ~]# head /etc/passwd root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin 一行记录对应着一个用户&#xff0c;每行记录被冒号:分隔为7个字段&#xff0c;这7个字段的具体含…

组织在召唤:如何免费获取一个js.org的二级域名

之前我是使用wangduanduan.github.io作为我的博客地址&#xff0c;后来觉得麻烦&#xff0c;有把博客关了。最近有想去折腾折腾。先看效果&#xff1a;wdd.js.org 如果你不了解js.org可以看看我的这篇文章:一个值得所有前端开发者关注的网站js.org 前提 已经有了github pages的…

linkedin爬虫_您应该在LinkedIn上关注的8个人

linkedin爬虫Finding great mentors are hard to come by these days. With so much information and so many opinions flooding the internet, finding an authority in a specific field can be quite tough.这些天很难找到优秀的导师。 互联网上充斥着如此众多的信息和众多…

重学TCP协议(4) 三次握手

1. 三次握手 请求端&#xff08;通常称为客户&#xff09;发送一个 S Y N段指明客户打算连接的服务器的端口&#xff0c;以及初始序号。这个S Y N段为报文段1。服务器发回包含服务器的初始序号的 S Y N报文段&#xff08;报文段2&#xff09;作为应答。同时&#xff0c;将确认序…

[设计模式]State模式

《Java与模式》 又称状态对象模式。状态模式是对象的行为模式。GOF95 一个对象的行为取决于一个或者多个动态变化的属性&#xff0c;这样的属性叫做状态。这样的对象叫做有状态的对象&#xff08;stateful&#xff09;。 状态模式把一个所研究的对象的行为包装在不同的状态对象…

java温故笔记(二)java的数组HashMap、ConcurrentHashMap、ArrayList、LinkedList

为什么80%的码农都做不了架构师&#xff1f;>>> HashMap 摘要 HashMap是Java程序员使用频率最高的用于映射(键值对)处理的数据类型。随着JDK&#xff08;Java Developmet Kit&#xff09;版本的更新&#xff0c;JDK1.8对HashMap底层的实现进行了优化&#xff0c;例…

前置交换机数据交换_我们的数据科学交换所

前置交换机数据交换The DNC Data Science team builds and manages dozens of models that support a broad range of campaign activities. Campaigns rely on these model scores to optimize contactability, volunteer recruitment, get-out-the-vote, and many other piec…

aws 弹性三剑客_AWS和弹性:超越用户需求

aws 弹性三剑客I’ll assume that, one way or another, you’re already familiar with many of AWS’s core deployment services. That means you now know about:我假设您已经熟悉许多AWS的核心部署服务。 这意味着您现在知道&#xff1a; • EC2 instances and AMIs (Ama…

leetcode 368. 最大整除子集(dp)

给你一个由 无重复 正整数组成的集合 nums &#xff0c;请你找出并返回其中最大的整除子集 answer &#xff0c;子集中每一元素对 (answer[i], answer[j]) 都应当满足&#xff1a; answer[i] % answer[j] 0 &#xff0c;或 answer[j] % answer[i] 0 如果存在多个有效解子集&a…

在Centos中安装mysql

下载mysql这里是通过安装Yum源rpm包的方式安装,所以第一步是先下载rpm包 1.打开Mysql官网 https://www.mysql.com/, 点击如图选中的按钮 点击如图框选的按钮 把页面拉倒最下面,选择对应版本下载,博主这里用的是CentOS7 下载完成后上传到服务器,由于是yum源的安装包,所以…