You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is ofthen easier to start with an existing script and adjust rather than totally from scratch.<br>
14
+
For that purpose, create a folder called 7zip_mine (in the directory where you had murphy, for example: c:\git_projects\murphy_sdk\samples\7zip_mine<br>
15
+
Copy the file extract_7zip_win_scraper.py from the samples\7zip into the new folder.<br>
16
+
<br>
17
+
The code of that file looks like this:<br>
18
+
<pre>
19
+
from model_extraction import base_extractor, configuration
The first parameter is the name we give to the model, so lets start by changing it to 7zip_mine<br>
40
+
The second parameter is the 1st action to perform when murphy starts crawling the application, we're not going to change it now but all you need to know for now is that
41
+
it will be a command that when build will look like: <pre>\utils\runurl.py http://192.168.56.1:8901/files/7z920.exe</pre>
42
+
In essence, it will download that url and then execute 7z920.exe<br>
43
+
Once we modified that line it should look like:<br>
We're ready to run it now, however we wont see it in the web workbench yet, we have to configure it, for doing so, open the file config.json that is located in the web_workbench directory.<br>
If you dont have the workbench running, launch it now (for example: C:\git-projects\murphy_sdk\web_workbench>workbench.py)<br>
81
+
Open a browser to http://127.0.0.1:8090 and enter your name, the project should appear in the dropdown list of models, of course it will still display a blank model.<br>
82
+
(if you had a browser opened then reload the page so you'll get the new project)<br>
Murphy will run in one machine (let's call it the controller) and will spawn a virtual machine<br>
7
+
In the virtual machine it will launch the application to be analyzed<br>
8
+
It will analyze what is seeing in the screen, what is the currently active window, what actions can the user do (buttons / links it can click, text inputs, selections from dropdown boxes, etc)<br>
9
+
It will systematically try to do those actions and generate a model that describes such application<br>
10
+
At any given point, murphy may decide to recreate the virtual machine to get back to a clean state (to prevent side effects from previously executed actions)<br>
11
+
<h4>Separation of concerns</h4>
12
+
Internally murphy has a few abstractions, amongst them:<br>
13
+
<ul>
14
+
<li>A scraper (a sorry name, but responsible to decompose what the user sees, akin to a DOM of the application)</li>
15
+
<li>A crawler (responsible for 'walking around' the application for mapping it)</li>
16
+
<li>A machine (handles the logic for creating, allocating and deallocating a virtual machine or device</li>
17
+
<li>A user (simulates user actions like mouse clicks and keyboard strokes, also responsible for providing screenshots</li>
18
+
</ul>
19
+
<h4>How does murphy know what elements the user can interact with?</h4>
20
+
The scraper component is a class responsible for doing that, there are at the moment 2 scrapers provided in murphy.<br>
21
+
One uses windows API's for enumerating windows and controls, so any native application built on c, c++, mfc and many other technologies will work fine,
22
+
it can be found in model_extraction_helpers/window_scraper.py<br>
23
+
The other uses user actions (pressing the TAB key and hovering the mouse) and analyzes the changes in the UI, it then deduces the user interface elements based on that, it can be found in model_extraction/ui/scraper.py<br>
24
+
The good side of scraper.py is that it works for most applications independently of the language used to develop them, the bad is that is unable to extract texts from the ui and that many applications are poorly written
25
+
and many ui elements are not reachable while pressing the TAB key.<br>
26
+
<br>
27
+
It is relatively simple to create additional scrapers, in house we had to develop a custom one for applications based on QT 4, we also develop an experimental scraper for android applications and also another one
28
+
based on the windows accessibility API (ui automation)<br>
29
+
<h4>How does murphy know it has to input a serial key / activation code / etc in an input field?</h4>
30
+
It doesnt, that's why the way to extract a model is to write a simple script and tell murphy the very specific, non guessable things of the application you're interested in.<br>
31
+
<h4>Boundaries</h4>
32
+
You dont want to crawl everything, suppose a case that there's a link in your application that opens a browser, im pretty sure you dont want murphy to crawl the whole internet.<br>
33
+
Here's where the concept of boundary comes, in an extraction script, one of the things you tell murphy is what you're NOT interested to crawl, in other words what are the boundaries of the exploration<br>
34
+
<h4>In simple words</h4>
35
+
The idea is to tell only the essential things in an extraction script, some typical things to handle:<br>
36
+
<ul>
37
+
<li>launch x application (run x command)</li>
38
+
<li>if the window is a help window, i'm not interested to crawl beyond it.</li>
39
+
<li>if the window is the 'enter serial number' then use x value on y field</li>
40
+
<li>if the window is 'license information' then the value of field 'y' must be ignored or custom handle (for example a timestamp)</li>
Murphy will launch a web server in the machine it is installed and will listen for connections in port 8090, care has been taken as this to be as safe as possible, however it
7
+
is recommended that you disable inbound connections to that port in your firewall unless you know and are sure of what you're doing.<br>
8
+
<h3>Platforms</h3>
9
+
Windows 7 (should work in Vista and windows 8, maybe xp, never tested with Metro apps)<br>
10
+
There's interest in making it work under Linux and we're almost there, if you know linux you can probably make it work.<br>
11
+
<h3>Dependencies</h3>
12
+
Python 2.7.3 or newer (32 bits), wont probably work on python 3.x and I havent tested with pre 2.7.3. It can be found <ahref="http://www.python.org/download/releases/2.7/">here</a><br>
13
+
There's a small dll written in c and compiled for 32 bits platform so it wont work on python 64 bits, however the work needed to support it is minimal<br>
14
+
Python PIL (be sure to install the one that matches your python version, including 32 or 64 bits...), it can be found <ahref="http://www.pythonware.com/products/pil/">here</a><br>
15
+
The included vnc library uses Twisted (download twisted for python), which can be found <ahref="https://twistedmatrix.com">here</a><br>
16
+
Twisted needs zope (4.0.6 seems to work fine), and can be found <ahref="https://pypi.python.org/pypi/zope.interface">here</a><br>
17
+
Graphviz, which is used for the flow graphs can be found <ahref="http://www.graphviz.org/">here</a> (Note: latest versions has some issues with the generated SVG, version 2.32 is known to work fine)<br>
18
+
You'll need Bottle, you can get it from <ahref="http://bottlepy.org/">here</a>, just drop the file in the web_workbench directory (it is known to work with version 0.11)<br>
19
+
VirtualBox, it can be found <ahref="https://www.virtualbox.org/">here</a><br>
20
+
Other virtualization tools like Kvm, VmWare, Dvmps, etc. can be used but need a small and simple adapter, take a look at virtualbox.py and rules_vbox.py in the model_extraction directory for that matter.<br>
21
+
7zip is used in some examples / exercises, get 7z920.exe and put it in the directory model_extraction_helpers/files (newer versions may work but I haven't tested them)<br>
22
+
23
+
24
+
<h3>Murphy</h3>
25
+
Since you're reading this, you already have this or know how to get this.<br>
26
+
You can copy murphy to any directory, you'll need to set your PYTHONPATH to that directory, so if you did a git clone to say c:\git_projects\murphy_sdk then do set PYTHONPATH=c:\git_projects\murphy_sdk<br>
27
+
Note that PYTHONPATH is needed for the model extraction scripts, the web workbench doesn't need it.<br>
28
+
29
+
<h3>Virtual machines</h3>
30
+
Murphy uses virtual machines to run the applications it will crawl and extract their models, it will not run the applications locally (unless you modify murphy to do so)<br>
31
+
See <ahref="virtual machine.html">here</a> on instructions on how to create a virtual machine that murphy can use.<br>
32
+
<h3>Checking the installation</h3>
33
+
Last but not least, in the murphy folder, there's a file graphviz.py, change the line:
As to point to the version of graphviz you installed<br>
38
+
After taking care of the dependencies, creating and configuring a virtual machine, be sure the virtual machine image you're going to use is not running!<br>
39
+
<br>
40
+
Assuming that your installation directory is c:\git_projects\murphy_sdk, do:<br>
2014-01-26 12:59:31,237 - root.murphy.user_simulation.vnc.vncdotool.vnc_wrapper - INFO - moving mouse to 1 1
71
+
2014-01-26 12:59:31,453 - root.model_extraction.virtualbox - INFO - Wait for remote machine to be idle...
72
+
2014-01-26 12:59:31,456 - root.murphy.user_simulation.helpers - INFO - Waiting for a stable screen
73
+
2014-01-26 12:59:39,292 - root.model_extraction.ui.node - DEBUG - Checking if i'm in Node 0
74
+
...
75
+
</pre>
76
+
It will take something between 5 and 10 minutes to extract the model, depending on many many many factors but it should finish, if you notice
77
+
in the log output that got stuck for more than a couple of minutes then something is definitively wrong.<br>
78
+
After (or while) the model is extracted, you can check the progress in the workbench tool.<br>
79
+
The models are already extracted in the git version so you can see the flows in the workbench but they wont work interactively or thru scripting if you dont rebuild them,
80
+
now is a good time to build the other provided examples (or you're doomed to forget it :))<br>
Some of the things that can be done with can be found <ahref="overview.html">here</a>.<br>
9
+
<br>
10
+
<ahref="why.html">Why?</a><br>
11
+
<br>
12
+
<ahref="how.html">How?</a><br>
13
+
<br>
14
+
<ahref="worthknowing.html">Things you should know...</a><br>
15
+
<br>
16
+
<ahref="install.html">Installation & running the samples</a><br>
17
+
<br>
18
+
<ahref="extractingmodels.html">Creating your first model extraction scripts</a><br>
19
+
<br>
20
+
<ahref="quickref.html">Quick references</a><br>
21
+
<br>
22
+
More to come...<br>
23
+
<br>
24
+
<h3>References on the web</h3>
25
+
A paper related to murphy was presented in EESSMod 2013 - Experiences and Empirical Studies in Software Modeling at <ahref="http://ceur-ws.org/Vol-1078/">http://ceur-ws.org/Vol-1078/</a>, a direct
26
+
link to the paper is <ahref="http://ceur-ws.org/Vol-1078/paper6.pdf">here</a><br>
27
+
Internal workshop of Ericsson in Stockholm, 2013 (sorry, no online material available at the moment)<br>
28
+
Anoter presentation related to murphy was submitted to <ahref="http://issta2014.org/">ISSTA 2014</a><br>
29
+
<br>
30
+
There's no official support, we may have support forums in the future if there's enough interest, in the meaintime (and I make no promises) you can try reach me at valkoinen.rapu at gmail.com.<br>
31
+
Some basic info I've written can be found in <ahref="http://valkoinenrapu.blogspot.com/2014/01/about-time.html">this blog</a><br>
32
+
<br>
33
+
<h3>Thanks to</h3>
34
+
Everybody who made this possible including the vncdotool guys and Pekka Aho et al (who kindly published papers about the experiences of Murphy in F-Secure)<br>
0 commit comments