summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/mbbsd.c18
-rw-r--r--mbbsd/stuff.c21
2 files changed, 39 insertions, 0 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c
index 589554aa..792f75ca 100644
--- a/mbbsd/mbbsd.c
+++ b/mbbsd/mbbsd.c
@@ -1483,6 +1483,7 @@ bind_port(int port)
static int shell_login(int argc, char *argv[], char *envp[]);
static int daemon_login(int argc, char *argv[], char *envp[]);
static int check_ban_and_load(int fd);
+static int check_badip(char *host);
int
main(int argc, char *argv[], char *envp[])
@@ -1708,6 +1709,10 @@ daemon_login(int argc, char *argv[], char *envp[])
close(csock);
getremotename(&xsin, fromhost, remoteusername);
+ if( check_badip(fromhost) ){
+ sleep(10);
+ exit(0);
+ }
telnet_init();
return 1;
}
@@ -1770,6 +1775,19 @@ check_ban_and_load(int fd)
return 0;
}
+static int check_badip(char *host)
+{
+ const unsigned int banip[] = {633,1009038678,1032298394,1039296018,1045135817,1045141443,1045146522,1045149950,1045149967,1045158608,1045159629,1048125300,1050904631,1051859979,1052940049,1053108379,1054112077,1054347447,1056043094,1062584838,1066794770,1070836110,1071923537,1071944402,1074063250,1074083292,1074083326,1075489208,1076016227,1076025623,1077853822,1078644530,1079076048,1079111824,1079113446,1079682122,1079685996,1079984214,1081740395,1082040402,1082453889,1082705931,1083053580,1083053581,1083055955,1083068136,1083073255,1083344605,1088831409,1089876581,1093025996,1096807575,1097163377,1101977914,1103421984,1107176915,1108063014,1110721050,1111466648,1111886389,1113217442,1113224772,1113322479,1113373922,1113382114,1113402741,1113425461,1113434866,1113636908,1113753649,1113772075,1114581897,1115848067,1117774152,1120256468,1120399410,1120402490,1121085691,1121663927,1121690022,1122271003,1122767540,1128530064,1134500635,1135012794,1135293538,1135447854,1135676771,1141170741,1142207674,1143515970,1143521285,1143584363,1144641674,1144959489,1146133398,1146747656,1147064262,1148294836,1148474651,1149196598,1150419377,1150601044,1151748065,1151813564,1151849048,1151849110,1151849155,1151849163,1152070561,1152290181,1153487012,1154098255,1154961799,1155750501,1155911402,1158451621,1158458362,1159670411,1160359620,1161353354,1161590883,1161731083,1164841069,1165040476,1165690270,1166598860,1167362328,1168255657,1168318604,1170378561,1170937115,1171701362,1173973384,1175490060,1175722981,1176278139,1179754272,1179939481,1180480034,1181632238,1182759416,1182804112,1184649196,1185963443,1186682872,1189258321,1189822561,1190540230,1193343820,1194912669,1199054851,1199489002,1199956953,1203817101,1206213296,1207073874,1207268119,1207310646,1208012760,1208219991,1209270694,1209344458,1210356342,1216501158,1218825340,1219581753,1222765174,1222831034,1223175530,1223175531,1241522546,1245917176,1250010691,1258759116,1259420513,1344441061,134689259,1347065008,1347862379,1347912607,1350444388,1350494747,1350517410,1351178913,1351327225,1351728327,1354384237,1354690934,1354691194,1354691202,1354692815,1354693400,1355442311,1355535118,1356673683,1356745546,1356784504,1356818896,1357746750,1357762141,1358086980,1358230143,1358745862,1359012275,1359326305,1359717269,1362631599,1362718537,1362730517,1370063490,1370065057,1370070630,1370074748,1370075271,1370075314,1370075526,1370075863,1370076340,1371458017,1373150675,1373891156,1374114496,1376151807,1377345932,1378751004,1379405935,1380096800,1380132259,1380774425,1381124029,1381818786,1381956558,1382895970,1384173743,1385515093,1385963901,1386582185,1386591344,1386609993,1387109136,1387687283,1390541681,1390625644,1390885676,1391134513,1391377452,1391387013,1391705656,1392042618,1396737916,1396792174,1398107099,1402700662,1403060026,1403755034,1403756911,1403758503,1405269447,1406546563,1406915685,1407151212,1407404039,1407787703,1407803901,1408456837,1408586424,1408948426,1409885092,1409891674,1409924377,1410394415,1410394777,1410395023,1410577730,1410577943,1411548633,1412009828,1412448398,1412913033,1412990513,1413004313,1413038539,1413243236,1413246708,1413292245,1413360537,1414031437,1414073003,1414116862,1417115591,1418566923,1418996608,1419217241,1419276187,1419413080,1419624980,1419796983,1420590936,1421026659,1421075170,1421129130,1423729645,1423787962,1423793480,1423822132,1424887638,1425659230,1426622565,1426768501,1426768746,1426776764,1426780410,1427037310,1427114872,1427706994,1427735671,1427736711,1428142618,1428142678,1428142932,1428142938,1431092705,1437600178,1437745942,1437759009,1437794010,1437996446,1439826300,1439996840,1440092857,1440094857,1440095497,1440095549,1440099454,1440100783,1440103150,1440103182,1440852132,1440899938,1440942724,1441432107,1446517409,1446712614,1455681014,1460597147,1465475993,1466513117,1467616278,1467706444,1467716930,1473854283,1481195590,1481933482,1481935866,1483751335,1483797428,1483810039,1485203105,1488915656,1488918078,1489435922,1500418228,2088298776,2147648687,2147650849,2148549201,2149456915,2151508644,2152952383,2156580657,2158918784,2165674195,2165695574,2176554627,2186911923,2191631745,2209603717,2256681234,2259262604,2259264684,2261779264,2261781242,2306389042,2306389057,2310910653,2313336213,2328543442,2353946503,2356154951,2356418826,2356424963,2356475572,2356898650,2357619472,2365013056,2365013568,2365013623,2370580058,2375385285,2386256229,2386288280,2482713740,2488852665,2500395033,2500401630,2500418754,2500430233,2500447561,2525806444,2533894179,2585994258,2585997115,2586003679,2586006801,2614063587,2677356814,2736247813,2789658370,2789664852,2792301837,2792356135,2828466980,307102044,311952114,314245444,317980786,317980860,318112160,3224007160,3225632660,3239090875,3243817332,3245234951,3250063682,3250996780,3251263491,3252362485,3256170502,3256715587,3261063369,3261951341,3261964705,3261976276,3276235734,3276275718,3277185425,3281954691,3281954907,3282671061,3283221348,3286673503,3287678731,3289080340,3301701415,3332463556,3343745550,3363387287,3375509188,3390899768,3393566277,3396407413,3396486214,3400371611,3402453129,3402616932,3409686647,3409690370,3420075024,3423569323,3423588416,3439174155,3467514649,3470660094,3475813379,3476545746,3482756931,3486665298,3486668144,3486668148,3486672370,3486673433,3490586373,3492338307,3492338312,3492338320,3492338327,3494035974,3496202123,3506972849,3507087555,3509823830,3513220865,3513960577,3517723726,3520956962,3520971047,3520974450,3522299190,3526605869,3545245990,3546201313,3546343681,3549911410,3549913020,3557231659,3558386406,3560741982,3564169059,3564170062,3564170067,3564171657,3564171679,3564171797,3564171935,3564305148,3567828488,3569037497,3570019295,3570028202,3570067714,3572463187,3572677652,3576144460,3579063043,3579076168,3579101268,3580101950,3580165827,3580892904,3580959557,3580991262,3580995315,3581025585,3581063558,3582233947,3582288825,3583144544,3586905730,3587875322,3588024591,3588551055,3589259951,3589262056,3589263022,3589264300,3589264429,3589264517,3589265810,3590181994,3624489557,3625693853,3625996363,3626471961,3627521301,3628797756,3632873814,3638227149,3639060658,3639447343,3639563198,3640550083,3641589830,3641996784,3642543759,3645851707,3645879670,3645917495,3646166834,3646195501,3646245964,3646256112,3648466694,3650310217,3650747396,3650866781,3651166069,3651169389,3651169576,3651175574,3651184412,3651185284,3651186737,3651187062,3651193626,3651197710,3651197980,3651205907,3651940697,3651974682,3651975131,3653517517,3655379603,3658026618,3658875414,3661255580,3669873169,3679337157,3680442328,3682154618,3715546252,3716744875,3738451558,403091818,403290595,403341299,403433871,404032416,404080998,404097098,404457344,405045610,405429290,406546379,406620913,407938789,408660381,409972402,411036682,411572343,412832289,413808504,414371179,414658013,414816791,415745688,415892806,416994429,418260068,418265481,419086569,419367087,644039254,998641561,0};
+ unsigned int thisip = 0;
+ char *ptr, *myhost = strdup(host);
+
+ for( ptr = strtok(myhost, ".") ; ptr != NULL ; ptr = strtok(NULL, ".") )
+ thisip = thisip * 256 + atoi(ptr);
+ free(myhost);
+
+ return uintbsearch(thisip, &banip[1], banip[0]) ? 1 : 0;
+}
+
/* ------- piaip's implementation of TELNET protocol ------- */
enum {
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index 6a37d816..ee645421 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -981,6 +981,27 @@ inline int *intbsearch(int key, const int *base0, int nmemb)
return (NULL);
}
+inline unsigned int *
+uintbsearch(const unsigned int key, const unsigned int *base0, const int nmemb)
+{
+ /* 改自 /usr/src/lib/libc/stdlib/bsearch.c ,
+ 專給搜 int array 用的, 不透過 compar function 故較快些 */
+ const char *base = (const char *)base0;
+ size_t lim;
+ unsigned int *p;
+
+ for (lim = nmemb; lim != 0; lim >>= 1) {
+ p = (unsigned int *)(base + (lim >> 1) * 4);
+ if( key == *p )
+ return p;
+ if( key > *p ){/* key > p: move right */
+ base = (char *)p + 4;
+ lim--;
+ } /* else move left */
+ }
+ return (NULL);
+}
+
int qsort_intcompar(const void *a, const void *b)
{
return *(int *)a - *(int *)b;