File: test-leak.py

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (43 lines) | stat: -rwxr-xr-x 1,018 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
# -*- coding: utf-8 -*
from r2.r_core import *

class PyApp():
   def __init__(self):
       self.previous_rss = 0
       self.a = 0
       pass

   def print_rss_mem(self):
       import resource
       current_rss = resource.getrusage(resource.RUSAGE_SELF)[2]
       print current_rss, "bytes on RSS memory,", current_rss - self.previous_rss, "bytes leaked!"
       self.previous_rss = current_rss

   def io_va(self):
       if self.a==0:
            self.core.cmd0("e io.va=0")
	    self.a=1
       else:
            self.core.cmd0("e io.va=1")
	    self.a=0

   def load_radare(self, widget=False):
       self.core = RCore()
       # Preparamos el archivo
       file = "/tmp/elf-linux-x86-64" #usr/bin/tar"
       self.core.file_open(file, 0, 0)
       self.core.bin_load(None)

app = PyApp()
import time
#time.sleep(10)

app.print_rss_mem()
app.load_radare()
app.print_rss_mem()
for i in range(0, 30):
   app.io_va()
   f = app.core.anal.get_fcns()
   print len(f)
   app.print_rss_mem()