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

Closed 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: When obfuscate a PCL Library adds a reference to mscorlib 4.0 [17]

$
0
0
I, am obfuscating a very simple PCL, but when I try to use it in another PCL lib it says, "The primary reference "PuenteX.Seguridad" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile88". To resolve this problem, either remove the reference "PuenteX.Seguridad" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
When I inspect the original dll file it's do not have a reference to mscorlib 4 but after the obfucation process It's appears.

How can I solve this?

Thanks in advance.

Juan.
Comments: Which version of Obfuscar do you use? This issue has been fixed for a while, in two revisions, https://github.com/lextm/obfuscar/commit/2537571e5b6b3363b787e0e9460f75f5c5df6f00 https://github.com/lextm/obfuscar/commit/f8133fba13816e294cea95c43346059e62a3af12 Thus if you are using Obfuscar 2.0 RTW (rc7 bits), you should not experience this issue. If you cannot upgrade to that version, make sure you set `HideStrings` to `false`. That's a workaround to avoid mscorlib import.

Commented Unassigned: Inconsistent virtual method obfuscation state detected. [16]

$
0
0
Hi.

Thank you for Obfuscar 2.0 rc7.

Windows 7 x64 SP1
.NET 3.5 assembly

Configuration file:
```
<?xml version='1.0'?>
<Obfuscator>
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="true" />
<Var name="KeyFile" value="..\..\..\StrongName.snk" />

<Module file="..\..\..\MyAssembly\bin\Release\MyAssembly.exe" />
</Obfuscator>
```

Output:
```
...
Trying to resolve dependency: mscorlib, Version=2.0.0.0, Culture=neutral, Public
KeyToken=b77a5c561934e089
Done.
Renaming: fields...parameters...properties...events...methods...
An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review the
following methods,
[MyAssembly]♫? ::♫? ? ☻[0]->WillRename:A
[MyAssembly]♠ ::♫? ? ☻[0]->Skipped:special name
[MyAssembly]♫ ::♫? ? ☻[0]->WillRename:A
```

The assembly has been merged with ilmerge and it seems that there's a reference to another assembly that has already been obfuscated.

Any ideas?

Thank you.
Comments: Did you try to obfuscate an assembly that's obfuscated by another tool? The function names are so strange, and I am not sure if that's the cause of the problem. The second method was reported as a special named method based on the log, and such decision is mainly driven by Mono.Cecil. Without analyzing this assembly, the conclusion cannot be drawn. If you like, you can share it with me via support@lextm.com.

Commented Unassigned: Improvement for signing with PFX files & WPF problems [15]

$
0
0
Hi there! :)
Congratulations for your Project! :)
I am trying to obfuscate a WPF app and apart from the problems that I will mention at the end, I have an improvement that will allow signing with PFX files. Here is the improvement:

Project.cs, Line 118 (replaced old code with this and added a "PfxPsw" element in the configuration XML)

```

} else {
try
{
var keyFile = vars.GetValue("KeyFile", null);
var bytes = File.ReadAllBytes(keyFile);
var ext = Path.GetExtension(keyFile);
if (ext!=null && ext.ToLower() == ".pfx")
{
bytes = Pfx2Snk(bytes, vars.GetValue("PfxPsw", null));
}
else
{
}
keyvalue = CryptoConvert.FromCapiKeyBlob(bytes);
} catch (Exception ex) {
throw new ObfuscarException (String.Format ("Failure loading key file \"{0}\"", vars.GetValue ("KeyFile", null)), ex);
}
```
```
/// <summary>
/// Converts .pfx file to .snk file.
/// </summary>
/// <param name="pfxData">.pfx file data.</param>
/// <param name="pfxPassword">.pfx file password.</param>
/// <returns>.snk file data.</returns>
public static byte[] Pfx2Snk(byte[] pfxData, string pfxPassword)
{
// load .pfx
var cert = new X509Certificate2(pfxData, pfxPassword, X509KeyStorageFlags.Exportable);

// create .snk
var privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
return privateKey.ExportCspBlob(true);
}
```



Now to the WPF problems:
I use this XML configuration that should not change the assemblies at all:

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:\Users\Me\" />
<Var name="OutPath" value="$(InPath)\Obfuscar_Output" />

<Var name="MarkedOnly" value="true" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="false" />
<Var name="ReuseNames" value="false" />
<Var name="HideStrings" value="false" />
<Var name="OptimizedMethods" value="false" />
<Var name="RenameProperties" value="false" />
<Var name="RenameEvents" value="false" />
<Var name="XmlMapping" value="true" />
<Var name="PfxPsw" value="myPfxPassword" />
<Var name="KeyFile" value=".\Key.pfx" />

<Module file="$(InPath)\Dll1.dll" />
<Module file="$(InPath)\Dll2.dll" />
<Module file="$(InPath)\EXE1.exe" />
<Module file="$(InPath)\EXE2.exe" />
</Obfuscator>
```
However, when i start the WPF app, it crashes and in the event log I see this:

> Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at KEL_Building_Manager.App.Main()

Comments: BTW, there is a new revision available for testing, which contains many XAML related fixes, https://www.nuget.org/packages/Obfuscar/2.0.1-beta It might solve the crash, but I recommend you share the assemblies with me if possible for further analysis.

Closed 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: Cannot reproduce.

Commented Unassigned: Improvement for signing with PFX files & WPF problems [15]

$
0
0
Hi there! :)
Congratulations for your Project! :)
I am trying to obfuscate a WPF app and apart from the problems that I will mention at the end, I have an improvement that will allow signing with PFX files. Here is the improvement:

Project.cs, Line 118 (replaced old code with this and added a "PfxPsw" element in the configuration XML)

```

} else {
try
{
var keyFile = vars.GetValue("KeyFile", null);
var bytes = File.ReadAllBytes(keyFile);
var ext = Path.GetExtension(keyFile);
if (ext!=null && ext.ToLower() == ".pfx")
{
bytes = Pfx2Snk(bytes, vars.GetValue("PfxPsw", null));
}
else
{
}
keyvalue = CryptoConvert.FromCapiKeyBlob(bytes);
} catch (Exception ex) {
throw new ObfuscarException (String.Format ("Failure loading key file \"{0}\"", vars.GetValue ("KeyFile", null)), ex);
}
```
```
/// <summary>
/// Converts .pfx file to .snk file.
/// </summary>
/// <param name="pfxData">.pfx file data.</param>
/// <param name="pfxPassword">.pfx file password.</param>
/// <returns>.snk file data.</returns>
public static byte[] Pfx2Snk(byte[] pfxData, string pfxPassword)
{
// load .pfx
var cert = new X509Certificate2(pfxData, pfxPassword, X509KeyStorageFlags.Exportable);

// create .snk
var privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
return privateKey.ExportCspBlob(true);
}
```



Now to the WPF problems:
I use this XML configuration that should not change the assemblies at all:

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:\Users\Me\" />
<Var name="OutPath" value="$(InPath)\Obfuscar_Output" />

<Var name="MarkedOnly" value="true" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="false" />
<Var name="ReuseNames" value="false" />
<Var name="HideStrings" value="false" />
<Var name="OptimizedMethods" value="false" />
<Var name="RenameProperties" value="false" />
<Var name="RenameEvents" value="false" />
<Var name="XmlMapping" value="true" />
<Var name="PfxPsw" value="myPfxPassword" />
<Var name="KeyFile" value=".\Key.pfx" />

<Module file="$(InPath)\Dll1.dll" />
<Module file="$(InPath)\Dll2.dll" />
<Module file="$(InPath)\EXE1.exe" />
<Module file="$(InPath)\EXE2.exe" />
</Obfuscator>
```
However, when i start the WPF app, it crashes and in the event log I see this:

> Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at KEL_Building_Manager.App.Main()

Comments: Hello. Thanks. I will try the new code soon. And I will also try to reproduce the error in a simpler EXE, since the error appeared on a quite big project. Right now I am quite busy with some stuff, that's why it took me so long to respond.

Reopened Issue: Obfuscated WPF application crashed [1]

$
0
0
Class names are hard coded in XAML files for Window and so on. Such strings are embedded in the resource section of the assembly in BAML format.

Thus, obfuscation should correctly rename the items in BAML, or automatically skip any types that appear in BAML.

Edited Issue: Obfuscated WPF application crashed [1]

$
0
0
Class names are hard coded in XAML files for Window and so on. Such strings are embedded in the resource section of the assembly in BAML format.

Thus, obfuscation should correctly rename the items in BAML, or automatically skip any types that appear in BAML.

Commented Issue: Obfuscated WPF application crashed [1]

$
0
0
Class names are hard coded in XAML files for Window and so on. Such strings are embedded in the resource section of the assembly in BAML format.

Thus, obfuscation should correctly rename the items in BAML, or automatically skip any types that appear in BAML.
Comments: There are more types in BAML than I originally thought, so more effort is required before WPF is fully supported.

Created Unassigned: Exception during using of anonymous types [18]

$
0
0
Hi.
When i try to execute code like that:
```
var elems = LastResults.SelectMany(cl => new[]
{
new
{
refno = cl.Element1,
db = cl.DbElement1,
},
new
{
refno = cl.Element2,
db = cl.DbElement2,
}
});
```
in runtime i've got an exception:
```
System.ArgumentException: Метод ' . `2[System.String,<Another_Full_Class_Name>.DbElement]. ' не является средством доступа к свойству
в System.Linq.Expressions.Expression.GetProperty(MethodInfo mi)
в System.Linq.Expressions.Expression.Property(Expression expression, MethodInfo propertyAccessor)
в <Some_Full_Class_Name>.Engine. ()
```
Not obfuscated code works well. And after i've added name to the type, the code has executed well with obfuscar.

Commented Unassigned: Exception during using of anonymous types [18]

$
0
0
Hi.
When i try to execute code like that:
```
var elems = LastResults.SelectMany(cl => new[]
{
new
{
refno = cl.Element1,
db = cl.DbElement1,
},
new
{
refno = cl.Element2,
db = cl.DbElement2,
}
});
```
in runtime i've got an exception:
```
System.ArgumentException: Метод ' . `2[System.String,<Another_Full_Class_Name>.DbElement]. ' не является средством доступа к свойству
в System.Linq.Expressions.Expression.GetProperty(MethodInfo mi)
в System.Linq.Expressions.Expression.Property(Expression expression, MethodInfo propertyAccessor)
в <Some_Full_Class_Name>.Engine. ()
```
Not obfuscated code works well. And after i've added name to the type, the code has executed well with obfuscar.
Comments: Thanks for the sample code. I will do some analysis and get back to you.

Commented Unassigned: Improvement for signing with PFX files & WPF problems [15]

$
0
0
Hi there! :)
Congratulations for your Project! :)
I am trying to obfuscate a WPF app and apart from the problems that I will mention at the end, I have an improvement that will allow signing with PFX files. Here is the improvement:

Project.cs, Line 118 (replaced old code with this and added a "PfxPsw" element in the configuration XML)

```

} else {
try
{
var keyFile = vars.GetValue("KeyFile", null);
var bytes = File.ReadAllBytes(keyFile);
var ext = Path.GetExtension(keyFile);
if (ext!=null && ext.ToLower() == ".pfx")
{
bytes = Pfx2Snk(bytes, vars.GetValue("PfxPsw", null));
}
else
{
}
keyvalue = CryptoConvert.FromCapiKeyBlob(bytes);
} catch (Exception ex) {
throw new ObfuscarException (String.Format ("Failure loading key file \"{0}\"", vars.GetValue ("KeyFile", null)), ex);
}
```
```
/// <summary>
/// Converts .pfx file to .snk file.
/// </summary>
/// <param name="pfxData">.pfx file data.</param>
/// <param name="pfxPassword">.pfx file password.</param>
/// <returns>.snk file data.</returns>
public static byte[] Pfx2Snk(byte[] pfxData, string pfxPassword)
{
// load .pfx
var cert = new X509Certificate2(pfxData, pfxPassword, X509KeyStorageFlags.Exportable);

// create .snk
var privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
return privateKey.ExportCspBlob(true);
}
```



Now to the WPF problems:
I use this XML configuration that should not change the assemblies at all:

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:\Users\Me\" />
<Var name="OutPath" value="$(InPath)\Obfuscar_Output" />

<Var name="MarkedOnly" value="true" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="false" />
<Var name="ReuseNames" value="false" />
<Var name="HideStrings" value="false" />
<Var name="OptimizedMethods" value="false" />
<Var name="RenameProperties" value="false" />
<Var name="RenameEvents" value="false" />
<Var name="XmlMapping" value="true" />
<Var name="PfxPsw" value="myPfxPassword" />
<Var name="KeyFile" value=".\Key.pfx" />

<Module file="$(InPath)\Dll1.dll" />
<Module file="$(InPath)\Dll2.dll" />
<Module file="$(InPath)\EXE1.exe" />
<Module file="$(InPath)\EXE2.exe" />
</Obfuscator>
```
However, when i start the WPF app, it crashes and in the event log I see this:

> Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at KEL_Building_Manager.App.Main()

Comments: Hi. I have tried the latest version of the code (taken from here: https://obfuscar.codeplex.com/SourceControl/list/changesets?branch=master). On a simple WPF EXE everything seems OK, but on the EXE that I have tried above I get the same error: ``` Application: MyApp.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.Windows.Markup.XamlParseException Stack: at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri) at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri) at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean) at System.Windows.Application.LoadComponent(System.Object, System.Uri) at KEL_Building_Manager.App.Main() ``` It throws some handled exceptions about not finding "WPFToolkit.Extended.dll" when debugging, but I don't know: - Why it can't find it (it is next to the EXE - should I add this to the obfuscation too? I think it is signed). - If this is a big problem or if it is not important.

Commented Unassigned: Improvement for signing with PFX files & WPF problems [15]

$
0
0
Hi there! :)
Congratulations for your Project! :)
I am trying to obfuscate a WPF app and apart from the problems that I will mention at the end, I have an improvement that will allow signing with PFX files. Here is the improvement:

Project.cs, Line 118 (replaced old code with this and added a "PfxPsw" element in the configuration XML)

```

} else {
try
{
var keyFile = vars.GetValue("KeyFile", null);
var bytes = File.ReadAllBytes(keyFile);
var ext = Path.GetExtension(keyFile);
if (ext!=null && ext.ToLower() == ".pfx")
{
bytes = Pfx2Snk(bytes, vars.GetValue("PfxPsw", null));
}
else
{
}
keyvalue = CryptoConvert.FromCapiKeyBlob(bytes);
} catch (Exception ex) {
throw new ObfuscarException (String.Format ("Failure loading key file \"{0}\"", vars.GetValue ("KeyFile", null)), ex);
}
```
```
/// <summary>
/// Converts .pfx file to .snk file.
/// </summary>
/// <param name="pfxData">.pfx file data.</param>
/// <param name="pfxPassword">.pfx file password.</param>
/// <returns>.snk file data.</returns>
public static byte[] Pfx2Snk(byte[] pfxData, string pfxPassword)
{
// load .pfx
var cert = new X509Certificate2(pfxData, pfxPassword, X509KeyStorageFlags.Exportable);

// create .snk
var privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
return privateKey.ExportCspBlob(true);
}
```



Now to the WPF problems:
I use this XML configuration that should not change the assemblies at all:

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:\Users\Me\" />
<Var name="OutPath" value="$(InPath)\Obfuscar_Output" />

<Var name="MarkedOnly" value="true" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="false" />
<Var name="ReuseNames" value="false" />
<Var name="HideStrings" value="false" />
<Var name="OptimizedMethods" value="false" />
<Var name="RenameProperties" value="false" />
<Var name="RenameEvents" value="false" />
<Var name="XmlMapping" value="true" />
<Var name="PfxPsw" value="myPfxPassword" />
<Var name="KeyFile" value=".\Key.pfx" />

<Module file="$(InPath)\Dll1.dll" />
<Module file="$(InPath)\Dll2.dll" />
<Module file="$(InPath)\EXE1.exe" />
<Module file="$(InPath)\EXE2.exe" />
</Obfuscator>
```
However, when i start the WPF app, it crashes and in the event log I see this:

> Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at KEL_Building_Manager.App.Main()

Comments: Oups! I have just seen your link above. I have downloaded the wrong version. I will try again...

Commented Unassigned: Improvement for signing with PFX files & WPF problems [15]

$
0
0
Hi there! :)
Congratulations for your Project! :)
I am trying to obfuscate a WPF app and apart from the problems that I will mention at the end, I have an improvement that will allow signing with PFX files. Here is the improvement:

Project.cs, Line 118 (replaced old code with this and added a "PfxPsw" element in the configuration XML)

```

} else {
try
{
var keyFile = vars.GetValue("KeyFile", null);
var bytes = File.ReadAllBytes(keyFile);
var ext = Path.GetExtension(keyFile);
if (ext!=null && ext.ToLower() == ".pfx")
{
bytes = Pfx2Snk(bytes, vars.GetValue("PfxPsw", null));
}
else
{
}
keyvalue = CryptoConvert.FromCapiKeyBlob(bytes);
} catch (Exception ex) {
throw new ObfuscarException (String.Format ("Failure loading key file \"{0}\"", vars.GetValue ("KeyFile", null)), ex);
}
```
```
/// <summary>
/// Converts .pfx file to .snk file.
/// </summary>
/// <param name="pfxData">.pfx file data.</param>
/// <param name="pfxPassword">.pfx file password.</param>
/// <returns>.snk file data.</returns>
public static byte[] Pfx2Snk(byte[] pfxData, string pfxPassword)
{
// load .pfx
var cert = new X509Certificate2(pfxData, pfxPassword, X509KeyStorageFlags.Exportable);

// create .snk
var privateKey = (RSACryptoServiceProvider)cert.PrivateKey;
return privateKey.ExportCspBlob(true);
}
```



Now to the WPF problems:
I use this XML configuration that should not change the assemblies at all:

```
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:\Users\Me\" />
<Var name="OutPath" value="$(InPath)\Obfuscar_Output" />

<Var name="MarkedOnly" value="true" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="false" />
<Var name="ReuseNames" value="false" />
<Var name="HideStrings" value="false" />
<Var name="OptimizedMethods" value="false" />
<Var name="RenameProperties" value="false" />
<Var name="RenameEvents" value="false" />
<Var name="XmlMapping" value="true" />
<Var name="PfxPsw" value="myPfxPassword" />
<Var name="KeyFile" value=".\Key.pfx" />

<Module file="$(InPath)\Dll1.dll" />
<Module file="$(InPath)\Dll2.dll" />
<Module file="$(InPath)\EXE1.exe" />
<Module file="$(InPath)\EXE2.exe" />
</Obfuscator>
```
However, when i start the WPF app, it crashes and in the event log I see this:

> Exception Info: System.Windows.Markup.XamlParseException
Stack:
at System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
at System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
at System.Windows.Application.LoadComponent(System.Object, System.Uri)
at KEL_Building_Manager.App.Main()

Comments: If you can provide a code repository instead of NuGet package it would be nice. I don't like NuGet so much. :) Will this work? : http://obfuscar.googlecode.com/svn/trunk/ obfuscar-read-only

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

$
0
0
This is the error:

Renaming: fields...parameters...properties...events...methods...
An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review the
following methods,
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.IPlaneObject::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.LineSegment::get_
BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YOrientedRectangl
e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YRectangle::get_B
oundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.BusRepresentations/c::g
et_BoundingBox[0]->Skipped:special name
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.LabelCandidate::get_BoundingBo
x[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]or/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]uw/g::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]ki/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.DynamicObstacl
eDecomposition/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Circular.CircularLayouter/b::g
et_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]dg/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.RemoveOverlapsLayoutSt
age/b::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.ShuffleLayouter/a::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.EdgeRouter/e::
get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]kz/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Labeling.MISLabelingAlgorithm/
c::get_BoundingBox[0]->WillRename:A


In the obfuscar.xml file i'm using this variables:

<Var name="InPath" value="..\Dlls" />
<Var name="OutPath" value="..\Dlls" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="ReuseNames" value="false" />

Can you help me with this issue?

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

$
0
0
This is the error:

Renaming: fields...parameters...properties...events...methods...
An error occurred during processing:
Inconsistent virtual method obfuscation state detected. Abort. Please review the
following methods,
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.IPlaneObject::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.LineSegment::get_
BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YOrientedRectangl
e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Algorithms.Geometry.YRectangle::get_B
oundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.BusRepresentations/c::g
et_BoundingBox[0]->Skipped:special name
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.LabelCandidate::get_BoundingBo
x[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]or/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]uw/g::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]ki/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]r8/e::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.DynamicObstacl
eDecomposition/a::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Circular.CircularLayouter/b::g
et_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]dg/d::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.RemoveOverlapsLayoutSt
age/b::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Organic.ShuffleLayouter/a::get
_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Router.Polyline.EdgeRouter/e::
get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]kz/c::get_BoundingBox[0]->WillRename:A
[yWorks.yFilesNET.Algorithms]yWorks.yFiles.Layout.Labeling.MISLabelingAlgorithm/
c::get_BoundingBox[0]->WillRename:A


In the obfuscar.xml file i'm using this variables:

<Var name="InPath" value="..\Dlls" />
<Var name="OutPath" value="..\Dlls" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="ReuseNames" value="false" />

Can you help me with this issue?
Comments: If you can share the assembly via support@lextm.com I can do some debugging on it. Generally speaking, you can see from line 656 that only in rare cases this skip line is used, https://github.com/lextm/obfuscar/blob/master/Obfuscar/AssemblyInfo.cs

Created Unassigned: Usage of environment variables in config xml [20]

$
0
0
I would like to specify "InPath" and "OutPath" using environment variables, e.g.:

___<Var name="InPath" value="%MYDEVPATH%\Project\bin\Release" />___

The reason is that this config file is in SVN and then should be used by people having their projects locally in different locations where the environment variable points to.

This could easily be done by adding these two lines in Obfuscar.Settings Constructor to expand environment variable:

```
public Settings (Variables vars)
{
inPath = vars.GetValue ("InPath", ".");
inPath = Environment.ExpandEnvironmentVariables(inPath); // <==
outPath = vars.GetValue ("OutPath", ".");
outPath = Environment.ExpandEnvironmentVariables(outPath); // <==
```
Could someone please review this and make a release if appropriate? Thanks!

Cheers,
Matmok

Commented Unassigned: When obfuscate a PCL Library adds a reference to mscorlib 4.0 [17]

$
0
0
I, am obfuscating a very simple PCL, but when I try to use it in another PCL lib it says, "The primary reference "PuenteX.Seguridad" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile88". To resolve this problem, either remove the reference "PuenteX.Seguridad" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
When I inspect the original dll file it's do not have a reference to mscorlib 4 but after the obfucation process It's appears.

How can I solve this?

Thanks in advance.

Juan.
Comments: This issue was caused by importing `SuppressIldasmAttribute` attribute. So a quick workaround is to set `SupressIldasm` option in XML file to `false`. Fixed in latest revision in master.

Closed Unassigned: When obfuscate a PCL Library adds a reference to mscorlib 4.0 [17]

$
0
0
I, am obfuscating a very simple PCL, but when I try to use it in another PCL lib it says, "The primary reference "PuenteX.Seguridad" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile88". To resolve this problem, either remove the reference "PuenteX.Seguridad" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
When I inspect the original dll file it's do not have a reference to mscorlib 4 but after the obfucation process It's appears.

How can I solve this?

Thanks in advance.

Juan.

Commented Unassigned: Usage of environment variables in config xml [20]

$
0
0
I would like to specify "InPath" and "OutPath" using environment variables, e.g.:

___<Var name="InPath" value="%MYDEVPATH%\Project\bin\Release" />___

The reason is that this config file is in SVN and then should be used by people having their projects locally in different locations where the environment variable points to.

This could easily be done by adding these two lines in Obfuscar.Settings Constructor to expand environment variable:

```
public Settings (Variables vars)
{
inPath = vars.GetValue ("InPath", ".");
inPath = Environment.ExpandEnvironmentVariables(inPath); // <==
outPath = vars.GetValue ("OutPath", ".");
outPath = Environment.ExpandEnvironmentVariables(outPath); // <==
```
Could someone please review this and make a release if appropriate? Thanks!

Cheers,
Matmok
Comments: Fixed in latest revision in master. Environment variables are supported in `InPath`, `OutPath`, `LogFile`, and `KeyFile` options.
Viewing all 249 articles
Browse latest View live


Latest Images

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