Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. How .NET Runtime interprets obfuscated C# code?

How .NET Runtime interprets obfuscated C# code?

Scheduled Pinned Locked Moved The Lounge
csharpjavaquestiontools
15 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jorgen Andersson

    Nope, but outsourcing is cheaper.

    Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #6

    :laugh:

    Veni, vidi, vici.

    1 Reply Last reply
    0
    • J Jun Du

      Have got a chance to work with some obfuscating tools. I understand .NET Runtime works the same way as JVM does. My question is the following: After I obfuscated (i.e. messed up) compiled byte-code (Java or .NET), how could the Virtual Machine (.NET Runtime or JVM) still understand the byte-code and compile it into the machine code?

      Best, Jun

      M Offline
      M Offline
      Marcelo Ricardo de Oliveira
      wrote on last edited by
      #7

      It's only "messed up" to humans... for example, the following obfuscated code isn't any harder for the runtime to understand than the code you write:

      using O111; using O111.l1000; using System; using System.Collections; using
      System.l1001; using System.l1010; using System.Text; public class l1011 {
      public string l1100; public int l1101; public l1011(string l1011) { l1100 =
      O1110(l1011); } public int O1111 { get { if (l1101 == 0) return 1; if (l1101
      == 1 && l1100 == "v\u006F\u0069\u0064") return 012; return 3; } } public bool
      O10000 { get { return l1101 == 0 && l1100 == "\u0076oid"; } } public string
      O10001(int O10010, bool O10011, bool l10100) { if (l1101 == 0) return l1100;
      if (O10010 == 0) return l1100+l10101(l10100 ? '\u0050' : '\u002A'); if (l1101

      1 || O10011 || O10010 == 1) return "\u0049n\u0074\u0050\u0074\u0072"; if (
      l1100 == "\u0076o\u0069d") switch (O10010) { case 2 : return "b\u0079\u0074\
      u0065[\u005D"; case 3 : return "sbyte\u005B]"; case 4 : return "\u0073\u0068\
      u006Fr\u0074[]"; case 5 : return "\u0075\u0073h\u006Fr\u0074\u005B]"; case
      6 : return "\u0069\u006E\u0074[\u005D"; case 7 : return "\u0075int[]"; case
      8 : return "\u0066\u006C\u006Fa\u0074[]"; case 011 : return "d\u006Fu\u0062\
      u006C\u0065\u005B]"; } return l1100+"\u005B]"; } string l10101(char O10110) {
      l10111 O11000 = new l10111(); for (int O11001 = 0; O11001 < l1101;
      O11001++ )O11000.l11010(O10110); return O11000.O10001(); } public bool O11011 {
      get { return l1101 > 0; } } public int O11100 { get { switch (l1100) { case "
      v\u006Fid" : return 0; case "b\u0079\u0074\u0065" : case "\u0073b\u0079te" :
      return 1; case "s\u0068o\u0072\u0074" : case "\u0075\u0073h\u006Fr\u0074" :
      return 2; case "i\u006Et" : case "u\u0069nt" : return 4; case "\u0066loat" :
      return 4; case "\u0064\u006F\u0075b\u006Ce" : return 8; default : throw new
      l11101("unkno\u0077\u006E \u0062\u0061se\u0020\u0074ype"); } } } static
      O11110 l11111; public static string O1110(string l1011) { if (l11111 == null)
      l11111 = O100000(); string l100001 = (string)l11111[l1011]; if (l100001 ==
      null) { l100010.l100011.l100100("\u0077a\u0072\u006Ei\u006Eg:\u0020u\u006Ekno\
      u0077\u006E\u0020\u0074\u0079\u0070\u0065\u0020\u0022"+l1011+"\u0022\
      u0020use \u0061\u0073 \u0069\u0073."); l11111[l1011] = l1011; l100001 =
      l1011; } return l100001; } static O11110 O100000() { O11110 l100001 = new
      O11110(); l100001["v\u006Fid"] = "\u0076o\u0069\u0064"; l100001["\u0047L\
      u0076oid"] = "v\u006F\u0069\u0064"; l100001["G\u004Cenum"] = "u\u0069n\
      u0074"; l100001["G\u004C

      1 Reply Last reply
      0
      • C CPallini

        It is NOT 'messed up', it is 'obfuscated'. (obfuscated answer)

        Veni, vidi, vici.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #8

        That depends on how much you paid for your obfuscater. :-D

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • J Jun Du

          Have got a chance to work with some obfuscating tools. I understand .NET Runtime works the same way as JVM does. My question is the following: After I obfuscated (i.e. messed up) compiled byte-code (Java or .NET), how could the Virtual Machine (.NET Runtime or JVM) still understand the byte-code and compile it into the machine code?

          Best, Jun

          T Offline
          T Offline
          TheGreatAndPowerfulOz
          wrote on last edited by
          #9

          Obfuscation just changes the identifiers in your code to make the code hard to read. It does not change how it compiles. The Reflection database is also obfuscated, so code reflection at runtime is also harder.

          If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
          You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

          B 1 Reply Last reply
          0
          • J Jorgen Andersson

            Nope, but outsourcing is cheaper.

            Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

            D Offline
            D Offline
            djdanlib 0
            wrote on last edited by
            #10

            Well played, sir!

            1 Reply Last reply
            0
            • J Jorgen Andersson

              Nope, but outsourcing is cheaper.

              Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

              B Offline
              B Offline
              BillWoodruff
              wrote on last edited by
              #11

              Jörgen Andersson wrote:

              Nope, but outsourcing is cheaper

              I am kind of "dense" here just after 7am (GMT + 7), and my brain is not yet fully caffeinated ... but ... Are you implying that outsourcing is cheaper because: the code you get back will be already obfuscated by the spaghetti-code style of the outsourcerer (outsorcerer ?) you hired on the cheap ? :) best, Bill

              "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

              J 1 Reply Last reply
              0
              • T TheGreatAndPowerfulOz

                Obfuscation just changes the identifiers in your code to make the code hard to read. It does not change how it compiles. The Reflection database is also obfuscated, so code reflection at runtime is also harder.

                If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
                You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

                B Offline
                B Offline
                BillWoodruff
                wrote on last edited by
                #12

                ahmed zahmed wrote:

                The Reflection database is also obfuscated, so code reflection at runtime is also harder.

                Hi Ahmed, could you say a bit more about this ? To me your statement implies there will a cost (one-time ?) as the reflection database is "un-obfuscated:" am I interpreting your remark correctly ? thanks, Bill

                "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

                D T 2 Replies Last reply
                0
                • B BillWoodruff

                  ahmed zahmed wrote:

                  The Reflection database is also obfuscated, so code reflection at runtime is also harder.

                  Hi Ahmed, could you say a bit more about this ? To me your statement implies there will a cost (one-time ?) as the reflection database is "un-obfuscated:" am I interpreting your remark correctly ? thanks, Bill

                  "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #13

                  For staticly implemented (not sure if this is the right term; I'm thinking of code where the reflection names are set at compile time) reflection within the lump of obfuscated code there shouldn't be a problem with a well written obfuscator since it should be smart enough to detect where reflection is taking place and replace the strings containing method/etc names with their obfuscated equivalents. In order do reflection based on runtime input you need to leave the names un-obfuscated. OTOH most code protection tools I've looked at go beyond just obfuscating names and do things to make reflection tools fail to show any code at all. And on the gripping hand, most of those companies also sell anti-obfuscating reflection tools that claim to be able to break everyone elses protection. I've not verified the latter claim however. Make of this what you will, and remember that if nothing else, a determined attacker can always capture the x86 machine code the jitter creates and work on it with a native debugger. At best you can only make your app as difficult to reverse engineer as if it was written as native C++ code.

                  Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                  1 Reply Last reply
                  0
                  • B BillWoodruff

                    Jörgen Andersson wrote:

                    Nope, but outsourcing is cheaper

                    I am kind of "dense" here just after 7am (GMT + 7), and my brain is not yet fully caffeinated ... but ... Are you implying that outsourcing is cheaper because: the code you get back will be already obfuscated by the spaghetti-code style of the outsourcerer (outsorcerer ?) you hired on the cheap ? :) best, Bill

                    "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

                    J Offline
                    J Offline
                    Jorgen Andersson
                    wrote on last edited by
                    #14

                    I think your coffee works just fine. :)

                    Light moves faster than sound. That is why some people appear bright, until you hear them speak. List of common misconceptions

                    1 Reply Last reply
                    0
                    • B BillWoodruff

                      ahmed zahmed wrote:

                      The Reflection database is also obfuscated, so code reflection at runtime is also harder.

                      Hi Ahmed, could you say a bit more about this ? To me your statement implies there will a cost (one-time ?) as the reflection database is "un-obfuscated:" am I interpreting your remark correctly ? thanks, Bill

                      "The greatest mystery is not that we have been flung at random between the profusion of matter and of the stars, but that within this prison we can draw from ourselves images powerful enough to deny our nothingness." Andre Malraux

                      T Offline
                      T Offline
                      TheGreatAndPowerfulOz
                      wrote on last edited by
                      #15

                      What Dan said.

                      If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
                      You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups