You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C# Winform程序被卡巴斯基误报为HEUR:Trojan-Spy.MSIL.Bobik.gen求解决

剪贴板监听WinForm程序被卡巴斯基误报为木马的问题分析与解决办法

问题原因

你代码中使用的AddClipboardFormatListener和RemoveClipboardFormatListener是Windows API中用于监听剪贴板内容变化的函数,这类行为与间谍软件窃取剪贴板数据的特征高度吻合。卡巴斯基的启发式检测(HEUR)机制会基于这类行为模式,将程序标记为HEUR:Trojan-Spy.MSIL.Bobik.gen木马。此外,直接调用未封装的Win32 API的写法,也会增加被误判的概率。

解决办法

1. 规范代码写法,减少特征触发

  • 给DllImport添加CharSet参数,明确字符编码,让代码更符合标准:
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern bool ReleaseCapture();
[DllImport("User32.dll", CharSet = CharSet.Unicode)]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool AddClipboardFormatListener(IntPtr hwnd);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool RemoveClipboardFormatListener(IntPtr hwnd);
  • 避免重复调用RemoveClipboardFormatListener:按钮点击事件中无需重复调用,因为FormClosing事件已经会执行该操作,重复调用可能产生不必要的系统调用痕迹:
public Form1()
{
    InitializeComponent();
    AddClipboardFormatListener(this.Handle);
    this.FormClosing += (s, e) =>
    {
        RemoveClipboardFormatListener(this.Handle);
    };
    button1.Click += (s, e) =>{
        // 按钮退出应用
        Application.Exit();
    };
}

2. 给程序添加代码签名

使用正规的代码签名证书对编译后的exe文件进行签名,签名后的程序会被杀毒软件认定为可信发布的程序,大幅降低误报概率。

3. 向卡巴斯基提交误报反馈

将你的程序文件提交到卡巴斯基的误报处理平台,说明这是正常的剪贴板监听工具,请求更新病毒库规则解除误报。

4. 临时信任设置

在卡巴斯基的防护设置中,将你的程序文件或所在文件夹添加到信任列表/排除项,避免程序被自动删除。

内容的提问来源于stack exchange,提问作者LeeJunx

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 06:16:18