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

Commented 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
Comments: I cannot reproduce your case. Note that in the package you attached, we can see that in Mapping.txt that only ObfuscarTest.MyClass was touched. ``` Renamed Types: [ObfuscarTest]ObfuscarTest.MyClass -> [ObfuscarTest]A.A { [ObfuscarTest]ObfuscarTest.MyClass::get_Value[0]( ) -> A [ObfuscarTest]ObfuscarTest.MyClass::.ctor[0]( ) skipped: special name System.String [ObfuscarTest]System.String ObfuscarTest.MyClass::Value -> dropped } Skipped Types: Renamed Resources: Skipped Resources: ``` However, on my machine I got ``` Renamed Types: [ObfuscarTest]ObfuscarTest.MyClass -> [ObfuscarTest]A.A { [ObfuscarTest]ObfuscarTest.MyClass::get_Value[0]( ) -> A [ObfuscarTest]ObfuscarTest.MyClass::.ctor[0]( ) skipped: special name System.String [ObfuscarTest]System.String ObfuscarTest.MyClass::Value -> dropped } Skipped Types: [ObfuscarTest.Tests]ObfuscarTest.Tests.TestClass skipped: namespace rule in configuration { [ObfuscarTest.Tests]ObfuscarTest.Tests.TestClass::GetStaticPropertyValue[0]( ) skipped: type rule in configuration [ObfuscarTest.Tests]ObfuscarTest.Tests.TestClass::.ctor[0]( ) skipped: special name } Renamed Resources: Skipped Resources: ``` I can only guess that on your machine for some other reason ObfuscarTest.Tests.dll was never processed, and that's why it still refers to the unobfuscated method name.

Closed 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

Commented 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
Comments: It was processed, like I said if you opened ObfuscarTest.Tests.dll after it has been processed by Obfuscar in ILSpy you can see the call to MyClass.Value has been changed to A.A(), so I'm not sure about that mapping.txt file. Rebuilding and testing the project now I get exactly the same output in mapping.txt that you've listed, but the dll is still unable to be loaded in NUnit. Were you able to open your compiled ObfuscarTest.Tests.dll in NUnit 2.6.3 as part of your testing?

Created Unassigned: Nested Classes [13]

$
0
0
With the usual settings (KeepPublicApi = true, HidePrivateApi = true), the nested classes are been renamed, even they're public.

As a workaround, I'm using the ObfuscationAttribute, to explicitly exclude them.

Created Unassigned: BinarySerialization and Auto-implemented Properties [14]

$
0
0
I have the following class with some auto-implemented properties (some properties were omitted).

[Serializable]
public class SessionInfo
{
public string UserLogin { get; set; }
public bool MustChangePassword { get; set; }
public DateTime PasswordExpirationDate { get; set; }
}

After the obfuscation, the automatic fields are renamed like this:

[Serializable]
public class SessionInfo
{
[CompilerGenerated] private string A;
[CompilerGenerated] private bool A;
[CompilerGenerated] private DateTime A;
public string UserLogin { get; set; }
public bool MustChangePassword { get; set; }
public DateTime PasswordExpirationDate { get; set; }
}

This is causing that the BinarySerialization fails while deserialization. Apparently, it can't determinate the right field because all are named the same.

This is the exception thrown:
System.ArgumentException. The object of type 'System.DateTime' cannot be converted to type 'System.Boolean'.

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: Close this item. The XAML issue is moved to a separate item, https://obfuscar.codeplex.com/workitem/12

Closed 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: BinarySerialization and Auto-implemented Properties [14]

$
0
0
I have the following class with some auto-implemented properties (some properties were omitted).

[Serializable]
public class SessionInfo
{
public string UserLogin { get; set; }
public bool MustChangePassword { get; set; }
public DateTime PasswordExpirationDate { get; set; }
}

After the obfuscation, the automatic fields are renamed like this:

[Serializable]
public class SessionInfo
{
[CompilerGenerated] private string A;
[CompilerGenerated] private bool A;
[CompilerGenerated] private DateTime A;
public string UserLogin { get; set; }
public bool MustChangePassword { get; set; }
public DateTime PasswordExpirationDate { get; set; }
}

This is causing that the BinarySerialization fails while deserialization. Apparently, it can't determinate the right field because all are named the same.

This is the exception thrown:
System.ArgumentException. The object of type 'System.DateTime' cannot be converted to type 'System.Boolean'.

Comments: This is a known issue. Serialization is a process that heavily relies on private member's names. Thus, please skip obfuscation on classes that will be touched in serialization.

Closed Unassigned: BinarySerialization and Auto-implemented Properties [14]

$
0
0
I have the following class with some auto-implemented properties (some properties were omitted).

[Serializable]
public class SessionInfo
{
public string UserLogin { get; set; }
public bool MustChangePassword { get; set; }
public DateTime PasswordExpirationDate { get; set; }
}

After the obfuscation, the automatic fields are renamed like this:

[Serializable]
public class SessionInfo
{
[CompilerGenerated] private string A;
[CompilerGenerated] private bool A;
[CompilerGenerated] private DateTime A;
public string UserLogin { get; set; }
public bool MustChangePassword { get; set; }
public DateTime PasswordExpirationDate { get; set; }
}

This is causing that the BinarySerialization fails while deserialization. Apparently, it can't determinate the right field because all are named the same.

This is the exception thrown:
System.ArgumentException. The object of type 'System.DateTime' cannot be converted to type 'System.Boolean'.

Commented Unassigned: Nested Classes [13]

$
0
0
With the usual settings (KeepPublicApi = true, HidePrivateApi = true), the nested classes are been renamed, even they're public.

As a workaround, I'm using the ObfuscationAttribute, to explicitly exclude them.
Comments: Thanks for the report. I can reproduce it with a test case now. Will investigate and fix it soon.

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

$
0
0
Hi there! :)
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 asseblies 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()

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

$
0
0
Hi there! :)
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 asseblies 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()

Edited 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 asseblies 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()

Edited 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()

Closed Unassigned: Nested Classes [13]

$
0
0
With the usual settings (KeepPublicApi = true, HidePrivateApi = true), the nested classes are been renamed, even they're public.

As a workaround, I'm using the ObfuscationAttribute, to explicitly exclude them.
Comments: Fixed in master.

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: Thanks. The PFX support is optional. You should import the PFX file using sn.exe in .NET SDK, (sn -i) http://msdn.microsoft.com/en-us/library/k5b5tt23(v=vs.110).aspx Then in Obfuscar configuration you can specify `KeyContainer` option to let Obfuscar use the key container to sign the assemblies. The password should never live in Obfuscar configuration file. About the XAML issue, can you share the binaries with me via support@lextm.com?

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: This has been identified as a bug in ILSpy. Will investigate further to see how to fix it.

Created 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.

Created 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: 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: This is a bug in ILSpy BAML reader, and I sent a pull request to ILSpy with the fix. Obfuscar 2.0.1 beta contains the fix, https://www.nuget.org/packages/Obfuscar/2.0.1-beta
Viewing all 249 articles
Browse latest View live


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