Wednesday, July 30, 2008

Generate AppArmor profiles with genprof

With SELinux being the focus of security solutions for Linux servers, it's easy to overlook some other solutions that may not be as comprehensive (or intrusive) as SELinux; however, there are other products that have a place in securing Linux servers. One such product is Novell's AppArmor, which is the successor of Immunix's SubDomain technology. Novell acquired SubDomain when it purchased Immunix.

Unlike SELinux, which is a total system security solution, AppArmor is more of an "application firewall" in that it protects the system if an application does something it isn't supposed to do. For instance, if a vulnerability in Apache could be exploited such that a remote user could make Apache display the contents of a file outside of the Web root, files such as /etc/passwd and other sensitive information could be displayed. With AppArmor, such exploits would not work because a proper AppArmor profile against the httpd process would prevent Apache from even accessing the file.

Currently, AppArmor is available for a modest few distributions, such as SUSE itself and Slackware. Because AppArmor uses the Linux Security Modules, it's easy to patch the kernel, enable AppArmor, and compile the appropriate user-land packages. As more distributions provide AppArmor support, expect to be able to install AppArmor support with your distribution's package manager, such as apt and smart.

Enabling and disabling AppArmor is as simple as running service apparmor start (or stop) which will load the apparmor kernel module and apply the policy rules typically found in /etc/apparmor.d/.

Creating profiles is easy as well. AppArmor comes with a tool called genprof, which can be used in one terminal to profile an application while using the application in another terminal or, in the case of a GUI application, by just starting it.

To begin, use:

# genprof /usr/bin/firefox

This will start the profile generation for the Firefox program; a default skeleton for the profile will be placed in /etc/apparmor.d/usr.bin.firefox and AppArmor will initially put it into "complain" mode, where things that Firefox does will be logged, but won't actually be prevented.

Use Firefox as you normally would and, when ready to finish the profile generation, switch to the terminal where genprof is running and hit the [S] key to scan the system logs for AppArmor events. genprof will then provide, one by one, a list of the violations logged in complain mode and allow you to either allow or deny the action. Once you're done, the new profile is written and it is switched to "enforce" mode, rather than "complain" mode.

AppArmor is quite easy to use and while not as robust as solutions like SELinux, it can provide excellent security with minimal configuration difficulty.

Thursday, July 24, 2008

mysql-proxy

I found this error message when connecting mysql-proxy with mysql server 4.0.13 :
file network-mysqld-proto.c: line 136 (network_mysqld_proto_get_string_len): assertion failed: (*_off <>len)
after googling, i found the problem. We need at least MySQL 4.1 to use MySQL Proxy.

Sunday, July 13, 2008

Wubi - Windows based installer Linux Ubuntu ( Run Linux Ubuntu inside Windows )

Wubi allows Ubuntu to be installed from within Windows - an alternative to running a virtual machine or running from a Live CD version. Windows will look this Wubi just like another windows application. Most of the files Wubi uses to load and run Ubuntu Linux reside in a single folder; the installer does not modify a system's disk partitions, bootloader, or any other vitals; and the whole affair uninstalls just as quickly and painlessly.

Best of all, Wubi can even transfer a Windows-based Ubuntu installation to a dedicated partition (or to a portable device such as a USB drive) and set up a dual-boot configuration for users who choose to take this step.

Check out for the Wubi Screen Shot installation
Download WUBI link.

Friday, July 4, 2008

Disable IPv6 in Linux Ubuntu

Edit the following line from /etc/modprobe.d/aliases:
1. Find the line: alias net-pf-10 ipv6
2. Edit this to: alias net-pf-10 off ipv6
3. Save the file and reboot

Thursday, July 3, 2008

Ubuntu 8.04 Hardy Hardening Guide and Configuration

1. INTRODUCTION
System hardening, also called Operating System hardening, helps minimize these security vulnerabilities.

The purpose of system hardening is to eliminate as many security risks as possible. This is typically done by removing all non-essential software programs and utilities from the computer. While these programs may offer useful features to the user, if they provide "back-door" access to the system, they must be removed during system hardening.

Advanced system hardening may involve reformatting the hard disk and only installing the bare necessities that the computer needs to function. The CD drive is listed as the first boot device, which enables the computer to start from a CD or DVD if needed. File and print sharing are turned off if not absolutely necessary and TCP/IP is often the only protocol installed. The guest account is disabled, the administrator account is renamed, and secure passwords are created for all user logins. Auditing is enabled to monitor unauthorized access attempts.
The following hardening configuration adopted from NSA Security Configuration Guides. NSA has developed and distributed configuration guidance for operating systems. They made this configuration base on RHEL 5 and i customize the configuration and implement it in Ubuntu 8.04 Server Edition.

1.1. General Principles
· Encrypt all data transmitted over the network. Encrypting authentication information (such as passwords) is particularly important.
· Minimize the amount of software installed and running in order to minimize vulnerability.
· Use security-enhancing software and tools whenever available (e.g., AppArmor, SELinux and Iptables).
o Ubuntu 8.04 default installation already hardened by AppArmor package.
o How to install SELinux in Ubuntu 8.04
# sudo apt-get install SELinux
o How to install Iptables
# sudo apt-get install Iptables
· Run each network service on a separate server whenever possible. This minimizes the risk that a compromise of one service could lead to a compromise of others.
· Maintain user accounts. Create a good password policy and enforce its use. Delete unused user accounts.
· Review system and application logs on a routine basis. Send logs to a dedicated log server. This prevents intruders from easily avoiding detection by modifying the local logs.
· Never activate root password and log in directly as root, unless absolutely necessary. Administrators should use sudo to execute commands as root when required. The accounts capable of using sudo are specified in /etc/sudoers, which is edited with the visudo utility. By default, relevant logs are written to /var/log/auth.log.
1.2. Disk Partitions and Mounting
During initial installation, ensure that filesystems with user‑writeable directories such as the following are mounted on separate partitions: /home, /tmp, /var/tmp.
During system configuration, change mount options in /etc/fstab to limit user access on appropriate filesystems. The defaults option is equal to rw,suid,dev,exec,auto,nouser,async. Using noexec instead prevents execution of binaries on a file system (though it will not prevent scripts from running). Using nosuid will prevent the setuid bit from having effect. The nodev option prevents use of device files on the filesystem.

1.3. Physical Security
Configure the BIOS to disable booting from CDs/DVDs, floppies, and external devices, and set a password to protect these settings.
Next, set a password for the GRUB bootloader. Generate a password hash using the command / /usr/sbin/grub-md5-crypt. Add the hash to the first line of /boot/grub/menu.lst as follows:
password --md5 passwordhash
This prevents users from entering single user mode or changing settings at boot time.

1.4. Keep Software Up to Date
Upgrade through the Ubuntu Repository Network to apply upgrade automatically. Security updates should be applied as soon as possible.
Create the file apt.cron, make it executable, place it in /etc/cron.daily or /etc/cron.weekly, and ensure that it reads as follows:
#!/bin/sh
/usr/bin/apt-get upgrade

1.5. Disable Unnecessary Services
For a list of network port that are open you can use the following commands:
# netstat -tulp or lsof -i -n | egrep 'COMMAND|LISTEN|UDP' or just a port scanner (nmap) 9
To list the services configured to start at boot, run the following command:
# sudo apt-get install sysv-rv-config ( similar function with chkconfig )
# sudo sysv-rc-config
Find the column for the current run level to see which services are enabled. The default run level is 5. To disable a service, run the following command:
# /sbin/sysv-rc-conf servicename off
It is particularly important to disable unnecessary services. Additionally, the following services can be safely disabled if NFS is not in use: netfs, nfslock, portmap, rpcgssd, and rpcidmapd. Some software relies on other services, so care should be taken when disabling them. Changes will take effect after a reboot.

1.6. Disable SUID and SGID Binaries
To find SUID and SGID files on the system, use the following command:
# find / \( -perm -4000 -o -perm -2000 \) -print
The following files can have their SUID or SGID bits safely disabled (using chmod -s filename) unless required for the purpose listed in the second column:

File: Required For:
/bin/ping6 IPv6
/sbin/mount.nfs NFS
/sbin/mount.nfs4 NFS
/sbin/netreport network control
/sbin/umount.nfs NFS
/sbin/umount.nfs4 NFS
/usr/bin/chage passwd
/usr/bin/chfn account info
/usr/bin/chsh account info
/usr/bin/crontab cron
/usr/bin/lockfile Procmail
/usr/bin/rcp rsh
/usr/bin/rlogin rsh
/usr/bin/rsh rsh
/usr/bin/wall console messaging
/usr/bin/write console messaging
/usr/kerberos/bin/ksu Kerberos
/usr/libexec/openssh/ssh-keysign SSH host-based authentication
/usr/sbin/suexec Apache, CGI
/usr/sbin/userisdnctl ISDN
/usr/sbin/usernetctl network control

1.7. Configure and Use Iptables and TCP Wrapper
The Iptables firewall should be configured to allow only necessary network communications. For workstations, this may entail blocking all incoming communications, except for those related to connections the system initiated. If Iptables is currently running, view the current firewall policy with the following command:
/sbin/iptables -L
By default, the output should correspond to rules stored in the file /etc/sysconfig/iptables. Understand and edit these rules, removing any lines that allow unnecessary communications. To activate the updated rules, restart the service.
Also configure the TCP Wrapper library to protect network daemons that support its use by adding appropriate rules to /etc/hosts.allow and /etc/hosts.deny.

1.8. Configure and Use SELinux ( Default for Ubuntu is AppArmor )
The default SELinux policy, called targeted, provides protection against compromised or misconfigured system services. This policy should not interfere with normal system operation. Ensure that /etc/selinux/config includes the following lines:
SELINUX=enforcing
SELINUXTYPE=targeted
Stronger policies such as strict and mls can be used if appropriate. However, these require customization to operate successfully for many general-purpose usage scenarios.
SELinux and AppArmor cannot be used together. They have a similar function. Ubuntu 8.04 already bundled AppArmor in their package, so it is better to use AppArmor instead of SELinux.

1.9. Set Kernel Parameters
At boot, the system reads and applies a set of kernel parameters from /etc/sysctl.conf. Add the following lines to that file to prevent certain kinds of attacks:
net.ipv4.conf.all.rp_filter=1
net.ipv4.conf.all.accept_source_route=0
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.icmp_ignore_bogus_error_messages=1
kernel.exec-shield=1
kernel.randomize_va_space=1

For more possible parameters, including settings for IPv6, please see our complete guide.

1.10. NTP
For most systems, the ntpd service introduces unnecessary overhead. Instead, call its update utility, ntpdate, directly through a cron job. Create the file /etc/cron.d/ntpdate with the following line:
15 * * * * root /usr/sbin/ntpdate server
Substitute an appropriate NTP server for server. Hosts on a network should synchronize their time from a local NTP server, and then only this local NTP server should acquire the time from an external, trusted source.

1.11. Configure or Disable SSH
SSH is often required, but if it is not, disable it:
# sysv-rc-conf ssh off
If SSH is required, ensure the SSH configuration file /etc/ssh/sshd_config (not ssh_config) includes the following lines:
PermitRootLogin no
Protocol 2
If possible, limit SSH access to a subset of users. Create a group called sshusers and only add the users that need remote access. Then, add the following line to /etc/ssh/ssh_config:
AllowGroups sshusers
Restart the service so that these changes take effect.

1.12. Disable IPv6
Unless your policy or network configuration requires it, disable IPv6. To do so, prevent the kernel module from loading by edit the following line from /etc/modprobe.d/aliases:
1. Find the line: alias net-pf-10 ipv6
2. Edit this to: alias net-pf-10 off ipv6
3. Save the file and reboot

Get Help by CrossLoop

Have any problem with your pc ,network or maybe your email can't send and receive? and you have no idea how to fix it. Just ask help from CrossLoop member. You can find helpers around the world to help you.

If you are a professional / expert, you also can help other people to solve a problem and get paid! MONEY-MONEY-MONEY.

Wednesday, July 2, 2008

Remote Desktop / PC accross internet tools for Windows ( CrossLoop )

Remotely controlling an end user’s PC across the Internet can be complicated. Remote support tools, like Windows Remote Desktop and VNC, simplify the process, but even these programs can trip up a frustrated, novice user. Add firewalls and routers to the mix, and remote support becomes a real headache. CrossLoop might be the cure.

CrossLoop is a remote control application that distills connecting two PCs via the Internet into a simple one-button interface. The program works through firewalls and routers, making it easy to connect two computers on different networks. CrossLoop uses GPL-licensed TightVNC, which protects all transferred data with 128-bit encryption

To run CrossLoop yourself, you’ll need a machine running Windows 98 or later, with a Pentium 500 MHz or better processor, at least 128 MB of RAM, 2 MB of free hard drive space, and a high-speed Internet connection.

CrossLoop is one of the best remote support tools I’ve used. It’s not perfect, and it sometimes drops connections, but it works as well as any remote control application on the market–only without the hassle. I frequently use CrossLoop to support my technically-challenged friends and family.

lighttpd vs apache

From my conclusion after read the comparison between them . Lighttpd has better performance then apache. Use lighttpd instead of apache for heavy traffic load web server.

HA error - attempted replay attack

I found this error message when slave node has been down for along time and i tried to bring it up again.

heartbeat[27177]: 2008/07/02_15:27:44 ERROR: should_drop_message: attempted replay attack [mysqldb2]? [gen = 18, curgen = 1207732349]
heartbeat[27177]: 2008/07/02_15:27:46 ERROR: should_drop_message: attempted replay attack [mysqldb2.]? [gen = 18, curgen = 1207732349]
heartbeat[27177]: 2008/07/02_15:27:48 ERROR: should_drop_message: attempted replay attack [mysqldb2]? [gen = 18, curgen = 1207732349]
2 ways to solve it:
1. Put 1207732350 (curgen+1) in /var/lib/heartbeat/hb_generation on mysqldb2 - from this log it should have a 1 (gen) in there now.

Basically, it should be one larger than the curgen number from the message above.

Then if you restart Heartbeat on the master node (paul), all should be well. This is the result of a feature called ReplayAttackProtection. You can also just restart Heartbeat on both nodes, if you prefer.

So, if you put any number larger than curgen into the hb_generation file on paul, on the machine you reinstalled, and restart, Heartbeat will be happy.

2. Remove hb_generation and hb_uuid file from /var/lib/heartbeat then restart HA service at both machine.