<?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>Linux, MySQL, PhP, Perl... &#187; Linux</title>
	<atom:link href="http://linux.bgsnow.com/tag/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://linux.bgsnow.com</link>
	<description></description>
	<lastBuildDate>Fri, 18 Jun 2010 16:30:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Google Gadgets on Linux</title>
		<link>http://linux.bgsnow.com/google-gadgets-on-linux.php</link>
		<comments>http://linux.bgsnow.com/google-gadgets-on-linux.php#comments</comments>
		<pubDate>Fri, 16 Oct 2009 15:10:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Google Gadgets]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=170</guid>
		<description><![CDATA[What is a gadget? The first definition that appears is &#8216;a device or control that is very useful for a particular job&#8216;. A more common understanding of a gadget is a pretty graphic staying on your desktop and displaying system information, weather or anything else&#8230; Gadgets are available not only for graphical desktop environments. There [...]]]></description>
			<content:encoded><![CDATA[<p>What is a gadget? The first definition that appears is &#8216;<em>a device or control that is very useful for a particular job</em>&#8216;. A more common understanding of a gadget is a pretty graphic staying on your desktop and displaying system information, weather or anything else&#8230;</p>
<p>Gadgets are available not only for graphical desktop environments. There are gadgets for web applications such as WordPress for example.</p>
<p>Still in this article I&#8217;ll make a review of Google gadgets running on Linux. I have bought a new Lenovo last month and since then I have left my old LXDE in favour of the good old Gnome. Of course, this change has had to come with lots more graphical extras <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So my next move was to install some gadgets and I can&#8217;t even remember how I stumbled upon Google gadgets. The very first thing I liked is the big analogue clock. The most useful gadget is the one for checking Gmail. Here is how my Desktop looks like now:</p>
<p><a href="http://linux.bgsnow.com/wp-content/uploads/2009/10/gadgets.png"><img class="alignnone size-medium wp-image-173" title="Google Gadgets on Linux" src="http://linux.bgsnow.com/wp-content/uploads/2009/10/gadgets-300x168.png" alt="Google Gadgets" width="300" height="168" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/google-gadgets-on-linux.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate random string in Linux</title>
		<link>http://linux.bgsnow.com/generate-random-string-in-linux.php</link>
		<comments>http://linux.bgsnow.com/generate-random-string-in-linux.php#comments</comments>
		<pubDate>Thu, 08 Oct 2009 08:01:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[makepasswd]]></category>
		<category><![CDATA[random generator]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=162</guid>
		<description><![CDATA[You probably know about /dev/random and /dev/urandom when it comes to generating a random string. Usually the problem is that these devices are not directly usable for ascii generators. This means that little conversion is necessary and here is one way to do it: $ dd if=/dev/urandom count=128 bs=1 2&#62;&#38;1 &#124; md5sum &#124; cut -b-10 [...]]]></description>
			<content:encoded><![CDATA[<p>You probably know about /dev/random and /dev/urandom when it comes to generating a random string. Usually the problem is that these <em>devices</em> are not directly usable for ascii generators. This means that little conversion is necessary and here is one way to do it:</p>
<p>$ dd if=/dev/urandom count=128 bs=1 2&gt;&amp;1 | md5sum | cut -b-10</p>
<p>This will generate a random string of 10 symbols. In order to change its length just change the last number from 10.</p>
<p>There are also some ready to use utilities such as <strong>makepasswd</strong> which are available on Ubuntu and other distributions. You can generate 10 characters with makepasswd as follows:</p>
<p>$ makepasswd &#8211;char=10</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/generate-random-string-in-linux.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thunderbird, Google Chrome and Linux</title>
		<link>http://linux.bgsnow.com/thunderbird-google-chrome-and-linux.php</link>
		<comments>http://linux.bgsnow.com/thunderbird-google-chrome-and-linux.php#comments</comments>
		<pubDate>Sun, 09 Aug 2009 07:00:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[google-chrome]]></category>
		<category><![CDATA[Thunderbird]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=143</guid>
		<description><![CDATA[Even if you have changed to Google Chrome your default browser in Linux, Thunderbird will not respect it. It will continue to open links in Firefox. Under Linux (Ubuntu and its derivatives for sure) there is only one way to amend this. Go to .mozilla-thunderbird, find the directory for your profile (something like rv7dwavi.default) and [...]]]></description>
			<content:encoded><![CDATA[<p>Even if you have changed to <a href="http://linux.bgsnow.com/ubuntu-change-default-browser-to-google-chrome.php" target="_blank">Google Chrome your default browser in Linux</a>, Thunderbird will not respect it. It will continue to open links in Firefox.</p>
<p>Under Linux (Ubuntu and its derivatives for sure) there is only one way to amend this. Go to .mozilla-thunderbird, find the directory for your profile (something like rv7dwavi.default) and open the file prefs.js.</p>
<p>Then search for the strings  <em>network.protocol-handler.app.htt</em>p and <em>network.protocol-handler.app.https. </em></p>
<p>Usually these directives are missing so you can safely add them anew as follows:</p>
<p><em>user_pref(&#8220;network.protocol-handler.app.http&#8221;, &#8220;google-chrome&#8221;);</em></p>
<p><em>user_pref(&#8220;network.protocol-handler.app.https&#8221;, &#8220;google-chrome&#8221;);</em></p>
<p>That&#8217;s all and from now on Thunderbird will open all links in Google Chrome.</p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/thunderbird-google-chrome-and-linux.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deleting malicious code from many files</title>
		<link>http://linux.bgsnow.com/deleting-malicious-code-from-many-files.php</link>
		<comments>http://linux.bgsnow.com/deleting-malicious-code-from-many-files.php#comments</comments>
		<pubDate>Sat, 12 Apr 2008 13:23:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[viruses]]></category>
		<category><![CDATA[worms]]></category>

		<guid isPermaLink="false">http://linux.bgsnow.com/?p=8</guid>
		<description><![CDATA[When a hacker / cracker compromises a website there is usually some malicious code inserted in html, php and other files. Usually cleaning it is a 5 minutes job In our case, we will assume the attacker has inserted the following string &#8220;&#60;script&#62; bla$%333%blablalalala &#60;/script&#62;&#8221; at random lines inline in PHP files. Here is an [...]]]></description>
			<content:encoded><![CDATA[<p>When a hacker / cracker compromises a website there is usually some malicious code inserted in html, php and other files. Usually cleaning it is a 5 minutes job <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In our case, we will assume the attacker has inserted the following string &#8220;&lt;script&gt; bla$%333%blablalalala &lt;/script&gt;&#8221; at random lines inline in PHP files. Here is an example:</p>
<p>&lt;?php</p>
<p>echo &#8216;Supa site blabla&#8217;; &lt;script&gt; bla$%333%blablalalala &lt;/script&gt;</p>
<p>include(&#8216;hackme.php&#8217;);</p>
<p>?&gt;</p>
<p>No problem to clean this with sed and a simple regular expression:</p>
<p>find -name &#8220;*.php&#8221; |xargs sed -i &#8216;s/&lt;script&gt;.*blabla.*&lt;\/script&gt;//g&#8217;</p>
<p>First we find every php file and pass it to sed with xargs. Then sed looks for anything that begins with &lt;script&gt; has anything inside(.*), has blabla somewhere in the middle, again has anything and ends with &lt;/script&gt;. The &#8220;/&#8221; has been escaped with &#8220;\&#8221; while .* means anything.</p>
<p>The above will work as long as you customize it for your case. You just have to change script&#8217;s opening and closing tags to anything else the attacker has used to begin and end his stuff.</p>
<p>In my experience I have come upon one problem with such cases. The attacker&#8217;s script left a blank line between or after his malicious code. When the malicious code is inserted at the end of a php file, this means that php files will have an empty line in the end after cleaning up the malicious code. Then you will get warnings such as &#8220;Headers already sent&#8221;. In this case we will have to delete the last empty lines from all php files using this sed string:</p>
<p>find -name &#8220;*.php&#8221; |xargs sed -i &#8216;${/^$/d}&#8217;</p>
<p>However, sometimes hackers / crackers play it hard and insert the malicious code over several lines. In this case sed would not help, because it processes the file line by line. The easiest solution is using this perl script:</p>
<p>$cat multiline-replace.pl</p>
<p><strong>#!/usr/bin/perl<br />
open(INPUT,&#8221;&lt;$ARGV[0]&#8220;) or die;<br />
@input_array=&lt;INPUT&gt;;<br />
close(INPUT);<br />
$input_scalar=join(&#8220;&#8221;,@input_array);<br />
# Do your substitution here.<br />
$input_scalar =~ s#</strong><em>\&lt;\?php.*</em><em>maliciouspattern</em><em>.*\n.*\n.*?&gt;</em><em>\n</em><strong>##ig;<br />
open(OUTPUT,&#8221;&gt;$ARGV[0]&#8220;) or die;<br />
print(OUTPUT $input_scalar);<br />
close(OUTPUT);</strong></p>
<p>First, the above has been copied almost literary from <a href="http://www.linuxquestions.org/questions/linux-newbie-8/perl-multi-line-search-and-replace...-can-i...-523942/" target="_blank">linuxquesions.org</a>. There are two important things about it:</p>
<p><em>\&lt;\?php.*maliciouspattern.*\n.*\n.*?&gt;\n</em> is the regular expression which matches (with the escapes):</p>
<p>&lt;?php <em>maliciouspattern</em> <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ))<br />
//I am a smart hacker, am not I ;P<br />
?&gt;</p>
<p>I have added an additional <em>\n</em> to the regex because otherwise it leaves a blank line <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The next thing is that the script looks for the first argument from the standard input. So if you&#8217;d like to run the above on all *.php scripts recursively, you should do it like this:</p>
<p><strong>for i in `find -name &#8220;*.php&#8221;`; do ./multiline-replace.pl $i; done</strong></p>
<p>The above runs the script file by file. It might take a bit longer but it will not exceed the maximum length for a bash variable no matter how many files you have, nor it will cause too high load on the server.</p>
<p>If you make the mistake to leave an empty line in one of sed&#8217;s mutations, here is how to delete it:</p>
<p><span style="font-size: small;">sed -i &#8216;/./,/^$/!d&#8217;</span></p>
<p>Hopefully this helps you fight those bad people and make the world better <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Don&#8217;t forget to make backups because all kinds of crazy stuff happens <img src='http://linux.bgsnow.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://linux.bgsnow.com/deleting-malicious-code-from-many-files.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
