Kesalahan kecil yang FATAL

| Monday, February 25, 2008

Namanya manusia ga luput dari kesalahan, lalai dan teledor. Dan akibatnya macam², tak jarang kesalahan kecilpun bisa berakibat fatal. Bayangin aja misalnya dokter salah tulis dikit aja ngasih resep, atau diagnosa bisa berakibat kematian kan..

Ok, kita ngga akan bahas medis karna gw ga ngeri sekali sama. Gw cuman mau nulis kesalahan kecil gue yang berakibat fatal meski ga sampe menyebabkan kematian *sigh*

Sore kemarin server gw loadnya beraaattt banget... seperti seorang pemuda yang naik BMW tapi mangku gajah lampung! Segera saja otakku yang mungkin sama dgn otak manusia indonesia yang jarang digunakan karena takut aus mulai terasah.
Tiba2 saja saya sudah login di gateway server² dan mulai mengallow ip tertentu yang diijinkan untuk ngakses server dan mulai mendeny ip2 yang tidak dibutuhkan untuk mengurangi load server gw yang sedang mangku gajah duduk..
Crap!
Ada rule yang salah saat ngetikkan baris2 perintah firewall...
Jadinya gateway ga bisa saya akses dan server yang lain juga sama kecuali server yg diduduki gajah tadi.

Help.. tasukete kudasai!..
Gatewaynya jauh di ibukota negara banjir nan macet 924 km darisini.
Harus call teman dulu disana, setelah proses yang mendebarkan bin menyebalkan bisa juga terhubung dan dia harus menempuh lebih dari 30 menit untuk sampai dan cangkruk di consolenya.
Oh baru cobaan gini aja gw dah bingung setengah hidup, ya maklum wong gatewaynya u/ beberapa server maha penting.

Finally smua bisa diatasi *ya jelas wong emang rulenya simple tapi mematikan*
Server yang lambreta ternyata karena ada salah satu cust. yang ngabis2in resource servernya, so smtr saya suspend dulu.
Report juga udah kukirim, report yang apa adanya tanpa bumbu² sedikitpun. Rangkaian kejadian dari awal sampai akhir sampai main effect kutulis disertai perasaan nano-nano seorang kuli yang sedang berkecamuk di dada. yah mo gmn lagi emang salah saya jadi tinggal siap2 konsekuensinya aja..

Hikmah yang bisa diambil :
1. Terkadang dengan cobaan sedikit saja, manusia sudah merasa merana. Terkadang makian sampai keluar, seakan lupa kalau nikmat yang telah diterima begitu banyak sampai tidak bisa dihitung bahkan walau jari gajah lampung ikut serta juga ga bakal cukup untuk ngitung. Kalkulator bisa jadi akan buffer overflow kalau kita maksa ngitung.

2. Jika melakukan sesuatu yang harus cepat selesai, dan cukup merepotkan. Biasakan untuk menenangkan diri dan konsentrasi penuh dan jangan lupa bismillah.

3. Usahakan ruangan cukup kondusif, tidak ada teman yang mengganggu, suara atau hal² kurang penting lainnya.

| Friday, February 22, 2008

dns1 named[1376]: client 125.162.42.67#64136: update 'swisscontact.or.id/IN' denied

I keep getting log messages like the following. Why?
Jun 21 12:00:00.000 client 10.0.0.1#1234: update denied
A:
Someone is trying to update your DNS data using the RFC2136 Dynamic Update protocol. Windows 2000 machines have a habit of sending dynamic update requests to DNS servers without being specifically configured to do so. If the update requests are coming from a Windows 2000 machine, see http://support.microsoft.com/support/kb/articles/q246/8/04.asp for information about how to turn them off.

DNS - named: ignoring out-of-zone data

|

Pake BIND? dan mengalami error sbb :

named[375]: master/domain.org:11: ignoring out-of-zone data ns2.mine.net.id

sama donk :P

Awalnya sih saya kira ada kesalahan di zone filenya. Tapi setelah diamati dalam tempo yang sesingkat²nya koq smua btul? ada apa ini.. ada apa.. :p
Saya coba query dari luar bisa u/ domain yg ada errornya tadi, dicek dari situs2 u/ cek dns juga ketemu tuh record²nya.

Akhirnya saya biarkan saja, toh sepertinya ngga ngaruh..
Sampai dengan pagi ini ada imel dari bos, nemuin log itu suruh nyari kenapa..
sebernaya gw juga bingung krn cari2 di google juga ga nemu, kalo nemu pun semua berkaitan dgn penulisan zone yang salah..

Ndilalah koq ada eror tambahan root. server bla bla.. duh sayang log e ilang :(
Gak pakai pikir lama, iseng² berhadiah tak coba replace named.rootnya

# dig @a.root-servers.net . ns > named.root
# rndc reload

Hurray.. thx god.. gw liat di log dah bersih sih.. n di query jg lancaarrr.. muach...

Ups.. jgn senang dulu.. ada cobaan lain.. muncul error ini nih di log, banyak lagi..

Feb 22 09:36:46 dns1 named[1376]: client IP#57305: RFC 1918 response from Internet for 3.0.168.192.in-addr.arpa

Untungya di FAQ ada :


Q: What does "RFC 1918 response from Internet for 0.0.0.10.IN-ADDR.ARPA"
mean?
A:
If the IN-ADDR.ARPA name covered refers to a internal address
space you are using then you have failed to follow RFC 1918 usage rules and are
leaking queries to the Internet. You should establish your own zones for these
addresses to prevent you querying the Internet's name servers for these
addresses. Please see http://as112.net/ for details of the problems you are causing
and the counter measures that have had to be deployed.
If you are not using
these private addresses then a client has queried for them. You can just ignore
the messages, get the offending client to stop sending you these messages as
they are most probably leaking them or setup your own zones empty zones to serve
answers to these queries.
zone "10.IN-ADDR.ARPA" {
type master;
file
"empty";
};
zone "16.172.IN-ADDR.ARPA" {
type master;
file
"empty";
};
...
zone "31.172.IN-ADDR.ARPA" {
type master;
file
"empty";
};
zone "168.192.IN-ADDR.ARPA" {
type master;
file
"empty";
};
empty:
@ 10800 IN SOA .
. (
1 3600 1200 604800 10800 )
@ 10800 IN NS
.


Hahaha.. bahasa inggris canggih gtu.. yang jelas dnsku ga dipake u/ query ip lokal, so spt saran di atas aku tambahin zone2 tsb.. trus reload deh.

Reset Root Password Debian VS FreeBSD

| Saturday, February 16, 2008

Semalam udah semangat 456789 mau nyoba debian yang udah lama tak terjamah tangan halusku, tapi tak dinyana aku lupa password rootnya ^^. Untung jam 11an nak ibnu bisa dikontak, secara dia biasa bersentuhan dgn mbak debby ini :P. *tenkiu yo le*

Berikut langkahnya, boot loadernya pakai grub nih bukan lilo and stich :P.

1. Waktu boot pilih "recory mode" dan tekan c.
2. Selanjutnya akan ada 4 pilihan, dan arahkan kursor pada pilihan yang ada tulisannya kernel bla2, pokoknya paling panjang sendiri deh, kemudian tekan e.
3. Tambahkan "init=/bin/bash" pada akhir baris dan tekan enter. Voila, udah masuk single mode.
4. ketikkan "mount -o remount, rw /"
5. ketik passwd, isikan password yang baru
6. kemudian ubah akses ke readonly "mount -o remount, ro /"
7. Selesai dan reboot deh..

Kalau di freebsd langkahnya lebih mudah,
1. Waktu boot, pada boot menu tekan angka 3
2. mount -a
3. ketik passwd dan isikan password baru dan reboot

Untuk freebsd ada pilihan untuk tetap prompt password walaupun kita masuk di single mode, bisa di cek /etc/ttys dan ubah pilihan secure menjadi insecure. Itu kalo qta admin paranoid n menjamin kalo qta ga bakalan lupa password kita :p.
Kalo di debian belum tahu sih gmn caranya, tapi kata si ibnu sih di linux yg versi baru u/ single modenya udah diprompt password juga.

LSOF (list open files)

| Friday, February 15, 2008

Siang ini makan siang ditemani seporsi mie ayam bakso ples artikel lsof but tanpa teh botol s*sro. Langsung install aja deh, drpd lupa n banyak kerjaan, installnya juga via jalur xpress :P

# cd /usr/ports/sysutils/lsof
# make install clean
# rehash

Lsof merupakan utility yang hampir mirip dengan netstat -an tapi mungkin lebih lengkap kali ya, karena qta juga bisa melihat file2 yang sedang dijalakan apa saja oleh suatu program, mulai dr binary file, library dan file2 yang berhubungan dengan program yg sedang berjalan.. la wong namanya aja "List open files" ker..

ok lanjut...

# lsof -l
perintah ini akan memperlihatkan smuaaa list prog yang sedang berjalan, sengaja ga dicapture hasilnya (panjang bokkk)

# lsof -c named
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
named 89535 named cwd VDIR 4,12 512 16662 /chroot/named/conf
named 89535 named rtd VDIR 4,12 512 16656 /chroot/named
named 89535 named jld VDIR 4,12 512 16656 /chroot/named
named 89535 named txt VREG 4,17 3507739 7774967 /usr/local/sbin/named
named 89535 named txt VREG 4,12 142236 16549 /libexec/ld-elf.so.1
named 89535 named txt VREG 4,12 1017456 8301 /lib/libcrypto.so.3
named 89535 named txt VREG 4,12 884716 8280 /lib/libc.so.5
named 89535 named 0u VCHR 2,2 0t0 7 /dev/null
named 89535 named 1u VCHR 2,2 0t0 7 /dev/null
named 89535 named 2u VCHR 2,2 0t0 7 /dev/null
named 89535 named 3u unix 0xc40a0000 0t0 ->0xc181a288
named 89535 named 4u VCHR 2,2 0t0 7 /dev/null
named 89535 named 5r VCHR 248,0 0t0 16 /dev/random
named 89535 named 22u IPv4 0xc3f980b4 0t0 UDP *:54519

lengkap kan? kalau ga mau panjang2 atau mau lihat file apa yg dijalankan tinggal ketik
# lsof -a -d cwd -c named
named 89535 named cwd VDIR 4,12 512 16662 /chroot/named/conf

kalau mau lihat pakai port berapa ya tinggal
# lsof -a -c named | grep "*:"
named 89535 named 22u IPv4 0xc3f980b4 0t0 UDP *:54519

Sep kan? lumayan bisa lihat service yang berjalan apa aja, n dikill aja kalo gak penting, bikin server berat, makan bw or samting else..

Huekz.. abis makan mie koq rasanya mual.. kayaknya mie/pentol nya byk msgnya niy, oh nooo saya skr ga bisa kena msg.. ora tawar jeesss...

backup antar server

| Wednesday, January 30, 2008

rsync adalah utility u/ memindah2 file/sinkronisasi file.
Kata manualnya sih rsync bisa digunakan sbb :

1. for copying local files. This is invoked when neither source nor destination path contains a : separator
2. for copying from the local machine to a remote machine using a remote shell program as the transport (such as rsh or ssh). This is invoked when the destination path contains a single : separator.
3. for copying from a remote machine to the local machine using a remote shell program. This is invoked when the source contains a : separator.
4. for copying from a remote rsync server to the local machine. This is invoked when the source path contains a :: separator or a rsync:// URL.
5. for copying from the local machine to a remote rsync server. This is invoked when the destination path contains a :: separator.
6. for listing files on a remote machine. This is done the same way as rsync transfers except that you leave off the local destination.

So, yuk mari kita buktikan.

Anggap saja server utama ipnya 10.10.10.75 dan server backupipnya 10.10.10.60
Nah rsync modenya nanti pakai yang over ssh.

Login ke 10.10.10.60, di directory /home ketik :
# ssh-keygen -f qlogin -t rsa
untuk password langsung enter saja, perintah ini akan mengenerate private (qlogin) dan public key (qlogin.pub)

Selanjutnya copykan qlogin.pub ke server 10.10.10.75 di directory homeuser/.ssh dan rename menjadi authorized_keys2, spt ini nih hasilnya : /home/rahma/.ssh/authorized_keys2

Kita tes, sukses ga login ssh scr otomatis..
Login ke 10.10.10.60, masuk ke directory dimana qlogin berada dan ketik
# ssh -i qlogin rahma@10.10.10.75

OK, setelah sshnya lantjar djaja, tinggal install rsyncnya.. (spt biasa wes.. ndak usah dijelasin yak :P)...

Nah untuk perintah sinkronisasi/backup filenya spt ini :
masuk ke dir dimana qlogin (private keynya berada), kebetulan punyaku di /home
# cd /home
# /usr/local/rsync/bin/rsync -e "ssh -i qlogin -l rahma -p 2223" -avz rahma@10.10.10.75:/home/www /home/BACKUP75/

sent 1636 bytes received 2421838595 bytes 3734526.19 bytes/sectotal size is 2421962606 speedup is 1.00

SMTP Auth auxprop dengan Postfix

| Tuesday, January 29, 2008

# cd /usr/local/mysql/lib/mysql/
# cp * /usr/local/lib
# cd /usr/local/mysql/include/
# cp * /usr/local/include/

Download cyrus-sasl-2.1.19 dan patchnya, kemudian ekstrak dan lakukan patching

# cd /cyrus-sasl-2.1.19
# patch -p1 < ../cyrus-sasl-2.1.19-checkpw.c+sql.c.patch. # ./configure --enable-static --enable-shared --enable-sql --with-mysql=/usr/local/mysql --enable-login --disable-otp --disable-ntlm # make && make install # ln -s /usr/local/lib/sasl2 /usr/lib/sasl2 # cd /usr/local/lib/sasl2 # cp *sql* /lib/ # vi /usr/local/lib/sasl2/smtpd.conf pwcheck_method: auxprop auxprop_plugin: sql sql_engine: mysql mech_list: DIGEST-MD5 CRAM-MD5 PLAIN LOGIN sql_engine: mysql sql_hostnames: localhost sql_user: dbmail sql_passwd: s3cr3t sql_database: dbmail sql_verbose: yes sql_select: SELECT passwd FROM dbmail_users WHERE userid = '%u@%r' # cd postfix-2.4.5 # make tidy
# make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl" AUXLIBS="-L/usr/local/lib/ -lsasl2" atau
# make makefiles CCARGS="-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/local/include/sasl -DHAS_MYSQL -I/usr/local/mysql/include/mysql" AUXLIBS="-L/usr/local/lib/ -lsasl2 -L/usr/local/mysql/ -lmysqlclient -lz -lm"

# make install

tambahkan baris berikut pada /etc/postfix/main.cf
smtpd_recipient_restrictions =
reject_unauth_pipelining
reject_non_fqdn_recipient
reject_unknown_recipient_domain
permit_mynetworks
permit_sasl_authenticated
reject_unauth_destination
permit

broken_sasl_auth_clients = yes
smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous

=== Selesai ===

/usr/local/sbin/saslauthd:
libgssapi.so.7 => /usr/lib/libgssapi.so.7 (0x2807e000)
libkrb5.so.7 => /usr/lib/libkrb5.so.7 (0x2808c000)
libasn1.so.7 => /usr/lib/libasn1.so.7 (0x280c4000)
libroken.so.7 => /usr/lib/libroken.so.7 (0x280e5000)
libcrypt.so.2 => /lib/libcrypt.so.2 (0x280f3000)
libcrypto.so.3 => /lib/libcrypto.so.3 (0x2810b000)
libcom_err.so.2 => /usr/lib/libcom_err.so.2 (0x28202000)
libpam.so.2 => /usr/lib/libpam.so.2 (0x28204000)
libc.so.5 => /lib/libc.so.5 (0x2820b000)

/usr/sbin/postfix:
libsasl2.so.2 => /usr/local/lib/libsasl2.so.2 (0x28083000)
libc.so.5 => /lib/libc.so.5 (0x28096000)
libcrypt.so.2 => /lib/libcrypt.so.2 (0x28170000)

/usr/libexec/postfix/smtpd:
libsasl2.so.2 => /usr/local/lib/libsasl2.so.2 (0x280b6000)
libc.so.5 => /lib/libc.so.5 (0x280c9000)
libcrypt.so.2 => /lib/libcrypt.so.2 (0x281a3000)


mail-h# telnet smtpku.co.id 25
Trying 203.134.232.67...
Escape character is '^]'.
220 smtpku.co.id ESMTP Postfix
ehlo a
250-PIPELINING
250-SIZE 5120000
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN DIGEST-MD5 CRAM-MD5
250-AUTH=LOGIN PLAIN DIGEST-MD5 CRAM-MD5
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN

Hardening FReeBSD

| Monday, December 31, 2007

Sebelumnya sih sudah pernah posting yang berbau hardening system, tapi sepertinya artikel berikut lebih lengkap deh.. thx to mbah google.

Tips dan trik seputar FreeBSD Security.
1. Selalu berdo'a sebelum action
2. Selalu membuat BACKUP sebelum melakukan segala sesuatunya.

BASIC SYSTEM HARDENING
1. Gunakan selalu FreeBSD versi STABLE (heheh..belum saya lakukan, selalu saja pake release). 2. Jangan menjalankan services yang tidak perlu, lihat /etc/inetd.conf, /etc/rc.conf

SERVICES PROTECTION
1. Gunakan chroot(8) atau jail(8) untuk menjalankan program-program yang berisiko vulnerable.
2.Memfilter setiap akses terhadap services menggunakan Firewall atau Packet Filtering software seperti ipfw atau IPF (ipfilter).
3. Aktifkan option log_in_vain="YES" untuk melihat koneksi ke port-port TCP/UDP yang
tidak menjalankan services.

SECURE LOGGING
Non-aktifkan syslogd logging ke mesin remote. gunakan option “-s -s”
Pastikan pada /etc/syslog.conf terdapat:
security.* /var/log/security
ftp.* /var/log/ftpd.log
auth.* /var/log/auth.log

Aktifkan ipfw atau IPF logging pada /etc/syslog.conf


B O F H (bastard operator from hell)
1. Gunakan AllowUsers/AllowGroups pada konfigurasi SSH untuk menentukan siapa saja user yang dapat login menggunakan SSH.
2. Gunakan tcp wrappers untuk mengijinkan atau melarang akses pada tcp-based services.
3. Berikan shell /sbin/nologin pada user yang hanya membutuhkan akses ftp.
4. Lakukan user accounting. accounting_enable="YES"

LOCKING-DOWN FILESYSTEM
1. Selalu membuat beberapa partisi.
2. Mount semua partisi kecuali /usr dengan argument ‘nosuid’
3. Hilangkan suid bits pada binary yang tidak digunakan (seperti pada UUCP binary files)
4. Gunakan chflags dengan variable sappnd pada logfiles, dan schg pada binary files.
# ls -lo /usr/bin/su
-r-sr-x--- 1 root wheel schg 8200 May 1 09:37 /usr/bin/su


KERNEL SECURELEVELS
Variable kernel securelevels menunjukkan level security.
Value antara ‘-1’ sampai ‘3’, dan ‘0’ adalah ‘insecure mode’.
Securelevel hanya dapat meningkat nilainya, dan tidak dapat turun pada multiuser mode.
Securelevel dikontrol menggunakan sysctl(8) dan sysctl.conf(5).

Securelevel 1 = flag sappnd dan schg tidak dapat diubah, kernel module tidak dapat diload/unload.
Securelevel 2 = securelevel 1 + tidak dapat menulis pada disk kecuali mount(2)
Securelevel 3 = securelevel 2 + ipfw rules tidak dapat dimodifikasi

KERNEL STATES CONTROL & SYSTEM CONFIGURATION

sysctl & rc.conf

net.inet.tcp.blackhole=2, net.inet.udp.blackhole=1
untuk tidak membuat RST pada portscan
kern_securelevel_enable="YES",
kern_securelevel="?" # range: -1..3;
icmp_drop_redirect="YES"
fsck_y_enable="YES"


SECURE REMOTE CONNECTIONS

1. Non-aktifkan telnet, dan r* commands, gunakan SSH atau OpenSSH sebagai pengganti
2. Gunakan sftp sebagai pengganti ftp
3. Gunakan otentifikasi pubkey pada SSH
4. Pertimbangkan kembali penggunaan OTP (One-Time-Password)

FIREWALL / PACKET FILTERING
Sebuah firewall dapat:
melakukan deny/permit packets
membedakan rules setiap interfaces

Software yang dapat digunakan:

ipfw (IPFirewall):
options IPFIREWALL enable ipfw
options IPFIREWALL_VERBOSE enable firewall logging
options IPFIREWALL_VERBOSE_LIMIT limit firewall logging
options IPDIVERT enable divert(4) sockets

IPF (IPFilter):
http://coombs.anu.edu.au/~avalon/


SECURITY CHECKS

nmap, swiss-army knife, err network mapper ;)
http://www.insecure.org/nmap/

snort, Lightweight network intrusion detection system
http://www.snort.org/

tripwire, Filesystem security & verification program
http://www.tripwire.org/

chkrootkit, memeriksa apakah terdapat rootkit pada local system.
http://www.chkrootkit.org/

dsniff, monkey watch monkey sniff
http://www.monkey.org/~dugsong/dsniff/



WHAT’S NEXT?

FreeBSD Security web page:
http://www.freebsd.org/security/security.html

FreeBSD Security How-To:
http://people.freebsd.org/~jkb/howto.html

FreeBSD Security advisories:
ftp://ftp.freebsd.org/pub/FreeBSD/CERT/advisories/

FreeBSD Hardening Project:
http://www.watson.org/fbsd-hardening/


WHAT’S NEXT?

FreeBSD ipfw howto:
http://www.freebsd-howto.com/HOWTO/Ipfw-HOWTO

IPF (ipfilter) howto:
http://www.obfuscation.org/ipf/ipf-howto.html

Cerb, security kernel module:
http://cerber.sourceforge.net/

Packetstorm Defense Tools:
http://packetstormsecurity.nl/defense.html

Akses file dari CD

| Thursday, November 29, 2007

Tambahkan berikut pada kernel

MOUNTING A CD-ROM DISK

We need to set up a directory before we can mount the CD, so let's go to the OS root directory by entering:

cd /
mkdir /cdrom
mount -t cd9660 /dev/acd0c /cdrom

READ A DIRECTORY LISTING
The CD-ROM disk is now mounted. To test, enter:
ls -lt /cdrom

This should give us a listing of the files on the CD.
COPY OR MOVE FILES
cp -p /cdrom/somefile.conf /some/directory/on/hard/drive/

UNMOUNT CD-ROM DISK
Once we are finished using the CD-ROM disk, before we remove it, enter:
umount /cdrom

Program saya jalan?

| Thursday, November 22, 2007

Berawal dari insiden matinya source streaming server saya kemarin, saya tak tahu kalau mati *dudulzmodeon*, HP lagi masuk bengkel ples sore itu saya sedang mengunjungi bu dokter jadi tidak ada koneksi internet sama sekali.
Dari dokter gigi saya ke matos ma adek..baru tahu setelah yang shift call ke hp adekQ. Fyuh.. matinya lmy lama *sighhh* gara2 yg jaga juga kagak ngerti adudududu...

So, hari ini otakku yang makin lama makin aus karena jrg digunakan :P mulai dikit2 bekerja.. gimana kalo dibuatin script aja biar ngecek tiap bbrp menit sekali.

Nih contohnya scriptnya, kasih aja nama /etc/cekecek
#!/bin/sh
SERVICE=httpd;
if ps ax | grep -v grep | grep $SERVICE > /dev/null
then
echo "$SERVICE service running, everything is fine"
else
echo "$SERVICE is not running"
/etc/rc.d/http
fi

Masukin ke crontab, oven tiap 1 jam sekali :P
59 * * * * /etc/cekecek

Buat para remote-R sejati

| Tuesday, November 20, 2007

Sodara2 sering remote dan tiba² pas lagi khusyuk²nya install sesuatu tiba-tiba koneksi putus. Jadi sebel bin ambien kan...
Hehehe kebetulan setelah ngintip blognya om Giest ada solusinya niy. Yups, qta bisa nginstall yg namanya screen, tutor berikut diambil dari postingannya om Giest.


#cd /usr/ports/sysutils/screen
make install clean

PEMAKAIAN

Perintah-perintah di screen yang penting sbb :

screen

ctrl a c = membuat session screen baru
ctrl a p = berpindah antar screen session
ctrl a d = keluar dari screen session tanpa mematikan proses yang sedang dilakukan.
exit = keluar dari screen setelah proses yang sedang dilakukan selesai

CONTOH

Ketikan screen untuk memulai screen session, apabila pertama kali maka ini adalah screen session satu-satunya sementara apabila anda pernah membuat screen session sebelumnya, maka perintah ini akan memulai screen session baru tanpa mengganggu session sebelumnya.

kemudian ketikan perintah yang ingin anda lakukan misalnya top, setelah top berjalan kemudian andaketikan ctrl a c untuk membuat screen baru dan anda akan mendapatkan screen kosong yang lain. Disini anda bisa melakukan perintah yang lain seperti misalnya ping ke host yang anda inginkan.

Setelah semua proses diatas berjalan untuk berpindah antar screen tadi (dari perintah top ke ping) anda cukup mengetikan ctrl a p dan anda pun sudah kembali ke screen berikutnya.

Untuk keluar dari screen tanpa mematikan proses screen tadi, anda cukup mengetikan ctrl a d maka anda akan kembali ke shell dan bukan di screen lagi. Apabila anda kemudian keluar atau mematikan remote koneksi maka session screen anda tetap berjalan.
Apabila anda karena alasan tertentu putus koneksi dengan server yang anda remote anda dan belum sempat keluar dari screen jangan takut karena proses yang anda lakukan tetap berjalan anda tinggal melanjutkan nya saja.

Untuk melanjutkan session screen pertama anda harus login dengan user yang membuat screen session. User yang lain tidak akan bisa melanjutkan (resume) session screen milik user yang lain.

Setelah anda login dengan user bersangkutan sekarang ketikan screen -r apabila anda sebelumnya memiliki session screen lebih dari satu silahkan cek terlebih dahulu dengan cara seperti berikut ini

/usr/local/bin/screen screen -ls
There are screens on:
96050.ttyp0.giest (Detached)
96172.ttyp0.giest (Detached)
2 Sockets in /tmp/screens/S-root.
/usr/local/bin/screen screen -ls
There are screens on:
96050.ttyp0.giest (Detached)
96172.ttyp0.giest (Detached)
2 Sockets in /tmp/screens/S-root.

Seperti terlihat bahwa ada dua session screen yang aktif untuk masuk dan mempergunakan session yang aktif lakukan perintah berikut ini

screen -r 96172.ttyp0.giest
screen -r 96172.ttyp0.giest
maka anda sekarang akan bekerja di screen tersebut sementara screen session yang lain tetap aman.

Ok sekarang tidak perlu lagi takut melakukan pekerjaan yang memerlukan waktu lama secara remote cukup buka screen dan koneksi putus bukan masalah lagi.

taken from giest.org

port ku perlu apa aja?

|

make pretty-print-build-depends-list
make pretty-print-run-depends-list

make -V RUN_DEPENDS and make -V BUILD_DEPENDS

You can use this to check for the value of any make variable (LIB_DEPENDS, OPTIONS, WITH_*, WITHOUT_*, etc).


# cd /usr/ports/category/port
# make build-depends-list
# make run-depends-list

Just Copy oaste.. :(

|

Learn some of the basic steps you can take to make your FreeBSD system more secure.
1. set additional flags on your /tmp and /home directories. I will show you how to see your current flags and how to change them[root]# mount/dev/ad0s1a on / (ufs, local)/dev/ad0s1f on /tmp (ufs, local, nodev, nosuid, soft-updates)/dev/ad0s1g on /usr (ufs, local, soft-updates)/dev/ad0s1e on /var (ufs, local, soft-updates)/dev/ad0s1h on /home (ufs, local, nosuid, with quotas, soft-updates)procfs on /proc (procfs, local)
The two partitions above are the ones we will be adding flags for. As you can see I added nodev and nosuid on /tmp and nosuid and quotas on /home
nodev - stops character or block special devices on the filesystemnosuid - disables suid programs from being run from this filesystemquotas - to limit the amount of disk space that your users may use
You can set these flags in /etc/fstab file
the /tmp directory is a world writable directory so taking these additional steps is a good idea
2. Set your system security level. For most machines there is no reason to run in securelevel -1, unless you wish to run X-Windows on the machine. If you would like to run a server it is best NOT to run X and step up your kernel security level to 1.
Changing this to 1 will mean that you may no longer replace the kernel without being in single user mode (system immutable and system append-only flags are also enforced), KLD's may not be loaded/unloaded and /dev/mem and /dev/kmem may not be opened for writing. To change the security level do the following:
[root]# sysctl kern.securelevel=1
to make this change permanent add the following to/etc/rc.conf:
kern_securelevel_enable="YES"kern_securelevel="1"
3.Remove the toor user.
By default, FreeBSD ships with an additional user that has a UID of 0. This user is known as toor (root backwards), and is intended as a backup user, so that if you mistakenly broke (for eg) root's shell, you could log in using this user and fix things. The account is disabled (passwordless) by default, and hence of no use UNLESS you change it's password. You may either choose to set a password for it, or remove it.
It should be noted that the rmuser(8) command will not allow the deletion of an account with a UID of 0, so you will need to use vipw(8) to remove this account.
4. Shutdown and services you are not using
[root]# netstat -na grep LISTENtcp46 0 0 *.80 *.* LISTENtcp4 0 0 *.22 *.* LISTENtcp46 0 0 *.22 *.* LISTEN
This shows that http(80) and ssh(22) are listening. If you have a process listening and you're unsure of what process is keeping that port open you may use sockstat(1) to list open sockets and provide you with the relevant information
You can all see anything listening for UDPnetstat -nap udpudp4 0 0 *.514 *.*
Here, you see that syslogd is listening on port 514 (UDP). You can disable syslogd from listening on a port by changing/etc/rc.confsyslogd_enable="YES"syslogd_flags="-ss"
5. Setup packets being sent to non-listening ports to be ignored and go to a 'Black Hole'
[root]# sysctl net.inet.tcp.blackhole=1
to make this change permanent modify/etc/rc.conf
net.inet.tcp.blackhole=1net.inet.udp.blackhole=1
6. KEEP YOUR PACKAGES AND OS CURRENT.
I have an article here on how to automatically update your freeBSD box. I would suggest you set this up!

Update binary freebsd

| Saturday, November 17, 2007

Pertama install dulu freebsd-update
# whereis freebsd-update
freebsd-update: /usr/local/sbin/freebsd-update
# cd /usr/local/sbin/freebsd-update
make install clean

cp /usr/local/etc/freebsd-update.conf.sample /usr/local/etc/freebsd-update.conf
# rehash
# freebsd-update fetch
# freebsd-update install

Shell-ku?

|

Untuk mengetahui jenis shell yang sedang kita gunakan ketik :
# echo $SHELL
/bin/csh

atau dgn perintah berikut :

office-mlg# ps -p $$
PID TT STAT TIME COMMAND
59155 p0 S 0:00.04 /bin/csh

Untuk melihat shell apa saja yang tersedia di FreeBSDBox-mu ketik :
# more /etc/shells
/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash

Ada satu tips lagih.. coba aja :

chmod 0750 `which curl` 2 > & - ; chmod 0750 `which fetch` 2 > & - ; chmod 0750 `which wget` 2 > & -

#!/bin/bash
USERS="$(awk -F: 'NF > 1 && $1 !~ /^[#+-]/ && $2=="" {print $0}'
/etc/passwd2 | cut -d: -f1)"
for u in $USERS
do
pw lock $u
done

Where
NF : Total number of record (so only continue if we have more than one record in password file)
$1 : First field in /etc/master.passwd
$2 : Second filed in /etc/master.passwd
$1 !~ /^[#+-]/ : It compares first field (user login name) and make sure it does not starts with either +,- or # symbol

How does it work?
1) Awk statement read each line in /etc/master.passwd where fields separated by : symbol
2) Account has no password if password field ($2) in /etc/master.passwd is empty

Once you found all such passwordless account., you can Lock user account with the following command:
pw lock {username}

# pw lock s2099msFor unlocking the account use:
pw unlock {username}

# pw unlock s2099ms

rootkitHunter

| Friday, November 16, 2007

Sebelumnya install rkhunter paling engga, qta musti punya : wget | curl | elinks | links | lynx bget GET

# fetch http://optusnet.dl.sourceforge.net/sourceforge/rkhunter/rkhunter-1.3.0.tar.gz
unpack the tarball and, as root, run the installation script:
tar zxf rkhunter-.tar.gz
cd rkhunter
./installer.sh --layout default --install
atau
./installer.sh --layout custom /usr/local/ --install

To show where files are installed using the "oldschool" layout run:

./installer.sh --layout oldschool --show
PREFIX: /usr/local
Application: /usr/local/bin
Configuration file: /usr/local/etc
Documents: /usr/local/rkhunter/lib/rkhunter/docs
Man page: /usr/local/rkhunter/lib/man/man8
Scripts: /usr/local/rkhunter/lib/rkhunter/scripts
Databases: /usr/local/rkhunter/lib/rkhunter/db
Temporary files: /usr/local/rkhunter/lib/rkhunter/tmp

./rkhunter --update
./rkhunter -c

Before running RKH you will need to fill the file properties database by
running the following command:

rkhunter --propupd


To run RKH, as root, simply enter the following command:

rkhunter --check


By default, the log file '/var/log/rkhunter.log' will be created. It
will contain the results of the checks made by RKH.

To see what other options can be used with rkhunter, enter:

rkhunter --help


NOTE: The first run of 'rkhunter' after installation may give some
warning messages. Please see the FAQ file for more details
about this.

Uninstall

tar zxf rkhunter-.tar.gz
cd rkhunter
./installer.sh --layout default --remove

If you chose a different layout, for example '/usr', then run the
installer using:

./installer.sh --layout /usr --remove

beastie tipz

| Wednesday, November 14, 2007

"ls -G", "ls -F" atau "ls -FG"
Gunakan untuk directory listing berwarna ;)

'set autolist'
pada tcsh shell digunakan u/ scr otomatis menampilkan semua kemungkinan saat melakukan ekspansi file/directory

'set autologout = 30'
jika idle lbh dari 30 menit akan dilogout (u/ tcsh shell)

`set filec'
mengaktifkan (file completion) dlm tcsh dengan menekan TAB

`set watch = (0 any any)'
Untuk mengaktifkan notifikasi jika ada user log in/out.

set prompt = '%n@%m:%/%# '
contoh tampilan rahm@server:/usr# u/ bold sbb : set prompt = '[%B%m%b] %B%~%b%# '

grep "string" filename1 [filename2 filename3 ...]
mencari suatu string dari suatu file

Setting alias u/ memendekkan perintah
alias lf="ls -FA"
alias ll="ls -lA"
alias su="su -m"

di csh or tcsh, spt ini :
alias lf ls -FA
alias ll ls -lA
alias su su -m
ketik 'alias' untuk melihat daftar alias yang ada

Lihat /etc/rc untuk melihat loading system.

whereis 'namaprog'
Gunakan untuk mencari binary, manual atau source dir. dari suatu program.

Ctrl-D
Gunakan untuk exit/logout dr shell.

"du -s * sort -n "
U. list directory dan sizenya.

Mixer
U. mengatur volume peripheral sound.

pkg_add -r
automatically download and install binary packages and it's dependency.


Mencari port tertentu?, ketik berikut pada dir. /usr/ports
"make search port="
or
"make search key=""


swapinfo
menampilkan virtual memory

"zcat" atau "zmore"
U/ membaca file terkompresi tanpa ekstraksi

du /partition_or_directory_name sort -rn head
Untuk melihat 10 file terbesar dlm dir. / partisi

file namafile
Untuk melihat apakah textfile, exe atau tipe file lain.

col -bx <> newfile
Untuk meremove karakter ^M pada DOS file

lock -p
Untuk melock terminal.

dig -x IP-address
U. melihat hostname suatu ip

Tambahkan berikut pada C Shell u/ melindungi core files dari penulisan.
limit coredumpsize 0

"leave +hhmm"
Untuk men-set reminder terminal

"sockstat -4l"
Need to see which daemons are listening for connection requests? Use
for IPv4, and "sockstat -l" for IPv4 and IPv6.

": > filename"
Untuk mengosongkan file

ls -R / more
melihat seluruh directory sistem


translated from : http://nixdoc.net/FreeBSD-Tips/

ODBC di PHP

| Friday, October 26, 2007

Siang ini ada yang rikues, server windows dgn apache n phpnya ga mau kalo pake database sql tapi maunya pake ODBC, yaw dah.. apa sich yang engga untuk dikau ? qeqeqe...

Pertama create dsn namenya di ODBC, pilih mdb driver dan select nama databasenya, misal metuek.mdb. Kalau untuk apache yang under unix settingnya gini
# cd /etc
# ee odbc.ini
[test]Description = test
DatabaseDriver = /usr/lib/libmdbodbc.so
Database = /var/www/test.mdb

Sudah? jika sudah re-start dunk apachenya.

Contoh script phpnya krg lebih spt ini niy.
$conn=odbc_connect('test','','');
if (!$conn) { exit("Connection Failed: " . $conn); }

$sql="SELECT * FROM customers";
$rs=odbc_exec($conn,$sql);
if (!$rs) {
exit("Error in SQL");
}
echo

;
echo ;
echo ;
while (odbc_fetch_row($rs))
{
$compname=odbc_result($rs,"CompanyName");
$conname=odbc_result($rs,"ContactName");
echo ;
echo ;
}
odbc_close($conn);
echo
CompanynameContactname
$compname$conname
;
?>

delete file by date

|

find /directory -name "namafile" -mtime +30 xargs rm atau
find /directory -name "namafile" -mtime +30 -type f -exec rm {}\;

Perintah diatas akan mencari file 30 hari n older dan akan menghapusnya.

-mtime n : kondisi True jika isi file modified n days ago.
Type Description
b : A block special device file
c : A character special device file
d : A directory
f : A plain file (SV only)
p : A named pipe (FIFO) (SV only)
l : A symbolic link to a file
s : A socket (BSD only)

Cek Cek ...

|

Sebagai admin gadungan, yah tugasnya secara rutin ngintip2 log di server.. tapi, koq slalu ada yang kelewatan yah ada yg belom dicek getuh..

akhirnya saya putuskan untuk saya tulis disini aja deh, kebetulan ini u/ mailserver untuk yg lain ga jauh beda..

1. Cek log /var/log/messages, /var/log/maillog n jgn lupa untuk cek dmesg dan auth.log

2. ps -ax, top, trafshow, sockstat -l adalah wajib hukumnya.

3. /var/virusmails harus didelete sisakan aja yang baru2, kali aja ada yg komplen.

# ls -l /var/virusmails/ |wc -l

4. /usr/local/mysql/var juga harus dicek minimal 1 bulan sekali file mysql-bin.xxxxx dan sisakan hanya 1 bulan terakhir saja.

5. /var/amavisd/tmp/.... (log temporary amavis dan clamd) juga harus
didelete setiap minggu (jika ada).

mailbox2 user juga harus dimonitor.