Closed chrisfry closed 7 years ago
I've been using the REST API for stuff like this. A script would probably be just a few lines I think, using Python requests library. I'll try to dig one out from whichever system I left it on.
The following code should work, but current master seems to have some bug attempting to display the listing in the UI.
#!/usr/bin/env python
#
import sys
import requests
import json
apikey = "<YOUR API KEY HERE>"
api_server = "http://<YOUR CRITS SERVER>/api/v1"
auth_params = {
'api_key': apikey,
'username': 'you'
}
my_targets = [
{'firstname': 'John', 'lastname': 'Doe',
'division': 'Janitorial', 'department': 'Basement',
'email_address': 'john.doe@org.com',
'organization_id': '12', 'title': 'Supervisor',
'note': 'Some helpful notes'},
{'firstname': 'Bernice', 'lastname': 'Johnston',
'division': 'Information Technology', 'department': 'Tower',
'email_address': 'bernice.johnston@org.com',
'organization_id': '13', 'title': 'Data Entry',
'note': 'Some more helpful notes'},
]
for t in my_targets:
t['api_key'] = auth_params['api_key']
t['username'] = auth_params['username']
t['source'] = 'OSINT Website'
t['reference'] = 'Ref1'
t['method'] = 'add-targets.py'
t['related_id'] = '' # Had to do this... seems related_id is used without checking for presence in targets
r = requests.post('{0}/targets/'.format(api_server), data=t)
As I said... my current master
seems to not display these in the UI listing when I click Targets in the CRITs menu.
However, if I visit the following, I can see the data made it into the database:
HTH
Issue #661 may also be causing this to not work as expected for you without the t['related_id']
assignment
PR #736 was merged into master, meaning that the following line is unnecessary in the above example:
t['related_id'] = '' # Had to do this... seems related_id is used without checking for presence in targets
This totally worked thanks man!
On 4/11/16 9:23 AM, Coleman Kane wrote:
PR #736 https://github.com/crits/crits/pull/736 was merged into master, meaning that the following line is unnecessary in the above example:
t['related_id'] = '' # Had to do this... seems related_id is used without checking for
presence in targets
— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/crits/crits/issues/733#issuecomment-208339462
any way we could get a script to add targets in bulk?