L
L
LoonTiG2016-04-03 13:16:21
C++ / C#
LoonTiG, 2016-04-03 13:16:21

How to decompile, modify and compile back (C#)?

There is a C# program.
After decompilation, the following code was obtained:

using System;
using System.Runtime.CompilerServices;

namespace DateReverse
{

    internal class Program
    {

        [Serializable]
        [CompilerGenerated]
        private sealed class <>c
        {

            public static readonly Program.<>c <>9;

            public static Func<int,byte> <>9__2_0;

            static <>c()
            {
                Program.<>c.<>9 = new Program.<>c();
            }

            public <>c()
            {
            }

            internal byte <GetFlag>b__2_0(int x)
            {
                // trial
                return 0;
            }

        } // class <>c

        [CompilerGenerated]
        private sealed class <>c__DisplayClass2_0
        {

            public byte[] key;

            public <>c__DisplayClass2_0()
            {
            }

            internal byte <GetFlag>b__1(byte t, int i)
            {
                return (t ^ key[i]);
            }

        } // class <>c__DisplayClass2_0

        private static Random rand;

        public Program()
        {
        }

        static Program()
        {
            Program.rand = new Random(50616);
        }

        private static string GetFlag()
        {
            // trial
            return null;
        }

        public static void Main(string[] args)
        {
            DateTime dateTime = DateTime.Now;
            Console.WriteLine((dateTime.DayOfYear == 94) && (dateTime.Year == 2016) && (dateTime.DayOfWeek == DayOfWeek.Friday) ? Program.GetFlag() : "Sorry, try it another day");
        }

    } // class Program

}

I need to get the flag (Function getFlag()), the problem is in the date - 94 days is Sun.
How can I fix this error in the program? (Compilation throws errors)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2016-04-03
@Koolerz

I'm not an expert, but recently I also needed to change the compiled code. I used IL Spy, but .NET Reflector works too. There is a plugin for them - Reflexil. With it, you can edit the IL code and save it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question