Quantcast
Channel: Obfuscar, The Open Source Obfuscation Tool for .NET Assemblies
Viewing all 249 articles
Browse latest View live

Edited Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A

Commented Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A
Comments: Thanks! Just added a much simpler example where there is no explicitly implemented interface members and it fails too.

Commented Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A
Comments: The obfuscation process reuses names, so that it really confuses CLR on which method should be called at runtime. I am still investigating to see whether there is any workaround. Will post back if I have any finding.

Updated Wiki: Configuration

$
0
0
Obfuscar accepts a single command line argument, the path to its configuration file.

The configuration file is used to specify what assemblies should be obfuscated, where to find the dependencies for the assemblies, and where the obfuscated assemblies should be saved.

Table of Settings

Name Description
InPath Input file location
OutPath Output file location
LogFile Obfuscation log file path (mapping.txt)
XmlMapping Whether the log file should be of XML format
KeyFile Key file path
RegenerateDebugInfo Whether to generate debug symbols for obfuscated assemblies
MarkedOnly Whether only to obfuscate marked items
RenameProperties Whether to rename properties
RenameEvents Whether to rename events
KeepPublicApi Whether to keep public API out of obfuscation
HidePrivateApi Whether to hide private API via obfuscation
ReuseNames Whether to reuse obfuscated names
UseUnicodeNames Whether to use Unicode characters as obfuscated names
UseKoreanNames Whether to use Korean characters as obfuscated names
HideStrings Whether to hide strings
OptimizedMethods Whether to optimize methods
SuppressIldasm Whether to inform ILdism that assemblies are obfuscated

Variables, InPath and OutPath

The following is a is an example of a minimal configuration. It is provided in the release as part of the Basic Example:
<?xml version='1.0'?>
<Obfuscator>
  <Var name="InPath" value=".\Obfuscator_Input" />
  <Var name="OutPath" value=".\Obfuscator_Output" />

  <Module file="$(InPath)\BasicExampleExe.exe" />
  <Module file="$(InPath)\BasicExampleLibrary.dll" />
</Obfuscator>


In the example configuration, two variables are defined, InPath and OutPath, using the Var element, and two assemblies are listed for obfuscation, an executable and a dll.

Variables defined using the Var element will be expanded in strings following the definition...After defining InPath as follows:
<Var name="InPath" value=".\Obfuscator_Input" />

It can be used in another location:
<Module file="$(InPath)\BasicExampleExe.exe" />

In addition to being usable like macros, there are a few special variables that have additional effects. The variable InPath is used when trying to find dependencies (the specified path is searched), and the variable OutPath is used as the output path for the obfuscated assemblies and the map. If either InPath or OutPath is unspecified, they default to the current path (".").

KeepPublicApi and HidePrivateApi (new)

A common case of assembly obfuscation is to strip out private information and keep public items. This can be achieved by setting the following combination,
<Var name="KeepPublicApi" value="true" />
  <Var name="HidePrivateApi" value="true" />

Note that by using above you don't need to set any obfuscation attribute or rule.

Another common case is to strip out everything, which can be achieved by setting
<Var name="KeepPublicApi" value="false" />
  <Var name="HidePrivateApi" value="true" />


Of course to keep everything we can use
<Var name="KeepPublicApi" value="true" />
  <Var name="HidePrivateApi" value="false" />


The last combination is the default, which strips out public information only,
<Var name="KeepPublicApi" value="false" />
  <Var name="HidePrivateApi" value="false" />

It should be rarely used.

Modules

For each assembly to be obfuscated, there must be a Module element. Assemblies referenced by an assembly specified by a Module element must be resolvable, either via Cecil's regular resolution process, or they must be present in the path specified by InPath.

Though additional assemblies are loaded for examination, only the specified assemblies will be obfuscated.

Exclusion Rules by Configuration

It is possible to include additional elements within the Module elements to skip types (the SkipTypes element), methods (the SkipMethod element), fields (SkipField), properties (SkipProperty), and events (SkipEvent, of course). Methods can be excluded from string obfuscation by SkipStringHiding.

The SkipNamespace element specifies a namespace that should be skipped. All types, methods, fields, etc., within the namespace will be skipped.

The SkipType element specifies the name of the type to skip, including the full namespace. It can also specify whether to skip the method, fields, properties, and/or events within the type.

The SkipMethod element specifies the name of the type containing the method, a protection specifier, and a name or regex to match the method. The protection specifier is currently ignored, but will eventually be used for additional filtering.

The SkipField element specifies the name of the type containing the field, a protection specifier, and a name or regex to match the field. The protection specifier is currently ignored, but will eventually be used for additional filtering.

The SkipProperty element specifies the name of the type containing the property, a protection specifier, and a name or regex to match the property. The protection specifier is currently ignored, but will eventually be used for additional filtering.

The SkipEvent element specifies the name of the type containing the event, a protection specifier, and a name or regex to match the event. The protection specifier is currently ignored, but will eventually be used for additional filtering.

The SkipStringHiding element works like the SkipMethod element, but specifies within which methods not to obfuscate the string constants. To make it harder to analyze the code, Obfuscar normally replaces string loads by method calls to lookup functions, which incurs a small performance penalty.

A more complete example:
<Module file="$(InPath)\AssemblyX.exe">
    <!-- skip a namespace -->
    <SkipNamespace name="Company.PublicBits" />

    <!-- to skip a namespace recursively, just put * on the end -->
    <SkipNamespace name="Company.PublicBits*" />

    <!-- skip field by name -->
    <SkipField type="Full.Namespace.And.TypeName"
      attrib="public" name="Fieldname" />

    <!-- skip field by regex -->
    <SkipField type="Full.Namespace.And.TypeName"
      attrib="public" rx="Pub.*" />

    <!-- skip type...will still obfuscate its methods -->
    <SkipType name="Full.Namespace.And.TypeName2" />

    <!-- skip type...will skip its methods next -->
    <SkipType name="Full.Namespace.And.TypeName3" />
    <!-- skip TypeName3's public methods -->
    <SkipMethod type="Full.Namespace.And.TypeName3"
      attrib="public" rx=".*" />
    <!-- skip TypeName3's protected methods -->
    <SkipMethod type="Full.Namespace.And.TypeName3"
      attrib="family" rx=".*" />

    <!-- skip type and its methods -->
    <SkipType name="Full.Namespace.And.TypeName4" skipMethods="true" />
    <!-- skip type and its fields -->
    <SkipType name="Full.Namespace.And.TypeName4" skipFields="true" />
    <!-- skip type and its properties -->
    <SkipType name="Full.Namespace.And.TypeName4" skipProperties="true" />
    <!-- skip type and its events -->
    <SkipType name="Full.Namespace.And.TypeName4" skipEvents="true" />
    <!-- skip attributes can be combined (this will skip the methods and fields) -->
    <SkipType name="Full.Namespace.And.TypeName4" skipMethods="true" skipFields="true" />
    <!-- skip the hiding of strings in this type's methods -->
    <SkipType name="Full.Namespace.And.TypeName4" skipStringHiding="true" />

    <!-- skip a property in TypeName5 by name -->
    <SkipProperty type="Full.Namespace.And.TypeName5"
      name="Property2" />
    <!-- skip a property in TypeName5 by regex -->
    <SkipProperty type="Full.Namespace.And.TypeName5"
      attrib="public" rx="Something\d" />

    <!-- skip an event in TypeName5 by name -->
    <SkipProperty type="Full.Namespace.And.TypeName5"
      name="Event2" />
    <!-- skip an event in TypeName5 by regex -->
    <SkipProperty type="Full.Namespace.And.TypeName5"
      rx="Any.*" />

    <!-- avoid the hiding of strings in TypeName6 on all methods -->
    <SkipStringHiding type="Full.Namespace.And.TypeName6" name="*" />
  </Module>


To prevent all properties from being obfuscated, set the RenameProperties variable to "false" (it's an xsd boolean). To prevent specific properties from being renamed, use the SkipProperty element. It will also skip the property's accessors, get_XXX and set_XXX.

To prevent all events from being obfuscated, set the RenameEvents variable to "false" (it's also xsd boolean). To prevent specific events from being renamed, use the SkipEvent element. It will also skip the event's accessors, add_XXX and remove_XXX.

Inclusion Rules by Configuration (new)

To supplement Skip* elements, Force* has been added.

Name Matching

The SkipMethod, SkipProperty, SkipEvent, SkipField, and SkipStringHiding elements accept an rx attribute that specifies a regular expression used to match the name of the thing to be skipped. The SkipType, SkipMethod, SkipProperty, SkipEvent, SkipField, and SkipStringHiding elements all accept a name attribute that specifies a string with optional wildcards or a regular expression used to match the name of the thing to be skipped. For elements where both the name and rx attributes are specified, the rx attribute is ignored. The name attribute can specify either a string or a regular expression to match the name of the thing to be skipped. If the value of the name attribute begins with a '^' character, the value (including the '^') will be treated as a regular expression (e.g., the name '^so.*g' will match the string something). Otherwise, the value will be used as a wildcard string, where '*' matches zero or more characters, and '?' matches a single character (e.g., the wildcard string som?t*g will match the string something).

This behavior also applies to the value of the type attribute of the SkipMethod, SkipProperty, SkipEvent, SkipField, and SkipStringHiding elements.

Accessibility Check

The SkipMethod, SkipProperty, SkipEvent, SkipField, and SkipStringHiding elements also accept an attrib attribute.
  • Not specified or attrib='': All members are skipped from obfuscation.
  • attrib='public': Only public members are skipped.
  • attrib='protected': Only public and protected members are skipped.
  • All other values for attrib generate an error by now.

Members which are internal or protected internal are not skipped when attrib is public or protected.
Properties and events do not directly have an accessibility attribute, but their underlying methods (getter, setter, add, remove) have. For properties the attribute of the getter and for events the attribute of the add method is used.

Exclusion by Attributes in Code

There's also some functionality where you can mark types with an attribute to prevent them from being obfuscated...reference Obfuscar.exe and add the Obfuscate attribute to your types. For example, to suppress obfuscation of X, its methods, fields, resources, etc.:
  [Obfuscate( false )]
  class X { }

The Obfuscate attribute has a flag, ShouldObfuscate, that defaults to true if not set. The following are equivalent:
  [Obfuscate]
  class X { }

  [Obfuscate( true )]
  class Y { }

  [Obfuscate( ShouldObfuscate = true )]
  class X { }

And if you only want specific classes obfuscated, you can set the MarkedOnly variable to "true" (also an xsd boolean), and apply the Obfuscate attribute to the things you want obfuscated. This is done in the ObfuscarTests project (included w/ the source...it's intended to be a place for unit tests, but for now does little) to obfuscate a subset of the classes. For example, if MarkedOnly is set to true, to include obfuscation of X, its methods, fields, resources, etc.:
  [Obfuscate]
  class X { }


Note that System.Reflection.ObfuscationAttribute is also supported.

Inclusion/Exclusion Rule Priorities

Above several inclusion/exclusion methods have been documented. What if multiple rules apply to a single item? Which rule is executed while others ignored?

The rule of thumb is as below,
  1. Attributes set on the item is always of top priority. If an attribute is detected, then all other rules are ignored. For members of a type, if the member itself does not contain such attributes, the type's attributes take effect.
  2. If no attribute is set, inclusion rules (Force*) are of top priority.
  3. If no inclusion rule is set, exclusion rules (Skip*) are of top priority.
  4. If no exclusion rule is set, KeepPublicApi and HidePrivateApi take effect.

Control Generation of Obfuscated Names

By default all new type and member names generated by Obfuscar are only unique within their scopes. A type with name A may be part of namespace A.A and A.B. The same holds true for type members. Multiple types may have fields and properties with the same name.

When using System.Xml.Serialization.XmlSerializer on obfuscated types, the names of generated Xml elements and attributes have to be specified with one of the XmlXXXXXAttribute attributes. This is because the original type and member names do not exist any more after obfuscation. For some reasons the XmlSerializer uses the obfuscated names internally even though they are overridden by attributes. Because of that it fails on duplicate names. The same is true for the XML Serializer Generator-Tool (Sgen.exe).

You can work around this problem by setting the ReuseNames variable to false. In this case the obfuscator does not reuse names for types, fields and properties. The generated names are unique over all assemblies. This setting does not apply to methods.

Add the following line to the configuration file to enable unique names:
<Var name="ReuseNames" value="false" />

Control Hiding of Strings

By default Obfuscar hides all string constants by replacing the string load (LDSTR opcode) by calls to methods which return the string from a buffer. This buffer is allocated on startup (in a static constructor) by reading from a XOR-encoded UTF8 byte array containing all strings. This comes with a small performance cost. You can disable this feature completely by adding the following line to the configuration file:
<Var name="HideStrings" value="false" />

If you only want to disable it on specific methods use the SkipStringHiding elements.

Signing of Strongly Named Assemblies

Signed assemblies will not work after obfuscation and must be re-signed.

Add the following line to the configuration file to specify the path to your key file. When given a KeyFile in the configuration, Obfuscar will sign a previously signed assembly with the given key. Relative paths are searched from the current directory and, if not found, from the directory containing the particular assembly.
<Var name="KeyFile" value="key.snk" />

If no KeyFile is specified, Obfuscar normally throws an exception on signed assemblies. If an assembly is marked delay signed, the signing step will be skipped in case no key file is given.

With the special key file name auto, Obfuscar uses the value of the AssemblyKeyFileAttribute instead (if existing).

Created Unassigned: NUnit fails to load obfuscated dll [8]

$
0
0
Hi

I've been experimenting with Obfuscar and to be safe I want to run my unit tests first, then obfuscate and rerun the tests to ensure nothing has broken. However after obfuscation of the library being tested I cannot get the dll containing the test code to load in NUnit - it throws a FileNotFound exception for the test code dll, even though I've just selected it, and it can be loaded by ILSpy.

I've created and attached an example which replicates the problem. There are two dlls, the first contains the code I want obfuscating, in this case MyClass with a single static property Value that returns a string. The second dll contains the NUnit test which simply checks the string is what it is expecting.

My Obfuscar configuration is set to obfuscate the first dll, and to ignore the namespace used in the test dll. The configuration file is at packages/Obfuscar.2.0.0.0/tools/test.xml and the obfuscated output written to the Output folder at that location.

If I load the test dll in ILSpy I can see that it has adjusted the call to the obfuscated class as A.A() instead of MyClass.Value, but otherwise appears untouched.

This is using the version of NUint (2.6.3) and Obfuscar (2.0.0) from nuget. You'll need the NUnit binaries from http://nunit.org/index.php?p=download

Thanks
Darren

Created Unassigned: Unhandled Exception: System.ArgumentException: Illegal characters in path. [9]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

From within a command prompt, running:
Obfuscar.Console.exe /?

Causes the following output:
Obfuscar is available at http://obfuscar.codeplex.com.
(C) 2007-2014, Ryan Williams and other contributors.

Loading project...
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)

at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I
nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o
ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea
n useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean
bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share)
at Obfuscar.Obfuscator..ctor(String projfile)
at Obfuscar.Program.Main(String[] args)

And produces the following dialog to appear:
[Window Title]
Obfuscar Console Utility

[Main Instruction]
Obfuscar Console Utility has stopped working

[Content]
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

[Debug] [Close program]


I expected to see "usage" information for the console application command line parameters/options instead of a crash.

Thank you.

Created Unassigned: Obfuscator sometimes hangs when doing string hiding [10]

$
0
0
One of my DLLs was not being obfuscated. It hangs when doing string hiding. I debugged the code and reached these lines in AssemblyInfo.cs:

private void CleanPool (List<Node<TypeDefinition>> pool, List<TypeDefinition> result)
{
while (pool.Count > 0) {
var toRemoved = new List<Node<TypeDefinition>> ();
foreach (var node in pool) {
if (node.Parents.Count == 0) { // line 384

toRemoved.Add (node);
if (result.Contains (node.Definition))
continue;

result.Add (node.Definition);
}
}

foreach (var remove in toRemoved) {
pool.Remove (remove);
foreach (var child in remove.Children) {
if (result.Contains (child.Definition))
continue;

child.Parents.Remove (remove);
}
}
}
}

This code hangs forever when I a node has itself as parent and child. I couldn´t figure out why or when it occurs (not easy to track because types are already obfuscated at this point), all I know is that it happened to one of my DLLs. It stopped hanging after I change line 384:

if (node.Parents.Count == 0 || (node.Children.Count == 1 && node.Parents[0] == node.Children[0]))

Not very nice, however it appears to have solved my problem.

Created Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks


Commented Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks

Comments: I try to exlude types and also namespace but error remain...?

Commented Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A
Comments: 1. There is BUG in renaming properties. Property is renamed, but not registred in method names. For example: a/ interface xxi { int code {get;} } b/ interface is not obfuscated c/you have class ZZ :xxi {..}, d/ method get_code is obfuscated in class ZZ. It cause runtime error. Correct: RenameMethods () ... if (m.Status == ObfuscationStatus.Skipped) { // IMPORTANT: shortcut for event and property methods. // JIRKA:To avoid rename public property MethodGroup mgr = project.InheritMap.GetMethodGroup(methodKey); if (mgr == null || mgr.Name == null) RenameVirtualMethod(info, baseSigNames, sigNames, methodKey, method, m.StatusText); continue; } But there is still error in result BABBBA. 2. I changed code for rename property to hash property instead of generate it and it is ok.

Commented Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks

Comments: The error message simply asks you to make a "all or nothing" choice. You either obfuscate all the virtual methods in this group, or skip any of them completely. In your case, you should not skip this `Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory` method, but force it to be renamed. That's the quickest fix. Otherwise, you have to skip all methods listed.

Commented Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks

Comments: I want to obfuscate all the virtual methods in that group.. sorry what I have to do? thanks

Commented Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks

Comments: oh.. sorry <Var name="KeepPublicApi" value="false" /> <Var name="HidePrivateApi" value="true" /> ok now compile but dont run executable

Commented Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks

Comments: sorry the problem now is caliburn.micro signed assembly.. i try to solve..

Commented Unassigned: Inconsistent virtual method obfuscation state detected [11]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

this is errors output:

An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review
the following methods,
[Emule.GUI]Emule.GUI.Controls.MyTabControl.BaseCrudModel::EditViewModelFactor
y[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.AlertAgent.Model::EditViewModelFactory[2]->Skip
ped:HidePrivateApi option in configuration
[Emule.GUI]Emule.GUI.Features.Alerts.Model::EditViewModelFactory[2]->WillRena
me:A
[Emule.GUI]Emule.GUI.Features.Categorie.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.Fornitori.Model::EditViewModelFactory[2]->WillR
ename:A
[Emule.GUI]Emule.GUI.Features.LiquidazioneFatture.Model::EditViewModelFactory
[2]->WillRename:A
[Emule.GUI]Emule.GUI.Features.MainFatture.Model::EditViewModelFactory[2]->Wil
lRename:A
[Emule.GUI]Emule.GUI.Features.TipiCategoria.Model::EditViewModelFactory[2]->W
illRename:A

thanks

Comments: ..after give a keyfile now the error output is : Eccezione non gestita: System.FormatException: Formato della stringa di input non corretto. in System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) in System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) in System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info) in Mono.Cecil.AssemblyNameReference.Parse(String fullName) in ILSpy.BamlDecompiler.CecilTypeResolver.GetTypeByAssemblyQualifiedName(String name) in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.FormatPropertyDeclaration(PropertyDeclaration propertyDeclaration, Boolean withPrefix, Boolean useReading, Boolean checkType) in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadPropertyWithExtension() in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ProcessNext() in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadInternal() in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r) in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o) in System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) in Obfuscar.Obfuscator.GetXamlDocuments(AssemblyDefinition library) in Obfuscar.Obfuscator.RenameTypes() in Obfuscar.Obfuscator.RunRules() in Obfuscar.Program.Main(String[] args) Renaming: fields...parameters...properties...events...methods...types... thanks

Commented Unassigned: Obfuscated code behaves differently [7]

$
0
0
__EDIT:__ added a second piece of code that doesn't use explicitly implemented interface members

Consider the following code:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var t = new Two();
Console.WriteLine(t.Property1);
Console.WriteLine(t.Property2);
Console.WriteLine(t.Property3);
Console.WriteLine(((I1) t).Property1);
Console.WriteLine(((I3) t).Property1);
Console.WriteLine(((I3) t).Property3);
Console.WriteLine(((I3) t).Property2);

var o = new One();
Console.WriteLine(o.Property1);
Console.WriteLine(((I1) o).Property1);
}
}

interface I1 { double Property1 { get; } }
interface I2 { double Property2 { get; } }
interface I3 : I1, I2 { double Property3 { get; } }

class One : I1
{
public double Property1 { get { return 1; } }
public double Another1 { get { return -1; } }
double I1.Property1 { get { return 1.5; } }
}

class Two : One, I3
{
public double Property2 { get { return 2; } }
public double Property3 { get { return 3; } }
public double Another2 { get { return -2; } }
public double Another3 { get { return -3; } }
double I3.Property3 { get { return 3.5; } }
}

```

Executed before obfuscation the output is:

```
1 2 3 1.5 1.5 3.5 2 1 1.5
```

Obfuscated with just KeepPublicApi=false and HidePrivateApi=true using the latest code in the repo (79ee199979), and executing the obfuscated assembly, the output changes:

```
1 2 3 **2** **2** 3.5 2 1 1.5
```

I've been fighting with the sourcecode trying to understand and fix (hack) this but I still haven't been lucky...

__EDIT__: this piece of code is simpler and also fails:

```
class Program
{
[Obfuscation(Exclude = true)]
static void Main(string[] args)
{
var x = new ClassB();
Console.Write(x.PropB); // B
Console.Write(x.PropA); // A
Console.Write(((IB) x).PropB); // B
Console.Write(((IB) x).PropA); // A
Console.Write(((IA) x).PropA); // A
Console.Write(((ClassA) x).PropA); // A
Console.WriteLine();
}
}

public interface IA { string PropA { get; } }
public interface IB : IA { string PropB { get; } }

public class ClassA : IA { public string PropA { get { return "A"; } } }
public class ClassB : ClassA, IB { public string PropB { get { return "B"; } } }
```

Non-obfuscated output: BABAAA
Obfuscated output: BAB**BB**A
Comments: Property are renamed to same name for example: public interface IA { string PropA { get; } } public interface IB : IA { string PropB { get; } } TO: public interface IA { string A { get; } } public interface IB : IA { string A { get; } } Both property have same name. Quick corretion is to make counter for renaming global insted of for every class. In RenameProperites method() .. You have to replace this varibale to global for all "uniqueMemberNameIndex++" i.e. instance varibale for class Obfuscator.

Created Unassigned: Format string Exception: [12]

$
0
0

On Windows 8.1 I have this

Eccezione non gestita: System.FormatException: Formato della stringa di input non corretto.
in System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
in System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
in System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info)
in Mono.Cecil.AssemblyNameReference.Parse(String fullName)
in ILSpy.BamlDecompiler.CecilTypeResolver.GetTypeByAssemblyQualifiedName(String name)
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.FormatPropertyDeclaration(PropertyDeclaration propertyDeclaration, Boolean withPrefix, Boolean useReading, Boolean checkType)
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadPropertyWithExtension()
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ProcessNext()
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadInternal()
in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
in System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
in Obfuscar.Obfuscator.GetXamlDocuments(AssemblyDefinition library)
in Obfuscar.Obfuscator.RenameTypes()
in Obfuscar.Obfuscator.RunRules()
in Obfuscar.Program.Main(String[] args)

Anyone can help me?
thanks

Commented Unassigned: Format string Exception: [12]

$
0
0

On Windows 8.1 I have this

Eccezione non gestita: System.FormatException: Formato della stringa di input non corretto.
in System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
in System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
in System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo info)
in Mono.Cecil.AssemblyNameReference.Parse(String fullName)
in ILSpy.BamlDecompiler.CecilTypeResolver.GetTypeByAssemblyQualifiedName(String name)
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.FormatPropertyDeclaration(PropertyDeclaration propertyDeclaration, Boolean withPrefix, Boolean useReading, Boolean checkType)
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadPropertyWithExtension()
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ProcessNext()
in Ricciolo.StylesExplorer.MarkupReflection.XmlBamlReader.ReadInternal()
in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r)
in System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o)
in System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
in Obfuscar.Obfuscator.GetXamlDocuments(AssemblyDefinition library)
in Obfuscar.Obfuscator.RenameTypes()
in Obfuscar.Obfuscator.RunRules()
in Obfuscar.Program.Main(String[] args)

Anyone can help me?
thanks
Comments: It seems that you are obfuscating something with XAML. Note that only WPF is supported (best efforts) while Windows Store/Windows Phone apps are not supported at all. If your assembly is indeed WPF, you have to somehow share it with me so that I can do further analysis. You can reach me via support@lextm.com.

Commented Unassigned: Obfuscator sometimes hangs when doing string hiding [10]

$
0
0
One of my DLLs was not being obfuscated. It hangs when doing string hiding. I debugged the code and reached these lines in AssemblyInfo.cs:

private void CleanPool (List<Node<TypeDefinition>> pool, List<TypeDefinition> result)
{
while (pool.Count > 0) {
var toRemoved = new List<Node<TypeDefinition>> ();
foreach (var node in pool) {
if (node.Parents.Count == 0) { // line 384

toRemoved.Add (node);
if (result.Contains (node.Definition))
continue;

result.Add (node.Definition);
}
}

foreach (var remove in toRemoved) {
pool.Remove (remove);
foreach (var child in remove.Children) {
if (result.Contains (child.Definition))
continue;

child.Parents.Remove (remove);
}
}
}
}

This code hangs forever when I a node has itself as parent and child. I couldn´t figure out why or when it occurs (not easy to track because types are already obfuscated at this point), all I know is that it happened to one of my DLLs. It stopped hanging after I change line 384:

if (node.Parents.Count == 0 || (node.Children.Count == 1 && node.Parents[0] == node.Children[0]))

Not very nice, however it appears to have solved my problem.
Comments: The "a node has itself as parent and child" case is so rare, and I don't know what kind of code can lead the compiler to generate such assemblies. Thus, more information is required for further analysis.

Commented Unassigned: Unhandled Exception: System.ArgumentException: Illegal characters in path. [9]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1

From within a command prompt, running:
Obfuscar.Console.exe /?

Causes the following output:
Obfuscar is available at http://obfuscar.codeplex.com.
(C) 2007-2014, Ryan Williams and other contributors.

Loading project...
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)

at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I
nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o
ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea
n useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean
bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share)
at Obfuscar.Obfuscator..ctor(String projfile)
at Obfuscar.Program.Main(String[] args)

And produces the following dialog to appear:
[Window Title]
Obfuscar Console Utility

[Main Instruction]
Obfuscar Console Utility has stopped working

[Content]
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

[Debug] [Close program]


I expected to see "usage" information for the console application command line parameters/options instead of a crash.

Thank you.
Comments: This is desired, as /? is not yet supported. Will consider it in vNext. Thanks for the report.
Viewing all 249 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>