Thursday, November 24, 2005

Missing Samba after Upgrade Packages

My Old PC is a Debian Linux box. I have not upgraded the packages for a long time. Therefore, yesterday, I run Aptitude to do a mass updates. Today, I find the Samba is removed after the mass updates.

I run Aptitude to figure out the reason. I found the Samba has some broken dependency -- libdb4.1. Then, I search the libdb4.1 on the Web. In the unstable branch of Debian, it only supports AMD64 Architecture. Oh! Some packages in Debian is moving from unstable to stable branch.

So, I edit the "/etc/apt/sources.list" to add the stable repository:

deb http://ftp.hk.debian.org/debian/ stable main non-free contrib

Then run Aptitude and update the package list. The broken dependency problem solve and Samba can be installed.

Wednesday, November 23, 2005

Free Virtual Machine -- QEMU

Long time ago, I have tried QEMU. I run QEMU in Debian and the guest OS is Win2000. It worked but it was very slow. Recently, I visit the site of QEMU and there is a QEMU Accelerator Module. According to the site, with the accelerator, QEMU's performance is comparable to commercial products.

I want to try QEMU in Windows XP. However, the accelerator for windows is alpha version. Anyway, I still want to try to download and run it on my Win XP. The guest OS is the sample Linux which can be download the QEMU's website. It crashes in LILO. Too bad!!!! After that, I try to run QEMU without the accelerator. It works fine. I think the accelerator for windows need to be improved.

Then, I try another accelerator module -- qvm86. This is a open source accelerator module. This module is even worse. It crashes my WinXP.

Related Links:
Offical site of QEMU
QEMU porting on Windows
QVM86

Sunday, November 20, 2005

Trojan Found

Two days ago, my sister reported to me that her computer had torjan. On one hand, IE has many many security bugs. On the other hand, she have not done Windows Update for a long long time. I guess the trojan was planted by visiting some bad web-site. Actually, I have told her don't use IE, use Firefox!

The trojan was found by AVG virus scanner. Actually, there are two trojans found: PSW.Generic.BWM and PSW.Generic.DAP. I search them in google, and nothing related found. The infected file are "WINDOWS\SYSTEM32\msd.dll" and "WINDOWS\SYSTEM32\roddll.dll".

For the filename "roddll.dll", I find some information on the Web. There is a trojan named "Troj/Ragrok-A". This trojan creates "WINDOWS\rundll132.exe" and the "roddll.dll" file. Moreover, it also creates a registry entry to execute the "rundll132.exe" in HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run. So, it is not difficult to remove.

For the "msd.dll", there is not much information find. Anyway, I inspect the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run in the registry, I find a suspect entry: "WINDOWS\system\rundll32.exe". I search on Google by key words "rundll32.exe" and "trojan". I find that rundll32.exe file is located in the c:\windows\System32 folder. In other cases, rundll32.exe is a virus, spyware, trojan or worm! Then, I remove the entry in the registry, remove the "rundll32.exe" in "WINDOWS\SYSTEM", as well as the "msd.dll". Then, reboot. Everything works fine! The AGV scanner doesn't find any trojan.


Friday, November 18, 2005

Obfuscate the Spammer's Robot

Most email users should have experience of receiving junk email. For me, my HongKong.com account, it receives around 100 junk email each day. This wastes our time to filter the email and makes us feel annoying.

Do you know how a spammer get your email addresses? Actually, your email addresses may already be put on the Web which can be accessed by the public. For example, in web-sites of many companies, they put contact lists containing email addresses of its staff. spammers use a program, called robot, to automatically retrieve email addresses on the Web. The spammers' robots move on the Web and try to get the email addresses. So, don't put your email addresses publicly.

However, sometimes you can't avoid it. So, it is suggested to post your email addresses on the Web in a obfuscated form. For example:

john [at] google [dot] com
The robot is a very simple program which can only recognize the email addresses in the form of "xxx@xxxx.xxx". Once the email address is transformed, the robot can't recognize it, but human can. However, it is not user-friendly. I suggest to use JavaScript to transform the the obfuscated email addresses back when mouse is over the email addresses. Here is a real example in my homepage: Contact. Such that, someone can copy and past the email address directly.

Wednesday, November 16, 2005

Get the Date of Tomorrow/Yesterday in Shell Script

In shell script, we may need to get the date of tomorrow/yesterday. If you use GNU version of "date", it is a piece of cake:
date -d tomorrow +%Y-%m-%d
The above command will display the date of tomorrow in "yyyy-mm-dd" format. Similarly, to find the date of yesterday:
date -d yesterday +%Y-%m-%d
The power of the GNU date command is out of my imagination, see the following examples:
date -d "2 days ago"
date -d "3 weeks ago"
date -d "1 month ago"
date -d "3 days"
date -d "4 weeks"
date -d "2 month"
date -d "2 month 1 week"
However, if your "date" is non-GNU version (e.g. in Solaris), it doesn't support "-d" option. Then, there seems no simple command can do this. You may need to write Perl script or use other more powerful programming/scripting language to achieve same results.

Tuesday, November 15, 2005

Power of "find"

"find" is a command line utility. Its basic usage is to find some files. e.g.
find . -name '*.html'
The above example is to find all HTML files under current directory.

While building a homepage, it is common to change HTML and graphic files to 0644 permission. We can use the "-exec" option of find to execute the "chmod"; command to change the permission of the files, e.g:

find . \( -name '*.html' -o -name '*.png' -o -name '*.jpg' \) -exec chmod 0644 {} \;
The parameters after "-exec" is the command to be executed. In the command, "{}" is replaced by the found file. The "\;" is the terminator of the command of "-exec".

Monday, November 14, 2005

Comments Submission

I continued to my Blog development. In the comments text area of comments submission, my original implementation did NOT allow any HTML tag. It was mainly due to security reasons. However, this made the text of comments looks dull. I think it is better to allow some simple formatting tag e.g. <p>, <b>, <i>....

After did some survey on the web, I found the most popular technology is BBCode. BBCode defines a set of tags in form of "[xxx]" which will be converted to HTML tags. For example, "[b]bold text[/b]" is converted to "<b>bold text</b>". There are several free BBCode parsers available. It is convenient to deploy this technology.

One disadvantage of BBCode is not user-friendly. Users need to learn a new set of code. I thinks it is better to have a WYSIWYG editor. Unfortunately, I cannot find any web-based WYSIWYG editor for BBCode.

On the other hand, I found some open source web-based WYSIWYG HTML editors. It is great! I have tried the Cross-Browser Rich Text Editor and it works well in both Firefox and IE.

However, it is not secure to accept all HTML tags. On server side, it should filter out some dangerous tags, e.g. , .... There already exist some HTML filters. One of them is safehtml. Finally, I decided to use the WYSIWYG HTML editor plus HTML filter.