当前位置:网站首页>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 .
边栏推荐
- Afnetworking framework_ Upload file or image server
- Execution process of MySQL query request - underlying principle
- C language college laboratory reservation registration system
- 图之广度优先遍历
- Transport layer congestion control - slow start and congestion avoidance, fast retransmission, fast recovery
- Specify flume introduction, installation and configuration
- 一种用于夜间和无袖测量血压手臂可穿戴设备【翻译】
- Self supervised heterogeneous graph neural network with CO comparative learning
- node の SQLite
- DOM简要
猜你喜欢

There is a sound prompt when inserting a USB flash disk under win10 system, but the drive letter is not displayed

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

The third season of Baidu online AI competition is coming in midsummer, looking for you who love AI!

Mathematics in machine learning -- common probability distribution (XIII): Logistic Distribution

Introduction and case analysis of Prophet model

Self-supervised Heterogeneous Graph Neural Network with Co-contrastive Learning 论文阅读

被疫情占据的上半年,你还好么?| 2022年中总结

SQL injection - access injection, access offset injection

当保存参数使用结构体时必备的开发技巧方式

【LeetCode第 300 场周赛】
随机推荐
被疫情占据的上半年,你还好么?| 2022年中总结
测试1234
线代笔记....
JDBC驱动器、C3P0、Druid和JDBCTemplate相关依赖jar包
图片缩放中心
SQL injection - access injection, access offset injection
bonecp使用数据源
Collection of penetration test information -- use with nmap and other tools
安装及管理程序
Alibaba cloud international ECS cannot log in to the pagoda panel console
2022 Summer Project Training (III)
From 2022 to 2024, the list of cifar azrieli global scholars was announced, and 18 young scholars joined 6 research projects
Automatic reservation of air tickets in C language
[.Net core] solution to error reporting due to too long request length
Bonecp uses data sources
十、进程管理
[Sun Yat sen University] information sharing of postgraduate entrance examination and re examination
Huawei 0 foundation - image sorting
Maixll dock camera usage
用友OA漏洞学习——NCFindWeb 目录遍历漏洞