<?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>seoxys.com&#187; Hacking</title>
	<atom:link href="http://www.seoxys.com/category/hacking/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seoxys.com</link>
	<description></description>
	<lastBuildDate>Mon, 04 Jan 2010 17:14:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>3 Easy Tips to Prevent a Binary Crack</title>
		<link>http://www.seoxys.com/3-easy-tips-to-prevent-a-binary-crack/</link>
		<comments>http://www.seoxys.com/3-easy-tips-to-prevent-a-binary-crack/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 11:14:17 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=88</guid>
		<description><![CDATA[When coding anti-piracy prevention measures, your goal should be to keep honest users honest. It is important to make the user experience pleasing and simple for your paid&#160;customers. While in an ideal world, people would buy everything legally, reality is very different. Most people, if tempted with an easy free way to get your app, [...]]]></description>
			<content:encoded><![CDATA[<p>When coding anti-piracy prevention measures, your goal should be to keep honest users honest.<br />
It is important to make the user experience pleasing and simple for your paid&nbsp;customers.</p>
<p>While in an ideal world, people would buy everything legally, reality is very different.<br />
Most people, if tempted with an easy free way to get your app, will pirate even though they know it is&nbsp;wrong.</p>
<p>Here are three easy tips that will help your app resist to binary cracks, but do not take much work to&nbsp;implement.</p>
<ul>
<li><a href="#strip">Strip debug&nbsp;symbols</a></li>
<li><a href="#ptrace">PT_DENY_ATTACH</a></li>
<li><a href="#checksum">Checksum your&nbsp;binary</a></li>
</ul>
<p>You can <a href="http://dl.azuretalon.com/ProtectionSample.zip">grab the sample code</a> for the first two&nbsp;tips.</p>
<h1 id="strip">Strip debug&nbsp;symbols</h1>
<p>Stripping debug symbols will remove all the method names from the executable, which makes it a lot harder for anyone to reverse-engineer your app using gdb. (I showed how this is usually done <a href="http://www.seoxys.com/hacking-mac-apps-direct-mail/">here</a>) Now, instead of seeing all your method names, which method the app is currently in, and instead of being able to breakpoint the app at that spot, they&#8217;ll only see hexadecimal&nbsp;addresses.</p>
<p>You can still get around this by class-dumping the executable and getting new method&#8217;s hex addresses from there, (although they might be off by a certain difference which you&#8217;d have to calculate) but this already makes it a lot harder for crackers to&nbsp;attack.</p>
<p>So, without further ado, here&#8217;s how you do this: Apple&#8217;s <a href="http://developer.apple.com/tools/xcode/symbolizingcrashdumps.html">documentation</a> has a detailed explanation, so instead of rewriting it myself, I&#8217;ll just copy-paste it&nbsp;here:</p>
<blockquote><p>Xcode provides several built-in options for stripping executables of their debugging symbols. One of these is the Strip Linked Product build setting. While typically set, it has no effect unless the Deployment Postprocessing setting is also set. Deployment Postprocessing is a master switch that enables the action of a host of other build settings. It&#8217;s approximately analogous to running the xcodebuild tool with the install&nbsp;command.</p>
<p>Again, open the target build settings and turn on debugging symbols for the Release configuration. Open the project build settings; in the Release configuration, enable both Strip Linked Product (if it isn&#8217;t on already) and Deployment Postprocessing. Your project settings should now resemble those shown in Table&nbsp;2.</p>
<table>
<tr>
<td><b>Build Setting</b></td>
<td><b>Value</b></td>
</tr>
<tr>
<td>Deployment Postprocessing</td>
<td>YES</td>
</tr>
<tr>
<td>Strip Linked Product</td>
<td>YES</td>
</tr>
</table>
</blockquote>
<h1 id="ptrace">PT_DENY_ATTACH</h1>
<p>Behind this barbaric name is a very useful flag which lets you prevent gdb from attaching to your app. Ever tried <a href="http://www.steike.com/code/debugging-itunes-with-gdb/">debugging iTunes</a>? Give it a try now, but be prepared for a disappointment, it crashes gdb when it tries to attach to&nbsp;it.</p>
<p>One step further in protecting your app after striping debug symbols is to activate PT_DENY_ATTACH. Note that this doesn&#8217;t make stripping debug symbols useless. While in theory it does, there are <a href="http://landonf.bikemonkey.org/code/macosx/Leopard_PT_DENY_ATTACH.20080122.html">ways</a> to get around&nbsp;it.</p>
<p>Activating this protection is really easy, and only involves editing your&nbsp;<i>main.m</i>.</p>
<pre class="textmate-source barf"><span class="source source_objc"><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>  main.m
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>  ProtectionSample
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>  Created by Kenneth Ballenegger on 2008/06/27.
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>  Copyright Azure Talon 2008. All rights reserved.
</span><span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>
</span>
<span class="meta meta_preprocessor meta_preprocessor_c meta_preprocessor_c_include">#<span class="keyword keyword_control keyword_control_import keyword_control_import_include keyword_control_import_include_c">import</span> <span class="string string_quoted string_quoted_other string_quoted_other_lt-gt string_quoted_other_lt-gt_include string_quoted_other_lt-gt_include_c"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_c">&lt;</span>Cocoa/Cocoa.h<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_c">&gt;</span></span></span>
<span class="meta meta_preprocessor meta_preprocessor_c meta_preprocessor_c_include">#<span class="keyword keyword_control keyword_control_import keyword_control_import_include keyword_control_import_include_c">include</span> <span class="string string_quoted string_quoted_other string_quoted_other_lt-gt string_quoted_other_lt-gt_include string_quoted_other_lt-gt_include_c"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_c">&lt;</span>sys/ptrace.h<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_c">&gt;</span></span></span>

<span class="storage storage_type storage_type_c">int</span><span class="meta meta_function meta_function_c"> <span class="entity entity_name entity_name_function entity_name_function_c">main</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_c">(</span><span class="storage storage_type storage_type_c">int</span> argc, <span class="storage storage_type storage_type_c">char</span> *argv<span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[]</span></span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_c">)</span></span>
{
    <span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>Build settings -&gt; Other C Flags: -DDEBUG
</span><span class="meta meta_preprocessor meta_preprocessor_c">#<span class="keyword keyword_control keyword_control_import keyword_control_import_c">ifdef</span> DEBUG</span>
    <span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span>do nothing
</span><span class="meta meta_preprocessor meta_preprocessor_c">#<span class="keyword keyword_control keyword_control_import keyword_control_import_c">else</span></span>
    ptrace(PT_DENY_ATTACH, <span class="constant constant_numeric constant_numeric_c">0</span>, <span class="constant constant_numeric constant_numeric_c">0</span>, <span class="constant constant_numeric constant_numeric_c">0</span>);
<span class="meta meta_preprocessor meta_preprocessor_c">#<span class="keyword keyword_control keyword_control_import keyword_control_import_c">endif</span></span>
    <span class="keyword keyword_control keyword_control_c">return</span> <span class="support support_function support_function_cocoa">NSApplicationMain</span>(argc,  (<span class="storage storage_modifier storage_modifier_c">const</span> <span class="storage storage_type storage_type_c">char</span> **) argv);
}
</span></pre>
<p>This code should be pretty&nbsp;self-explanotary&#8230;</p>
<p>You need to have a flag that differs for release build and debug builds. You want to be able to debug your app while you code it. That&#8217;s why I set <i>Other C Flags</i> for the Debug build settings to &#8220;-DDEBUG&#8221; and used an #ifdef to activate it only for release&nbsp;builds.</p>
<p>Test it if it works quickly, fire up terminal and try to use&nbsp;gdb.</p>
<pre class="textmate-source barf"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">seoMac:~ kenneth$ gdb /Users/kenneth/Desktop/ProtectionSample/build/Release/ProtectionSample.app/Contents/MacOS/ProtectionSample
GNU gdb 6.3.50-20050815 (Apple version gdb-952) (Sat Mar 29 03:33:05 UTC 2008)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin"...Reading symbols for shared libraries ..... done
</span>
<span class="meta meta_paragraph meta_paragraph_text">(gdb) r
Starting program: /Users/kenneth/Desktop/ProtectionSample/build/Release/ProtectionSample.app/Contents/MacOS/ProtectionSample
Reading symbols for shared libraries ++++....................................................................... done
</span>
<span class="meta meta_paragraph meta_paragraph_text">Program exited with code 055.
(gdb)
</span></span></pre>
<p>Congratulations, it works! Your app cannot be loaded into gdb anymore. (Note: there are workarounds. Experienced hackers who really want to will still manage to get&nbsp;in.)</p>
<h1 id="checksum">Checksum your&nbsp;binary</h1>
<p>The last tip for today is of a different kind, and it is probably the most effective of the&nbsp;three.</p>
<p>Basically, all you need to do is to checksum your binary. Put the md5 somewhere in your .app, preferably well hidden. Preferably use a salted hash, or double-hash it. Make it hard for a potential hacker to figure out how to get the correct hash for a given hash. Hide the file in which you store this hash well, or store it in your Info.plist. Where you store it doesn&#8217;t matter, but you can&#8217;t put it in the binary. Preferably set up a build script that will re-generate the new hash at every build (when your binary changes), so you don&#8217;t have to do it&nbsp;yourself.</p>
<p>In your code, check the stored hash against the binary, and if they are different, it means the binary has been modified. In that case, display an error message asking to re-download the app from your site, and&nbsp;quit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/3-easy-tips-to-prevent-a-binary-crack/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Registration Schemes: Asymmetrical Cryptography</title>
		<link>http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/</link>
		<comments>http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 22:13:05 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=86</guid>
		<description><![CDATA[One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: Serial Numbers, Asymmetrical Cryptographic Keys and Product&#160;Activation. Part Two: Asymmetrical&#160;Cryptography Asymmetrical Cryptographic Keys are a great way to secure you app, because the [...]]]></description>
			<content:encoded><![CDATA[<p>One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: <b>Serial Numbers</b>, <b>Asymmetrical Cryptographic Keys</b> and <b>Product&nbsp;Activation</b>.</p>
<hr />
<h1>Part Two: Asymmetrical&nbsp;Cryptography</h1>
<p>Asymmetrical Cryptographic Keys are a great way to secure you app, because the code used to generate serials is not included in your app, thus removing the risk of a keygen. Using a private key, you sign (or encrypt) some of the user&#8217;s details. You then use this singed data as the key to your software, either in the form of a serial, a file, or even <a href="http://switchersblog.com/2007/04/05/license-keys-mac-style-1passwd-introduces-new-license-cards.html">an image with the data embedded</a>. You then verify that the signature is valid using the public key in your&nbsp;app.</p>
<p><b>Example</b></p>
<p>Start off by generating a set of private and public RSA keys. You can do this by using the following in&nbsp;Terminal.app:</p>
<p><code>openssl genrsa -out private.pem 2048<br />
openssl rsa -in private.pem -out public.pem -outform PEM&nbsp;-pubout</code></p>
<p>You can use different size keys. Using a shorter key, such as 512 will make your software more vulnerable to brute-force attack, but has the advantage of making the signature smaller (Which is useful if you wish to display it in the form of a Serial&nbsp;Number).</p>
<p>I believe I used the following set of keys. The keys are also included as files in the source code of this example (available at the bottom of this&nbsp;article).</p>
<p><code>-----BEGIN RSA PRIVATE KEY-----<br />
MIIEpAIBAAKCAQEAwKhjrkHmaupDGERSHdgZuSwBWBr4kufBGz0Dk5sn3PR3ZtaP<br />
Vrv6+5Mdz1gAEBYbUVH3m+4+dHcwol5xNckKBT8M5Zy6GPoV9dBUS/1wQBzgdTzf<br />
jvV4uE9S0pofQWw3faZ904tTOjbM0qUko2nd7yyjYBhh/m1ABEFHuL62BvRp13na<br />
vv6534OqqeExEb9VD3K9+Rr4+YQVRUpqZSz2xwhqfLgAzFVQ9bmSG8yTVKmF/vQA<br />
t+N8ThN2WO5qYtCbPawkmIpwvUCTXkxAiiTPNOiU3G1vwtzBoma9TL6dgGmhq6P7<br />
0KBcQNGUEpA2PFC7MEBeNyVyiMIOAvrkHjY/VQIDAQABAoIBABUNET9EMiIykLxB<br />
Etvx9fWWylrPL6QVsLMCOrbROEzbZYSWIzlt9uGwVIyIaBFZ6Qg8tZqTML3XHDhR<br />
q3seCXtDRWx9cJQ0F1wxtFRNUAuhXCFTUnYzekphWIJslse2RGX1YEBSM/jjbgQC<br />
SXuVoMt2jC9+2o5Lb7hHTcfxBsDBmZpghArT5seTOwDOOhTULqoh2wgZYB2IpgTI<br />
UV2CPpAqRVECRnPNdE5UcNIeHc7g4aji5BO0G0u8uM4RUffuRcLaPymuxpU9vwd1<br />
gjVaG6BF/2odW7GEBU3FNLUtvr9MxT+HC+hwOJUuk8NWxU7DqMdyiwSs7W3Nnx7R<br />
5RPvj8ECgYEA34DZjy5EMm7QyPZA6DvAZv6RIecFEwEkwFG+mQgoCy4VfLikkwzC<br />
bI8M8fc6Xiix7ZTjSmvuHt1D4HSRHMOVYgDzY0A5+F+8X657mN5TwNlYMOUkDX3I<br />
rNwc3cRVqtLZYGX0H7cR6eEomGJ7fA9gKuTpaXI0IJz5DsqsgTaGvfECgYEA3Ktr<br />
Q53i52jnssL9c3JsxQO+I/2fWKgo3bZeBI/5zLsz3itVjFjMVldrIK1QZWXI4z7l<br />
dPYwh6qCa1unsizuuzeAhW6NcuUjGPBlBqlo/a9WfOo16ExPXBoH3PH2DXz/YS+D<br />
DOp4Wl8ePhO7C46t3zmGahchysx3kCGkAmNkA6UCgYEA0upvZNUOemFlGiB5RC8O<br />
9KMLJukyOqr7mZoKubOexl4o3NgKRtLlrziXyMe8Bxt0PXYhwBt2TR4Vbf3S60gO<br />
8rte86yqiB8gT1MDRFGazATPWuUCTtECzU2y1/ztsxTjGjtcU4mZmBJpEtTtHzgL<br />
Uq9PLbkeRCCeUD0m6ZEhOqECgYB85jFyNh1F6aSrE56tB2j1Iicu69CTN6rZwuz4<br />
HB3BeXvkFhb3txMBE7244yAMJE5OAT2Ss/3H7AShi2EhgjklkkaWP3qkO3lgFkC4<br />
Qo8Ad4u2bEJS105bzQgCUJl6DPPnKCM+3j98tzXA4R4PbpSPMloYFju0M4LA+6l/<br />
CI6FWQKBgQCWr4Py/GBhgoYOlY/f41NzOfsttwcCBum3uPbiPq6gM/AQQRjzdUmK<br />
QRgG9XXs/33KUMiU+/15hK8ShrOWRSx+zHdgeMhVmuYJdEeygANI9dkonJ3+Olth<br />
77beMQrKIY9kw4bVRFtLWhxfAHXvnksnBg79PX05joVvoHFgVxuwlg==<br />
-----END RSA PRIVATE KEY-----<br />
-----BEGIN PUBLIC KEY-----<br />
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwKhjrkHmaupDGERSHdgZ<br />
uSwBWBr4kufBGz0Dk5sn3PR3ZtaPVrv6+5Mdz1gAEBYbUVH3m+4+dHcwol5xNckK<br />
BT8M5Zy6GPoV9dBUS/1wQBzgdTzfjvV4uE9S0pofQWw3faZ904tTOjbM0qUko2nd<br />
7yyjYBhh/m1ABEFHuL62BvRp13navv6534OqqeExEb9VD3K9+Rr4+YQVRUpqZSz2<br />
xwhqfLgAzFVQ9bmSG8yTVKmF/vQAt+N8ThN2WO5qYtCbPawkmIpwvUCTXkxAiiTP<br />
NOiU3G1vwtzBoma9TL6dgGmhq6P70KBcQNGUEpA2PFC7MEBeNyVyiMIOAvrkHjY/<br />
VQIDAQAB<br />
-----END PUBLIC KEY-----<br />
</code></p>
<p>Next, we will create the generator. We will start by concatenating the details (full name and email address) into a single&nbsp;string:</p>
<p><code>First&nbsp;Last+email@address.com</code></p>
<p>Then, we will use RSA to sign this string using the private key generated&nbsp;above:</p>
<p><code>lFZpwJ6GPLXz8sDez033RIxJsN072lOEa0qF+8hQ5KCcZEPQqSBU4MKbW+UJxIfSmKMOBYnVfy/wwAoSxTtqn2JIuAPEJvsTlb0mGH5u7mpxH+FDj2TicoBKephWv7UXP9k10OPA45247+j/u4yKT1UZcq7WjChQ3JoE3wBtEoFucQm8vLk/VqvNaBM1TyNEgwT8FmrKlbK1FNUI8nQ0QOEJ9P8oMAblkWE5kALZZqWnAs6xE7c73sex73t5FvxYRqRDzRDzkjTwK0anXCv8dmeLvnaaHAFcfD5llx09oa89q+wzWucE7V1TsPRYKH1sZsSz5G2xTt2pZrjIoTw5ew==</code></p>
<p><b>Note</b>: for this sample app, I explicitly turned off creating newlines in the base64&nbsp;signature.</p>
<p>The code used for this generator&nbsp;is:</p>
<pre class="textmate-source"><span class="source source_objc"><span class="meta meta_implementation meta_implementation_objc"><span class="meta meta_scope meta_scope_implementation meta_scope_implementation_objc"><span class="meta meta_function meta_function_objc">-<span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">IBAction</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">generate</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">sender</span></span>
</span>{
    <span class="support support_class support_class_cocoa">NSData</span> *privateKeyData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSData</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataWithContentsOfURL<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSURL</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">fileURLWithPath<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSBundle</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">mainBundle</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">pathForResource<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>private<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span> <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">ofType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>pem<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSData</span> *publicKeyData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSData</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataWithContentsOfURL<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSURL</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">fileURLWithPath<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSBundle</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">mainBundle</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">pathForResource<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>public<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span> <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">ofType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>pem<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSString</span> *details = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSString</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringWithFormat<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>%@+%@<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>name <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>email <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    SSCrypto *crypto = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>SSCrypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">alloc</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">initWithPublicKey<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>publicKeyData <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">privateKey<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>privateKeyData</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setClearTextWithString<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>details</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="support support_class support_class_cocoa">NSData</span> *signedTextData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">sign</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSString</span> *string = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>signedTextData <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">encodeBase64WithNewlines<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="constant constant_language constant_language_objc">NO</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>serial <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setStringValue<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>string</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">release</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
}
</span></span></span></pre>
<p>As you can see, I used Septicus Software&#8217;s great <a href="http://septicus.com/products/opensource/">SSCrypto</a> framework for this task&#8230; It makes things so much easier&#8230; Unfortunately it doesn&#8217;t support base32 or DSA, which would both have helped make more human-friendly&nbsp;keys.</p>
<p>The other piece needed is the validator, used in your software to validate serial numbers. Include only the public key in your app, and use RSA to verify the&nbsp;key.</p>
<pre class="textmate-source"><span class="source source_objc"><span class="meta meta_implementation meta_implementation_objc"><span class="meta meta_scope meta_scope_implementation meta_scope_implementation_objc"><span class="meta meta_function meta_function_objc">-<span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">IBAction</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">validate</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">sender</span></span>
</span>{
    <span class="support support_class support_class_cocoa">NSData</span> *publicKeyData = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSData</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataWithContentsOfURL<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSURL</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">fileURLWithPath<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSBundle</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">mainBundle</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">pathForResource<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>public<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span> <span class="support support_function support_function_any-method support_function_any-method_name-of-parameter support_function_any-method_name-of-parameter_objc">ofType<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>pem<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSString</span> *details = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="support support_class support_class_cocoa">NSString</span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringWithFormat<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>%@+%@<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>name <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>, <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>email <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="support support_class support_class_cocoa">NSData</span> *number = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>serial <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">stringValue</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">dataUsingEncoding<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="support support_constant support_constant_cocoa">NSUTF8StringEncoding</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">decodeBase64WithNewLines<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="constant constant_language constant_language_objc">NO</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    SSCrypto *crypto = <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>SSCrypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">alloc</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">initWithPublicKey<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>publicKeyData</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">setCipherText<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>number</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">verify</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;

    <span class="keyword keyword_control keyword_control_c">if</span>(<span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span><span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">clearTextAsString</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span> <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">isEqualToString<span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span>details</span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>)
        <span class="support support_function support_function_cocoa">NSRunAlertPanel</span>(<span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Result<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Good serial!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>OK<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="constant constant_language constant_language_objc">nil</span>, <span class="constant constant_language constant_language_objc">nil</span>);
    <span class="keyword keyword_control keyword_control_c">else</span>
        <span class="support support_function support_function_cocoa">NSRunAlertPanel</span>(<span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Result<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>Wrong serial!<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="string string_quoted string_quoted_double string_quoted_double_objc"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_objc">@"</span>OK<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_objc">"</span></span>, <span class="constant constant_language constant_language_objc">nil</span>, <span class="constant constant_language constant_language_objc">nil</span>);

    <span class="meta meta_bracketed meta_bracketed_objc"><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">[</span>crypto <span class="meta meta_function-call meta_function-call_objc"><span class="support support_function support_function_any-method support_function_any-method_objc">release</span></span><span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_objc">]</span></span>;
}
</span></span></span></pre>
<p><b>Important Note</b>: In this sample code, I included both the generator and the validator in the same application. I included the private.pem file in the bundle. You should <b>never</b> do this. If the private key is ever leaked, it compromises the whole security of your&nbsp;application.</p>
<p><b>Making it&nbsp;safer</b></p>
<p>You can easily make it more secure by combining this technique with the technique explained in Part One. Instead of simple concatenating the details as I did here, you could use all the techniques applied in Part One, such as using a hash instead, or doing ROT13 on it, or rearranging the order of the&nbsp;characters.</p>
<p>Another thing you should do is to hardcode and obfuscate your public key. Having it as a file in the bundle makes you vulnerable to key substitution. (Basically, a cracker would replace the public key in your app by a different key they created using a private key they know, thus making their licenses valid instead of&nbsp;yours.) </p>
<p><b>Form&nbsp;Factors</b></p>
<p>While you may not realize it at first sight, this has become one of the most common methods in Mac shareware, thanks to the open-source framework <a href="http://aquaticmac.com">AquaticPrime</a>. AquaticPrime uses this technique behind the scenes, by embedding the signature in a plist file. AquaticPrime is a very easy way to use this. Unfortunately, if you decide to use AquaticPrime.framework in your app, it is very easy to replace the .framework file with a malicious one that will always claim your licenses are&nbsp;valid.</p>
<p>To date, as far as I know, there isn&#8217;t any HackuaticPrime.framework yet, but this might one day become a problem with AquaticPrime gaining popularity thanks to it&#8217;s extreme simplicity of&nbsp;implementation.</p>
<p><b>Update</b>: <b>Devon</b> in the comments suggests implementing a hash check of the framework, which is a simple way of checking the framework&#8217;s integrity. Of course, there are still ways to get around it, but this makes it one step more&nbsp;difficult.</p>
<p>Another common form factor for Asymmetrical Cryptographic Keys is custom URL schemes. That&#8217;s actually a very clever and convenient way of doing it. To register, the users get to simple click on a link which looks like this: (All the user sees is a nice &#8220;Click here to register&#8221;&nbsp;link)</p>
<p><code>myapp://name:email:key</code> </p>
<p>Another clever, but controversial form factor is Agile Web Solution&#8217;s 1Password <a href="http://switchersblog.com/2007/04/05/license-keys-mac-style-1passwd-introduces-new-license-cards.html">License&nbsp;&#8220;Cards&#8221;</a>.</p>
<p>And of course, if you find a way to make short base32 signatures (I hear DSA makes short signatures), you can even use longer Serial&nbsp;Numbers.</p>
<p><code>AHJ53-5HGJZ-8DG8R-284DF-56FJB-74FH4-FJUEH</code></p>
<hr />
<p><b>Sample&nbsp;Code</b></p>
<p>The code used in this article can be downloaded <a href="http://dl.azuretalon.com/async.zip">here</a>.<br />
As always, licensed under MIT license. If you do use it, mention it in the About Box or&nbsp;readme.txt.</p>
<hr />
<p><a href="http://www.seoxys.com/registration-schemes-serial-numers/">Part One: Serial Numbers</a><br />
The next part will be coming&nbsp;soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Registration Schemes: Serial Numbers</title>
		<link>http://www.seoxys.com/registration-schemes-serial-numers/</link>
		<comments>http://www.seoxys.com/registration-schemes-serial-numers/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 21:26:56 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/?p=85</guid>
		<description><![CDATA[One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: Serial Numbers, Asymmetrical Cryptographic Keys and Product&#160;Activation. Part One: Serial&#160;Numbers Serial numbers are the simplest, most practical option. However, they are also the [...]]]></description>
			<content:encoded><![CDATA[<p>One challenge that most developers face when nearing release of their first application is how to implement registration and piracy protection. This three-part article will describe three common types of registration schemes: <b>Serial Numbers</b>, <b>Asymmetrical Cryptographic Keys</b> and <b>Product&nbsp;Activation</b>.</p>
<hr />
<h1>Part One: Serial&nbsp;Numbers</h1>
<p>Serial numbers are the simplest, most practical option. However, they are also the least secure. It consists of taking at least one of the customers&#8217; details, and creating a serial number from it. The serial number is usually tied to either the customer&#8217;s name, or his email address, preferably&nbsp;both.</p>
<p>For example, let&#8217;s say the customer&#8217;s name &#8220;First Last&#8221; and his email address is &#8220;email@address.com&#8221;. The first step would be to strip his name and email address of any non-alphabetical characters, concatenate it and convert it to uppercase. (I put the email address first, because it&#8217;s less recognizable) Here&#8217;s what we&nbsp;get:</p>
<p><code>EMAILADDRESSCOMFIRSTLAST</code></p>
<p>Now map this string onto a XXXX-XXXX-XXXX-XXXX-XXXX key. If there are any character leftovers, just discard them. If there aren&#8217;t enough characters to fill all the Xs in, leave them as something constant. (they don&#8217;t have to be all the same, but they have to be the same for each position all the time. You could for example say you&#8217;re mapping it onto an QRST-ABCD-IJLK-EFGH-MNOP key, and leave unfilled spaces as&nbsp;is)</p>
<p><code>EMAI-LADD-RESS-COMF-IRST</code></p>
<p>Then, we&#8217;d apply ROT13 on&nbsp;it.</p>
<p><code>RZNV-YNQQ-ERFF-PBZS-VEFG</code></p>
<p>Lastly, we could replace any swearwords in the key by some random other constant text, <a href="http://www.rogueamoeba.com/utm/posts/Random/RASN2-Swears-2007-10-16-15-00.html">just in&nbsp;case</a>.</p>
<p>Another example, using a similar method: Using the same customer, here&#8217;s what we&#8217;d do. Take his details, concatenate and salt&nbsp;them:</p>
<p><code>First Last+random&nbsp;salt+email@address.com</code></p>
<p>Then, MD5 the result and add another&nbsp;salt:</p>
<p><code>salt+0fb61d4a0f894c63d3ddbd8388404b6c</code></p>
<p>Next, SHA1 the&nbsp;result:</p>
<p><code>28a8275bdcbca542f567efef9cc4db2150c38900</code></p>
<p>And finally, uppercase it and map it onto a XXXX-XXXX-XXXX-XXXX-XXXX&nbsp;serial:</p>
<p><code>28A8-275B-DCBC-A542-F567</code></p>
<p>When you have decided on a serial scheme, implementing it is easy. Upon registration, you take the buyer&#8217;s name and email address, and generate a serial from it. He then has to input this serial into you app, along with his name and email address. All you have to do in you app is take the name and email address he gave you, generate a serial from it, and check it against the serial he gave&nbsp;you.</p>
<p><b>Making it more&nbsp;secure</b></p>
<p>For security reasons, one important step to take is obfuscating how you create those serials, in case anyone tries to create a keygen for you app. The easiest way is adding dummy maths code in the middle of the code where you work out your serial. It will not affect your serial, but it will show up in the assembly code in case anyone tries to gdb your app (more on that in another blog post I have&nbsp;planned).</p>
<p>Another quick thing you could do is shuffle the characters a bit on a set pattern to make them less&nbsp;obvious.</p>
<p>For example you could use this&nbsp;pattern:</p>
<p><code>ABCD-EFGH-IJKL-MNOP-QRST</code></p>
<p>becomes</p>
<p><code>TMLN-DQGA-ISPC-BEOK-FJRH</code></p>
<p><b>Stand-alone&nbsp;serials</b></p>
<p>Sometimes, your serials cannot be tied to any of the customer&#8217;s data, for example for retail sales. In that case, you&#8217;d need a different serial scheme. You need to choose certain characteristics / rules that make a serial valid. It could be as simple as checking that the 19th character is a&nbsp;W.</p>
<p>Here&#8217;s a set of example rules you could&nbsp;use:</p>
<ul>
<li>The ASCII value of the first character of all five blocks of four characters have to add up to&nbsp;100.</li>
<li>The last character of all five blocks of four characters have to be&nbsp;vowels.</li>
<li>The first character of either block 3 or 4 has to be&nbsp;E.</li>
<li>The ASCII value to the third character of every block have to be even&nbsp;numbers.</li>
</ul>
<p>In your apps, just check the serial against the rules, and if it&#8217;s correct, you can assume it is a correct&nbsp;serial.</p>
<p>For your generator, you can have a pre-made list of valid serials, and assign them to a customer or print them on a retail copy when needed. The problem with this method is that you can eventually run out of valid serials. In which case you would have to generate a new batch of serials, or reassign already used serials to a second&nbsp;customer.</p>
<p>Another (better) way of doing stand-alone serial numbers is splitting the serial number in two, and basing the second part on the first part. [thanks to <b>tomasf</b> from the <a href="irc://irc.freenode.net/#macsb">#macsb</a> IRC channel for this&nbsp;method]</p>
<p>For example, in a serial number ABCD-EFGH-D07A-A959-F269, separate the first eight characters from the rest of the&nbsp;serial:</p>
<p><code>ABCDEFGH</code> </p>
<p>Salt&nbsp;it:</p>
<p><code>saltyABCDEFGH+123</code></p>
<p>MD5:</p>
<p><code>d07aa959f269104ab28e2a748c415c5c</code></p>
<p>Map it onto&nbsp;XXXX-XXXX-XXXX:</p>
<p><code>D07A-A959-F269</code></p>
<p>And check it against the second part of the serial. In this example, the serial is&nbsp;correct.</p>
<hr />
<p><a href="http://www.seoxys.com/registration-schemes-asymmetrical-cryptography/">Part Two: Asymmetrical Cryptographic Keys</a><br />
The last parts will be coming&nbsp;soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/registration-schemes-serial-numers/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Hacking mac apps: Direct Mail</title>
		<link>http://www.seoxys.com/hacking-mac-apps-direct-mail/</link>
		<comments>http://www.seoxys.com/hacking-mac-apps-direct-mail/#comments</comments>
		<pubDate>Tue, 18 Dec 2007 23:02:36 +0000</pubDate>
		<dc:creator>kenneth</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Cocoa]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://www.seoxys.com/2007/12/19/hacking-mac-apps-direct-mail/</guid>
		<description><![CDATA[In this post, I will describe how to hack a mac shareware app. The reason for this is to push the developers to create stronger protection, and to show common weaknesses in licensing&#160;code. Before each hack is published, I get the concerned developer&#8217;s approval, and send them a note describing the hack, and suggesting ways [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I will describe how to hack a mac shareware app.<br />
<br />
The reason for this is to push the developers to create stronger protection, and to show common weaknesses in licensing&nbsp;code.</p>
<p>Before each hack is published, I get the concerned developer&#8217;s approval, and send them a note describing the hack, and suggesting ways to improve their protection. I also leave them some time to patch their app before I publish the&nbsp;hack.</p>
<p>I have no intention of promoting piracy, and this not meant to be used as a guide for would-be pirates to get those for free. What follows if of highly technical nature, and is intended for fellow&nbsp;developers.</p>
<p>Today is up: <a href="http://ethreesoftware.com/directmail/index.php">Direct Mail</a>, a great app from e3 software useful for anyone doing mailing lists or press&nbsp;releases.</p>
<p>I did this hack on version 1.8.3, because it isn&#8217;t the&nbsp;latest.</p>
<p>First thing to do, is to class-dump the executable, which results in an interesting find:<br />
</p>
<pre class="textmate-source barf"><span class="source source_objc"><span class="meta meta_interface-or-protocol meta_interface-or-protocol_objc"><span class="storage storage_type storage_type_objc"><span class="punctuation punctuation_definition punctuation_definition_storage punctuation_definition_storage_type punctuation_definition_storage_type_objc">@</span>interface</span> <span class="entity entity_name entity_name_type entity_name_type_objc">CAppDelegate</span> <span class="punctuation punctuation_definition punctuation_definition_entity punctuation_definition_entity_other punctuation_definition_entity_other_inherited-class punctuation_definition_entity_other_inherited-class_objc">:</span> <span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_objc">NSObject</span><span class="meta meta_divider meta_divider_objc">
</span><span class="meta meta_scope meta_scope_interface meta_scope_interface_objc">{
    <span class="storage storage_type storage_type_objc">BOOL</span> _registered;   <span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span> 4 = 0x4
</span>    <span class="support support_class support_class_cocoa">NSString</span> *_registeredName;  <span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span> 8 = 0x8
</span>    SUUpdater *sparkleUpdater;  <span class="comment comment_line comment_line_double-slash comment_line_double-slash_c++"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_c">//</span> 12 = 0xc
</span>}

<span class="meta meta_function meta_function_objc">+ <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">sharedDelegate</span></span>;</span>
<span class="meta meta_function meta_function_objc">+ <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span  span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">applyIconsToChangeStatusMenu</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">init</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">BOOL</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">registered</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">registeredName</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">setRegisteredName</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">BOOL</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">validateMenuItem</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">loadRegistration</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">BOOL</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">isValidCode</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span> <span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc">forName</span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp12</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">saveRegistrationCode</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span> <span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc">forName</span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp12</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">sparkleUpdater</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">doPrefs</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">doRegister</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">doPurchase</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">BOOL</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">alertShowHelp</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">doAbout</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">doReportBug</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">doConnectionDoctor</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">openAppWebsite</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">openRegisterWebsite</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">runKRM</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">lookupKagiAffiliate</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">showPurchaseThankYou</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">showFirstRunAlert</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">applicationWillFinishLaunching</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_c">void</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">applicationDidFinishLaunching</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>
<span class="meta meta_function meta_function_objc">- <span class="meta meta_return-type meta_return-type_objc"><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">BOOL</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="entity entity_name entity_name_function entity_name_function_objc">crashReporterShouldDisplayException</span></span><span class="meta meta_argument-type meta_argument-type_objc"><span class="entity entity_name entity_name_function entity_name_function_name-of-parameter entity_name_function_name-of-parameter_objc"><span class="punctuation punctuation_separator punctuation_separator_arguments punctuation_separator_arguments_objc">:</span></span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">(</span><span class="storage storage_type storage_type_objc">id</span><span class="punctuation punctuation_definition punctuation_definition_type punctuation_definition_type_objc">)</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_objc">fp8</span></span>;</span>

</span><span class="storage storage_type storage_type_objc"><span class="punctuation punctuation_definition punctuation_definition_storage punctuation_definition_storage_type punctuation_definition_storage_type_objc">@</span>end</span></span>
</span></pre>
<p>Now, there&#8217;s different ways to hack this. You could just edit the ivar _registered upon launch. Other option would be to hack registered or isValidCode:forName: to always return true.<br />
<br />
I&#8217;m going to go with a slightly more complicated way, and hack the methods which call&nbsp;isValidCode:forName:.</p>
<p>Let&#8217;s set a breakpoint when isValidCode is called. Disassemble the whole thing, and check where isValidCode:forName: is called. For me, it returns at 0x00008fdc. Run. It hits the breakpoint immediately. Continue once, to let it finish its setting up etc. Now, using the app, go to the register menu and try to register (with a properly-formatted email-address). It will hit the breakpoint again. Do a nexti. You now are in &#8220;0x0002ffb7 in -[CRegisterPanelController doOK:] ()&#8221;<br />
<br />
Let&#8217;s disassemble this&nbsp;method:</p>
<p><code style="overflow:auto;white-space: nowrap; ">0x0002ff50 &lt;-[CRegisterPanelController doOK:]+0&gt;:   push   %ebp<br />0x0002ff51 &lt;-[CRegisterPanelController doOK:]+1&gt;:   mov    %esp,%ebp<br />0x0002ff53 &lt;-[CRegisterPanelController doOK:]+3&gt;:   push   %edi<br />0x0002ff54 &lt;-[CRegisterPanelController doOK:]+4&gt;:   push   %esi<br />0x0002ff55 &lt;-[CRegisterPanelController doOK:]+5&gt;:   push   %ebx<br />0x0002ff56 &lt;-[CRegisterPanelController doOK:]+6&gt;:   sub    $0x1c,%esp<br />0x0002ff59 &lt;-[CRegisterPanelController doOK:]+9&gt;:   mov    0x8(%ebp),%edi<br />0x0002ff5c &lt;-[CRegisterPanelController doOK:]+12&gt;:  mov    0x22091c,%eax<br />0x0002ff61 &lt;-[CRegisterPanelController doOK:]+17&gt;:  mov    %eax,0x4(%esp)<br />0x0002ff65 &lt;-[CRegisterPanelController doOK:]+21&gt;:  mov    0x221fa4,%eax<br />0x0002ff6a &lt;-[CRegisterPanelController doOK:]+26&gt;:  mov    %eax,(%esp)<br />0x0002ff6d &lt;-[CRegisterPanelController doOK:]+29&gt;:  call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x0002ff72 &lt;-[CRegisterPanelController doOK:]+34&gt;:  mov    %eax,%esi<br />0x0002ff74 &lt;-[CRegisterPanelController doOK:]+36&gt;:  mov    0xc(%edi),%edx<br />0x0002ff77 &lt;-[CRegisterPanelController doOK:]+39&gt;:  mov    0x221428,%eax<br />0x0002ff7c &lt;-[CRegisterPanelController doOK:]+44&gt;:  mov    %eax,0x4(%esp)<br />0x0002ff80 &lt;-[CRegisterPanelController doOK:]+48&gt;:  mov    %edx,(%esp)<br />0x0002ff83 &lt;-[CRegisterPanelController doOK:]+51&gt;:  call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x0002ff88 &lt;-[CRegisterPanelController doOK:]+56&gt;:  mov    %eax,%ebx<br />0x0002ff8a &lt;-[CRegisterPanelController doOK:]+58&gt;:  mov    0x8(%edi),%edx<br />0x0002ff8d &lt;-[CRegisterPanelController doOK:]+61&gt;:  mov    0x221428,%eax<br />0x0002ff92 &lt;-[CRegisterPanelController doOK:]+66&gt;:  mov    %eax,0x4(%esp)<br />0x0002ff96 &lt;-[CRegisterPanelController doOK:]+70&gt;:  mov    %edx,(%esp)<br />0x0002ff99 &lt;-[CRegisterPanelController doOK:]+73&gt;:  call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x0002ff9e &lt;-[CRegisterPanelController doOK:]+78&gt;:  mov    %ebx,0xc(%esp)<br />0x0002ffa2 &lt;-[CRegisterPanelController doOK:]+82&gt;:  mov    %eax,0x8(%esp)<br />0x0002ffa6 &lt;-[CRegisterPanelController doOK:]+86&gt;:  mov    0x22084c,%eax<br />0x0002ffab &lt;-[CRegisterPanelController doOK:]+91&gt;:  mov    %eax,0x4(%esp)<br />0x0002ffaf &lt;-[CRegisterPanelController doOK:]+95&gt;:  mov    %esi,(%esp)<br />0x0002ffb2 &lt;-[CRegisterPanelController doOK:]+98&gt;:  call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x0002ffb7 &lt;-[CRegisterPanelController doOK:]+103&gt;: test   %al,%al<br />0x0002ffb9 &lt;-[CRegisterPanelController doOK:]+105&gt;: jne    0x2ffc7 &lt;-[CRegisterPanelController doOK:]+119&gt;<br />0x0002ffbb &lt;-[CRegisterPanelController doOK:]+107&gt;: add    $0x1c,%esp<br />0x0002ffbe &lt;-[CRegisterPanelController doOK:]+110&gt;: pop    %ebx<br />0x0002ffbf &lt;-[CRegisterPanelController doOK:]+111&gt;: pop    %esi<br />0x0002ffc0 &lt;-[CRegisterPanelController doOK:]+112&gt;: pop    %edi<br />0x0002ffc1 &lt;-[CRegisterPanelController doOK:]+113&gt;: pop    %ebp<br />0x0002ffc2 &lt;-[CRegisterPanelController doOK:]+114&gt;: jmp    0x21f444 &lt;dyld_stub_NSBeep&gt;<br />0x0002ffc7 &lt;-[CRegisterPanelController doOK:]+119&gt;: mov    0x22091c,%eax<br />0x0002ffcc &lt;-[CRegisterPanelController doOK:]+124&gt;: mov    %eax,0x4(%esp)<br />0x0002ffd0 &lt;-[CRegisterPanelController doOK:]+128&gt;: mov    0x221fa4,%eax<br />0x0002ffd5 &lt;-[CRegisterPanelController doOK:]+133&gt;: mov    %eax,(%esp)<br />0x0002ffd8 &lt;-[CRegisterPanelController doOK:]+136&gt;: call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x0002ffdd &lt;-[CRegisterPanelController doOK:]+141&gt;: mov    %eax,%esi<br />0x0002ffdf &lt;-[CRegisterPanelController doOK:]+143&gt;: mov    0xc(%edi),%edx<br />0x0002ffe2 &lt;-[CRegisterPanelController doOK:]+146&gt;: mov    0x221428,%eax<br />0x0002ffe7 &lt;-[CRegisterPanelController doOK:]+151&gt;: mov    %eax,0x4(%esp)<br />0x0002ffeb &lt;-[CRegisterPanelController doOK:]+155&gt;: mov    %edx,(%esp)<br />0x0002ffee &lt;-[CRegisterPanelController doOK:]+158&gt;: call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x0002fff3 &lt;-[CRegisterPanelController doOK:]+163&gt;: mov    %eax,%ebx<br />0x0002fff5 &lt;-[CRegisterPanelController doOK:]+165&gt;: mov    0x8(%edi),%edx<br />0x0002fff8 &lt;-[CRegisterPanelController doOK:]+168&gt;: mov    0x221428,%eax<br />0x0002fffd &lt;-[CRegisterPanelController doOK:]+173&gt;: mov    %eax,0x4(%esp)<br />0x00030001 &lt;-[CRegisterPanelController doOK:]+177&gt;: mov    %edx,(%esp)<br />0x00030004 &lt;-[CRegisterPanelController doOK:]+180&gt;: call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x00030009 &lt;-[CRegisterPanelController doOK:]+185&gt;: mov    %ebx,0xc(%esp)<br />0x0003000d &lt;-[CRegisterPanelController doOK:]+189&gt;: mov    %eax,0x8(%esp)<br />0x00030011 &lt;-[CRegisterPanelController doOK:]+193&gt;: mov    0x220788,%eax<br />0x00030016 &lt;-[CRegisterPanelController doOK:]+198&gt;: mov    %eax,0x4(%esp)<br />0x0003001a &lt;-[CRegisterPanelController doOK:]+202&gt;: mov    %esi,(%esp)<br />0x0003001d &lt;-[CRegisterPanelController doOK:]+205&gt;: call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x00030022 &lt;-[CRegisterPanelController doOK:]+210&gt;: movl   $0x219530,0x8(%esp)<br />0x0003002a &lt;-[CRegisterPanelController doOK:]+218&gt;: mov    0x220784,%eax<br />0x0003002f &lt;-[CRegisterPanelController doOK:]+223&gt;: mov    %eax,0x4(%esp)<br />0x00030033 &lt;-[CRegisterPanelController doOK:]+227&gt;: mov    0x221fb4,%eax<br />0x00030038 &lt;-[CRegisterPanelController doOK:]+232&gt;: mov    %eax,(%esp)<br />0x0003003b &lt;-[CRegisterPanelController doOK:]+235&gt;: call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x00030040 &lt;-[CRegisterPanelController doOK:]+240&gt;: mov    0x220780,%edx<br />0x00030046 &lt;-[CRegisterPanelController doOK:]+246&gt;: mov    %edx,0x4(%esp)<br />0x0003004a &lt;-[CRegisterPanelController doOK:]+250&gt;: mov    %eax,(%esp)<br />0x0003004d &lt;-[CRegisterPanelController doOK:]+253&gt;: call   0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />0x00030052 &lt;-[CRegisterPanelController doOK:]+258&gt;: mov    0x4(%edi),%edx<br />0x00030055 &lt;-[CRegisterPanelController doOK:]+261&gt;: mov    0x220900,%eax<br />0x0003005a &lt;-[CRegisterPanelController doOK:]+266&gt;: mov    %eax,0xc(%ebp)<br />0x0003005d &lt;-[CRegisterPanelController doOK:]+269&gt;: mov    %edx,0x8(%ebp)<br />0x00030060 &lt;-[CRegisterPanelController doOK:]+272&gt;: add    $0x1c,%esp<br />0x00030063 &lt;-[CRegisterPanelController doOK:]+275&gt;: pop    %ebx<br />0x00030064 &lt;-[CRegisterPanelController doOK:]+276&gt;: pop    %esi<br />0x00030065 &lt;-[CRegisterPanelController doOK:]+277&gt;: pop    %edi<br />0x00030066 &lt;-[CRegisterPanelController doOK:]+278&gt;: pop    %ebp<br />0x00030067 &lt;-[CRegisterPanelController doOK:]+279&gt;: jmp    0x21f395 &lt;dyld_stub_objc_msgSend&gt;<br />
</code></p>
<p>We now are at this line: &#8220;0x0002ffb7 <-[CRegisterPanelController doOK:]+103>:	test&nbsp;%al,%al&#8221;</p>
<p>That, in the right, is assembly code. This is basically some kind of &#8220;if&#8221; statement. (a TEST followed by a JNE (jump if not equal)).<br />
<br />
What interests me is the next line: &#8220;0x0002ffb9 <-[CRegisterPanelController doOK:]+105>:	jne    0x2ffc7 <-[CRegisterPanelController doOK:]+119>&#8221;<br />
<br />
If we just reverse this test (turn the JNE into a JE (jump if equal)), any invalid code will be considered valid, and vice-versa. Let&#8217;s examine the memory for this&nbsp;statement.</p>
<p><code style="overflow:auto;white-space: nowrap; "><br />
<br />
(gdb) x/x 0x0002ffb9<br />
<br />
0x2ffb9 <-[CRegisterPanelController doOK:]+105>:	0xc4830c75<br />
<br />
</code></p>
<p>Now, I&#8217;m working on a intel machine. And for some dumb reason, every block of four bytes is inverted. What this means, is that the byte that interests me is  the rightmost one: 0x75. This is what a JNE looks like. Do some more tests by setting breakpoints until you find a JE, and read the memory for it: you will find that a JE is&nbsp;0x74.</p>
<p>Let&#8217;s test if our theory is correct by editing the memory live, before we edit it in the binary. Do the&nbsp;following:</p>
<p><code style="overflow:auto;white-space: nowrap; "><br />
<br />(gdb) set {char}0x0002ffb9=0x74<br />(gdb) x/x 0x0002ffb9<br />0x2ffb9 <-[CRegisterPanelController doOK:]+105>:	0xc4830c74<br />(gdb) disassemble 0x0002ffb7<br />Dump of assembler code for function -[CRegisterPanelController doOK:]:<br />[...edited out...]<br />0x0002ff99 <-[CRegisterPanelController doOK:]+73>:	call   0x21f395 <dyld_stub_objc_msgSend><br />0x0002ff9e <-[CRegisterPanelController doOK:]+78>:	mov    %ebx,0xc(%esp)<br />0x0002ffa2 <-[CRegisterPanelController doOK:]+82>:	mov    %eax,0x8(%esp)<br />0x0002ffa6 <-[CRegisterPanelController doOK:]+86>:	mov    0x22084c,%eax<br />0x0002ffab <-[CRegisterPanelController doOK:]+91>:	mov    %eax,0x4(%esp)<br />0x0002ffaf <-[CRegisterPanelController doOK:]+95>:	mov    %esi,(%esp)<br />0x0002ffb2 <-[CRegisterPanelController doOK:]+98>:	call   0x21f395 <dyld_stub_objc_msgSend><br />0x0002ffb7 <-[CRegisterPanelController doOK:]+103>:	test   %al,%al<br />0x0002ffb9 <-[CRegisterPanelController doOK:]+105>:	je     0x2ffc7 <-[CRegisterPanelController doOK:]+119><br />0x0002ffbb <-[CRegisterPanelController doOK:]+107>:	add    $0x1c,%esp<br />0x0002ffbe <-[CRegisterPanelController doOK:]+110>:	pop    %ebx<br />0x0002ffbf <-[CRegisterPanelController doOK:]+111>:	pop    %esi<br />0x0002ffc0 <-[CRegisterPanelController doOK:]+112>:	pop    %edi<br />0x0002ffc1 <-[CRegisterPanelController doOK:]+113>:	pop    %ebp<br />0x0002ffc2 <-[CRegisterPanelController doOK:]+114>:	jmp    0x21f444 <dyld_stub_NSBeep><br />0x0002ffc7 <-[CRegisterPanelController doOK:]+119>:	mov    0x22091c,%eax<br />[...edited out...]<br />End of assembler dump.<br />(gdb) <br />
</code></p>
<p>Here we change the byte for the JNE, then test if we changed it correctly by re-reading it.<br />
<br />
Then we disassemble the whole method again to see if the JNE was changed correctly. And yes&thinsp;&#8212;&thinsp;tah-da&thinsp;&#8212;&thinsp;- it now says JE. Perfect. Continue. You are now registered. To make this change permanent: do &#8220;x/8x 0x0002ffb9&#8221;. You will get 24 bytes of data. Open the binary in your favorite hex editor and find the bytes outputted by gdb. If you&#8217;re on intel, don&#8217;t forget you have to reverse all the blocks of four bytes before searching. When you find it, edit the 0x75 into 0x74. Bravo! You have now made the change&nbsp;permanent.</p>
<p>We are not finished yet. As you will now notice if you run the program, it makes your code valid, but you get an error message each launch, and you have to re-do the entering a code process every time. This is because the first check at launch doesn&#8217;t happen in&nbsp;doOk:.</p>
<p>Continue and quit normally (using cmd-Q in Direct Mail). Launch it again by doing run. But this time, don&#8217;t continue after hitting the breakpoint at launch. Do nexti. Ok, so now we are in loadRegistration. Disassemble this method. Similarly, there&#8217;s a JE this time, just after the call to isValidCode:forName: Turn this into a JNE by changing the 0x74 into a 0x75 at this location in memory. If you disassemble the method again, you can see that the JE turned into a JNE. Like before, change this in the&nbsp;binary.</p>
<p>Well Done! You have now fully hacked Direct Mail&nbsp;1.8.3.</p>
<p>By now, the developer has probably fixed this security flaw, so you can&#8217;t use this to get this app for free. If you like it, buy it. It&#8217;s a great piece of software! Think about the poor developers who have to feed their family.<br />
<br />
You can <a href="http://ethreesoftware.com/directmail/download.php">download the trial version&nbsp;here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seoxys.com/hacking-mac-apps-direct-mail/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
