return To index


.NET Source Code Cross-Infection
--------------------------------
by alcopaul/brigada ocho
May 16, 2011


Intro
-----

I've created the 3rd C# source code infector, Vitamin C#, released in doomriderz #1 under linuspauling
handle (actually the first C# source code infector, was just being sarcastic) and the first VB.NET
source code infector, which is released in this zine. What's the next step?

Infect both types?
------------------

Yes! A source code infector for both C# and VB.NET files is possible. First it has to have in its body
both the C# and VB.NET version of itself. If ran as a C# source code and it finds a VB.NET source code
it should extract and write its stored VB.NET source from itself to the target. Vise versa.

How To
------

Source Structure (C# mode)

-------------------------------------------------------------------------------------------------------------

[Head in C#][encoded Head in VB.NET/encoded Tail in VB.NET/encoded Head in C#/encoded Tail in C#][Tail in C#]

-------------------------------------------------------------------------------------------------------------

Head in C# usually contains the beginning part of the file + "string database = \""
Middle part is "encoded Head in VB.NET/encoded Tail in VB.NET/encoded Head in C#/encoded Tail in C#"
Tail in C# contains "\"" and the methods that will recreate the source and facilitate infecting other files.

if target file is .vb, recreate the source code by decode(database[0])+database+decode(database[1]) and infect.
if target file is .cs, recreate the source code by decode(database[2])+database+decode(database[3]) and infect.

Source Structure (VB.NET mode)

--------------------------------------------------------------------------------------------------------------------

[Head in VB.NET][encoded Head in VB.NET/encoded Tail in VB.NET/encoded Head in C#/encoded Tail in C#][Tail in VB.NET]

--------------------------------------------------------------------------------------------------------------------

Head in VB.NET usually contains the beginning part of the file + "Dim database as String = """
Middle part is "encoded Head in VB.NET/encoded Tail in VB.NET/encoded Head in C#/encoded Tail in C#"
Tail in VB.NET contains """" and the methods that will recreate the source and facilitate infecting other files.

if target file is .vb, recreate the source code by decode(database[0])+database+decode(database[1]) and infect.
if target file is .cs, recreate the source code by decode(database[2])+database+decode(database[3]) and infect.

Cross-Infector Sample
---------------------

A demo code is included with this file and can be found in the Sources Section.

Conclusion
----------

It's done. What's next? Find out, tomorrow.