• 安全扫描项目


    项目描述

    为了增强靶场平台的能力,选择与第三方公司合作,借助第三方平台增强已方平台的能力
    本项目是为了将其他第三方安全软件的能力融入到靶场平台中
    
    引用:  
    	GOBY集成资产发现、漏洞发现、漏洞利用、漏洞全网扫描、反弹shell、蜜罐识别、代理隧道、拓扑展示、报告输出、自定义插件等功能于一身,强大且灵活的框架覆盖绝大部分攻击流程。使攻击效果,不再依赖于攻击人员自身的能力及经验。GOBY内集成的“靶标漏洞”,全部为实际可利用漏洞,部分来自于历年攻防演习爆发的漏洞,更加贴近于企业对于攻防演习实战化的需求,以全面提升攻击队成绩项目
    
    项目分为两个部分
    	1.安全扫描服务Server
    		该服务运行在靶场平台,作为靶场Server端的服务,负责具体业务功能,每个靶场只需要部署一个
    	2.适配器Agent
    		该服务部署在第三方安全软件所属的环境中,负责处理·安全扫描服务Server·的请求,之所以需要Agent端主要考虑网络隔离的因素,避免部署多个含有业务功能的Server,于是使用更下层的适配器去沟通第三方安全软件
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    项目周期

    	一周
    	一人
    
    • 1
    • 2

    框架

    在这里插入图片描述

    项目进度

    适配器Agent 已完成
    领导没有想好安全扫描服务的业务功能,于是本次只对Agent进行描述
    
    • 1
    • 2

    代码摘要

    Agent端

    适配器核心逻辑
    	根据用户传入的参数决定工厂创建那家公司的对象,对象创建完成后在对应的方法完成参数的封装后交给Rest对象进行远程调用,将结果进行返回到对应的对象后由对象在对结果进行封装然后返回给用户
    
    	使用工厂模式,如果将来需要兼容C/D公司的安全软件那么只需要三步操作且不影响原有的业务逻辑
    		1. 工厂类增加生产C/D公司的业务处理类
    		2. 新增业务处理类实现统一的接口
    		3. 配置文件配置相应的远程调用信息
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述

    @Component
    public class ProductFactory {
    
        @Resource
        private ProductProperty productProperty;
    
        public ProductService builder(String type) {
            switch (type.toUpperCase()) {
                case "GOBY":
                    return new GobyServiceImpl(productProperty);
                case "BuiBuiBui":
                    return new BuiBuiBuiImpl(productProperty);
                default:
                    throw new IllegalArgumentException("不支持的产品类型");
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    通过@configurationProperties() 读取对应的第三方软件的相关属性
    
    • 1
    @ConfigurationProperties("scan")
    @Configuration
    @Data
    public class ProductProperty {
        private Goby goby;
    
        @Data
        public static class Goby {
            private String protocol;
            private String host;
            private String port;
            private String uriPrefix;
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    scan:
      goby:
        host: 172.172.0.250
        port: 20017
        uriPrefix: api/v1
        protocol: http
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    A公司安全软件业务处理类
    
    • 1
    public class GobyServiceImpl implements ProductService {
    
    
        private RestClient<Object> restClient;
    
        public GobyServiceImpl(ProductProperty productProperty) {
            this.restClient = new RestClient(productProperty, "GOBY");
        }
    
    	//具体的业务方法
    	public void test(){
    		//远程调用的方法
    		restClient.rest();
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    B公司安全软件业务处理类
    
    • 1
    public class BuiBuiBuiImpl implements ProductService {
    
        private RestClient<Object> restClient;
    
        public BuiBuiBuiImpl(ProductProperty productProperty){
            this.restClient = new RestClient(productProperty, "GOBY");
        }
        //具体的业务方法
    	public void test(){
    		
    	}
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    Controller 层
    
    • 1
    @RestController
    @RequestMapping("task")
    @Api(tags = "任务相关")
    public class TaskController {
        @Resource
        private ProductFactory productFactory;
    
    	//通过工程创建出具体的业务处理对象
        @ApiOperation(value = "开始任务")
        @PostMapping()
        public ServerResult taskStart(@RequestBody TaskDTO taskDTO) {
            return productFactory.builder(taskDTO.getType()).taskStart(taskDTO);
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    Rest 远程调用类
    
    • 1
    public class RestClient<T> {
    
        private final RestTemplate restTemplate;
        private final ProductProperty productProperty;
        private final String type;
    
    
        public RestClient(ProductProperty productProperty, String type) {
            this.type = type;
            this.productProperty = productProperty;
            SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
            factory.setConnectTimeout(3000);
            factory.setReadTimeout(5000);
            BufferingClientHttpRequestFactory bufferFactory = new BufferingClientHttpRequestFactory(factory);
            restTemplate = new RestTemplate(bufferFactory);
            restTemplate.setInterceptors(Collections.singletonList(new RestClientConfig()));
        }
    
    	//远程调用
        public JSONObject gobyPostRest(String path, Object o) {
            return gobyRest(path, HttpMethod.POST, o);
        }
        ....
        //最终通过 restTemplate实现真正的远程调用
        public <T> ResponseEntity<T> rest(String uri, HttpMethod method, RequestEntity<?> request, Class<T> c) {
            return restTemplate.exchange(URI.create(uri), method, request, c);
        }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
  • 相关阅读:
    根据多个乱序经纬度计算多边形顶点顺序并绘制到指定地图上
    内网穿透,轻松实现PostgreSQL数据库公网远程连接!
    Hadoop编程——第二章:(2)Centos操作系统的虚拟机导入
    05.QString字符串处理及中文乱码问题处理
    计算机毕业设计django基于python仓库管理系统(源码+系统+mysql数据库+Lw文档)
    哪吒汽车选择BlackBerry QNX为中国新能源轿跑——哪吒S保驾护航
    python操作日期和时间
    Docker入门学习笔记
    QT多线程的可重入与线程安全介绍
    5. 内部类
  • 原文地址:https://blog.csdn.net/qq_41149775/article/details/126137492