I can't really explain the configuration quickly...there's a lot to it ;)
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.
There's an example of a minimal configuration in the release, see
http://obfuscar.googlecode.com/svn/trunk/Examples/BasicExample/obfuscar.xml
To build and obfuscate the BasicExample, get the source, change to the
BasicExample path, and run "msbuild release.proj". It will build a
solution, and obfuscate the output.
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...From the example, after defining InPath:
<Var name="InPath" value=".\Obfuscator_Input" />
It can be used in another location:
<Module file="$(InPath)\BasicExampleExe.exe" />
In addition to being like macros, there are a few special variables
that have 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 (".").
For each assembly to be obfuscated, there must be a Module element.
Assemblies referenced by an assembly specified by a Module element
must be resolveable, either via Cecil's regular resolve process, or
they must be present in the path specified by InPath (currently,
Obfuscar will crash if it can't find them...it really needs to be made
more polite about it).
Though additional assemblies may be loaded for examination, only the
specified assemblies will be obfuscated.
It is possible to include additional elements within the Module
elements to skip types (the SkipTypes element), methods (the
SkipMethod element), and fields (SkipField, of course).
The SkipType element specifies the name of the type to skip, including
the full namespace.
The SkipMethod element specifies the name of the type containing the
method, a protection specifier (currently ignored, but will eventually
be used for additional filtering), and a name or regex to match the
method.
The SkipField element specifies the name of the type containing the
field, a protection specifier (again, currently ignored, but will
eventually be used for additional filtering), and a name or regex to
match the field.
A more complete example:
<Module file="$(InPath)\AssemblyX.exe">
<!-- 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=".*" />
</Module>
To prevent any properties from being obfuscated, set the
RenameProperties variable to "false" (it's an xsd boolean). To
prevent specific properties from being renamed, skip the underlying
methods, get_XXX and set_XXX (you can use a regex like
"(get|set)_XXX").
To prevent any events from being obfuscated, set the RenameEvents
variable to "false" (it's also xsd boolean). To prevent specific
events from being renamed, skip the underlying methods, add_XXX and
remove_XXX (you can use a regex like "(add|remove)_XXX").
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, it's 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, it's methods, fields, resources, etc.:
[Obfuscate]
class X { }
Sorry for cluttering the mono-cecil group...I've created one
specifically for Obfuscar, http://groups.google.com/group/obfuscar or
obfu...@googlegroups.com. I'll also put up the above on the Obfuscar
site at http://code.google.com/p/obfuscar/, in the wiki.
On 5/4/07, obiwanjacobi <obiwan...@hotmail.com> wrote:
>
> Does Obfuscar generate a mapping file? Most obfuscators generate a
> file that documents what (original) names were replaced for which
> scrambled names.
>
> Could you also explain (in short) the configuration xml the Obfuscar
> seems to need?
>
> Thanx,
> Marc
>
>
> >
>