Java工具開發手記
前言
這段時間沉迷於工具開發方面,個人也比較傾向於gui的工具。使用在開發過程中避免的就是gui的一些框體,這里主要用於記錄一些關鍵點。
工具開發
其實在前段時間編寫的14882_exploit_Gui工具的時候,提出的一個問題。除了命令執行在工具里還有什么實用的功能模塊。當時提出的一個proxy功能,並把他給實現了。
開發過程中其實具體在Gui框體的設計這塊相對來說比較費時間。
代理模塊核心實現代碼
public Proxy createProxy_SOCKET() {
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(this.socket_ip_addr, this.socket_port));
return proxy;
}
...
Proxy proxy_socket = createProxy_SOCKET();
...
HttpsURLConnection https = (HttpsURLConnection)url.openConnection(proxy_socket);
GUI設計
this.setResizable(false); //不可最大化設置
setLocationRelativeTo(null); //框體居中
proxy_setting 如何進行消息框彈出的問題解決
jDialog1.setVisible(rootPaneCheckingEnabled);
check_box選項框事件監聽問題解決,且實現不勾選輸入框無法使用功能。
jCheckBox1.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean proxy_flag = jCheckBox1.isSelected();
// System.out.println(proxy_flag);
if(proxy_flag){
jTextField4.setEditable(true);
jTextField5.setEditable(true);
// jComboBox4.setEditable(true);
}else {
jTextField4.setEditable(false);
jTextField5.setEditable(false);
jComboBox4.setEditable(false);
}
// System.out.println(jComboBox4.getSelectedItem().toString());
}
});
寫文件功能問題解決:
public class Fileutils {
public static void writeFile(String savepath,String shell) {//寫文件
FileOutputStream fos = null;
try {
fos = new FileOutputStream(savepath);
fos.write(shell.getBytes());
fos.close();
System.out.println("已保存");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}}
......
JFileChooser chooser = new JFileChooser();
String shell = processor.get_shell(Generated_password, Generated_key, Generated_Encode);
if (chooser.showSaveDialog(jButton2)==JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
Fileutils.writeFile(file.getPath(),shell);
最后來看看成品


GitHub地址:https://github.com/nice0e3/CVE-2020-14882_Exploit_Gui/
命令框崩潰問題解決
在前面幾個版本中遇到在打weblogic的時候命令框使用echo語句寫shell會導致框體崩潰
如下圖:

原因其實是以為在寫gui的時候,設置了命令框可拉伸,取消掉拉伸功能,並且將框體設置不可最大化即可解決。
this.setResizable(false);
來自某人的反饋

批量探測POC,窗體無回顯問題
在寫批量POC的時候,發現已探知的漏洞想要將他輸出到框體里面,但顯示卻為空白,打了斷點調試也沒找到原因。而sout輸出到控制台卻能正常顯示內容。而后使用命令行編寫批量poc和利用的poc進行分離,暫時解決此問題。
String轉換inputsterm
InputStream byteArrayInputStream = new ByteArrayInputStream(data.getBytes());
讀取全部String內容
public static String read(String path){
File file = new File(path);
StringBuilder sb = new StringBuilder();
String line;
FileInputStream fileInputStream = null;
String str = null;
try {
fileInputStream = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fileInputStream));
while ((line = br.readLine()) != null) {
sb.append(line);
}
str = sb.toString();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
打包成jar包后無法讀取到資源文件問題解決
BufferedReader in = new BufferedReader(new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("CVE-2019-2725-10.txt")));
StringBuffer buffer = new StringBuffer();
String line = "";
try {
while ((line = in.readLine()) != null){
buffer.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
String input = buffer.toString();
未完續...
持續記錄問題與問題解決方案
