mirror of https://github.com/MISP/PyMISP
Add the following options:
- possibility to copy in one direction or the other between instance - add loop to simply put event ids to copypull/1/head
parent
9262405318
commit
31eb0d4c96
|
@ -1,24 +1,30 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
from pymisp import PyMISP
|
from pymisp import PyMISP
|
||||||
|
|
||||||
from keys import src, dest
|
from keys import cert, priv
|
||||||
|
|
||||||
url_source = 'https://misp.circl.lu'
|
url_cert = 'https://misp.circl.lu'
|
||||||
url_dest = 'https://misppriv.circl.lu'
|
url_priv = 'https://misppriv.circl.lu'
|
||||||
cert_source = 'misp.circl.lu.crt'
|
cert_cert = 'misp.circl.lu.crt'
|
||||||
cert_dest = 'misppriv.circl.lu.crt'
|
cert_priv = 'misppriv.circl.lu.crt'
|
||||||
source = None
|
source = None
|
||||||
destination = None
|
destination = None
|
||||||
|
|
||||||
|
|
||||||
def init():
|
def init(cert_to_priv=True):
|
||||||
global source
|
global source
|
||||||
global destination
|
global destination
|
||||||
source = PyMISP(url_source, src, cert_source, 'xml')
|
print cert_to_priv
|
||||||
destination = PyMISP(url_dest, dest, cert_dest, 'xml')
|
if cert_to_priv:
|
||||||
|
source = PyMISP(url_cert, cert, cert_cert, 'xml')
|
||||||
|
destination = PyMISP(url_priv, priv, cert_priv, 'xml')
|
||||||
|
else:
|
||||||
|
source = PyMISP(url_priv, priv, cert_priv, 'xml')
|
||||||
|
destination = PyMISP(url_cert, cert, cert_cert, 'xml')
|
||||||
|
|
||||||
|
|
||||||
def _to_utf8(request):
|
def _to_utf8(request):
|
||||||
|
@ -39,9 +45,25 @@ def copy_event(event_id):
|
||||||
def list_copy(filename):
|
def list_copy(filename):
|
||||||
with open(filename, 'r') as f:
|
with open(filename, 'r') as f:
|
||||||
for l in f:
|
for l in f:
|
||||||
l = int(l.strip())
|
copy(l)
|
||||||
print l
|
|
||||||
copy_event(l)
|
|
||||||
|
def loop_copy():
|
||||||
|
while True:
|
||||||
|
line = sys.stdin.readline()
|
||||||
|
copy(line)
|
||||||
|
|
||||||
|
|
||||||
|
def copy(eventid):
|
||||||
|
eventid = eventid.strip()
|
||||||
|
if len(eventid) == 0 or not eventid.isdigit():
|
||||||
|
print 'empty line or NaN.'
|
||||||
|
return
|
||||||
|
eventid = int(eventid)
|
||||||
|
print eventid, 'copying...'
|
||||||
|
r = copy_event(eventid)
|
||||||
|
print r.text
|
||||||
|
print eventid, 'done.'
|
||||||
|
|
||||||
|
|
||||||
def export_our_org():
|
def export_our_org():
|
||||||
|
@ -52,8 +74,16 @@ if __name__ == '__main__':
|
||||||
import argparse
|
import argparse
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description='Copy the events from one MISP instance to an other.')
|
description='Copy the events from one MISP instance to an other.')
|
||||||
parser.add_argument('-f', '--filename', type=str, required=True,
|
parser.add_argument('-f', '--filename', type=str,
|
||||||
help='File containing a list of event id.')
|
help='File containing a list of event id.')
|
||||||
|
parser.add_argument(
|
||||||
|
'-l', '--loop', action='store_true',
|
||||||
|
help='Endless loop: eventid in the terminal and it will be copied.')
|
||||||
|
parser.add_argument('--priv_to_cert', action='store_false', default=True,
|
||||||
|
help='Copy from MISP priv to MISP CERT.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
init()
|
init(args.priv_to_cert)
|
||||||
|
if args.filename is not None:
|
||||||
list_copy(args.filename)
|
list_copy(args.filename)
|
||||||
|
else:
|
||||||
|
loop_copy()
|
||||||
|
|
Loading…
Reference in New Issue