0

这是我的课:

class Program
{
    [DllImport("User32", CharSet = CharSet.Auto)]
    public static extern int SystemParametersInfo(int uiAction, int uiParam,
    string pvParam, uint fWinIni);

    static void Main(string[] args)
    {
        while (true)
        {
            if (!Directory.Exists("C:/temp"))
            {
                Directory.CreateDirectory("C:/temp");
            }

            if (!File.Exists(@"c:\temp\image.png"))
            {
                using (WebClient client = new WebClient())
                {
                    client.DownloadFile(new Uri("https://i.imgur.com/dhaP3Mu.png"), @"c:\temp\image.png");
                }
            }

            if (!CheckWallpaper(@"c:\temp\image.png"))
            {
                SystemParametersInfo(0x0014, 0, @"c:\temp\image.png", 0x0001);
            }

            Thread.Sleep(1000);
        }
    }

    static bool CheckWallpaper(string imagePath)
    {
        bool isSame = false;

        try
        {
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop\WallPaper"))
            {
                if (key != null)
                {
                    Object o = key.GetValue(imagePath);
                    if (o != null)
                    {
                        Version version = new Version(o as String);  //"as" because it's REG_SZ...otherwise ToString() might be safe(r)
                    }
                }
            }
        }
        catch (Exception ex)  //just for demonstration...it's always best to handle specific exceptions
        {
            //react appropriately
        }

        return isSame;
    }
}

这只是一个小恶作剧,使用户无法更改他的壁纸。但是现在我无法构建它,因为 eData 立即说它是“Variant.Razy.587029”病毒。我可以理解它认为它是一种病毒,那么有没有办法改进我的代码使其看起来不可疑?我没有卡巴斯基的问题。而且我无法更改病毒扫描设置,因为它显然不是我的电脑

编辑:我还没有完成,例如 CheckWallpaper() 总是输出false,我只是想测试它。

EDIT2:我现在将墙纸检查从“在注册表中查找”更改为“%appdata%/Roaming/Microsoft/Windows/Themes/TranscodedWallpaper与我的 Image.png 比较。我还添加了一个Thread.Sleep(1000),否则程序会再次被检测到”

4

1 回答 1

1

正如 Glenn van Acker 所说,它本质上是一种病毒。如果您真的希望这样的程序被杀毒软件忽略,“最简单”的方法是部署、签名和发布程序。然后写信给防病毒公司将其列入白名单。

于 2019-12-03T10:49:40.407 回答