C sharp - Ayuda para comprender esta función

 
Vista:
sin imagen de perfil
Val: 17
Ha disminuido 1 puesto en C sharp (en relación al último mes)
Gráfica de C sharp

Ayuda para comprender esta función

Publicado por aguml (9 intervenciones) el 23/12/2017 23:16:52
Hola amigos, tengo un código que estoy intentando entender pero en visual studio c# no compila. La parte que quiero entender por ahora y donde da los errores es esta:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
public unsafe byte[] Decrypt(byte[] eData)
{
    byte[] buffer2;
    byte[] buffer = Class41.smethod_0((int) Class37.smethod_0(eData));
    if (((buffer2 = eData) != null) && (((int) Class37.smethod_0(buffer2)) != 0))
    {
        numRef2 = &(buffer2[Class4.smethod_0(0x114)]);
    }
    fixed (byte* numRef2 = ((byte*) Class4.smethod_0(0x110)))
    {
        if (((buffer2 = buffer) != null) && (((int) Class37.smethod_0(buffer2)) != 0))
        {
            numRef = &(buffer2[Class4.smethod_0(0x11c)]);
        }
        fixed (byte* numRef = ((byte*) Class4.smethod_0(280)))
        {
            int* numPtr = (int*) numRef2;
            int* numPtr2 = (int*) numRef;
            int num = Class4.smethod_0(0x120);
            do
            {
                numPtr += Class4.smethod_0(0x124);
                int num2 = numPtr[0].smethod_2();
                numPtr += Class4.smethod_0(0x128);
                int num3 = numPtr[0].smethod_2();
                this.ccfae92404b1d8caf890158f763ac579b(ref num2, ref num3);
                numPtr2 += Class4.smethod_0(300);
                numPtr2[0] = num2 = num2.smethod_2();
                numPtr2 += Class4.smethod_0(0x130);
                numPtr2[0] = num3 = num3.smethod_2();
                num += Class4.smethod_0(0x134);
            }
            while (num < (((int) Class37.smethod_0(eData)) >> Class4.smethod_0(0x138)));
        }
    }
    return buffer;
}
Los errores los da en las líneas con fixed.
¿Alguien puede corregir el código y comentarlo para entender que hace en cada línea?
Otra duda que tengo pero no aparece en este código es ¿Que diferencia hay entre usar IntPtr y int*?
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 17
Ha disminuido 1 puesto en C sharp (en relación al último mes)
Gráfica de C sharp

Ayuda para comprender esta función

Publicado por agustin (9 intervenciones) el 25/12/2017 17:05:44
Aqui os pongo todas las funciones que creo que son las que estan involucradas por si podeis echarme un cable:
El botón que desencripta:
El botón que desencripta:
1
2
3
4
5
private void button_1_Click(object sender, EventArgs e)
{
    File.WriteAllBytes(this.string_0, new Form1.GClass1(this.byte_0).Decrypt(File.ReadAllBytes(this.string_0)));
    int num = (int)MessageBox.Show(Class5.c39c0e0f1863ae92a6bb9f1c4d11eea98(80));
}

La función desencriptadora:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
public unsafe byte[] Decrypt(byte[] eData)
{
    byte[] numArray = Class41.smethod_0((int) Class37.smethod_0(eData));
    byte[] byte_0_1;
    // ISSUE: cast to a reference type
    // ISSUE: explicit reference operation
    // ISSUE: explicit reference operation
    fixed (byte* numPtr1 = &^((byte_0_1 = eData) == null || (int) Class37.smethod_0(byte_0_1) == 0 ? (byte&) Class4.smethod_0(272) : @byte_0_1[Class4.smethod_0(276)]))
    {
        byte[] byte_0_2;
        // ISSUE: cast to a reference type
        // ISSUE: explicit reference operation
        // ISSUE: explicit reference operation
        fixed (byte* numPtr2 = &^((byte_0_2 = numArray) == null || (int) Class37.smethod_0(byte_0_2) == 0 ? (byte&) Class4.smethod_0(280) : @byte_0_2[Class4.smethod_0(284)]))
        {
            int* numPtr3 = (int*) numPtr1;
            int* numPtr4 = (int*) numPtr2;
            int num1 = Class4.smethod_0(288);
            while (num1 < (int) Class37.smethod_0(eData) >> Class4.smethod_0(312))
            {
                int* numPtr5 = numPtr3;
                IntPtr num2 = (IntPtr) Class4.smethod_0(292);
                int* numPtr6 = (int*) ((IntPtr) numPtr5 + num2);
                int int_2 = GClass0.smethod_2(*numPtr5);
                int* numPtr7 = numPtr6;
                IntPtr num3 = (IntPtr) Class4.smethod_0(296);
                numPtr3 = (int*) ((IntPtr) numPtr7 + num3);
                int int_3 = GClass0.smethod_2(*numPtr7);
                this.ccfae92404b1d8caf890158f763ac579b(ref int_2, ref int_3);
                int* numPtr8 = numPtr4;
                IntPtr num4 = (IntPtr) Class4.smethod_0(300);
                int* numPtr9 = (int*) ((IntPtr) numPtr8 + num4);
                int num5;
                int num6 = num5 = GClass0.smethod_2(int_2);
                *numPtr8 = num5;
                int* numPtr10 = numPtr9;
                IntPtr num7 = (IntPtr) Class4.smethod_0(304);
                numPtr4 = (int*) ((IntPtr) numPtr10 + num7);
                int num8;
                int_3 = num8 = GClass0.smethod_2(int_3);
                *numPtr10 = num8;
                num1 += Class4.smethod_0(308);
            }
            // ISSUE: cast to a reference type
            // ISSUE: variable of a reference type
            byte& local1 = (byte&) Class4.smethod_0(316);
            // ISSUE: cast to a reference type
            // ISSUE: variable of a reference type
            byte& local2 = (byte&) Class4.smethod_0(320);
            return numArray;
        }
    }
}

Esta función creo que es la que realmente desencripta usando dos valores enteros (supongo que uno será el que está en el archivo y el otro el que se usa para desencriptar):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
private void ccfae92404b1d8caf890158f763ac579b(ref int int_2, ref int int_3)
{
     Class4.smethod_0(376);
     int num1 = Class4.smethod_0(380);
     int num2;
     do
     {
         num2 = this.int_0[Class4.smethod_0(384) - num1] ^ int_2;
         int_2 = (this.int_1[Class4.smethod_0(388), (int) (byte) (num2 >> Class4.smethod_0(392))] + this.int_1[Class4.smethod_0(396), (int) (byte) (num2 >> Class4.smethod_0(400))] ^ this.int_1[Class4.smethod_0(404), (int) (byte) (num2 >> Class4.smethod_0(408))]) + this.int_1[Class4.smethod_0(412), (int) (byte) num2] ^ int_3;
         int_3 = num2;
         num1 += Class4.smethod_0(416);
     }
     while (num1 < Class4.smethod_0(420));
     int_3 = this.int_0[Class4.smethod_0(424)] ^ int_2;
     int_2 = this.int_0[Class4.smethod_0(428)] ^ num2;
}

La función Class41.smethod_0:
1
2
3
4
internal static byte[] smethod_0(int int_0)
{
    return new byte[int_0];
}

la función Class37.smethod_0:
1
2
3
4
internal static UIntPtr smethod_0(byte[] byte_0)
{
    return (UIntPtr) byte_0.Length;
}

La función Class4.smethod_0:
1
2
3
4
internal static int smethod_0(int int_1)
{
    return BitConverter.ToInt32(Class4.byte_0, int_1);
}

La parte donde se define Class4.byte_0:
1
2
3
4
5
6
7
8
9
10
11
12
13
internal sealed class Class4
{
    internal static readonly byte[] byte_0;
    internal readonly int int_0;
 
    static Class4()
    {
        if (Class4.byte_0 != null)
            return;
        byte[] bytes = Convert.FromBase64String("UmVzaWRlbnQgRXZpbCBSZXZlbGF0aW9ucyAyIERlY3J5cHRlciU=");
        Class4.byte_0 = Class6.smethod_1(97L, Assembly.GetExecutingAssembly().GetManifestResourceStream(Encoding.UTF8.GetString(bytes, 0, bytes.Length)));
    }
    ...

El botón donde se encripta:
1
2
3
4
5
private void button_2_Click(object sender, EventArgs e)
{
    File.WriteAllBytes(this.string_0, new Form1.GClass1(this.byte_0).Encrypt(File.ReadAllBytes(this.string_0)));
    int num = (int)MessageBox.Show(Class5.c39c0e0f1863ae92a6bb9f1c4d11eea98(95));
}

Para la funcion encriptadora:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
public unsafe byte[] Encrypt(byte[] uData)
{
    byte[] numArray = Class41.smethod_0((int) Class37.smethod_0(uData));
    byte[] byte_0_1;
    // ISSUE: cast to a reference type
    // ISSUE: explicit reference operation
    // ISSUE: explicit reference operation
    fixed (byte* numPtr1 = &^((byte_0_1 = uData) == null || (int) Class37.smethod_0(byte_0_1) == 0 ? (byte&) Class4.smethod_0(220) : @byte_0_1[Class4.smethod_0(224)]))
    {
        byte[] byte_0_2;
        // ISSUE: cast to a reference type
        // ISSUE: explicit reference operation
        // ISSUE: explicit reference operation
        fixed (byte* numPtr2 = &^((byte_0_2 = numArray) == null || (int) Class37.smethod_0(byte_0_2) == 0 ? (byte&) Class4.smethod_0(228) : @byte_0_2[Class4.smethod_0(232)]))
        {
            int* numPtr3 = (int*) numPtr2;
            int* numPtr4 = (int*) numPtr1;
            int num1 = Class4.smethod_0(236);
            while (num1 < (int) Class37.smethod_0(uData) >> Class4.smethod_0(260))
            {
                int* numPtr5 = numPtr4;
                IntPtr num2 = (IntPtr) Class4.smethod_0(240);
                int* numPtr6 = (int*) ((IntPtr) numPtr5 + num2);
                int int_2 = GClass0.smethod_2(*numPtr5);
                int* numPtr7 = numPtr6;
                IntPtr num3 = (IntPtr) Class4.smethod_0(244);
                numPtr4 = (int*) ((IntPtr) numPtr7 + num3);
                int int_3 = GClass0.smethod_2(*numPtr7);
                this.c0c1ef294051644e1e4a229a2e6a0ee04(ref int_2, ref int_3);
                int* numPtr8 = numPtr3;
                IntPtr num4 = (IntPtr) Class4.smethod_0(248);
                int* numPtr9 = (int*) ((IntPtr) numPtr8 + num4);
                int num5;
                int num6 = num5 = GClass0.smethod_2(int_2);
                *numPtr8 = num5;
                int* numPtr10 = numPtr9;
                IntPtr num7 = (IntPtr) Class4.smethod_0(252);
                numPtr3 = (int*) ((IntPtr) numPtr10 + num7);
                int num8;
                int_3 = num8 = GClass0.smethod_2(int_3);
                *numPtr10 = num8;
                num1 += Class4.smethod_0(256);
            }
            // ISSUE: cast to a reference type
            // ISSUE: variable of a reference type
            byte& local1 = (byte&) Class4.smethod_0(264);
            // ISSUE: cast to a reference type
            // ISSUE: variable of a reference type
            byte& local2 = (byte&) Class4.smethod_0(268);
            return numArray;
        }
    }
}

Esta función creo que es la que realmente encripta usando dos valores enteros (supongo que uno será el que está en el archivo y el otro el que se usa para encriptar):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
private void c0c1ef294051644e1e4a229a2e6a0ee04(ref int int_2, ref int int_3)
{
    Class4.smethod_0(324);
    int index = Class4.smethod_0(328);
    int num;
    do
    {
        num = this.int_0[index] ^ int_2;
        int_2 = (this.int_1[Class4.smethod_0(332), (int) (byte) (num >> Class4.smethod_0(336))] + this.int_1[Class4.smethod_0(340), (int) (byte) (num >> Class4.smethod_0(344))] ^ this.int_1[Class4.smethod_0(348), (int) (byte) (num >> Class4.smethod_0(352))]) + this.int_1[Class4.smethod_0(356), (int) (byte) num] ^ int_3;
        int_3 = num;
        index += Class4.smethod_0(360);
    }
    while (index < Class4.smethod_0(364));
    int_3 = this.int_0[Class4.smethod_0(368)] ^ int_2;
    int_2 = this.int_0[Class4.smethod_0(372)] ^ num;
}
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar