Repository: hxsecurity/dongtai-agent-java
Issue: [Bug]: agent在wndows下运行时，无法注册，报错

### Preflight Checklist

- [X] I agree to follow the [Code of Conduct](https://github.com/HXSecurity/DongTai/blob/main/.github/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/HXSecurity/DongTai/issues) for an issue that matches the one I want to file, without success.
- [X] I am not looking for support or already pursued the available [support channels](https://github.com/HXSecurity/DongTai/issues/new/choose) without success.

### Version

latest

### Installation Type

Official Kubernetes

### Service Name

DongTai-Web

### Describe the details of the bug and the steps to reproduce it

下载agent后在windows下运行（运行命令` java -javaagent:dongtai-agent.jar -jar xxx.jar`），报错注册失败：
2022-11-03 09:00:11 [io.dongtai.iast.agent] [ERROR] Register msg: {"status": 202, "msg": "\\u63a2\\u9488\\u6ce8\\u518c\\u5931\\u8d25"}

### Additional Information

查看服务端日志，疑似编码问题。
相关日志：
ERROR 2022-11-03 10:28:09,614 [agent_register.post:298] 探针注册失败，原因：'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte
Traceback (most recent call last):
  File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 272, in post
    self.register_server(
  File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 122, in register_server
    env = base64.b64decode(server_env).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte
[pid: 25|app: 0|req: 1/5] 10.42.178.223 () {42 vars in 643 bytes} [Thu Nov  3 10:28:08 2022] POST /api/v1/agent/register => generated 62

### Logs

```shell
ERROR 2022-11-03 10:28:09,614 [agent_register.post:298] 探针注册失败，原因：'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte
Traceback (most recent call last):
  File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 272, in post
    self.register_server(
  File "/opt/dongtai/./dongtai_protocol/views/agent_register.py", line 122, in register_server
    env = base64.b64decode(server_env).decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 480: invalid start byte
[pid: 25|app: 0|req: 1/5] 10.42.178.223 () {42 vars in 643 bytes} [Thu Nov  3 10:28:08 2022] POST /api/v1/agent/register => generated 62
```


Changed files:
dongtai-agent/src/main/java/io/dongtai/iast/agent/report/AgentRegisterReport.java

diff --git a/dongtai-agent/src/main/java/io/dongtai/iast/agent/report/AgentRegisterReport.java b/dongtai-agent/src/main/java/io/dongtai/iast/agent/report/AgentRegisterReport.java
index ce285d2b..6b887954 100644
--- a/dongtai-agent/src/main/java/io/dongtai/iast/agent/report/AgentRegisterReport.java
+++ b/dongtai-agent/src/main/java/io/dongtai/iast/agent/report/AgentRegisterReport.java
@@ -13,6 +13,7 @@ import org.json.JSONArray;
 import org.json.JSONObject;
 
 import java.net.*;
+import java.nio.charset.Charset;
 import java.util.Enumeration;
 
 /**
@@ -48,8 +49,9 @@ public class AgentRegisterReport {
         object.put("hostname", AgentRegisterReport.getInternalHostName());
         object.put("language", AgentConstant.LANGUAGE);
         object.put("network", readIpInfo());
-        object.put("serverEnv",
-                Base64Encoder.encodeBase64String(System.getProperties().toString().getBytes()).replaceAll("\\n", ""));
+        object.put("serverEnv", Base64Encoder
+                .encodeBase64String(System.getProperties().toString().getBytes(Charset.forName("UTF-8")))
+                .replaceAll("\\n", ""));
         object.put("containerName", null == server ? "" : server.getName());
         object.put("containerVersion", null == server ? "" : server.getVersion());
         object.put("serverPath", ServerDetect.getWebServerPath());
@@ -195,12 +197,12 @@ public class AgentRegisterReport {
                     JSONObject jsonObject = new JSONObject();
                     String displayName = networkInterface.getDisplayName();
                     String hostAddress = inetAddress.getHostAddress();
-                    jsonObject.put("name",displayName);
-                    jsonObject.put("ip",hostAddress);
-                    if (displayName.startsWith("en")){
-                        jsonObject.put("isAddress","1");
-                    }else {
-                        jsonObject.put("isAddress","0");
+                    jsonObject.put("name", displayName);
+                    jsonObject.put("ip", hostAddress);
+                    if (displayName.startsWith("en")) {
+                        jsonObject.put("isAddress", "1");
+                    } else {
+                        jsonObject.put("isAddress", "0");
                     }
                     network.put(jsonObject);
                 }
@@ -211,7 +213,7 @@ public class AgentRegisterReport {
         }
     }
 
-    public void register(){
+    public void register() {
         try {
             if (server == null) {
                 System.out.println("[io.dongtai.iast.agent] Can't Recognize Web Service");