zoukankan      html  css  js  c++  java
  • Java工具开发手记

    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();
    

    未完续...

    持续记录问题与问题解决方案

  • 相关阅读:
    js开发规范,在php上也适用
    [读码时间] 仿腾讯微博效果
    [读码时间] 完美拖拽
    [读码时间] div闪烁
    [读码时间]用键盘控制div
    [读码时间] 自定义右键菜单
    [读码时间] 跟随鼠标移动(大图展示)
    [读码时间] 阻止右键菜单
    [读码时间] 按下键盘显示keyCode
    面试(5)
  • 原文地址:https://www.cnblogs.com/nice0e3/p/14664238.html
Copyright © 2011-2022 走看看