diff --git a/examples/get_attachment.py b/examples/get_attachment.py new file mode 100755 index 0000000..f40f38d --- /dev/null +++ b/examples/get_attachment.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from pymisp import PyMISP +from keys import misp_url, misp_key, misp_verifycert +import argparse + + +def init(url, key): + return PyMISP(url, key, misp_verifycert, 'json') + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Get an attachment.') + parser.add_argument("-a", "--attribute", type=int, help="Attribute ID to download.") + args = parser.parse_args() + + misp = init(misp_url, misp_key) + + with open('foo', 'wb') as f: + out = misp.get_attachment(args.attribute) + if isinstance(out, dict): + # Fails + print(out) + else: + f.write(out)