package com.example.fuzzControll.service.impl; import com.example.fuzzControll.conf.KittyProperties; import com.example.fuzzControll.constents.ProtocolConstent; import com.example.fuzzControll.exception.CmdException; import com.example.fuzzControll.exception.FuzzException; import com.example.fuzzControll.pojo.vo.TestEntity; import com.example.fuzzControll.service.ProtocolTemplateService; import com.example.fuzzControll.tools.CmdTools; import com.example.fuzzControll.tools.TestTools; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; import java.util.Map; @Slf4j @Service public class ProtocolTemplateImpl implements ProtocolTemplateService { CmdTools cmdTools = new CmdTools(); @Autowired KittyProperties kitty; @Override public Map<String, List<String>> generation(TestEntity testEntity) throws FuzzException, CmdException { String cmd = parseParameters(testEntity); if (cmd == null || cmd.equals("")) { throw new FuzzException("cmd is null ! The number of parameters does not match!"); } return cmdTools.runProgramCmdAndResult(cmd); } public String parseParameters(TestEntity testEntity) throws FuzzException { if (testEntity == null) { throw new FuzzException("testEntity is null!"); } try { switch (testEntity.getTestClassName().toLowerCase()) { case "arp": return arpCmd(testEntity); case "bgp": return bgpCmd(testEntity); case "dhcp": return dhcpCmd(testEntity); case "dns": return dnsCmd(testEntity); case "frp": return frpCmd(testEntity); case "ftp": return ftpCmd(testEntity); case "hdlc": return hdlcCmd(testEntity); case "http_dos_qemu": return http_dos_qemuCmd(testEntity); case "icmp"://need long time return icmpCmd(testEntity); case "igmpv1": return igmpv1Cmd(testEntity); case "igmpv2": return igmpv2Cmd(testEntity); case "imap"://cant run with error return imapCmd(testEntity); case "radius": return radiusCmd(testEntity); case "sip": return sipCmd(testEntity); case "rpc": return rpcCmd(testEntity); case "smb": return smbCmd(testEntity); case "ssl"://cant run with error return sslCmd(testEntity); case "ssh"://cant run with error return sshCmd(testEntity); case "nfs"://cant run with error return nfsCmd(testEntity); case "nntp"://cant run with error return nntpCmd(testEntity); case "ntp"://cant run with error return ntpCmd(testEntity); case "snmp"://cant run with error return snmpCmd(testEntity); case "upnp"://cant run with error return upnpCmd(testEntity); case "rarp": return rarpCmd(testEntity); case "lldp"://longtime return lldpCmd(testEntity); case "mstp"://longtime return mstpCmd(testEntity); case "ppp"://cant run with error return pppCmd(testEntity); case "pppoe"://longtime return pppoeCmd(testEntity); case "stp"://longtime return stpCmd(testEntity); case "vlan"://longtime cant get result return vlanCmd(testEntity); case "ospf"://longtime return ospfCmd(testEntity); case "isis"://have error return isisCmd(testEntity); case "ip"://have error return ipCmd(testEntity); case "telnet"://have error return telnetCmd(testEntity); case "pop3"://have error return pop3Cmd(testEntity); case "ipsec"://have error return ipsecCmd(testEntity); case "https"://have error return httpsCmd(testEntity); case "rip"://longtime return ripCmd(testEntity); case "netbios"://have error return netbiosCmd(testEntity); case "sharp": return sharpCmd(testEntity); case "tftp"://have error return tftpCmd(testEntity); case "udp": return udpCmd(testEntity); case "tcp"://have error return tcpCmd(testEntity); default: throw new FuzzException("Unknown protocol!"); //TODO testcase_dos/testcase_rpc/ftp_vuln_reproduce } } catch (Exception e) { throw new FuzzException("Count of params is not match or unknown protocol!"); } } private String tcpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tcp")) { return ""; } String dst_ip = null; String src_ip = null; try { dst_ip = testEntity.getParamJson()[0]; src_ip = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("tcp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.TCP + " " + dst_ip + " " + src_ip; } private String udpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "udp")) { return ""; } String dst_ip = null; String src_ip = null; try { dst_ip = testEntity.getParamJson()[0]; src_ip = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("udp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.UDP + " " + dst_ip + " " + src_ip; } private String tftpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tftp")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("tftp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.TFTP + " " + dst_ip + " " + dst_port; } private String sharpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sharp")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("sharp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SHARP + " " + dst_ip + " " + dst_port; } private String netbiosCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "netbios")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("netbios参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NETBIOS + " --host=" + dst_ip + " --port=" + dst_port; } private String ripCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rip")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("rip参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RIP + " --host=" + dst_ip + " --port=" + dst_port; } private String httpsCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "https")) return ""; String src_ip = null; String src_port = null; String dst_ip = null; String dst_port = null; try { src_ip = testEntity.getParamJson()[0]; src_port = testEntity.getParamJson()[1]; dst_ip = testEntity.getParamJson()[2]; dst_port = testEntity.getParamJson()[3]; } catch (Exception e) { log.error("https参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HTTPS + " " + src_ip + " " + src_port + " " + dst_ip + " " + dst_port; } private String ipsecCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "ipsec")) return ""; String src_ip = null; String dst_ip = null; String bind_ip = null; try { src_ip = testEntity.getParamJson()[0]; dst_ip = testEntity.getParamJson()[1]; bind_ip = testEntity.getParamJson()[2]; } catch (Exception e) { log.error("ipsec参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IPSEC + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip; } private String pop3Cmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "pop3")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("pop3参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.POP3 + " --host=" + dst_ip + " --port=" + dst_port; } private String telnetCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "telnet")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("telnet参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.TELNET + " --host=" + dst_ip + " --port=" + dst_port; } private String ipCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "ip")) return ""; String dst_mac = null; String src_mac = null; String dst_ip = null; String src_ip = null; try { dst_mac = testEntity.getParamJson()[0]; src_mac = testEntity.getParamJson()[1]; dst_ip = testEntity.getParamJson()[2]; src_ip = testEntity.getParamJson()[3]; } catch (Exception e) { log.error("ip参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IP + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip; } private String isisCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 1, "isis")) return ""; String dst_mac = null; try { dst_mac = testEntity.getParamJson()[0]; } catch (Exception e) { log.error("isis参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ISIS + " --dst_mac==" + dst_mac; } private String ospfCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ospf")) return ""; String dst_mac = null; String dst_ip = null; try { dst_mac = testEntity.getParamJson()[0]; dst_ip = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("ospf参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.OSPF + " --dest_mac=" + dst_mac + " --dest_ip=" + dst_ip; } private String vlanCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "vlan")) return ""; String dts_mac = null; String src_mac = null; try { dts_mac = testEntity.getParamJson()[0]; src_mac = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("vlan参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.VLAN + " " + dts_mac + " " + src_mac; } private String stpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "stp")) return ""; String src_mac = null; String dts_mac = null; try { src_mac = testEntity.getParamJson()[0]; dts_mac = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("stp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.STP + " -s " + src_mac + " -d " + dts_mac; } private String pppoeCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "pppoe")) return ""; String dst_mac = null; String src_mac = null; String dst_ip = null; String src_ip = null; try { dst_mac = testEntity.getParamJson()[0]; src_mac = testEntity.getParamJson()[1]; dst_ip = testEntity.getParamJson()[2]; src_ip = testEntity.getParamJson()[3]; } catch (Exception e) { log.error("pppoe参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.PPPOE + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip; } private String pppCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "ppp")) return ""; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.PPP; } private String mstpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "mstp")) return ""; String src_mac = null; String dst_mac = null; try { src_mac = testEntity.getParamJson()[0]; dst_mac = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("mstp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.MSTP + " -s " + src_mac + " -d " + dst_mac; } private String lldpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "lldp")) return ""; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.LLDP; } private String rarpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rarp")) return ""; String dst_mac = null; String src_mac = null; try { dst_mac = testEntity.getParamJson()[0]; src_mac = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("rarp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RARP + " " + dst_mac + " " + src_mac; } private String upnpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "upnp")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("upnp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.UPNP + " " + dst_ip + " " + dst_port; } private String snmpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "snmp")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("snmp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SNMP + " " + dst_ip + " " + dst_port; } private String ntpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ntp")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("ntp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NTP + " " + dst_ip + " " + dst_port; } private String nntpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "nntp")) return ""; String src_ip = null; String src_port = null; String dst_ip = null; String dst_port = null; try { src_ip = testEntity.getParamJson()[0]; src_port = testEntity.getParamJson()[1]; dst_ip = testEntity.getParamJson()[2]; dst_port = testEntity.getParamJson()[3]; } catch (Exception e) { log.error("nntp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NNTP + " " + src_ip + " " + src_port + " " + dst_ip + " " + dst_port; } private String nfsCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "nfs")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("nfs参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.NFS + " " + dst_ip + " " + dst_port; } private String sshCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssh")) return ""; String dst_ip = null; try { dst_ip = testEntity.getParamJson()[0]; } catch (Exception e) { log.error("ssh参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SSH + " -d " + dst_ip; } private String sslCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ssl")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("ssl参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SSL + " -d " + dst_ip + " -p " + dst_port; } private String smbCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "smb")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("smb参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RPC + " " + dst_ip + " " + dst_port; } private String rpcCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "rpc")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("rpc参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RPC + " " + dst_ip + " " + dst_port; } private String sipCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "sip")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("sip参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.SIP + " -d " + dst_ip + " -p " + dst_port; } private String radiusCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "radius")) return ""; String dst_ip = null; String dst_port = null; String src_ip = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; src_ip = testEntity.getParamJson()[2]; } catch (Exception e) { log.error("radius参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.RADIUS + " --host=" + dst_ip + " --port=" + dst_port + " --src_host=" + src_ip; } private String imapCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "imap")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("imap参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IMAP + " --host=" + dst_ip + " --port=" + dst_port; } private String igmpv2Cmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv2")) return ""; String src_ip = null; String dst_ip = null; String bind_ip = null; try { src_ip = testEntity.getParamJson()[0]; dst_ip = testEntity.getParamJson()[1]; bind_ip = testEntity.getParamJson()[2]; } catch (Exception e) { log.error("igmpv2参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IGMPV2 + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip; } private String igmpv1Cmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "igmpv1")) return ""; String src_ip = null; String dst_ip = null; String bind_ip = null; try { src_ip = testEntity.getParamJson()[0]; dst_ip = testEntity.getParamJson()[1]; bind_ip = testEntity.getParamJson()[2]; } catch (Exception e) { log.error("igmpv1参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.IGMPV1 + " -s " + src_ip + " -d " + dst_ip + " -b " + bind_ip; } private String icmpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "icmp")) return ""; String dst_mac = null; String src_mac = null; String dst_ip = null; String src_ip = null; try { dst_mac = testEntity.getParamJson()[0]; src_mac = testEntity.getParamJson()[1]; dst_ip = testEntity.getParamJson()[2]; src_ip = testEntity.getParamJson()[3]; } catch (Exception e) { log.error("icmp参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ICMP + " " + dst_mac + " " + src_mac + " " + dst_ip + " " + src_ip; } private String http_dos_qemuCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "http")) return ""; String dst_ip = null; String port = null; try { dst_ip = testEntity.getParamJson()[0]; port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("http_dos_qemu参数解析失败!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HTTP_DOS_QUMU + " -d " + dst_ip + " -p " + port; } private String hdlcCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 0, "hdlc")) return ""; return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.HDLC; } //todo need change private String ftpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "ftp")) return ""; String target_host = null; String target_port = null; try { target_host = testEntity.getParamJson()[0]; target_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("ftp参数解析失败!"); throw new FuzzException("count of params is not match!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FTP + target_host + " " + target_port; } private String frpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "frp")) return ""; String target_host = null; String target_port = null; try { target_host = testEntity.getParamJson()[0]; target_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("frp参数解析失败!"); throw new FuzzException("count of params is not match!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.FRP + target_host + " " + target_port; } private String dnsCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dns")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("dns参数解析失败!"); throw new FuzzException("count of params is not match!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DNS + dst_ip + " " + dst_port; } private String dhcpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "dhcp")) return ""; String dst_ip = null; String dst_port = null; try { dst_ip = testEntity.getParamJson()[0]; dst_port = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("dhcp参数解析失败!"); throw new FuzzException("count of params is not match!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DHCP + dst_ip + " " + dst_port; } private String bgpCmd(TestEntity testEntity) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 4, "bgp")) return ""; String src_ip = null; String src_port = null; String dst_ip = null; String dst_port = null; try { src_ip = testEntity.getParamJson()[0]; src_port = testEntity.getParamJson()[1]; dst_ip = testEntity.getParamJson()[2]; dst_port = testEntity.getParamJson()[3]; } catch (Exception e) { log.error("bgp参数解析失败!"); throw new FuzzException("count of params is not match!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.BGP + src_ip + " " + src_port + " " + dst_ip + " " + dst_port; } public String arpCmd(TestEntity testEntity) throws FuzzException { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "arp")) return ""; String dst_mac = null; String src_mac = null; try { dst_mac = testEntity.getParamJson()[0]; src_mac = testEntity.getParamJson()[1]; } catch (Exception e) { log.error("arp参数解析失败!"); throw new FuzzException("count of params is not match!"); } return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.ARP + dst_mac + " " + src_mac; } }