Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OSCD Sprint #2] Final Pull Request / Summary #991

Merged
merged 93 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
ef5fa25
added initial files for gmail responder
Oct 6, 2020
f138f1e
implemented basic responder body
Oct 9, 2020
2b758ec
implemented blocking and unblocking of messages
Oct 9, 2020
b95cbba
added trashing cap and fixed some comments
Oct 9, 2020
aa77a4a
changed authenticate function
Oct 9, 2020
0400dd3
Add files via upload
districtofpaige Oct 11, 2020
a4de4de
implemented initial thehive connection
Oct 15, 2020
26bdc4b
pseudo implemented blocking mechanisms
Oct 15, 2020
8282fdc
implemented service files
Oct 16, 2020
8a2621c
implemented blockdomain (with mock block action)
Oct 16, 2020
64c364e
implemented unblock of domain (dirty and fake data)
Oct 16, 2020
682849a
implemented blocksender (fake n dirty)
Oct 16, 2020
ecd92c7
added some comments and fixes
Oct 16, 2020
4723ef1
implemented blocking/unblocking
Oct 19, 2020
2d57010
added trash message function and deleted some code
Oct 20, 2020
bc5f4e9
implemeted error message if gmail auth fails
Oct 20, 2020
729f9a3
implemeted deletemessage service
Oct 20, 2020
d1866f5
implemeted helper functions for auth and observable requests
Oct 20, 2020
4570ebe
replaced variable to fit new helper functions
Oct 20, 2020
de99000
changed the hive auth
Oct 20, 2020
e9c7c92
added comment for dynamic call part
Oct 20, 2020
677c830
фвв
staf711 Oct 20, 2020
0e5aa7c
Add new responders for PaloAltoNGFW
staf711 Oct 20, 2020
d16e0b3
implemeted helper function for tag and deleted useless comments
Oct 20, 2020
f2496ce
removed custom filter field of case
Oct 20, 2020
1a8dfc3
Add responce for PaloAltoNGFW
staf711 Oct 20, 2020
b5edcd4
implemented servicec account info for gmail auth
Oct 20, 2020
456bf91
Add response with security rules
staf711 Oct 26, 2020
0ad4459
credentails get valid with the first request; patched gmail_auth
Oct 28, 2020
c45961f
Add Responder for port with rules
staf711 Oct 29, 2020
401c46e
implemented gmail auth
Oct 29, 2020
9b2941d
implemented thehive authentication
Oct 29, 2020
1ee3390
fixed naming convention
Oct 29, 2020
cce8357
implemented service file configurationitems
Oct 29, 2020
97248f7
added gsuite domain configurationitem
Oct 29, 2020
50b2c57
added gmail domain config
Oct 29, 2020
962cdb6
fixed private key to be compliant with PEM format
Oct 29, 2020
79609a1
changed to quote because it takes single string and urlencodes
Oct 29, 2020
f67f108
changed function descriptoin
Oct 29, 2020
a73bae0
added functionality for custom gsuite domains
Oct 29, 2020
4949512
fixed case observable creation
Nov 2, 2020
8407623
implemented two dimensional tags for saving the filters
Nov 2, 2020
99c0b63
removed some unessassary function overload
Nov 2, 2020
3d819c8
implemented bulk delete via query
Nov 2, 2020
58688d3
fixed general tag
Nov 2, 2020
7b7c32b
added docker file
Nov 4, 2020
eef66ba
added urllib to requirements.txt
Nov 4, 2020
127f29c
deleted testing file
Nov 4, 2020
a546548
untracked venv
Nov 4, 2020
1dc39fc
handle error if no messages found
Nov 4, 2020
be935fb
fixed git case-sensitivity issue
Nov 6, 2020
f79ce83
remove useless service configuration file
Nov 6, 2020
6b4ee03
implemented readme for responder explanation
Nov 6, 2020
a85366f
bumped version number and fixed service descriptoin
Nov 6, 2020
fc84e08
newline at the end!
Nov 6, 2020
5ec1563
extended author to OSCD twitter handle
Nov 7, 2020
2cb53cf
Add custom rules and save attributes
staf711 Nov 8, 2020
6a56338
changed to delete API call acccording to discussion in pull request #891
Nov 12, 2020
e47eda9
Update AzureTokenRevoker.json
districtofpaige Nov 22, 2020
580dc21
Update AzureTokenRevoker.py
districtofpaige Nov 22, 2020
4915a53
Update AzureTokenRevoker.py
districtofpaige Nov 22, 2020
6594c9b
Update AzureTokenRevoker.py
districtofpaige Nov 22, 2020
da777ab
Add new version responders
staf711 Dec 16, 2020
888a9d0
Fixed bugs and errors
Jan 13, 2021
fee2f8a
add new version readme
Jan 18, 2021
45f9a0a
Fix error and redme.md
Feb 10, 2021
1bbc64e
Add fix
Feb 12, 2021
cfa1013
add new version json files
Feb 12, 2021
baca6bb
changed requirements to urllib3
Feb 13, 2021
79e32de
add new vesion configs and readme
Feb 25, 2021
0c05251
pip freeze with compatible version requirements
strassi Feb 26, 2021
878e132
implemented thehive permission check
strassi Mar 4, 2021
605dc7f
fail in hive auth if permissions are wrong
strassi Mar 4, 2021
7f68242
added api key permission contrains to readme.md
strassi Mar 4, 2021
2687147
add new version responders
Mar 16, 2021
4dc4034
[OSCD Initiative] Develop Responder for Duo Security; fix #857
yugoslavskiy Mar 27, 2021
5035ffa
New version responders
Apr 6, 2021
87a7ebc
Add new prefix for object
Apr 20, 2021
a4e7265
rename files
Apr 26, 2021
d07a6eb
Update version
Apr 26, 2021
309c24a
changed prefix
May 17, 2021
f8d00bc
Merge branch 'master' into feature/oscd
May 20, 2021
0deee22
Revert "Merge branch 'master' into feature/oscd"
May 20, 2021
e37a700
adjust files / doc
jeromeleonard Jul 21, 2021
7141d2d
Merge branch 'staf711-feature/oscd' into feature/oscd
jeromeleonard Jul 21, 2021
a0a04f3
Merge branch 'master' of https://github.com/strassi/Cortex-Analyzers …
jeromeleonard Jul 21, 2021
f9b3f21
adjust files / doc
jeromeleonard Jul 21, 2021
da19776
Merge branch 'strassi-master' into feature/oscd
jeromeleonard Jul 21, 2021
a4e9481
Merge branch 'master' of https://github.com/Dmweiner/Cortex-Analyzers…
jeromeleonard Jul 21, 2021
8f08ee2
Merge branch 'Dmweiner-master' into feature/oscd
jeromeleonard Jul 21, 2021
2d78f15
Merge branch 'master' of https://github.com/yugoslavskiy/Cortex-Analy…
jeromeleonard Jul 21, 2021
35fb61c
adjust files / doc
jeromeleonard Jul 21, 2021
2faf010
Merge branch 'yugoslavskiy-master' into feature/oscd
jeromeleonard Jul 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,898 changes: 1,898 additions & 0 deletions analyzers/EmlParser/input/Payment Notification 00000307700.eml

Large diffs are not rendered by default.

1,839 changes: 1,839 additions & 0 deletions analyzers/EmlParser/input/Payment_attachment.b64

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions analyzers/EmlParser/input/att.b64

Large diffs are not rendered by default.

Binary file added analyzers/EmlParser/input/att.doc
Binary file not shown.
Binary file added analyzers/EmlParser/input/file.xlsm
Binary file not shown.
17 changes: 17 additions & 0 deletions analyzers/EmlParser/input/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"dataType":"file",
"file": "Payment Notification 00000307700.eml",
"filename": "filetest",
"config":{
"manalyze_enable": false,
"manalyze_enable_docker": false,
"proxy_http": null,
"proxy_https": null,
"cacerts": null,
"jobTimeout": 10,
"check_tlp": false,
"max_tlp": 2,
"check_pap": false,
"max_pap": 2
}
}
172 changes: 172 additions & 0 deletions analyzers/EmlParser/input/mail.eml

Large diffs are not rendered by default.

Binary file not shown.
1 change: 1 addition & 0 deletions analyzers/EmlParser/output/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"success": true, "summary": {"taxonomies": [{"level": "info", "namespace": "EmlParser", "predicate": "Attachments", "value": 1}]}, "artifacts": [{"dataType": "ip", "data": "18.23.71.149"}, {"dataType": "ip", "data": "165.199.8.49"}, {"dataType": "ip", "data": "87.227.176.38"}, {"dataType": "mail", "data": "[email protected]"}, {"dataType": "mail", "data": "[email protected]"}, {"dataType": "hash", "data": "4dd9dfc92887e8c02cbc54a2abf73fb2"}, {"dataType": "hash", "data": "f7586d41577ed314ef5794072ddffef838996088"}, {"dataType": "hash", "data": "bfee589efb80fccdc2c19e16b54fa19d2a9ee7f5c359e0340cd568dce09f8ecb"}, {"dataType": "file", "file": "tmpu4zg7dbi", "filename": "Inv_307700_Service_04086.xlsm"}], "full": {"subject": "Payment Notification 00000307700", "date": "Mon, 22 Jun 2020 14:15:37 +0200", "receivers": "", "displayFrom": "[email protected]", "sender": "", "topic": "", "bcc": "", "displayTo": "<>", "headers": "Received: from ([87.227.176.38]) by [removed] for [removed];\n\tMon, 22 Jun 2020 12:15:38 +0000 (UTC)\nReceived: from [18.23.71.149] (account [email protected] HELO TIQOPOP.GAFYWOG.bwd) by customer.orbitel.bg (Exim 4.89)\twith ESMTPA id 89509C7C5024 for [removed]; Mon, 22 Jun 2020 14:15:37 +0200\nReceived: from ([165.199.8.49]) by customer.orbitel.bg with SMTP id 3943963C; Mon, 22 Jun 2020 14:15:37 +0200\nDate: Mon, 22 Jun 2020 14:15:37 +0200\nContent-Class: urn:content-classes:message\nSubject: Payment Notification 00000307700\nFrom: \"Billing Support\" <[email protected]>\n", "body": "Thank you very much for your business and continued support.\n\nPlease open the attached file to view your Invoice.\n\n Invoice Due Date: 06/22/2020\n Invoice Total Amount: $1,278.00\n\nBest Regards\n", "attachments": [{"filename": "Inv_307700_Service_04086.xlsm", "mime": "Microsoft Excel 2007+", "extension": "xlsm", "md5": "4dd9dfc92887e8c02cbc54a2abf73fb2", "sha1": "f7586d41577ed314ef5794072ddffef838996088", "sha256": "bfee589efb80fccdc2c19e16b54fa19d2a9ee7f5c359e0340cd568dce09f8ecb", "path": "/job/output/Inv_307700_Service_04086.xlsm"}]}}
Binary file added analyzers/EmlParser/output/tmpu4zg7dbi
Binary file not shown.
1 change: 1 addition & 0 deletions analyzers/Splunk/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
splunk-sdk
cortexutils
32 changes: 32 additions & 0 deletions responders/AzureTokenRevoker/AzureTokenRevoker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "AzureTokenRevoker",
"version": "1.0",
"author": "Daniel Weiner @dmweiner",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Revoke all Microsoft Azure authentication session tokens for a list of User Principal Names",
"dataTypeList": ["thehive:case"],
"command": "AzureTokenRevoker.py",
"baseConfig": "AzureTokenRevoker",
"configurationItems": [
{"name": "redirect_uri",
"description": "Azure AD Application URI (Example: https://login.microsoftonline.com/TENANTIDHERE/oauth2/token)",
"type": "string",
"multi": false,
"required": true
},
{"name": "client_id",
"description": "Client ID/Application ID of Azure AD Registered App",
"type": "string",
"multi": false,
"required": true
},
{"name": "client_secret",
"description": "Secret for Azure AD Registered Application",
"type": "string",
"multi": false,
"required": true
}
]

}
65 changes: 65 additions & 0 deletions responders/AzureTokenRevoker/AzureTokenRevoker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env python3
# encoding: utf-8
# Author: Daniel Weiner @dmweiner
import requests
import traceback
import datetime
from cortexutils.responder import Responder

# Initialize Azure Class
class AzureTokenRevoker(Responder):
def __init__(self):
Responder.__init__(self)
self.client_id = self.get_params('config.client_id', None, 'Azure AD Application ID/Client ID Missing')
self.client_secret = self.get_params('config.client_secret', None, 'Azure AD Registered Application Client Secret Missing')
self.redirect_uri = self.get_params('config.redirect_uri', None, 'Set a redirect URI in Azure AD Registered Application. (ex. https://logon.microsoftonline.<tenant id>/oauth2/token)')
self.time = ''
def run(self):
try:
self.user = self.get_params('data.data', None, 'No UPN supplied to revoke credentials for')
if not self.user:
self.error("No user supplied")
base_resource = "https://graph.microsoft.com"

token_data = {
"grant_type": "client_credentials",
'client_id': self.client_id,
'client_secret': self.client_secret,
'resource': 'https://graph.microsoft.com',
'scope': 'https://graph.microsoft.com'
}


#Authenticate to the graph api

token_r = requests.post(self.redirect_uri, data=token_data)
token = token_r.json().get('access_token')

if token_r.status_code != 200:
self.error('Failure to obtain azure access token: {}'.format(token_r.content))

# Set headers for future requests
headers = {
'Authorization': 'Bearer {}'.format(token)
}

base_url = 'https://graph.microsoft.com/v1.0/'

r = requests.post(base_url + 'users/{}/revokeSignInSessions'.format(self.user), headers=headers)

if r.status_code != 200:
self.error('Failure to revoke access tokens of user {}: {}'.format(self.user, r.content))

else:
#record time of successful auth token revokation
self.time = datetime.datetime.utcnow()

except Exception as ex:
self.error(traceback.format_exc())
# Build report to return to Cortex
full_report = {"message": "User {} authentication tokens successfully revoked at {}".format(self.user, self.time)}
self.report(full_report)


if __name__ == '__main__':
AzureTokenRevoker().run()
3 changes: 3 additions & 0 deletions responders/AzureTokenRevoker/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cortexutils
requests
datetime
34 changes: 34 additions & 0 deletions responders/Duo_Security/DuoLockUserAccount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "DuoLockUserAccount",
"version": "1.0",
"author": "Sven Kutzer / Gyorgy Acs, @oscd_initiative",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Lock User Account in Duo Security via AdminAPI (The user will not be able to log in)",
"dataTypeList": ["thehive:case_artifact"],
"command": "Duo_Security/duoLockUserAccount.py",
"baseConfig": "Duo_Security_main",
"configurationItems": [
{
"name": "API_hostname",
"description": "Duo Admin API hostname, api-XXXXXXXX.duosecurity.com",
"type": "string",
"multi": false,
"required": true
},
{
"name": "Integration_Key",
"description": "Integration Key",
"type": "string",
"multi": false,
"required": true
},
{
"name": "Secret_Key",
"description": "Secret Key",
"type": "string",
"multi": false,
"required": true
}
]
}
34 changes: 34 additions & 0 deletions responders/Duo_Security/DuoUnlockUserAccount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "DuoUnlockUserAccount",
"version": "1.0",
"author": "Sven Kutzer / Gyorgy Acs, @oscd_initiative",
"url": "https://github.com/TheHive-Project/Cortex-Analyzers",
"license": "AGPL-V3",
"description": "Unlock User Account in Duo Security via AdminAPI (The user must complete secondary authentication)",
"dataTypeList": ["thehive:case_artifact"],
"command": "Duo_Security/duoUnlockUserAccount.py",
"baseConfig": "Duo_Security_main",
"configurationItems": [
{
"name": "API_hostname",
"description": "Duo Admin API hostname, api-XXXXXXXX.duosecurity.com",
"type": "string",
"multi": false,
"required": true
},
{
"name": "Integration_Key",
"description": "Integration Key",
"type": "string",
"multi": false,
"required": true
},
{
"name": "Secret_Key",
"description": "Secret Key",
"type": "string",
"multi": false,
"required": true
}
]
}
31 changes: 31 additions & 0 deletions responders/Duo_Security/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### CortexResponder_DuoUserAccount
Rep. for Cortex Responder (TheHive project - https://github.com/TheHive-Project/CortexDocs)
to Lock/Unlock User Accounts in the Duo Admin Portal (Cisco Security)


There are two Responder available in order to change the status of a User in Duo Security via the AdminAPI (https://duo.com/docs/adminapi)

**DuoLockUserAccount** -> changes the "status" to “disabled” - The user will not be able to log in.

**DuoUnlockUserAccount** -> changes the "status" to “active” - The user must complete secondary authentication.

The Responder is looking for a "**username**" as input and queries the Duo Admin API, to receive the associated UserID.
The UserID is used to change the "status" of the particular user.

#### How to install:
* copy the folders "DuoLockUserAccount" & "DuoUnlockUserAccount" into your Cortex responders path
* install necessary python modules from the requirements.txt (**pip install -r requirements.txt**)
* restart Cortex to initialize the new Responder "**systemctl restart cortex**"
* add the ResponderConfig
* ![ResponderConfig](assets/ResponderConfig.jpg)
* enable the Responder Actions
* ![Responders](assets/Responders.jpg)

#### Add Observable type in TheHive**
* per default TheHive has no "username" Observable type, so we have to add this in the Admin settings
* ![AddObservableType](assets/AddObservableType.jpg)

#### Run the Responder action in TheHive

If you have add an observable, you can now take action and lock/unlock the User in Duo Security
* ![Demo_Lock-Unlock_DuoUser](assets/Demo_Lock-Unlock_DuoUser.gif)
48 changes: 48 additions & 0 deletions responders/Duo_Security/duoLockUserAccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
# encoding: utf-8

from cortexutils.responder import Responder
import requests
import duo_client
from datetime import datetime

class DuoLockUserAccount(Responder):
def __init__(self):
Responder.__init__(self)
self.API_hostname = self.get_param('config.API_hostname', None, "API hostname is missing")
self.iKey = self.get_param('config.Integration_Key', None, "Integration Key is missing")
self.sKey = self.get_param('config.Secret_Key', None, "Secret Key is missing")

def run(self):
Responder.run(self)

if self.get_param('data.dataType') == 'username':

str_username = self.get_param('data.data', None, 'No artifacts available')

admin_api = duo_client.Admin(self.iKey, self.sKey, self.API_hostname)

response = admin_api.get_users_by_name(username=str_username)

# print(response)

user_id=response[0]["user_id"]

# print("user_id:",user_id)

r = admin_api.update_user(user_id=user_id,status='disabled')

# print("response:",r)

if r.get('status') == 'disabled':
self.report({'message': 'User is locked in Duo Security.'})
else:
self.error('Failed to lock User Account in Duo.')
else:
self.error('Incorrect dataType. "username" expected.')

def operations(self, raw):
return [self.build_operation('AddTagToArtifact', tag='Duo User: locked')]

if __name__ == '__main__':
DuoLockUserAccount().run()
48 changes: 48 additions & 0 deletions responders/Duo_Security/duoUnlockUserAccount.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python3
# encoding: utf-8

from cortexutils.responder import Responder
import requests
import duo_client
from datetime import datetime

class DuoUnlockUserAccount(Responder):
def __init__(self):
Responder.__init__(self)
self.API_hostname = self.get_param('config.API_hostname', None, "API hostname is missing")
self.iKey = self.get_param('config.Integration_Key', None, "Integration Key is missing")
self.sKey = self.get_param('config.Secret_Key', None, "Secret Key is missing")

def run(self):
Responder.run(self)

if self.get_param('data.dataType') == 'username':

str_username = self.get_param('data.data', None, 'No artifacts available')

admin_api = duo_client.Admin(self.iKey, self.sKey, self.API_hostname)

response = admin_api.get_users_by_name(username=str_username)

# print(response)

user_id=response[0]["user_id"]

# print("user_id:",user_id)

r = admin_api.update_user(user_id=user_id,status='active')

# print("response:",r)

if r.get('status') == 'active':
self.report({'message': 'User is unlocked in Duo Security. The user must complete secondary authentication.'})
else:
self.error('Failed to unlock User Account in Duo.')
else:
self.error('Incorrect dataType. "username" expected.')

def operations(self, raw):
return [self.build_operation('AddTagToArtifact', tag='Duo User: reactivated')]

if __name__ == '__main__':
DuoUnlockUserAccount().run()
4 changes: 4 additions & 0 deletions responders/Duo_Security/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cortexutils
requests
datetime
duo_client
6 changes: 6 additions & 0 deletions responders/Gmail/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM python:3

WORKDIR /worker
COPY . Gmail
RUN pip install --no-cache-dir -r Gmail/requirements.txt
ENTRYPOINT Gmail/Gmail.py
Loading