In order to manually change the timezone, you can edit
the /etc/sysconfig/clock
file and then make a new
soft link to /etc/localtime. Here is an
example of changing the timezone manually to "America/Denver":
1. Select the appropriate time zone from the /usr/share/zoneinfo directory. Time zone names
are relative to that directory. In this case, we will select "America/Denver"
2. Edit the /etc/sysconfig/clock
text file so that it looks
like this:
ZONE="America/Denver"
UTC=true
ARC=false
Of course, this assumes that your
hardware clock is running UTC time...
3. Delete
the following file: /etc/localtime
4. Create a new soft link for /etc/localtime.
Here is an example of step 3 and step 4:
# cd /etc
# ls -al localtime
lrwxrwxrwx 1 root root 39 Mar 28 07:00 localtime -> /usr/share/zoneinfo/America/Los_Angeles
# rm /etc/localtime
# ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
# ls -al localtime
lrwxrwxrwx 1 root root 34 Mar 28 08:59 localtime -> /usr/share/zoneinfo/America/Denver
# date
Fri Mar 28 09:00:04 MST 2003
Kinh Nghiệm Việt Nam - Thủ Thuật PC
Wednesday, April 18, 2012
Friday, March 16, 2012
How to secure your Kloxo for iptables
Stop iptables service:
iptables -t filter -A INPUT -p tcp -s SLAVE_IP --dport 7779 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -d SLAVE_IP --dport 7779 -j ACCEPT
Note: replace SLAVE_IP with your Slave server IP.
iptables -t filter -A INPUT -p tcp -s MASTER_IP --dport 7779 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -d MASTER_IP --dport 7779 -j ACCEPT
Note: replace MASTER_IP with your Master server IP.
/etc/init.d/iptables stop
Disable iptables service:
chkconfig iptables off
Disable iptables service:
chkconfig iptables off
Copy this code to /etc/init.d/firewall (Reminder: Disable "word wrap" in your text editor. Ex.: nano -w /etc/init.d/firewall)
#!/bin/sh
# firewall
# chkconfig: 3 21 91
# description: Starts, stops iptables firewall
case "$1" in
start)
# Clear rules
iptables -t filter -F
iptables -t filter -X
echo - Clear rules : [OK]
# SSH In
iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
echo - SSH : [OK]
# Don't break established connections
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
echo - established connections : [OK]
# Block all connections by default
iptables -t filter -P INPUT DROP
iptables -t filter -P FORWARD DROP
iptables -t filter -P OUTPUT DROP
echo - Block all connections : [OK]
# SYN-Flood Protection
iptables -N syn-flood
iptables -A syn-flood -m limit --limit 10/second --limit-burst 50 -j RETURN
iptables -A syn-flood -j LOG --log-prefix "SYN FLOOD: "
iptables -A syn-flood -j DROP
echo - SYN-Flood Protection : [OK]
# Loopback
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A OUTPUT -o lo -j ACCEPT
echo - Loopback : [OK]
# ICMP (Ping)
iptables -t filter -A INPUT -p icmp -j ACCEPT
iptables -t filter -A OUTPUT -p icmp -j ACCEPT
echo - PING : [OK]
# DNS In/Out
iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
echo - DNS : [OK]
# NTP Out
iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT
echo - NTP : [OK]
# FTP Out
iptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 30000:50000 -j ACCEPT
# FTP In
iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 30000:50000 -j ACCEPT
iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
echo - FTP : [OK]
# HTTP + HTTPS Out
iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
# HTTP + HTTPS In
iptables -t filter -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -t filter -A INPUT -p tcp --dport 443 -j ACCEPT
echo - HTTP/HTTPS : [OK]
# Mail SMTP:25
iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
echo - SMTP : [OK]
# Mail POP3:110
iptables -t filter -A INPUT -p tcp --dport 110 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 110 -j ACCEPT
echo - POP : [OK]
# Mail IMAP:143
iptables -t filter -A INPUT -p tcp --dport 143 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 143 -j ACCEPT
echo - IMAP : [OK]
# Kloxo
iptables -t filter -A INPUT -p tcp --dport 7777:7778 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --dport 7777:7778 -j ACCEPT
echo - Kloxo : [OK]
echo - Firewall [OK]
exit 0
;;
stop)
echo "Stopping Firewall... "
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t filter -F
echo "Firewall Stopped!"
exit 0
;;
restart)
/etc/init.d/firewall stop
/etc/init.d/firewall start
;;
*)
echo "Usage: /etc/init.d/firewall {start|stop|restart}"
exit 1
;;
esac
chmod 700 /etc/init.d/firewall
add firewall service:
chkconfig --add firewall
auto start firewall:
chkconfig --level 2345 firewall on
start firewall:
/etc/init.d/firewall start
add firewall service:
chkconfig --add firewall
auto start firewall:
chkconfig --level 2345 firewall on
start firewall:
/etc/init.d/firewall start
If you have slave server, add this on the master
iptables -t filter -A INPUT -p tcp -s SLAVE_IP --dport 7779 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -d SLAVE_IP --dport 7779 -j ACCEPT
Note: replace SLAVE_IP with your Slave server IP.
Add this on slave server
iptables -t filter -A INPUT -p tcp -s MASTER_IP --dport 7779 -j ACCEPT
iptables -t filter -A OUTPUT -p tcp -d MASTER_IP --dport 7779 -j ACCEPT
Note: replace MASTER_IP with your Master server IP.
Thursday, March 15, 2012
Cron running job / script every 5 second
crontab -e
add this on your crontab
*/1 * * * * /scripts/5secondrotatorscript.sh
#! /bin/bash
LOGFILE=/root/username/logs/log_`date +%H%M%S`.log
x=60
while [ ${x} -gt 0 ]
do
/usr/bin/php /home/username/public_html/scripts/file.php >> $LOGFILE
x=$((x-5))
sleep 5
done
save as 5secondrotatorscript.sh
Chức năng NAT của iptables
iptables -t nat -A PREROUTING -p tcp --dport 80 -d 1.1.1.1 -i eth0 -j DNAT --to 2.2.2.2:80
iptables -t nat -A POSTROUTING -p tcp --dport 80 -o eth0 -j SNAT --to 1.1.1.1
Ghi chú:
- 1.1.1.1 là IP address của eth0 trên reverse proxy, 2.2.2.2 là IP address của eth0 trên web-server.
- 2 lệnh này được chạy trên reverse proxy và chúng chỉ "redirect" traffic đến cổng 80, nếu bạn cần redirect traffic đến các cổng khác như 443 chẳng hạn, bạn phải thêm vào các lệnh tương ứng.
- Lệnh số 1 có tác dụng chuyển destination IP address (hence DNAT) của tất cả TCP packet đến cổng 80 của IP 1.1.1.1 thành cổng 80 của IP 2.2.2.2. Lệnh này nằm ở chain PREROUTING, nghĩa là nó được apply trước giai đoạn routing.
- Lệnh số 2 có tác dụng chuyển source IP address (hence SNAT) của tất cả TCP packet đi ra bằng đường eth0 có destination port là 80 thành 1.1.1.1. Lệnh này nằm ở chain POSTROUTING, nghĩa là nó được apply sau giai đoạn routing.
Giải thích:
1. client 3.3.3.3 gửi một packet (src=3.3.3.3, dst=1.1.1.1) đến reverse proxy 1.1.1.1
2. Lệnh thứ nhất sẽ chuyển packet này thành (src=3.3.3.3, dst=2.2.2.2).
3. Lệnh thứ hai sẽ chuyển packet này thành (src=1.1.1.1, dst=2.2.2.2).
3. Sau khi web-server 2.2.2.2 nhận được packet này, nó sẽ tạo ra một packet (src=2.2.2.2, dst=1.1.1.1) và gửi lại cho reverse proxy 1.1.1.1.
4. reverse proxy 1.1.1.1 sẽ nhìn vào NAT table của lệnh thứ hai để chuyển packet này thành (src=2.2.2.2, dst=3.3.3.3)
5. reverse proxy 1.1.1.1 tiếp tục nhìn vào NAT table của lệnh thứ nhất để chuyển packet này thành (src=1.1.1.1, dst=3.3.3.3)
6. reverse proxy 1.1.1.1 gửi packet (src=1.1.1.1, dst=3.3.3.3) lại cho client 3.3.3.3
iptables -t nat -A POSTROUTING -p tcp --dport 80 -o eth0 -j SNAT --to 1.1.1.1
Ghi chú:
- 1.1.1.1 là IP address của eth0 trên reverse proxy, 2.2.2.2 là IP address của eth0 trên web-server.
- 2 lệnh này được chạy trên reverse proxy và chúng chỉ "redirect" traffic đến cổng 80, nếu bạn cần redirect traffic đến các cổng khác như 443 chẳng hạn, bạn phải thêm vào các lệnh tương ứng.
- Lệnh số 1 có tác dụng chuyển destination IP address (hence DNAT) của tất cả TCP packet đến cổng 80 của IP 1.1.1.1 thành cổng 80 của IP 2.2.2.2. Lệnh này nằm ở chain PREROUTING, nghĩa là nó được apply trước giai đoạn routing.
- Lệnh số 2 có tác dụng chuyển source IP address (hence SNAT) của tất cả TCP packet đi ra bằng đường eth0 có destination port là 80 thành 1.1.1.1. Lệnh này nằm ở chain POSTROUTING, nghĩa là nó được apply sau giai đoạn routing.
Giải thích:
1. client 3.3.3.3 gửi một packet (src=3.3.3.3, dst=1.1.1.1) đến reverse proxy 1.1.1.1
2. Lệnh thứ nhất sẽ chuyển packet này thành (src=3.3.3.3, dst=2.2.2.2).
3. Lệnh thứ hai sẽ chuyển packet này thành (src=1.1.1.1, dst=2.2.2.2).
3. Sau khi web-server 2.2.2.2 nhận được packet này, nó sẽ tạo ra một packet (src=2.2.2.2, dst=1.1.1.1) và gửi lại cho reverse proxy 1.1.1.1.
4. reverse proxy 1.1.1.1 sẽ nhìn vào NAT table của lệnh thứ hai để chuyển packet này thành (src=2.2.2.2, dst=3.3.3.3)
5. reverse proxy 1.1.1.1 tiếp tục nhìn vào NAT table của lệnh thứ nhất để chuyển packet này thành (src=1.1.1.1, dst=3.3.3.3)
6. reverse proxy 1.1.1.1 gửi packet (src=1.1.1.1, dst=3.3.3.3) lại cho client 3.3.3.3
Wednesday, March 14, 2012
Apache 2.2.x security tricks (CentOS) - Bảo vệ an toàn cho apache 2.2.x
Install httpd-devel and gcc:
Download this modules (you'll need the .c files)
mod_allowmethods: http://www.apachelounge.com/viewtopic.php?t=4238
mod_antiloris: http://sourceforge.net/projects/mod-antiloris/
mod_reqtimeout: https://github.com/apache/httpd/blob/2.2.x/modules/filters/mod_reqtimeout.c
Upload those files to your server (secure ftp via ssh port should be a good way to do so).
Build and install the modules
apxs -cia mod_allowmethods.c
apxs -cia mod_antiloris.c
apxs -cia mod_reqtimeout.c
Go to /etc/httpd/conf.d and add a file named 3rdparty.conf with:
TraceEnable Off
Please note that LimitRequestBody will disallow uploading/posting more than 8MB (8388608 bytes) but for most websites it should be ok.
$ service httpd fullstatus | grep antiloris mod_antiloris/0.4
yum install httpd-devel gcc
Download this modules (you'll need the .c files)
mod_allowmethods: http://www.apachelounge.com/viewtopic.php?t=4238
mod_antiloris: http://sourceforge.net/projects/mod-antiloris/
mod_reqtimeout: https://github.com/apache/httpd/blob/2.2.x/modules/filters/mod_reqtimeout.c
Upload those files to your server (secure ftp via ssh port should be a good way to do so).
Build and install the modules
apxs -cia mod_allowmethods.c
apxs -cia mod_antiloris.c
apxs -cia mod_reqtimeout.c
Go to /etc/httpd/conf.d and add a file named 3rdparty.conf with:
TraceEnable Off
TraceEnable Off
<Directory />
LimitRequestBody 8388608
<IfModule allowmethods_module>
AllowMethods GET HEAD OPTIONS POST
</IfModule>
</Directory>
<IfModule antiloris_module>
IPReadLimit 20
</IfModule>
<IfModule reqtimeout_module>
RequestReadTimeout header=20-40,MinRate=500 body=20,MinRate=500
</IfModule>
Please note that LimitRequestBody will disallow uploading/posting more than 8MB (8388608 bytes) but for most websites it should be ok.
$ service httpd fullstatus | grep antiloris mod_antiloris/0.4
Tuesday, March 13, 2012
Install mod_security in Kloxo (Lxadmin) on Centos 5.3
First of all make sure you switched the default webserver to Apache2. This can be done in the Kloxo admin console under the Server > Switch server tab.
Retrieve the mod_security binary for your platform. You can find detailed information here, but below are the key steps assuming you're running a Centos 5.3 VPS.
1. Validate the packages by installing the GPG key:
rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
2. Add the following to your '/etc/sysconfig/rhn/sources' file:
yum utterramblings http://www.jasonlitka.com/media/EL5/$ARCH
3. Type:
vi /etc/yum.repos.d/utterramblings.repo
... and then paste the following into the editor:
[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
4. Update your yum repository by typing yum update and accepting the update. This might take a bit of time depending on when you did your last update.
5. Install modsecurity by typing: yum install mod_security
6. Restart the Apache webserver: service httpd restart.
That's it!
Note that a default ruleset is included and activated during the installation. If you want to edit the configuration, the following can be useful:
/etc/httpd/conf.d: all files in this directory are loaded during Apache startup
/etc/httpd/conf.d/mod_security.conf: default configuration loading the mod_security module and the default rule set
/etc/httpd/modsecurity.d: default rule set
Tham khao: http://www.clientcentral.info/knowledgebase.php?action=displaycat&catid=1015
Tuesday, March 6, 2012
Dùng iptables để band IP
Liệt kê tất cả các IP đang band
/etc/init.d/iptables status
- Band một IP
iptables -A INPUT -s 123.42.168.250 -j DROP
iptables -A OUTPUT -p tcp -d 123.42.168.250 -j DROP
Lệnh trên để band IP tức thời thôi, khi restart lại service iptables, thì tất cả các IP đã band sẽ mất
Nếu muốn không mất ta phải save nó lại
/etc/init.d/iptables save
[root@ns ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
2 DROP all -- 112.213.95.11 0.0.0.0/0
3 DROP all -- 123.42.168.250 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 DROP tcp -- 0.0.0.0/0 112.213.95.11
2 DROP tcp -- 0.0.0.0/0 123.42.168.250
Để remove IP đã band, ta phải xác định IP band đang ở num mấy
[root@ns ~]# iptables -D INPUT 2
[root@ns ~]# iptables -D OUTPUT 1
Các lệnh view log
iptables -L INPUT -v -n --line-numbers
iptables -L OUTPUT -v -n --line-numbers
Có thể dùng lệnh sau để drop
iptables -D INPUT -s 113.161.207.117 -j DROP
/etc/init.d/iptables status
- Band một IP
iptables -A INPUT -s 123.42.168.250 -j DROP
iptables -A OUTPUT -p tcp -d 123.42.168.250 -j DROP
Lệnh trên để band IP tức thời thôi, khi restart lại service iptables, thì tất cả các IP đã band sẽ mất
Nếu muốn không mất ta phải save nó lại
/etc/init.d/iptables save
[root@ns ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
2 DROP all -- 112.213.95.11 0.0.0.0/0
3 DROP all -- 123.42.168.250 0.0.0.0/0
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 DROP tcp -- 0.0.0.0/0 112.213.95.11
2 DROP tcp -- 0.0.0.0/0 123.42.168.250
Để remove IP đã band, ta phải xác định IP band đang ở num mấy
[root@ns ~]# iptables -D INPUT 2
[root@ns ~]# iptables -D OUTPUT 1
Các lệnh view log
iptables -L INPUT -v -n --line-numbers
iptables -L OUTPUT -v -n --line-numbers
Có thể dùng lệnh sau để drop
iptables -D INPUT -s 113.161.207.117 -j DROP
Friday, February 24, 2012
Thanh toán và Rút tiền từ tài khoản Paypal ở Việt Nam
Có lẽ nhiều bạn đã biết về Paypal cũng như công dụng và hạn chế của nó. Nếu ai chưa biết thì mình giới thiệu sơ qua về Paypal. Paypal là 1 cổng thanh toán trực tuyến phổ biến thế giới và hiện nay có rất nhiều website cho phép thanh toán trực tuyến thông qua tài khoản Paypal để mua hàng trên mạng. Paypal sẽ giúp lên kết đến số tiền có trong các tài khoản ngân hàng (Band Account), thẻ tín dụng (Credit Card), thẻ ghi nợ (Debit Card)… để tiến hành các giao dịch.
Theo xu thế tiến bộ của thời đại thì việc thanh toán trực tuyến là điều khó tránh khỏi, vậy tại sao không tạo 1 tài khoản Paypal ngay từ bây giờ để dùng cho các giao dịch trực tuyến sau này. Ở các nước tiến bộ, Paypal cho phép người dùng gởi tiền vào để mua sắm hoặc rút tiền ra từ số tiền trong Paypal (dành cho những người buôn bán trên mạng) để có tiền mặt sử dụng.
Đối với Việt Nam, với danh hiệu “lỗ đen Internet” lẫy lừng nên việc Paypal không cho phép tài khoản ở Việt Nam rút tiền là điều không lấy làm lạ ^^. Tuy nhiên, do sức ép cùng với nhu cầu mở rộng giao dịch trực tuyến nên cách đây mấy tháng thì các tài khoản Paypal Việt Nam đã có thể rút tiền được từ tài khoản Paypal rồi. Đồng nghĩa với việc bạn có thể nhận tiền hoặc kinh doanh trực tuyến thông qua tài khoản Paypal.
Sau 1 thời gian kiểm nghiệm, mua sắm, xin tiền vô tài khoản và rút tiền thành công từ paypal với tài khoản ở Việt Nam, nay mình viết bài này nhằm chia sẽ tới các bạn những kinh nghiệm trong việc sử dụng paypal để mua sắm, buôn bán Online mà không sợ ràng buộc như trước. Bài này mình sẽ tập trung vào 1 số trọng điểm chính sau:
1> Tạo tài khoản paypal ở Việt Nam
2> Verify địa chỉ Email cho tài khoản Paypal.
3> Đăng ký thẻ VISA Debit để giao dịch.
4> Kết hợp & Xác nhận thẻ vào tài khoản Paypal để thực hiện các giao dịch.
5> Một Hóa đơn minh họa thanh toán thành công bằng tài khoản Paypal.
6> Rút tiền ngược từ tài khoản Paypal về thẻ để sử dụng.
1> Tạo tài khoản paypal ở Việt Nam
![]() |
| Hình 1-1: Nhấn vào liên kết Sign Up để đăng ký tài khoản paypal |
![]() |
| Hình 1-2: Chọn quốc gia Việt Nam và loại tài khoản bạn cần tạo. Có thể tạo Personal để mua hàng. Loại tài khoản này bạn có thể thay đổi sau cũng được. Nhấn nút Get Started để bắt đầu. |
2> Verify địa chỉ Email cho tài khoản Paypal
![]() |
| Hình 2-1: Sau khi đăng ký tài khoản thì Paypal sẽ gởi 1 email với nội dung như trên. Trong email sẽ có phần mã xác nhận (là 20 chữ số) trong phần CONFIRMATION CODE. |
![]() |
Hình 2-3: Nhấn vào liên kết mà mũi tên màu đỏ chỉ, để tới trang nhập mã xác nhận mà bạn nhận được trong email.
|
![]() |
| Hình 2-4: Nhập mã xác nhận trong email vào đây rồi nhấn Confirm |
![]() |
| Hình 2-5: Nếu mã xác nhận bạn nhập là hợp lệ thì bạn sẽ thông báo là đã xác nhận email thành công. Các bước tiếp theo chúng ta sẽ tiến hành liên kết thẻ ngân hàng vào tài khoản Paypal |
3> Đăng ký thẻ VISA Debit để giao dịch.
![]() |
| Hình 3-2: Hình dạng thẻ VISA Debit của ACB phát hành. Một số thông tin bạn cần biết đó là: Mã thẻ (16 chữ số), tên chủ tài khoản, ngày hết hạn và mã an toàn để tiến hành các giao dịch. |
![]() |
Hình 3-3: Nếu bạn có tài khoản do bên ngân hàng cấp thì có thể login tại trang acb.com.vn để vào xem tình trạng thẻ.
|
4> Kết hợp & Xác nhận thẻ vào tài khoản Paypal để thực hiện các giao dịch
![]() |
| Hình 4-4: Email Paypal đưa các chỉ dẫn các bước Xác nhận tài khoản VISA của bạn. |
5> Một Hóa đơn minh họa thanh toán thành công bằng tài khoản Paypal
6> Rút tiền ngược từ tài khoản Paypal về thẻ để sử dụng
Nếu bạn muốn rút tiền từ PayPal balance thì đầu tiên bạn phải chuyển tiền từ PayPal balance vào tài khoản VISA Debit của bạn, sau đó chỉ cần ra ATM của ACB rút thôi, cũng không phức tạp lắm. Mình sẽ hướng dẫn các bạn.![]() |
| Hình 6-1: Bạn nhấn vào liên kết Withdraw trong trang My Account như trên. |
![]() |
| Hình 6-2: Tới đây bạn nhấn vào liên kết mà mũi tên chỉ. |
.
—————–
Như vậy là mình đã hướng dẫn khá chi tiết những bước giúp các bạn
tận dụng Paypal như là 1 công cụ đắc lực hỗ trợ cho các giao dịch trực
tuyến
Tuesday, February 14, 2012
how to install memcached
Install memcached
Cách 1: Cài và chạy bằng tay
Here's a quick recipe for installing memcached on EC2 Amazon Linux AMI 1.0.
yum install gcc libevent libevent-devel cd /usr/local/src wget http://memcached.org/latest tar -xf memcached-*.tar.gz cd memcached-* ./configure make && make install
/usr/local/bin/memcached -u root -d
netstat -anp | grep 11211ps aux | grep memcached
pkill memcached
Cách 2: Cài và chạy service
Going all out - building a memcached rpm
If you're installing memcached on multiple machines then having an RPM handy is preferred. Make sure to run this as the ec2-user and not root.
cd ~
sudo yum install gcc libevent libevent-devel rpm-build perl-Test-Base
echo "%_topdir /home/ec2-user/rpmbuild" >> ~/.rpmmacros
mkdir -p /home/ec2-user/rpmbuild/{SPECS,BUILD,SRPMS,RPMS,SOURCES}
wget http://memcached.org/latest
rpmbuild -ta memcached-*.tar.gz
The RPM will be created in ~/rpmbuild/RPMS/x86_64/ or ~/rpmbuild/RPMS/i386/ depending on whether you chose a 32 or 64 bit AMI. Copy the rpm to your home directory and run the command below to install memcached to /usr/bin/memcache
sudo yum localinstall memcached-*.rpm --nogpgcheck
The beauty of this approach is that you can now do the following to start or stop memcached
And finally you can enable memcached at startup with this simple command:service memcached status service memcached start service memcached stop
chkconfig memcached on
Install php-pecl-memcache
#if apt-get, rpm, or yum doesn't work
cd /usr/src/
wget http://pecl.php.net/get/memcache-2.2.4.tgz
tar -zxvf memcached-2.2.4.tgz
cd memcached-2.2.4
phpize && ./configure --enable-memcache && make
cp modules/memcache.so /usr/lib/php/modules/
# Note: packaged extension modules are now loaded via the .ini files
# found in the directory php.ini
php -i | grep php.ini
vi /etc/sysconfig/memcached
PORT=”11211″ #define on which port to urnadd php.ini
USER=”nobody” #same as apache user
MAXCONN=”1024″ #maximum number of connections allowed
CACHESIZE=”64″ #memory used for caching
OPTIONS=”" #use for any custom options
extension="memcache.so"restart service https
/etc/init.d/httpd restart
Note: Neu bi loi can install cac goi
yum install php-develCheck memcache
yum install zlib-devel
yum install zlib zlib-devel
php -i | grep memcache
[root@dedi94125 ~]# more testmemcach.php
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211);
print_r($memcache);
?>
[root@dedi94125 ~]# php testmemcach.php
Memcache Object
(
[connection] => Resource id #5
)
[root@dedi94125 ~]#
Thursday, February 2, 2012
Learn how to Sniff Wireless Passwords with Pirni (Man in the Middle Attack)
The thing about the iPod Touch and the iPhone is that they are
great portable hacking devices. To the naked eye the iPod Touch/iPhone
looks like nothing more than an ordinary mp3 player/cellphone however
that is just an understatement to its full potential. Once your iPod
Touch/iPhone is jailbroken you have access to your whole file system
meaning that applications generally associated with laptop/desktop hacking can be ported and used on the iPod Touch/iPhone. This opens up a whole lot of possibilities for network sniffing, port scanning and much much more! In this tutorial we are going to take a look at one of these programs called Pirni.

Step 1) - The first thing you are going to need to do is install a program called Mobile Terminal on your iPod Touch/iPhone. This program is available through cydia, so open up cydia and type in terminal into the search tab. Once you find Mobile Terminal on your search Results install it to your iPod Touch/iPhone.
Step 2) - Once you have installed terminal the next application
you are going to install is Pirni. Type pirni into the search tab and
once it appears on your search results click it and install it to your
iPod Touch/iPhone. Once Pirni installs you will have installed
everything you need to begin sniffing wireless networks…
Step 3) - Before you launch terminal and begin sniffing you will need a few pieces of information on your wireless network; the network’s
ip address and the router’s ip address. You can find out this
information by launching Settings and clicking Wifi then clicking on
the arrow next to Your wireless network’s Name. Once you find the
information you are looking for which is the IP Address and the Router
IP Address write it down on a piece of paper so you remember it.
Step 4) - Now that you have the required
information you are ready to begin the process of sniffing with Pirni.
The first thing you need to do is open up Terminal; so do this now by
finding Terminal on your springboard and clicking it to launch it. **Note Terminal sometimes takes a few times to actually load. If you click the Terminal application
and it opens and closes then simply click it again until it fully
launches. Once you get Terminal up and Running you are going to need to
login as a a root user to gain full access to your iPod Touch/iPhone.
Type in the following commands and please note they are all case sensitive so copy them exactly as shown…
Once you have gained root access continue to step 5…
Step 5) - Once you are logged in as the root user you can begin using Pirni. To initiate Pirni you are going to need to enter in a line of commands replacing whats in red with your network specific information.
-s: Specifies the IP-adress you want to spoof, this is where the Router IP Address goes.
-d: Specifies the target you want to perform MITM on, this is where the IP Address of your network goes.
-f: Specifies the Berkley Packet Filter so that pirni only collects interesting packets. This is very good if you want to filter out specific packets – such as FTP, SMTP or HTTP. If no -f options is supplied, all packets will be captured.
-o: Specifies the dumpfile where all the collected packets end up. This is a pcap dump format, that most traffic analyzers can handle.
Once you enter the Commands Pirni will initiate and begin collecting
packets. A packet is a formatted unit of data carried by a packet mode computer network.
For example, every Web page that you receive comes as a series of
packets, and every e-mail you send leaves as a series of packets. Pirni
collects these packets and records them into a readable dump file that
can be analyized at a later date on your computer. In order for Pirni to
collect something interesting you are going to need to visit a website
that doesnt use an ssl encrypted connection. Leave your iPod Touch or
iPhone alone collecting packets and go to a website that doesn’t use an
ssl encrypted connection and login to that website. An example of this
kind of website would be Hawkee.com
this website does not use an ssl encrypted connection while handling
logins. If you want to test out Pirni to see if you can get a password
register an account up with Hawkee.com and login to your account while you are sniffing your network. Once you are done scanning the network drag your finger across the screen in a diagnol direction and this will stop pirni correctly. **Note it is important to close pirni this way to avoid errors while analyzing your dump file later on.
Step 1) - Download openssh to your iPodTouch/iPhone by going into Cydia and typing in openssh into the search panel. Once you see openssh on the search results click it and install open ssh. Once open ssh has been installed exit cydia and continue to step 2…
Step 2) - The next thing you need to do is install a program called winscp to your computer. This program will allow you to take files off your iPod Touch/iPhone with an easy to use GUI (Graphical User Interface).
Step 3) - Once Winscp has finished installing double click the winscp.exe to launch the program. You will be presented with a window like the one depicted below…
Once you get Winscp up and running you are going to need to enter in some information into Winscp. The first thing you need to enter is the Host name which is your networks IP Address. This is the Address that you wrote down earlier you can find it inside Settings > Wifi >Your Network Name Tab. The next thing you need to enter is the Username this is always left as root. The last piece of information you need to enter in is the password the default password if you haven’t changed it is alpine. If you have changed your password then enter your current password in the password field now.
Once you enter in the required information click the Login Button. The first time you login it will take awhile to load just be patient and wait it can take up to five minutes. The first time you login you will also get a warning message that will appear simply hit the ok button to the warning message. When you succesfully login click the / button on the top right hand corner of the screen…
Once you click the / Button (Which is the Root Directory Shortcut) the next thing you are going to do is click the User file directory as shown below. This is where all your dump files are saved and stored through Pirni…
Once you are inside the User File Directory you should now see your log file. Drag the Log file to your Desktop and then Exit Winscp as you are now done using the program. Winscp is a useful program if you need to access your iPod Touch/iPhones internal File Structure. Now that you know how to use Winscp you can use this useful program anytime you want.
Step 4) - Now that your Log File has been successfully transferred to your computer you are now going to need to download an application that will analyze the dump file called WireShark.
Step 5) - Now that WireShark is installed double click the WireShark.exe on your Desktop to start the program. Once the Program is up and running you are going to need to open your log file. Click the Open Button in the middle of the screen and then locate your log file which should be on your Desktop.
Once you locate your Dump file and load it into WireShark you will now see a screen with a bunch of packets displayed. These are all the Packets that you captured while you were sniffing your network. If you have never seen packets before all of this information will mean nothing to you and seem confusing. If you research a little bit online about packets you will find these packets are a lot more interesting however if you are new to this whole thing then the search tool will be your friend. Click the Magnifying glass on the top of the screen and it will bring up a search window.
Once the Search window comes up you will be presented with three options Display Filter, Hex Value and String. Click the String Option and then type in password into the search field and click the Find Button. The Search Tool is a great tool to find interesting information in your dump file. With the search tool it will quickly scan through all your packets and will find a match to what you are searching for. It defiantly beats looking through hundreds of packets till you find something interesting. With the search tool you can simply type in keywords that would be of interest to you like password,username,login,email and it will try to find a match. **Note not all dump files will contain interesting information like passwords,usernames etc… It all depends on what users connected to the network you are scanning are doing.
Once you click the find button you will be directed to the packet that contains the password string or the string that you typed into the search field. If you look at what is highlight you can see that you have successfully found the username and password to your hawkee.com account. If this was performed on an unknown network you would have successfully sniffed a password that you can then do what you want with. WireShark is a very powerful tool for analyzing packets if you go to their Website you can learn a lot about packets and other analyzing techniques not discussed on this tutorial.
As you can see your iPod Touch or iPhone can be transformed into a powerful password sniffing device. With Pirni you can have a powerful password sniffing program hidden within your iPod Touch/iPhone. You can have your morning coffee at starbucks while sniffing its wireless network without anyone knowing or suspecting a thing. There are many other useful hacking programs on the iPod Touch/iPhone, and I will write more tutorials for programs like Ngrep and TCP Dump in the future if enough interest is given. As always if you require any help with this tutorial please feel free to post your questions/comments in the comments section below.
What is Pirni?
Pirni is an application that was ported to The Ipod Touch/iPhone to be used as a native network sniffer. Pirni is so useful because it gets past the iPod Touch’s/iPhone’s wifi hardware limitation of not being able to be set into promiscious mode (a mode that allows a network device to intercept and read each network packet that arrives in its entirety). To get past this limitation Pirni comes with an ARP spoofer that successfully routes all the network traffic through your iPod Touch/iPhone, records it to a dump file and then uses packet forwarding to send it to it’s normal recipent (ie. the router). What this basically means in simpler terms is that all the traffic on a specific network comes through your iPod Touch/iPhone before it reaches the router. This meaning that if we sniff the network long enough, another user connected to the network could enter in an unencrypted password and you could then retrieve that password after looking through your dump file.
Using Pirni
Pirni is an application that does not have a GUI (Graphical User Interface) and it requires a program called Terminal to run and be used. Terminal is basically an application that allows you to give your iPod Touch/iPhone simple commands. Below I am going to go through the steps of installing and using Pirni… **Note this is a technical tutorial and is not recommended for users new to computers. Please also note that this tutorial is for educational purposes only. It is illegal to sniff a wireless network that is not your own. Use and Follow this Tutorial at your own Risk.Step 1) - The first thing you are going to need to do is install a program called Mobile Terminal on your iPod Touch/iPhone. This program is available through cydia, so open up cydia and type in terminal into the search tab. Once you find Mobile Terminal on your search Results install it to your iPod Touch/iPhone.
su
alpine (alpine is the default password. If you have not changed your password then use alpine)
Step 5) - Once you are logged in as the root user you can begin using Pirni. To initiate Pirni you are going to need to enter in a line of commands replacing whats in red with your network specific information.
-s: Specifies the IP-adress you want to spoof, this is where the Router IP Address goes.
-d: Specifies the target you want to perform MITM on, this is where the IP Address of your network goes.
-f: Specifies the Berkley Packet Filter so that pirni only collects interesting packets. This is very good if you want to filter out specific packets – such as FTP, SMTP or HTTP. If no -f options is supplied, all packets will be captured.
-o: Specifies the dumpfile where all the collected packets end up. This is a pcap dump format, that most traffic analyzers can handle.
iphone4s:~ root# more get.sh
pirni -s 192.168.1.1 -o log.pcap pirni -s 192.168.1.1 -d 192.168.1.189 -f "tcp dst port 80" -o log.pcap pirni -i en1 -s 192.168.1.1 -d 255.255.255.0 -o log.pcap iphone4s:~ root# |
Analyzing your Dump File
Now that you have sniffed the packets on your network you now have to analyze the dump file created by Pirni. To do this you will need to get the dump file off your iPodTouch/iPhone by using a program called Winscp. This program allows you to access the files on your iPodTouch/iPhone. To use this program you will need two things; open ssh installed on your iPodTouch/iPhone and Winscp installed on your computer…Step 1) - Download openssh to your iPodTouch/iPhone by going into Cydia and typing in openssh into the search panel. Once you see openssh on the search results click it and install open ssh. Once open ssh has been installed exit cydia and continue to step 2…
Download Winscp Here
Once Winscp Downloads to your computer install it by following the easy to use steps of the installer…Step 3) - Once Winscp has finished installing double click the winscp.exe to launch the program. You will be presented with a window like the one depicted below…
Once you get Winscp up and running you are going to need to enter in some information into Winscp. The first thing you need to enter is the Host name which is your networks IP Address. This is the Address that you wrote down earlier you can find it inside Settings > Wifi >Your Network Name Tab. The next thing you need to enter is the Username this is always left as root. The last piece of information you need to enter in is the password the default password if you haven’t changed it is alpine. If you have changed your password then enter your current password in the password field now.
Once you enter in the required information click the Login Button. The first time you login it will take awhile to load just be patient and wait it can take up to five minutes. The first time you login you will also get a warning message that will appear simply hit the ok button to the warning message. When you succesfully login click the / button on the top right hand corner of the screen…
Once you click the / Button (Which is the Root Directory Shortcut) the next thing you are going to do is click the User file directory as shown below. This is where all your dump files are saved and stored through Pirni…
Once you are inside the User File Directory you should now see your log file. Drag the Log file to your Desktop and then Exit Winscp as you are now done using the program. Winscp is a useful program if you need to access your iPod Touch/iPhones internal File Structure. Now that you know how to use Winscp you can use this useful program anytime you want.
Step 4) - Now that your Log File has been successfully transferred to your computer you are now going to need to download an application that will analyze the dump file called WireShark.
Download WireShark Here
With WireShark successfully downloaded to your computer double click the setup.exe and install it to your computer. When it asks you if you want to install WinPcap click no because you will not need this functionality while analyzing your dump file.Step 5) - Now that WireShark is installed double click the WireShark.exe on your Desktop to start the program. Once the Program is up and running you are going to need to open your log file. Click the Open Button in the middle of the screen and then locate your log file which should be on your Desktop.
Once you locate your Dump file and load it into WireShark you will now see a screen with a bunch of packets displayed. These are all the Packets that you captured while you were sniffing your network. If you have never seen packets before all of this information will mean nothing to you and seem confusing. If you research a little bit online about packets you will find these packets are a lot more interesting however if you are new to this whole thing then the search tool will be your friend. Click the Magnifying glass on the top of the screen and it will bring up a search window.
Once the Search window comes up you will be presented with three options Display Filter, Hex Value and String. Click the String Option and then type in password into the search field and click the Find Button. The Search Tool is a great tool to find interesting information in your dump file. With the search tool it will quickly scan through all your packets and will find a match to what you are searching for. It defiantly beats looking through hundreds of packets till you find something interesting. With the search tool you can simply type in keywords that would be of interest to you like password,username,login,email and it will try to find a match. **Note not all dump files will contain interesting information like passwords,usernames etc… It all depends on what users connected to the network you are scanning are doing.
Once you click the find button you will be directed to the packet that contains the password string or the string that you typed into the search field. If you look at what is highlight you can see that you have successfully found the username and password to your hawkee.com account. If this was performed on an unknown network you would have successfully sniffed a password that you can then do what you want with. WireShark is a very powerful tool for analyzing packets if you go to their Website you can learn a lot about packets and other analyzing techniques not discussed on this tutorial.
As you can see your iPod Touch or iPhone can be transformed into a powerful password sniffing device. With Pirni you can have a powerful password sniffing program hidden within your iPod Touch/iPhone. You can have your morning coffee at starbucks while sniffing its wireless network without anyone knowing or suspecting a thing. There are many other useful hacking programs on the iPod Touch/iPhone, and I will write more tutorials for programs like Ngrep and TCP Dump in the future if enough interest is given. As always if you require any help with this tutorial please feel free to post your questions/comments in the comments section below.
Subscribe to:
Posts (Atom)









































