فهرست منبع

- DNSBL. Refer to changelog.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6258 54d463be-8e91-2dee-dedb-b68131a5f0ec
Zido 19 سال پیش
والد
کامیت
e79642ff57
4فایلهای تغییر یافته به همراه72 افزوده شده و 0 حذف شده
  1. 3 0
      Changelog-Trunk.txt
  2. 3 0
      conf-tmpl/login_athena.conf
  3. 34 0
      src/login/login.c
  4. 32 0
      src/login_sql/login.c

+ 3 - 0
Changelog-Trunk.txt

@@ -2,7 +2,10 @@ Date	Added
 
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
+
 2006/04/24
+	* Added DNS Blocklist support. Set in login_athena.conf.
+	  I'll make it more customizable tomorrow, I coded it pretty bad. [Zido]
 	* Corrected mob_spawn_delay/boss_spawn_delay/plant_spawn_delay settings
 	  (they were named rate rather than delay in monster.conf) [Skotlex]
 	* Cleaned up @grind2, @monsterbig, @monstersmall. [Skotlex]

+ 3 - 0
conf-tmpl/login_athena.conf

@@ -179,4 +179,7 @@ dynamic_pass_failure_ban_how_long: 60
 dynamic_account_ban: 1
 dynamic_account_ban_class: 0
 
+//DNS Blacklist Blocking (on: 1, off: 0)
+use_dnsbl: 0
+
 import: conf/import/login_conf.txt

+ 34 - 0
src/login/login.c

@@ -69,6 +69,8 @@ struct _subnet {
 
 int subnet_count = 0;
 
+int use_dnsbl=0;
+
 char account_filename[1024] = "save/account.txt";
 char GM_account_filename[1024] = "conf/GM_account.txt";
 char login_log_filename[1024] = "log/login.log";
@@ -1153,9 +1155,39 @@ int mmo_auth(struct mmo_account* account, int fd) {
 	char ip[16];
 	unsigned char *sin_addr = (unsigned char *)&session[fd]->client_addr.sin_addr;
 	char user_password[256];
+	char r_ip[16]; // [Zido]
+	char ip_dnsbl[256]; // [Zido]
 
 	sprintf(ip, "%d.%d.%d.%d", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]);
 
+	// Start DNS Blacklist check [Zido]
+	if(use_dnsbl) {
+		sprintf(r_ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]);
+		
+		sprintf(ip_dnsbl,"%s.opm.blitzed.org",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+		sprintf(ip_dnsbl,"%s.sbl.deltaanime.net",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+		sprintf(ip_dnsbl,"%s.dnsbl.njabl.org",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+		sprintf(ip_dnsbl,"%s.sbl-xbl.spamhaus.org",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+	}
+	// End DNS Blacklist check [Zido]
+
+
 	len = strlen(account->userid) - 2;
 	// Account creation with _M/_F
 	if (account->passwdenc == 0 && account->userid[len] == '_' &&
@@ -3740,6 +3772,8 @@ int login_config_read(const char *cfgName) {
 					online_check = atoi(w2);
 			} else if (strcmpi(w1, "import") == 0) {
 				login_config_read(w2);
+			} else if(strcmpi(w1,"use_dnsbl")==0) { // [Zido]
+				use_dnsbl=atoi(w2);
 			}
 		}
 	}

+ 32 - 0
src/login_sql/login.c

@@ -64,6 +64,7 @@ void Gettimeofday(struct timeval *timenow)
 //-----------------------------------------------------
 // global variable
 //-----------------------------------------------------
+int use_dnsbl=0; // [Zido]
 int server_num;
 int new_account_flag = 0; //Set from config too XD [Sirius]
 int bind_ip_set_ = 0;
@@ -588,6 +589,35 @@ int mmo_auth( struct mmo_account* account , int fd){
 
 	unsigned char *sin_addr = (unsigned char *)&session[fd]->client_addr.sin_addr;
 
+	char r_ip[16]; // [Zido]
+	char ip_dnsbl[256]; // [Zido]
+
+	// Start DNS Blacklist check [Zido]
+	if(use_dnsbl) {
+		sprintf(r_ip, "%d.%d.%d.%d", sin_addr[3], sin_addr[2], sin_addr[1], sin_addr[0]);
+		
+		sprintf(ip_dnsbl,"%s.opm.blitzed.org",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+		sprintf(ip_dnsbl,"%s.sbl.deltaanime.net",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+		sprintf(ip_dnsbl,"%s.dnsbl.njabl.org",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+		sprintf(ip_dnsbl,"%s.sbl-xbl.spamhaus.org",r_ip);
+		if(gethostbyname(ip_dnsbl)!=NULL) {
+			ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n",r_ip);
+			return 3;
+		}
+	}
+	// End DNS Blacklist check [Zido]
 
 	sprintf(ip, "%d.%d.%d.%d", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]);
 	//ShowInfo("auth start for %s...\n", ip);
@@ -2136,6 +2166,8 @@ int login_config_read(const char *cfgName){
 				log_login = atoi(w2);
 		} else if (strcmpi(w1, "import") == 0) {
 			login_config_read(w2);
+		} else if(strcmpi(w1,"use_dnsbl")==0) { // [Zido]
+			use_dnsbl=atoi(w2);
 		}
  	}
 	fclose(fp);