在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.pswp.cn/news/391334.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391334.shtml
英文地址,請注明出處:http://en.pswp.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源的安裝包,所以…