<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>TechniTip.Net &#187; script</title> <atom:link href="http://technitip.net/tag/script/feed" rel="self" type="application/rss+xml" /><link>http://technitip.net</link> <description>TechniTip.Net - Useful tips regarding technical stuff for things like Linux, MySQL, Apache, PHP, Linux Server, iPhone and more.</description> <lastBuildDate>Sun, 05 Sep 2010 09:32:08 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.1</generator> <image><link>http://technitip.net</link> <url>http://technitip.net/wp-content/plugins/maxblogpress-favicon/icons/favicon-66.ico</url><title>TechniTip.Net</title> </image> <item><title>How do you protect your Blog from Hackers?</title><link>http://technitip.net/how-do-you-protect-your-blog-from-hackers</link> <comments>http://technitip.net/how-do-you-protect-your-blog-from-hackers#comments</comments> <pubDate>Sun, 08 Aug 2010 16:08:34 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Latest Featured]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Linux Server]]></category> <category><![CDATA[Perl]]></category> <category><![CDATA[WordPress]]></category> <category><![CDATA[Blog]]></category> <category><![CDATA[hacker]]></category> <category><![CDATA[htaccess]]></category> <category><![CDATA[perl]]></category> <category><![CDATA[protect]]></category> <category><![CDATA[script]]></category><guid isPermaLink="false">http://technitip.net/?p=1511</guid> <description><![CDATA[Using WordPress is nice and many websites use it. The advantage of course that there are many tips, additional plugins etc. are available. But on the other hand there is a big disadvantage. Hackers attack WordPress sitse due to many many sites use it. I found an article and video from Matt Cutts an employee [...]<div style="clear: both;"> <strong>Related posts:</strong><ol><li><a href='http://technitip.net/wordpress-3-0-%e2%80%9ethelonious%e2%80%9c-update' rel='bookmark' title='Permanent Link: WordPress 3.0 „Thelonious“ Update'>WordPress 3.0 „Thelonious“ Update</a></li><li><a href='http://technitip.net/limit-your-wordpress-tag-cloud' rel='bookmark' title='Permanent Link: Limit Your WordPress Tag Cloud'>Limit Your WordPress Tag Cloud</a></li><li><a href='http://technitip.net/howto-beautify-ugly-php-urls' rel='bookmark' title='Permanent Link: Howto Beautify Ugly .PHP URL&#8217;s'>Howto Beautify Ugly .PHP URL&#8217;s</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p>Using WordPress is nice and many websites use it. The advantage of course that there are many tips, additional plugins etc. are available. But on the other hand there is a big disadvantage. Hackers attack WordPress sitse due to many many sites use it. I found an <a title="Three tips to protect your WordPress installation" href="http://www.mattcutts.com/blog/three-tips-to-protect-your-wordpress-installation/" target="_blank">article</a> and <a title="How do you protect your blog from hackers? " href="http://www.youtube.com/watch?v=gwAlEf-AbCU" target="_blank">video</a> from Matt Cutts an employee from Google.</p><p>He recommends to protect your wp-admin area using the Apache .htaccess file. Here in detail access is only allowed from IP addresses from where you are logging in. It&#8217;s definitely a good way to protect you blog, but often people don&#8217;t have a fixed IP address. The DSL provider assigns a different IP address on every dial in. Unfortunately there is no easy way to obtain the network addresses of your DSL provider which can be entered in your .htaccess file.</p><p>Another important recommendation: Always keep your server software and WordPress software up to date!</p><p>Also remove the following line from your header.php which will show hackers your WordPress version:</p><p><code>&lt;meta name=”generator” content=”WordPress &lt;?php  bloginfo(’version’); ?&gt;” /&gt; &lt;!-– leave this for stats please  --&gt;</code></p><p>So let&#8217;s concentrate on the restricted access in the wp-admin area. It&#8217;s a little bit tricky to get the address list of your DSL provider. I&#8217;ll explain and show an example script below. First let&#8217;s have a look at the <a title="How do you protect your blog from hackers? " href="http://www.youtube.com/watch?v=gwAlEf-AbCU" target="_blank">video</a> from Matt Cutts.<br /> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="618" height="373" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/gwAlEf-AbCU&amp;hl=en_GB&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="618" height="373" src="http://www.youtube.com/v/gwAlEf-AbCU&amp;hl=en_GB&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p><p>As step one you have to find out your own IP address. Let&#8217;s assume your IP address assigned from your provider is 213.168.95.20 (this is just an example!). Next do a whois lookup:</p><pre>server:~# whois 213.168.95.20
...
inetnum:        213.168.95.0 - 213.168.98.255
<strong>netname:        NC-DIAL-IN-POOL</strong>
</pre><p>Have a look at the <strong>netname NC-DIAL-IN-POOL</strong>. Usually provider assign  a common name for all DSL dynamic address. But we want to add all IP addresses or better all network ranges into our .htaccess file. Ok now we need to get all address ranges with this netname. This can be achieved using the Linux whois tool:</p><pre>server:~# whois -h whois.ripe.net NC-DIAL-IN-POOL
...
inetnum:        194.8.209.0 - 194.8.209.255
...
inetnum:        194.8.205.0 - 194.8.205.255
...
</pre><p>Fine we get a list with all network ranges from our provider now, but still not the correct netmask format and a lot of other output which we don&#8217;t need. Basically it&#8217;s possible to manually generate the .htaccess file now. Not big fun&#8230; So I&#8217;ve created a small perl script which does the job. As small bonus it creates the needed format for .htaccess file which means you are able to directly add the output to your .htaccess file in the wp-admin folder.</p><p><strong>Important:</strong> Before usage you have to add the <strong>netname</strong> of the dial-in pool of your provider. How to find it out is described above. Below is only an example. The output will look like:</p><pre>server:~# ./gethtaccessranges.sh
allow from 194.8.209.0/24
allow from 194.8.205.0/24
allow from 195.14.226.0/24
</pre><p>Finally generate a .htaccess file in your wp-admin/ folder with the content:</p><pre>order deny,allow
deny from all</pre><p>and add the output of the script gethtaccessranges.sh below the two lines. That&#8217;s it! Now access to wp-admin is only allowed from dynamic IP address from your provider. Sure it&#8217;s not the perfect solution but I&#8217;ll prevent you from many other hack attempts from all over the world.</p><p>At the end of the script there is also an example in case providers use number in their netnames.</p><pre>#!/usr/bin/perl -w
# gethtaccessranges.sh
# Harald Kraemer 08.08.2010
# www.technnitip.net
#
# NET::CIDR and NET::Whois is need to run this script.
# On debian you can install using apt-get:
# apt-get install libnet-cidr-perl libnet-whois-perl
#
<strong># Important: Replace the netname "NC-DIAL-IN-POOL" at the end of the
# script with the dial-in netname of your provider! Use the command
# whois &lt;my-ip-address&gt; to find out the netname.</strong>

use Net::CIDR;
use Net::CIDR ':all';
use Net::Whois::Raw;
use strict;

sub getRanges
{
  my($netname) = @_;
  my $whois;
  my @whois_array;
  my @ranges;

  $whois = whois( $netname, 'whois.ripe.net' );

  @whois_array   = split( "\n", $whois );
  @ranges        = grep( /inetnum:/, @whois_array );

  foreach ( @ranges )
  {
    s/inetnum://g;
    s/ //g;
    s/ - /-/g;

    foreach my $item ( Net::CIDR::range2cidr( $_ ) )
    {
      print "allow from " . $item . "\n";
    }
  }
}

getRanges('NC-DIAL-IN-POOL');

#for( my $i=1; $i &lt;= 30; $i++)
#{
#  getRanges('DTAG-DIAL' . $i);
#}</pre><div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ftechnitip.net%2Fhow-do-you-protect-your-blog-from-hackers&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 50px;"></iframe></div><div style="clear: both;"><p><strong>Related posts:</strong><ol><li><a href='http://technitip.net/wordpress-3-0-%e2%80%9ethelonious%e2%80%9c-update' rel='bookmark' title='Permanent Link: WordPress 3.0 „Thelonious“ Update'>WordPress 3.0 „Thelonious“ Update</a></li><li><a href='http://technitip.net/limit-your-wordpress-tag-cloud' rel='bookmark' title='Permanent Link: Limit Your WordPress Tag Cloud'>Limit Your WordPress Tag Cloud</a></li><li><a href='http://technitip.net/howto-beautify-ugly-php-urls' rel='bookmark' title='Permanent Link: Howto Beautify Ugly .PHP URL&#8217;s'>Howto Beautify Ugly .PHP URL&#8217;s</a></li></ol></p></div>]]></content:encoded> <wfw:commentRss>http://technitip.net/how-do-you-protect-your-blog-from-hackers/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>VMWare ESX Backup Script</title><link>http://technitip.net/vmware-esx-backup-script</link> <comments>http://technitip.net/vmware-esx-backup-script#comments</comments> <pubDate>Fri, 02 Jan 2009 15:03:07 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[VMWare]]></category> <category><![CDATA[backup]]></category> <category><![CDATA[esx]]></category> <category><![CDATA[script]]></category> <category><![CDATA[vmware infrastructure]]></category><guid isPermaLink="false">http://technitip.net/?p=140</guid> <description><![CDATA[There is a simple method doing automated backups using VMWare Infrastructure 3. For this reason a command &#8220;vcbMounter&#8221; is included. Also the name of this command is confusing it can be used for doing backups of virtual machines. Doing a backup of a virtual machine can be done using a single command line call: vcbMounter [...]<div style="clear: both;"> <strong>Related posts:</strong><ol><li><a href='http://technitip.net/simple-mysql-backup-script' rel='bookmark' title='Permanent Link: Simple MySql Backup Script'>Simple MySql Backup Script</a></li><li><a href='http://technitip.net/vmware-esxi-test-installation' rel='bookmark' title='Permanent Link: VMWare ESXi Test Installation'>VMWare ESXi Test Installation</a></li><li><a href='http://technitip.net/wrong-keyboard-layout-with-vmware-and-vnc' rel='bookmark' title='Permanent Link: Wrong Keyboard Layout with VMWare and VNC'>Wrong Keyboard Layout with VMWare and VNC</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p>There is a simple method doing automated backups using VMWare Infrastructure 3. For this reason a command &#8220;vcbMounter&#8221; is included. Also the name of this command is confusing it can be used for doing backups of virtual machines.</p><p>Doing a backup of a virtual machine can be done using a single command line call:</p><pre>vcbMounter -a name:"Virtual-Machine-1" -r "/path/to/backup/Virtual-Machine-1"</pre><p>Ok, your vm named &#8220;Virtual-Machine-1&#8243; will now be backuped to the given path. The directory is generated from vcbMounter. The next time you will run vcbMounter it will complain that the directory already exists, so you will have to delete the directory every time before you start the backup:</p><pre>rm -rf "/path/to/backup/Virtual-Machine-1"
vcbMounter -a name:"Virtual-Machine-1" -r "/path/to/backup/Virtual-Machine-1"</pre><p>But there is another problem which will cause vcbMounter to complain: For every backup vcbMounter generates a snapshot and will not remove it after backup. What we need is to delete the snapshot before we backup:</p><pre>vmware-cmd "/vmfs/volumes/storage1/Virtual-Machine-1.vmx" removesnapshots

rm -rf "/path/to/backup/Virtual-Machine-1"

vcbMounter -a name:"Virtual-Machine-1" -r "/path/to/backup/Virtual-Machine-1"</pre><p>We delete the snapshots for a given virtual machine using &#8220;vmware-cmd&#8221; and removesnapshots. vmware-cmd needs the path to your .vmx file of the virtual machine. It&#8217;s usually stored in /vmfs/volumes/&#8230;</p><p>vcbMounter does not expect the path to the .vmx. It only needs the name of your virtual machine.</p><p>Doing the backup on a NFS mount is also possible. You need to deactive the VMWare ESX firewall and can mount e.g. using &#8220;mount -t smbfs&#8221;.</p><div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ftechnitip.net%2Fvmware-esx-backup-script&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 50px;"></iframe></div><div style="clear: both;"><p><strong>Related posts:</strong><ol><li><a href='http://technitip.net/simple-mysql-backup-script' rel='bookmark' title='Permanent Link: Simple MySql Backup Script'>Simple MySql Backup Script</a></li><li><a href='http://technitip.net/vmware-esxi-test-installation' rel='bookmark' title='Permanent Link: VMWare ESXi Test Installation'>VMWare ESXi Test Installation</a></li><li><a href='http://technitip.net/wrong-keyboard-layout-with-vmware-and-vnc' rel='bookmark' title='Permanent Link: Wrong Keyboard Layout with VMWare and VNC'>Wrong Keyboard Layout with VMWare and VNC</a></li></ol></p></div>]]></content:encoded> <wfw:commentRss>http://technitip.net/vmware-esx-backup-script/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>MySQL Optimize Script</title><link>http://technitip.net/mysql-optimize-script</link> <comments>http://technitip.net/mysql-optimize-script#comments</comments> <pubDate>Wed, 31 Dec 2008 00:08:40 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[PHP/MySQL]]></category> <category><![CDATA[optimize]]></category> <category><![CDATA[php]]></category> <category><![CDATA[script]]></category><guid isPermaLink="false">http://planlos.org/~harry/php/?p=114</guid> <description><![CDATA[A nice small PHP script which simple connects to a given MySQL server and optimizes all databases and included tables. Only the internal table &#8220;information_schema&#8221; is skipped because it will show an error. Working with MySQL version 5.0.32 and PHP version 5.2.0 on Debian Etch. Script is designed to run from command line &#8220;php optimize.php&#8221; [...]<div style="clear: both;"> <strong>Related posts:</strong><ol><li><a href='http://technitip.net/simple-mysql-backup-script' rel='bookmark' title='Permanent Link: Simple MySql Backup Script'>Simple MySql Backup Script</a></li><li><a href='http://technitip.net/simple-php-flood-protection-class' rel='bookmark' title='Permanent Link: Simple PHP Flood Protection Class'>Simple PHP Flood Protection Class</a></li><li><a href='http://technitip.net/mysql-performance-tips' rel='bookmark' title='Permanent Link: MySQL Performance Tips'>MySQL Performance Tips</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p>A nice small PHP script which simple connects to a given MySQL server and optimizes all databases and included tables. Only the internal table &#8220;information_schema&#8221; is skipped because it will show an error.</p><p>Working with MySQL version 5.0.32 and PHP version 5.2.0 on Debian Etch.</p><p>Script is designed to run from command line &#8220;php optimize.php&#8221; maybe from a cron job. Be careful: avoid running this script during your server &#8220;rush hour&#8221;, it may slow down your server.</p><pre>&lt;?php
/***********************************************************
 optimimze.php - optimizes all databases and tables of the
                 given mysql host.

 2008 - technitip.net
 ***********************************************************/

$mysqlhost = "localhost"; // enter MySQL host
$mysqluser = "user";      // enter MySQL user
$mysqlpwd  = "password";  // enter password

###########################################

$connection = mysql_connect($mysqlhost, $mysqluser, $mysqlpwd);
if (mysql_error())
{
  echo "Could not connect to database server! " . mysql_error() . "\n";
  exit;
}

$db_list = mysql_list_dbs();
$i = 0;
$cnt = mysql_num_rows($db_list);

while ($i &lt; $cnt)
{
  $db = mysql_db_name($db_list, $i);
  ###########################################
  mysql_select_db($db, $connection);
  $result = mysql_list_tables($db);

  while ($row = mysql_fetch_row($result))
  {
    if ( $db == "information_schema" )
      continue;

    echo $db . " : `" . $row[0] . "`";

    $sql = "OPTIMIZE TABLE `".$row[0]."`";
    $erg = mysql_query($sql, $connection) or die(mysql_error());
    $data= mysql_fetch_array($erg, MYSQL_ASSOC);

    if($data)
    {
      echo " - " . $data['Msg_text'] . "\n";
    }
  }
  ###########################################
  $i++;
}

?&gt;</pre><div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ftechnitip.net%2Fmysql-optimize-script&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 50px;"></iframe></div><div style="clear: both;"><p><strong>Related posts:</strong><ol><li><a href='http://technitip.net/simple-mysql-backup-script' rel='bookmark' title='Permanent Link: Simple MySql Backup Script'>Simple MySql Backup Script</a></li><li><a href='http://technitip.net/simple-php-flood-protection-class' rel='bookmark' title='Permanent Link: Simple PHP Flood Protection Class'>Simple PHP Flood Protection Class</a></li><li><a href='http://technitip.net/mysql-performance-tips' rel='bookmark' title='Permanent Link: MySQL Performance Tips'>MySQL Performance Tips</a></li></ol></p></div>]]></content:encoded> <wfw:commentRss>http://technitip.net/mysql-optimize-script/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Simple MySql Backup Script</title><link>http://technitip.net/simple-mysql-backup-script</link> <comments>http://technitip.net/simple-mysql-backup-script#comments</comments> <pubDate>Tue, 30 Dec 2008 13:44:28 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[PHP/MySQL]]></category> <category><![CDATA[backup]]></category> <category><![CDATA[script]]></category><guid isPermaLink="false">http://planlos.org/~harry/php/?p=92</guid> <description><![CDATA[The following example scripts performs a simple backup of all MySQL databases. The resulting .sql file is automatically zipped. Using &#8220;find&#8221; backups older than 3 days are deleted, so you will get complete backups of the last 3 days. This script is intended to be called periodically (e.g. every day) from cron: 2 2       * [...]<div style="clear: both;"> <strong>Related posts:</strong><ol><li><a href='http://technitip.net/vmware-esx-backup-script' rel='bookmark' title='Permanent Link: VMWare ESX Backup Script'>VMWare ESX Backup Script</a></li><li><a href='http://technitip.net/mysql-optimize-script' rel='bookmark' title='Permanent Link: MySQL Optimize Script'>MySQL Optimize Script</a></li><li><a href='http://technitip.net/simple-php-flood-protection-class' rel='bookmark' title='Permanent Link: Simple PHP Flood Protection Class'>Simple PHP Flood Protection Class</a></li></ol></div>]]></description> <content:encoded><![CDATA[<p>The following example scripts performs a simple backup of all MySQL databases. The resulting .sql file is automatically zipped. Using &#8220;find&#8221; backups older than 3 days are deleted, so you will get complete backups of the last 3 days.</p><p>This script is intended to be called periodically (e.g. every day) from cron:</p><pre>2 2       * * *   root /root/scripts/mysql_backup.sh</pre><pre>#/bin/sh
now=`date "+%Y-%m-%d"`
user="mysql_user"
password="mysql_password"
path="/home/backup/"

cd $path

mysqldump -u $user -p$password  --all-databases | gzip -c &gt; backup_all_$now.sql.gz

# delete files older than 3 days
find . -name "*.gz" -type f -mtime +3 -exec rm {} ";"</pre><div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Ftechnitip.net%2Fsimple-mysql-backup-script&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height: 50px;"></iframe></div><div style="clear: both;"><p><strong>Related posts:</strong><ol><li><a href='http://technitip.net/vmware-esx-backup-script' rel='bookmark' title='Permanent Link: VMWare ESX Backup Script'>VMWare ESX Backup Script</a></li><li><a href='http://technitip.net/mysql-optimize-script' rel='bookmark' title='Permanent Link: MySQL Optimize Script'>MySQL Optimize Script</a></li><li><a href='http://technitip.net/simple-php-flood-protection-class' rel='bookmark' title='Permanent Link: Simple PHP Flood Protection Class'>Simple PHP Flood Protection Class</a></li></ol></p></div>]]></content:encoded> <wfw:commentRss>http://technitip.net/simple-mysql-backup-script/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>