def download_data(request, api=False): """Download Application Data from Device.""" logger.info('Downloading app data') data = {} try: env = Environment() md5_hash = request.POST['hash'] if not is_md5(md5_hash): return invalid_params(api) package = get_package_name(md5_hash) if not package: data = { 'status': 'failed', 'message': 'App details not found in database' } return send_response(data, api) apk_dir = os.path.join(settings.UPLD_DIR, md5_hash + '/') httptools_url = get_http_tools_url(request) stop_httptools(httptools_url) files_loc = '/data/local/' logger.info('Archiving files created by app') env.adb_command([ 'tar', '-cvf', files_loc + package + '.tar', '/data/data/' + package + '/' ], True) logger.info('Downloading Archive') env.adb_command( ['pull', files_loc + package + '.tar', apk_dir + package + '.tar']) logger.info('Stopping ADB server') env.adb_command(['kill-server']) data = {'status': 'ok'} except Exception as exp: logger.exception('Downloading application data') data = {'status': 'failed', 'message': str(exp)} return send_response(data, api)
def configure_proxy(self, project, request): """HTTPS Proxy.""" self.install_mobsf_ca('install') proxy_port = settings.PROXY_PORT logger.info('Starting HTTPs Proxy on %s', proxy_port) httptools_url = get_http_tools_url(request) stop_httptools(httptools_url) start_proxy(proxy_port, project)
def httptools_start(request): """Start httprools UI.""" logger.info('Starting httptools Web UI') try: httptools_url = get_http_tools_url(request) stop_httptools(httptools_url) start_httptools_ui(settings.PROXY_PORT) time.sleep(3) logger.info('httptools UI started') if request.GET['project']: project = request.GET['project'] else: project = '' url = f'{httptools_url}/dashboard/{project}' return HttpResponseRedirect(url) # lgtm [py/reflective-xss] except Exception: logger.exception('Starting httptools Web UI') err = 'Error Starting httptools UI' return print_n_send_error_response(request, err)