Jump to content
×
×
  • Create New...

Metin2 Server Config & FreeBSD Shell Script


Recommended Posts

Hello I made today simple freebsd stuffs..

 

My first release on  forum ^_^ 

 

#!/bin/bash
clear
echo -e "033[31m#-------------- Welcome to Galactica Gaming FreeBSD Shell Script  --------------------#"
echo -e "033[31m#-------------- Made By : Mehti  --------------------#"
echo "#-----------------------------------------------------------------#"
echo -e "033[33m#----------------SECURiTY BiTCHEZ----------------#" 
echo "# (1) Check Server Ram                                           #" 
echo "# (2) DDoS Attack Counts + Attacks IP               #"
echo "# (3) Who Login my Server??!?!                           #"
echo "# (4) YouHaveANoobAttacker? Try IP Ban :H                                                 #"
echo "# (5) Last Connection                               #"
echo "# (6) Check Online User Count                                     #"
echo "#-----------------------------------------------------------------#"
echo -e "033[34m#-------------- QUEST PANEL ---------------#"
echo "# (7) Update Quest Cache                                             #" 
echo "#-----------------------------------------------------------------#"
echo "# (8) MAX_LEVEL CONFIG                                   #"
echo "# (9) Max_LEVEL_STATUS CONFIG                      #"
echo "# (10) MAX_STATUS CONFIG                              #"
echo "# (11) SKILL_BOOK_READ_TIME CONFIG                  #"
echo "# (12) SKILL_BOOK_READ_EXP CONFIG                  #"
echo "# (13) MAX_GUILD_LEVEL CONFIG                #"
echo "# (14) ITEM_OWNER_TIME CONFIG                       #"
echo "# (15) SKILL_BOOK_ALWAYS#"
echo "# (16) ALWAYS BONUS ADD CONFIG  : 1 YES 0 NO             #"
echo "# (17) BONUS CHANGE LIMIT TIME CONFIG                #"
echo "# (18) GOLD DROP TIME CONFIG                         #"
echo -e "033[31m#033[33m-----------------------------------------------------------------033[31m#"
echo -e "033[31m#033[34m########################033[32m SERVER PORTS STATUS 033[34m ######################033[31m#033[0m"
netstat -ln | grep ".13000 " | wc -l | awk '{if ($1 == 0) system("echo -e 033[31m#033[36m#########################  1.033[0m Kanal 033[31mOfline 033[36m########################033[0m") }'
netstat -ln | grep ".13000 " | wc -l | awk '{if ($1 > 0) system("echo -e 033[31m#033[36m#########################   1.033[0m Kanal 033[32mOnline  033[36m########################033[0m") }'
netstat -ln | grep ".13010" | wc -l | awk '{if ($1 == 0) system("echo -e 033[31m#033[36m#########################  2.033[0m Kanal 033[31mOfline 033[36m########################033[0m") }'
netstat -ln | grep ".13010 " | wc -l | awk '{if ($1 > 0) system("echo -e 033[31m#033[36m#########################   2.033[0m Kanal 033[32mOnline   033[36m########################033[0m") }'
netstat -ln | grep ".13020 " | wc -l | awk '{if ($1 == 0) system("echo -e 033[31m#033[36m#########################  3.033[0m Kanal 033[31mOfline 033[36m########################033[0m") }'
netstat -ln | grep ".13020 " | wc -l | awk '{if ($1 > 0) system("echo -e 033[31m#033[36m#########################   3.033[0m Kanal 033[32mOnline   033[36m########################033[0m") }'
netstat -ln | grep ".13030 " | wc -l | awk '{if ($1 == 0) system("echo -e 033[31m#033[36m#########################  4.033[0m Kanal 033[31mOfline 033[36m########################033[0m") }'
netstat -ln | grep ".13030 " | wc -l | awk '{if ($1 > 0) system("echo -e 033[31m#033[36m#########################   4.033[0m Kanal 033[32mOnline   033[36m########################033[0m") }'
echo -e "033[31m#033[33m-----------------------------------------------------------------033[31m#"


echo Select Number :
read  secenek 


case $secenek in


1)
clear
echo "Checking Ram.."
sleep 3
dmesg | grep memory
echo "Real Memory is Your Ram."
;;
2)
clear
echo "Checking DDOS Attacks.."
sleep 3
netstat -np | grep SYN_RECV | awk '{print $5}' | cut -d. -f1-4 | cut -d: -f1 | sort -n | uniq -c | sort -n
echo "Attacks and IP"
;;
3)
who
;;
4)
clear
echo "Opening IP Ban Screen~"
sleep 3
echo Use " Ctrl+C " to Exit.
echo -n "IP: "
read ip
echo ""
echo '$IP'F 1 deny all from $ip to me >> /etc/ipfw.rules
/etc/rc.d/ipfw restart
echo "Successfuly Banned: "$ip" ~ "
sleep 4
clear
/etc/rc.d/ipfw restart
sh /etc/ipfw.rules
cd /bin
sleep 2
neta
;;
5)
clear
echo "Opening Last Connection on Server.."
sleep 3
last
;;
6)
clear
echo "Calculating Number of Online Players."
sleep 3
echo "First_Channel;"
netstat -nat | grep 13000 | grep ESTABLISHED | wc -l
netstat -nat | grep 13002 | grep ESTABLISHED | wc -l
echo "MapServer_Cores;"
netstat -nat | grep 13099 | grep ESTABLISHED | wc -l
netstat -nat | grep 13100 | grep ESTABLISHED | wc -l
netstat -nat | grep 13001 | grep ESTABLISHED | wc -l
;;
7)
clear
echo "Cleaning and RE-Build Quest Cache"
sleep 3
cd /usr/home/game/share/locale/germany/quest && ./make.sh
echo "Succesfully ReBuild Cache"
;;
8)
echo -n " MAX_LEVEL CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo MAX_LEVEL: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo MAX_LEVEL: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo MAX_LEVEL: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo MAX_LEVEL: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo MAX_LEVEL: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo MAX_LEVEL: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo MAX_LEVEL: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo MAX_LEVEL: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo MAX_LEVEL: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
9)
echo -n " MAX_LEVEL_STATUS CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo MAX_LEVEL_STATUS: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
10)
echo -n " MAX_STATUS CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo MAX_STATUS: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo MAX_STATUS: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo MAX_STATUS: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo MAX_STATUS: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo MAX_STATUS: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo MAX_STATUS: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo MAX_STATUS: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo MAX_STATUS: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo MAX_STATUS: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
11)
echo -n " SKILLBOOK_DELAY CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo SKILLBOOK_DELAY: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo SKILLBOOK_DELAY: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo SKILLBOOK_DELAY: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo SKILLBOOK_DELAY: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo SKILLBOOK_DELAY: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo SKILLBOOK_DELAY: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo SKILLBOOK_DELAY: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo SKILLBOOK_DELAY: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo SKILLBOOK_DELAY: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
12)
echo -n " SKILLBOOK_NEED_EXP CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo SKILLBOOK_NEED_EXP: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
13)
echo -n " guild_max_level CONFIG "
echo -n " Maximum Guild Level Max is : 50 Min : 1 "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo guild_max_level: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo guild_max_level: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo guild_max_level: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo guild_max_level: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo guild_max_level: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo guild_max_level: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo guild_max_level: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo guild_max_level: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo guild_max_level: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
14)
echo -n " item_owner_time CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo item_owner_time: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo item_owner_time: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo item_owner_time: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo item_owner_time: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo item_owner_time: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo item_owner_time: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo item_owner_time: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo item_owner_time: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo item_owner_time: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
15)
echo -n " SKILLBOOK_ALWAYS_BOOK  CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo SKILLBOOK_ALWAYS_BOOK: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
16)
echo -n " attr_always_add CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo attr_always_add: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo attr_always_add: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo attr_always_add: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo attr_always_add: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo attr_always_add: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo attr_always_add: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo attr_always_add: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo attr_always_add: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo attr_always_add: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
17)
echo -n " attr_change_limit CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo attr_change_limit: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo attr_change_limit: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo attr_change_limit: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo attr_change_limit: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo attr_change_limit: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo attr_change_limit: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo attr_change_limit: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo attr_change_limit: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo attr_change_limit: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
18)
echo -n " gold_drop_time_interval CONFIG "
read ip
echo "All Server Closig Now.."
cd /usr/home/game/ && ./close.sh
echo gold_drop_time_interval: $ip >> /usr/home/game/auth_server/CONFIG #auth
echo gold_drop_time_interval: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re1/CONFIG # channel1 core1
echo gold_drop_time_interval: $ip >> /usr/home/game/first_channel/mehti_channelz_c0re2/CONFIG # channel1 core2
echo gold_drop_time_interval: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core1/CONFIG    # MapServer Core1
echo gold_drop_time_interval: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core2/CONFIG # MapServer Core2
echo gold_drop_time_interval: $ip >> /usr/home/game/game_map_server/Mehti_Map_Core3/CONFIG # MapServer Core3
# echo gold_drop_time_interval: $ip >> /usr/home/game/channel2/CONFIG #Channel2
# echo gold_drop_time_interval: $ip >> /usr/home/game/channel3/CONFIG #Channel3
# echo gold_drop_time_interval: $ip >> /usr/home/game/channel4/CONFIG #Channel4
echo "IT'S OK. Now Closing Server and Cleaning Logs."
cd /usr/home/game/ && ./clear.sh
;;
*)
echo "You have selected and incorrent option"
esac

Note: Some Game core configs for Vanilla sources.

 

Regards, Mehti.

  • Love 2
Link to comment
Share on other sites

Well some suggestions for your script stuff:

  • Don't do ipfw restart when adding IP bans, this will break all your dynamic rules, e.g. if you have anything like

    allow tcp from any to me 13001 setup keep-state
    all your clients will be kicked as the dynamic rules table is flushed and no packets of already open connections will match setup (which is for reason).
  • Don't just append the rule for an IP ban to the ipfw.rules file with rule number 1, this is dirty and unperformant.

    Rather use an IPFW table:

    /etc/ipfw.rules:

    ipfw add <XXX> deny all from "table(1)" to me ## <XXX> is some rule number smaller than your allow rules
    # Load blacklist from file:
    while read line
    do
        ipfw table 1 add $line
    done < /etc/ipfw.blacklist
    
    Ban command:

    ipfw table 1 add $ip
    echo $ip >> /etc/ipfw.blacklist
    
    Unban command:

    ipfw table 1 delete $ip
    ipfw table 1 list | awk '{print $1;}' > /etc/ipfw.blacklist ## awk removes the value from ipfw table command output
    With this you can even ban whole ranges like e.g. 192.168.0.0/16. Though you cannot remove a single IP out of this range but only the whole range at once.
  • Love 4
Link to comment
Share on other sites

Well some suggestions for your script stuff:

  • Don't do ipfw restart when adding IP bans, this will break all your dynamic rules, e.g. if you have anything like

    allow tcp from any to me 13001 setup keep-state
    all your clients will be kicked as the dynamic rules table is flushed and no packets of already open connections will match setup (which is for reason).
  • Don't just append the rule for an IP ban to the ipfw.rules file with rule number 1, this is dirty and unperformant.

    Rather use an IPFW table:

    /etc/ipfw.rules:

    ipfw add <XXX> deny all from "table(1)" to me ## <XXX> is some rule number smaller than your allow rules
    # Load blacklist from file:
    while read line
    do
        ipfw table 1 add $line
    done < /etc/ipfw.blacklist
    
    Ban command:

    ipfw table 1 add $ip
    echo $ip >> /etc/ipfw.banlist
    
    Unban command:

    ipfw table 1 delete $ip
    ipfw table 1 list | awk '{print $1;}' > /etc/ipfw.blacklist ## awk removes the value from ipfw table command output
    With this you can even ban whole ranges like e.g. 192.168.0.0/16. Though you cannot remove a single IP out of this range but only the whole range at once.

 

Thank you for the correction :)

Link to comment
Share on other sites

  • 2 months later...
  • Recently Browsing   0 members

    • No registered users viewing this page.


Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.