<?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>Protection Against Reversing &#8211; Adwiteeya Agrawal | Home</title>
	<atom:link href="https://adwiteeya.com/tag/protection-against-reversing/feed/" rel="self" type="application/rss+xml" />
	<link>https://adwiteeya.com</link>
	<description>Security fanatic. Reverse Engineer and Web App Specialist.</description>
	<lastBuildDate>Tue, 03 Dec 2013 07:53:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.7</generator>
	<item>
		<title>Code Obfusction &#124; Writing a VM</title>
		<link>https://adwiteeya.com/code-obfusction-writing-a-vm/</link>
					<comments>https://adwiteeya.com/code-obfusction-writing-a-vm/#comments</comments>
		
		<dc:creator><![CDATA[Adwiteeya Agrawal]]></dc:creator>
		<pubDate>Tue, 03 Dec 2013 07:18:19 +0000</pubDate>
				<category><![CDATA[At the College]]></category>
		<category><![CDATA[Information Security]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[adwiteeya agrawal]]></category>
		<category><![CDATA[Code Obfusction]]></category>
		<category><![CDATA[OIVM]]></category>
		<category><![CDATA[Protection Against Reversing]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[Virtual Machine in C]]></category>
		<guid isPermaLink="false">http://adwiteeya.com/blog/?p=444</guid>

					<description><![CDATA[What is this Blog About ? It is about a minor project that i recently completed. That is writing a virtual machine to slow down the process of reverse engineering. This is not a tutorial to do the same however I have included the presentation that i used during the final presentation, the PDFs for [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><strong>What is this Blog About ?</strong></p>
<p>It is about a minor project that i recently completed. That is writing a virtual machine to slow down the process of reverse engineering. This is not a tutorial to do the same however I have included the presentation that i used during the final presentation, the PDFs for System Design and Sample Runs and one step by step sample run.<span id="more-444"></span></p>
<p><strong>#Presentation</strong></p>
<p><center><br />
<iframe style="border: 1px solid #CCC; border-width: 1px 1px 0; margin-bottom: 5px;" src="http://www.slideshare.net/slideshow/embed_code/28832154" height="356" width="427" allowfullscreen="" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></center></p>
<div style="margin-bottom: 5px; text-align: center;"><strong> <a title="OIVM" href="https://www.slideshare.net/adwiteeyaagrawal/oivm" target="_blank">OIVM</a> </strong> from <strong><a href="http://www.slideshare.net/adwiteeyaagrawal" target="_blank">Adwiteeya Agrawal</a></strong></div>
<div style="margin-bottom: 5px;"></div>
<div style="margin-bottom: 5px;"></div>
<div style="margin-bottom: 5px;"><strong>#Design</strong></div>
<div style="margin-bottom: 5px;"></div>
<p><iframe style="border: 1px solid #CCC; border-width: 1px 1px 0; margin-bottom: 5px;" src="http://www.slideshare.net/slideshow/embed_code/28832223" height="613" width="574" allowfullscreen="" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<div style="margin-bottom: 5px;"></div>
<div style="margin-bottom: 5px;"><strong>#Implementation &#8211; Sample Runs</strong></div>
<p><iframe style="border: 1px solid #CCC; border-width: 1px 1px 0; margin-bottom: 5px;" src="http://www.slideshare.net/slideshow/embed_code/28832221" height="613" width="574" allowfullscreen="" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>#Code</strong></p>
<p><script src="https://gist.github.com/adwiteeya/7765256.js"></script></p>
<p><strong>#Sample Run</strong></p>
<p>In this sample run I am going to implement the POC expansion algorithm that was the final program that was written for OIVM.1. Make sure bootrom.txt and OIVM.exe are in the same folder.<br />
2. Open the Bootrom.txt using a Hex Editor (example : Hex Workshop) and write the following hex stream to it.</p>
<p><strong>3F <span style="color: #000080;">11</span> 25 <span style="color: #333399;">00</span> 2F <span style="color: #333399;">08</span> 3F <span style="color: #333399;">38</span> 3F <span style="color: #333399;">38</span> 41 <span style="color: #333399;">3D</span> 09 <span style="color: #333399;">1B</span> 3C<span style="color: #333399;"> 4C</span> <span style="color: #000000;">21<span style="color: #000080;"> 25</span> 00 <span style="color: #000080;">2F</span> 14 <span style="color: #000080;">7C</span> 67 <span style="color: #000080;">63</span> 55 <span style="color: #000080;">64</span> 61 <span style="color: #000080;">38</span> 67 <span style="color: #000080;">7C</span> 63</span> <span style="color: #000080;">38</span> 55 <span style="color: #000080;">64</span> 61 <span style="color: #000080;">38</span> 37 <span style="color: #000080;">41</span> 3D <span style="color: #000080;">15</span> C9 <span style="color: #000080;">45</span> 3F <span style="color: #000080;">11</span> 3F 12 18 <span style="color: #000080;">68</span> 3C <span style="color: #000080;">25</span> 00 <span style="color: #000080;">2F</span> 08 <span style="color: #000080;">12</span> 86 <span style="color: #000080;">C5</span> 38 <span style="color: #000080;">41</span> 3D <span style="color: #000080;">09</span> 00 <span style="color: #000080;">02</span> 04 <span style="color: #000080;">06</span> 08 </strong></p>
<p>3. Save the file. This is basically in the format of [STUB][Compressed Code]. The stub is 60 Bytes long and extends till the 0x09 in the second line of the hexadecimal stream. The parallel <strong>assembly</strong> for this code is as follows :</p>
<p><strong>[EXPANSION STUB]</strong><br />
scanf(&#8220;%d&#8221;,&amp;STACK[SP])<br />
MOV A,STACK[SP]<br />
FLAG=A-ROM[++IP]<br />
JE 8 BYTES<br />
scanf(&#8220;%d&#8221;,&amp;STACK[SP])<br />
++SP<br />
scanf(&#8220;%d&#8221;,&amp;STACK[SP])<br />
++SP<br />
&#8211;A<br />
JMP -9 BYTES<br />
MOV B,ROM[++IP] //STUB LENGTH<br />
A = fileLen<br />
A=A-B<br />
FLAG=A-ROM[++IP]<br />
JE 14 BYTES<br />
MOV C ,ROM[B]<br />
MOV D,SP<br />
MOV SP,C<br />
MOV C,STACK[SP]<br />
MOV SP,D<br />
MOV STACK[SP],C<br />
++SP<br />
MOV D,SP<br />
MOV C,ROM[B]<br />
MOV SP,C<br />
++SP<br />
MOV C,STACK[SP]<br />
MOV SP,D<br />
MOV STACK[SP],C<br />
++SP<br />
++B<br />
&#8211;A<br />
JMP -21 BYTES<br />
ROM=(char *)realloc(ROM,ROM[++IP]) //FILE EXPANDED<br />
scanf(&#8220;%d&#8221;,&amp;STACK[SP])<br />
MOV A,STACK[SP]<br />
scanf(&#8220;%d&#8221;,&amp;STACK[SP])<br />
MOV B,STACK[SP]<br />
MOV SP,B<br />
MOV C,ROM[++IP]<br />
FLAG=A-ROM[++IP]<br />
JE 8 BYTES<br />
MOV B,STACK[SP]<br />
MOV ROM[C],B<br />
++C<br />
++SP<br />
&#8211;A<br />
JMP -9 BYTES<br />
<strong>[COMPRESSED FORM]</strong><br />
00 02 04 06 08</p>
<p>4. Now run the program.If however you dont speak assembly that doesnt matter here is the <strong>algorithm</strong> for it :</p>
<p>1. Enter the Number of elements in the dictionary.<br />
2. Enter the dictionary.<br />
(Dictionary is stored on the stack)<br />
(The dictionary is looked up for values corresponding to compressed code)<br />
(The new Values are updated over the stack)<br />
3. Enter the New Size.<br />
4. Enter the SP (which could have been hardcoded as well)<br />
(The code expands)<br />
(The execution is now passed on to the expanded program)<br />
5. Enter the first element. Hit Enter.<br />
6. Enter the second element. Hit Enter.<br />
7. The sum is Displayed.<br />
8. OIVM halts.</p>
<p><strong>Results/Output</strong></p>
<p><a href="http://adwiteeya.com/wp-content/uploads/2013/12/output.png"><img loading="lazy" decoding="async" class="size-full wp-image-453 aligncenter" alt="Output" src="http://adwiteeya.com/wp-content/uploads/2013/12/output.png" width="438" height="325" srcset="https://adwiteeya.com/wp-content/uploads/2013/12/output.png 438w, https://adwiteeya.com/wp-content/uploads/2013/12/output-300x222.png 300w" sizes="auto, (max-width: 438px) 100vw, 438px" /></a>#Thanks</p>
<p><strong>Special thanks</strong> to Mr. Atul Alex Cherian, Ms. Nishtha Jatana and Ms. Kritika Sobti.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://adwiteeya.com/code-obfusction-writing-a-vm/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
