Tuesday, November 26, 2013

Test send mail: command


Test SMTP relay

Testing SMTP relay is very easy, and simply requires a small change to the above commands. See below:
telnet mydomain 25
ehlo mydomain.com
mail from:<martin9700@mydomain.com>
rcpt to:<recipient@someotherdomain.com>
data
This is a test, please do not respond
.
quit

Ref: spicework

Thursday, October 3, 2013

terminal server client ubuntu badatom

สร้าง short cut ตามภาพด้านล่าง

command: rdesktop -u administrator -g 1024x768 -n REMOTE5-13 192.168.5.13

Maximize/Minimize : Ctrl+Alt+Enter




Tuesday, September 24, 2013

Recover Passwd Administrator windows server 2008

คัดลอกมาจาก Thaiadmin 

คู่มือแก้ไขปัญหากรณีลืม Password Windows 2008 R2 X64
อ้างอิงจากกระทู้เก่า http://www.thaiadmin.org/board/index.php?topic=150314.0
เนื่องจาก like รูปและไฟล์หายไปไหนไม่รู้

วัน นึงไซต์งานของลูกค้าผมเค้ารายงานว่าเค้าไม่สามารถ login ระบบได้ด้วย password ของตนเอง งานเข้าหล่ะครับจะต้องทำอย่างไรดี ผมจึงหาคำตอบให้แก้ไขดังนี้
เผื่อว่าจะเป็นประโยชน์กับเพื่อนๆ ผมจึงเขียนบทความนี้ไว้เผื่อคนที่เจอปัญหาเหมือนกันจะได้ไม่เสียเวลาล้าง ระบบลงใหม่กันให้ยุ่งยาก เพราะว่า Windows 2008 นี่รักษาความปลอดภัยสุดๆ แต่ก็ไม่วายโดนผม Hack ระบบจนได้ เหอะๆ จะอะไรมากกับการไปเปลี่ยน password Admin ตามนี้เลยครับ ค่อยๆอ่าน ค่อยๆทำตาม ทุกขั้นตอนเลยนะครับ

1. ให้ใช้แผ่นตั้ง Windows Server 2008 R2 X64 สั่งให้ New install System ใหม่


2. เลือกเมนู Repair your computer 


3. เลือก Next> ตามรูป


4. เลือกเมนู Command Prompt


5. มีโปรแกรม Dos ขึ้นมาให้หา Drive ที่มี Windows ให้เจอ


6. จากตัวอย่าง Drive D: เป็น Drive ที่ลง System ไว้สังเกตได้จาก Folder  มี Windows
-------------------------------------------------------------------------------------------------------------------------------
d:
cd Windows
cd System32
move Utilman.exe Utilman.exe.bak   (copy ไฟล์โปรแกรมไว้ก่อนทุกครั้งเผื่อมีอะไรผิดพลาด)
copy cmd.exe Utilman.exe
-------------------------------------------------------------------------------------------------------------------------------

เสร็จแล้วให้ Restart


7. ให้คลิ๊กเข้าเมนู icon Utilman ซึ่งเมื่อกี้นี้เราได้แปลงโปรแกรมให้เป็น Dos ไปเรียบร้อยแล้ว


8. จะมีโปรแกรม Dos ขึ้นมาทีนี้เราก็สามารถใช้คำสั่งเพิ่ม User เพิ่ม Group ได้ตามต้องการแล้ว


9. ให้พิมพ์คำสั่งต่อจากนี้ลงไป
net user admin2 P@ssw0rd /add
net localgroup administrators admin2 /add



10. จากในรูปจะมี User admin2 ขึ้นมาตามคำสั่ง Dos ที่ใช้เมื่อก่อนหน้านี้


11. สามารถตรวจสอบสิทธิ์ของ User ใหม่ที่สร้างขึ้นว่าได้อยู่ใน Group administrators ตามที่ต้องการแล้วใช่หรือไม่ สำหรับ Password ของ Administrator ที่ลืมก็สามารถแก้ไขได้เลยครับ


12. เรียบร้อยแล้วอย่าลืมเข้าไปแก้ไข ไฟล์ cmd.exe และ Utilman.exe , Utilman.exe.bak ให้กลับมาเหมือนเดิมด้วยนะครับ
เข้าไปแก้ไขที่ C:\Windows\System32\

Download เป็นไฟล์ PDF เผื่อจะมีเพื่อนๆ เอาไปทำเอกสารส่งหัวหน้างาน ได้ที่นี่
http://www.upload-thai.com/download.php?id=f9f4e4d3a5d163a074f087a32545250d

ถ้าทำไม่ได้อย่างไร
โทรติดต่อ WhatsApp , Line : กิตติณัฐต์ 0808079933
Email : kittinut.jun@hotmail.com
ตำแหน่งงาน System Engineer Network
(อ่านแล้วขอบคุณขอให้ร่ำรวย)


Monday, September 23, 2013

Remove & Install Java 7

Check version java
#java -version

Uninstall old java version
#apt-get remove openjdk*

Install Oracle java
#dd-apt-repository ppa:webupd8team/java
#apt-get update
#pt-get install oracle-java7-installer

And Check version again
#java -version

Ref.
Youtube


Tuesday, September 17, 2013

ตรวจสอบว่าไอพีไหนอยู่ที่ไหน?

      ในการเชื่อมอินเตอร์เน็ตคุณจะต้องเกาะไอพี Public 1 เบอร์ ออกสู่โลกออนไลน์ ซึ่งจะได้จาก Net 3G, Net cafe', Net ADSL(hom,office) ... ซึ่งเราจะนำไอพีดังกล่าวไป Trace หา Latitude, Logtitude แล้วใช้ Google Earth ค้นหาว่าคุณอยู่ที่ไหน?
       ในการเช็คไอพี Publice ให้เปิดเว็บไซต์ http://www.ip-adress.com มันจะแสดงไอพีที่คุณเชื่อมต่ออินเตอร์เน็ตขึ้นมาทันที และยังแสดงตำแหน่งบนโลก(ค่า Loti,Long)
       แนะนำเว็บไซต์ http://www.maxmind.com สำหรับค้นหาค่า loti,logt...

Friday, August 30, 2013

Install SPF Record


www.howtoforge.com/postfix_spf

www.openspf.org

www.openspf.org

http://kb.gfi.com

10. Install and Configure SPF


Install:apt-get install postfix-policyd-spf-python -y
vi /etc/postfix/master.cf
and add the following stanza at the end:

policy-spf  unix  -       n       n       -       -       spawn      
 user=nobody argv=/usr/bin/policyd-spf 
 
*Note:  (The leading spaces before user=nobody are important so that Postfix knows that this line belongs to the previous one!)
*Note: We already added the entry for main.cf using the postfix setup script.

Then restart Postfix:
 /etc/init.d/postfix restart

That's it already.

Monday, August 26, 2013

Update GeoIP Database

Update GeoIP Database

chage permission /var/www/mailscanner/temp to 775 and chage owner root:www-data





Friday, August 23, 2013

config https


ทำตามลิ้งค์ www.howtoforge.com

vim /etc/apache2/sites-available/default-ssl



        ServerAdmin webmaster@localhost
        ServerName www.domain.co.th:443
        DocumentRoot /var/www

--------------------------------------------------------------------
** อย่าลืม  a2ensite default-ssl


ปิด http
vim /etc/apache2/ports.conf
#NameVirtualHost *:80
#Listen 80

Thursday, August 22, 2013

Cron [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete

ไม่ต้องการมัน ให้ลบบรรทัดนี้ออก

# configuration for php MING module

จากไฟล์

PHP Deprecated:  Comments starting with '#' are deprecated in
/etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
PHP Deprecated:  Comments starting with '#' are deprecated in
/etc/php5/cli/conf.d/ps.ini on line 1 in Unknown on line 0

Wednesday, August 21, 2013

install driver D-Link DWA-525 A2 on Ubuntu 12.04



Ref: mtotschn.blogspot.com

D-Link DWA-525 A2 on Ubuntu 12.04

Trying to make a newly bought D-Link Wireless N 150 PCI Desktop Adapter DWA-525 A2 work under Ubuntu 12.04 (precise). References like this blog post that refer to drivers from the Ralinktech website do not work for the A2 version of the device. You can find out, what version you have through

lspci |grep -i ralink

which for the A2 should give:

05:03.0 Network controller: Ralink corp. Device 5360 

Wikidevi references a patch to the rt2800pci module (part of the rt2x00 driver) but I found no explanation on how to apply this to a Ubuntu 12.04, and it took some time to find out. The patch seems to apply to Kernel 3.4, but Precise uses 3.2. Ubuntuforums has a thread on the topic and one posting explains how to patch a download of compat-wireless for kernel 2.6 manually.

Instead of going that route, I wanted to give the patch for the 3.4. version a try, and on the way document a solution that would be easier to reproduce. The compat-wireless releases can be found at http://wireless.kernel.org/en/users/Download/stable/ , the patch is linked from http://rt2x00.serialmonkey.com/pipermail/users_rt2x00.serialmonkey.com/2012-May/004942.html . Putting that together:

wget http://rt2x00.serialmonkey.com/pipermail/users_rt2x00.serialmonkey.com/attachments/20120507/e2072201/attachment.bin
wget http://www.orbit-lab.org/kernel/compat-wireless-3-stable/v3.4/compat-wireless-3.4-rc3-1.tar.bz2
tar -xjf compat-wireless-3.4-rc3-1.tar.bz2
cd  compat-wireless-3.4-rc3-1
patch -p1 <../attachment.bin
./scripts/driver-select rt2x00
make
sudo make install
sudo make unload
sudo modprobe rt2800pci

With this, the card should be recognized and start to work. I suspect that the compilation of the module has to be redone each time, the kernel is upgraded.

Tuesday, August 20, 2013

Monday, August 19, 2013

Block ไม่ให้ใช้ Flash driver, Haddis External ในอูบันตู 12.04 - 13.04

1. ตรวจสอบ version ubuntu : uname -a

 Linux moyoon-desktop 3.2.0-51-generic-pae #77-Ubuntu SMP Wed Jul 24 20:40:32 UTC 2013 i686 i686 i386 GNU/Linux

2. Disable storage ดังนี้

mv /lib/modules/3.x.x-xx-generic-pae/kernel/drivers/usb/storage /lib/modules/3.x.x-xx-generic-pae/kernel/drivers/usb/storage_disable

 แล้วรีบู๊ดเครื่อง 1 ครั้ง

3. สำหรับวิธีง่าย ๆ ที่สุดหากไม่ต้องการทำขั้นตอนที่ 1-2 ให้เปลี่ยน permission /media เป็น 700 ดังนี้
#chmod 700 /media
และหากต้องการใช้งานเหมือนเดิม
#chmod 755 /media

Ref.ubuntuclub.com

Friday, August 16, 2013

ค้นหาชื่อคอมพิวเตอร์ด้วย IP Address ภายใน Network (Linux)

REF. askubuntu.com


To find a hostname in your local network by IP address you can use:
nmblookup -A 
To find a hostname on the internet you could use the host program:
host 
Or you can install nbtscan by running:
sudo apt-get install nbtscan
And use:
nbtscan 

++

$ hostnamectl
$ ifconfig eth0 | grep inet

Wednesday, August 14, 2013

การเดินทางจากบ้าน - บางปะกง

เริ่ม ระยะทาง 99.1
1. ระยะทางจากบ้านบางใหญ่ถึงด่านเก็บเงินพระราม 3(ทางด่วน)   41  KM. ค่าทางด่วน  45B.
2. รับบัตรทางด่วนบางนาด่านที่สอง ระยะทาง 59 KM.
3. แยกลงทางด่วนพระราม 2 ถ.กาญจนาภิเษก ระยะทาง 61 KM. เลยด่านเก็บเงินบางนามาอีกสองกิโลเมตร
4. ต่อไปเป็นทางไปสนามบินสุวรรณภูมิ
5. ระยะทางที่ 91 KM. ลงทางด่วนบางวัว ค่าทางด่วน 45B.
6. ระยะทางที่ 95 KM. ปั้มน้ำมันบางจาก
7. ระยะทางที่ 99.1 KM. ถึงบริษัทศิริวัฒนา


กลับระยะทาง 109
1. จากบริษัทถึงแยกพระราม 2 ถ.กาญจนา  41 KM.
2. จาก ถ.กาญจนาถึงบ้าน 68 KM.

Tuesday, August 13, 2013

30 command Nmap

Ref: www.cyberciti.biz

Special 

Scan host only online
sudo nmap -sn 192.168.1.0/24 -oG - | awk '$4=="Status:" && $5=="Up" {print $0}'|column -t

#1: Scan a single host or an IP address (IPv4)

### Scan a single ip address ###
nmap 192.168.1.1
 
## Scan a host name ###
nmap server1.cyberciti.biz
 
## Scan a host name with more info###
nmap -v server1.cyberciti.biz
 
Sample outputs:
Fig.01: nmap output
Fig.01: nmap output

#2: Scan multiple IP address or subnet (IPv4)

nmap 192.168.1.1 192.168.1.2 192.168.1.3
## works with same subnet i.e. 192.168.1.0/24
nmap 192.168.1.1,2,3
You can scan a range of IP address too:
nmap 192.168.1.1-20
You can scan a range of IP address using a wildcard:
nmap 192.168.1.*
Finally, you scan an entire subnet:
nmap 192.168.1.0/24

#3: Read list of hosts/networks from a file (IPv4)

The -iL option allows you to read the list of target systems using a text file. This is useful to scan a large number of hosts/networks. Create a text file as follows:
cat > /tmp/test.txt
Sample outputs:
server1.cyberciti.biz
192.168.1.0/24
192.168.1.1/24
10.1.2.3
localhost
The syntax is:
nmap -iL /tmp/test.txt

#4: Excluding hosts/networks (IPv4)

When scanning a large number of hosts/networks you can exclude hosts from a scan:
nmap 192.168.1.0/24 --exclude 192.168.1.5
nmap 192.168.1.0/24 --exclude 192.168.1.5,192.168.1.254
OR exclude list from a file called /tmp/exclude.txt
nmap -iL /tmp/scanlist.txt --excludefile /tmp/exclude.txt

#5: Turn on OS and version detection scanning script (IPv4)

nmap -A 192.168.1.254
nmap -v -A 192.168.1.1
nmap -A -iL /tmp/scanlist.txt 

#6: Find out if a host/network is protected by a firewall

nmap -sA 192.168.1.254
nmap -sA server1.cyberciti.biz

#7: Scan a host when protected by the firewall

nmap -PN 192.168.1.1
nmap -PN server1.cyberciti.biz

#8: Scan an IPv6 host/address

The -6 option enable IPv6 scanning. The syntax is:
nmap -6 IPv6-Address-Here
nmap -6 server1.cyberciti.biz
nmap -6 2607:f0d0:1002:51::4
nmap -v A -6 2607:f0d0:1002:51::4

#9: Scan a network and find out which servers and devices are up and running

This is known as host discovery or ping scan:
nmap -sP 192.168.1.0/24
Sample outputs:
Host 192.168.1.1 is up (0.00035s latency).
MAC Address: BC:AE:C5:C3:16:93 (Unknown)
Host 192.168.1.2 is up (0.0038s latency).
MAC Address: 74:44:01:40:57:FB (Unknown)
Host 192.168.1.5 is up.
Host nas03 (192.168.1.12) is up (0.0091s latency).
MAC Address: 00:11:32:11:15:FC (Synology Incorporated)
Nmap done: 256 IP addresses (4 hosts up) scanned in 2.80 second

#10: How do I perform a fast scan?

nmap -F 192.168.1.1

#11: Display the reason a port is in a particular state

nmap --reason 192.168.1.1
nmap --reason server1.cyberciti.biz

#12: Only show open (or possibly open) ports

nmap --open 192.168.1.1
nmap --open server1.cyberciti.biz

#13: Show all packets sent and received

nmap --packet-trace 192.168.1.1
nmap --packet-trace server1.cyberciti.biz

14#: Show host interfaces and routes

This is useful for debugging (ip command or route command or netstat command like output using nmap)
nmap --iflist
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 02:01 IST
************************INTERFACES************************
DEV    (SHORT)  IP/MASK          TYPE        UP MAC
lo     (lo)     127.0.0.1/8      loopback    up
eth0   (eth0)   192.168.1.5/24   ethernet    up B8:AC:6F:65:31:E5
vmnet1 (vmnet1) 192.168.121.1/24 ethernet    up 00:50:56:C0:00:01
vmnet8 (vmnet8) 192.168.179.1/24 ethernet    up 00:50:56:C0:00:08
ppp0   (ppp0)   10.1.19.69/32    point2point up
 
**************************ROUTES**************************
DST/MASK         DEV    GATEWAY
10.0.31.178/32   ppp0
209.133.67.35/32 eth0   192.168.1.2
192.168.1.0/0    eth0
192.168.121.0/0  vmnet1
192.168.179.0/0  vmnet8
169.254.0.0/0    eth0
10.0.0.0/0       ppp0
0.0.0.0/0        eth0   192.168.1.2
 

#15: How do I scan specific ports?

map -p [port] hostName
## Scan port 80
nmap -p 80 192.168.1.1
 
## Scan TCP port 80
nmap -p T:80 192.168.1.1
 
## Scan UDP port 53
nmap -p U:53 192.168.1.1
 
## Scan two ports ##
nmap -p 80,443 192.168.1.1
 
## Scan port ranges ##
nmap -p 80-200 192.168.1.1
 
## Combine all options ##
nmap -p U:53,111,137,T:21-25,80,139,8080 192.168.1.1
nmap -p U:53,111,137,T:21-25,80,139,8080 server1.cyberciti.biz
nmap -v -sU -sT -p U:53,111,137,T:21-25,80,139,8080 192.168.1.254
 
## Scan all ports with * wildcard ##
nmap -p "*" 192.168.1.1
 
## Scan top ports i.e. scan $number most common ports ##
nmap --top-ports 5 192.168.1.1
nmap --top-ports 10 192.168.1.1
 
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 01:23 IST
Interesting ports on 192.168.1.1:
PORT     STATE  SERVICE
21/tcp   closed ftp
22/tcp   open   ssh
23/tcp   closed telnet
25/tcp   closed smtp
80/tcp   open   http
110/tcp  closed pop3
139/tcp  closed netbios-ssn
443/tcp  closed https
445/tcp  closed microsoft-ds
3389/tcp closed ms-term-serv
MAC Address: BC:AE:C5:C3:16:93 (Unknown)
 
Nmap done: 1 IP address (1 host up) scanned in 0.51 seconds
 

#16: The fastest way to scan all your devices/computers for open ports ever

nmap -T5 192.168.1.0/24

#17: How do I detect remote operating system?

You can identify a remote host apps and OS using the -O option:
 
nmap -O 192.168.1.1
nmap -O  --osscan-guess 192.168.1.1
nmap -v -O --osscan-guess 192.168.1.1
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 01:29 IST
NSE: Loaded 0 scripts for scanning.
Initiating ARP Ping Scan at 01:29
Scanning 192.168.1.1 [1 port]
Completed ARP Ping Scan at 01:29, 0.01s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 01:29
Completed Parallel DNS resolution of 1 host. at 01:29, 0.22s elapsed
Initiating SYN Stealth Scan at 01:29
Scanning 192.168.1.1 [1000 ports]
Discovered open port 80/tcp on 192.168.1.1
Discovered open port 22/tcp on 192.168.1.1
Completed SYN Stealth Scan at 01:29, 0.16s elapsed (1000 total ports)
Initiating OS detection (try #1) against 192.168.1.1
Retrying OS detection (try #2) against 192.168.1.1
Retrying OS detection (try #3) against 192.168.1.1
Retrying OS detection (try #4) against 192.168.1.1
Retrying OS detection (try #5) against 192.168.1.1
Host 192.168.1.1 is up (0.00049s latency).
Interesting ports on 192.168.1.1:
Not shown: 998 closed ports
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http
MAC Address: BC:AE:C5:C3:16:93 (Unknown)
Device type: WAP|general purpose|router|printer|broadband router
Running (JUST GUESSING) : Linksys Linux 2.4.X (95%), Linux 2.4.X|2.6.X (94%), MikroTik RouterOS 3.X (92%), Lexmark embedded (90%), Enterasys embedded (89%), D-Link Linux 2.4.X (89%), Netgear Linux 2.4.X (89%)
Aggressive OS guesses: OpenWrt White Russian 0.9 (Linux 2.4.30) (95%), OpenWrt 0.9 - 7.09 (Linux 2.4.30 - 2.4.34) (94%), OpenWrt Kamikaze 7.09 (Linux 2.6.22) (94%), Linux 2.4.21 - 2.4.31 (likely embedded) (92%), Linux 2.6.15 - 2.6.23 (embedded) (92%), Linux 2.6.15 - 2.6.24 (92%), MikroTik RouterOS 3.0beta5 (92%), MikroTik RouterOS 3.17 (92%), Linux 2.6.24 (91%), Linux 2.6.22 (90%)
No exact OS matches for host (If you know what OS is running on it, see http://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=5.00%D=11/27%OT=22%CT=1%CU=30609%PV=Y%DS=1%G=Y%M=BCAEC5%TM=50B3CA
OS:4B%P=x86_64-unknown-linux-gnu)SEQ(SP=C8%GCD=1%ISR=CB%TI=Z%CI=Z%II=I%TS=7
OS:)OPS(O1=M2300ST11NW2%O2=M2300ST11NW2%O3=M2300NNT11NW2%O4=M2300ST11NW2%O5
OS:=M2300ST11NW2%O6=M2300ST11)WIN(W1=45E8%W2=45E8%W3=45E8%W4=45E8%W5=45E8%W
OS:6=45E8)ECN(R=Y%DF=Y%T=40%W=4600%O=M2300NNSNW2%CC=N%Q=)T1(R=Y%DF=Y%T=40%S
OS:=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%R
OS:D=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=
OS:0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=N)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID
OS:=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=S)
Uptime guess: 12.990 days (since Wed Nov 14 01:44:40 2012)
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=200 (Good luck!)
IP ID Sequence Generation: All zeros
Read data files from: /usr/share/nmap
OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 12.38 seconds
           Raw packets sent: 1126 (53.832KB) | Rcvd: 1066 (46.100KB)
See also: Fingerprinting a web-server and a dns server command line tools for more information.

#18: How do I detect remote services (server / daemon) version numbers?

nmap -sV 192.168.1.1
Sample outputs:
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 01:34 IST
Interesting ports on 192.168.1.1:
Not shown: 998 closed ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     Dropbear sshd 0.52 (protocol 2.0)
80/tcp open  http?
1 service unrecognized despite returning data.

#19: Scan a host using TCP ACK (PA) and TCP Syn (PS) ping

If firewall is blocking standard ICMP pings, try the following host discovery methods:
nmap -PS 192.168.1.1
nmap -PS 80,21,443 192.168.1.1
nmap -PA 192.168.1.1
nmap -PA 80,21,200-512 192.168.1.1

#20: Scan a host using IP protocol ping

nmap -PO 192.168.1.1

#21: Scan a host using UDP ping

This scan bypasses firewalls and filters that only screen TCP:
nmap -PU 192.168.1.1
nmap -PU 2000.2001 192.168.1.1

#22: Find out the most commonly used TCP ports using TCP SYN Scan

 
### Stealthy scan ###
nmap -sS 192.168.1.1
 
### Find out the most commonly used TCP ports using  TCP connect scan (warning: no stealth scan)
###  OS Fingerprinting ###
nmap -sT 192.168.1.1
 
### Find out the most commonly used TCP ports using TCP ACK scan
nmap -sA 192.168.1.1
 
### Find out the most commonly used TCP ports using TCP Window scan
nmap -sW 192.168.1.1
 
### Find out the most commonly used TCP ports using TCP Maimon scan
nmap -sM 192.168.1.1
 

#23: Scan a host for UDP services (UDP scan)

Most popular services on the Internet run over the TCP protocol. DNS, SNMP, and DHCP are three of the most common UDP services. Use the following syntax to find out UDP services:
nmap -sU nas03
nmap -sU 192.168.1.1
Sample outputs:
 
Starting Nmap 5.00 ( http://nmap.org ) at 2012-11-27 00:52 IST
Stats: 0:05:29 elapsed; 0 hosts completed (1 up), 1 undergoing UDP Scan
UDP Scan Timing: About 32.49% done; ETC: 01:09 (0:11:26 remaining)
Interesting ports on nas03 (192.168.1.12):
Not shown: 995 closed ports
PORT     STATE         SERVICE
111/udp  open|filtered rpcbind
123/udp  open|filtered ntp
161/udp  open|filtered snmp
2049/udp open|filtered nfs
5353/udp open|filtered zeroconf
MAC Address: 00:11:32:11:15:FC (Synology Incorporated)
 
Nmap done: 1 IP address (1 host up) scanned in 1099.55 seconds
 

#24: Scan for IP protocol

This type of scan allows you to determine which IP protocols (TCP, ICMP, IGMP, etc.) are supported by target machines:
nmap -sO 192.168.1.1

#25: Scan a firewall for security weakness

The following scan types exploit a subtle loophole in the TCP and good for testing security of common attacks:
 
## TCP Null Scan to fool a firewall to generate a response ##
## Does not set any bits (TCP flag header is 0) ##
nmap -sN 192.168.1.254
 
## TCP Fin scan to check firewall ##
## Sets just the TCP FIN bit ##
nmap -sF 192.168.1.254
 
## TCP Xmas scan to check firewall ##
## Sets the FIN, PSH, and URG flags, lighting the packet up like a Christmas tree ##
nmap -sX 192.168.1.254
 
See how to block Xmas packkets, syn-floods and other conman attacks with iptables.

#26: Scan a firewall for packets fragments

The -f option causes the requested scan (including ping scans) to use tiny fragmented IP packets. The idea is to split up the TCP header over
several packets to make it harder for packet filters, intrusion detection systems, and other annoyances to detect what you are doing.
nmap -f 192.168.1.1
nmap -f fw2.nixcraft.net.in
nmap -f 15 fw2.nixcraft.net.in
## Set your own offset size with the --mtu option ##
nmap --mtu 32 192.168.1.1

#27: Cloak a scan with decoys

The -D option it appear to the remote host that the host(s) you specify as decoys are scanning the target network too. Thus their IDS might report 5-10 port scans from unique IP addresses, but they won't know which IP was scanning them and which were innocent decoys:
nmap -n -Ddecoy-ip1,decoy-ip2,your-own-ip,decoy-ip3,decoy-ip4 remote-host-ip
nmap -n -D192.168.1.5,10.5.1.2,172.1.2.4,3.4.2.1 192.168.1.5

#28: Scan a firewall for MAC address spoofing

 
### Spoof your MAC address ##
nmap --spoof-mac MAC-ADDRESS-HERE 192.168.1.1
 
### Add other options ###
nmap -v -sT -PN --spoof-mac MAC-ADDRESS-HERE 192.168.1.1
 
 
### Use a random MAC address ###
### The number 0, means nmap chooses a completely random MAC address ###
nmap -v -sT -PN --spoof-mac 0 192.168.1.1
 

#29: How do I save output to a text file?

The syntax is:
nmap 192.168.1.1 > output.txt
nmap -oN /path/to/filename 192.168.1.1
nmap -oN output.txt 192.168.1.1

#30: Not a fan of command line tools?

Try zenmap the official network mapper front end:
Zenmap is the official Nmap Security Scanner GUI. It is a multi-platform (Linux, Windows, Mac OS X, BSD, etc.) free and open source application which aims to make Nmap easy for beginners to use while providing advanced features for experienced Nmap users. Frequently used scans can be saved as profiles to make them easy to run repeatedly. A command creator allows interactive creation of Nmap command lines. Scan results can be saved and viewed later. Saved scan results can be compared with one another to see how they differ. The results of recent scans are stored in a searchable database.
You can install zenmap using the following apt-get command:
$ sudo apt-get install zenmap
Sample outputs:
[sudo] password for vivek:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  zenmap
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 616 kB of archives.
After this operation, 1,827 kB of additional disk space will be used.
Get:1 http://debian.osuosl.org/debian/ squeeze/main zenmap amd64 5.00-3 [616 kB]
Fetched 616 kB in 3s (199 kB/s)
Selecting previously deselected package zenmap.
(Reading database ... 281105 files and directories currently installed.)
Unpacking zenmap (from .../zenmap_5.00-3_amd64.deb) ...
Processing triggers for desktop-file-utils ...
Processing triggers for gnome-menus ...
Processing triggers for man-db ...
Setting up zenmap (5.00-3) ...
Processing triggers for python-central ...
Type the following command to start zenmap:
$ sudo zenmap
Sample outputs
Fig.02: zenmap in action
Fig.02: zenmap in action

Wednesday, August 7, 2013

Ubuntu 13.04 -- New install skype and anather software

 ==For Tweak Tool===========================

 ======================================= 

For install skype
-----------------------------------------------ii---------------------------------------------------







============uu============oo============


-----------------------Install Adobe acrobat------------------------------------------






Install adobe flash player on ubuntu 13.04

Press ALT + CTR + T to open terminal and type the below commands . Step 1 » Issue the below command to add and enable canonical repository. krizna@ubuntu13:~$ sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner" Step 2 » Type the below command to update repository and install adobe flash player . krizna@ubuntu13:~$ sudo apt-get update && sudo apt-get install flashplugin-installer Step 3 » After installation . Open firefox browser and goto http://www.adobe.com/software/flash/about/ to test your installation.

Manual installation

» Goto http://get.adobe.com/flashplayer/otherversions/
» Choose your OS architect EG: Linux 32-bit on Step 1
» Choose Flash Player 11.2 (tar.gz) on Step 2 and download the file
» Extract the downloaded file .
» Launch Terminal (Ctrl+Alt+T).
» goto to extracted folder and copy/move the libflashplayer.so to /usr/lib/firefox-addons/plugins
krizna@ubuntu13:~$ sudo mv libflashplayer.so /usr/lib/firefox-addons/plugins

www.krizna.com 







For another software

www.noobslab.com

Wednesday, July 31, 2013

How to disable USB port on Ubuntu

ปิดไม่ให้ใช้อุปกรณ์ USB port สำหรับ H/D external, Flash drive แต่ยังคงใช้อุปกรณ์เมาส์ คีย์บอร์ด USB ได้

For a permanent solution edit /etc/modprobe.d/blacklist and add following line:

  blacklist usb_storage
-------------------------------------------------------------------------------------------------------------------

then save and reboot.

สำหรับ Ubuntu 12.04 - 13.04 ใช้วิธีนี้ block-flash-driver-haddis-external

www.makeuseof.com

Monday, July 29, 2013

Set Postfix with SSL Port 465, 587

แก้ไข #vi /etc/postfix/master.cf

เพิ่มเข้าไปในไฟล์ดังกล่าว

## Enable SMTP on port 587 only for authenticated/TLS clients
submission inet n       -       n       -       -       smtpd
  -o smtpd_enforce_tls=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

## Enable SMTP on port 465 only for authenticated/SSL clients
smtps     inet  n       -       n       -       -       smtpd
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
   
Restart Service postfix 
 
Ref.
www.brandonchecketts.com 

new link: PostfixAndSASL




Command to test smtps
#openssl s_client -connect mymailserver:myport
#openssl s_client -connect mailserver:465


Ref. testing-smtps-certificate

 
ถ้าเจอ Err. SASL authentication failure: cannot connect to saslauthd server: No such file or directory 

ให้แก้ไขดังนี้
--------------------------------------------------- 
rm -r /var/run/saslauthd/
mkdir -p /var/spool/postfix/var/run/saslauthd
ln -s /var/spool/postfix/var/run/saslauthd /var/run
chgrp sasl /var/spool/postfix/var/run/saslauthd
adduser postfix sasl
---------------------------------------------------
อ้างอิง www.jimmy.co.at 
 
 

Setup Postfix on debian

Read Link

perfect-server-debian-squeeze-ispconfig-2-p4


ตัวอย่างไฟล์ postfix config

cat /etc/postfix/main.cf
##################################################################
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = /usr/share/doc/postfix

# TLS parameters
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

myhostname = pop3.sirivatana.co.th
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = pop3.sirivatana.co.th, localhost.sirivatana.co.th, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 10.10.10.222
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
html_directory = /usr/share/doc/postfix/html
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
home_mailbox = Maildir/
#######################################################################

Set dovecot with SSL port 995,993

Install Dovecot
Dovecot is POP3/IMAP server which needs MTA like Postfix to work properly.
#aptitude install dovecot-imapd dovecot-pop3d dovecot-common
Dovecot configuration file is located at: /etc/dovecot/dovecot.conf
Before we proceed we need to make some changes with dovecot configuration file. Double check the following entries in the file if the values are entered properly.
Edit the dovecot configuration file using the following command

Edit /etc/dovecot/dovecot.conf file

#vi /etc/dovecot/dovecot.conf
protocols = imap imaps pop3 pop3s
# uncomment this and change to no.
disable_plaintext_auth = no
pop3_uidl_format = %08Xu%08Xv

# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before
# dropping root privileges, so keep the key file unreadable by anyone but
# root.
ssl_cert_file = /etc/ssl/certs/dovecot.pem
ssl_key_file = /etc/ssl/private/dovecot.pem

Look for the line that starts with auth default, before that insert the lines below.

auth default {
mechanisms = plain login
passdb pam {
}
userdb passwd {
}
socket listen {
client {
path = /var/spool/postfix/private/auth
mode = 0660
user = postfix
group = postfix
}
}
}
Now, rename previous auth default to auth default2. If you dont rename this then dovecot server will give you error like multiple instances of auth default.


Now, create a user to test our pop3 mail with outlook:
#adduser user_name
Note: Always create a separate user to test your mail or ftp.
Restart Dovecot using the following command
#/etc/init.d/dovecot restart

Ref.
www.debianadmin.com


create a self-signed SSL certificate for the Dovecot

openssl req -new -x509 -days 1000 -nodes -out "/etc/ssl/certs/dovecot.pem" -keyout "/etc/ssl/private/dovecot.pem"

cd /etc/ssl/private
# chown root:dovecot dovecot.pem
# chmod 440 dovecot.pem
# cd /etc/ssl/certs
# chown root:dovecot dovecot.pem
# chmod 440 dovecot.pem

 Ref.
paulschreiber.com 

Postfix Autorespon mail

Set auto reply mail on postfix

www.howtoforge.com

Source Debian 6, 7.5

Source list debain 6

deb http://ftp.th.debian.org/debian/ squeeze main contrib non-free
deb-src http://ftp.th.debian.org/debian/ squeeze main contrib non-free

ตัวนี้ใช้ได้ สำหรับ Debain 6.0.10
** deb http://archive.debian.org/debian/ squeeze contrib main non-free **

Source Liste debian 7.5 Wheezy
# /etc/apt/sources.list :
deb http://ftp.th.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.th.debian.org/debian/ wheezy main contrib non-free


Ref
how-to.linuxcareer.com

Remove exim4

วิธีลบโปรแกรมเมล Exim4
1. aptitude search ~i~nexim   แสดงโปรแกรม exim4 มีอะไรบ้าง?
2. aptitude purge ~i~nexim    ลบโปรแกรม exim4


อ้างอิง
forums.debian.net 

Tuesday, July 2, 2013

Cron [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete

วิธีการปิด Cron ดังกล่าวให้แก้ไข 2 ไฟล์คือ
1. /etc/php5/cli/conf.d/ming.ini
ลบบรรทัดแรก # configuration for php MING module ออกไป

2. /etc/php5/cli/conf.d/ps.ini
 ลบบรรทัดแรก # configuration for php ps module ออกไป


Monday, July 1, 2013

Script iptables on mail server

 root@smtp:/home/man# cat /etc/init.d/iptables

---------------------Begin-----------------------------------
 #!/bin/sh
#
# Firewall script for ChilliSpot
# A Wireless LAN Access Point Controller
#
# Uses $EXTIF (eth0) as the external interface (Internet or intranet) and
# $INTIF (eth1) as the internal interface (access points).
#
#
# SUMMARY
# * All connections originating from chilli are allowed.
# * Only ssh is allowed in on external interface.
# * Nothing is allowed in on internal interface.
# * Forwarding is allowed to and from the external interface, but disallowed
#   to and from the internal interface.
# * NAT is enabled on the external interface.

IPTABLES="/sbin/iptables"
EXTIF="eth0"
INTIF="eth1"

$IPTABLES -F
$IPTABLES -F INPUT
$IPTABLES -F FORWARD
$IPTABLES -F OUTPUT

$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT ACCEPT

#Allow related and established on all interfaces (input)
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPTABLES -A INPUT -i lo -j ACCEPT
#$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT

#Block ip Spam with IP
$IPTABLES -A INPUT -s 41.203.64.0/24 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 41.203.64.131 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 41.203.64.132 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 41.203.64.133 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 41.203.64.134 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 41.203.64.135 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 67.15.76.50 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 186.82.169.236 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 122.164.34.182 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 89.123.161.227 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 208.83.136.12 -p tcp --dport 25 -j DROP
$IPTABLES -A INPUT -s 208.83.136.13 -p tcp --dport 25 -j DROP
curl -s http://www.spamhaus.org/drop/drop.lasso |grep ^[1-9]|cut -f 1 -d ' ' | xargs -iX -n 1 /sbin/iptables -A INPUT -s X -p tcp --dport 25 -j DROP

#Allow http and https on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp --dport 22 -i $EXTIF -m state --state NEW -m recent --set
$IPTABLES -A INPUT -p tcp --dport 22 -i $EXTIF -m state --state NEW -m recent --update --seconds 600 --hitcount 3 -j DROP
$IPTABLES -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 25 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 465 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 110 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 10000 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT

# Drop everything to and from $INTIF (forward)
$IPTABLES -A FORWARD -i lo -j ACCEPT

#Protect Syn Flood
$IPTABLES -N syn-flood
$IPTABLES -A syn-flood -i eth0 -m limit --limit 75/s --limit-burst 100 -j RETURN
$IPTABLES -A syn-flood -j LOG --log-prefix "SYN-FLOOD: "
$IPTABLES -A syn-flood -j DROP

-----------------//End//--------------------------------------

Run script boot up!

#update-rc.d iptables defaults

show iptables
#iptables -L --line-number
#iptables -S
#iptables -L -v

Save iptable
1. install package to autosave during install have a question choose Yes to save rule
aptitude install iptables-persistent

2. command: iptables-save

----For Centos----------พิมพ์คำสั่งด้านล่าง service ssh port 55001--------------------------------------
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 55001 --syn -j ACCEPT
iptables -A INPUT -p tcp --dport 55001 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --dport 55001 -m state --state NEW -m recent --update --seconds 600 --hitcount 3 -j DROP
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
-----------------------------------------------------------------------------

#For samba
iptables -A INPUT -p tcp -m tcp --dport 445 --syn -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 139 --syn -j ACCEPT


Ref: digitalocean
Ref: serverfault.com

Postfix flush mail

Flush mail

#postfix flush
#postfix -f
#postqueue -f

Delete queue mail
#postsuper -d ALL

delete by email
#postqueue -p | grep -v "^ " | grep "email@domain.com" | awk -F"* " '{ print $1}' | postsuper -d -

Ref: www.cyberciti.biz

View detail mail
#postcat -vq queuemailID

Ref: 5-top-tips-reviewing-postfix-mail-queue


postcat -v
43C811592800A
43C811592800A

Set Date & Time

#hwclock --show

#date

# hwclock --systohc
OR
# hwclock --systohc --utc
***** use the second option if you use UTC.

hwclock --set --date="09/21/2005 14:23:23"

Ref: geekride.com

อ้างอิงจากเว็บไซต์ voip4share.com

For CentOS 7

check date and time
#timedatectl
set date
#timedatectl set-time mm-dd-yyyy
set time
#timedatectl set-time hh:mm:ss
To configure your system to maintain the clock in the local time, use the following command:
#timedatectl set-local-rtc yes
To configure your system to use UTC, use the following command:
#timedatectl set-local-rtc no
to set sync NTP 
#timedatectl set-ntp yes
to set unsync NTP
#timedatectl set-ntp no

Ref.
https://www.thegeekdiary.com/centos-rhel-7-how-to-set-datetime-ntp-and-timezone-using-timedatectl/

วิธีการเซ็ตอัพ Hardware Clock และ System Time บน Linux

โพสต์โดย nuiz » 07 ก.ย. 2010 17:41
พอดีผมเพิ่งเซ็ต Time บนเครื่องเซอร์เวอร์เสร็จเมื่อกี้นี้ เลยเอาวิธีการต่างๆที่ผมได้ใช้ไปมาแชร์ให้ทราบกันครับ เพื่อต้องใช้สักวันหนึ่ง

จากบทความเรื่อง "การติดตั้ง NTP บน CentOS" เป็นการเซ็ตเวลา (Time) บน Linux โดยการดึงเวลามาจาก Time Server แต่บทความนี้ผมจะแนะนำวิธีการเซ็ต System Time โดยใช้คำสั่ง "date" และเซ็ต Hardware Clock โดยใช้คำสั่ง "hwclock"

ใน เครื่องคอมพิวเตอร์ทุกเครื่องที่เราใช้งานกันอยู่ทุกวันนี้นะครับ ไม่ว่าจะเป็น Windows หรือว่า Linux หรือว่า Mac หรือว่า OS อะไรก็แล้วแต่ จะมีเวลา (Time) อยู่ด้วยกัน 2 ส่วน คือ "เวลาที่เก็บอยู่ในฮาร์ดแวร์เครื่อง" ซึ่งก็คือ BIOS นั่นเองครับ บางคนก็เรียกเวลานี้ว่า "Hardware clock" หรือ "BIOS clock" หรือ "CMOS clock" นะครับ และจะมีแบ็ตเตอรี่แบ็คอัพไว้อยู่ ถ้าแบ็ตไม่เสื่อมหล่ะก็เวลาที่เซ็ตไว้ก็จะไม่หายไปไหนครับ

เวลาอีกส่วนหนึ่งเป็นเวลาที่ระบบปฏิบัติการในเครื่องใช้ครับ เรียกว่า "System clock" โดยเมื่อเราบู๊ตเครื่อง เจ้า OS ก็จะไปเช็คเวลาจาก Hardward clock แล้วเอามาทำเป็น "System clock"

กรณี ของระบบปฏิบัติการ Linux เราต้องเลือกว่าจะใช้ Hardward clock ในรูปแบบไหนระหว่าง "UTC/GMT time" หรือว่า "Local time" ผมแนะนำว่าควรเลือกเป็นแบบ "UTC/GMT time" ดีกว่านะครับ เพราะมันจะมีเรื่องของ DST (Daylight Saving Time) หรือการปรับเปลี่ยนเวลาเข้ามาเกี่ยวข้องด้วย เรื่องของเรื่องก็คือ ถ้าเราใช้แบบ UTC/GMT แล้วเซอร์เวอร์ของเราติดตั้งอยู่ในประเทศที่ต้องมีการปรับเวลาด้วย (DST) เช่นแถบประเทศสหรัฐอเมริกา ระบบก็จะปรับเวลาให้เองโดยอัตโนมัติ โดยเราไม่ต้องทำอะไร แต่ประเทศไทยไม่มี DST นะครับ ไม่ต้องมีการปรับเวลา

แต่ การเซ็ต Hardward clock ให้เป็นแบบ UTC/GMT ก็มีข้อเสียอยู่เหมือนกันนะครับ แต่ว่าไม่น่าจะมีผลต่อเรา ข้อเสียที่ว่าก็คือ ถ้าเราติดตั้ง Linux ด้วย และ DOS ด้วยบนเครื่องเดียวกัน เวลาบน DOS จะไม่ตรงเพราะ DOS ต้องการ Hardward clock แบบ Local time นะครับ

การเซ็ต Timezone
เรา เซ็ต Timezone บน Linux โดยการทำ Symbolic Link จาก /etc/localtime ไปยัง /usr/share/zoneinfo ซึ่งจะมีไดเร็คตอรีย่อยๆที่สอดคล้องกับ Timezone ที่เราอยู่ ยกตัวอย่างเช่น ผมอยู่ที่กรุงเทพ ประเทศไทย ผมต้องทำ Symbolic Link จาก /etc/localtime ไปยัง /usr/share/zoneinfo/Asia/Bangkok ด้วยคำสั่งนี้

โค้ด: เลือกทั้งหมด
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Bangkok /etc/localtime
การเซ็ต Hardware clock ให้อยู่ในรูปแบบ UTC/GMT time หรือ Local time
ใน ขณะที่ Linux กำลังบู๊ตเครื่อง งานอย่างหนึ่งของมันก็คือรันสคริปต์ /sbin/hwclock เพื่อก๊อบปี้เวลาใน Hardware clock แล้วนำไปใช้เป็น System clock โดยโปรแกรมสคริปต์ hwclock จะสมมติเอาว่า Hardware clock เซ็ตเป็นรูปแบบ Local time เว้นแต่ว่าเรารัน /sbin/hwclock และมี --utc ต่อท้ายด้วย แบบนี้นะครับ "/sbin/hwclock --utc" แต่การจะไปแก้ไขสคริปต์ก็ใช่ที่ ถ้าเราใช้ Red Hat หรือว่า CentOS ให้แก้ไขไฟล์ /etc/sysconfig/clockแทน แก้ไขบรรทัด UTC ให้เป็น true
โค้ด: เลือกทั้งหมด
UTC=true
แล้วเซฟไฟล์

การเซ็ต System Clock
บน Linux ใช้คำสั่ง date เช่น ถ้าต้องการเซ็ตวันที่และเวลาปัจจุบันให้เป็น 7 กันยายน 2010 เวลา 15:55:25 ก็ใช้คำสั่งนี้
โค้ด: เลือกทั้งหมด
date -s "09/07/2010 15:55:25"
มีเครื่องหมาย "" ด้วยนะครับ

การเช็คเวลาเวลาปัจจุบันบน Linux
ใช้คำสั่ง date ไม่ต้องมีอะไรต่อท้าย
โค้ด: เลือกทั้งหมด
date
การเซ็ต Hardware clock
ปกติวิธีการที่ผมใช้คือเซ็ต System Clock ก่อน จากนั้นค่อยเซ็ต Hardware clock จาก System clock โดยการรันคำสั่ง
เซ็ตในรูปแบบ Local time
โค้ด: เลือกทั้งหมด
/sbin/hwclock --systohc
เซ็ตในรูปแบบ UTC/GMT time
โค้ด: เลือกทั้งหมด
/sbin/hwclock --systohc --utc
เช็ค Hardware clock
โค้ด: เลือกทั้งหมด
hwclock
ถ้าเป็นแบบ UTC/GMT แล้วต้องการดูเวลาที่เทียบเท่ากับ Local time
โค้ด: เลือกทั้งหมด
hwclock --utc
ถ้าเวลาในโปรแกรมไม่ตรง
ถ้า เราใช้คำสั่ง date พบว่าเวลาตรง แต่โปรแกรมอื่นแสดงเวลาไม่ตรง แก้ไขโดยการสร้าง Symbolic Link จาก /usr/lib/zoneinfo ไปยัง /usr/share/zoneinfo
โค้ด: เลือกทั้งหมด
ln -s /usr/share/zoneinfo /usr/lib/zoneinfo

Ref: www.voip4share.com 

Configue MailScanner + MailWatch

1. หลังจาก configure เสร็จแล้ว ปรากฎว่าส่งเมลไป ไม่ได้รับแต่มันเข้าไปอยู่ที่ /var/spool/postfix/hold ให้แก้ไขไฟล์ /usr/sbin/MailScanner โดยเพิ่ม -U ในบรรทัดแรก ดังนี้

#!/usr/bin/perl -I/usr/share/MailScanner/ -U

อ้างอิง: bugs.launchpad.net

2. การเซทให้ mailscanner อ่านภาษาไทยได้
  
- การแก้ไข Apache โดย Set php.ini 2 จุดคือ
   1. #vim /etc/php5/apach2/php.ini
   2. #vim /etc/php5/cli/php.ini
    ใส่บรรทัดนี้เข้า default_charset = "TIS-620" หรือแก้ไขจากที่มีอยู่แล้ว restart service apache2

- แก้ไข mysql ไฟล์ /etc/mysql/my.cnf มี 3 จุดดังนี้
     [client] (ช่วงต้น)
port            = 3306
socket          = /var/run/mysqld/mysqld.sock
default-character-set=tis620

      # my edit (ช่วงกลาง) ตรงนี้ใส่เพิ่มเข้าไปเอง
default-character-set = tis620
collation-server = tis620_thai_ci
init-connect='SET NAMES TIS620'
character-set-server = tis620

      [mysql] (ช่วงท้าย)
#no-auto-rehash # faster start of mysql but no tab completition
default-character-set=tis620

       Restart servic mysql
     ต่อไปลบ Database ตัวเดิมทิ้ง และสร้างขึ้นมาใหม่ด้วย phpmyadmin และทำการ import database mailwatch เข้ามาใช้งาน

Import / Export Database





เมื่อได้ไฟล์ฐานข้อมูลแล้วก็โยนไฟล์ดังกล่าวเข้าไปยัง Server ดังนี้
scp Downloads/localhost.sql admin@192.168.xxx.x:/home/admin

ต่อก็ใช้คำสั่ง Import Database เข้าไป โดยเข้าไปยัง path ที่เราก็อปปี้ดาต้าเบสมา แล้วใช้คำสั่งดังนี้

** ให้ลบดาต้าเบสตัวเดิมออกก่อน Import database

mysql -uroot -p < localhost.sql
เสร็จแล้วเข้าไปสร้าง User เพื่อเข้าใช้งานฐานข้อมูล

mysql -u root -p
mysql> GRANT ALL ON mailscanner.* TO mailwatch@localhost IDENTIFIED BY 'mailwatchpassword';
mysql> quit

จบครับ.
เครดิตการ setup mailscaner mailwatch , Inport database opensource.cc.psu.ac.th

download mailwatch


Blacklists & Whiltelist

Edit file MailScanner_perl_scripts/SQLBlackWhiteList.pm

my($db_user) = ‘mailwatch’;
my($db_pass) = ‘password';

copy file SQLBlackWhiteList.pm to /etc/MailScanner/CustomFunctions/
#cp SQLBlackWhiteList.pm /etc/MailScanner/CustomFunctions/

edit /etc/MailScanner/MailScanner.conf

Is Definitely Not Spam = &SQLWhitelist
Is Definitely Spam = &SQLBlacklist
Always Looked Up Last = &MailWatchLogging


#service mailscanner restart



Tuesday, June 11, 2013

windows xp lock shared folder

       ต้องการกำหนดการแชร์แบบให้ Folder ใน Window XP แบบสามารถดูได้อย่างเดียว บาง Folder ให้เข้าใช้งานได้แบบ Full optoin
       วิธีการคือ
       ต้องเปิด User Guest ขึ้นมาแล้วกำหนด Passwd ให้ User Guest ดังนี้
       Start -> Run -> พิมพ์ Net user guest password แล้ว Enter

       แล้วเข้าไปกำหนด password guest แล้ว Reboot เครื่อง 1 ครั้ง

      Ref. lancelhoff.com

Friday, May 31, 2013

Sharing via Samba (Linux server - window client)

การเซทพริ้นให้เครื่อง windows เข้าไปแอดพริ้น ที่ Ubuntu ได้

/etc/samba/smb.conf
[ML1250]
    comment=Samsung ML-1250 Laser Printer
    printer=ml1250
    path=/var/spool/samba
    printing=cups
    printable=yes
    printer admin=@admin root yourusername
    user client driver=yes
    # to allow user 'guest account' to print.
    guest ok=no
    writable=no
    write list=@adm root yourusername
    valid users=@adm root yourusername 

# useradd yourusername
# smbpasswd -a yourusername
 
Ref. wiki.archlinux.org 

Thursday, May 30, 2013

แอดเครื่องพริ้นเตอร์ hp laserjet p1102w กับ ubuntu 12.04 (problem with hplip)

สำหรับการ Add printer ผ่าน Wireless

1. Set printer กับระบบ wireless ให้ได้ก่อน โดยต่อใช้ windows xp ใส่แผ่น Driver ที่มากับเครื่อง เลือกการเซทแบบแรก คือการ config wireless (เพื่อกำหนดไอพีให้กับเครื่องพริ้นเตอร์)
2. เมื่อเซทไอพีได้แล้ว สามารถนำไอพีดังกล่าวเข้าไปปรับค่าเซทติ้งต่าง ๆ เช่นการปรับไม่ให้ปิดเครื่องเมื่อไม่ใช้งาน วิธีเข้าไปปรับแต่ง ให้เปิด Browser (firefox, ie) แล้วเรียกด้วยไอพี เช่น 192.168.1.2

สำหรับการ Add Printer (Ubuntu)


ให้เซทด้วย ipp://ip:631/ipp

สำหรับ ubuntu 12.04 มีปัญหาไม่สามารถแอดด้วยวิธีดังกล่าวได้ เนื่องจาก Driver HPLIP เป็น 3.12.xx ให้อัพเดตเป็น 3.13.5 ตามลิ้งต่อไปนี้
preinstall  ต้องเลือกรุ่น ubuntu ที่ใช้งานอยู่
install
เมื่อโหลด Driver มาแล้วก็ทำตามขั้นตอนในเว็บไซต์ได้เลย


Wednesday, April 17, 2013

บล็อกอีเมลพนักงานไม่ให้ส่งเมลออกไปนอกบริษัท

สร้างไฟล์ header_checks /etc/postfix
-----------------------------------------------------------
/^To:.*domain\.co\.th/      OK
/^To:.*\.*/   REJECT You are not allowed to send mail outside the company.
/^Cc:.*domain\.co\.th/      OK
/^Cc:.*\.*/   REJECT You are not allowed to send mail outside the company.
/^Bcc:.*domain\.co\.th/     OK
/^Bcc:.*\.*/  REJECT You are not allowed to send mail outside the company.
-----------------------------------------------------------

#postmap /etc/postfix/header_checks
#vim /etc/postfix/main.cf

 เพิ่ม  header_checks = regexp:/etc/postfix/header_checks เข้าไปในไฟล์ main.cf

#/etc/init.d/postfix reload
#tail -f /var/log/mail.log   ดู Log mail


Thursday, April 11, 2013

Postfix Autorespont

Howto set auto respont by Postfix

Reading ...



Monday, April 8, 2013

Scrip Map network drive on ubuntu


For ubuntu 10.xx - 12.04
//192.168.4.xx/market  /media/market  cifs    username=center,password=xxx001,iocharset=utf8,codepage=unicode,unicode       0       0

For ubuntu 12.04 Kernel 3.6.0
install packet smbfs
#aptitude install smbfs
edit #vim /etc/fstab
.
.
//192.168.4.xx/market  /media/market  cifs    username=center,password=xx001,iocharset=utf8,uid=1000,gid=1000       0       0

**uid=1000 check on /etc/passwd
**gid=1000 check on /etc/group

command map

#mount -o username=mxx,password=mxxx //192.168.xx.25/share folder /media/mail

Create file Credentails

1. Create Folder on Client
#mkdir /home/user/Sharefile

2. create file passwd credentail

#echo “username=samba_username” > /home/user/Sharefile/.smbcredentials
#echo “password=password_username” > /home/user/Sharefile/.smbcredentials
#chmod 600 /home/user/Sharefile/.smbcredentials

3. Edit file /etc/fstab
add new line

#//192.168.0.xx/downloads        /home/user/Sharefile       cifs    uid=1000,gid=1000,credentials=/home/user/Sharefile/.smbcredentials,defaults        0       0

4.Run mapdrive
#mount //192.168.0.xx/downloads
or
#mount -a

umount
#umount Sharefile


Ref.
techsuii.com



Setup Propdfd

how to setup propdfd

Reading digitalocean.com

Friday, April 5, 2013

Sunday, March 31, 2013

ต้นไม้

1. ต้นออมเพชร


เป็นในไม้ร่ม ไม่ควรถูกแดดจัด ควรอยู่ในที่มีลม อากาศโปร่ง รดน้ำวันละครั้ง หรือสังเกตวัสดุปลูก ถ้ายังชื้นอยู่ ไม่จำเป็นต้องรดน้ำ (ในรูปเป็นขนาด ไม้กระถาง 4 นิ้ว) 

อ้างอิง
 siamonlineshop

2. ต้นเขียวหมื่นปี


ลักษณะ
          เป็นว่านชนิดหนึ่ง ลำต้นตั้งตรง มีใบยาวเรียว บางชนิดอาจแซมด้วยลายสีเทาเงิน ให้สีเขียวเข้มสดใสตลอดทั้งปี โดยเป็นไม้ประดับที่ชอบความชื้น และสามารถอยู่ในที่แสงน้อยได้ อีกทั้งยังมีขนาดเล็ก ไม่เกะกะพื้นที่ด้วย

ประโยชน์

          เป็นว่านคงกระพันชาตรี ที่เชื่อกันว่าปลูกไว้จะอายุยืนยาว อีกทั้งยังมีคุณสมบัติ รักษาแผลได้ โดยให้นำใบเขียวหมื่นปีมาตำให้ละเอียด แล้วผสมกับเหล้าขาว จากนั้นนำไปพอกไว้ที่แผลสด แล้วเอาผ้ารัดไว้ จะทำให้แผลสมานเร็วขึ้น 

การดูแลรักษา
          เขียวหมื่นปีสามารถปลูกได้ทั้งในดินปนทราย ดินร่วนซุย หรือปลูกในน้ำก็ได้ โดยเป็นพืชที่ชอบความขื้นจึงควรหมั่นรดน้ำ ไม่จำเป็นต้องมีแสงแดดส่องถึง แต่ถ้าไม่ได้โดนแดดเป็นเวลานาน สามารถนำออกไปรับแดดได้นาน ๆ ครั้ง

Ref.
- www.bloggang.com
- kapook.com

 3. เศรษฐีมีทรัพย์


4. เฟิร์นบอสตัน (เฟิร์นใบมะขาม)
  

ลักษณะ
          เป็นพืชตระกูลเฟิร์นชนิดหนึ่งที่มีพุ่มสวยงาม มีใบคล้ายใบมะขาม ปลายใบไม่มีแฉก มีสีเขียวสด มีคุณสมบัติพิเศษในการดูดสารพิษ และดูดความชื้นได้ดี

 
ประโยชน์

          สามารถดูดสารพิษได้ดีมาก นอกจากนี้ยังเป็นพืชที่ชอบความขื้น จึงดูดความขื้นได้มาก เหมาะกับห้องที่มีความเปียกชื้น เนื่องจากจะช่วยสร้างความสมดุลให้กับห้อง

 
การดูแลรักษา
          ควรหมั่นรดน้ำให้ชุ่มชื่นอยู่เสมอ แต่อย่าให้แฉะจนเกินไป เพราะจะทำให้เฟิร์นดูดซับน้ำเอาไว้มากจนเฉาได้ หากต้องการใส่ปุ๋ยให้ใช้ปุ๋ยหมักหรือปุ๋ยคอกฉีดพ่นละอองเบา ๆ เดือนละครั้งก็เพียงพอ ควรให้เฟิร์นได้รับแดดจากหน้าต่าง หรือ ช่องรับแสงบ้าง เพื่อให้ไม่ให้ใบแห้ง และกลายเป็นสีเหลือง


 5. ออมเงิน ออมทอง

ลักษณะ
          เป็นต้นไม้พันธุ์เล็กในตระกูลไม้เลื้อย มีโคนใบเว้าลึก ปลายเรียวแหลม ตรงกลางใบเป็นสีขาวหรือเหลือง ไล่ออกมาเป็นสีเขียวบริเวณขอบ
ประโยชน์

          เชื่อกันว่าเป็นไม้มงคลที่เสริมดวงเรื่องการประหยัดเก็บออม อีกทั้งยังเป็นการปลูกไว้เพื่อเตือนใจว่า เมื่อเห็นต้นออมเงิน ออมทองแล้ว ให้ระมัดระวังในการใช้จ่ายมากขึ้นด้วย โดยเทคนิคคือให้เริ่มต้นปลูกครั้งแรกในวันอังคาร และหันทิศทางการปลูกไปทางทิศตะวันออกเฉียงเหนือ จะช่วยเสริมพลังได้มากกว่าทิศอื่น ๆการดูแลรักษา
          จำเป็นต้องปลูกตามช่องแสงแดด หรือตรงหน้าต่าง เพื่อให้ได้รับแสงแดดเต็มที่ สามารถดูดซับน้ำและความชื้นได้มาก จึงต้องหมั่นรดน้ำบ่อย ใช้ดินที่มีความชื้นสูง ถ้าต้องการใส่ปุ๋ยให้ใส่เดือนละครั้ง

6. ต้นธรรมรักษา (ไม้ริมรั้ว)

7. เศรษฐีใบละพัน

8. ต้นเงินเต็มบ้าน

   
         ถิ่นกำเนิดอยู่ที่ประเทศฟิลิปปินส์ แต่นิยมนำมาปลูกไว้ที่บ้าน เสริมความเป็นมงคล ความเจริญรุ่งเรืองให้กับชีวิตหน้าที่การงาน และมีเงินทองกองเต็มบ้านอีกด้วย
        เป็นไม้ที่ไม่ชอบแดดมากนัก อยู่รำไร ไม่ต้องดูแลมากนัก พรวนดิน+ใส่ปุ๋ย 16-16-16 ประมาณ 2 เดือนครั้งก็ใบเขียวสวยดี ขยายพันธ์ง่าย เพียงตัดลำต้นไปปลูกใหม่ก็ขึ้นแล้ว หรือหากกระถางเดิมที่ปลูกไว้มันเต็มเกินไปรูปทรงไม่สวยสามารถตัดทิ้งได้ ไม่นานก็จะออกใบใหม่สวยงามเหมือนเดิม 




 

Thursday, March 28, 2013

Linux Command (ที่จำเป็นต้องใช้ประจำ)

Mail
- iRedmail
  1. tail -f /var/log/iredapd.log -> Logmail
  2. tail -f /val/log/mail.log  -> Logmail

General
- tar cjvf file.tar.bz2 file  for creat file .bz2
- tar jxf file.bz2  (need install bzip2) for unzip file .bz2
- rsync -rv (src) (dst) --progress ก็อปปี้ Directory
- rsync (src) (dst) --progress ก็อปปี้ไฟล์ทั่วไป

For apt-get
#apt-get install PACKAGE
# apt-get remove PACAKAGE
# apt-get purge PACKAGE
# apt-cache search PACKAGE|KEYWORDS
# apt-cache show PACKAGE

Remove/Uninstall
# apt-get remove --purge packetname*
# apt-get clean
# apt-get autoremove
# apt-get -f install

Update & Upgrade
# sudo apt-get -y update &&
# sudo apt-get -y upgrade &&
# sudo apt-get clean &&
# sudo apt-get -y autoremove

For aptitude
# aptitude
# aptitude install sudo
# aptitude remove sudo
# aptitude purge sudo
# aptitude search sudo
# aptitude show sudo
# man aptitude
 

Wednesday, March 27, 2013

ssh config

#For Debian
-------------------------------
Port   22
ListenAddress   0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
ServerKeyBits   1024
LoginGraceTime   600
KeyRegenerationInterval   3600
PermitRootLogin no
IgnoreRhosts   yes
IgnoreUserKnownHosts   yes
StrictModes   yes
X11Forwarding   no
PrintMotd   yes
SyslogFacility   AUTH
LogLevel   INFO
RhostsRSAAuthentication  no
RSAAuthentication   yes
PasswordAuthentication   yes
PermitEmptyPasswords   no
AllowUsers sysadmin
Subsystem   sftp   /usr/libexec/openssh/sftp-server
-------------------------------

If set port not 22 like 2200
shell log in #ssh -l user -p 2200 ip address/hostname
--------------------------------------------------------------

#For Centos

Port   55001
ListenAddress   0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
ServerKeyBits   1024
LoginGraceTime   600
KeyRegenerationInterval   3600
PermitRootLogin no
IgnoreRhosts   yes
IgnoreUserKnownHosts   yes
StrictModes   yes
X11Forwarding   no
PrintMotd   yes
SyslogFacility   AUTH
LogLevel   INFO
RhostsRSAAuthentication  no
RSAAuthentication   yes
PasswordAuthentication   yes
PermitEmptyPasswords   no
AllowUsers sysadmin
Subsystem   sftp   /usr/libexec/openssh/sftp-server