ban掉restful-fast-request--api-buddy的验证服务器ip
This commit is contained in:
		@@ -21,11 +21,19 @@ public class AgentMain {
 | 
			
		||||
                        .visit(Advice.to(HttpClientAdvice.class)
 | 
			
		||||
                                .on(ElementMatchers.named("openServer"))))
 | 
			
		||||
                .asTerminalTransformation()
 | 
			
		||||
 | 
			
		||||
                .type(ElementMatchers.named("java.lang.System"))
 | 
			
		||||
                .transform((builder, typeDescription, classLoader, module, protectionDomain) -> builder
 | 
			
		||||
                        .visit(Advice.to(SystemAdvice.class)
 | 
			
		||||
                                .on(ElementMatchers.named("getProperty"))))
 | 
			
		||||
                .asTerminalTransformation()
 | 
			
		||||
 | 
			
		||||
                .type(ElementMatchers.named("java.net.Socket"))
 | 
			
		||||
                .transform((builder, typeDescription, classLoader, module, protectionDomain) -> builder
 | 
			
		||||
                        .visit(Advice.to(SocketAdvice.class)
 | 
			
		||||
                                .on(ElementMatchers.named("connect"))))
 | 
			
		||||
                .asTerminalTransformation()
 | 
			
		||||
 | 
			
		||||
                .installOn(inst);
 | 
			
		||||
 | 
			
		||||
        agentBuilder.installOn(inst);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								jetbra-agent/src/main/java/win/novice/li/SocketAdvice.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								jetbra-agent/src/main/java/win/novice/li/SocketAdvice.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
package win.novice.li;
 | 
			
		||||
 | 
			
		||||
import net.bytebuddy.asm.Advice;
 | 
			
		||||
 | 
			
		||||
import java.net.ConnectException;
 | 
			
		||||
import java.net.InetAddress;
 | 
			
		||||
import java.net.InetSocketAddress;
 | 
			
		||||
import java.net.SocketAddress;
 | 
			
		||||
 | 
			
		||||
public class SocketAdvice {
 | 
			
		||||
    @Advice.OnMethodExit
 | 
			
		||||
    public static void intercept(@Advice.Argument(value = 0,readOnly = false) SocketAddress socketAddress) throws Exception {
 | 
			
		||||
        if (socketAddress instanceof InetSocketAddress){
 | 
			
		||||
            InetAddress address = ((InetSocketAddress) socketAddress).getAddress();
 | 
			
		||||
            if (address.getHostAddress().equals("116.62.33.138")){
 | 
			
		||||
                throw new ConnectException("拒绝连接");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -13,14 +13,12 @@ import org.springframework.web.bind.annotation.RequestBody;
 | 
			
		||||
import org.springframework.web.bind.annotation.RestController;
 | 
			
		||||
import win.novice.li.model.License;
 | 
			
		||||
 | 
			
		||||
import java.io.FileInputStream;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
import java.security.*;
 | 
			
		||||
import java.security.cert.CertificateFactory;
 | 
			
		||||
import java.security.cert.X509Certificate;
 | 
			
		||||
import java.util.Base64;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
@RestController
 | 
			
		||||
@@ -33,8 +31,6 @@ public class LicenseController {
 | 
			
		||||
    @PostMapping("/generateLicense")
 | 
			
		||||
    @SneakyThrows
 | 
			
		||||
    public Map<String, Object> generateLicense(@RequestBody @Validated License license) {
 | 
			
		||||
        Map<String, Object> ans = new HashMap<>();
 | 
			
		||||
 | 
			
		||||
        String licenseId = generateLicenseId();
 | 
			
		||||
        license.setLicenseId(licenseId);
 | 
			
		||||
 | 
			
		||||
@@ -42,7 +38,6 @@ public class LicenseController {
 | 
			
		||||
        byte[] licensePartBytes = licensePart.getBytes(StandardCharsets.UTF_8);
 | 
			
		||||
        String licensePartBase64 = Base64.getEncoder().encodeToString(licensePartBytes);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        Signature signature = Signature.getInstance("SHA1withRSA");
 | 
			
		||||
        signature.initSign(PRIVATE_KEY);
 | 
			
		||||
        signature.update(licensePartBytes);
 | 
			
		||||
@@ -51,8 +46,7 @@ public class LicenseController {
 | 
			
		||||
 | 
			
		||||
        String result = licenseId + "-" + licensePartBase64 + "-" + sigResultsBase64 + "-" + Base64.getEncoder().encodeToString(CRT.getEncoded());
 | 
			
		||||
 | 
			
		||||
        ans.put("license",result);
 | 
			
		||||
        return ans;
 | 
			
		||||
        return Map.of("license", result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user