├── .idea ├── .gitignore ├── compiler.xml ├── encodings.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── Dockerfile ├── README.md ├── bridge.sql ├── docker-compose.yml ├── pom.xml └── src └── main ├── java └── bridge │ ├── BridgeApplication.java │ ├── config │ └── DnslogConfig.java │ ├── controller │ ├── APIController.java │ ├── APIInfoController.java │ ├── AuthController.java │ ├── DnsSettingController.java │ ├── DnslogController.java │ ├── ResponseSettingController.java │ └── WeblogController.java │ ├── dnsserver │ ├── DNSHandler.java │ └── UDPServer.java │ ├── intercept │ ├── AppWebConfiguration.java │ └── WebLogIntercept.java │ ├── mapper │ ├── DnsRecordAMapper.java │ ├── DnsRecordRebindMapper.java │ ├── DnslogMapper.java │ ├── ResponseMapper.java │ ├── UserMapper.java │ └── WeblogMapper.java │ ├── model │ ├── DnsLog.java │ ├── DnsRecordA.java │ ├── DnsRecordRebind.java │ ├── Response.java │ ├── User.java │ └── WebLog.java │ ├── security │ └── SecurityConfig.java │ └── service │ ├── DnsLogService.java │ ├── DnsRecordAService.java │ ├── DnsRecordRebindService.java │ ├── ResponseService.java │ ├── UserService.java │ └── WeblogService.java └── resources ├── application.properties └── templates ├── apiinfo.html ├── authheader.html ├── dnslog.html ├── dnssetting.html ├── login.html ├── mainheader.html ├── register.html ├── responsesetting.html └── weblog.html /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | 3 | RUN yum install java-1.8.0-openjdk* -y 4 | 5 | RUN yum install wget -y 6 | 7 | RUN wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo --no-check-certificate 8 | RUN yum -y install apache-maven 9 | 10 | RUN mkdir /bridge 11 | COPY . /bridge 12 | 13 | WORKDIR /bridge 14 | 15 | RUN yum install which -y 16 | 17 | RUN export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac))))) 18 | 19 | RUN mvn clean package -DskipTes -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Bridge 2 | 3 | 无回显漏洞测试辅助平台 (Spring Boot + Spring Security + Netty) 4 | 5 | 平台使用Java编写,提供DNSLOG,HTTPLOG等功能,辅助渗透测试过程中无回显漏洞及SSRF等漏洞的验证和利用。 6 | 7 | 8 | 主要功能 9 | ----------- 10 | 11 | * DNSLOG 12 | * HTTPLOG 13 | * 自定义DNS解析 14 | * DNS Rebinding 15 | * 自定义HTTP Response(Response内容、状态码、Header) 16 | * 数据查询API 17 | 18 | 19 | 部署方法(支持手动部署和Docker部署) 20 | ----------- 21 | 22 | ### 1. 手动部署 23 | 24 | #### 域名解析 25 | 26 | 假设根域名是dnslog.com,服务器IP是10.10.10.10进行以下配置 27 | 28 | 配置A记录,子域名ns,解析到10.10.10.10 29 | 30 | 配置NS记录,子域名dns,解析到ns.dnslog.com 31 | 32 | 配置A记录,子域名dnslog,解析到10.10.10.10 33 | 34 | dnslog.dnslog.com 用于访问平台web 35 | 36 | dns.dnslog.com 作为测试时payload中设置的域名,每个用户对应dns.dnslog.com下的子域名,如1.dns.dnslog.com,登录平台后可以在API信息中看到对应的地址 37 | 38 | 子域名随意设置,对应上即可 39 | 40 | #### 数据库配置 41 | 42 | 登录mysql执行以下命令,bridge.sql在程序的根目录下 43 | 44 | source bridge.sql 45 | 46 | #### 服务器配置 47 | 48 | 环境:Java 1.8、Maven 49 | 50 | 修改resources目录下application.properties文件中的web服务端口(默认80端口)和数据库连接信息 51 | 52 | mvn clean package -DskipTests 53 | 54 | maven生成的jar包位置在target目录下,如dns_log-0.0.1-SNAPSHOT.jar 55 | 56 | java -jar dns_log-0.0.1-SNAPSHOT.jar dns.dnslog.com dnslog.dnslog.com 10.10.10.10 a1b2c3d4 57 | 58 | 第一个参数指定payload设置对应的子域名 59 | 60 | 第二个参数指定访问平台对应的子域名 61 | 62 | 第三个参数服务器的IP地址 63 | 64 | 第四个参数设置注册时的注册暗号,注册需要填写该字段 65 | 66 | 67 | ### 2. Docker部署 68 | 69 | 域名解析部分与手动部署相同,无需配置数据库和服务器 70 | 71 | git clone https://github.com/SPuerBRead/Bridge.git 72 | cd ./Bridge 73 | 74 | 默认的mysql密码是password,若要修改,请保持以下两项中的密码相同(可不修改) 75 | 76 | 1. docker-compose.yml文件中的MYSQL_ROOT_PASSWORD项 77 | 78 | 2. 程序配置文件application.properties中的spring.datasource.password 79 | 80 | 修改docker-compose.yml倒数第三行command的值,此处为启动命令,将对应参数替换成域名配置中的信息,如: 81 | 82 | java -jar dns_log-0.0.1-SNAPSHOT.jar dns.dnslog.com dnslog.dnslog.com 10.10.10.10 a1b2c3d4 83 | 84 | 参数含义见手动部署部分。 85 | 86 | 配置完成后执行以下命令: 87 | 88 | docker-compose build 89 | docker-compose up -d 90 | 91 | 访问 dnslog.dnslog.com(实际域名根据根域名和配置而定)即可看到登录界面。 92 | 93 | 94 | 部分截图 95 | ----------- 96 | 97 | DNSLOG 98 | 99 |  100 | 101 | 102 | HTTPLOG 103 | 104 |  105 | 106 | API接口 107 | ----------- 108 | 109 | apiKey在登录后的API信息页面中 110 | 111 | #### dnslog查询接口 112 | 113 | http://xxx.xx/api/dnslog/search?token={apiKey}&keyword={test} 114 | 115 | keyword参数值必须是完整除去logAdress后的部分,此处没有模糊查询,如aaaaaa.1.dnslog.com对应keyword=aaaaaa,返回数据格式样例如下: 116 | 117 | ``` 118 | [ 119 | { 120 | "ip": "localhost", 121 | "host": "test1.1.dns.xxxx.com", 122 | "time": "2019-07-30 15:25:14.0", 123 | "type": "A(1)" 124 | } 125 | ] 126 | ``` 127 | 128 | #### httplog查询接口 129 | http://xxx.xx/api/weblog/search?token={apiKey}&keyword={test} 130 | keyword要求同上,返回数据格式样例如下: 131 | 132 | ``` 133 | [ 134 | { 135 | "path": "/", 136 | "method": "POST", 137 | "data": "", 138 | "ip": "10.10.37.75", 139 | "host": "test.1.dns.xxxx.com", 140 | "header": "{\"content-length\":\"22896\",\"postman-token\":\"9575b873-ccd9-4d5b-ba8a-c1f746e40086\",\"host\":\"test.1.dns.xxxx.com\",\"content-type\":\"text/plain\",\"connection\":\"keep-alive\",\"cache-control\":\"no-cache\",\"accept-encoding\":\"gzip, deflate\",\"user-agent\":\"PostmanRuntime/7.13.0\",\"accept\":\"*/*\"}", 141 | "time": "2019-07-23 17:50:10.0", 142 | "params": null, 143 | "version": "HTTP/1.1" 144 | } 145 | ] 146 | ``` 147 | 148 | -------------------------------------------------------------------------------- /bridge.sql: -------------------------------------------------------------------------------- 1 | drop database if exists bridge; 2 | create database bridge; 3 | use bridge; 4 | 5 | 6 | SET FOREIGN_KEY_CHECKS=0; 7 | 8 | DROP TABLE IF EXISTS `dnslog`; 9 | CREATE TABLE `dnslog` ( 10 | `id` varchar(36) DEFAULT NULL, 11 | `host` text DEFAULT NULL, 12 | `type` varchar(32) DEFAULT NULL, 13 | `ip` text DEFAULT NULL, 14 | `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 15 | `logid` int DEFAULT NULL 16 | ) CHARSET=utf8; 17 | 18 | 19 | DROP TABLE IF EXISTS `user`; 20 | CREATE TABLE `user` ( 21 | `userid` varchar(36) DEFAULT NULL, 22 | `username` varchar(32) DEFAULT NULL, 23 | `password` text DEFAULT NULL, 24 | `logid` int DEFAULT NULL, 25 | `apikey` text DEFAULT NULL 26 | ) CHARSET=utf8; 27 | 28 | DROP TABLE IF EXISTS `weblog`; 29 | CREATE TABLE `weblog` ( 30 | `id` varchar(36) DEFAULT NULL, 31 | `host` text DEFAULT NULL, 32 | `ip` varchar(32) DEFAULT NULL, 33 | `method` varchar(32) DEFAULT NULL, 34 | `version` varchar(32) DEFAULT NULL, 35 | `path` text DEFAULT NULL, 36 | `header` text DEFAULT NULL, 37 | `params` text DEFAULT NULL, 38 | `data` text DEFAULT NULL, 39 | `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 40 | `logid` int DEFAULT NULL 41 | ) CHARSET=utf8; 42 | 43 | 44 | DROP TABLE IF EXISTS `dns_record_a`; 45 | CREATE TABLE `dns_record_a` ( 46 | `id` varchar(36) DEFAULT NULL, 47 | `subdomain` text DEFAULT NULL, 48 | `ip` varchar(32) DEFAULT NULL, 49 | `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 50 | `logid` int DEFAULT NULL 51 | ) CHARSET=utf8; 52 | 53 | DROP TABLE IF EXISTS `dns_record_rebind`; 54 | CREATE TABLE `dns_record_rebind` ( 55 | `id` varchar(36) DEFAULT NULL, 56 | `subdomain` text DEFAULT NULL, 57 | `ip1` varchar(32) DEFAULT NULL, 58 | `ip2` varchar(32) DEFAULT NULL, 59 | `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 60 | `logid` int DEFAULT NULL 61 | ) CHARSET=utf8; 62 | 63 | DROP TABLE IF EXISTS `response`; 64 | CREATE TABLE `response` ( 65 | `id` varchar(36) DEFAULT NULL, 66 | `subdomain` text DEFAULT NULL, 67 | `responseType` text DEFAULT NULL, 68 | `statusCode` int DEFAULT NULL, 69 | `responsebody` text DEFAULT NULL, 70 | `headers` text DEFAULT NULL, 71 | `redirectURL` text DEFAULT NULL, 72 | `time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, 73 | `logid` int DEFAULT NULL 74 | ) CHARSET=utf8; -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | mysql: 4 | container_name: mysql 5 | environment: 6 | MYSQL_ROOT_PASSWORD: password 7 | image: mysql:5.7 8 | command: --default-authentication-plugin=mysql_native_password 9 | restart: always 10 | volumes: 11 | - db_data:/var/lib/mysql 12 | - ./bridge.sql:/docker-entrypoint-initdb.d/bridge.sql:ro 13 | bridge: 14 | build: . 15 | ports: 16 | - 80:80 17 | - 53:53/udp 18 | depends_on: 19 | - mysql 20 | links: 21 | - mysql 22 | command: nohup java -jar /bridge/target/bridge-1.0-SNAPSHOT.jar dns.dnslog.com dnslog.dnslog.com 10.10.10.10 a1b2c3d4 & 23 | volumes: 24 | db_data: {} -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 2.1.6.RELEASE 10 | 11 | 12 | tools.scanner 13 | bridge 14 | 1.0-SNAPSHOT 15 | 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.mybatis.spring.boot 28 | mybatis-spring-boot-starter 29 | 2.0.1 30 | 31 | 32 | mysql 33 | mysql-connector-java 34 | 35 | 36 | 37 | io.netty 38 | netty-all 39 | 4.1.42.Final 40 | 41 | 42 | log4j 43 | log4j 44 | 1.2.17 45 | 46 | 47 | com.google.guava 48 | guava 49 | 28.0-jre 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-starter-security 55 | 2.1.6.RELEASE 56 | 57 | 58 | org.springframework.boot 59 | spring-boot-starter-thymeleaf 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | org.springframework.boot 68 | spring-boot-maven-plugin 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/java/bridge/BridgeApplication.java: -------------------------------------------------------------------------------- 1 | package bridge; 2 | 3 | import bridge.config.DnslogConfig; 4 | import bridge.dnsserver.UDPServer; 5 | import org.mybatis.spring.annotation.MapperScan; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.ConfigurableApplicationContext; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.scheduling.annotation.EnableScheduling; 11 | 12 | @Configuration 13 | @SpringBootApplication 14 | @MapperScan("bridge.mapper") 15 | @EnableScheduling 16 | public class BridgeApplication { 17 | 18 | public static void main(String[] args) { 19 | 20 | DnslogConfig.dnslogDomain = args[0]; 21 | DnslogConfig.managerDomain = args[1]; 22 | DnslogConfig.ip = args[2]; 23 | DnslogConfig.signal = args[3]; 24 | 25 | ConfigurableApplicationContext context = SpringApplication.run(BridgeApplication.class, args); 26 | 27 | UDPServer udpServer = context.getBean(UDPServer.class); 28 | 29 | udpServer.start(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/bridge/config/DnslogConfig.java: -------------------------------------------------------------------------------- 1 | package bridge.config; 2 | 3 | public class DnslogConfig { 4 | public static String managerDomain; 5 | 6 | public static String dnslogDomain; 7 | 8 | public static String ip; 9 | 10 | public static String signal; 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/bridge/controller/APIController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | 4 | import bridge.config.DnslogConfig; 5 | import bridge.model.DnsLog; 6 | import bridge.model.User; 7 | import bridge.model.WebLog; 8 | import bridge.service.DnsLogService; 9 | import bridge.service.UserService; 10 | import bridge.service.WeblogService; 11 | import com.fasterxml.jackson.core.JsonProcessingException; 12 | import com.fasterxml.jackson.databind.ObjectMapper; 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.stereotype.Controller; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.RequestParam; 17 | import org.springframework.web.bind.annotation.ResponseBody; 18 | 19 | import java.util.ArrayList; 20 | import java.util.HashMap; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | @Controller 25 | public class APIController { 26 | 27 | @Autowired 28 | private UserService userService; 29 | 30 | @Autowired 31 | private DnsLogService dnsLogService; 32 | 33 | @Autowired 34 | private WeblogService weblogService; 35 | 36 | @ResponseBody 37 | @GetMapping(value = "/api/dnslog/search", produces = "text/plain;charset=utf-8") 38 | public String dnslogSearchAPI(@RequestParam Map args) throws JsonProcessingException { 39 | ObjectMapper mapper = new ObjectMapper(); 40 | List> logList = new ArrayList<>(); 41 | String token = args.get("token"); 42 | User user = userService.getUserByApiKey(token); 43 | if(user != null){ 44 | String keyword = args.get("keyword"); 45 | int logID = user.getLogid(); 46 | List dnslogList = dnsLogService.getDnsLogByHost(keyword+'.'+String.valueOf(logID)+'.'+DnslogConfig.dnslogDomain); 47 | for(Object x:dnslogList){ 48 | HashMap map = new HashMap(); 49 | map.put("host", ((DnsLog)x).getHost()); 50 | map.put("type", ((DnsLog)x).getType()); 51 | map.put("ip", ((DnsLog)x).getIp()); 52 | map.put("time", ((DnsLog)x).getTime().toString()); 53 | logList.add(map); 54 | } 55 | return mapper.writeValueAsString(logList); 56 | }else{ 57 | return mapper.writeValueAsString("[]"); 58 | } 59 | } 60 | 61 | @ResponseBody 62 | @GetMapping(value = "/api/weblog/search", produces = "text/plain;charset=utf-8") 63 | public String weblogSearchAPI(@RequestParam Map args) throws JsonProcessingException{ 64 | ObjectMapper mapper = new ObjectMapper(); 65 | List> logList = new ArrayList<>(); 66 | String token = args.get("token"); 67 | User user = userService.getUserByApiKey(token); 68 | if(user != null){ 69 | String keyword = args.get("keyword"); 70 | int logID = user.getLogid(); 71 | List weblogList = weblogService.getWeblogByHost(keyword+'.'+String.valueOf(logID)+'.'+DnslogConfig.dnslogDomain); 72 | System.out.println(weblogList); 73 | for(Object x:weblogList){ 74 | WebLog a = (WebLog) x; 75 | HashMap map = new HashMap(); 76 | map.put("host", a.getHost()); 77 | map.put("method", a.getMethod()); 78 | map.put("ip", a.getIp()); 79 | map.put("version", a.getVersion()); 80 | map.put("path", a.getPath()); 81 | map.put("header", a.getHeader()); 82 | map.put("params", a.getParams()); 83 | map.put("data", a.getData()); 84 | map.put("time", a.getTime().toString()); 85 | logList.add(map); 86 | } 87 | return mapper.writeValueAsString(logList); 88 | }else{ 89 | return mapper.writeValueAsString("[]"); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/bridge/controller/APIInfoController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | import bridge.config.DnslogConfig; 4 | import bridge.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.security.core.context.SecurityContext; 7 | import org.springframework.security.core.context.SecurityContextHolder; 8 | import org.springframework.stereotype.Controller; 9 | import org.springframework.ui.ModelMap; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.servlet.ModelAndView; 12 | 13 | import java.util.HashMap; 14 | import java.util.Map; 15 | 16 | @Controller 17 | public class APIInfoController { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | 23 | @GetMapping("/api_info") 24 | public ModelAndView api() { 25 | SecurityContext securityContext = SecurityContextHolder.getContext(); 26 | String username = securityContext.getAuthentication().getName(); 27 | String apiKey = userService.getapiKeyByName(username); 28 | int logID = userService.getLogIdByName(username); 29 | Map map = new HashMap<>(); 30 | map.put("apiKey", apiKey); 31 | map.put("logAddress", String.valueOf(logID) + '.' + DnslogConfig.dnslogDomain); 32 | ModelMap model = new ModelMap(); 33 | model.addAttribute("apimap", map); 34 | model.addAttribute("username", username); 35 | return new ModelAndView("apiinfo", model); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/bridge/controller/AuthController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | import bridge.config.DnslogConfig; 4 | import bridge.model.User; 5 | import bridge.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.core.context.SecurityContext; 8 | import org.springframework.security.core.context.SecurityContextHolder; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.web.bind.annotation.GetMapping; 11 | import org.springframework.web.bind.annotation.PostMapping; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | 14 | import java.util.Map; 15 | 16 | @Controller 17 | public class AuthController { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | @GetMapping("/login") 23 | public String login() { 24 | return "login"; 25 | } 26 | 27 | @GetMapping("/") 28 | public String index() { 29 | SecurityContext securityContext = SecurityContextHolder.getContext(); 30 | String username = securityContext.getAuthentication().getName(); 31 | if (username.equals("anonymousUser")) { 32 | return "login"; 33 | } else { 34 | return "redirect:dnslog"; 35 | } 36 | } 37 | 38 | 39 | @GetMapping("/register") 40 | public String register() { 41 | return "register"; 42 | } 43 | 44 | 45 | @PostMapping("/register") 46 | public String register(@RequestParam Map args) { 47 | if(DnslogConfig.signal.equals(args.get("signal"))){ 48 | if (args.get("password1").equals(args.get("password2"))) { 49 | User user = new User(); 50 | user.setPassword(args.get("password1")); 51 | user.setUsername(args.get("username")); 52 | try { 53 | userService.insertNewUser(user); 54 | } catch (RuntimeException runtimeException) { 55 | return "redirect:register?error1"; 56 | } 57 | } else { 58 | return "redirect:register?error2"; 59 | } 60 | }else{ 61 | return "redirect:register?error3"; 62 | } 63 | return "redirect:login"; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/bridge/controller/DnsSettingController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | 4 | import bridge.config.DnslogConfig; 5 | import bridge.model.DnsRecordA; 6 | import bridge.model.DnsRecordRebind; 7 | import bridge.service.DnsRecordAService; 8 | import bridge.service.DnsRecordRebindService; 9 | import bridge.service.UserService; 10 | import com.fasterxml.jackson.core.JsonProcessingException; 11 | import com.fasterxml.jackson.databind.ObjectMapper; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.security.core.context.SecurityContext; 14 | import org.springframework.security.core.context.SecurityContextHolder; 15 | import org.springframework.stereotype.Controller; 16 | import org.springframework.ui.ModelMap; 17 | import org.springframework.web.bind.annotation.GetMapping; 18 | import org.springframework.web.bind.annotation.PostMapping; 19 | import org.springframework.web.bind.annotation.RequestParam; 20 | import org.springframework.web.bind.annotation.ResponseBody; 21 | import org.springframework.web.servlet.ModelAndView; 22 | 23 | import java.sql.Timestamp; 24 | import java.util.*; 25 | 26 | @Controller 27 | public class DnsSettingController { 28 | 29 | 30 | @Autowired 31 | private UserService userService; 32 | 33 | @Autowired 34 | private DnsRecordAService dnsRecordAService; 35 | 36 | @Autowired 37 | private DnsRecordRebindService dnsRecordRebindService; 38 | 39 | @GetMapping("/dns_setting") 40 | public ModelAndView getDNSSettingList() { 41 | List> dnsRecordASettingList = new ArrayList>(); 42 | List> dnsRecordRebindSettingList = new ArrayList>(); 43 | SecurityContext securityContext = SecurityContextHolder.getContext(); 44 | String username = securityContext.getAuthentication().getName(); 45 | Integer userLogID = userService.getLogIdByName(username); 46 | String userDomain = String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 47 | for (Object x : dnsRecordAService.getAllDnsRecordA(userDomain)) { 48 | DnsRecordA a = (DnsRecordA) x; 49 | HashMap tmpMap = new HashMap(); 50 | tmpMap.put("id", a.getId()); 51 | tmpMap.put("host", a.getSubdomain()); 52 | tmpMap.put("subdomain", a.getSubdomain().replace('.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain, "")); 53 | tmpMap.put("ip", a.getIp()); 54 | String timeString = a.getTime().toString(); 55 | tmpMap.put("time", timeString.substring(0, timeString.length() - 2)); 56 | dnsRecordASettingList.add(tmpMap); 57 | } 58 | for (Object x : dnsRecordRebindService.getAllDnsRecordRebind(userDomain)) { 59 | DnsRecordRebind a = (DnsRecordRebind) x; 60 | HashMap tmpMap = new HashMap(); 61 | tmpMap.put("id", a.getId()); 62 | tmpMap.put("host", a.getSubdomain()); 63 | tmpMap.put("subdomain", a.getSubdomain().replace('.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain, "")); 64 | tmpMap.put("ip1", a.getIp1()); 65 | tmpMap.put("ip2", a.getIp2()); 66 | String timeString = a.getTime().toString(); 67 | tmpMap.put("time", timeString.substring(0, timeString.length() - 2)); 68 | dnsRecordRebindSettingList.add(tmpMap); 69 | } 70 | ModelMap model = new ModelMap(); 71 | model.addAttribute("dnsRecordASettingList", dnsRecordASettingList); 72 | model.addAttribute("dnsRecordRebindSettingList", dnsRecordRebindSettingList); 73 | model.addAttribute("username", username); 74 | 75 | return new ModelAndView("dnssetting", model); 76 | } 77 | 78 | @ResponseBody 79 | @PostMapping(value = "/dns_setting/add/a", produces = "text/plain;charset=utf-8") 80 | public String addRecordA(@RequestParam Map args) throws JsonProcessingException { 81 | String subDomainA = args.get("subDomainA"); 82 | String destIP = args.get("destIP"); 83 | ObjectMapper mapper = new ObjectMapper(); 84 | HashMap map = new HashMap(); 85 | String result; 86 | DnsRecordA dnsRecordA = new DnsRecordA(); 87 | SecurityContext securityContext = SecurityContextHolder.getContext(); 88 | String username = securityContext.getAuthentication().getName(); 89 | int userLogID = userService.getLogIdByName(username); 90 | 91 | subDomainA = subDomainA + '.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 92 | if (dnsRecordAService.getDnsRecordABySubdomain(subDomainA) == null && dnsRecordRebindService.getDnsRecordRebindBySubdomain(subDomainA) == null) { 93 | dnsRecordA.setSubdomain(subDomainA); 94 | dnsRecordA.setIp(destIP); 95 | dnsRecordA.setTime(new Timestamp(System.currentTimeMillis())); 96 | dnsRecordA.setId(UUID.randomUUID().toString()); 97 | dnsRecordA.setLogid(userLogID); 98 | 99 | dnsRecordAService.addDnsRecordA(dnsRecordA); 100 | map.put("status", true); 101 | result = mapper.writeValueAsString(map); 102 | return result; 103 | } else { 104 | map.put("status", false); 105 | map.put("message", "subdomain is already existed"); 106 | result = mapper.writeValueAsString(map); 107 | return result; 108 | } 109 | } 110 | 111 | @ResponseBody 112 | @PostMapping(value = "/dns_setting/add/rebind", produces = "text/plain;charset=utf-8") 113 | public String addRecordRebind(@RequestParam Map args) throws JsonProcessingException { 114 | String subDomainRebind = args.get("subDomainRebind"); 115 | String destIPRebind1 = args.get("destIPRebind1"); 116 | String destIPRebind2 = args.get("destIPRebind2"); 117 | ObjectMapper mapper = new ObjectMapper(); 118 | HashMap map = new HashMap(); 119 | String result; 120 | DnsRecordRebind dnsRecordRebind = new DnsRecordRebind(); 121 | SecurityContext securityContext = SecurityContextHolder.getContext(); 122 | String username = securityContext.getAuthentication().getName(); 123 | int userLogID = userService.getLogIdByName(username); 124 | 125 | subDomainRebind = subDomainRebind + '.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 126 | if (dnsRecordAService.getDnsRecordABySubdomain(subDomainRebind) == null && dnsRecordRebindService.getDnsRecordRebindBySubdomain(subDomainRebind) == null) { 127 | dnsRecordRebind.setSubdomain(subDomainRebind); 128 | dnsRecordRebind.setIp1(destIPRebind1); 129 | dnsRecordRebind.setIp2(destIPRebind2); 130 | dnsRecordRebind.setTime(new Timestamp(System.currentTimeMillis())); 131 | dnsRecordRebind.setId(UUID.randomUUID().toString()); 132 | dnsRecordRebind.setLogid(userLogID); 133 | 134 | dnsRecordRebindService.addDnsRecordRebind(dnsRecordRebind); 135 | map.put("status", true); 136 | result = mapper.writeValueAsString(map); 137 | return result; 138 | } else { 139 | map.put("status", false); 140 | map.put("message", "subdomain is already existed"); 141 | result = mapper.writeValueAsString(map); 142 | return result; 143 | } 144 | } 145 | 146 | @ResponseBody 147 | @PostMapping(value = "/dns_setting/delete/a", produces = "text/plain;charset=utf-8") 148 | public String deleteOneDnsRecordASetting(@RequestParam Map args) throws JsonProcessingException { 149 | ObjectMapper mapper = new ObjectMapper(); 150 | HashMap map = new HashMap(); 151 | String result; 152 | DnsRecordA dnsRecordA = dnsRecordAService.getDnsRecordAByID(args.get("id")); 153 | SecurityContext securityContext = SecurityContextHolder.getContext(); 154 | String username = securityContext.getAuthentication().getName(); 155 | int userLogID = userService.getLogIdByName(username); 156 | if (Objects.equals(dnsRecordA.getLogid(), userLogID)) { 157 | dnsRecordAService.delOneDnsRecordA(args.get("id")); 158 | map.put("status", true); 159 | result = mapper.writeValueAsString(map); 160 | } else { 161 | map.put("status", false); 162 | result = mapper.writeValueAsString(map); 163 | } 164 | return result; 165 | } 166 | 167 | @ResponseBody 168 | @PostMapping(value = "/dns_setting/delete/rebind", produces = "text/plain;charset=utf-8") 169 | public String deleteOneDnsRecordRebindSetting(@RequestParam Map args) throws JsonProcessingException { 170 | ObjectMapper mapper = new ObjectMapper(); 171 | HashMap map = new HashMap(); 172 | String result; 173 | DnsRecordRebind dnsRecordRebind = dnsRecordRebindService.getDnsRecordRebindByID(args.get("id")); 174 | SecurityContext securityContext = SecurityContextHolder.getContext(); 175 | String username = securityContext.getAuthentication().getName(); 176 | int userLogID = userService.getLogIdByName(username); 177 | if (Objects.equals(dnsRecordRebind.getLogid(), userLogID)) { 178 | dnsRecordRebindService.delOneDnsRecordRebind(args.get("id")); 179 | map.put("status", true); 180 | result = mapper.writeValueAsString(map); 181 | } else { 182 | map.put("status", false); 183 | result = mapper.writeValueAsString(map); 184 | } 185 | return result; 186 | } 187 | 188 | @ResponseBody 189 | @GetMapping(value = "/dns_setting/delete_all/a", produces = "text/plain;charset=utf-8") 190 | public String deleteAllDnsRecordA() throws JsonProcessingException { 191 | ObjectMapper mapper = new ObjectMapper(); 192 | HashMap map = new HashMap(); 193 | String result; 194 | SecurityContext securityContext = SecurityContextHolder.getContext(); 195 | String username = securityContext.getAuthentication().getName(); 196 | int userLogID = userService.getLogIdByName(username); 197 | try { 198 | dnsRecordAService.delAllDnsRecordA(userLogID); 199 | map.put("status", true); 200 | } catch (RuntimeException r) { 201 | map.put("status", false); 202 | } 203 | result = mapper.writeValueAsString(map); 204 | return result; 205 | } 206 | 207 | @ResponseBody 208 | @GetMapping(value = "/dns_setting/delete_all/rebind", produces = "text/plain;charset=utf-8") 209 | public String deleteAllDnsRecordRebind() throws JsonProcessingException { 210 | ObjectMapper mapper = new ObjectMapper(); 211 | HashMap map = new HashMap(); 212 | String result; 213 | SecurityContext securityContext = SecurityContextHolder.getContext(); 214 | String username = securityContext.getAuthentication().getName(); 215 | int userLogID = userService.getLogIdByName(username); 216 | try { 217 | dnsRecordRebindService.delAllDnsRecordRebind(userLogID); 218 | map.put("status", true); 219 | } catch (RuntimeException r) { 220 | map.put("status", false); 221 | } 222 | result = mapper.writeValueAsString(map); 223 | return result; 224 | } 225 | 226 | @ResponseBody 227 | @PostMapping(value = "/dns_setting/edit/a", produces = "text/plain;charset=utf-8") 228 | public String editRecordA(@RequestParam Map args) throws JsonProcessingException { 229 | String subDomainA = args.get("subDomainA"); 230 | String destIP = args.get("destIP"); 231 | String id = args.get("id"); 232 | ObjectMapper mapper = new ObjectMapper(); 233 | HashMap map = new HashMap(); 234 | String result; 235 | DnsRecordA dnsRecordA = new DnsRecordA(); 236 | SecurityContext securityContext = SecurityContextHolder.getContext(); 237 | String username = securityContext.getAuthentication().getName(); 238 | int userLogID = userService.getLogIdByName(username); 239 | DnsRecordA dnsRecordAByID = dnsRecordAService.getDnsRecordAByID(id); 240 | subDomainA = subDomainA + '.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 241 | if (dnsRecordAService.getDnsRecordABySubdomain(subDomainA) == null && dnsRecordRebindService.getDnsRecordRebindBySubdomain(subDomainA) == null || dnsRecordAByID.getSubdomain().equals(subDomainA)) { 242 | if (dnsRecordAByID != null && dnsRecordAByID.getLogid() == userLogID) { 243 | dnsRecordA.setSubdomain(subDomainA); 244 | dnsRecordA.setIp(destIP); 245 | dnsRecordA.setTime(new Timestamp(System.currentTimeMillis())); 246 | dnsRecordA.setId(id); 247 | dnsRecordAService.updateDnsRecordAByID(dnsRecordA); 248 | map.put("status", true); 249 | result = mapper.writeValueAsString(map); 250 | return result; 251 | } else { 252 | map.put("status", false); 253 | map.put("message", "记录ID不存在或没有更新权限,更新失败"); 254 | result = mapper.writeValueAsString(map); 255 | return result; 256 | } 257 | } else { 258 | map.put("status", false); 259 | map.put("message", "新更新的子域名与现有子域名设置重复,更新失败"); 260 | result = mapper.writeValueAsString(map); 261 | return result; 262 | } 263 | } 264 | 265 | @ResponseBody 266 | @PostMapping(value = "/dns_setting/edit/rebind", produces = "text/plain;charset=utf-8") 267 | public String editRecordRebind(@RequestParam Map args) throws JsonProcessingException { 268 | String subDomainRebind = args.get("subDomainRebind"); 269 | String destIPRebind1 = args.get("destIPRebind1"); 270 | String destIPRebind2 = args.get("destIPRebind2"); 271 | String id = args.get("id"); 272 | ObjectMapper mapper = new ObjectMapper(); 273 | HashMap map = new HashMap(); 274 | String result; 275 | DnsRecordRebind dnsRecordRebind = new DnsRecordRebind(); 276 | SecurityContext securityContext = SecurityContextHolder.getContext(); 277 | String username = securityContext.getAuthentication().getName(); 278 | int userLogID = userService.getLogIdByName(username); 279 | DnsRecordRebind dnsRecordRebindByID = dnsRecordRebindService.getDnsRecordRebindByID(id); 280 | subDomainRebind = subDomainRebind + '.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 281 | if (dnsRecordAService.getDnsRecordABySubdomain(subDomainRebind) == null && dnsRecordRebindService.getDnsRecordRebindBySubdomain(subDomainRebind) == null || dnsRecordRebindByID.getSubdomain().equals(subDomainRebind) ) { 282 | if (dnsRecordRebindByID != null && dnsRecordRebindByID.getLogid() == userLogID) { 283 | dnsRecordRebind.setSubdomain(subDomainRebind); 284 | dnsRecordRebind.setIp1(destIPRebind1); 285 | dnsRecordRebind.setIp2(destIPRebind2); 286 | dnsRecordRebind.setTime(new Timestamp(System.currentTimeMillis())); 287 | dnsRecordRebind.setId(id); 288 | dnsRecordRebindService.updateDnsRecordRebindByID(dnsRecordRebind); 289 | map.put("status", true); 290 | result = mapper.writeValueAsString(map); 291 | return result; 292 | } else { 293 | map.put("status", false); 294 | map.put("message", "记录ID不存在或没有更新权限,更新失败"); 295 | result = mapper.writeValueAsString(map); 296 | return result; 297 | } 298 | } else { 299 | map.put("status", false); 300 | map.put("message", "新更新的子域名与现有子域名设置重复,更新失败"); 301 | result = mapper.writeValueAsString(map); 302 | return result; 303 | } 304 | } 305 | } 306 | -------------------------------------------------------------------------------- /src/main/java/bridge/controller/DnslogController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | import bridge.config.DnslogConfig; 4 | import bridge.model.DnsLog; 5 | import bridge.service.DnsLogService; 6 | import bridge.service.UserService; 7 | import com.fasterxml.jackson.core.JsonProcessingException; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.security.core.context.SecurityContext; 11 | import org.springframework.security.core.context.SecurityContextHolder; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.ui.ModelMap; 14 | import org.springframework.web.bind.annotation.*; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | import java.util.*; 18 | 19 | @Controller 20 | public class DnslogController { 21 | 22 | 23 | @Autowired 24 | private UserService userService; 25 | 26 | @Autowired 27 | private DnsLogService dnsLogService; 28 | 29 | 30 | @GetMapping("/dnslog") 31 | public ModelAndView getDnslogList() { 32 | List> dnslogList = new ArrayList>(); 33 | SecurityContext securityContext = SecurityContextHolder.getContext(); 34 | String username = securityContext.getAuthentication().getName(); 35 | Integer userLogID = userService.getLogIdByName(username); 36 | String userDomain = String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 37 | for (Object x : dnsLogService.getAllDnslog(userDomain)) { 38 | DnsLog a = (DnsLog) x; 39 | HashMap tmpMap = new HashMap(); 40 | tmpMap.put("id", a.getId()); 41 | tmpMap.put("host", a.getHost()); 42 | tmpMap.put("ip", a.getIp()); 43 | tmpMap.put("type", a.getType()); 44 | String timeString = a.getTime().toString(); 45 | tmpMap.put("time", timeString.substring(0, timeString.length() - 2)); 46 | dnslogList.add(tmpMap); 47 | } 48 | ModelMap model = new ModelMap(); 49 | model.addAttribute("dnslogList", dnslogList); 50 | model.addAttribute("username", username); 51 | 52 | return new ModelAndView("dnslog", model); 53 | } 54 | 55 | @ResponseBody 56 | @PostMapping(value = "/dnslog/delete", produces = "text/plain;charset=utf-8") 57 | public String deleteOneDnslog(@RequestParam Map args) throws JsonProcessingException { 58 | ObjectMapper mapper = new ObjectMapper(); 59 | HashMap map = new HashMap(); 60 | String result; 61 | DnsLog dnslog = dnsLogService.getDnslogByID(args.get("id")); 62 | SecurityContext securityContext = SecurityContextHolder.getContext(); 63 | String username = securityContext.getAuthentication().getName(); 64 | int userLogID = userService.getLogIdByName(username); 65 | if (Objects.equals(dnslog.getLogid(), userLogID)) { 66 | dnsLogService.delOneDnslog(args.get("id")); 67 | map.put("status", true); 68 | result = mapper.writeValueAsString(map); 69 | } else { 70 | map.put("status", false); 71 | result = mapper.writeValueAsString(map); 72 | } 73 | return result; 74 | } 75 | 76 | @ResponseBody 77 | @GetMapping(value = "/dnslog/delete_all", produces = "text/plain;charset=utf-8") 78 | public String deleteAllDnslog() throws JsonProcessingException { 79 | ObjectMapper mapper = new ObjectMapper(); 80 | HashMap map = new HashMap(); 81 | String result; 82 | SecurityContext securityContext = SecurityContextHolder.getContext(); 83 | String username = securityContext.getAuthentication().getName(); 84 | int userLogID = userService.getLogIdByName(username); 85 | try { 86 | dnsLogService.delAllDnslog(userLogID); 87 | map.put("status", true); 88 | } catch (RuntimeException r) { 89 | map.put("status", false); 90 | } 91 | result = mapper.writeValueAsString(map); 92 | return result; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/bridge/controller/ResponseSettingController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | 4 | import bridge.config.DnslogConfig; 5 | import bridge.model.Response; 6 | import bridge.service.ResponseService; 7 | import bridge.service.UserService; 8 | import com.fasterxml.jackson.core.JsonProcessingException; 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.security.core.context.SecurityContext; 12 | import org.springframework.security.core.context.SecurityContextHolder; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.ui.ModelMap; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PostMapping; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.bind.annotation.ResponseBody; 19 | import org.springframework.web.servlet.ModelAndView; 20 | 21 | import java.io.IOException; 22 | import java.sql.Timestamp; 23 | import java.util.*; 24 | 25 | @Controller 26 | public class ResponseSettingController { 27 | 28 | @Autowired 29 | private UserService userService; 30 | 31 | @Autowired 32 | private ResponseService responseService; 33 | 34 | 35 | @GetMapping("/response_setting") 36 | public ModelAndView getResponseSetting() throws JsonProcessingException, IOException { 37 | ObjectMapper mapper = new ObjectMapper(); 38 | List> responseList = new ArrayList>(); 39 | SecurityContext securityContext = SecurityContextHolder.getContext(); 40 | String username = securityContext.getAuthentication().getName(); 41 | Integer userLogID = userService.getLogIdByName(username); 42 | String userDomain = String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 43 | for (Object x : responseService.getAllResponse(userDomain)) { 44 | Response a = (Response) x; 45 | HashMap tmpMap = new HashMap(); 46 | tmpMap.put("id", a.getId()); 47 | tmpMap.put("host", a.getSubDomain()); 48 | tmpMap.put("subDomain", a.getSubDomain().replace('.'+String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain,"")); 49 | tmpMap.put("responseType", a.getResponseType()); 50 | tmpMap.put("statusCode", String.valueOf(a.getStatusCode())); 51 | if(a.getResponseBody() == null || a.getResponseBody().equals("")){ 52 | tmpMap.put("responseBody",""); 53 | }else{ 54 | tmpMap.put("responseBody",a.getResponseBody()); 55 | } 56 | if(a.getHeaders() == null){ 57 | tmpMap.put("headers","[]"); 58 | }else{ 59 | ArrayList headerList = mapper.readValue(a.getHeaders(),ArrayList.class); 60 | tmpMap.put("headers",headerList); 61 | }if(a.getRedirectURL() == null){ 62 | tmpMap.put("redirectURL",""); 63 | }else{ 64 | tmpMap.put("redirectURL",a.getRedirectURL()); 65 | } 66 | String timeString = a.getTime().toString(); 67 | tmpMap.put("time", timeString.substring(0, timeString.length() - 2)); 68 | responseList.add(tmpMap); 69 | } 70 | ModelMap model = new ModelMap(); 71 | model.addAttribute("responseList", responseList); 72 | model.addAttribute("username", username); 73 | return new ModelAndView("responsesetting", model); 74 | } 75 | 76 | @ResponseBody 77 | @PostMapping(value = "/response_setting/add", produces = "text/plain;charset=utf-8") 78 | public String addResponseSetting(@RequestParam Map args) throws JsonProcessingException { 79 | String subDomain = args.get("subDomain"); 80 | String responseType = args.get("responseType"); 81 | String statusCode = args.get("statusCode"); 82 | String responseBody = args.get("responseBody"); 83 | String redirectURL = args.get("redirectURL"); 84 | String headers = args.get("headers"); 85 | ObjectMapper mapper = new ObjectMapper(); 86 | HashMap map = new HashMap(); 87 | String result; 88 | 89 | Response response = new Response(); 90 | SecurityContext securityContext = SecurityContextHolder.getContext(); 91 | String username = securityContext.getAuthentication().getName(); 92 | int userLogID = userService.getLogIdByName(username); 93 | subDomain = subDomain + '.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 94 | 95 | if (responseService.getResponseBySubdomain(subDomain) == null){ 96 | response.setSubDomain(subDomain); 97 | response.setResponseType(responseType); 98 | 99 | SetResponse(responseType, statusCode, responseBody, redirectURL, response); 100 | 101 | response.setHeaders(headers); 102 | response.setTime(new Timestamp(System.currentTimeMillis())); 103 | response.setId(UUID.randomUUID().toString()); 104 | response.setLogid(userLogID); 105 | 106 | responseService.addResponse(response); 107 | map.put("status", true); 108 | result = mapper.writeValueAsString(map); 109 | return result; 110 | }else{ 111 | map.put("status", false); 112 | map.put("message", "subdomain is already existed"); 113 | result = mapper.writeValueAsString(map); 114 | return result; 115 | } 116 | } 117 | 118 | 119 | @ResponseBody 120 | @PostMapping(value = "/response_setting/edit", produces = "text/plain;charset=utf-8") 121 | public String editResponseSetting(@RequestParam Map args) throws JsonProcessingException { 122 | String subDomain = args.get("subDomain"); 123 | String responseType = args.get("responseType"); 124 | String statusCode = args.get("statusCode"); 125 | String responseBody = args.get("responseBody"); 126 | String redirectURL = args.get("redirectURL"); 127 | String headers = args.get("headers"); 128 | String id = args.get("id"); 129 | ObjectMapper mapper = new ObjectMapper(); 130 | HashMap map = new HashMap(); 131 | String result; 132 | 133 | 134 | Response response = new Response(); 135 | SecurityContext securityContext = SecurityContextHolder.getContext(); 136 | String username = securityContext.getAuthentication().getName(); 137 | int userLogID = userService.getLogIdByName(username); 138 | subDomain = subDomain + '.' + String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 139 | 140 | Response selectResponse = responseService.getResponseByID(id); 141 | if(selectResponse!=null && selectResponse.getLogid() == userLogID){ 142 | if (responseService.getResponseBySubdomain(subDomain) == null || selectResponse.getSubDomain().equals(subDomain)){ 143 | response.setSubDomain(subDomain); 144 | response.setResponseType(responseType); 145 | 146 | SetResponse(responseType, statusCode, responseBody, redirectURL, response); 147 | 148 | response.setHeaders(headers); 149 | response.setTime(new Timestamp(System.currentTimeMillis())); 150 | response.setId(id); 151 | 152 | 153 | responseService.updateResponseAByID(response); 154 | map.put("status", true); 155 | result = mapper.writeValueAsString(map); 156 | return result; 157 | }else { 158 | map.put("status", false); 159 | map.put("message", "新更新的子域名与现有子域名设置重复,更新失败"); 160 | result = mapper.writeValueAsString(map); 161 | return result; 162 | } 163 | }else{ 164 | map.put("status", false); 165 | map.put("message", "记录ID不存在或没有更新权限,更新失败"); 166 | result = mapper.writeValueAsString(map); 167 | return result; 168 | } 169 | 170 | 171 | } 172 | 173 | @ResponseBody 174 | @PostMapping(value = "/response_setting/delete", produces = "text/plain;charset=utf-8") 175 | public String deleteOneDResponseSetting(@RequestParam Map args) throws JsonProcessingException { 176 | ObjectMapper mapper = new ObjectMapper(); 177 | HashMap map = new HashMap(); 178 | String result; 179 | Response response = responseService.getResponseByID(args.get("id")); 180 | SecurityContext securityContext = SecurityContextHolder.getContext(); 181 | String username = securityContext.getAuthentication().getName(); 182 | int userLogID = userService.getLogIdByName(username); 183 | if (Objects.equals(response.getLogid(), userLogID)) { 184 | responseService.delOneResponse(args.get("id")); 185 | map.put("status", true); 186 | result = mapper.writeValueAsString(map); 187 | } else { 188 | map.put("status", false); 189 | result = mapper.writeValueAsString(map); 190 | } 191 | return result; 192 | } 193 | 194 | @ResponseBody 195 | @GetMapping(value = "/response_setting/delete_all", produces = "text/plain;charset=utf-8") 196 | public String deleteAllResponse() throws JsonProcessingException { 197 | ObjectMapper mapper = new ObjectMapper(); 198 | HashMap map = new HashMap(); 199 | String result; 200 | SecurityContext securityContext = SecurityContextHolder.getContext(); 201 | String username = securityContext.getAuthentication().getName(); 202 | int userLogID = userService.getLogIdByName(username); 203 | try { 204 | responseService.delAllResponse(userLogID); 205 | map.put("status", true); 206 | } catch (RuntimeException r) { 207 | map.put("status", false); 208 | } 209 | result = mapper.writeValueAsString(map); 210 | return result; 211 | } 212 | 213 | private void SetResponse(String responseType, String statusCode, String responseBody, String redirectURL, Response response) { 214 | if(responseType.equals("Data")){ 215 | response.setStatusCode(Integer.parseInt(statusCode)); 216 | response.setResponseBody(responseBody); 217 | response.setRedirectURL(""); 218 | }else if(responseType.equals("Error")){ 219 | response.setStatusCode(Integer.parseInt(statusCode)); 220 | response.setResponseBody(""); 221 | response.setRedirectURL(""); 222 | }else if(responseType.equals("Redirect")){ 223 | response.setRedirectURL(redirectURL); 224 | response.setStatusCode(302); 225 | response.setResponseBody(""); 226 | } 227 | } 228 | } -------------------------------------------------------------------------------- /src/main/java/bridge/controller/WeblogController.java: -------------------------------------------------------------------------------- 1 | package bridge.controller; 2 | 3 | 4 | import bridge.config.DnslogConfig; 5 | import bridge.model.WebLog; 6 | import bridge.service.UserService; 7 | import bridge.service.WeblogService; 8 | import com.fasterxml.jackson.core.JsonProcessingException; 9 | import com.fasterxml.jackson.databind.ObjectMapper; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.security.core.context.SecurityContext; 12 | import org.springframework.security.core.context.SecurityContextHolder; 13 | import org.springframework.stereotype.Controller; 14 | import org.springframework.ui.ModelMap; 15 | import org.springframework.web.bind.annotation.GetMapping; 16 | import org.springframework.web.bind.annotation.PostMapping; 17 | import org.springframework.web.bind.annotation.RequestParam; 18 | import org.springframework.web.bind.annotation.ResponseBody; 19 | import org.springframework.web.servlet.ModelAndView; 20 | 21 | import java.io.IOException; 22 | import java.util.*; 23 | 24 | @Controller 25 | public class WeblogController { 26 | 27 | @Autowired 28 | private WeblogService weblogService; 29 | 30 | 31 | @Autowired 32 | private UserService userService; 33 | 34 | 35 | @GetMapping("/weblog") 36 | public ModelAndView getWeblogList() throws IOException { 37 | List> weblogList = new ArrayList>(); 38 | SecurityContext securityContext = SecurityContextHolder.getContext(); 39 | String username = securityContext.getAuthentication().getName(); 40 | Integer userLogID = userService.getLogIdByName(username); 41 | String userDomain = String.valueOf(userLogID) + '.' + DnslogConfig.dnslogDomain; 42 | for (Object x : weblogService.getAllWeblog(userDomain)) { 43 | WebLog a = (WebLog) x; 44 | HashMap tmpMap = new HashMap(); 45 | ObjectMapper objectMapper = new ObjectMapper(); 46 | Map headerMap = objectMapper.readValue(a.getHeader(), Map.class); 47 | tmpMap.put("id", a.getId()); 48 | tmpMap.put("host", a.getHost()); 49 | tmpMap.put("ip", a.getIp()); 50 | tmpMap.put("method", a.getMethod()); 51 | tmpMap.put("path", a.getPath()); 52 | tmpMap.put("header", headerMap); 53 | tmpMap.put("version", a.getVersion()); 54 | if (a.getParams() == null) { 55 | tmpMap.put("query", ""); 56 | } else { 57 | tmpMap.put("query", "?" + a.getParams()); 58 | } 59 | tmpMap.put("userAgent", headerMap.get("user-agent").toString()); 60 | String timeString = a.getTime().toString(); 61 | tmpMap.put("time", timeString.substring(0, timeString.length() - 2)); 62 | if (a.getData() != null) { 63 | tmpMap.put("data", a.getData()); 64 | } else { 65 | tmpMap.put("data", ""); 66 | } 67 | weblogList.add(tmpMap); 68 | } 69 | ModelMap model = new ModelMap(); 70 | model.addAttribute("weblogList", weblogList); 71 | model.addAttribute("username", username); 72 | 73 | return new ModelAndView("weblog", model); 74 | } 75 | 76 | @ResponseBody 77 | @PostMapping(value = "/weblog/delete", produces = "text/plain;charset=utf-8") 78 | public String deleteOneWeblog(@RequestParam Map args) throws JsonProcessingException { 79 | ObjectMapper mapper = new ObjectMapper(); 80 | HashMap map = new HashMap(); 81 | String result; 82 | WebLog webLog = weblogService.getWeblogByID(args.get("id")); 83 | SecurityContext securityContext = SecurityContextHolder.getContext(); 84 | String username = securityContext.getAuthentication().getName(); 85 | int userLogID = userService.getLogIdByName(username); 86 | if (Objects.equals(webLog.getLogid(), userLogID)) { 87 | weblogService.delOneWeblog(args.get("id")); 88 | map.put("status", true); 89 | result = mapper.writeValueAsString(map); 90 | } else { 91 | map.put("status", false); 92 | result = mapper.writeValueAsString(map); 93 | } 94 | return result; 95 | } 96 | 97 | @ResponseBody 98 | @GetMapping(value = "/weblog/delete_all", produces = "text/plain;charset=utf-8") 99 | public String deleteAllWeblog() throws JsonProcessingException { 100 | ObjectMapper mapper = new ObjectMapper(); 101 | HashMap map = new HashMap(); 102 | String result; 103 | SecurityContext securityContext = SecurityContextHolder.getContext(); 104 | String username = securityContext.getAuthentication().getName(); 105 | int userLogID = userService.getLogIdByName(username); 106 | try { 107 | weblogService.delAllWeblog(userLogID); 108 | map.put("status", true); 109 | } catch (RuntimeException r) { 110 | map.put("status", false); 111 | } 112 | result = mapper.writeValueAsString(map); 113 | return result; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/bridge/dnsserver/DNSHandler.java: -------------------------------------------------------------------------------- 1 | package bridge.dnsserver; 2 | 3 | import bridge.config.DnslogConfig; 4 | import bridge.model.DnsLog; 5 | import bridge.model.DnsRecordA; 6 | import bridge.model.DnsRecordRebind; 7 | import bridge.service.DnsLogService; 8 | import bridge.service.DnsRecordAService; 9 | import bridge.service.DnsRecordRebindService; 10 | import com.fasterxml.jackson.databind.ObjectMapper; 11 | import com.google.common.collect.Maps; 12 | import io.netty.buffer.ByteBuf; 13 | import io.netty.buffer.Unpooled; 14 | import io.netty.channel.ChannelHandlerContext; 15 | import io.netty.channel.SimpleChannelInboundHandler; 16 | import io.netty.handler.codec.dns.*; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import org.springframework.stereotype.Component; 19 | import org.springframework.web.client.HttpServerErrorException; 20 | import org.springframework.web.client.RestTemplate; 21 | 22 | import javax.jws.Oneway; 23 | import java.io.IOException; 24 | import java.sql.Timestamp; 25 | import java.util.*; 26 | import java.util.regex.Pattern; 27 | import java.util.stream.Collectors; 28 | 29 | @Component 30 | public class DNSHandler extends SimpleChannelInboundHandler { 31 | 32 | private String domain = DnslogConfig.dnslogDomain; 33 | 34 | @Autowired 35 | private DnsLogService dnsLogService; 36 | 37 | private static Map questionDomainMap = Maps.newConcurrentMap(); 38 | 39 | private static Map> rebindRecordMap = Maps.newConcurrentMap(); 40 | 41 | @Autowired 42 | private DnsRecordAService dnsRecordAService; 43 | 44 | @Autowired 45 | private DnsRecordRebindService dnsRecordRebindService; 46 | 47 | 48 | @Override 49 | public void channelRead0(ChannelHandlerContext ctx, DatagramDnsQuery query) throws Exception { 50 | ByteBuf answerIP; 51 | int logID; 52 | DatagramDnsResponse response = new DatagramDnsResponse(query.recipient(), query.sender(), query.id()); 53 | DefaultDnsQuestion dnsQuestion = query.recordAt(DnsSection.QUESTION); 54 | query.sender().getHostName(); 55 | String connectIP = query.sender().getAddress().toString(); 56 | String domainRegex = "\\.\\d+\\." + domain.replace(".", "\\.") + "\\.$"; 57 | String subDomain = dnsQuestion.name().replaceAll(domainRegex, ""); 58 | String[] hd = dnsQuestion.name().replace('.' + domain + '.', "").split("\\."); 59 | try { 60 | logID = Integer.parseInt(hd[hd.length - 1]); 61 | } catch (NumberFormatException n) { 62 | return; 63 | } 64 | String ipRegex = "^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$"; 65 | String rebindRegex = "^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$"; 66 | if (Pattern.compile(rebindRegex).matcher(subDomain).matches()) { 67 | String[] s = subDomain.split("\\."); 68 | byte[] ip = new byte[4]; 69 | byte[] rebindIP = new byte[4]; 70 | for (int i = 0; i < s.length; i++) { 71 | if (i < 4) { 72 | ip[i] = (byte) Integer.parseInt(s[i]); 73 | } else { 74 | rebindIP[i - 4] = (byte) Integer.parseInt(s[i]); 75 | } 76 | } 77 | if (questionDomainMap.containsKey(dnsQuestion.name())) { 78 | answerIP = Unpooled.wrappedBuffer(questionDomainMap.get(dnsQuestion.name())); 79 | questionDomainMap.remove(dnsQuestion.name()); 80 | } else { 81 | answerIP = Unpooled.wrappedBuffer(ip); 82 | questionDomainMap.put(dnsQuestion.name(), rebindIP); 83 | } 84 | } else if (Pattern.compile(ipRegex).matcher(subDomain).matches()) { 85 | String[] s = subDomain.split("\\."); 86 | byte[] ip = new byte[s.length]; 87 | for (int i = 0; i < s.length; i++) { 88 | ip[i] = (byte) Integer.parseInt(s[i]); 89 | } 90 | answerIP = Unpooled.wrappedBuffer(ip); 91 | }else if(dnsRecordAService.getDnsRecordABySubdomain(dnsQuestion.name().substring(0,dnsQuestion.name().length()-1)) != null){ 92 | DnsRecordA dnsRecordA = dnsRecordAService.getDnsRecordABySubdomain(dnsQuestion.name().substring(0,dnsQuestion.name().length()-1)); 93 | List byteIP = stringIP2ByteArrayIP(dnsRecordA.getIp()); 94 | answerIP = Unpooled.wrappedBuffer(new byte[]{byteIP.get(0), byteIP.get(1), byteIP.get(2), byteIP.get(3)}); 95 | }else if(dnsRecordRebindService.getDnsRecordRebindBySubdomain(dnsQuestion.name().substring(0,dnsQuestion.name().length()-1)) != null){ 96 | DnsRecordRebind dnsRecordRebind = dnsRecordRebindService.getDnsRecordRebindBySubdomain(dnsQuestion.name().substring(0,dnsQuestion.name().length()-1)); 97 | String rebindSubDomain = dnsRecordRebind.getSubdomain(); 98 | if(rebindRecordMap.containsKey(rebindSubDomain)){ 99 | String matchIP = isInIPC(connectIP.split("/")[1], rebindRecordMap.get(rebindSubDomain)); 100 | if(!matchIP.equals("")){ 101 | List byteIP = stringIP2ByteArrayIP(dnsRecordRebind.getIp2()); 102 | answerIP = Unpooled.wrappedBuffer(new byte[]{byteIP.get(0), byteIP.get(1), byteIP.get(2), byteIP.get(3)}); 103 | rebindRecordMap.get(rebindSubDomain).remove(matchIP); 104 | }else{ 105 | List byteIP = stringIP2ByteArrayIP(dnsRecordRebind.getIp1()); 106 | answerIP = Unpooled.wrappedBuffer(new byte[]{byteIP.get(0), byteIP.get(1), byteIP.get(2), byteIP.get(3)}); 107 | rebindRecordMap.get(rebindSubDomain).add(connectIP.split("/")[1]); 108 | } 109 | 110 | }else{ 111 | List tmpList = new ArrayList<>(); 112 | System.out.println(connectIP); 113 | tmpList.add(connectIP.split("/")[1]); 114 | rebindRecordMap.put(rebindSubDomain, tmpList); 115 | List byteIP = stringIP2ByteArrayIP(dnsRecordRebind.getIp1()); 116 | answerIP = Unpooled.wrappedBuffer(new byte[]{byteIP.get(0), byteIP.get(1), byteIP.get(2), byteIP.get(3)}); 117 | } 118 | System.out.println(rebindRecordMap); 119 | } else { 120 | List byteIP = stringIP2ByteArrayIP(DnslogConfig.ip); 121 | answerIP = Unpooled.wrappedBuffer(new byte[]{byteIP.get(0), byteIP.get(1), byteIP.get(2), byteIP.get(3)}); 122 | } 123 | response.addRecord(DnsSection.QUESTION, dnsQuestion); 124 | DefaultDnsRawRecord queryAnswer = new DefaultDnsRawRecord(dnsQuestion.name(), DnsRecordType.A, 0, answerIP); 125 | response.addRecord(DnsSection.ANSWER, queryAnswer); 126 | ctx.writeAndFlush(response); 127 | String address = getIPAdderssInfo(connectIP.split("/")[1]); 128 | String connectAddress = connectIP+' '+address; 129 | if(!dnsQuestion.name().replaceAll("\\d+\\." + domain.replace(".", "\\.") + "\\.$", "").equals("")){ 130 | DnsLog dnslog = new DnsLog(UUID.randomUUID().toString(), dnsQuestion.name().substring(0, dnsQuestion.name().length() - 1), new Timestamp(System.currentTimeMillis()), connectAddress, dnsQuestion.type().toString(), logID); 131 | dnsLogService.addDnsLog(dnslog); 132 | getIPAdderssInfo(connectIP.split("/")[1]); 133 | } 134 | } 135 | 136 | 137 | private List stringIP2ByteArrayIP(String ip) { 138 | return Arrays.asList(ip.split("\\.")).stream().map(x -> (byte) Integer.parseInt(x)).collect(Collectors.toList()); 139 | } 140 | 141 | private String getIPAdderssInfo(String ip) throws IOException { 142 | String address = ""; 143 | String requestURL = "http://ip-api.com/json/"+ip+"?lang=zh-CN"; 144 | RestTemplate restTemplate = new RestTemplate(); 145 | try{ 146 | String responseText = restTemplate.getForEntity(requestURL,String.class).getBody(); 147 | ObjectMapper objectMapper = new ObjectMapper(); 148 | Map responseTextMap = objectMapper.readValue(responseText,Map.class); 149 | if(responseTextMap.containsKey("status") && responseTextMap.get("status").equals("success")){ 150 | if(responseTextMap.containsKey("country")){ 151 | address+=responseTextMap.get("country"); 152 | }else{ 153 | address+="unknown"; 154 | } 155 | if(responseTextMap.containsKey("city")){ 156 | address+="/"+responseTextMap.get("city"); 157 | }else { 158 | address+="/unknown"; 159 | } 160 | } 161 | }catch (HttpServerErrorException e){ 162 | return ""; 163 | } 164 | return address; 165 | } 166 | 167 | private String isInIPC(String thisIP, List ipList){ 168 | String[] thisIPList = thisIP.split("\\."); 169 | for(String ip : ipList) { 170 | String[] cIpList = ip.split("\\."); 171 | if(thisIPList[0].equals(cIpList[0]) && thisIPList[1].equals(cIpList[1]) && thisIPList[2].equals(cIpList[2])){ 172 | return ip; 173 | } 174 | } 175 | return ""; 176 | } 177 | 178 | 179 | } -------------------------------------------------------------------------------- /src/main/java/bridge/dnsserver/UDPServer.java: -------------------------------------------------------------------------------- 1 | package bridge.dnsserver; 2 | 3 | import io.netty.bootstrap.Bootstrap; 4 | import io.netty.channel.ChannelFuture; 5 | import io.netty.channel.ChannelInitializer; 6 | import io.netty.channel.ChannelOption; 7 | import io.netty.channel.nio.NioEventLoopGroup; 8 | import io.netty.channel.socket.nio.NioDatagramChannel; 9 | import io.netty.handler.codec.dns.DatagramDnsQueryDecoder; 10 | import io.netty.handler.codec.dns.DatagramDnsResponseEncoder; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Component; 13 | 14 | 15 | @Component 16 | public class UDPServer { 17 | 18 | @Autowired 19 | private DNSHandler dnsHandler; 20 | 21 | public void start() { 22 | 23 | final NioEventLoopGroup group = new NioEventLoopGroup(); 24 | try { 25 | Bootstrap bootstrap = new Bootstrap(); 26 | bootstrap.group(group).channel(NioDatagramChannel.class) 27 | .handler(new ChannelInitializer() { 28 | @Override 29 | protected void initChannel(NioDatagramChannel nioDatagramChannel) throws Exception { 30 | nioDatagramChannel.pipeline().addLast(new DatagramDnsQueryDecoder()); 31 | nioDatagramChannel.pipeline().addLast(new DatagramDnsResponseEncoder()); 32 | nioDatagramChannel.pipeline().addLast(dnsHandler); 33 | } 34 | }).option(ChannelOption.SO_BROADCAST, true); 35 | 36 | ChannelFuture future = bootstrap.bind("0.0.0.0", 53).sync(); 37 | future.channel().closeFuture().sync(); 38 | } catch (InterruptedException e) { 39 | e.printStackTrace(); 40 | } finally { 41 | group.shutdownGracefully(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/bridge/intercept/AppWebConfiguration.java: -------------------------------------------------------------------------------- 1 | package bridge.intercept; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; 7 | 8 | @Component 9 | public class AppWebConfiguration extends WebMvcConfigurationSupport { 10 | @Autowired 11 | WebLogIntercept webLogIntercept; 12 | 13 | @Override 14 | public void addInterceptors(InterceptorRegistry registry) { 15 | registry.addInterceptor(webLogIntercept).addPathPatterns("/**"); 16 | super.addInterceptors(registry); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/bridge/intercept/WebLogIntercept.java: -------------------------------------------------------------------------------- 1 | package bridge.intercept; 2 | 3 | import bridge.config.DnslogConfig; 4 | import bridge.model.Response; 5 | import bridge.model.WebLog; 6 | import bridge.service.ResponseService; 7 | import bridge.service.WeblogService; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | import org.apache.tomcat.util.buf.MessageBytes; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | import org.springframework.web.servlet.HandlerInterceptor; 13 | 14 | import javax.servlet.http.HttpServletRequest; 15 | import javax.servlet.http.HttpServletResponse; 16 | import java.io.BufferedReader; 17 | import java.io.IOException; 18 | import java.io.PrintWriter; 19 | import java.lang.reflect.Field; 20 | import java.sql.Timestamp; 21 | import java.util.*; 22 | 23 | @Component 24 | public class WebLogIntercept implements HandlerInterceptor { 25 | 26 | @Autowired 27 | private WebLog webLog; 28 | 29 | 30 | @Autowired 31 | private WeblogService weblogService; 32 | 33 | @Autowired 34 | private ResponseService responseService; 35 | 36 | @Override 37 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 38 | String host = request.getHeader("host").replaceAll(":(.*)", "").trim(); 39 | Integer logID; 40 | if (host.equals(DnslogConfig.managerDomain)) { 41 | return true; 42 | } else { 43 | ObjectMapper mapper = new ObjectMapper(); 44 | PrintWriter writer = response.getWriter(); 45 | response.setCharacterEncoding("utf-8"); 46 | response.setContentType("application/json; charset=utf-8"); 47 | HashMap map = new HashMap(); 48 | String[] hd = host.replace('.' + DnslogConfig.dnslogDomain, "").split("\\."); 49 | try { 50 | logID = Integer.parseInt(hd[hd.length - 1]); 51 | } catch (NumberFormatException n) { 52 | map.put("status", "error"); 53 | map.put("message", "request host no logid found"); 54 | writer.write(mapper.writeValueAsString(map)); 55 | return false; 56 | } 57 | if (!host.endsWith(DnslogConfig.dnslogDomain)) { 58 | map.put("status", "error"); 59 | map.put("message", "request host no logid found"); 60 | writer.write(mapper.writeValueAsString(map)); 61 | return false; 62 | } 63 | webLog.setLogid(logID); 64 | webLog.setHost(host); 65 | webLog.setTime(new Timestamp(System.currentTimeMillis())); 66 | webLog.setId(UUID.randomUUID().toString()); 67 | webLog.setMethod(request.getMethod()); 68 | webLog.setParams(request.getQueryString()); 69 | 70 | Object a = findCoyoteRequest(request); 71 | Field coyoteRequest = a.getClass().getDeclaredField("coyoteRequest"); 72 | coyoteRequest.setAccessible(true); 73 | Object b = coyoteRequest.get(a); 74 | 75 | Field uriMB = b.getClass().getDeclaredField("uriMB"); 76 | uriMB.setAccessible(true); 77 | MessageBytes c = (MessageBytes) uriMB.get(b); 78 | webLog.setPath(c.getString()); 79 | 80 | 81 | HashMap headersMap = new HashMap(); 82 | Enumeration e = request.getHeaderNames(); 83 | while (e.hasMoreElements()) { 84 | String headerName = e.nextElement(); 85 | Enumeration headerValues = request.getHeaders(headerName); 86 | while (headerValues.hasMoreElements()) { 87 | headersMap.put(headerName, headerValues.nextElement()); 88 | } 89 | } 90 | webLog.setHeader(mapper.writeValueAsString(headersMap)); 91 | webLog.setData(getBodyData(request)); 92 | webLog.setIp(getIPAddress(request)); 93 | webLog.setVersion(request.getProtocol()); 94 | weblogService.addWeblog(webLog); 95 | if(responseService.getResponseBySubdomain(host) != null){ 96 | Response responseData = responseService.getResponseBySubdomain(host); 97 | if(responseData.getResponseType().equals("Data")){ 98 | String responseBody = responseData.getResponseBody(); 99 | int statusCode = responseData.getStatusCode(); 100 | ArrayList headerList = mapper.readValue(responseData.getHeaders(),ArrayList.class); 101 | writer.write(responseBody); 102 | response.setStatus(statusCode); 103 | if(headerList.size() > 0){ 104 | for(Object x:headerList){ 105 | String[] keyValue = ((String) x).split(":"); 106 | response.setHeader(keyValue[0],keyValue[1]); 107 | } 108 | } 109 | }else if(responseData.getResponseType().equals("Redirect")){ 110 | String redirectURL = responseData.getRedirectURL(); 111 | response.setStatus(responseData.getStatusCode()); 112 | response.setHeader("Location", redirectURL); 113 | ArrayList headerList = mapper.readValue(responseData.getHeaders(),ArrayList.class); 114 | if(headerList.size() > 0){ 115 | for(Object x:headerList){ 116 | String[] keyValue = ((String) x).split(":"); 117 | response.setHeader(keyValue[0],keyValue[1]); 118 | } 119 | } 120 | }else if(responseData.getResponseType().equals("Error")){ 121 | ArrayList headerList = mapper.readValue(responseData.getHeaders(),ArrayList.class); 122 | if(headerList.size() > 0){ 123 | for(Object x:headerList){ 124 | String[] keyValue = ((String) x).split(":"); 125 | response.setHeader(keyValue[0],keyValue[1]); 126 | } 127 | } 128 | response.sendError(responseData.getStatusCode()); 129 | }else{ 130 | map.put("status", "success"); 131 | map.put("message", "response type in database error"); 132 | writer.write(mapper.writeValueAsString(map)); 133 | } 134 | }else{ 135 | map.put("status", "success"); 136 | map.put("message", "ok"); 137 | writer.write(mapper.writeValueAsString(map)); 138 | } 139 | return false; 140 | } 141 | } 142 | 143 | private String getBodyData(HttpServletRequest request) { 144 | StringBuffer data = new StringBuffer(); 145 | String line = null; 146 | BufferedReader reader = null; 147 | try { 148 | reader = request.getReader(); 149 | while (null != (line = reader.readLine())) 150 | data.append(line); 151 | } catch (IOException e) { 152 | } finally { 153 | } 154 | return data.toString(); 155 | } 156 | 157 | private String getIPAddress(HttpServletRequest request) { 158 | String ipAddress = request.getHeader("X-FORWARDED-FOR"); 159 | if (ipAddress == null) { 160 | ipAddress = request.getRemoteAddr(); 161 | } 162 | return ipAddress; 163 | } 164 | 165 | 166 | private Class getClassByName(Class classObject, String name) { 167 | Map> fieldMap = new HashMap<>(); 168 | Class returnClass = null; 169 | Class tempClass = classObject; 170 | while (tempClass != null) { 171 | fieldMap.put(tempClass, Arrays.asList(tempClass.getDeclaredFields())); 172 | tempClass = tempClass.getSuperclass(); 173 | } 174 | 175 | for (Map.Entry> entry : fieldMap.entrySet()) { 176 | for (Field f : entry.getValue()) { 177 | if (f.getName().equals(name)) { 178 | returnClass = entry.getKey(); 179 | break; 180 | } 181 | } 182 | } 183 | return returnClass; 184 | } 185 | 186 | private Object findCoyoteRequest(Object request) throws Exception { 187 | Class a = getClassByName(request.getClass(), "request"); 188 | Field request1 = a.getDeclaredField("request"); 189 | request1.setAccessible(true); 190 | Object b = request1.get(request); 191 | if (getClassByName(b.getClass(), "coyoteRequest") == null) { 192 | return findCoyoteRequest(b); 193 | } else { 194 | return b; 195 | } 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /src/main/java/bridge/mapper/DnsRecordAMapper.java: -------------------------------------------------------------------------------- 1 | package bridge.mapper; 2 | 3 | 4 | import bridge.model.DnsRecordA; 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.apache.ibatis.annotations.Update; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | @Repository 14 | public interface DnsRecordAMapper { 15 | 16 | @Insert("insert into dns_record_a(id,subdomain,time,ip,logid) values(#{id},#{subdomain},#{time},#{ip},#{logid})") 17 | void insert(DnsRecordA dnsRecordA); 18 | 19 | @Select("select * from dns_record_a where subdomain = #{subdomain} limit 1") 20 | DnsRecordA selectDnsRecordABySubdomain(String subdomain); 21 | 22 | @Select("select * from dns_record_a where subdomain like concat('%',#{0},'%') order by time desc") 23 | List getAll(String subdomain); 24 | 25 | @Select("select * from dns_record_a where id = #{id} limit 1") 26 | DnsRecordA selectDnsRecordAByID(String id); 27 | 28 | @Delete("delete from dns_record_a where id=#{id}") 29 | void deleteOneByID(String id); 30 | 31 | @Delete("delete from dns_record_a where logid=#{logid}") 32 | void deleteAllDnsRecordABylogID(int logid); 33 | 34 | @Update("update dns_record_a set subdomain=#{subdomain},ip=#{ip},time=#{time} where id=#{id}") 35 | void updateByID(DnsRecordA dnsRecordA); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/bridge/mapper/DnsRecordRebindMapper.java: -------------------------------------------------------------------------------- 1 | package bridge.mapper; 2 | 3 | 4 | import bridge.model.DnsRecordRebind; 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.apache.ibatis.annotations.Update; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | @Repository 14 | public interface DnsRecordRebindMapper { 15 | 16 | @Insert("insert into dns_record_rebind(id,subdomain,time,ip1,ip2,logid) values(#{id},#{subdomain},#{time},#{ip1},#{ip2},#{logid})") 17 | void insert(DnsRecordRebind dnsRecordRebind); 18 | 19 | @Select("select * from dns_record_rebind where subdomain = #{subdomain} limit 1") 20 | DnsRecordRebind selectDnsRecordRebindBySubdomain(String subdomain); 21 | 22 | @Select("select * from dns_record_rebind where subdomain like concat('%',#{0},'%') order by time desc") 23 | List getAll(String subdomain); 24 | 25 | @Select("select * from dns_record_rebind where id = #{id} limit 1") 26 | DnsRecordRebind selectDnsRecordRebindByID(String id); 27 | 28 | @Delete("delete from dns_record_rebind where id=#{id}") 29 | void deleteOneByID(String id); 30 | 31 | @Delete("delete from dns_record_rebind where logid=#{logid}") 32 | void deleteAllDnsRecordRebindBylogID(int logid); 33 | 34 | @Update("update dns_record_rebind set subdomain=#{subdomain},ip1=#{ip1},ip1=#{ip2},time=#{time}, where id=#{id}") 35 | void updateByID(DnsRecordRebind dnsRecordRebind); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/bridge/mapper/DnslogMapper.java: -------------------------------------------------------------------------------- 1 | package bridge.mapper; 2 | 3 | import bridge.model.DnsLog; 4 | import org.apache.ibatis.annotations.Delete; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Select; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | 12 | @Repository 13 | public interface DnslogMapper { 14 | 15 | @Insert("insert into dnslog(id,host,time,ip,type,logid) values(#{id},#{host},#{time},#{ip},#{type},#{logid})") 16 | void insert(DnsLog dnslog); 17 | 18 | @Select("select * from dnslog where host like concat('%',#{0},'%') order by time desc") 19 | List getAll(String host); 20 | 21 | @Delete("delete from dnslog where id=#{id}") 22 | void deleteOneByID(String id); 23 | 24 | @Delete("delete from dnslog where logid=#{logid}") 25 | void deleteAllBylogID(int logid); 26 | 27 | @Select("select * from dnslog where id = #{id} limit 1") 28 | DnsLog selectDnslogByID(String id); 29 | 30 | @Select("select * from dnslog where host = #{host}") 31 | List selectDnsLogByHost(String host); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/bridge/mapper/ResponseMapper.java: -------------------------------------------------------------------------------- 1 | package bridge.mapper; 2 | 3 | 4 | import bridge.model.Response; 5 | import org.apache.ibatis.annotations.Delete; 6 | import org.apache.ibatis.annotations.Insert; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.apache.ibatis.annotations.Update; 9 | import org.springframework.stereotype.Repository; 10 | 11 | import java.util.List; 12 | 13 | @Repository 14 | public interface ResponseMapper { 15 | 16 | @Insert("insert into response(id,subDomain,responseType,statusCode,responseBody,headers,redirectURL,logid,time) values(#{id},#{subDomain},#{responseType},#{statusCode},#{responseBody},#{headers},#{redirectURL},#{logid},#{time})") 17 | void insert(Response response); 18 | 19 | @Select("select * from response where subDomain = #{subDomain} limit 1") 20 | Response selectResponseBySubdomain(String subDomain); 21 | 22 | @Select("select * from response where id = #{id} limit 1") 23 | Response selectResponseByID(String id); 24 | 25 | @Select("select * from response where subDomain like concat('%',#{0},'%') order by time desc") 26 | List getAll(String subDomain); 27 | 28 | @Update("update response set subDomain=#{subDomain}, responseType=#{responseType},statusCode=#{statusCode},responseBody=#{responseBody},headers=#{headers},time=#{time}, redirectURL=#{redirectURL} where id=#{id}") 29 | void updateByID(Response response); 30 | 31 | @Delete("delete from response where id=#{id}") 32 | void deleteOneByID(String id); 33 | 34 | @Delete("delete from response where logid=#{logid}") 35 | void deleteAllBylogID(int logid); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/bridge/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package bridge.mapper; 2 | 3 | import bridge.model.User; 4 | import org.apache.ibatis.annotations.Insert; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Repository 9 | public interface UserMapper { 10 | @Insert("insert into user (userid,username,password,logid,apikey) values(#{userid},#{username},#{password},#{logid},#{apiKey})") 11 | void insert(User user); 12 | 13 | @Select("select userid,username,password,logid,apiKey from user where username = #{username}") 14 | User getUserByUsername(String username); 15 | 16 | @Select("select userid,username,logid,apiKey from user where apiKey = #{token}") 17 | User getUserByToken(String token); 18 | 19 | @Select("select logid from user order by logid desc limit 1") 20 | Integer getLastLogID(); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/bridge/mapper/WeblogMapper.java: -------------------------------------------------------------------------------- 1 | package bridge.mapper; 2 | 3 | import bridge.model.WebLog; 4 | import org.apache.ibatis.annotations.Delete; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Select; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public interface WeblogMapper { 13 | 14 | @Insert("insert into weblog(id,host,time,ip,path,header,method,params,data,logid,version) values(#{id},#{host},#{time},#{ip},#{path},#{header},#{method},#{params},#{data},#{logid},#{version})") 15 | void insert(WebLog webLog); 16 | 17 | 18 | @Select("select * from weblog where host like concat('%',#{0},'%') order by time desc") 19 | List getAll(String host); 20 | 21 | @Delete("delete from weblog where id=#{id}") 22 | void deleteOneByID(String id); 23 | 24 | @Delete("delete from weblog where logid=#{logid}") 25 | void deleteAllBylogID(int logid); 26 | 27 | @Select("select * from weblog where id = #{id} limit 1") 28 | WebLog selectWeblogByID(String id); 29 | 30 | @Select("select * from weblog where host = #{host}") 31 | List selectWebLogByHost(String host); 32 | } -------------------------------------------------------------------------------- /src/main/java/bridge/model/DnsLog.java: -------------------------------------------------------------------------------- 1 | package bridge.model; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Timestamp; 5 | 6 | public class DnsLog implements Serializable { 7 | 8 | private static final long serialVersionUID = 1L; 9 | private String id; 10 | private String host; 11 | private Timestamp time; 12 | private String ip; 13 | private String type; 14 | private int logid; 15 | 16 | 17 | public DnsLog() { 18 | super(); 19 | } 20 | 21 | public DnsLog(String id, String host, Timestamp time, String ip, String type, int logid) { 22 | super(); 23 | this.id = id; 24 | this.host = host; 25 | this.time = time; 26 | this.ip = ip; 27 | this.type = type; 28 | this.logid = logid; 29 | } 30 | 31 | public String getHost() { 32 | return host; 33 | } 34 | 35 | public void setHost(String host) { 36 | this.host = host; 37 | } 38 | 39 | public Timestamp getTime() { 40 | return time; 41 | } 42 | 43 | public void setTime(Timestamp time) { 44 | this.time = time; 45 | } 46 | 47 | public String getIp() { 48 | return ip; 49 | } 50 | 51 | public void setIp(String ip) { 52 | this.ip = ip; 53 | } 54 | 55 | public String getType() { 56 | return type; 57 | } 58 | 59 | public void setType(String type) { 60 | this.type = type; 61 | } 62 | 63 | public String getId() { 64 | return id; 65 | } 66 | 67 | public void setId(String id) { 68 | this.id = id; 69 | } 70 | 71 | public int getLogid() { 72 | return logid; 73 | } 74 | 75 | public void setLogid(int logid) { 76 | this.logid = logid; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/bridge/model/DnsRecordA.java: -------------------------------------------------------------------------------- 1 | package bridge.model; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Timestamp; 5 | 6 | public class DnsRecordA implements Serializable { 7 | private static final long serialVersionUID = 1L; 8 | private String id; 9 | private String subdomain; 10 | private Timestamp time; 11 | private String ip; 12 | private int logid; 13 | 14 | public DnsRecordA() { 15 | } 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getSubdomain() { 26 | return subdomain; 27 | } 28 | 29 | public void setSubdomain(String subdomain) { 30 | this.subdomain = subdomain; 31 | } 32 | 33 | public Timestamp getTime() { 34 | return time; 35 | } 36 | 37 | public void setTime(Timestamp time) { 38 | this.time = time; 39 | } 40 | 41 | public String getIp() { 42 | return ip; 43 | } 44 | 45 | public void setIp(String ip) { 46 | this.ip = ip; 47 | } 48 | 49 | public int getLogid() { 50 | return logid; 51 | } 52 | 53 | public void setLogid(int logid) { 54 | this.logid = logid; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/bridge/model/DnsRecordRebind.java: -------------------------------------------------------------------------------- 1 | package bridge.model; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Timestamp; 5 | 6 | public class DnsRecordRebind implements Serializable { 7 | 8 | 9 | private static final long serialVersionUID = 1L; 10 | private String id; 11 | private String subdomain; 12 | private Timestamp time; 13 | private String ip1; 14 | private String ip2; 15 | private int logid; 16 | 17 | public String getId() { 18 | return id; 19 | } 20 | 21 | public void setId(String id) { 22 | this.id = id; 23 | } 24 | 25 | public String getSubdomain() { 26 | return subdomain; 27 | } 28 | 29 | public void setSubdomain(String subdomain) { 30 | this.subdomain = subdomain; 31 | } 32 | 33 | public Timestamp getTime() { 34 | return time; 35 | } 36 | 37 | public void setTime(Timestamp time) { 38 | this.time = time; 39 | } 40 | 41 | public String getIp1() { 42 | return ip1; 43 | } 44 | 45 | public void setIp1(String ip1) { 46 | this.ip1 = ip1; 47 | } 48 | 49 | public String getIp2() { 50 | return ip2; 51 | } 52 | 53 | public void setIp2(String ip2) { 54 | this.ip2 = ip2; 55 | } 56 | 57 | public int getLogid() { 58 | return logid; 59 | } 60 | 61 | public void setLogid(int logid) { 62 | this.logid = logid; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/bridge/model/Response.java: -------------------------------------------------------------------------------- 1 | package bridge.model; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Timestamp; 5 | 6 | public class Response implements Serializable { 7 | 8 | private static final long serialVersionUID = 1L; 9 | private String id; 10 | private String subDomain; 11 | private String responseType; 12 | private int statusCode; 13 | private String responseBody; 14 | private String headers; 15 | private String redirectURL; 16 | private int logid; 17 | private Timestamp time; 18 | 19 | 20 | public String getId() { 21 | return id; 22 | } 23 | 24 | public void setId(String id) { 25 | this.id = id; 26 | } 27 | 28 | public String getSubDomain() { 29 | return subDomain; 30 | } 31 | 32 | public void setSubDomain(String subDomain) { 33 | this.subDomain = subDomain; 34 | } 35 | 36 | public String getResponseType() { 37 | return responseType; 38 | } 39 | 40 | public void setResponseType(String responseType) { 41 | this.responseType = responseType; 42 | } 43 | 44 | public int getStatusCode() { 45 | return statusCode; 46 | } 47 | 48 | public void setStatusCode(int statusCode) { 49 | this.statusCode = statusCode; 50 | } 51 | 52 | public String getResponseBody() { 53 | return responseBody; 54 | } 55 | 56 | public void setResponseBody(String responseBody) { 57 | this.responseBody = responseBody; 58 | } 59 | 60 | public String getHeaders() { 61 | return headers; 62 | } 63 | 64 | public void setHeaders(String headers) { 65 | this.headers = headers; 66 | } 67 | 68 | public String getRedirectURL() { 69 | return redirectURL; 70 | } 71 | 72 | public void setRedirectURL(String redirectURL) { 73 | this.redirectURL = redirectURL; 74 | } 75 | 76 | public int getLogid() { 77 | return logid; 78 | } 79 | 80 | public void setLogid(int logid) { 81 | this.logid = logid; 82 | } 83 | 84 | public Timestamp getTime() { 85 | return time; 86 | } 87 | 88 | public void setTime(Timestamp time) { 89 | this.time = time; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/bridge/model/User.java: -------------------------------------------------------------------------------- 1 | package bridge.model; 2 | 3 | import java.io.Serializable; 4 | 5 | public class User implements Serializable { 6 | 7 | private static final long serialVersionUID = 1L; 8 | 9 | private String username; 10 | 11 | private String password; 12 | 13 | private Integer logid; 14 | 15 | private String userid; 16 | 17 | private String apiKey; 18 | 19 | 20 | public String getUsername() { 21 | return username; 22 | } 23 | 24 | public void setUsername(String username) { 25 | this.username = username; 26 | } 27 | 28 | public String getPassword() { 29 | return password; 30 | } 31 | 32 | public void setPassword(String password) { 33 | this.password = password; 34 | } 35 | 36 | public Integer getLogid() { 37 | return logid; 38 | } 39 | 40 | public void setLogid(Integer logid) { 41 | this.logid = logid; 42 | } 43 | 44 | public String getUserid() { 45 | return userid; 46 | } 47 | 48 | public void setUserid(String userid) { 49 | this.userid = userid; 50 | } 51 | 52 | public String getApiKey() { 53 | return apiKey; 54 | } 55 | 56 | public void setApiKey(String apiKey) { 57 | this.apiKey = apiKey; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/bridge/model/WebLog.java: -------------------------------------------------------------------------------- 1 | package bridge.model; 2 | 3 | import org.springframework.stereotype.Repository; 4 | 5 | import java.io.Serializable; 6 | import java.sql.Timestamp; 7 | 8 | 9 | @Repository 10 | public class WebLog implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | private String id; 14 | private String host; 15 | private Timestamp time; 16 | private String ip; 17 | private String path; 18 | private String header; 19 | private String method; 20 | private String params; 21 | private String data; 22 | private String version; 23 | private int logid; 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | public String getHost() { 34 | return host; 35 | } 36 | 37 | public void setHost(String host) { 38 | this.host = host; 39 | } 40 | 41 | public Timestamp getTime() { 42 | return time; 43 | } 44 | 45 | public void setTime(Timestamp time) { 46 | this.time = time; 47 | } 48 | 49 | public String getIp() { 50 | return ip; 51 | } 52 | 53 | public void setIp(String ip) { 54 | this.ip = ip; 55 | } 56 | 57 | public String getPath() { 58 | return path; 59 | } 60 | 61 | public void setPath(String path) { 62 | this.path = path; 63 | } 64 | 65 | public String getHeader() { 66 | return header; 67 | } 68 | 69 | public void setHeader(String header) { 70 | this.header = header; 71 | } 72 | 73 | public String getMethod() { 74 | return method; 75 | } 76 | 77 | public void setMethod(String method) { 78 | this.method = method; 79 | } 80 | 81 | public int getLogid() { 82 | return logid; 83 | } 84 | 85 | public void setLogid(int logid) { 86 | this.logid = logid; 87 | } 88 | 89 | public String getParams() { 90 | return params; 91 | } 92 | 93 | public void setParams(String params) { 94 | this.params = params; 95 | } 96 | 97 | public String getData() { 98 | return data; 99 | } 100 | 101 | public void setData(String data) { 102 | this.data = data; 103 | } 104 | 105 | public String getVersion() { 106 | return version; 107 | } 108 | 109 | public void setVersion(String version) { 110 | this.version = version; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/bridge/security/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package bridge.security; 2 | 3 | import bridge.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 11 | 12 | @Configuration 13 | @EnableWebSecurity 14 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 15 | 16 | @Autowired 17 | private UserService userService; 18 | 19 | 20 | @Override 21 | protected void configure(HttpSecurity http) throws Exception { 22 | http.authorizeRequests() 23 | .antMatchers("/", "/login", "logout").permitAll() 24 | .antMatchers("/dnslog/**").hasAuthority("USER") 25 | .antMatchers("/weblog/**").hasAuthority("USER") 26 | .antMatchers("/api_info/**").hasAuthority("USER") 27 | .antMatchers("/dns_setting/**").hasAuthority("USER") 28 | .antMatchers("/response_setting/**").hasAuthority("USER") 29 | .and() 30 | .formLogin() 31 | .loginPage("/login").defaultSuccessUrl("/dnslog") 32 | .and() 33 | .logout().logoutUrl("/logout").logoutSuccessUrl("/login") 34 | .and() 35 | .csrf().disable(); 36 | } 37 | 38 | @Override 39 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 40 | auth.userDetailsService(userService).passwordEncoder(new BCryptPasswordEncoder()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/bridge/service/DnsLogService.java: -------------------------------------------------------------------------------- 1 | package bridge.service; 2 | 3 | import bridge.mapper.DnslogMapper; 4 | import bridge.model.DnsLog; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | 11 | @Repository 12 | public class DnsLogService { 13 | 14 | @Autowired 15 | private DnslogMapper dnslogMapper; 16 | 17 | public void addDnsLog(DnsLog dnsLog) { 18 | dnslogMapper.insert(dnsLog); 19 | } 20 | 21 | public List getAllDnslog(String userDomain) { 22 | return dnslogMapper.getAll(userDomain); 23 | } 24 | 25 | public void delOneDnslog(String id) { 26 | dnslogMapper.deleteOneByID(id); 27 | } 28 | 29 | public void delAllDnslog(int logid) { 30 | dnslogMapper.deleteAllBylogID(logid); 31 | } 32 | 33 | public DnsLog getDnslogByID(String id) { 34 | return dnslogMapper.selectDnslogByID(id); 35 | } 36 | 37 | 38 | public List getDnsLogByHost(String host) {return dnslogMapper.selectDnsLogByHost(host);} 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/bridge/service/DnsRecordAService.java: -------------------------------------------------------------------------------- 1 | package bridge.service; 2 | 3 | 4 | import bridge.mapper.DnsRecordAMapper; 5 | import bridge.model.DnsRecordA; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public class DnsRecordAService { 13 | 14 | @Autowired 15 | private DnsRecordAMapper dnsRecordAMapper; 16 | 17 | public void addDnsRecordA(DnsRecordA dnsRecordA) { 18 | dnsRecordAMapper.insert(dnsRecordA); 19 | } 20 | 21 | public DnsRecordA getDnsRecordABySubdomain(String subdomain) { 22 | return dnsRecordAMapper.selectDnsRecordABySubdomain(subdomain); 23 | } 24 | 25 | public List getAllDnsRecordA(String userDomain) { 26 | return dnsRecordAMapper.getAll(userDomain); 27 | } 28 | 29 | public DnsRecordA getDnsRecordAByID(String id) { 30 | return dnsRecordAMapper.selectDnsRecordAByID(id); 31 | } 32 | 33 | public void delOneDnsRecordA(String id) { 34 | dnsRecordAMapper.deleteOneByID(id); 35 | } 36 | 37 | public void delAllDnsRecordA(int logid) { 38 | dnsRecordAMapper.deleteAllDnsRecordABylogID(logid); 39 | } 40 | 41 | public void updateDnsRecordAByID(DnsRecordA dnsRecordA) { 42 | dnsRecordAMapper.updateByID(dnsRecordA); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/bridge/service/DnsRecordRebindService.java: -------------------------------------------------------------------------------- 1 | package bridge.service; 2 | 3 | import bridge.mapper.DnsRecordRebindMapper; 4 | import bridge.model.DnsRecordRebind; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | @Repository 11 | public class DnsRecordRebindService { 12 | 13 | @Autowired 14 | private DnsRecordRebindMapper dnsRecordRebindMapper; 15 | 16 | public void addDnsRecordRebind(DnsRecordRebind dnsRecordRebind) { 17 | dnsRecordRebindMapper.insert(dnsRecordRebind); 18 | } 19 | 20 | public DnsRecordRebind getDnsRecordRebindBySubdomain(String subdomain) { 21 | return dnsRecordRebindMapper.selectDnsRecordRebindBySubdomain(subdomain); 22 | } 23 | 24 | public List getAllDnsRecordRebind(String userDomain) { 25 | return dnsRecordRebindMapper.getAll(userDomain); 26 | } 27 | 28 | public DnsRecordRebind getDnsRecordRebindByID(String id) { 29 | return dnsRecordRebindMapper.selectDnsRecordRebindByID(id); 30 | } 31 | 32 | public void delOneDnsRecordRebind(String id) { 33 | dnsRecordRebindMapper.deleteOneByID(id); 34 | } 35 | 36 | public void delAllDnsRecordRebind(int logid) { 37 | dnsRecordRebindMapper.deleteAllDnsRecordRebindBylogID(logid); 38 | } 39 | 40 | public void updateDnsRecordRebindByID(DnsRecordRebind dnsRecordRebind) { 41 | dnsRecordRebindMapper.updateByID(dnsRecordRebind); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/bridge/service/ResponseService.java: -------------------------------------------------------------------------------- 1 | package bridge.service; 2 | 3 | 4 | import bridge.mapper.ResponseMapper; 5 | import bridge.model.Response; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | @Repository 12 | public class ResponseService { 13 | 14 | @Autowired 15 | private ResponseMapper responseMapper; 16 | 17 | public Response getResponseByID(String id) { 18 | return responseMapper.selectResponseByID(id); 19 | } 20 | 21 | public Response getResponseBySubdomain(String subdomain) { 22 | return responseMapper.selectResponseBySubdomain(subdomain); 23 | } 24 | 25 | public void addResponse(Response response) { 26 | responseMapper.insert(response); 27 | } 28 | 29 | public List getAllResponse(String userDomain) { 30 | return responseMapper.getAll(userDomain); 31 | } 32 | 33 | public void updateResponseAByID(Response response) { 34 | responseMapper.updateByID(response); 35 | } 36 | 37 | public void delOneResponse(String id) { 38 | responseMapper.deleteOneByID(id); 39 | } 40 | 41 | public void delAllResponse(int logid) { 42 | responseMapper.deleteAllBylogID(logid); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/bridge/service/UserService.java: -------------------------------------------------------------------------------- 1 | package bridge.service; 2 | 3 | import bridge.mapper.UserMapper; 4 | import bridge.model.User; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 11 | import org.springframework.stereotype.Repository; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | import java.util.UUID; 16 | 17 | 18 | @Repository 19 | public class UserService implements UserDetailsService { 20 | 21 | @Autowired 22 | private UserMapper userMapper; 23 | 24 | @Override 25 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 26 | User user = userMapper.getUserByUsername(username); 27 | if (user == null) { 28 | throw new UsernameNotFoundException("用户不存在!"); 29 | } 30 | List simpleGrantedAuthorities = new ArrayList<>(); 31 | simpleGrantedAuthorities.add(new SimpleGrantedAuthority("USER")); 32 | return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), simpleGrantedAuthorities); 33 | } 34 | 35 | public void insertNewUser(User user) { 36 | User existUser = userMapper.getUserByUsername(user.getUsername()); 37 | if (existUser == null) { 38 | encryptPassword(user); 39 | creatLogID(user); 40 | createUserID(user); 41 | createapiKey(user); 42 | userMapper.insert(user); 43 | } else { 44 | throw new RuntimeException("用户名已存在!"); 45 | } 46 | } 47 | 48 | private void encryptPassword(User user) { 49 | String password = user.getPassword(); 50 | user.setPassword(new BCryptPasswordEncoder().encode(password)); 51 | } 52 | 53 | private void creatLogID(User user) { 54 | Integer logID = userMapper.getLastLogID(); 55 | if (logID == null) { 56 | user.setLogid(1); 57 | } else { 58 | user.setLogid(logID + 1); 59 | } 60 | } 61 | 62 | private void createUserID(User user) { 63 | String userID = UUID.randomUUID().toString(); 64 | user.setUserid(userID); 65 | } 66 | 67 | private void createapiKey(User user) { 68 | String apiKey = UUID.randomUUID().toString().replace("-", ""); 69 | user.setApiKey(apiKey); 70 | } 71 | 72 | public int getLogIdByName(String username) { 73 | return userMapper.getUserByUsername(username).getLogid(); 74 | } 75 | 76 | public String getapiKeyByName(String username) { 77 | return userMapper.getUserByUsername(username).getApiKey(); 78 | } 79 | 80 | public User getUserByApiKey(String apiKey){ 81 | return userMapper.getUserByToken(apiKey); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/bridge/service/WeblogService.java: -------------------------------------------------------------------------------- 1 | package bridge.service; 2 | 3 | import bridge.mapper.WeblogMapper; 4 | import bridge.model.WebLog; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.List; 9 | 10 | 11 | @Repository 12 | public class WeblogService { 13 | 14 | @Autowired 15 | private WeblogMapper weblogMapper; 16 | 17 | public void addWeblog(WebLog webLog) { 18 | weblogMapper.insert(webLog); 19 | } 20 | 21 | public List getAllWeblog(String userDomain) { 22 | return weblogMapper.getAll(userDomain); 23 | } 24 | 25 | public void delOneWeblog(String id) { 26 | weblogMapper.deleteOneByID(id); 27 | } 28 | 29 | public void delAllWeblog(int logid) { 30 | weblogMapper.deleteAllBylogID(logid); 31 | } 32 | 33 | public WebLog getWeblogByID(String id) { 34 | return weblogMapper.selectWeblogByID(id); 35 | } 36 | 37 | public List getWeblogByHost(String host) {return weblogMapper.selectWebLogByHost(host); } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.url=jdbc:mysql://mysql:3306/bridge?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8&useSSL=false 2 | spring.datasource.username=root 3 | spring.datasource.password=password 4 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 5 | server.port=80 -------------------------------------------------------------------------------- /src/main/resources/templates/apiinfo.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DNSLOG 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | rebind解析 22 | 1、 1.1.1.1.2.2.2.2.1.dns.com即为rebind,第一次解析为1.1.1.1,第二次解析为2.2.2.2 上一次访问的ip,下一次同c段的地址都会返回rebind结果 23 | 2、 通过配置解析处进行配置 24 | 25 | 26 | 自定义解析IP 27 | 1、 通过域名8.8.8.8.1.dns.com即解析为8.8.8.8 28 | 2、 通过配置解析处进行配置 29 | 3、 优先按照域名匹配进行处理,即数据库中存储8.8.8.8.1.dns.com指向1.1.1.1,实际请求结果仍然会返回8.8.8.8,rebind记录也是一样 30 | 31 | 32 | dnslog查询接口 33 | http://xxx.xx/api/dnslog/search?token={apiKey}&keyword={test} 34 | keyword参数值必须是完整除去logAdress后的部分,此处没有模糊查询,如aaaaaa.1.dnslog.com对应keyword=aaaaaa,返回数据格式样例如下: 35 | 36 | 37 | 38 | ] 39 | { 40 | "ip": "localhost", 41 | "host": "test1.1.dns.xxxx.com", 42 | "time": "2019-07-30 15:25:14.0", 43 | "type": "A(1)" 44 | } 45 | ] 46 | 47 | 48 | 49 | weblog查询接口 50 | http://xxx.xx/api/weblog/search?token={apiKey}&keyword={test} 51 | keyword要求同上,返回数据格式样例如下: 52 | 53 | 54 | 55 | [ 56 | { 57 | "path": "/", 58 | "method": "POST", 59 | "data": "", 60 | "ip": "10.10.37.75", 61 | "host": "test.1.dns.xxxx.com", 62 | "header": "{\"content-length\":\"22896\",\"postman-token\":\"9575b873-ccd9-4d5b-ba8a-c1f746e40086\",\"host\":\"test.1.dns.xxxx.com\",\"content-type\":\"text/plain\",\"connection\":\"keep-alive\",\"cache-control\":\"no-cache\",\"accept-encoding\":\"gzip, deflate\",\"user-agent\":\"PostmanRuntime/7.13.0\",\"accept\":\"*/*\"}", 63 | "time": "2019-07-23 17:50:10.0", 64 | "params": null, 65 | "version": "HTTP/1.1" 66 | } 67 | ] 68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/main/resources/templates/authheader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Bridge 无回显漏洞测试辅助平台 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/main/resources/templates/dnslog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DNSLOG 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 删除所有 21 | 22 | 23 | 24 | 25 | 26 | # 27 | Host 28 | IP 29 | Type 30 | Time 31 | 操作 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 删除 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/main/resources/templates/dnssetting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DNSLOG 6 | 7 | 8 | 9 | 10 | 11 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | A记录配置 31 | Rebind记录配置 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 删除所有 40 | 41 | 42 | 43 | 新增A记录 44 | 45 | 46 | 47 | 48 | 49 | 50 | 新增A记录 51 | 52 | 53 | 54 | 55 | 子域名 56 | 58 | 59 | 60 | 目的IP 61 | 63 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | # 76 | Host 77 | IP 78 | Time 79 | 操作 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 编辑 92 | 93 | 95 | 96 | 97 | 98 | 编辑解析 99 | 100 | 101 | 102 | 103 | 子域名 104 | 107 | 108 | 109 | 目的IP 110 | 113 | 114 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 删除 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 删除所有 135 | 136 | 137 | 138 | 新增Rebind记录 139 | 140 | 141 | 143 | 144 | 145 | 146 | × 148 | 新增Rebind记录(源IP地址的C段都会走Rebind) 149 | 150 | 151 | 152 | 153 | 子域名 154 | 156 | 157 | 158 | IP1 159 | 161 | 162 | 163 | IP2 164 | 166 | 167 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | # 179 | Host 180 | IP1 181 | IP2 182 | Time 183 | 操作 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 编辑 197 | 198 | 200 | 201 | 202 | 203 | 编辑解析 204 | 205 | 206 | 207 | 208 | 子域名 209 | 212 | 213 | 214 | IP1 215 | 218 | 219 | 220 | IP2 221 | 224 | 225 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 删除 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 438 | 439 | -------------------------------------------------------------------------------- /src/main/resources/templates/login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 登录 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Login 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 登录失败,账号或密码错误! 41 | 42 | 43 | 44 | 登录 45 | 46 | 47 | 48 | 49 | 创建账号 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/main/resources/templates/mainheader.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Bridge 16 | 17 | 18 | DNSLOG列表 19 | 20 | 21 | HTTPLOG列表 22 | 23 | 24 | 配置解析 25 | 26 | 27 | 配置响应 28 | 29 | 30 | API信息 31 | 32 | 33 | 34 | 35 | 37 | 38 | 注销 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main/resources/templates/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 注册 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Register 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | 48 | 50 | 51 | 52 | 53 | 54 | 注册失败,账号已存在! 55 | 56 | 57 | 注册失败,两次输入密码不相同! 58 | 59 | 60 | 暗号不正确! 61 | 62 | 63 | 64 | 注册 65 | 66 | 67 | 68 | 69 | 返回登录页面 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/resources/templates/responsesetting.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DNSLOG 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 删除所有 26 | 27 | 28 | 29 | 新增响应记录 30 | 31 | 32 | 34 | 35 | 36 | 37 | × 39 | 新增响应记录 40 | 41 | 42 | 43 | 44 | 子域名 45 | 47 | 48 | 49 | 返回内容类型 50 | 51 | Data 52 | Redirect 53 | Error 54 | 55 | 56 | 57 | 状态码 58 | 59 | 60 | 61 | Response Body 62 | 64 | 65 | 66 | Redirect URL 67 | 69 | 70 | 71 | 72 | 添加Header 73 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | # 84 | Host 85 | responseType 86 | StatusCode 87 | Time 88 | 操作 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 编辑 102 | 103 | 105 | 106 | 107 | 108 | 编辑响应 109 | 110 | 111 | 112 | 113 | 子域名 114 | 117 | 118 | 119 | 返回内容类型 120 | 121 | Data 122 | Redirect 123 | Error 124 | 125 | 126 | 127 | 状态码 128 | 129 | 130 | 131 | Response Body 132 | 134 | 135 | 136 | Redirect URL 137 | 139 | 140 | 141 | 142 | 143 | header 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 删除 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 419 | 420 | 421 | 422 | 423 | 424 | -------------------------------------------------------------------------------- /src/main/resources/templates/weblog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DNSLOG 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 删除所有 26 | 27 | 28 | 29 | 30 | 31 | # 32 | Host 33 | IP 34 | Method 35 | UserAgent 36 | Time 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 详细 50 | 51 | 53 | 54 | 55 | 56 | × 58 | 请求信息 59 | 60 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 删除 84 | 85 | 86 | 87 | 88 | 89 | 90 | 130 | 131 | 132 | 133 | --------------------------------------------------------------------------------
38 | ] 39 | { 40 | "ip": "localhost", 41 | "host": "test1.1.dns.xxxx.com", 42 | "time": "2019-07-30 15:25:14.0", 43 | "type": "A(1)" 44 | } 45 | ]
55 | [ 56 | { 57 | "path": "/", 58 | "method": "POST", 59 | "data": "", 60 | "ip": "10.10.37.75", 61 | "host": "test.1.dns.xxxx.com", 62 | "header": "{\"content-length\":\"22896\",\"postman-token\":\"9575b873-ccd9-4d5b-ba8a-c1f746e40086\",\"host\":\"test.1.dns.xxxx.com\",\"content-type\":\"text/plain\",\"connection\":\"keep-alive\",\"cache-control\":\"no-cache\",\"accept-encoding\":\"gzip, deflate\",\"user-agent\":\"PostmanRuntime/7.13.0\",\"accept\":\"*/*\"}", 63 | "time": "2019-07-23 17:50:10.0", 64 | "params": null, 65 | "version": "HTTP/1.1" 66 | } 67 | ]
登录失败,账号或密码错误!
注册失败,账号已存在!
注册失败,两次输入密码不相同!
暗号不正确!