diff options
author | dnobori <da.git@softether.co.jp> | 2018-04-20 16:23:18 +0300 |
---|---|---|
committer | dnobori <da.git@softether.co.jp> | 2018-04-20 16:23:18 +0300 |
commit | afa436626920fbbe73738e70b97ae6a50dd96dc5 (patch) | |
tree | ec6d0ed8b7a11699145cad71b1ffc5490c4b6fca /src/Mayaqua | |
parent | c23142a8ffc35088047060989fc3d76c5b4e00af (diff) |
v4.27-9664-betav4.27-9664-beta
Diffstat (limited to 'src/Mayaqua')
-rw-r--r-- | src/Mayaqua/Mayaqua.c | 16 | ||||
-rw-r--r-- | src/Mayaqua/Mayaqua.h | 3 | ||||
-rw-r--r-- | src/Mayaqua/Microsoft.c | 37 | ||||
-rw-r--r-- | src/Mayaqua/Microsoft.h | 1 | ||||
-rw-r--r-- | src/Mayaqua/Network.c | 10 |
5 files changed, 67 insertions, 0 deletions
diff --git a/src/Mayaqua/Mayaqua.c b/src/Mayaqua/Mayaqua.c index 3215243e..6316a770 100644 --- a/src/Mayaqua/Mayaqua.c +++ b/src/Mayaqua/Mayaqua.c @@ -156,6 +156,20 @@ static bool probe_enabled = false; +// The function which should be called once as soon as possible after the process is started
+static bool init_proc_once_flag = false;
+void InitProcessCallOnce()
+{
+ if (init_proc_once_flag == false)
+ {
+ init_proc_once_flag = true;
+
+#ifdef OS_WIN32
+ MsInitProcessCallOnce();
+#endif // OS_WIN32
+ }
+}
+
// Calculate the checksum
USHORT CalcChecksum16(void *buf, UINT size)
{
@@ -490,6 +504,8 @@ void InitMayaqua(bool memcheck, bool debug, int argc, char **argv) return;
}
+ InitProcessCallOnce();
+
g_memcheck = memcheck;
g_debug = debug;
cmdline = NULL;
diff --git a/src/Mayaqua/Mayaqua.h b/src/Mayaqua/Mayaqua.h index 8e6260f0..194f8e62 100644 --- a/src/Mayaqua/Mayaqua.h +++ b/src/Mayaqua/Mayaqua.h @@ -133,6 +133,8 @@ #endif // VPN_SPEED
+void InitProcessCallOnce();
+
#ifdef VPN_EXE
// To build the executable file
#ifdef WIN32
@@ -142,6 +144,7 @@ int main(int argc, char *argv[]); int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, char *CmdLine, int CmdShow)
{
char *argv[] = { CmdLine, };
+ InitProcessCallOnce();
return main(1, argv);
}
#endif // WIN32
diff --git a/src/Mayaqua/Microsoft.c b/src/Mayaqua/Microsoft.c index 2ec1ef2e..c36b2254 100644 --- a/src/Mayaqua/Microsoft.c +++ b/src/Mayaqua/Microsoft.c @@ -273,6 +273,43 @@ typedef struct MS_MSCHAPV2_PARAMS UCHAR ResponseBuffer[MAX_SIZE];
} MS_MSCHAPV2_PARAMS;
+// The function which should be called once as soon as possible after the process is started
+void MsInitProcessCallOnce()
+{
+ // Mitigate the DLL injection attack
+ char system_dir[MAX_PATH];
+ char kernel32_path[MAX_PATH];
+ UINT len;
+ HINSTANCE hKernel32;
+
+ // Get the full path of kernel32.dll
+ memset(system_dir, 0, sizeof(system_dir));
+ GetSystemDirectory(system_dir, sizeof(system_dir));
+ len = lstrlenA(system_dir);
+ if (system_dir[len] == '\\')
+ {
+ system_dir[len] = 0;
+ }
+ wsprintfA(kernel32_path, "%s\\kernel32.dll", system_dir);
+
+ // Load kernel32.dll
+ hKernel32 = LoadLibraryA(kernel32_path);
+ if (hKernel32 != NULL)
+ {
+ BOOL (WINAPI *_SetDllDirectoryA)(LPCTSTR);
+
+ _SetDllDirectoryA = (BOOL (WINAPI *)(LPCTSTR))
+ GetProcAddress(hKernel32, "SetDllDirectoryA");
+
+ if (_SetDllDirectoryA != NULL)
+ {
+ _SetDllDirectoryA("");
+ }
+
+ FreeLibrary(hKernel32);
+ }
+}
+
// Collect the information of the VPN software
bool MsCollectVpnInfo(BUF *bat, char *tmpdir, char *svc_name, wchar_t *config_name, wchar_t *logdir_name)
{
diff --git a/src/Mayaqua/Microsoft.h b/src/Mayaqua/Microsoft.h index 56c0032e..11fead6a 100644 --- a/src/Mayaqua/Microsoft.h +++ b/src/Mayaqua/Microsoft.h @@ -1160,6 +1160,7 @@ void MsTest(); bool MsSaveSystemInfo(wchar_t *dst_filename);
bool MsCollectVpnInfo(BUF *bat, char *tmpdir, char *svc_name, wchar_t *config_name, wchar_t *logdir_name);
+void MsInitProcessCallOnce();
MS_SUSPEND_HANDLER *MsNewSuspendHandler();
void MsFreeSuspendHandler(MS_SUSPEND_HANDLER *h);
diff --git a/src/Mayaqua/Network.c b/src/Mayaqua/Network.c index f5c12825..729aaf5f 100644 --- a/src/Mayaqua/Network.c +++ b/src/Mayaqua/Network.c @@ -19750,6 +19750,8 @@ LIST *GetHostIPAddressListInternal() struct addrinfo hint;
struct addrinfo *info;
+// Debug("***** GetHostIPAddressListInternal IPv4 Begin *****\n");
+
Zero(&hint, sizeof(hint));
hint.ai_family = AF_INET;
hint.ai_socktype = SOCK_DGRAM;
@@ -19771,12 +19773,15 @@ LIST *GetHostIPAddressListInternal() InAddrToIP(&ip, &addr);
AddHostIPAddressToList(o, &ip);
+// Debug("%r\n", &ip);
+
current = current->ai_next;
}
}
freeaddrinfo(info);
}
+// Debug("***** GetHostIPAddressListInternal IPv4 End *****\n");
}
#ifndef UNIX_LINUX
@@ -19794,6 +19799,8 @@ LIST *GetHostIPAddressListInternal() hint.ai_protocol = IPPROTO_UDP;
info = NULL;
+// Debug("***** GetHostIPAddressListInternal IPv6 Begin *****\n");
+
if (getaddrinfo(hostname, NULL, &hint, &info) == 0)
{
if (info->ai_family == AF_INET6)
@@ -19811,12 +19818,15 @@ LIST *GetHostIPAddressListInternal() AddHostIPAddressToList(o, &ip);
+// Debug("%r\n", &ip);
+
current = current->ai_next;
}
}
freeaddrinfo(info);
}
+// Debug("***** GetHostIPAddressListInternal IPv6 End *****\n");
}
#endif // UNIX_LINUX
#endif // MAYAQUA_SUPPORTS_GETIFADDRS
|