Tuesday, November 30, 2010

Belajar Jaringan pada Java

saya sedang belajar jaringan pada java,
pada Jaringan java ada yang akan menjadi server, dan ada yang akan menjadi client.

ini source code untuk server :

package server;
import java.net.*;
import java.io.*;
public class servertyang {
    public static void main(String [] args) {
        ServerSocket server = null;
        Socket client;
        try {
            server = new ServerSocket(31);
            //1234 is an unused port number
        } catch (IOException ie) {
            System.out.println("Cannot open socket.");
            System.exit(1);
        }
        while(true) {
            try {
                client = server.accept();
                OutputStream clientOut = client.getOutputStream();
                PrintWriter pw = new PrintWriter(clientOut, true);
                InputStream clientIn = client.getInputStream();
                BufferedReader br = new BufferedReader(new InputStreamReader(clientIn));
               
                String in = br.readLine();
                if(in.equals("Halo"))pw.println("apa kabar?");
                if(in.equals("Boleh Kenalan?")) pw.println("Boleh donk, aku tyang, kamu siapa?");
                if(in.equals("Saya Jawi Salam kenal.")) pw.println("salam kenal juga.");
               
               
            } catch (IOException ie) {
            }
        }
    }
}


dan yang ini untuk client :

package client;
import java.io.*;
import java.net.*;
public class clienttyang {
    public static void main(String args[]) {
        try {//Socket client = new Socket("133.0.0.1", 1234);
            Socket client = new Socket("192.168.78.136",31);
            InputStream clientIn = client.getInputStream();
            OutputStream clientOut = client.getOutputStream();
            PrintWriter pw = new PrintWriter(clientOut, true);
            BufferedReader br = new BufferedReader(new InputStreamReader(clientIn));
            BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
            System.out.println("Type a message for the server: ");
            pw.println(stdIn.readLine());
            System.out.println("Server message: ");
            System.out.println(br.readLine());
           
            pw.close();
            br.close();
            client.close();
           
            } catch (ConnectException ce) {
            System.out.println("Cannot connect to the server.");
            } catch (IOException ie) {
            System.out.println("I/O Error.");{
           
        }
    }
}
}


kedua source code di atas merupakan source code sederhana untuk jaringan pada java. kata dosen saya, source code itu bisa dikembangkan menjadi aplikasi chat.

menyembunyikan Pesan dalam file

         Apakah kamu pernah terpikirkan bahwa sebuah gambar JPG dapat digunakan untuk menyembunyikan pesan rahasia untuk dikirimkan?
         Jawabannya tentu saja ada. caranya dapat menggunakan STEGANOGRAFI. Steganografi adalah seni dan ilmu menulis pesan tersembunyi atau menyembunyikan pesan dengan suatu cara sehingga selain si pengirim dan si penerima, tidak ada seorangpun yang mengetahui atau menyadari bahwa ada suatu pesan rahasia (kata wikipedia). disini saya garis bawahi tentang mengetahui atau menyadari, karena kriptografi memang ditujukan untuk menyembunyikan pesan bukan mengengkripsinya.
          Bagaimana cara menyembunyikannya?
          Caranya sederhana, cukup dengan menumpangkan pesan pada suatu file. pada zaman digital seperti sekarang, semuanya serba digital, dari gambar, musik,video,pesan,data,dsb. Hal ini dapat dimanfaatkan untuk menumpangkan pesan pada suatu file. Namun, cara menumpangkan pesan tersebut akan tergantung dari file yang digunakan sebagai pembawa(carrier).
          Menyembunyikan file pada Gambar.
          Gambar digital sebenarnya adalah sebuah file 24-bit color. Artinya setiap pixel dari sebuah gambar akan terdiri dari 24-bit color yang terdiri dari 8-bit warna merah(Red), 8-bit warna hijau(Green), dan 8-bit warna biru(Blue). 8-bit berarti xxxxxxxx dimana x adalah 0 atau 1 (bilangan biner), dengan begitu dalam setiap 8-bit dapat memiliki 2^8 (256) kombinasi warna, atau dalam satu pixel 24-bit memiliki 2^24 warna. Dengan struktur file seperti ini, terdapat suatu algoritma Steganografi yang dapat digunakan untuk menyembunyikan dalam file gambar tersebut tanpa ada kecurigaan yaitu dengan metode Least Significant Bits (LSB) insertion atau sebut saja metode penyisipan LSB.
          Metode Least Significant Bits (LSB) insertion.
          Pada 8-bit setiap pixel akan digunakan bit yang paling belakang contoh : 01011011 yang dicetak tebal adalah LSB. LSb ini yang akan menggantikan setiap bit dari pesan yang akan disembunyikan. Sebagai ilustrasi, akan disembunyikan pesan berupa huruf 'C' dimana dalam kode ASCII bernilai 67 (1000011). Pesan tersebut akan disembunyikan dalam sebuah gambar dengan 3 pixel rangkaian bit
10100011.10010100.01100010 00100101.10101000.10001001 1010010.01011010.10010110
          Karena ASCII hanya 7-bit kita akan menambahkan 2 buah bit 0 di depannya. sehingga 'C' menjadi 001 000 011. Masing-masing dari setiap 9 bit tersebut akan di subtitusikan pada bit terakhir setiap 8-bit, sehingga rangkaian bit dari 3 pixel yang tadi digunakan menjadi
10100010.10010100.01100011 00100100.10101000.10001000 1010010.01011011.10010111
        Dengan demikian sulit bagi seseorang untuk menyadari bahwa pada gambar tersebut memiliki sebuah pesan.
        Namun, metode LSB ini memiliki beberapa kelemahan. Pertama, dengan berubahnya bit terakhir dari setiap 8-bit akan menyebabkan gambar menjadi tidak wajar (disebut stego image).

Mungkin sampai disini dulu,kalo ada waktu disambung lagi.

Sunday, July 11, 2010

Amankan file dalam hosting

Saat saya pertama kali menggunakan jasa file hosting untuk menyimpan file-file saya,saya tidak menyadari betapa pentingnya file index.html atau index.php
saat it dengan bodohnya saya menghapus file tersebut. Kemudian beberapa waktu kemudian,saya membuka domain saya tempat hosting itu, dan ternyata yang ditampilkan oleh browser adalah isi semua folder saya. Celaka,kalo ada yang buka,isinya file-file pribadi yang sangat privat.
Mengamankan isi folder dalam hosting dapat dilakukan dengan cara yang sangat sederhana,yaitu membuat file index.php index.html atau index.htm isinya terserah anda,ini akan berguna jika ada seorang yang tidak maupun sengaja menuliskan url halaman anda secara tidak lengkap.
Selamat mencoba.

Monday, June 14, 2010

Secret Message on FaceBook

An Secret information should be sent in fast, no one could be read it, and hide in public service. Nowadays, most people using facebook, very simply to sent a message in facebook, but everyone can read the message.
Some times, we must have a privacy to transmite our message to our friends. Now, I will share how to sent a secret message with facebook wall post safely.

As we know, every file could be edited with notepad, so do the PNG file. we can edited the code of PNG file in notepad,but sometimes, the file will be couldn't viewed if we edit it with notepad. I just can suggest for useeing DOS Promt to insert our secret message in PNG file, The PNG file won't be error again.

After you insert your message in PNG file, you can place thet PNG file on Wall Post,so not everyones knoes if you place a secret message. Than,make an agreement with your friend if you and he/she will tranfer information in the PNG file. You and your friend can read the message with open the PNG file with notepad.

Message  +   PNG file   =   PNG file(secret message)

How to Inserting message in PNG file

  • Select the PNG file will you use ( use a familliar picture) example :


      • Create a TXT file which include your messase(save in same directory with your PNG file)

          • Open the directory of your PNG file and TXT file with DOS Promt
          I save my file in D:>hack/
          open D:>hack/ in dos

              • write : type your_txt_file.txt >> your_png_file.png  : enter
               my file is dunia.txt  and gambar.png

                  • try to open your PNG file with notepad after thet.
                    the result of this procces is :

                    look at the buttom of the file, you will look your message there..


                    note : use special caracter on the message begin and on the end of message.
                    Example : use {" and "}
                    {" Secret Message "}

                    then if you insert thet text message to png file, it will be :
                    %&^#ED@((*hnvttyu$%&(^$$ygu%&$7*&596%$7 {" secret Message "}

                    your friend open the PNG file, he know if your message is the text inside of {"...."}

                    Please read following post to understanding :
                    Create a Secret message with Encrypt it.

                    Create a secret message

                    If we insert an plain text to PNG file, everyone who open the sourch of our PNG file can read our message. because our message unencrypt. Safely, if we encrypt our message before we inserting our message to PNG file.

                    Plain Message => Encrypt => Chiper Message + PNG file = PNG file(with encrypt message)

                    For encryption we can you every encryption algorithm.

                    you can use caesar algorthm for example in caesar
                    or use vigener
                    encrypt your message there, so you can sent your message safely.


                    After that all procces, you can post your PNG file in facebook Wall post. place your key in the text of wall post. make an agreement with your partner how to sent the key.


                    Please read the following post to understanding :
                    How to inserting text Message in PNG file.

                    Friday, May 28, 2010

                    Vigener Subtitution

                    Vigener is an Algorithm of plain encryption with caesar columnar subtitution.
                    so,every plain in colum encrypt with caesar Algortm by an different key.

                    Key : A T T A C K
                    Plain : M I S S I O
                    Chiper: M B L S K Y
                    Plain : N C A N C E
                    Chiper: N V T N E O
                    Plain : L E D
                    Chiper: L X W

                    So from the plain mission canceled encrypt with key ATTACK we can get the chiper text : MBLSK YNVTN EOLXW

                    we can make the php program of Vigener algorthm:
                    1. make the input text.

                    2. make the program.

                    3. testing the program.



                    Plain(with point '.') :

                    Key(with point '.') :



                    Caesar Algorithm

                    Caesar is an Algorithm which create by Yulius Caesar for encrypt his message text with
                    Chiper = Plain + 3 ;

                    Modern Caesar is not only plain + 3, but the key can be the other of modulus 26 or can use the mix alphabtic for encryption.

                    we can make a php program of caesar :


                    1. make the input page.





                    2. make the algorithm of caesar.





                    3. Testing the program.



                    Text(with point '.') :
                    Key(a number) :

                    Sunday, March 28, 2010

                    SMS security - TA-SMS

                    Encrypt your messages


                    ta-sms overview


                    when we send an sms to someone, such as our partner, sometimes we do not want others to know its contents. if we only use the applications of mobile sms sender of the original so anyone would be very easy to read that sms. especially if the content is seduction sms or important things, how busy we are when we send an sms that we receive or read others.
                    I had enough facilities provided menukmati motorola SLVR L6 at a secure sms I received and I sent a password, so that others can not read sms in my mobile phone. but what about other types of mobile phone?
                    I tried to find a solution for some time ..
                    I finally found an even better solution.My friend advised me to use the TA-sms. on the application there is encryption and Decryption facilities sms message with a same key.
                    so if I want to send a message that I consider to be kept secret to my friends, then I'll encrypt my message with a key, for example (abcd1234), then I send messages to my friends numbers. My friend also has a TA-sms. me and my friend has agreed the key that I used before, so he's going to decrypt my message abcd1234 key, where as I use.
                    If someone borrows my cell phone or handphoe my friend, so he will not discover my secret message, because the message was can only be accessed with the TA-sms.
                    TA-sms can be downloaded for free at GetJar.com with the keyword search engine "TA-sms" without the quotes.


                    good luck.



                    Security No. 1

                    Sunday, March 21, 2010

                    Hidden Files - minicommander

                    sometimes we have the files (pictures, music, videos etc.) that sometimes we do not want others to see / know. If we want to hide it, the theory is only change the properties file / folder to be 'hidden'.
                    For the mobile phone of course not as easy as 'right click' select 'properties' such as in the computer.
                    Need an additional application to change the file properties to hidden.
                    Please download minicommander, It can be download in GetJar.com from your mobile phone.

                    To Hidden file/folder in your phone with monicommander :
                    1. Select the file will be hidden,
                    2. Press the menu, trus properties, Or Click "2" on your keypad to show the file/folder properties
                    3. Select hidden
                    4. Try to minimize minicommander,
                    5. Search for files do you hidden, in previous folders
                    6. Files invisible, God willing
                    7. have done hidden processes.
                    8. calm, your important files are not lost,
                    9. if you want to be tough minicommander pake must have looked.
                    Minicommander can be given a password, to open the application, to ensure the security of your files.

                    minicommander screenshot
                    If you want to know more about minicommander, view the review here.

                    Good Luck.
                    Security is no 1.