3/29/2011

Php : Tips

find path php.ini

php -i | grep php.ini
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.in

3/28/2011

Linux (Debian) : Mail Server

The Big Picture

http://workaround.org/ispmail/lenny/bigpicture

iRedMail
http://www.howtoforge.com/virtual-users-with-postfix-dovecot-mysql-roundcube-iredadmin-on-debian-6-squeeze

Linux (Apache) : mod rewrite

root@debian:/a2enmod rewrite
Enabling module rewrite.
Run '/etc/init.d/apache2 restart' to activate new configuration!
root@debian:/var/log# /etc/init.d/apache2 restart

edit site
/etc/apache2/sites-enabled/000-default


ServerAdmin webmaster@localhost

DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


:
:



ดูที่ โดยมองที่ AllowOverride None ให้เปลี่ยนเป็น All

#/etc/init.d/apache2 restart

ไฟล์ .htaccess




config apache : http://www.aboutdebian.com/internet.htm

3/26/2011

Hosting Control panel

Manager and Hosting Control panel

http://www.lxcenter.org/

3/25/2011

Apache : site enable

site enable
/etc/apache2/sites-available

#a2ensite sitename

remove site
#a2dissite sitename


ที่มา : http://www.debian-administration.org/articles/207

Linux (Debian) : user nologin shell

เนื่องจาก vsftpd ใช้ user ตรงๆ จาก os เลย ดังนั้นการสร้าง user ก็เป็นการสร้าง user ของ os ด้วยคำสั่ง useradd ซื้อมีออฟชั่นให้ใช้ล้านเจ็ดสิบเอ็ดแสน

useradd [options] LOGINNAME

เมื่อสร้าง user แล้ว อย่าลืมตั้งรหัสผ่านให้ user ที่สร้างด้วยคำสั่ง passwd LOGIN ด้วยนะครับ

ใน option เราต้องระบุ shell สำหรับ user นั้นด้วย แนะนำให้ระบุ shell ไปที่ /usr/sbin/nologin เพื่อที่จะให้ user ท่านนี้สามารถ เข้าใช้ ftp ได้ แต่ไม่สามารถใช้งาน shell ได้
แต่จะใช้ /usr/sbin/nologin ได้นั้น ต้องไปแก้ไขไฟล์ /etc/shells ก่อน ให้ดูว่า มีบรรทัด/usr/sbin/nologin อยู่รึยัง ถ้ายังไม่มี ให้เพิ่มเข้าไป

Linux (Debian) : vsftpd

install
#apt-get install vsftpd

Config
#vi /etc/vsftpd.conf

listen=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
file_open_mode=0777
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
xferlog_std_format=YES
ftpd_banner=Welcome to unbbz FTP Service.
secure_chroot_dir=/var/run/vsftpd
pam_service_name=vsftpd
chroot_local_user=YES


restart vsftpd
#/etc/init.d/vsftpd restart

3/24/2011

Linux : Debain fail2ban

Install Fail2ban

#apt-get install fail2ban
หลังจากลงเสร็จแล้วให้ทำการ copy ไฟล์ใหม่ขึ้นมานะครับเพื่อทำการแก้ไข

config file
#/etc/fail2ban/jail.conf

Edit Config file
#nano /etc/fail2ban/jail.local

[DEFAULT]
ignoreip = 127.0.0.1 # เป็น ip ที่จะไม่มีการ Ban
bantime =600 # เป็นเวลาที่จะ Ban IPสามารถเพิ่มลดได้ตามต้องการครับ
maxretry = 3 # คือตัวระบุการทำผิดพลาด 3ครั้งสามารถตั้งได้ตามต้องการ

[ssh-ddos]
enabled = true # ผมเปลี่ยนจาก false เป็น true เพื่อเพิ่มการตรวจสอบ SSH DoS
port = ssh, sftp
filter = sshd-ddos

เมื่อทำการแก้ไข config เสร็จแล้วให้ทำการ restart หervice ให้ทำงานได้เลยครับ

#/etc/init.d/fail2ban restart
และคุณสามารถเช็ค log ได้ที่นี่ครับ

#tail /var/log/fail2ban.log
อยากรู้ว่าใช้งานได้ไม่ได้นั้นลองทำการ login ได้เลยครับใส่มั่วๆลองเข้าไปดูแล้วรอเวลาที่เราตั้งให้มัน unban เองครับหรือว่ามีอีกเครื่องนึงก็ลอง ssh เข้าไปดู

#tail /var/log/fail2ban.log
iptables -X fail2ban-[name]
2007-11-28 13:25:59,853 fail2ban.actions.action: INFO
Set actionStart = iptables -N fail2ban-[name]
iptables -A fail2ban-[name]. -j RETURN
iptables -I INPUT -p -m multiport –dports
[port] -j fail2ban-[name]
2007-11-28 13:25:59,854 fail2ban.actions.action: INFO
Set actionUnban = iptables -D fail2ban-[name] -s -j DROP
2007-11-28 13:25:59,855 fail2ban.actions.action: INFO
Set actionCheck = iptables -n -L INPUT | grep -q fail2ban-[name]
2007-11-28 19:01:00,896 fail2ban.actions: WARNING [ssh] Ban 124.121.118.234
2007-11-28 19:03:46,896 fail2ban.actions: WARNING [ssh] Ban 202.142.215.206

การ unban

root@bebian:/home/redcode# iptables -n -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-ssh tcp — 0.0.0.0/0 0.0.0.0/0 multiport dports 22,115

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain fail2ban-ssh (1 references)
target prot opt source destination
DROP 0 — 202.142.215.206 0.0.0.0/0
DROP 0 — 124.121.118.234 0.0.0.0/0
RETURN 0 — 0.0.0.0/0 0.0.0.0/0
แล้วจากนั้นก็ใส่ DROP iptables โดยระบุ IP ที่เราต้องการ DROP ไปซ่ะ

root@bebian:/home/redcode# iptables -D fail2ban-ssh -s 124.121.118.234 -j DROP
DROP แล้วทำการเช็คดู iptable ดูครับว่า IP ที่เรา DROP ไปนั้นออกไปยัง

root@bebian:/home/redcode# iptables -n -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-ssh tcp — 0.0.0.0/0 0.0.0.0/0 multiport dports 22,115

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain fail2ban-ssh (1 references)
target prot opt source destination
DROP 0 — 202.142.215.206 0.0.0.0/0
RETURN 0 — 0.0.0.0/0 0.0.0.0/0
สังเกตุได้ว่า IP 124.121.118.234 ออกไปจากระบบแล้วเพียงเท่านี้ก็สามารถ login ได้ปกติ

Linux : Alias

Set Command Alias for commands often used.

1. Apply to all users.

root@debian:~# vi /etc/profile

# last line: add aliases
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

root@debian:~# source /etc/profile # reload

2.Apply to a user

user@debian:~$ vi .bashrc

# last line: add aliases
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

user@debian:~$ source .bashrc # reload

3/23/2011

Hack

http://poc-hack.blogspot.com/

3/22/2011

Code Snippet

Add msn
msnim:add?contact=ใส่Emailของท่าน@hotmail.com