Пример #1
0
	def __init__(self, path):
		super(ELF, self).__init__()
		self.path = path
		self.r2 = r2pipe.open(path)
		self.info = DotMap({i:self.r2.cmdj("ij")["bin"][i] for i in ELF.info})
		self._base = 0

		l = []
		for m in ELF.info:
			l.append(m)
			l.append(self.info[m])	
		log.info("Opening binary {}".format(self.path), ("{:32}{}\n"*len(ELF.info)).format(*l).strip())

		self.sym = DotMap()
		
		for i in self.r2.cmdj("isj"):
			self.sym[i["name"]] = i["vaddr"]

		self.sections = {i["name"]:i["vaddr"] for i in self.r2.cmdj("iSj")}
		
		self.sym.got = DotMap({i["name"]:i["vaddr"] for i in self.r2.cmdj("irj")})
		self.sym.plt = DotMap({i["name"]:i["plt"]   for i in self.r2.cmdj("iij")})

		log.debug("GOT {} entries".format(len(self.sym.got)), "\n".join(["{:32}0x{:016x}".format(r[0], r[1]) for r in self.sym.got.items()]))
		log.debug("PLT {} entries".format(len(self.sym.plt)), "\n".join(["{:32}0x{:016x}".format(r[0], r[1]) for r in self.sym.plt.items()]))
Пример #2
0
 def close(self):
     self.p.stdin.close()
     self.p.stdout.close()
     self.p.stderr.close()
     self.p.terminate()
     self.p.wait()
     log.info("Process {} exited with code {}".format(
         green(self.p.pid), green(self.p.returncode)))
Пример #3
0
 def __init__(self, host, port, timeout=5):
     super(remote, self).__init__()
     self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.s.settimeout(timeout)
     self.s.connect((host, port))
     self.host = host
     self.port = port
     log.info("Connecting to {} on port {}".format(green(host),
                                                   green(port)))
Пример #4
0
 def __init__(self,
              args,
              stdin=subprocess.PIPE,
              stdout=subprocess.PIPE,
              stderr=subprocess.PIPE):
     super(process, self).__init__()
     self.p = subprocess.Popen(args,
                               stdin=stdin,
                               stdout=stdout,
                               stderr=stderr,
                               shell=False)
     log.info("Process started with PID {} {}".format(
         green(self.p.pid), args))
Пример #5
0
 def close(self):
     self.s.shutdown(socket.SHUT_RDWR)
     self.s.close()
     log.info("Closed connection with {} on port {}".format(
         green(self.host), green(self.port)))