合法程序上的反病毒检测

Ben*_*Ben 22 java obfuscation antivirus

基本上,我的程序与另一个jar文件一起运行.以下是下载功能的代码:

public void saveUrl(final String filename, final String urlString) throws MalformedURLException, IOException {
    BufferedInputStream in = null;
    FileOutputStream fout = null;
    try {
        in = new BufferedInputStream(new URL(urlString).openStream());
        fout = new FileOutputStream(filename);

        final byte data[] = new byte[1024];
        int count;
        while ((count = in.read(data, 0, 1024)) != -1) {
            fout.write(data, 0, count);
        }

    } catch (Exception e) {
        return;
    } finally {
        if (in != null) {
            in.close();
        }
        if (fout != null) {
            fout.close();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

并开始新的过程

public void runUpdate() throws IOException{
    String folder = fileLocation;
    ProcessBuilder p = new ProcessBuilder();
    p.command(folder);
    p.start();
}
Run Code Online (Sandbox Code Playgroud)

但是,即使有用户提示并且必须批准下载,当我在Eclipse环境之外进行测试时,我的防病毒软件会立即将其提取出来.

它被检测为"trojan.downloader".我认为它与下载功能有关?我并没有真正想要击败反病毒程序.我不是在试图做任何非法行为.

也许一些混淆可以解决这个问题?

小智 12

您的编译器生成的字节码与AV正在寻找的某些特定代码模式/签名相匹配,这意味着他们过去发现/撤消的某些恶意软件具有类似于他们可以可靠找到的代码.

最好的选择是识别和重写触发检测的任何方法,直到它不再匹配AV正在寻找的任何方式,混淆不是一个好主意(但可以做,如果混淆器确实控制流混淆)用于修复这个问题因为无法保证它会产生与原始字节码不同的字节码(有些混淆器,比如ProGuard,甚至也没有控制流混淆).