Skip to content

Commit

Permalink
update 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
F6JO committed Jan 8, 2023
1 parent 981f319 commit ee6fcdd
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 12 deletions.
17 changes: 11 additions & 6 deletions src/main/java/func/init_Yaml_thread.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;

public class init_Yaml_thread extends Thread {
private BurpExtender burp;
Expand All @@ -35,9 +36,12 @@ public void run() {
IResponseInfo AnalyzeYamlResponse = this.burp.help.analyzeResponse(YamlResponse);
String ResponseBody = this.burp.help.bytesToString(YamlResponse).substring(AnalyzeYamlResponse.getBodyOffset());

FileOutputStream file = new FileOutputStream(BurpExtender.Yaml_Path);
file.write(this.burp.help.stringToBytes(ResponseBody));
file.close();
Map<String, Object> NewYaml = YamlUtil.readStrYaml(ResponseBody);
YamlUtil.MergerUpdateYamlFunc(NewYaml);

// FileOutputStream file = new FileOutputStream(BurpExtender.Yaml_Path);
// file.write(this.burp.help.stringToBytes(ResponseBody));
// file.close();

Bfunc.show_yaml(burp);
JOptionPane.showMessageDialog(one, "Update successful", "Tips ", 1);
Expand All @@ -46,10 +50,11 @@ public void run() {
}
} catch (MalformedURLException e) {
JOptionPane.showMessageDialog(one, "URL creation failed", "Error ", 0);
} catch (IOException e) {
JOptionPane.showMessageDialog(one, "File write failed", "Error ", 0);

}
// catch (IOException e) {
// JOptionPane.showMessageDialog(one, "File write failed", "Error ", 0);
//
// }


}
Expand Down
60 changes: 54 additions & 6 deletions src/main/java/yaml/YamlUtil.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
package yaml;

import burp.BurpExtender;
import burp.IHttpRequestResponse;
import burp.IRequestInfo;
import burp.View;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import func.init_Yaml_thread;
import org.yaml.snakeyaml.Yaml;

Expand Down Expand Up @@ -93,6 +87,60 @@ public static void addYaml(Map<String, Object> add, String filePath) {

}

public static Map<String, Object> readStrYaml(String str){
Map<String, Object> data = null;
Yaml yaml = new Yaml();
data = yaml.load(str);
return data;
}


public static void MergerUpdateYamlFunc(Map<String, Object> newYaml){
Map<String, Object> oldYaml = YamlUtil.readYaml(BurpExtender.Yaml_Path);
List<Map<String, Object>> oldYamlList = (List<Map<String, Object>>)oldYaml.get("Load_List");
List<Map<String, Object>> newYamlList = (List<Map<String, Object>>)newYaml.get("Load_List");
for (Map<String, Object> i : newYamlList){
if (!YamlUtil.inYamlList(oldYamlList,i)){
int id = 0;
for (Map<String, Object> zidian : (List<Map<String, Object>>)YamlUtil.readYaml(BurpExtender.Yaml_Path).get("Load_List")) {
if ((int) zidian.get("id") > id) {
id = (int) zidian.get("id");
}
}
id += 1;
i.remove("id");
i.put("id",id);
YamlUtil.addYaml(i,BurpExtender.Yaml_Path);
}
}


}

public static boolean inYamlList(List<Map<String, Object>> mapList,Map<String, Object> oneMap){
for (Map<String, Object> i : mapList){
if (YamlUtil.ifmapEqual(i,oneMap)){
return true;
}
}
return false;

}

public static boolean ifmapEqual(Map<String, Object> i, Map<String, Object> oneMap){
boolean mapEqual = true;
for (String key : i.keySet()){
if (!key.equals("loaded") && !key.equals("id") && !key.equals("type")){
if (!i.get(key).equals(oneMap.get(key))){
mapEqual = false;
break;
}
}
}
return mapEqual;
}



}

Expand Down

0 comments on commit ee6fcdd

Please sign in to comment.