<?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>All Things IT Blog &#187; Reverse Engineering</title>
	<atom:link href="http://www.enusbaum.com/blog/tag/reverse-engineering/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.enusbaum.com/blog</link>
	<description>My little nerded out corner of the Internets!</description>
	<lastBuildDate>Tue, 18 Oct 2011 20:22:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Semagic LiveJournal Client Password Decryption and Recovery</title>
		<link>http://www.enusbaum.com/blog/2007/02/semagic-livejournal-client-password-decryption-and-recovery/</link>
		<comments>http://www.enusbaum.com/blog/2007/02/semagic-livejournal-client-password-decryption-and-recovery/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 18:09:07 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[LiveJournal]]></category>
		<category><![CDATA[Password Decrypt]]></category>
		<category><![CDATA[Password Decrypter]]></category>
		<category><![CDATA[Semagic]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2007/02/15/semagic-livejournal-client-password-decryption-and-recovery/</guid>
		<description><![CDATA[Semagic (link) is a client application for LiveJournal (link). Recently I needed to recover a password that was &#8216;remembered&#8217; by Semagic, but it was hidden in the password field. Simple password unmasking applications weren&#8217;t helping me any as the field itself isn&#8217;t a simple password box. After further investigation I was able to find where [...]]]></description>
			<content:encoded><![CDATA[<p>Semagic (<a href="http://semagic.sourceforge.net/">link</a>) is a client application for LiveJournal (<a href="http://www.livejournal.com">link</a>).</p>
<p>Recently I needed to recover a password that was &#8216;remembered&#8217; by Semagic, but it was hidden in the password field. Simple password unmasking applications weren&#8217;t helping me any as the field itself isn&#8217;t a simple password box.</p>
<p>After further investigation I was able to find where Semagic stores the saved passwords in the Windows Registry. It was obvious that the password was encrypted and was stored in it&#8217;s entire form. Since Semagic is open source, I was able to find the code block which served as its password decrypter:</p>
<p>[cpp] m_password = m_app-&gt;GetProfileString(userkey, _T(&#8220;password&#8221;), _T(&#8220;&#8221;));    //Gets Encrypted password from registry<br />
enc = m_app-&gt;GetProfileInt(userkey, _T(&#8220;obscure&#8221;), 0);    //Checks to see if the password is &#8216;obscured&#8217;</p>
<p>if (enc) {    //If password is obscured<br />
LPTSTR str = m_password.GetBuffer(m_password.GetLength());    //Password<br />
LPTSTR key = new TCHAR[m_user.GetLength()+1];    //Sets Key Size (Username + 1)<br />
_tcsncpy(key, (LPCTSTR) m_user, m_user.GetLength()+1);    //Copies Username to Key<br />
LPTSTR orig = key;</p>
<p>while (*str) {<br />
if (!*key)    //If we&#8217;re OOB on the key, reset it<br />
key = orig;<br />
*(str) -= &#8216;a&#8217;;    //subtract the value of &#8216;a&#8217;, which is 97, from the encrypted value<br />
*(str++) ^= *(key++);    //XOR bitwise based on the key<br />
}<br />
key = orig;<br />
m_password.ReleaseBuffer();<br />
delete[] key;<br />
}</p>
<p>[/cpp]</p>
<p>So needless to say it was just a matter of debugging and some time before I was able to port the decryption routine over to a stand alone C# application.</p>
<p>[csharp]</p>
<p>for (int iLoop = 0; iLoop &lt; Convert.ToString(sPassword).Length; iLoop++)<br />
{<br />
int iInputCharacter = (int)Convert.ToChar(sPassword.ToString().Substring(iLoop,1));</p>
<p>if(iXORCharacter &gt;= sUserName.Length) iXORCharacter = 0;</p>
<p>iInputCharacter -= 97;<br />
iInputCharacter ^= (int)Convert.ToChar(sUserName.Substring(iXORCharacter, 1));</p>
<p>textBox1.Text += (char)iInputCharacter;</p>
<p>iXORCharacter++;<br />
}</p>
<p>[/csharp]</p>
<p>I&#8217;ve compiled a quick little program that&#8217;ll extract the usernames from the registry and display their passwords:</p>
<p><a id="p14" onmousedown="selectLink(14);" href="http://www.enusbaum.com/blog//wp-content/uploads/2007/02/semagicdecrypt.zip">Semagic Password Decrypter</a></p>
<p>This program is 100% safe and won&#8217;t e-mail your password to me or any other silly crap like that. I just figured someone out there would need it as well.</p>
<p>Cheers!</p>
<div class="su-linkbox" id="post-13-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2007/02/semagic-livejournal-client-password-decryption-and-recovery/&quot;&gt;Semagic LiveJournal Client Password Decryption and Recovery&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2007/02/semagic-livejournal-client-password-decryption-and-recovery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

