Archive for the ‘ Linux ’ Category

Most web based attacks tend to occur by uploading malicious scripts into world writable directories such as cache, and then letting the web server execute those scripts. In apache, one of preventing such scripts from being executed is to add a “.htaccess” file in that directory and insert the following lines

cd /var/www/html/mydomain/uploads
vim .htaccess

Options -ExecCGI
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi

How to use ncftpget to copy directories from FTP server.

The old ftp command is not convenient for recursively copying directories from the command line. An alternative to the ftp command is the ncftpget.

1. Download ncftpget

a. RHEL/Fedora/CentOS


yum install ncftpget

b.Debian/Ubuntu


apt-get install ncftpget

2. Make sure you have the hostname, username and password of the ftp server, from which you want to download a bunch of directories. Let us say you want to copy /var/www/html in the ftp server to a local directory /home/user1/Desktop


ncftpget –u ftpusername -R -v ftp.example.com /home/user1/Desktop /var/www/html

You will be prompted for a password, once you entered the correct password, it will recursively(-R) download the files under /var/www/html to /home/user1/Desktop in a verbose(-v) mode – that is you will see the file transfer on your screen for each file.

The format is


ncftpget -u username -R -c hostname-of-ftp-server local-directory remote-directory

Of course it is recommended to use ftp as a last resort, otherwise you should use secure tools or protocols for security reasons. Recommended ones are sftp and scp.

osama bin laden is dead

Killing obama from the command line in linux

$whoami
bush
$rm -rf /bin/laden
permission denied
$su obama
$date
05-01-2011
$pwd
/home/pakistan/abbottabad
$rm -rf /bin/laden
file permanently deleted
$echo “We got him” > potus.txt | wall

No doubt Microsoft windows is the “most used” operating system in personal computers, including laptops and netbooks. Not “most popular”, rather “most used”, as popularity comes with freedom of choice. Nearly all windows users are using windows just because it came preinstalled in their computers. Same argument applies to Apple and OS X. On the other hand, Linux users have to pick Linux just because they think it gets the job done for them well. In my experience, most Linux users are the ones who had previously tried different operating systems and had to finally stick with Linux. This is not to imply that Linux is the best operating system, but rather to say it has certain unique advantages compared to other operating systems. It is free, as in freedom, and again generally free, as in cost. It tends to be reliable and has multiple distributions, which gives you the choice to pick the one which suits you well. Techgradar has a nice article on this, by Nick Bothwick.

http://www.techradar.com/news/software/operating-systems/20-reasons-you-should-switch-to-linux-912294

Unblocking a host

Is your firewall blocking connection from a host and still you want to unblock the IP address of the remote host? Here is one way of doing it:

1. Do a listing of firewall rules and grep the IP (eg. 1.2.3.4)
$ /sbin/iptables -L INPUT -n –line-numbers | grep 1.2.3.4

-write down the line number.
-If the chain name is different or user defined, replace “INPUT” by the relevant chain name such as OUTPUT.

2. Delete the line number (eg. for line number 99 and chain INPUT)

$/sbin/iptables -D INPUT 99

@credit to: http://www.cyberciti.biz/faq/iptables-delete-ip-address-subnet-from-linux-firewall/

Block a host

Normally if you want to block all requests to and from an IP address, iptables is an ideal solution. A rule similar to this one would be handy

/sbin/iptables -A INPUT -s 1.2.3.4 -j DROP

What if you want to block that IP without using iptables, route command would do the job

/sbin/route add -host 1.2.3.4 reject