<?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>./alexandru &#187; cli</title>
	<atom:link href="http://alexandrulazar.com/category/cli/feed/" rel="self" type="application/rss+xml" />
	<link>http://alexandrulazar.com</link>
	<description>mnml</description>
	<lastBuildDate>Sun, 01 Apr 2012 01:32:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>bash script to encode mkv avi to mpeg-4</title>
		<link>http://alexandrulazar.com/bash-script-to-encode-mkv-avi-to-mpeg-4/</link>
		<comments>http://alexandrulazar.com/bash-script-to-encode-mkv-avi-to-mpeg-4/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 05:11:07 +0000</pubDate>
		<dc:creator>Alexandru</dc:creator>
				<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[command-line interface]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://alexandrulazar.com/?p=65</guid>
		<description><![CDATA[This will allow a classic XBOX to play 1280&#215;720 video and should work for anything you can throw at mencoder. subtitletracks=`mkvinfo "${1}" &#124; fgrep "Track type: subtitles" -b2 &#124; fgrep "Track number:" &#124; awk '{print $NF}' &#124; xargs`; echo "Found subtitle tracks: ${subtitletracks}"; if [ `echo ${subtitletracks} &#124; wc -w` -gt 1 ]; then for [...]]]></description>
			<content:encoded><![CDATA[<p>This will allow a classic XBOX to play 1280&#215;720 video and should work for anything you can throw at mencoder.<br />
<code><br />
subtitletracks=`mkvinfo "${1}" | fgrep "Track type: subtitles" -b2 | fgrep "Track number:" | awk '{print $NF}' | xargs`;<br />
echo "Found subtitle tracks:  ${subtitletracks}";<br />
if [ `echo ${subtitletracks} | wc -w` -gt 1 ]; then<br />
for i in ${subtitletracks};<br />
do<br />
mkvextract tracks "${1}" ${i}:"$1".avi.srt.${i};<br />
done;<br />
cp -i -a "${1}".avi.srt.`echo ${subtitletracks} | cut -d " " -f1` "${1}".avi.srt;<br />
else<br />
mkvextract tracks "${1}" ${subtitletracks}:"${1}".avi.srt;<br />
fi;<br />
echo "Finished extracting subtitle tracks for ${1}.  Now encoding video.";<br />
nice -n 19 ionice -c3 mencoder "${1}" -o "${1}".avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=4000:vrc_maxrate=5000:vrc_buf_size=4096;<br />
echo "Finished encoding video for ${1}.  Exit status was:  ${?}";<br />
unset subtitletracks<br />
</code></p>
<img src="http://alexandrulazar.com/?ak_action=api_record_view&id=65&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://alexandrulazar.com/bash-script-to-encode-mkv-avi-to-mpeg-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding compromised accounts in a shared hosting environment</title>
		<link>http://alexandrulazar.com/finding-compromised-accounts-in-a-shared-hosting-environment/</link>
		<comments>http://alexandrulazar.com/finding-compromised-accounts-in-a-shared-hosting-environment/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 02:37:43 +0000</pubDate>
		<dc:creator>Alexandru</dc:creator>
				<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://alexandrulazar.com/?p=50</guid>
		<description><![CDATA[To locate a suspicious process&#8217;s (httpd, sendmail, perl) current working directory look in /proc/$PID/cwd If httpd fullstatus isn&#8217;t available, you can use this to enumerate the current working directories of httpd processes: for i in `ps -elf &#124; grep http &#124; awk '{print $4}' &#124; sort &#124; uniq`; do ls -la /proc/$i/cwd ; done &#124; [...]]]></description>
			<content:encoded><![CDATA[<p>To locate a suspicious process&#8217;s (httpd, sendmail, perl) current working directory look in /proc/$PID/cwd</p>
<p>If httpd fullstatus isn&#8217;t available, you can use this to enumerate the current working directories of httpd processes:</p>
<p><code>for i in `ps -elf | grep http | awk '{print $4}' | sort | uniq`; do ls -la /proc/$i/cwd ; done | awk '{print $11}'| grep -Ev ^$ | sort | uniq -c | sort -n</code></p>
<p>If you do not have mytop, mysqladmin, or access to the mysql console, you can use this to enumerate the file descriptors of the mysqld process:</p>
<p><code>ls -al /proc/`pidof mysqld`/fd/ | awk -F\&gt; '{print $2}' | awk -F/ '{print $5}' | sort | uniq -c | sort -n</code></p>
<p>If you do not catch them quickly enough after spawning, malicious processes can reparent themselves under init so their cwd is reset.  You can look in /tmp, /var/tmp, and /dev/shm for any clues, as well as reference the /proc/$PID timestamps in logs.  You can always strace the suspicious process and see what files it has open with lsof and netstat.</p>
<p>To identify malicious files in a suspicious directory:</p>
<p>1.  Scan their directory using <a href="http://www.rfxn.com/projects/linux-malware-detect/">maldet</a>, which should finds most newer PHP and Perl shells.  It likely won&#8217;t find older or custom payloads.</p>
<p>2.  Scan their directory with clamav if there is time to spare.  For our purpose there is fingerprint overlap with maldet but clamav has a larger database and may catch something.</p>
<p>3.  Use the following for an audit against common shells and malicious files:</p>
<p>If they have gigs of files they may be a file dump.  If they have only a few kilobytes it may be a new fraudulent account.</p>
<p><code>du -sh</code></p>
<p>Custom 404 redirects are not very common and are usually only found in the webroot&#8217;s .htaccess.  A common attack is creating .htaccess files which 404 redirect to malicious files (usually a PHP shell with all-numeric filename) which connect to a remote server and open a shell.</p>
<p><code>find . -name .htaccess -print0 | xargs -0 fgrep ErrorDocument\ 404</code></p>
<p>These are search strings for common PHP shells.  Note that intruders may use incorrect extensions to confuse you and prepend image file headers so that the malicious file is recognized as an image by file.</p>
<p><code>find . -iname \*php -print0 | xargs -0 grep -E 'c99_|c99shell|999sh|fx29_|fx29shell|r57_|r57shell|aHR0cDov'</code></p>
<p>Base64-encoded content should be scrutinized as a potential payload.  Intruders will copy system file headers/templates from your software&#8217;s (eg: WordPress) installation and encode (gzinflate, base64, rot13) them to confuse you on whether they&#8217;re malicious code or legitimate footers which sometimes contain images.</p>
<p><code>find . -iname \*php -print0 | xargs -0 fgrep base64_</code></p>
<p>Files with 777 permissions are a security concern and should be investigated.</p>
<p><code>find . -perm 777 -type f</code></p>
<p><code>find . -perm 777 -type d</code></p>
<p>Files which are 000&#8242;d may have been disabled by the user or an administrator due to suspicious behavior.</p>
<p><code>find . -perm 000</code></p>
<p>Files owned by root hopefully are from an administrator forgetting to assign them proper ownership and not a privilege escalation.</p>
<p><code>find . -user root</code></p>
<p>Files owned by the http server may indicate access was gained through the customer&#8217;s software.</p>
<p><code>find . -user nobody -o -user apache</code></p>
<p>Files modified recently are of primary concern.  For a thorough check run a second pass for ctime, as intruders are able to set their mtimes to past datetimes.</p>
<p><code>find . -mtime -1</code></p>
<p><code>find . -mtime +1 -mtime -10</code></p>
<p><code>find . -ctime -1</code></p>
<p><code>find . -ctime +1 -ctime -10</code></p>
<p>You can supplement your investigation by parsing the access-log of the suspected target for suspicious POST&#8217;s:</p>
<p>Referrers:  <code>cut -d " " -f11 access_log | sort | uniq -c | sort -n</code></p>
<p>Visitors:  <code>cut -d " " -f1 access_log | sort | uniq -c | sort -n</code></p>
<p>POSTs:  <code>fgrep POST access_log | fgrep -v " 404 " | cut -d " " -f7 | sort | uniq -c | sort -n</code></p>
<p>The error_log will have stderr output for injections and subsequent attempts to retrieve payloads from other servers, often using wget or curl.</p>
<p><code>grep -E 'wget|curl' error_log</code></p>
<p>Once you have filenames and their checksums and IP addresses, you can search other servers and their logs.</p>
<img src="http://alexandrulazar.com/?ak_action=api_record_view&id=50&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://alexandrulazar.com/finding-compromised-accounts-in-a-shared-hosting-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GNU Screen, Window Manager.</title>
		<link>http://alexandrulazar.com/gnu-screen-window-manager/</link>
		<comments>http://alexandrulazar.com/gnu-screen-window-manager/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 12:54:08 +0000</pubDate>
		<dc:creator>Alexandru</dc:creator>
				<category><![CDATA[.screenrc]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[color wrapper]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[command-line interface]]></category>
		<category><![CDATA[cw]]></category>
		<category><![CDATA[gnu screen]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[window manager]]></category>
		<category><![CDATA[yakuake]]></category>
		<category><![CDATA[screen_ssh]]></category>

		<guid isPermaLink="false">http://alexandrulazar.com/?p=14</guid>
		<description><![CDATA[GUI is for the weak. Meet my window manager, GNU screen: 0. Build screen from source to fix the slowdown when scrolling in a vertical split. 1. This is my .screenrc with keyboard shortcuts and a nifty status bar.  &#8211;help? Control + Up:  previous split screen Control + Down: next split screen Control + Left:  [...]]]></description>
			<content:encoded><![CDATA[<p>GUI is for the weak.  Meet my window manager, <a href="http://www.gnu.org/software/screen/">GNU screen</a>:</p>
<p><a href="http://alexandrulazar.com/wp-content/uploads/2010/06/screen2.jpg"><img class="aligncenter size-full wp-image-27" title="screen1" src="http://alexandrulazar.com/wp-content/uploads/2010/06/screen1.jpg" alt="Small image of GNU screen setup" width="500" height="374" /></a></p>
<p>0. Build screen <a href="http://savannah.gnu.org/git/?group=screen">from source</a> to fix the slowdown when scrolling in a vertical split.</p>
<p>1.  This is <a href="http://www.alexandrulazar.com/junk/articles/.screenrc">my .screenrc</a> with keyboard shortcuts and a nifty status bar.  &#8211;help?</p>
<pre style="padding-left: 60px;">Control + Up:  previous split screen</pre>
<pre style="padding-left: 60px;">Control + Down: next split screen</pre>
<pre style="padding-left: 60px;">Control + Left:  previous screen window</pre>
<pre style="padding-left: 60px;">Control + Right: next screen window</pre>
<pre style="padding-left: 60px;">F1: kill current tab</pre>
<pre style="padding-left: 60px;">F2: write paste buffer to file</pre>
<pre style="padding-left: 60px;">F3: split horizontally</pre>
<pre style="padding-left: 60px;">F4: split vertically</pre>
<pre style="padding-left: 60px;">F5: remove single split</pre>
<pre style="padding-left: 60px;">F6: remove all splits</pre>
<pre style="padding-left: 60px;">F7: <a href="http://gd.tuwien.ac.at/linuxcommand.org/man_pages/urlview1.html">urlview</a> pulls URL's from your current output, very useful</pre>
<pre style="padding-left: 60px;">F8: new tab</pre>
<pre style="padding-left: 60px;">F9: resize split +1 line</pre>
<pre style="padding-left: 60px;">F10: resize split -1 line</pre>
<p>2. <a href="http://www.tenshu.net/screen_ssh/" target="_self">Install screen_ssh.sh</a> so your window title automatically renames to your ssh destination.  To have the title revert after closing your shell <a href="http://old.nabble.com/Dynamic-Title-tp23754108p23840219.html">follow this</a>.</p>
<p>3. color = readability.  <a href="http://freshmeat.net/projects/cw/">Install color wrapper</a> to colorize your terminal output.  Alias <em>man</em> to use <em>most</em> as its pager.  Use the following for a colorful prompt with $? in $2:</p>
<p><strong><span style="color: #00ccff;">00:43:18</span> <span style="color: #00ff00;">0</span> <span style="color: #3366ff;">user@hostname</span>:<span style="color: #ffff00;">~/<span style="color: #00ff00;">$</span></span></strong></p>
<p><code>\[\033[1;36m\]\t\[\033[0m\] `LastExitValue=$?; if [ $LastExitValue = 0 ]; then echo \[\033[1\;32m\]$LastExitValue\[\033[0m\]; else echo \[\033[1\;31m\]$LastExitValue\[\033[0m\]; fi` \[\033[1;34m\]\u@\h\[\033[0m\]:\[\033[1;33m\]\w\[\033[0m\]\[\033[1;32m\]\$\[\033[0m\]</code></p>
<p>To remove color use:  <code>s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g</code></p>
<p>4.  <a href="http://extragear.kde.org/apps/yakuake/">Yakuake is the best terminal emulator<strong>.</strong></a> Configure these shortcuts:</p>
<pre style="padding-left: 60px;">Shift + Left: previous shell</pre>
<pre style="padding-left: 60px;">Shift + Right: next shell</pre>
<pre style="padding-left: 60px;">F11: full screen</pre>
<pre style="padding-left: 60px;">F12: drop down</pre>
<img src="http://alexandrulazar.com/?ak_action=api_record_view&id=14&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://alexandrulazar.com/gnu-screen-window-manager/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

