Archive

Archive for May, 2023

Hardening web server อีกหน่อย

May 10th, 2023 Comments off

จริง ๆ ผมไม่ได้เก่งอะไรหรือมีประสบการณ์อะไรมากมาย แต่ช่วงที่ผ่านมา mail มีแจ้งว่าถูก login

จากบราซิลก็เลยระแวงว่า web โดนแฮครึเปล่า ก็คิดจนตกผลึกละว่าน่าจะเพิ่มเรื่องความปลอดภัยอีกหน่อย

ซึ่งผมทำเพิ่มอีกแบบนี้ครับ

  • ตัว firewall ผมใช้ ufw ผมเปลี่ยน rule ให้ deny outgoing เป็น default อย่างน้อยน่าจะกันพวก reverse shell ได้
  • เพิ่มจำนวน history ให้มากขึ้นจากเดิม 1000 ผมเพิ่มเป็น 2500
  • monitor ตัว web dir ให้แจ้งเตือนกรณีมีการสร้างไฟล์หรือแก้ไข ซึ่งผมใช้ inotifywait ตัว bash ก็ให้ run หลัง reboot //ยังไม่สำเร็จ

#!/bin/bash
inotifywait -m /xxx/yyy -e create -e moved_to |
while read dir action file; do
python /home/pi/bots/alert.py
# do something with the file
done

Categories: Uncategorized Tags: