Senin, 02 Januari 2012
Senin, 06 Desember 2010
Factorial Function
When I told to compute the factorial function, I think as a human being.
But then how we write a program that compute a factorial? Here's the factorial function
n! = n x (n-1) x (n-2) x (n-3) x ....
But then how we write a program that compute a factorial? Here's the factorial function
int factorial (int n)
{
int product = 1;
while (n>0)
{
product = n * product;
n--;
}
return product;
}
Kamis, 07 Oktober 2010
Koneksi ke Remote Postgresql Server
Tambahkan IP address pada pg_hba.conf
server# vim /etc/postgresql/8.3/main/pg_hba.conf
host all all 192.168.2.0/24 trust
Sebagai awalan saya set trust saja, untuk menguji coba dulu.
Lalu coba lakukan koneksi sekarang
remote$ psql -h server -U za -d template1
psql: could not connect to server: Connection refused
Is the server running on host "192.168.2.198" and accepting
TCP/IP connections on port 5432?
Eh, masih belum bisa juga. Ternyata masih ada 1 konfigurasi lagi yang perlu ditambahkan, yaitu postgresql.conf
server# vim /etc/postgresql/8.3/main/postgresql.conf
listen_addresses = '192.168.2.198'
Voila, coba lagi
remote$ psql -h server -U za -d template1
Password for user za:
psql (8.4.4, server 8.3.11)
WARNING: psql version 8.4, server version 8.3.
Some psql features might not work.
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
template1=>
server# vim /etc/postgresql/8.3/main/pg_hba.conf
host all all 192.168.2.0/24 trust
Sebagai awalan saya set trust saja, untuk menguji coba dulu.
Lalu coba lakukan koneksi sekarang
remote$ psql -h server -U za -d template1
psql: could not connect to server: Connection refused
Is the server running on host "192.168.2.198" and accepting
TCP/IP connections on port 5432?
Eh, masih belum bisa juga. Ternyata masih ada 1 konfigurasi lagi yang perlu ditambahkan, yaitu postgresql.conf
server# vim /etc/postgresql/8.3/main/postgresql.conf
listen_addresses = '192.168.2.198'
Voila, coba lagi
remote$ psql -h server -U za -d template1
Password for user za:
psql (8.4.4, server 8.3.11)
WARNING: psql version 8.4, server version 8.3.
Some psql features might not work.
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
template1=>
Jumat, 01 Oktober 2010
Multiple C++ Files
For beginners, there's a famous idiom in programming, called hello world! Maybe it's describing how a little baby who had just come out to the world. :-)
It's more common to see this hello world source code:
Compile it with g++ and execute it:
It's the basic. How about if we manage to build a complex program? We divide it. We made several files. Here's the hello world with multiple files version. In this example there are three files:
First, the helloworld.cpp
Then the helloworld.h
Last, the main.cpp
Then it's time to compile it. How to do it?
Execute it!
Reference, accessed on 2010.10.01 14:20 (GMT+7).
It's more common to see this hello world source code:
$ vim hello.cpp
#include
int
main(){
std::cout<<"hello world!\n";
return 0;
}
Compile it with g++ and execute it:
$ g++ -o hello hello.cpp
$ ./hello
It's the basic. How about if we manage to build a complex program? We divide it. We made several files. Here's the hello world with multiple files version. In this example there are three files:
- helloworld.cpp
- helloworld.h
- main.cpp
First, the helloworld.cpp
#include "helloworld.h"
#include
using namespace std;
void hello_world(){
cout << "hello world!\n";
}
Then the helloworld.h
#ifndef _HELLOWORLD_H
#define _HELLOWORLD_H
#include
void hello_world();
#endif
Last, the main.cpp
#include "helloworld.h"
#include
using namespace std;
int main(){
hello_world();
return 0;
}
Then it's time to compile it. How to do it?
g++ -o hello main.cpp helloworld.cpp
Execute it!
$ ./hello
hello world!
Reference, accessed on 2010.10.01 14:20 (GMT+7).
Selasa, 15 Desember 2009
Kamis, 03 September 2009
Install Nessus di Debian Lenny
cari paket-paket yang berhubungan dengan kata kunci "nessus"
Install nessus client
Install nessus server
* Coba baca dokumen-dokumen di /usr/share/doc/nessus
Nah jadi bisa kan? Dari Om Har, rules dibuat kosong saja. Tekan Ctrl-D.
* Register nessus
# http://www.nessus.org/plugins/index.php?view=register
referensi: http://bsdnetwork.blogsome.com/2007/02/23/nessus-debian/
* Setelah melakukan register nessus
Plugin yang diload semakin banyak. Sebelum diregister sepertinya hanya 3000-an. Sekarang setelah diregister mencapai 29914. Efek lain dari semakin banyaknya plugin nessus yang diload, aplikasi nessus dan nessud memakan CPU yang besar. Oleh karena itu nessus membutuhkan daya komputasi yang besar.
* Bagaimana arsitektur aplikasi nessus
Mengapa harus ada server dan client?
# apt-cache search nessus
harden-remoteaudit - Audit your remote systems from this host
libnasl-dev - Nessus Attack Scripting Language, static library and headers
libnasl2 - Nessus Attack Scripting Language, shared library
libnessus-dev - Nessus static libraries and headers
libnessus2 - Nessus shared libraries
nessus - Remote network security auditor, the client
nessus-dev - Nessus development header files
nessus-plugins - Nessus plugins
nessusclient - Transitional package to openvas-client
nessusd - Remote network security auditor, the server
Install nessus client
# apt-get install nessus
Install nessus server
# apt-get install nessusd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libswfdec-0.6-90 libuser-identity-perl libepc-ui-1.0-1 libmtp7 libepc-1.0-1 libgksu1.2-0 aspell libraw1394-8
djvulibre-desktop libicu38 libmime-types-perl libgda3-common libgksuui1.0-1 libmagick++10 gnome-network-admin libnm-util0
libjaxp1.3-java-gcj python-numeric libcamel1.2-11 libpt-1.10.10-plugins-alsa libtotem-plparser10 libfile-remove-perl
libpt-1.10.10 libsoup2.2-8 libsuitesparse-3.1.0 libgpod3 libxerces2-java-gcj libeel2-data libdirectfb-1.0-0 p7zip dhcdbd
libcurl3 libio-stringy-perl libjaxp1.3-java gnome-spell libssh2-1 libpoppler3 libxerces2-java
libobject-realize-later-perl libeel2-2.20 openoffice.org-style-andromeda libopal-2.2 libxalan2-java libdvdread3
libgnomevfs2-bin libiw29 libedataserver1.2-9 libgucharmap6 libgda3-3 svgalibg1 libpt-1.10.10-plugins-v4l
libgnome-desktop-2 libavahi-core5 libmail-box-perl libcucul0 libxalan2-java-gcj libpoppler-glib3
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
libnasl2 nessus-plugins snmp
The following NEW packages will be installed:
libnasl2 nessus-plugins nessusd snmp
0 upgraded, 4 newly installed, 0 to remove and 1 not upgraded.
Need to get 4347kB of archives.
After this operation, 21.9MB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Get:1 http://202.6.233.34 testing/main libnasl2 2.2.10-1 [318kB]
Get:2 http://202.6.233.34 testing/main nessus-plugins 2.2.10-6 [2785kB]
Get:3 http://202.6.233.34 testing/main nessusd 2.2.10-3 [206kB]
Get:4 http://202.6.233.34 testing/main snmp 5.4.1~dfsg-12 [1038kB]
Fetched 4347kB in 0s (4486kB/s)
Preconfiguring packages ...
Selecting previously deselected package libnasl2.
(Reading database ... 169172 files and directories currently installed.)
Unpacking libnasl2 (from .../libnasl2_2.2.10-1_i386.deb) ...
Selecting previously deselected package nessus-plugins.
Unpacking nessus-plugins (from .../nessus-plugins_2.2.10-6_i386.deb) ...
Selecting previously deselected package nessusd.
Unpacking nessusd (from .../nessusd_2.2.10-3_i386.deb) ...
Selecting previously deselected package snmp.
Unpacking snmp (from .../snmp_5.4.1~dfsg-12_i386.deb) ...
Processing triggers for man-db ...
Setting up libnasl2 (2.2.10-1) ...
Setting up nessus-plugins (2.2.10-6) ...
Setting up nessusd (2.2.10-3) ...
/var/lib/nessus/private/CA created
/var/lib/nessus/CA created
Congratulations. Your server certificate was properly created.
The following files were created :
. Certification authority :
Certificate = /var/lib/nessus/CA/cacert.pem
Private key = /var/lib/nessus/private/CA/cakey.pem
. Nessus Server :
Certificate = /var/lib/nessus/CA/servercert.pem
Private key = /var/lib/nessus/private/CA/serverkey.pem
/etc/nessus/nessusd.conf updated to use the server's certificate / keys
Setting up snmp (5.4.1~dfsg-12) ...
* Coba baca dokumen-dokumen di /usr/share/doc/nessus
Nah jadi bisa kan? Dari Om Har, rules dibuat kosong saja. Tekan Ctrl-D.
* Register nessus
# http://www.nessus.org/plugins/index.php?view=register
referensi: http://bsdnetwork.blogsome.com/2007/02/23/nessus-debian/
* Setelah melakukan register nessus
Plugin yang diload semakin banyak. Sebelum diregister sepertinya hanya 3000-an. Sekarang setelah diregister mencapai 29914. Efek lain dari semakin banyaknya plugin nessus yang diload, aplikasi nessus dan nessud memakan CPU yang besar. Oleh karena itu nessus membutuhkan daya komputasi yang besar.
* Bagaimana arsitektur aplikasi nessus
Mengapa harus ada server dan client?
Selasa, 25 Agustus 2009
Tomcat6 di Debian Lenny
Tomcat sudah mencapai versi yang keenam. Dulu terakhir saya bermain dengan Tomcat, masih versi 5.5 Selesai melakukan instalasi tomcat6 dari binary, saya coba panggil. Saat saya panggil, saya bingung. Tomcat harus saya panggil di port berapa?
Di /etc/tomcat6/server.xml tertulis port 8005
Namun saat saya melakukan nmap port yang terbuka adalah port 8080
Di /etc/tomcat6/server.xml tertulis port 8005
Server port="8005" shutdown="SHUTDOWN"
Namun saat saya melakukan nmap port yang terbuka adalah port 8080
# nmap localhost
Starting Nmap 4.68 ( http://nmap.org ) at 2009-08-25 21:00 WIT
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Interesting ports on localhost (127.0.0.1):
Not shown: 1707 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
111/tcp open rpcbind
631/tcp open ipp
5432/tcp open postgresql
5900/tcp open vnc
8080/tcp open http-proxy
Langganan:
Postingan (Atom)