Monkeyrunner can help you recover ColorNote password

This time I engaged myself in some “cracking” activity after a stressed conversation I had with a friend.
*** If you came to this Blogpost because you locked your phone and you are not really IT person please read the comment below from Ashley***
There is a not so quick but not so ‘hackerish’ workaround:
—-
actually i discover a method, that is once u restart u smart phone, u enter the colornote it aint required any password, then u faster screenshots the contents inside, it only persist for around 5 seconds, then will log out , so u keep restart then u cn get bck all the things inside dy simply by screenshots…. this is what i do to take bck my thngs as i frgt my lock pattern as well =)
—-
Thanks Ashley!

This is how it all happened…

I was chatting with a friend when suddenly(quite stressed) she asked me if I know someone ( i quote) “who can crack an Android application”?! Since  I don’t usually support cracking anything I wanted her to explain exactly what she meant with that sentence.  So, she had installed an application – ColorNote on her phone that allows locking files with certain important information with some so-called master password. Then the files are encrypted and there is no way of decrypting them if you don’t know the password. First I tried to calm her down telling her to search the web for some solution. I installed the application, tested it for a while, created some files of my own, locked some of them, did a backup…. All of that went smooth! I must say that the developers have done a really good job with this app. Even if someone gets my files they are still encrypted with the password I put! The problem arises when I forget the master password of the application! If you want to change it all of the files that were encrypted with it are DELETED?!!! After reading many forums/blogs/discussions it became clear to me that there is no solution to the problem other than deleting all the locked files which seemed like the developers missed to solve a quite trivial problem! What if I store my credit card pin in it and I am somewhere away from home and I urgently need it? What if I have stored my bank details and I need them immediately for some transaction? What if I have stored some other really important information? And even though I am sure at the time of creating the master password that I will remember it always, it might happen that I forget it, right? So this really got me angry and I decided to find a way how to prove that even their concept was not the perfect one…

So I came to an idea to write a simple monkeyrunner script that would generate combinations of letters/numbers that came to my mind that I might have put as a password. There is no limit in the number of tries to enter the password so..  I was right.. this really worked!

Here is the script that I used for “cracking” my ColorNote master password.

# Imports the monkeyrunner modules used by this program
from __future__ import generators
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

def xcombinations(items, n):
    if n==0: yield []
    else:
        for i in xrange(len(items)):
            for cc in xcombinations(items[:i]+items[i+1:],n-1):
                yield [items[i]]+cc

def xuniqueCombinations(items, n):
    if n==0: yield []
    else:
        for i in xrange(len(items)):
            for cc in xuniqueCombinations(items[i+1:],n-1):
                yield [items[i]]+cc

def xselections(items, n):
    if n==0: yield []
    else:
        for i in xrange(len(items)):
            for ss in xselections(items, n-1):
                yield [items[i]]+ss

def xpermutations(items):
    return xcombinations(items, len(items))

if __name__=="__main__":

# Connects to the current device, returning a MonkeyDevice object
    device = MonkeyRunner.waitForConnection()

# sets a variable with the package's internal name
    package = 'com.socialnmobile.dictapps.notepad.color.note'

# sets a variable with the name of an Activity in the package
    activity = 'com.socialnmobile.colornote.activity.NoteList'

    print device.getProperty('display.width'), device.getProperty('display.height')

# sets the name of the component to start
    runComponent = package + '/' + activity

# Runs the component
    device.startActivity(component=runComponent)

# Presses the Menu button
    device.press('KEYCODE_MENU','DOWN_AND_UP')

    MonkeyRunner.sleep(1)
    device.touch(240, 750, 'DOWN_AND_UP')
#device.drag((230, 750), (240, 760), 2.0, 2) 

    MonkeyRunner.sleep(1)
    device.touch(240, 350, 'DOWN_AND_UP')

    MonkeyRunner.sleep(1)
    device.touch(120, 500, 'DOWN_AND_UP')

#MonkeyRunner.sleep(1)
#device.type('5551234')

#MonkeyRunner.sleep(1)
#device.touch(240, 350, 'DOWN_AND_UP')

#MonkeyRunner.sleep(1)
#device.type('5551234')

    MonkeyRunner.sleep(1)
    #device.type('color')
    #device.touch(240, 350, 'DOWN_AND_UP')
#device.touch(240, 350, 'DOWN_AND_UP')

    #for num in range(2000, 2003):
    #    print num
    #    device.type(str(num))
    #    MonkeyRunner.sleep(1)
    #    device.touch(240, 350, 'DOWN_AND_UP')

    print "Permutations"
    for p in xselections(['3','4','6','5','2'],4):
        print ''.join(p)
        device.type(''.join(p))
        MonkeyRunner.sleep(1)
        device.touch(240, 350, 'DOWN_AND_UP')

Here is a video of the monkeyrunner working on my phone! I put simple password just to make the video short so that you can see the result of the script.

NOTE: In order to make it work on your phone you’d have to check the screen size and tune the clicks.

NOTE1: This script lasts up to couple of hours but if the right letters/numbers are put it might solve your problem! Also this is something that I’d suggest to people who really are in need of their encrypted data! (and till the developers don’t think of a solution!)

And a final NOTE to the developers: Think of a way in the next update (using IMEI, PIN, mail, other…) how to solve this problem and I’d put this app in my all time Android favs!

How to become a famous blogger?

I noticed that I don’t find so much time for my blog lately so this is just a little something to get me going 🙂

I have a feeling that I’ll soon have a lot to blog about but till that day comes I’ll leave this photo to remind me 🙂

Since I usually quote what I have learned from where this image was taken from a post: http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/25388 on the SAP SCN Blogs.

Accordion-like widget for Android

I had some Android project this last week and I came to a problem.  I wanted to make an accordion-like view for a part of the application that I am making and since I have a short deadline the first thing that came to my mind was to search what others have done. I only managed to find a simple idea given on the Android developer’s mailing list but I couldn’t find any code available.

So I decided to publish my code in order to help others that would like to implement accordion-like view for Android quick and simple or simply to learn more. I must say that for any other problem it would need a lot customization and this code that I’ll publish here is more like an implementation of a design pattern for making accordion widget.

Here is a video of how it looks like in the Emulator.

So first it is important to talk about the layout design. It was done following the suggestion given here.  I won’t explain much I think that it is very clear how it is done ;).

So I’ll simply paste part of my main.xml code here:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/root_layout" android:layout_width="fill_parent"
	android:layout_height="fill_parent" android:background="#FFFFFFFF"
	android:layout_weight="1" android:orientation="vertical">
	<Button android:id="@+id/btnProfile" android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:text="Profile"
		android:textColor="#FFFFFFFF" />
	<LinearLayout android:id="@+id/panelProfile"
		android:orientation="vertical" android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:layout_weight="1"
		android:background="#FFFFFFFF">
		<LinearLayout android:id="@+id/panelProfile1"
			android:orientation="horizontal" android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_weight="1"
			android:background="#FFFFFFFF">
			<TextView android:id="@+id/strName" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:text="Name" />
			<EditText android:id="@+id/txtName" android:layout_width="fill_parent"
				android:layout_height="wrap_content" />
		</LinearLayout>
		<LinearLayout android:id="@+id/panelProfile2"
			android:orientation="horizontal" android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_weight="1"
			android:background="#FFFFFFFF">
			<TextView android:id="@+id/strSurname" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:text="Surname" />
			<EditText android:id="@+id/txtSurname" android:layout_width="fill_parent"
				android:layout_height="wrap_content" />
		</LinearLayout>
	</LinearLayout>
	<Button android:id="@+id/btnSettings" android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:text="Settings"
		android:textColor="#FFFFFFFF" />
	<LinearLayout android:id="@+id/panelSettings"
		android:orientation="vertical" android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:layout_weight="1"
		android:background="#FFFFFFFF">
		<LinearLayout android:id="@+id/panelSettings1"
			android:orientation="horizontal" android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_weight="1"
			android:background="#FFFFFFFF">
			<TextView android:id="@+id/strMail" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:text="e-mail" />
			<EditText android:id="@+id/txtMail" android:layout_width="fill_parent"
				android:layout_height="wrap_content" />
		</LinearLayout>
		<LinearLayout android:id="@+id/panelSettings2"
			android:orientation="horizontal" android:layout_width="fill_parent"
			android:layout_height="wrap_content" android:layout_weight="1"
			android:background="#FFFFFFFF">
			<TextView android:id="@+id/strPhone" android:layout_width="wrap_content"
				android:layout_height="wrap_content" android:text="Phone" />
			<EditText android:id="@+id/txtPhone" android:layout_width="fill_parent"
				android:layout_height="wrap_content" />
		</LinearLayout>
	</LinearLayout>
	<Button android:id="@+id/btnPrivacy" android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:text="Privacy"
		android:textColor="#FFFFFFFF" />
	<LinearLayout android:id="@+id/panelPrivacy"
		android:orientation="vertical" android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:layout_weight="1"
		android:background="#FFFFFFFF">
		<CheckBox android:id="@+id/checkFacebook"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" android:text="Facebook" android:textColor="#ff355689">
		</CheckBox>
		<CheckBox android:id="@+id/checkLinkedIn"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" android:text="LinkedIn" android:textColor="#ff355689">
		</CheckBox>
		<CheckBox android:id="@+id/checkTwitter"
			android:layout_width="fill_parent" android:layout_height="wrap_content"
			android:layout_weight="1" android:text="Twitter" android:textColor="#ff355689">
		</CheckBox>
	</LinearLayout>
</LinearLayout>

Then it is very important to use the parameter

android:visibility="gone"

for all the clicks performed on different buttons.

Here is the code for the activity.

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class AccordionActivity extends Activity {
	/** Called when the activity is first created. */

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		Button btnProfile = (Button) findViewById(R.id.btnProfile);
		Button btnSettings = (Button) findViewById(R.id.btnSettings);
		Button btnPrivacy = (Button) findViewById(R.id.btnPrivacy);

		View panelProfile = findViewById(R.id.panelProfile);
		panelProfile.setVisibility(View.GONE);

		View panelSettings = findViewById(R.id.panelSettings);
		panelSettings.setVisibility(View.GONE);

		View panelPrivacy = findViewById(R.id.panelPrivacy);
		panelPrivacy.setVisibility(View.GONE);

		btnProfile.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// DO STUFF
				View panelProfile = findViewById(R.id.panelProfile);
				panelProfile.setVisibility(View.VISIBLE);

				View panelSettings = findViewById(R.id.panelSettings);
				panelSettings.setVisibility(View.GONE);

				View panelPrivacy = findViewById(R.id.panelPrivacy);
				panelPrivacy.setVisibility(View.GONE);

			}
		});

		btnSettings.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// DO STUFF
				View panelProfile = findViewById(R.id.panelProfile);
				panelProfile.setVisibility(View.GONE);

				View panelSettings = findViewById(R.id.panelSettings);
				panelSettings.setVisibility(View.VISIBLE);

				View panelPrivacy = findViewById(R.id.panelPrivacy);
				panelPrivacy.setVisibility(View.GONE);

			}
		});

		btnPrivacy.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				// DO STUFF
				View panelProfile = findViewById(R.id.panelProfile);
				panelProfile.setVisibility(View.GONE);

				View panelSettings = findViewById(R.id.panelSettings);
				panelSettings.setVisibility(View.GONE);

				View panelPrivacy = findViewById(R.id.panelPrivacy);
				panelPrivacy.setVisibility(View.VISIBLE);

			}
		});

	}

}

I noticed that I can not upload archives here on WordPress so I promise that I’ll soon upload the full project somewhere and add a link here. But these pieces of code that I have put here are enough for anyone who wants to have it done fast and simple.

I dare others to make a horizontal accordion. It is kinda cute and stylish 😉

Multi-language messages in SAP

The title of this post says it all.  It is known that usually international companies can afford to implement SAP and that part of the correspondence that they will have will be in several languages. So here is a simple procedure that can be used when a message to customers from different countries should be sent.

Step 1 -> Open the transaction s010 for Standard text creation

Step 2 ->  In the field add descriptive

TEXT NAME – (in this case – Z_CUST_MSG)

TEXD ID – ST

LANGUAGE – any.

Step 3 ->  Write the content of the message in the text editor and save it.

Step 4 ->  Repeat Steps 1-3 for all the languages that you would like to use.

Step 4 -> Using the text via ABAP code.

* t_lines to hold the text
  data: t_lines type table of tline with header line.
* CUSTOMER COMMUNICATION LANGUAGE
  select spras
    into cust_lang
    from kna1
    where kunnr = p_kunnr.
  endselect.
* GET THE TEXT FOR THE BODY OF THE MESSAGE
  CALL FUNCTION 'READ_TEXT'
    EXPORTING
      CLIENT   = SY-MANDT
      ID       = 'ST'
      LANGUAGE = cust_lang
      NAME     = 'Z_CUST_MSG'
      OBJECT   = 'TEXT'
    TABLES
      LINES    = t_lines.
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* IF THERE IS NO TRANSLATION OF THE LANGUAGE ASK USER
  ENDIF.
  DATA: counter type i.
 counter = 0.
 loop at t_lines.
 if counter = 0.
* in this case the first line of the text is used as a subject text for the message
      REPLACE ALL OCCURRENCES OF '/' IN t_lines WITH ''.
      modify t_lines.
      msg_sub = t_lines.
      counter = counter + 1.
    else.
      REPLACE ALL OCCURRENCES OF '/' IN t_lines WITH ''.
      modify t_lines.
      concatenate msg_body t_lines CL_ABAP_CHAR_UTILITIES=>NEWLINE into msg_body.
      counter = counter + 1.
    endif.
  endloop.

Outlook messages from SAP system

This is a sample code that can be used to create draft messages in your Outlook through SAP. Of course it is important to understand what it does so I tried to comment as much I can.

The VB code that can be used to create draft message is given here:

Sub create_draftmsg()
  Dim oApp As Outlook.Application
    Dim oEmail As Outlook.MailItem
    Set oApp = New Outlook.Application
    Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
        .To = "to@mail.com"
        .CC = ""
        .Subject = "SUBJECT"
        .Body = "BODY TEXT"
        .Attachments.Add "C:\Cat.bmp", olByValue
        .Save
    End With
    Set oEmail = Nothing
End Sub

The ABAP code is given below.

INCLUDE OLE2INCL.
* they are all OLE2_OBJECTS so it is important to know the real classes
DATA: OUTLOOK TYPE OLE2_OBJECT,
MAILITEM TYPE OLE2_OBJECT,
ATTACHMENTS TYPE OLE2_OBJECT,
APPT TYPE OLE2_OBJECT,
DESTI TYPE OLE2_OBJECT,
BODYMAIL(600) TYPE C.
CREATE OBJECT OUTLOOK 'OUTLOOK.APPLICATION'.
* Get the outlook namespace
CALL METHOD OF OUTLOOK 'GetNamespace' = NAMESPACE
EXPORTING
#1 = 'MAPI'.
* Get outlook folders and create a reference to sent mail folder
* (myfolder)
* If this is not used than a draft message is not created when Outlook is not running
CALL METHOD OF NAMESPACE 'GetDefaultFolder' = MYFOLDER  EXPORTING     #1 = 16.    "olFolderDraftMail (value from a short debugging in VB)
CALL METHOD OF OUTLOOK 'CreateItem' = OUTMAIL EXPORTING #1 = 0. " 0 - MailItem
SET PROPERTY OF OUTMAIL 'SUBJECT' = 'SUBJECT'.
SET PROPERTY OF OUTMAIL 'BODY' = BODYMAIL.
CALL METHOD OF OUTMAIL 'RECIPIENTS' = DESTI.
CALL METHOD OF DESTI 'ADD' EXPORTING #1 = 'recipient@mail.com'.
CALL METHOD OF OUTMAIL 'ATTACHMENTS' = ATTS.
CALL METHOD OF ATTS 'ADD' EXPORTING #1 = 'filepath:\file.type'.
CALL METHOD OF OUTMAIL 'SAVE'.
FREE OBJECT DESTI.
FREE OBJECT ATTS.
FREE OBJECT OUTMAIL.
FREE OBJECT OUTLOOK.

Today’s wisdom: Use Macro recorder to discover the classes needed in order to use Microsoft goodies in ABAP! 🙂

Testing my thesis apps in a local primary school

After the first version of the apps is done it was time to test them with kids and see if they like them. I visited a primary school here in Skopje and had a chance to test them in 3 different classes. Total 75 kids tested the apps. The interesting fact was that 34 out of 75 kids (or their parents) had smartphones but only 7 of them had game consoles at home.

It is obvious that the second application is not motivating too much physical activity but this was due to the limited space we had in the classroom since now they have PC for every child in primary schools and tables couldn’t be moved around. But we were invited by the gym teacher to join them on a gym lesson next time.

SAP Technical sites/blogs I often consult…

The best technical  ones

http://www.saptechnical.com

http://abap4.tripod.com

http://abaplovers.blogspot.com

http://sap.ittoolbox.com

http://www.erpdb.info

http://www.freesaptutorial.com/

http://www.erpgenie.com

I’ll update this list every time I find a site/blog that will help me.