<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="https://hwdavr.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://hwdavr.github.io/" rel="alternate" type="text/html" /><updated>2020-01-21T14:31:41+00:00</updated><id>https://hwdavr.github.io/feed.xml</id><title type="html">Home</title><subtitle>Mobile Programming and Security</subtitle><author><name>Walter Huang</name><email>hwdavr@gmail.com</email></author><entry><title type="html">iOSOpenDev environment setup solution</title><link href="https://hwdavr.github.io/mobliesecurity/iOSOpenDev-environment-setup-solution/" rel="alternate" type="text/html" title="iOSOpenDev environment setup solution" /><published>2018-07-14T08:10:33+00:00</published><updated>2018-07-14T08:10:33+00:00</updated><id>https://hwdavr.github.io/mobliesecurity/iOSOpenDev%20environment%20setup%20solution</id><content type="html" xml:base="https://hwdavr.github.io/mobliesecurity/iOSOpenDev-environment-setup-solution/">&lt;p&gt;The step of setup basically can follow the article below,
&lt;a href=&quot;https://github.com/535064094/iosOpenDevInstallTools/wiki/iOSOpenDev-install-solution&quot;&gt;https://github.com/535064094/iosOpenDevInstallTools/wiki/iOSOpenDev-install-solution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The only issue is to build ldid, you will encounter an error below,&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ld: library not found for -lcrypto
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Instead of using official release of ldid, you can use the unofficial release from below github repo,
https://github.com/xerub/ldid&lt;/p&gt;

&lt;p&gt;May after that you will still have issue while installing iOSOpenDev.
Suggest to use &lt;a href=&quot;http://www.alonemonkey.com/2017/06/28/monkeydev/&quot;&gt;MonkeyDev&lt;/a&gt; instead.&lt;/p&gt;</content><author><name>Walter Huang</name><email>hwdavr@gmail.com</email></author><summary type="html">The step of setup basically can follow the article below, https://github.com/535064094/iosOpenDevInstallTools/wiki/iOSOpenDev-install-solution</summary></entry><entry><title type="html">Clutch and Dumpdecrypted Usage</title><link href="https://hwdavr.github.io/mobliesecurity/Clutch-dumpdecrypted-usage/" rel="alternate" type="text/html" title="Clutch and Dumpdecrypted Usage" /><published>2018-03-29T11:00:33+00:00</published><updated>2018-03-29T11:00:33+00:00</updated><id>https://hwdavr.github.io/mobliesecurity/Clutch-dumpdecrypted-usage</id><content type="html" xml:base="https://hwdavr.github.io/mobliesecurity/Clutch-dumpdecrypted-usage/">&lt;h2 id=&quot;clutch-usage&quot;&gt;Clutch Usage&lt;/h2&gt;
&lt;p&gt;Dump the installed app&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Clutch -i
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Dump app with number&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Clutch -d 63
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;dumpdecrypted-usage&quot;&gt;dumpdecrypted Usage&lt;/h2&gt;
&lt;p&gt;Check the process Id&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;ps -e | grep Aplipay
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Use cycript check app documents directory&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cycript -p 10854
[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
                                              inDomains:NSUserDomainMask][0]

#&quot;file:///var/mobile/Containers/Data/Application/DB840722-C37B-47F7-AAAB-E3C4C7616220/Documents/&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Copy dumpdecrypted.dylib to documents directory，you can use scp command or use iFunbox tool&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;scp dumpdecrypted.dylib root@ip: /var/mobile/Containers/Data/Application/371430E9-C2EE-4888-849C-6A51CF32867C/Documents/

cd /var/mobile/Containers/Data/Application/DB840722-C37B-47F7-AAAB-E3C4C7616220/Documents/
put dumpdecrypted.dylib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Switch to mobile user, go to documents directory and execute&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;su mobile
cd /var/mobile/Containers/Data/Application/DB840722-C37B-47F7-AAAB-E3C4C7616220/Documents/
DYLD_INSERT_LIBRARIES=dumpdecrypted.dylib /var/containers/Bundle/Application/0C32538D-939A-4E15-9509-04AC67A290FD/yweather.app/yweather
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now you can use class-dump to dump the classes&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;class-dump -S -s -H weather.decrypted -o /to/dir
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Walter Huang</name><email>hwdavr@gmail.com</email></author><summary type="html">Clutch Usage Dump the installed app Clutch -i Dump app with number Clutch -d 63</summary></entry><entry><title type="html">How to resolve Tomcat Error - java.lang.OutOfMemoryError: PermGen in Amazon Linux AMI</title><link href="https://hwdavr.github.io/servercloud/how-to-resolve-tomcat/" rel="alternate" type="text/html" title="How to resolve Tomcat Error - java.lang.OutOfMemoryError: PermGen in Amazon Linux AMI" /><published>2018-03-29T11:00:33+00:00</published><updated>2018-03-29T11:00:33+00:00</updated><id>https://hwdavr.github.io/servercloud/how-to-resolve-tomcat</id><content type="html" xml:base="https://hwdavr.github.io/servercloud/how-to-resolve-tomcat/">&lt;p&gt;Tomcat web server often suffers from java.lang.OutOfMemoryError: PermGen space whenever you deploy and un-deploy your web application couple of time. 
In this article, we will see how to fix java.lang.OutOfMemoryError: PermGen Space in tomcat server.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Goto Tomcat startup script file location, for Amazon Linux AMI. It locates at “/etc/rc.d/init.d/”&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Edit the script file by “sudo nano tomcat7”&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add the following JAVA_OPTS at the beginning of the file after “NAME=”$(basename $0)””
export JAVA_OPTS=”-Xms1024m -Xmx10246m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m”&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can change the actual heap size and PermGen Space as per your requirement.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Restart Tomcat.
Increasing PermGen space can prevent java.lang.OutOfMemoryError: PermGen in tomcat only for some time and it will eventually occur based on how many times you redeploy your web application, its best to find the offending class which is causing a memory leak in tomcat and fix it.&lt;/li&gt;
&lt;/ol&gt;</content><author><name>Walter Huang</name><email>hwdavr@gmail.com</email></author><summary type="html">Tomcat web server often suffers from java.lang.OutOfMemoryError: PermGen space whenever you deploy and un-deploy your web application couple of time. In this article, we will see how to fix java.lang.OutOfMemoryError: PermGen Space in tomcat server.</summary></entry><entry><title type="html">Understanding of MVVM architecture</title><link href="https://hwdavr.github.io/programming/understanding-of-MVVM-architecture/" rel="alternate" type="text/html" title="Understanding of MVVM architecture" /><published>2018-03-29T11:00:33+00:00</published><updated>2018-03-29T11:00:33+00:00</updated><id>https://hwdavr.github.io/programming/understanding-of-MVVM-architecture</id><content type="html" xml:base="https://hwdavr.github.io/programming/understanding-of-MVVM-architecture/">&lt;p&gt;After done one WPF application and one JavaFX application, I already have a good understanding of MVVM architecture.
Although MVVM architecture was first introduced by Microsoft and widely used in WPF application, now some other applications also can use it, for example, Android application by using google data-binding library and Web application by using Angular JS.
MVVM becoming more and more popular is because its loose coupling and clear responsibility of View layer and Control layer, comparing with traditional MVC.&lt;/p&gt;

&lt;h3 id=&quot;why-mvvm-architecture-is-loosely-decoupled&quot;&gt;Why MVVM architecture is loosely decoupled?&lt;/h3&gt;
&lt;p&gt;The reason is simple. In MVVM, only View layer is holding the reference of View Model, only View Model is holding the reference of Model layer.
Not like MVC, even Model layer also can hold the reference of View layer.
As a results, when one view is not used, its memory can be collected even its modeling is used by another view.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://hwdavr.github.io/assets/images/mvvm.png&quot; alt=&quot;MVVM&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;data-binding&quot;&gt;Data binding&lt;/h3&gt;
&lt;p&gt;The foundation of MVVM is data binding, without data binding, MVVM cannot be achieved. MVVM use data binding to communicate with View and View Model. This is the basic principle of MVVM. Someone may make mistake to use data binding with View and Model, it’s not a correct practice. In MVVM, View only communicates with View Model directly.&lt;/p&gt;

&lt;h2 id=&quot;implementation&quot;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;As long as you know how to work in each layer, you know how to implement MVVM.&lt;/p&gt;

&lt;h3 id=&quot;view&quot;&gt;View&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Create UI components&lt;/li&gt;
  &lt;li&gt;Create data-binding with View Model&lt;/li&gt;
  &lt;li&gt;Limited components event handler
Ideally an MVVM application should not have any code like this where a button’s click event is handled in the code-behind of the view:
```&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;button content=&quot;Click here!&quot; click=&quot;btn_Click&quot;&gt;&lt;/button&gt;&lt;/p&gt;

&lt;p&gt;protected void btn_Click(object sender, RoutedEventArgs e)
{
  /* This is not MVVM! */
}
```
Instead, in addition to providing properties to expose data to be displayed or edited in the view, the view model defines actions that can be performed by the user and typically expose these as commands. 
The reason that don’t put these event handlers in View layer is because normally inside even handler, you will be inevitable to do some UI logic. But for MVVM, all the UI logic should go to View Model.&lt;/p&gt;

&lt;h3 id=&quot;view-model&quot;&gt;View Model&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Create data binding properties&lt;/li&gt;
  &lt;li&gt;Commands&lt;/li&gt;
  &lt;li&gt;Value Converters
All the UI logic should be implemented in View Model. For example, when the data is fetching, a progress bar is shown, after the data is loaded, the progress bar is dismissed, and the UI is updated.
The interaction of UI logic is done in View Model, because View Model is holding all the properties that binding to the View. All the view change can be done in View Model through data binding. So it’s the best place to do UI components interaction.
View Model is only doing UI logic, not business logic, don’t put the business logic here also.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;model&quot;&gt;Model&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Creating plain objects&lt;/li&gt;
  &lt;li&gt;Implement business logic
The Modeling layer is just some plain objects with some business logic. In multi-platform application, the business logic is implemented at server side and is commonly used by different clients, for example, web, mobile application. To reduce the development effort, you can put as much of logic in server side as possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;view---view-model&quot;&gt;View -&amp;gt; View Model&lt;/h3&gt;
&lt;p&gt;View and View Model are mapping together. When you have a Label on view, you might need a string property in View Model. When you have a Table on view, you might need a list property in View Model. When the view is changed by using, the property in View Model is changed automatically, if you already implement the data binding.&lt;/p&gt;

&lt;h3 id=&quot;view-model---view&quot;&gt;View Model -&amp;gt; View&lt;/h3&gt;
&lt;p&gt;If you set the data binding to bi-direction, View can be updated when View Model property is changed. Data binding has the mechanism to send notifications when the View Model property is changed. In WPF, you need to implement INotifyPropertyChanged to enable this function. 
Or in another way, use observable property (normally an ObservableCollection), and implement the event listener in View layer (This is the only way in JavaFX application).&lt;/p&gt;

&lt;h3 id=&quot;view-model---model&quot;&gt;View Model -&amp;gt; Model&lt;/h3&gt;
&lt;p&gt;Because View Model is holding the reference of Modeling, View Model can change the Model data directly.&lt;/p&gt;

&lt;h3 id=&quot;model-view-model&quot;&gt;Model-&amp;gt;View Model&lt;/h3&gt;
&lt;p&gt;In simple application, you may don’t need even consider this problem. Because all the UI logic is done in View Model, and View Model record the change in Model layer, you don’t need the Model to change View Model.
In some complicated application, especially multiple views sharing the same modeling, we still need it. In this case, we can use some messaging framework (PRISM, OSGi EventAdmin).&lt;/p&gt;

&lt;h3 id=&quot;view-model---view-model&quot;&gt;View Model &amp;lt;-&amp;gt; View Model&lt;/h3&gt;
&lt;p&gt;Same as Model to View Model, you can use some messaging framework to communicate between View Models.&lt;/p&gt;</content><author><name>Walter Huang</name><email>hwdavr@gmail.com</email></author><summary type="html">After done one WPF application and one JavaFX application, I already have a good understanding of MVVM architecture. Although MVVM architecture was first introduced by Microsoft and widely used in WPF application, now some other applications also can use it, for example, Android application by using google data-binding library and Web application by using Angular JS. MVVM becoming more and more popular is because its loose coupling and clear responsibility of View layer and Control layer, comparing with traditional MVC.</summary></entry></feed>