Change the hex code in c # exe

1k views Asked by At

How can I change the image with C # as the hex codes http://prntscr.com/1oiw50

byte[] byt = File.ReadAllBytes("D:\\\\a.exe");
string hex = new SoapHexBinary(byt).ToString().Replace("504B0304", "424C0304");
File.WriteAllBytes("D:\\\\b.exe", new SoapHexBinary(hex).Value);

Exe does not work this way, but I'm trying.

1

There are 1 answers

2
Dotnet Programmer On
    byte[] byt = File.ReadAllBytes("D:\\a.exe");
    for (int i = 0; i <= byt.Length - 1; i++)
    {
        if (byt[i] == 80)
        {
            if (byt[i + 1] == 75)
            {
                if (byt[i + 2] == 3)
                {
                    if (byt[i + 3] == 4)
                    {
                        byt[i] = 66;
                        byt[i + 1] = 76;
                        byt[i + 2] = 3;
                        byt[i + 3] = 4;
                    }
                }


            }
        }
    }
    File.WriteAllBytes("D:\\b.exe", byt);

Do you have a bug in this code.I turned to decimal hex codes byt changed accordingly.