REVEN-Axion 2015v1.1-r3
controlling_runs.py

Here is a small example demonstrating how to plug an inspector, add start an execution, pause, and test the current progress.

Here are the involved services:

1 
2 import reven
3 import time
4 import sys
5 
6 rvn = reven.reven_connection("localhost", 13370)
7 
8 if len(rvn.run_get_all()) > 0:
9  sys.stderr.write("[!] An analysis has already been done. Let's not start a new one.\n")
10  sys.exit(1)
11 
12 # Here is a list of inspectors that you can plug into Reven.
13 
14 print reven.inspector_list
15 
16 # Let's see what arguments are available in the stop_execution inspector:
17 for arg in reven.inspector_list["stop_execution"].arguments:
18  print arg
19 
20 # stop_at_top_level = False, symbol='Malloc', sequence_number=0 (unlimited)
21 stopper = reven.stop_execution(False, "malloc", 0)
22 rvn.engine_plug_inspector(stopper)
23 
24 # Launch the execution from the scenario start
25 rvn.engine_start_execution()
26 
27 # At this point, the execution is running in background
28 
29 
30 # Let's wait up to 10 seconds, or until we reach malloc.
31 max = 10
32 progress = rvn.engine_get_progress()
33 while progress.busy and max > 0:
34  print "Analyzing %s" % progress.text
35  time.sleep(1)
36  progress = rvn.engine_get_progress()
37  max -= 1
38 
39 if max < 0 and progress.busy:
40  # In this case, this means malloc was still not reached after 10 seconds of analysis.
41  rvn.engine_pause_execution()
42 
43 
44 # do some stuff with Reven
45 
46 
47 rvn.engine_resume_execution()
48 
49 # Wait again that Reven finishes some work, etc