Esempio n. 1
0
 def recvn(self, n, timeout=None):
     # must recv n bytes within timeout
     showbanner("Recv")
     buf = self.read(n, timeout)
     if len(buf) != n:
         raise (EOFError(color("[-]: Timeout when use recvn", 'red')))
     showbuf(buf)
     return buf
Esempio n. 2
0
 def recv_thread():
     try:
         while not go.is_set():
             buf = self.read(0x10000, 0.125, interactive=True)
             if buf:
                 showbuf(buf, is_noout=False)
                 showbanner('Interacting', is_noout=False)
             go.wait(0.2)
     except KeyboardInterrupt:
         go.set()
         print(color('[-]: Exited', 'red'))
Esempio n. 3
0
 def recvuntil(self, delim, drop=True, timeout=None):
     showbanner("Recv")
     if timeout is None:
         if self.timeout:
             timeout = self.timeout
         else:
             timeout = context.timeout
     buf = ''
     st = time.time()
     xt = st
     while (buf[-len(delim):] != delim):
         buf += self.read(1, timeout=timeout - (xt - st))
         if self.debugger is None:
             xt = time.time()
             if (xt - st) >= timeout:
                 break
     if not buf.endswith(delim):
         raise (EOFError(color("[-]: Recvuntil error", 'red')))
     if drop:
         buf = buf[:-len(delim)]
     showbuf(buf)
     return buf
Esempio n. 4
0
 def recvall(self, timeout=None):
     showbanner('Recv')
     buf = self.read(0x100000, timeout)
     showbuf(buf)
     return buf
Esempio n. 5
0
 def recv(self, n, timeout=None):
     # try to read n bytes, no exception
     showbanner('Recv')
     buf = self.read(n, timeout)
     showbuf(buf)
     return buf
Esempio n. 6
0
 def send(self, buf):
     showbanner('Send')
     rs = self.write(buf)
     showbuf(buf)
     return rs