ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • OpenWrt: DDos ๊ณต๊ฒฉ์„ Snort ๋กœ ํƒ์ง€
    SECURITY/OpenWrt 2021. 8. 7. 20:59

    OpenWrt ์—์„œ Snort ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ DDos ๊ณต๊ฒฉ์„ ํƒ์ง€ํ•ด๋ณด์•˜๋‹ค.

     

    ์‹คํ—˜ ํ™˜๊ฒฝ ์„ค์ •

    ์šฐ์„ , Docker ๋กœ ์‹ค์Šต ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•œ๋‹ค.

    ๋‹ค์Œ์˜ ๋‘ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค.

    (์ž์„ธํ•œ ์„ค์ • ๋ฐฉ๋ฒ•์€ ์œ„ ํฌ์ŠคํŒ…๊ณผ Kali Linux ๊ณต์‹ docker images ๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉด ๋œ๋‹ค.

    ๊ฐ„๋‹จํ•˜๊ฒŒ ๋ฐ”๋กœ ์„ค์น˜ํ•˜๊ณ  ๋„˜์–ด๊ฐ€์‹œ๋ ค๋ฉด, ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•ด๋„ ๋œ๋‹ค)

    $ docker run -it openwrtorg/rootfs
    $ docker run --tty --interactive kalilinux/kali-rolling /bin/bash

    Kali Linux ๋ฅผ ๊ณต๊ฒฉ์ž๋กœ ์‚ฌ์šฉํ•˜์—ฌ OpenWrt ์— DDos ๊ณต๊ฒฉ์„ ๋‚ ๋ ค๋ณผ ๊ฒƒ์ด๋‹ค!

     

    ๋‹ค์Œ๊ณผ ๊ฐ™์ด ip ์ฃผ์†Œ๋ฅผ ๋จผ์ € ํ™•์ธํ•ด์ฃผ์ž.

    OpenWrt ๋Š” 172.17.0.2 ์ด๊ณ , Kali linux ๋Š” 172.17.0.3 ์ด๋‹ค.

     

     

    * ์ฒ˜์Œ Kali Linux ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋งŒ๋“ค๋ฉด, ifconfig ๋‚˜ hping3 ๊ฐ™์€ ํˆด์ด ์—†๋Š” ์ƒํƒœ์ด๋‹ค.

    ๋”ฐ๋ผ์„œ ๋‹ค์Œ ๋ช…๋ น์–ด๋“ค๋กœ ์„ค์น˜ํ•ด์ฃผ์ž.

    # apt update
    # apt install net-tools
    # apt install hping3

    OpenWrt ์— Snort ์„ค์น˜

    OpenWrt ์—์„œ๋Š” Snort ๊ณต์‹ ํŒจํ‚ค์ง€๋ฅผ ์ง€์›ํ•œ๋‹ค.

    ์ฆ‰, opkg ๋กœ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค!

    $ opkg update #update repo
    $ opkg install snort #install snort

    (https://openwrt.org/docs/guide-user/services/snort)

    ์‹ค์ œ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ๋ช‡๊ฐ€์ง€ ์„ค์ •์„ ํ•ด์ค˜์•ผ ํ•œ๋‹ค.

    snort.conf ํŒŒ์ผ์„ ์ž˜ ์„ค์ •ํ•ด๋‘ฌ์•ผ ํ•˜๋Š”๋ฐ, ํ•ด๋‹น ํŒŒ์ผ์€ rules ํŒŒ์ผ์˜ ์œ„์น˜ ๋“ฑ์„ ์ž‘์„ฑํ•ด๋‘๋Š” Configuration ํŒŒ์ผ์ด๋‹ค.

    Rules ํŒŒ์ผ๋“ค์˜ ์œ„์น˜์™€ IP ์ฃผ์†Œ ๋“ฑ์„ ์ž์‹ ์— ๋งž๊ฒŒ ์„ค์ •ํ•ด์•ผ ํ•œ๋‹ค.

    ํ•ด๋‹น ๋‚ด์šฉ์€ OpenWrt - snort ๋ฌธ์„œ์—์„œ (์œ„ ๋งํฌ) ์ž์„ธํžˆ ์„ค๋ช…ํ•ด์ฃผ๊ณ  ์žˆ์œผ๋‹ˆ, ๋ฉ”๋‰ด์–ผ์— ๋งž๊ฒŒ ๋”ฐ๋ผ๊ฐ€๋ฉด ๋œ๋‹ค.

     

    ๋ฃฐ (rule) ์„ค์ •

    ์•ž์„œ ์„ค๋ช…ํ•œ DDos ๊ณต๊ฒฉ ๊ธฐ๋ฒ•๋“ค์„ ํƒ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๋ฃฐ์„ local.rules ํŒŒ์ผ์— ์ž‘์„ฑํ•œ๋‹ค.

    ๋ฃฐ์˜ ํ˜•ํƒœ๋Š” ๋‹ฌ๋ผ์งˆ ์ˆ˜ ์žˆ์ง€๋งŒ, ๊ธฐ๋ณธ์ ์ธ ๋ฃฐ๋“ค์„ ์ž‘์„ฑํ•ด๋’€๋‹ค.

     

     /etc/snort/rules/local.rules

    # SYN Flooding
    alert tcp any any -> 172.17.0.2 80 (msg:"SYN-Flooding-Detection"; flags: S; threshold: type threshold, track by_dst, count 5, seconds 10; sid: 1000004;)
    
    # UDP Flooding
    alert udp any any -> 172.17.0.2 any (msg:"UDP-Flooding-Detection"; threshold: type threshold, track by_dst, count 10, seconds 1; sid: 1000002;)
    
    # ICMP Flooding
    alert icmp any any -> 172.17.0.2 any (msg:"ICMP-Flooding-Detection"; threshold: type threshold, track by_dst, count 10, seconds 1; sid: 1000003;)

    ๊ฒฐ๊ณผ

    ์œ„์™€ ๊ฐ™์ด rule ์„ ์„ค์ •ํ•œ rules ํŒŒ์ผ๊ณผ ํ•จ๊ป˜ snort ๋ฅผ ์‹คํ–‰์‹œํ‚จ๋‹ค.

    snort -v -c /etc/snort/rules/local.rules --daq-dir /usr/lib/daq

    ์‹คํ–‰ ํ™”๋ฉด

     

    SYN Flooding ์‹ค์Šต

    ๊ทธ๋ฆฌ๊ณ  Kali Linux ์—์„œ hping3 ๋กœ SYN ํŒจํ‚ท์„ ๋ณด๋‚ธ๋‹ค.

    $ hping3 -S --rand-source 172.17.0.2 -p 80 --faster

    * hping3 ์‚ฌ์šฉ๋ฒ•

    -S: SYN ํŒจํ‚ท์„ ๋ณด๋‚ด๋ผ
    -i u50: ์ดˆ๋‹น 50๊ฐœ์˜ ํŒจํ‚ท
    -c 100: 100๊ฐœ์˜ ํŒจํ‚ท๋งŒ ๊ณต๊ฒฉ
    --flood: Flooding
    --rand-source: Source IP ๋ฅผ Random ํ•˜๊ฒŒ ๋ณ€๊ฒฝํ•˜์—ฌ ๊ณต๊ฒฉ
    --faster: 1์ดˆ์— 100๊ฐœ์˜ ํŒจํ‚ท์„ ๋ณด๋‚ด๋ผ
    --fast: 1์ดˆ์— 10๊ฐœ์˜ ํŒจํ‚ท์„ ๋ณด๋‚ด๋ผ
    -1 ๋˜๋Š” --icmp : ICMP ๋ชจ๋“œ

    -2 ๋˜๋Š” --udp: UDP ๋ชจ๋“œ, ์•ˆ์จ์ฃผ๋ฉด TCP

     

    ๋ณด๋‚ด๊ธฐ ์‹œ์ž‘ํ•˜๋ฉด, OpenWrt [snort] ์—์„œ ๋ฐ˜์‘์ด ์˜จ๋‹ค.

     

     

    ์‹คํ–‰์‹œํ‚ค๋‹ค ์ข…๋ฃŒํ•˜๋ฉด, ๋ฐ›์€ ํŒจํ‚ท ๋ถ„์„ ๋‚ด์—ญ์„ ๋ณด์—ฌ์ฃผ๊ณ  Snort ๊ฐ€ ์ข…๋ฃŒํ•œ๋‹ค.

     

     

    ํ•ด๋‹น Alert ๋กœ๊ทธ๋Š” ๋‹ค์Œ์˜ ๊ฒฝ๋กœ์— ์žˆ๋‹ค.

    /var/log/snort

     

    .log. ํŒŒ์ผ๋“ค์€ ๋ฐ”์ด๋„ˆ๋ฆฌ ํŒŒ์ผ๋“ค์ด๊ณ , alert ๋Š” ํ…์ŠคํŠธ ํ˜•์‹์œผ๋กœ ๋œ ํŒŒ์ผ์ด๋‹ค..[?]

     

    alert ํŒŒ์ผ์„ ํ™•์ธํ•ด๋ณด๋ฉด, ์ž‘์„ฑํ•œ rules ์— ๋งž๊ฒŒ alert ๊ฐ€ ๊ธฐ๋ก๋œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

     

    /var/log/snort/alert ํŒŒ์ผ ์ค‘ ์ผ๋ถ€


    UDP Flooding ์‹ค์Šต

    Kali Linux ๋กœ UDP ํŒจํ‚ท์„ ๋ณด๋ƒˆ๋‹ค.

    ์ด๋•Œ, 1์ดˆ์— 50๊ฐœ ๊ทธ๋ฆฌ๊ณ  ์ด 100๊ฐœ์˜ ํŒจํ‚ท์„ ๋ณด๋‚ธ๋‹ค๋Š” ์กฐ๊ฑด์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ณด๋ƒˆ๋‹ค.

    $ hping3 172.17.0.2 --udp --rand-source -i u50 -c 100

    ์ด๋ฅผ ๋ณด๋‚ด๋ฉด, Snort ๊ฐ€ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š” OpenWrt ์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด UDP ํŒจํ‚ท์ด ๋“ค์–ด์˜จ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

     

     

    alert log ํŒŒ์ผ์„ ํ™•์ธํ•ด๋ณด๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์ด UDP-Flooding-Detection ์ด ์ž˜ ํƒ์ง€๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

    ์ด๋•Œ hping3 ๋กœ 100๊ฐœ์˜ ํŒจํ‚ท์„ ๋ณด๋ƒˆ๊ธฐ ๋•Œ๋ฌธ์—, ์ด 10๊ฐœ์˜ alert log ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

    (10๊ฐœ์˜ ํŒจํ‚ท๋งˆ๋‹ค alert ํ•˜๋„๋ก ๋ฃฐ์„ ์„ค์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ)

     

     

    ICMP Flooding ์‹ค์Šต

    ๋งˆ์ง€๋ง‰์œผ๋กœ ICMP Flooding ์„ ์‹ค์Šตํ•˜๊ธฐ ์œ„ํ•ด Kali Linux ๋กœ ICMP ํŒจํ‚ท์„ ๋ณด๋ƒˆ๋‹ค.

    UDP Flooding ์‹ค์Šต๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ 1์ดˆ์— 50๊ฐœ ๊ทธ๋ฆฌ๊ณ  ์ด 100๊ฐœ์˜ ํŒจํ‚ท์„ ๋ณด๋‚ธ๋‹ค๋Š” ์กฐ๊ฑด์„ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ณด๋ƒˆ๋‹ค.

     

    ์‹คํ–‰์‹œํ‚ค๋ฉด, Snort ๊ฐ€ ์‹คํ–‰๋˜๊ณ  ์žˆ๋Š” OpenWrt ์—์„œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ICMP ํŒจํ‚ท์ด ๋“ค์–ด์˜จ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

     

    ๊ทธ๋ฆฌ๊ณ  alert log ํŒŒ์ผ์„ ํ™•์ธํ•ด๋ณด๋ฉด, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ICMP-Flooding-Detection ์ด ์ž˜ ํƒ์ง€๋œ ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

    ์ด ์—ญ์‹œ 100๊ฐœ์˜ ํŒจํ‚ท์„ ๋ณด๋ƒˆ๊ธฐ ๋•Œ๋ฌธ์—, ์ด 10๊ฐœ์˜ alert log ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.

     


    ์ด์ƒ์œผ๋กœ OpenWrt, Snort ๊ทธ๋ฆฌ๊ณ  Kali Linux ๋ฅผ ํ™œ์šฉํ•˜์—ฌ DDos ๊ณต๊ฒฉ์„ ๋ฐœ์ƒ์‹œํ‚ค๊ณ  ์ด๋ฅผ ํƒ์ง€ํ•ด๋ณด์•˜๋‹ค.

     


    ๋ฒˆ์™ธ

    tcpdump ๋กœ๋„ ํŒจํ‚ท ํ™•์ธ๊ฐ€๋Šฅ.

    ์ขŒ: OpenWrt [tcpdump] ์šฐ: Kali Linux

    * tcpdump ๋ฅผ OpenWrt ์—์„œ ์“ฐ๋ ค๋ฉด (https://openwrt.org/docs/guide-user/firewall/misc/tcpdump_wireshark)

    # opkg update
    # opkg install tcpdump

    ๋ฅผ ์‹คํ–‰ํ•ด์ฃผ๋ฉด ์ž˜ ์„ค์น˜๋œ๋‹ค.

    'SECURITY > OpenWrt' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

    OpenWrt: Package ํŒจํ‚ค์ง€ ๋นŒ๋“œ :: Hello, world!  (0) 2021.07.22
    OpenWrt ๋ฅผ docker ๋กœ :: OpenWrt, SDK, Package, ipk, scp  (0) 2021.07.16

    ๋Œ“๊ธ€

Designed by Tistory.