Commit 7752009e by 钱炳权

增加车联网协议

parent e47c4040
...@@ -48,4 +48,9 @@ public class ProtocolConstent { ...@@ -48,4 +48,9 @@ public class ProtocolConstent {
public static final String RSTP = "rstp_raw.py "; public static final String RSTP = "rstp_raw.py ";
public static final String SMTP = "smtp_tcp.py "; public static final String SMTP = "smtp_tcp.py ";
public static final String TIRP = "tirp_udp.py "; public static final String TIRP = "tirp_udp.py ";
public static final String AMQP = "amqp.py ";
public static final String UDPNM = "udpnm_udp.py ";
public static final String DOIP = "doip.py ";
public static final String COAP = "coap.py ";
public static final String MQTT = "mqtt.py ";
} }
package com.example.fuzzControll.constents; package com.example.fuzzControll.constents;
public enum ServerClassEnum { public enum ServerClassEnum {
RTSP("rtsp","testOnDemandRTSPServer 8554"),
FTP("ftp","testOnDemandFTP 8554"),//error
DTLS12("dtls12","testOnDemandFTP 8554"),//error
DNS("dns","testOnDemandFTP 8554"),//error
DICOM("dicom","testOnDemandFTP 8554"),//error
SMTP("smtp","testOnDemandFTP 8554"),//error
SSH("ssh","testOnDemandFTP 8554"),//error
TLS("tls","testOnDemandFTP 8554"),//error
DAAP_HTTP("daap_http","testOnDemandFTP 8554"),//error
SIP("sip","testOnDemandFTP 8554");//error
private String name;
private String serverName;
ServerClassEnum(String name, String serverName) {
this.name = name;
this.serverName = serverName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getServerName() {
return serverName;
}
public void setServerName(String serverName) {
this.serverName = serverName;
}
} }
...@@ -138,6 +138,20 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -138,6 +138,20 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
return smtpCmd(testEntity); return smtpCmd(testEntity);
case "tirp": case "tirp":
return tirpCmd(testEntity); return tirpCmd(testEntity);
case "amqp"://todo need doc
return amqpCmd(testEntity);
case "udpnm":
return udpnmCmd(testEntity);
case "someIp":
return someIpCmd(testEntity);
case "doip":
return doipCmd(testEntity);
case "coap":
return coapCmd(testEntity);
case "mqtt":
return mqttCmd(testEntity);
case "sendPcap":
return sendPcapCmd(testEntity);
default: default:
throw new FuzzException("Unknown protocol!"); throw new FuzzException("Unknown protocol!");
} }
...@@ -147,6 +161,117 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService { ...@@ -147,6 +161,117 @@ public class ProtocolTemplateImpl implements ProtocolTemplateService {
} }
private String sendPcapCmd(TestEntity testEntity) {
//todo 还不清楚怎么做
return null;
}
private String mqttCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 5, "mqtt")) {
return "";
}
String ip = null;
String port = null;
String topic = null;
String username = null;
String password = null;
try {
ip = testEntity.getParamJson()[0];
port = testEntity.getParamJson()[1];
topic = testEntity.getParamJson()[1];
username = testEntity.getParamJson()[1];
password = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("mqtt参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.MQTT + " " + ip + " " + port+ " " + topic+ " " + username+ " " + password;
}
private String coapCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 3, "coap")) {
return "";
}
String ip = null;
String port = null;
String path = null;
try {
ip = testEntity.getParamJson()[0];
port = testEntity.getParamJson()[1];
path = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("coap参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.COAP + " " + ip + " " + port+ " " + path;
}
private String doipCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "doip")) {
return "";
}
String ip = null;
String port = null;
try {
ip = testEntity.getParamJson()[0];
port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("doip参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.UDPNM + " " + ip + " " + port;
}
private String someIpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "someIp")) {
return "";
}
String ip = null;
String port = null;
try {
ip = testEntity.getParamJson()[0];
port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("someIp参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.DOIP + " " + ip + " " + port;
}
private String udpnmCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "udpnm")) {
return "";
}
String ip = null;
String port = null;
try {
ip = testEntity.getParamJson()[0];
port = testEntity.getParamJson()[1];
} catch (Exception e) {
log.error("udpnm参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.UDPNM + " " + ip + " " + port;
}
private String amqpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 5, "amqp")) {
return "";
}
String ip = null;
String port = null;
String queue = null;
String exchange = null;
String routing_key = null;
try {
ip = testEntity.getParamJson()[0];
port = testEntity.getParamJson()[1];
queue = testEntity.getParamJson()[2];
exchange = testEntity.getParamJson()[3];
routing_key = testEntity.getParamJson()[4];
} catch (Exception e) {
log.error("amqp参数解析失败!");
}
return kitty.getVenvPath() + " " + kitty.getPath() + ProtocolConstent.AMQP + " " + ip + " " + port+ " " + queue+ " " + exchange+ " " + routing_key;
}
private String tirpCmd(TestEntity testEntity) { private String tirpCmd(TestEntity testEntity) {
if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tirp")) { if (!TestTools.paramsLenghtTest(testEntity.getParamJson().length, 2, "tirp")) {
return ""; return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment