Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etersoft-admin-essentials
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etersoft-admin-essentials
Commits
ad0f8f1d
Commit
ad0f8f1d
authored
Aug 11, 2015
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update ddos script
parent
2f779e48
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
28 deletions
+16
-28
load_avg_vz.sh
common/load_avg_vz.sh
+0
-10
check_ddos_ip.sh
ddos/check_ddos_ip.sh
+16
-18
No files found.
common/load_avg_vz.sh
deleted
100755 → 0
View file @
2f779e48
#!/bin/sh
for
id
in
$(
vzlist |
sed
-e
"s| *
\(
[0-9]*
\)
.*|
\1
|g"
)
;
do
CONF
=
/etc/vz/conf/
$id
.conf
test
-r
$CONF
||
continue
eval
`
cat
$CONF
|
grep
^HOSTNAME |
sed
-e
"s|office.etersoft.ru||g"
`
printf
"%4s (%20s):"
$id
$HOSTNAME
vzctl
exec
$id
uptime
done
echo
"---"
uptime
ddos/check_ddos_ip.sh
View file @
ad0f8f1d
#!/bin/bash
#!/bin/bash
cd
/root/bin
cd
/root/bin
IFDEV
=
breth0
# Сколько запросов анализируем за раз
# Сколко запоов анализием за аз
NUMP
=
10000
NUMP
=
10000
# Скол
ко поенов може занима один аде
# Скол
ько процентов может занимать один адрес
MAXPERC
=
15
MAXPERC
=
15
#
акимм в
емени на tcpdmp
#
Максимум вр
емени на tcpdmp
TIMEP
=
15
TIMEP
=
15
get_already_dropped
()
get_already_dropped
()
{
{
/sbin/iptables
-L
-n
|
grep
DROP |
awk
'{print $4;}'
>
ipt.dropped.list
/sbin/iptables
-L
-n
|
grep
DROP |
awk
'{print $4;}'
>
ipt.dropped.list
}
}
do_drop
()
do_drop
()
{
{
grep
-q
"
$1
"
ipt.dropped.list white.list
&&
return
1
grep
-q
"
$1
"
ipt.dropped.list white.list
&&
return
1
echo
"
$1
#
$2
percent,
$(
date
)
"
>>
dropped.list
echo
"
$1
#
$2
percent,
$(
date
)
"
>>
dropped.list
/sbin/iptables
-A
INPUT
-s
$1
-j
DROP
/sbin/iptables
-A
INPUT
-s
$1
-j
DROP
}
}
get_already_dropped
get_already_dropped
SECST
=
$(
date
"+%s"
)
SECST
=
$(
date
"+%s"
)
timeout
-s
SIGQUIT
$TIMEP
/usr/sbin/tcpdump
-n
-c
$NUMP
-f
-i
$IFDEV
dst 212.176.192.225 or dst 212.176.200.17 |
\
timeout
-s
SIGQUIT
$TIMEP
/usr/sbin/tcpdump
-n
-c
$NUMP
-f
-i
inet
dst 212.176.192.225 or dst 212.176.200.17 |
\
awk
'{print $3;}'
|
\
awk
'{print $3;}'
|
\
sed
's/\([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\)\..*/\1/g'
>
full.list
sed
's/\([[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\.[[:digit:]]*\)\..*/\1/g'
>
full.list
SECST
=
$(($(
date
"+%s"
)
-
$SECST
))
SECST
=
$(($(
date
"+%s"
)
-
$SECST
))
NUMP
=
$(
cat
full.list |
wc
-l
)
NUMP
=
$(
cat
full.list |
wc
-l
)
...
@@ -36,12 +34,12 @@ cat full.list | sort | uniq -c | sort -r -n > attack.list
...
@@ -36,12 +34,12 @@ cat full.list | sort | uniq -c | sort -r -n > attack.list
TOTALATTACKED
=
0
TOTALATTACKED
=
0
while
read
c ip
;
do
while
read
c ip
;
do
#echo $c = $ip
#echo $c = $ip
perc
=
$((
100
*
$c
/
$NUMP
))
perc
=
$((
100
*
$c
/
$NUMP
))
if
[
$perc
-gt
$MAXPERC
]
;
then
if
[
$perc
-gt
$MAXPERC
]
;
then
do_drop
$ip
$perc
&&
echo
"Drop IP
$ip
with
$perc
percent traffic"
||
echo
"IP
$ip
already dropped"
do_drop
$ip
$perc
&&
echo
"Drop IP
$ip
with
$perc
percent traffic"
||
echo
"IP
$ip
already dropped"
TOTALATTACKED
=
$((
$TOTALATTACKED
+
$perc
))
TOTALATTACKED
=
$((
$TOTALATTACKED
+
$perc
))
fi
fi
done
< attack.list
done
< attack.list
echo
"Checked packages:
$NUMP
(
$SECST
secs). Traffic:
$((
$NUMP
/
$SECST
))
rps. Atacker percent:
$TOTALATTACKED
"
|
tee
result.out
echo
"Checked packages:
$NUMP
(
$SECST
secs). Traffic:
$((
$NUMP
/
$SECST
))
rps. Atacker percent:
$TOTALATTACKED
"
|
tee
result.out
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment