The slicer script make use of REVEN data tainting capabilities to display a list of instructions that manipulate tainted data.
5 host = raw_input(
'Enter the reven host [localhost]: ')
10 port = int(raw_input(
'Enter the reven port [13370]: '))
11 except ValueError
as e:
15 rvn = reven.reven_connection(host, port)
17 print(
"[!] Reven not found on port %d" % port)
20 print(
"[+] Connected to reven on %s:%d" % (host, port))
21 runs = rvn.run_get_all()
24 sys.stderr.write(
"[!] No run detected.\n")
31 start_sequence = int(raw_input(
"Enter the initial sequence [0]: "))
32 except ValueError
as e:
36 start_instruction = int(raw_input(
"Enter the initial instruction [0]: "))
37 except ValueError
as e:
41 stop_sequence = int(raw_input(
"Enter the ending sequence [1]: "))
42 except ValueError
as e:
47 reg = raw_input(
"Enter the initialy tainted register [eax]: ")
52 register_tainted = [reg]
56 first_memory_tainted = reven.logical_address(0,0)
57 last_memory_tainted = reven.logical_address(0,0)
59 initial_taint = reven.vector_of_symbolic()
64 start_point = reven.execution_point(run, start_sequence, start_instruction)
65 stop_point = reven.execution_point(run, stop_sequence, stop_instruction)
68 for sym
in register_tainted:
69 smem = reven.symbolic()
71 smem.type = reven.symbolic_type.register_all_purpose
72 initial_taint.append(smem)
75 offset_tainted = first_memory_tainted.offset
79 segment = first_memory_tainted.segment
80 for offset
in range(first_memory_tainted.offset, last_memory_tainted.offset):
81 smem = reven.symbolic()
82 smem.name =
"0x%x:0x%x" % (segment, offset)
83 smem.type = reven.symbolic_type.memory_physical
84 smem.physical_address = rvn.memory_get_physical_address(start_point, reven.logical_address(segment, offset))
86 initial_taint.append(smem)
89 print "[*] Tainting ..."
90 tainted_points = rvn.run_search_tainted_instructions(start_point, stop_point, 5000, initial_taint,
False)
92 print(
"[*] Tracking ")
93 for i
in initial_taint:
94 print(
"%s, " % (i.name),
'',
None)
95 print(
"from #%d:%d to #%d:%d" % (start_sequence,
99 print(
"-----------------------------------------------\n")
105 for entry
in tainted_points:
109 if not len(v.new)
and not len(v.old):
114 sequences = rvn.run_get_instructions_range(reven.execution_range(run, k.sequence_identifier, 1, 0))
116 ins = seq.instructions[k.instruction_index]
121 if ins.prefixes: mnemonic =
"%s " % ins.prefixes
122 mnemonic += ins.mnemonic
123 if ins.operand_one: mnemonic +=
" " + ins.operand_one
124 if ins.operand_two: mnemonic +=
", " + ins.operand_two
125 if ins.operand_three: mnemonic +=
", " + ins.operand_three
127 symbol =
"%s+%x" % (seq.sequence.symbol.name, seq.sequence.symbol.offset)
128 print(
"%-32s: #%d_%d: %s" % (symbol, k.sequence_identifier, k.instruction_index, mnemonic))