Virus Programming in C/C++

Basics about virus programing in C/C++ and some example

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 17548 Views - Last Post: 08 August 2009 - 06:05 AM Rate Topic: -----

#1 kishor25feb  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 18-March 08

Virus Programming in C/C++

Post icon  Posted 18 March 2008 - 01:42 AM

I want to know about virus programing in C/C++ and some example with
Is This A Good Question/Topic? 1
  • +

Replies To: Virus Programming in C/C++

#2 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1385
  • View blog
  • Posts: 10,962
  • Joined: 06-February 08

Re: Virus Programming in C/C++

Posted 18 March 2008 - 03:02 AM

You might find this link useful.
Was This Post Helpful? 0
  • +
  • -

#3 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3120
  • View blog
  • Posts: 19,163
  • Joined: 14-September 07

Re: Virus Programming in C/C++

Posted 18 March 2008 - 04:51 AM

in before lock :)
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Virus Programming in C/C++

Posted 18 March 2008 - 05:20 AM

Virus programming often leads to illegal activities, and as such, the site cannot provide or promote any code that would be used in a virus.

I'll leave the thread open for the moment, to see if the user can provide an acceptable explanation as to why he/she may want virus code. We have no problem with the discussion of viruses, but I will delete any code that may be used in the creation of a software virus.
Was This Post Helpful? 0
  • +
  • -

#5 red_4900  Icon User is offline

  • Code T(h)inkers
  • member icon

Reputation: 21
  • View blog
  • Posts: 1,120
  • Joined: 22-February 08

Re: Virus Programming in C/C++

Posted 18 March 2008 - 05:57 AM

Quote

If you know the enemy
and know yourself, you need not fear the result of a
hundred battles.


thats the only reason I can think of. he want to create an antivirus program and because of that, he needs to 'know' the enemy(virus) first :P
Was This Post Helpful? 0
  • +
  • -

#6 zombie_chan51  Icon User is offline

  • D.I.C Regular

Reputation: 7
  • View blog
  • Posts: 327
  • Joined: 16-March 08

Re: Virus Programming in C/C++

Posted 18 March 2008 - 10:23 AM

the best way to learn how to make virus is to study the ones that have been made. Though i only suggest making viruses if you were making one as a prank. Also most viruses i found were coded in Visual Basic, so that might be a plus.

admin edit: link to virus source code site removed - Amadeus

This post has been edited by Amadeus: 18 March 2008 - 10:25 AM

Was This Post Helpful? 0
  • +
  • -

#7 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Re: Virus Programming in C/C++

Posted 18 March 2008 - 10:30 AM

If you have to ask how to make a virus, then it is beyond your ability, and you shouldn't be making one anyways.
Was This Post Helpful? 1

#8 spearfish  Icon User is offline

  • Monkey in Training
  • member icon

Reputation: 10
  • View blog
  • Posts: 746
  • Joined: 10-March 08

Re: Virus Programming in C/C++

Posted 18 March 2008 - 10:32 AM

Here comes the lock!
Was This Post Helpful? 0
  • +
  • -

#9 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Virus Programming in C/C++

Posted 18 March 2008 - 11:50 AM

Actually virus programming is quite interesting. Because of its nature it can be a little difficult to find information on the topic. There are a number of books that go into detail -- but you will find most of them out of date.

I find that searching for things like "programming viruses" does not turn up much information, but if you take it from the other side and search the security sites you can find quite in-depth discussions (including source code).
Was This Post Helpful? 0
  • +
  • -

#10 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Virus Programming in C/C++

Posted 19 March 2008 - 09:47 AM

Quote

Actually virus programming is quite interesting. Because of its nature it can be a little difficult to find information on the topic.

Very true.

Let me also state that C with Assembly Inserts can make viruses more 'interesting' ;)
Was This Post Helpful? 0
  • +
  • -

#11 nirvanarupali  Icon User is offline

  • D.I.C Stomach
  • member icon

Reputation: 13
  • View blog
  • Posts: 1,119
  • Joined: 01-August 07

Re: Virus Programming in C/C++

Posted 07 April 2008 - 09:24 PM

If you are an experienced coder most especially in Windows API. Writing a virus is not difficult. For me, C/C++ is one of the best languages. :)
Was This Post Helpful? 0
  • +
  • -

#12 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5388
  • View blog
  • Posts: 27,384
  • Joined: 10-May 07

Re: Virus Programming in C/C++

Posted 07 April 2008 - 09:30 PM

View Postred_4900, on 18 Mar, 2008 - 08:57 AM, said:

Quote

If you know the enemy
and know yourself, you need not fear the result of a
hundred battles.


thats the only reason I can think of. he want to create an antivirus program and because of that, he needs to 'know' the enemy(virus) first :P

Actually, I would disagree with this comment. For two reasons:

1.) What would writing viruses have to teach you about how an Anti Virus works? Since Anti Viruses work with the binary executable, the how & why of virus code is irrelevant.

2.) Anti Viruses don't really care what a Virus does (or how it works). An Anti Virus simply hooks the Windows API Messenger, & simply scans for known "Strings". That's why "new" viruses that are simply re-writes of existing code are considered new breakouts & get those funky .a .b & what have you extensions (that I've seen with McAfee anyhow).
Was This Post Helpful? 0
  • +
  • -

#13 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Virus Programming in C/C++

Posted 08 April 2008 - 07:32 AM

There are lots of reasons to learn about virus programming. First of all there is a great benefit to understand what is going on. Sometimes Anti-Virus software is not enough because as No2 points out they tend to look for known viruses. But they can also check for some known behaviors (like writing info to MBR).

There is also a mindset that goes along with virus programming. When we develop software we tend to think about how to solve problems and meet requirements etc. and we try to make our systems expandable and manageable. And we tend to write in security holes in the process. We didn't mean to, but our mind set was focused on how to make things work, not "how can I use this to take advantage?"

There are many viruses which exploit very innocuous looking features.

side note: I have a friend who is amazing at building decks for Magic the Gathering. The reason is that he can see the loop holes. He takes seemingly harmless cards and sees how they can be leveraged with other cards to create killer combinations. -- I have always said that he could make a great deal of money in computer security (wearing either the black or white hat).

So learning to critique your software from a virus programmers point of view helps you see the potential exploits (which you may not be able to avoid, but at least you can know take steps to make it harder to exploit).

And then there are times when this point of view can be VERY helpful. We tend to use things roughly as they were designed to be used, but sometimes some of the most elegant solutions are actually an unintended use of a software feature. For example meta-template-programming in C++ was *discovered* not designed. Its an exploit of preexisting system.

Many many inventions are actually just creative uses for existing systems. Virus programming is all about this type of thinking: Using systems/protocals/APIs/Software features etc to achieve unintended results.
Was This Post Helpful? 0
  • +
  • -

#14 UG Cyber  Icon User is offline

  • D.I.C Addict

Reputation: 32
  • View blog
  • Posts: 556
  • Joined: 24-July 08

Re: Virus Programming in C/C++

Posted 29 July 2008 - 06:57 PM

I know that this topic is dead but this is for others that come across this.
I have written viruses before and its not hard at all. If you want to learn to write one then google is your best friend but if you want to learn how they "Think" then this is for you!!

Virus want to survive and be a pain in the A**. In order for them to survive they have to block off certain programs and become silent. They block others by the title of the window so for instance Windows Task Manager is the title of Task manager, That is what it looks for.
The best way to stop a new virus that i have found is to use the Taskkill function in ms dos prompt.

if you compile a code like this it will allow you to use Command Prompt

#include <iostream>

using namespace std;
void main(void)  //some rather prude compilers wont allow void for a function type
{
   start:;
   char Input[100];
   cout << "Command:  ";
   cin >> Input;
   system(Input);
   goto start;
}



Hope this helps someone
Was This Post Helpful? 0
  • +
  • -

#15 perfectly.insane  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 70
  • View blog
  • Posts: 644
  • Joined: 22-March 08

Re: Virus Programming in C/C++

Posted 29 July 2008 - 07:07 PM

I don't think "true" virii impacts as many these days as it used to... virii meaning a program that spreads itself by modifying other programs (in the literal sense). There have been quite a few programs that spread themselves via. email, which is sort of an automated social engineering technique. Yes, sometimes these programs actually exploit flawed software to do such. I'm more worried about rootkits than actually being infected with a virus these days.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2