<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[UAE Linux User Group - [Shell-Scripting] Simple Webserver]]></title>
		<link>http://uaelug.org/topic/38/shellscripting-simple-webserver/</link>
		<description><![CDATA[The most recent posts in [Shell-Scripting] Simple Webserver.]]></description>
		<lastBuildDate>Wed, 15 Jul 2009 22:58:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/270/#p270</link>
			<description><![CDATA[<p>You should inform your superiors that everything one does in IE is permanently cached and stored in another completely hidden directory, even if you delete your history, cookies, and cache. This link provides more details:</p><p><a href="http://membrane.com/security/secure/Microsoft_Is_Unscrupulous.html">http://membrane.com/security/secure/Mic &#133; ulous.html</a></p><p>Not to mention that it&#039;d probably be a good idea to give them a detailed report on how insecure IE is. Print out reports, and tell them that their company&#039;s computer security is at risk. Just word it up to make it seem really serious.</p>]]></description>
			<author><![CDATA[dummy@example.com (AdmiralA)]]></author>
			<pubDate>Wed, 15 Jul 2009 22:58:17 +0000</pubDate>
			<guid>http://uaelug.org/post/270/#p270</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/265/#p265</link>
			<description><![CDATA[<div class="quotebox"><cite>xaitax wrote:</cite><blockquote><p>Will I be lapidated if I say - I don&#039;t care about IE? <img src="http://uaelug.org/img/smilies/lol.png" width="15" height="15" alt="lol" /><br />Especially IE6.</p><p>Please have a look now, I changed something in the src. <br />Does it still look like before?</p></blockquote></div><p>Neither do I <img src="http://uaelug.org/img/smilies/hmm.png" width="15" height="15" alt="hmm" /> But we gotta do what we gotta do. IE is the standard one in this company <img src="http://uaelug.org/img/smilies/mad.png" width="15" height="15" alt="mad" /></p><p>It&#039;s not fixed yet. If you&#039;ll keep trying, it&#039;s for other members, I&#039;m fine with the current one since I know how to get it.</p><br /><div class="quotebox"><cite>dan_r wrote:</cite><blockquote><p>P.S.: Tell your boss to install Firefox so you can surf properly <img src="http://uaelug.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p></blockquote></div><p>Thanks for explaning what the script does.</p><p>It&#039;s not allowed to install apps ... I already got my final warning .. Thank you <img src="http://uaelug.org/img/smilies/sad.png" width="15" height="15" alt="sad" /></p>]]></description>
			<author><![CDATA[dummy@example.com (linuxhat)]]></author>
			<pubDate>Wed, 15 Jul 2009 05:28:30 +0000</pubDate>
			<guid>http://uaelug.org/post/265/#p265</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/264/#p264</link>
			<description><![CDATA[<p>Oh, sorry. I completely read it over.<br />But Dan&#039;s explanation was - of course - 100% correct. <img src="http://uaelug.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (xaitax)]]></author>
			<pubDate>Tue, 14 Jul 2009 09:23:21 +0000</pubDate>
			<guid>http://uaelug.org/post/264/#p264</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/262/#p262</link>
			<description><![CDATA[<div class="quotebox"><cite>linuxhat wrote:</cite><blockquote><div class="quotebox"><cite>linuxhat wrote:</cite><blockquote><p>What about adding this line? Good honeypot if you watch the logs, might become very interesting.</p></blockquote></div><p>What would this script do? Can you give us a brief explanation?</p></blockquote></div><p>If I understand correctly, adding this line would identify our &quot;web server&quot; as an old Apache/PHP stack that can be exploited.&nbsp; Unpleasant people out there are scanning automatically for servers running vulnerable software.</p><p>Without much effort, you might capture a real attack in your log file.&nbsp; That would be most excellent.&nbsp; Like catching a fox with a piece of bubble gum and a shoe string.</p><p>P.S.: Tell your boss to install Firefox so you can surf properly <img src="http://uaelug.org/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (dan_r)]]></author>
			<pubDate>Tue, 14 Jul 2009 09:12:11 +0000</pubDate>
			<guid>http://uaelug.org/post/262/#p262</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/261/#p261</link>
			<description><![CDATA[<p>Will I be lapidated if I say - I don&#039;t care about IE? <img src="http://uaelug.org/img/smilies/lol.png" width="15" height="15" alt="lol" /><br />Especially IE6.</p><p>Please have a look now, I changed something in the src. <br />Does it still look like before?</p>]]></description>
			<author><![CDATA[dummy@example.com (xaitax)]]></author>
			<pubDate>Tue, 14 Jul 2009 09:06:33 +0000</pubDate>
			<guid>http://uaelug.org/post/261/#p261</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/260/#p260</link>
			<description><![CDATA[<p>I&#039;m using XP and IE at work. <img src="http://uaelug.org/img/smilies/sad.png" width="15" height="15" alt="sad" /></p><p><span class="postimg"><img src="http://img33.imageshack.us/img33/3209/snapshotqjv.jpg" alt="http://img33.imageshack.us/img33/3209/snapshotqjv.jpg" /></span></p>]]></description>
			<author><![CDATA[dummy@example.com (linuxhat)]]></author>
			<pubDate>Tue, 14 Jul 2009 08:56:47 +0000</pubDate>
			<guid>http://uaelug.org/post/260/#p260</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/259/#p259</link>
			<description><![CDATA[<p>I have no idea which funny operating system and browser you use, but with me, everything is fine <img src="http://uaelug.org/img/smilies/big_smile.png" width="15" height="15" alt="big_smile" /><br />Can you post a screenshot please?</p>]]></description>
			<author><![CDATA[dummy@example.com (xaitax)]]></author>
			<pubDate>Tue, 14 Jul 2009 08:30:06 +0000</pubDate>
			<guid>http://uaelug.org/post/259/#p259</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/258/#p258</link>
			<description><![CDATA[<div class="quotebox"><cite>xaitax wrote:</cite><blockquote><p>Did I miss something? It is?</p><p>[1] <a href="http://www.dd-wrt.com/dd-wrtv3/index.php">http://www.dd-wrt.com/dd-wrtv3/index.php</a></p><p>/xai</p></blockquote></div><p>There is command in the beigning of this post as shown below but the [ code ] option is hiding it:</p><p>A verbose command for downloading the top 3 videos from youtube:</p><div class="quotebox"><blockquote><p>wget <a href="http://www.youtube.com/">http://www.youtube.com/</a> -O - 2&gt; /dev/null | grep &quot;&lt;a href&quot; | sed &#039;s/.*&lt;a href/&lt;a href/&#039; |cut -f2 -d&#039;&quot;&#039; | grep &quot;popular&quot; | cut -f1 -d&#039;&amp;&#039; | head -n 3 | sed &#039;s/^/http:\/\/youtube.com/&#039; | xargs -i clive {} \;</p></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (linuxhat)]]></author>
			<pubDate>Tue, 14 Jul 2009 07:44:27 +0000</pubDate>
			<guid>http://uaelug.org/post/258/#p258</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/257/#p257</link>
			<description><![CDATA[<div class="quotebox"><cite>dan_r wrote:</cite><blockquote><p>Cool.&nbsp; But where would you run such a thing?&nbsp; VPS? (expensive)</p></blockquote></div><p>Yes, for example.<br />I could run it on my Router (Linksys WRT54G2 flashed with DD-WRT[1]) for a time.</p><div class="quotebox"><cite>linuxhat wrote:</cite><blockquote><p>Can you edit the 1st post to show the 1st verbose command:</p></blockquote></div><p>Did I miss something? It is?</p><p>[1] <a href="http://www.dd-wrt.com/dd-wrtv3/index.php">http://www.dd-wrt.com/dd-wrtv3/index.php</a></p><p>/xai</p>]]></description>
			<author><![CDATA[dummy@example.com (xaitax)]]></author>
			<pubDate>Tue, 14 Jul 2009 07:34:30 +0000</pubDate>
			<guid>http://uaelug.org/post/257/#p257</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/256/#p256</link>
			<description><![CDATA[<div class="quotebox"><cite>xaitax wrote:</cite><blockquote><p>Nice dan!</p><div class="codebox"><pre><code>xai@w00t:~# diff -Naur webserver.sh webserver_alex.sh
--- webserver.sh        2009-07-14 16:33:44.000000000 +0200
+++ webserver_alex.sh   2009-07-14 16:34:58.000000000 +0200
@@ -20,6 +20,7 @@
   if [ -f &quot;${docroot}/${url}&quot; ]; then
   echo -e &quot;HTTP/1.1 200 OK\r
   Content-Type: text/html; charset=ISO-8859-1\r
+  Server: Apache/1.2.6 PHP/4.0.6\r
   \r&quot;
   cat ${docroot}/${url}
   echo -e &quot;\r&quot;</code></pre></div><p>What about adding this line? Good honeypot if you watch the logs, might become very interesting.</p><p>/xai</p></blockquote></div><p>What would this script do? Can you give us a brief explanation?</p>]]></description>
			<author><![CDATA[dummy@example.com (linuxhat)]]></author>
			<pubDate>Tue, 14 Jul 2009 07:31:53 +0000</pubDate>
			<guid>http://uaelug.org/post/256/#p256</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/255/#p255</link>
			<description><![CDATA[<p>Thanks a lot Dan ... Awesome session indeed.</p><p>Alex,<br />Can you edit the 1st post to show the 1st verbose command:</p><p><strong>wget <a href="http://www.youtube.com/">http://www.youtube.com/</a> -O - 2&gt; /dev/null | grep &quot;&lt;a href&quot; | sed &#039;s/.*&lt;a href/&lt;a href/&#039; |cut -f2 -d&#039;&quot;&#039; | grep &quot;popular&quot; | cut -f1 -d&#039;&amp;&#039; | head -n 3 | sed &#039;s/^/http:\/\/youtube.com/&#039; | xargs -i clive {} \;</strong></p>]]></description>
			<author><![CDATA[dummy@example.com (linuxhat)]]></author>
			<pubDate>Tue, 14 Jul 2009 07:29:23 +0000</pubDate>
			<guid>http://uaelug.org/post/255/#p255</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/254/#p254</link>
			<description><![CDATA[<p>Cool.&nbsp; But where would you run such a thing?&nbsp; VPS? (expensive)</p>]]></description>
			<author><![CDATA[dummy@example.com (dan_r)]]></author>
			<pubDate>Tue, 14 Jul 2009 07:19:16 +0000</pubDate>
			<guid>http://uaelug.org/post/254/#p254</guid>
		</item>
		<item>
			<title><![CDATA[Re: [Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/251/#p251</link>
			<description><![CDATA[<p>Nice dan!</p><div class="codebox"><pre><code>xai@w00t:~# diff -Naur webserver.sh webserver_alex.sh
--- webserver.sh        2009-07-14 16:33:44.000000000 +0200
+++ webserver_alex.sh   2009-07-14 16:34:58.000000000 +0200
@@ -20,6 +20,7 @@
   if [ -f &quot;${docroot}/${url}&quot; ]; then
   echo -e &quot;HTTP/1.1 200 OK\r
   Content-Type: text/html; charset=ISO-8859-1\r
+  Server: Apache/1.2.6 PHP/4.0.6\r
   \r&quot;
   cat ${docroot}/${url}
   echo -e &quot;\r&quot;</code></pre></div><p>What about adding this line? Good honeypot if you watch the logs, might become very interesting.</p><p>/xai</p>]]></description>
			<author><![CDATA[dummy@example.com (xaitax)]]></author>
			<pubDate>Tue, 14 Jul 2009 05:56:33 +0000</pubDate>
			<guid>http://uaelug.org/post/251/#p251</guid>
		</item>
		<item>
			<title><![CDATA[[Shell-Scripting] Simple Webserver]]></title>
			<link>http://uaelug.org/post/250/#p250</link>
			<description><![CDATA[<p>This has been showed in July Meetup by <a href="http://uaelug.org/user/9/">dan_r</a>. Also presentet in the forums <a href="http://uaelug.org/post/247/#p247">here</a>!</p><p>As requested, here are some snippets from last night:</p><p>A verbose command for downloading the top 3 videos from youtube:<br /></p><div class="codebox"><pre><code>wget http://www.youtube.com/ -O - 2&gt; /dev/null | grep &quot;&lt;a href&quot; | sed &#039;s/.*&lt;a href/&lt;a href/&#039; |cut -f2 -d&#039;&quot;&#039; | grep &quot;popular&quot; | cut -f1 -d&#039;&amp;&#039; | head -n 3 | sed &#039;s/^/http:\/\/youtube.com/&#039; | xargs -i clive {} \;</code></pre></div><p>For the web server, here are the contents of a config file that must be added to /etc/xinetd.d/&nbsp; <br />(The name of the file doesn&#039;t matter):</p><div class="codebox"><pre><code>service www
{
    port           = 80
    protocol       = tcp
    wait           = no
    user           = root
    server         = /home/dan/uaelug/httpd/httpd
}</code></pre></div><p>And here&#039;s the example web server in bash script (for educational use only).</p><div class="codebox"><pre><code>#! /bin/bash

docroot=&quot;/home/dan/uaelug/httpd&quot;

# First line holds the HTTP request
read request

# Keep swallowing lines until you get a blank one
# Note: HTTP lines are terminated with CR LF, and CR=&#039;\r&#039;
while read line; do
  test &quot;$line&quot; == $&#039;\r&#039; &amp;&amp; break
done

# Trim the request string and log it
url=${request#GET }
url=${url% HTTP/*}
echo $url &gt;&gt; /home/dan/uaelug/httpd/log.txt

# Serve the request if the file exists, otherwise 404
if [ -f &quot;${docroot}/${url}&quot; ]; then
echo -e &quot;HTTP/1.1 200 OK\r
Content-Type: text/html; charset=ISO-8859-1\r
\r&quot;
cat ${docroot}/${url}
echo -e &quot;\r&quot;

else
echo -e &quot;HTTP/1.1 404 Not Found\r
Content-Type: text/html; charset=UTF-8\r
\r&quot;
cat ${docroot}/404.html
echo -e &quot;\r&quot;

fi</code></pre></div><p>Reference: <a href="http://www.debian-administration.org/article/A_web_server_in_a_shell_script">http://www.debian-administration.org/ar &#133; ell_script</a></p><p>Again -&gt; Kudos to <a href="http://uaelug.org/user/9/">dan_r</a>.</p>]]></description>
			<author><![CDATA[dummy@example.com (xaitax)]]></author>
			<pubDate>Tue, 14 Jul 2009 05:56:08 +0000</pubDate>
			<guid>http://uaelug.org/post/250/#p250</guid>
		</item>
	</channel>
</rss>
