diff --git a/SKSocks-server/SKSocks-server.cpp b/SKSocks-server/SKSocks-server.cpp index 2a7f4e3..a2329b6 100644 --- a/SKSocks-server/SKSocks-server.cpp +++ b/SKSocks-server/SKSocks-server.cpp @@ -278,6 +278,23 @@ class SKCommonApp return close(toClose); #endif } + + BOOL isIPLAN(const string ipstring) + { + istringstream st(ipstring); + int ip[2]; + for (int i = 0; i < 2; i++) + { + string temp; + getline(st, temp, '.'); + istringstream a(temp); + a >> ip[i]; + } + if ((ip[0] == 10) || (ip[0] == 172 && ip[1] >= 16 && ip[1] <= 31) || (ip[0] == 192 && ip[1] == 168)) + return TRUE; + else return FALSE; + } + public: // 成员变量和函数声明 }; @@ -315,6 +332,14 @@ class SKServerApp:public SKCommonApp * 建议添加IP过滤规则,防止恶意利用。 */ + if (isIPLAN(IPAddr)) + { +#ifdef _DEBUG + cout << "禁止访问内网资源!" << CPPFAILED_INFO << endl; +#endif // _DEBUG + return INVALID_SOCKET; + } + int theFlagV6 = AF_INET; if (isIPV6)theFlagV6 = AF_INET6; @@ -375,6 +400,7 @@ class SKServerApp:public SKCommonApp void AddUser(string UNAME, string PWD) { + // 有空建议使用 非可逆加密 加密一下密码。 userMap[UNAME] = PWD; }