From db7708c7a2dc46af4d401beb61f09199427cdd1a Mon Sep 17 00:00:00 2001 From: Leon Jacobs Date: Wed, 10 Jan 2018 12:35:29 +0200 Subject: [PATCH] Add ability to dump cookies as a JSON structure. Fixes #41 --- objection/commands/ios/cookies.py | 19 ++++++++++++++++++- objection/console/commands.py | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/objection/commands/ios/cookies.py b/objection/commands/ios/cookies.py index 078d9d22..b44fe7af 100644 --- a/objection/commands/ios/cookies.py +++ b/objection/commands/ios/cookies.py @@ -1,3 +1,5 @@ +import json + import click from tabulate import tabulate @@ -5,7 +7,18 @@ from objection.utils.templates import ios_hook -def get(args: list = None) -> None: +def _should_dump_json(args: list) -> bool: + """ + Check if --json is part of the arguments. + + :param args: + :return: + """ + + return '--json' in args + + +def get(args: list) -> None: """ Gets cookies using the iOS NSHTTPCookieStorage sharedHTTPCookieStorage and prints them to the screen. @@ -30,6 +43,10 @@ def get(args: list = None) -> None: click.secho('No cookies found') return + if _should_dump_json(args): + print(json.dumps(response.data, indent=4)) + return + data = [] for cookie in response.data: diff --git a/objection/console/commands.py b/objection/console/commands.py index 07e6c892..796b5e72 100644 --- a/objection/console/commands.py +++ b/objection/console/commands.py @@ -423,6 +423,7 @@ 'commands': { 'get': { 'meta': 'Get the current apps shared cookies', + 'flags': ['--json'], 'exec': cookies.get } }