Jun 25

1. On your firewall (you do have one don’t you?) check the incoming MySQL port and if 3306 is open, close it. If this port is left open it can pose both a security and server abuse threat since not only can hackers attempt to break into MySQL, any user can host their SQL database on your server and access it from another host and so (ab)use your server resources

2. Check /tmp permissions. /tmp should be chmod 1777

3. Check /tmp ownership /tmp should be owned by root:root

4. Check /etc/cron.daily/logrotate for /tmp noexec workaround. Due to a bug in logrotate if /tmp is mounted with the noexec option, you need to have logrotate use a different temporary directory. If you don’t do this syslog may not restart correctly and will write to the wrong (older) log files.

5. Check /var/tmp permissions. /var/tmp should be chmod 1777

6. Check /var/tmp ownership. /var/tmp should be owned by root:root

7. Check /var/tmp is mounted as a filesystem. /var/tmp should either be symlinked to /tmp or mounted as a filesystem

8. Check /var/tmp is mounted noexec,nosuid. /var/tmp isn’t mounted with the noexec,nosuid options (currently: none). You should consider adding a mountpoint into /etc/fstab for /var/tmp with those options

9. Check /usr/tmp permissions. /usr/tmp should be chmod 1777

10. Check /usr/tmp ownership. /usr/tmp should be owned by root:root

11. Check /usr/tmp is mounted as a filesystem or is a symlink to /tmp. /usr/tmp should either be symlinked to /tmp or mounted as a filesystem.
Check /etc/resolv.conf for localhost entry. You should not specify 127.0.0.1 or localhost as a nameserver in /etc/resolv.conf – use the servers main IP address instead

12. Check /etc/named.conf for recursion restrictions. If you have a local DNS server running but do not have any recursion restrictions set in /etc/named.conf this is a security and performance risk and you should look at restricting recursive lookups to the local IP addresses only. Unrestricted recursive lookups are as good as a DDoS attack against your system. They will eat up all your system resources

13. Check server runlevel. For a secure server environment you should only run the server at runlevel 3. You can fix this by editing /etc/inittab and changing the initdefault line to:
id:3:initdefault: and then rebooting the server.

14. Check nobody cron. You have a nobody cron log file – you should check that this has not been created by an exploit.

15. Check Operating System support. Make certain that your OS version is still supported by the manufacturer and that upgrades continue to be available.

16. Check SSHv1 is disabled. You should disable SSHv1 by editing /etc/ssh/sshd_config and setting: Protocol 2 (remove the hash # from in front of the line and edit out the 1.1)

17. Check SSH on non-standard port. Moving SSH to a non-standard port avoids basic SSH port scans. Edit /etc/ssh/sshd_config and setting: Port nnnn Where nnnn is a port of your choosing. Don’t forget to open the port in the firewall first!

18. Check SSH PasswordAuthentication. For ultimate SSH security, you might want to consider disabling PasswordAuthentication and only allow access using PubkeyAuthentication.

19. Check telnet port 23 is not in use. Close this port in your firewall. Telnet is an insecure protocol and you should disable the telnet daemon if it is running

20. Check shell resource limits. You should enable shell resource limits to prevent shell users from consuming server resources – DOS exploits typically do this. If you are using cPanel/WHM set Shell Fork Bomb Protection.

21. Disable all instances of IRC – BitchX, bnc, eggdrop, generic-sniffers, guardservices, ircd, psyBNC, ptlink. If you are using WHM you can do this in the Background Process Killer.

22. Check apache for mod_security if not installed install it from source.

23. Check apache for mod_evasive. You should install the mod_evasive apache module from source to help prevent DOS attacks against apache. Note that this module breaks FrontPage functionality.

24. Check apache for RLimitCPU. You should set a value RLimitCPU to prevent runaway scripts from consuming server resources – DOS exploits can typically do this.

25. Check apache for RLimitMEM. You should set a value RLimitMEM to prevent runaway scripts from consuming server resources – DOS exploits can typically do this.

written by admin

Jun 09

1 To get hard disk information.
hdparm -I /dev/sda

2 Search and replace option in vi.
:%s/old/new/g

3 To make an icon.
convert -size 900×120 xc:black -font Times-Roman -pointsize 100 -fill green -annotate +20+80 ‘Linux is the Best’ -fill green -annotate +25+90 ‘Linux is the Best’ -trim +repage logo1.png

4 To replace one word with another with the backup of the original one.
sed -ibackup s/orange/grapes/g sedd

5 To search for a particular word and delete it.
find / -name aaa* -delete

6 To delete the last 30 days files. For files before 30 days +30.
find /root/wallpapers/ -mtime -30 | xargs /bin/rm -f

7 Command to dump partitions, directory etc..
dump -0aj -f /back/mydump /dev/sda2

8 Command to restore the dumped partition.
restore -rf mydump /back

9 To convert all jpeg files in the current directory to avi.
mencoder “mf://*.jpg” -mf fps=1 -o outputs.avi -ovc lavc -lavcopts vcodec=mpeg4

10 To convert avi to mpeg-2
mencoder /root/ItalianJob.avi -mf fps=1 -o /opt/ItalianJob.mpg -ovc lavc -oac pcm -lavcopts vcodec=mpeg2video

11 To convert mpg to avi.
mencoder /editor/Seval.mpg -ovc xvid -oac mp3lame -xvidencopts bitrate=800 -o /opt/Seval.avi

12 To delete lines 23-47 using vim or vi.
:23,47 d

13 Command to display the installed fonts.
fc-list

14 To check the CD/DVD drive/eject.
fuser /media/cdrom [eject]/[eject -p]

15 To kill the process.
fuser -k /media/cdrom

16 Find all files that have the .exe extension in the current directory.
find . -name \*.exe

17 Lists all of the files in the queue, as well as the user, the job number, the size and the root directories from which the print jobs originate.
lpq

18 To free memory when memory is in short.
memhog 500m

19 Cron to shutdown machine.
55 23 * * * /sbin/shutdown -h now

20 To password protect a zip file.
zip -e -r /root/Desktop/new /root/Desktop/old

21 To delete all hidden files from current directory.
rm -rf .*

22 Extracting files to a specific directory
unzip Commonly\ Used\ Malayalam\ Fonts.zip -d /usr/share/X11/fonts/TTF/ -(Sorry! I’m a Malayali)

23 To format CD-RW
cdrecord blank=fast dev=1,0,0

24 To stop all process except your shell.
kill 0

25 To disable usb in linux, eg. fedora 8.
mv /lib/modules/2.6.23.1-42.fc8/kernel/drivers/usb/storage/usb-storage.ko /opt/

written by admin