当前位置:网站首页>Solve DoS attack production cases
Solve DoS attack production cases
2022-07-06 18:39:00 【JohnnyFang】
The requirements of this experiment are : according to web Number of log or network connections , Monitor when a IP Number of concurrent connections or in a short time PV achieve 100, Call the firewall command to block the corresponding IP, Monitoring frequency every 5 minute . The firewall command is :iptables -A INPUT -s IP -j REJECT.
Because the monitoring frequency is every 5 Minutes at a time , We can use scripts + Plan tasks to operate .
- Create script
First, create two files to store the ip Situation and forbidden ip Information , Then create the script dos.sh. Script ,ss -nt | awk -F" +|:" '/ESTAB/{print $6}' | sort | uniq -c The command can filter out the currently connected hosts Ip And number of connections , We input this information into dos.txt in , And then use it exec Command from the dos.txt The information is read from the file ; At the same time, we will single ip Number of connections and ip Set as variables respectively $nums and $ip, When reading line by line , If $nums achieve 100( Greater than or equal to -ge), Will ip Prohibition , At the same time dos_drop.txt write in $ip is dorpped( Here's the picture ).

perform chmod +x dos.sh Command gives script execution permission , perform bash dos.sh Command view effect , Because of the problem of the author's experiment , So for the time being, there is only dos.txt There are records in the document ( Here's the picture ).


In order to see the effect as soon as possible , The author first sets the upper limit of the number of connections to 3, After execution ,dos_drop.txt There are also records in the document ( Here's the picture ).
* So in the above script , Better add “sleep 10” Or a longer time limit , Otherwise, it will be banned all the time ip Enter information into dos_drop.txt In file , It may cause the remote connection to crash .



- Create a scheduled task
The creation of planned tasks was mentioned in the homework of last week , I won't go into details here , perform crontab -e Command to create a scheduled task , In case of unclear , Write directly above PATH route , Because it's every 5 Once per minute , The first part of the planning task is */5( Here's the picture ).

To this step , We can let the host check by itself according to the time ip Connection , And count the information into the corresponding file to view .
边栏推荐
- Penetration test information collection - site architecture and construction
- Grafana 9.0 is officially released! It's the strongest!
- 首先看K一个难看的数字
- With the implementation of MapReduce job de emphasis, a variety of output folders
- DOM Brief
- Introduction and case analysis of Prophet model
- Splay
- C language college laboratory reservation registration system
- Cocos2d Lua smaller and smaller sample memory game
- 视频化全链路智能上云?一文详解什么是阿里云视频云「智能媒体生产」
猜你喜欢

Alibaba cloud international ECS cannot log in to the pagoda panel console

Summary of performance knowledge points

SAP Fiori 应用索引大全工具和 SAP Fiori Tools 的使用介绍

Splay

Penetration test information collection - WAF identification

Jushan database was among the first batch of financial information innovation solutions!

Easy to use PDF to SVG program

爬虫玩得好,牢饭吃到饱?这3条底线千万不能碰!
![[Matlab] Simulink 同一模块的输入输出的变量不能同名](/img/99/adfe50075010916439cd053b8f04c7.png)
[Matlab] Simulink 同一模块的输入输出的变量不能同名

44 colleges and universities were selected! Publicity of distributed intelligent computing project list
随机推荐
一种用于夜间和无袖测量血压手臂可穿戴设备【翻译】
Alibaba cloud international ECS cannot log in to the pagoda panel console
Windows connects redis installed on Linux
Stm32+mfrc522 completes IC card number reading, password modification, data reading and writing
Cobra 快速入门 - 专为命令行程序而生
Cocos2d Lua 越来越小样本 内存游戏
使用cpolar建立一个商业网站(1)
Reproduce ThinkPHP 2 X Arbitrary Code Execution Vulnerability
Recursive way
There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed
AvL树的实现
Crawling data encounters single point login problem
被疫情占据的上半年,你还好么?| 2022年中总结
Transport layer congestion control - slow start and congestion avoidance, fast retransmission, fast recovery
STM32+MFRC522完成IC卡号读取、密码修改、数据读写
2022/02/12
Execution process of MySQL query request - underlying principle
ADB common commands
The role of applet in industrial Internet
随着MapReduce job实现去加重,多种输出文件夹