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

more rate limiting #1

Merged
merged 67 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
c9e7bcb
first commit
punkrokk Sep 1, 2023
9874a3b
fix syntax
punkrokk Sep 2, 2023
a531176
linting
punkrokk Sep 2, 2023
1b3d5ee
add zip
punkrokk Sep 2, 2023
a08ef6f
add deploy to Azure botton
punkrokk Sep 2, 2023
1031f9a
add deploy to Azure botton
punkrokk Sep 2, 2023
0e2efd2
packaging-v3.0-script
punkrokk Sep 5, 2023
05d2406
fix linting
punkrokk Sep 5, 2023
467d904
fix build errors
punkrokk Sep 5, 2023
4096814
fix build errors
punkrokk Sep 5, 2023
e506d3d
fix logo metatdata
punkrokk Sep 5, 2023
c0b6fa6
fix publisher id
punkrokk Sep 5, 2023
0acc0d9
fix tier
punkrokk Sep 5, 2023
c928d3b
fix tier
punkrokk Sep 5, 2023
68ac237
fix fx type and runtime lang
punkrokk Sep 5, 2023
3cf05e1
fix fx app to be Linux
punkrokk Sep 5, 2023
4af7819
rebuild zip and samples
punkrokk Sep 6, 2023
f96ec7b
Update settings.json
punkrokk Sep 6, 2023
393433a
Update settings.json
punkrokk Sep 6, 2023
0809168
Update settings.json
punkrokk Sep 6, 2023
5e80362
revert settings
punkrokk Sep 6, 2023
ae795b8
revert settings
punkrokk Sep 6, 2023
41c8f06
update zip file path
punkrokk Sep 6, 2023
01f8410
add .gitignore
punkrokk Sep 6, 2023
424c522
update zip
punkrokk Sep 6, 2023
94d5a26
update deployment json dc
punkrokk Sep 6, 2023
cd60733
update function
punkrokk Sep 6, 2023
14828a9
repackage solution
punkrokk Sep 6, 2023
c7ec870
add analytic rule
punkrokk Sep 6, 2023
17e8291
readme
punkrokk Sep 6, 2023
e4c8b08
valid connector
punkrokk Sep 6, 2023
afccdfd
kql validation
punkrokk Sep 7, 2023
5457984
kql validation
punkrokk Sep 7, 2023
111713a
fix data connector UI
punkrokk Sep 7, 2023
622377c
add initial workbook
punkrokk Sep 7, 2023
b749921
Merge branch 'master' into solution/GreyNoise-1
punkrokk Sep 7, 2023
4010d38
add initial workbook
punkrokk Sep 7, 2023
e91eec3
update function cron to 1x per day
punkrokk Sep 11, 2023
aeef9e1
repackage with updated cron and workbook json
punkrokk Sep 11, 2023
f2371f2
add sample
punkrokk Sep 11, 2023
db458a5
update descr
punkrokk Sep 13, 2023
c679835
update zip
punkrokk Sep 13, 2023
9c03bf3
update package
punkrokk Sep 13, 2023
536d180
update offerId
punkrokk Sep 13, 2023
7ee03b5
fix clickhere
punkrokk Sep 14, 2023
d1863ca
update funcapp
punkrokk Sep 15, 2023
b341c23
update link
punkrokk Sep 15, 2023
2c33da7
update zp
punkrokk Sep 15, 2023
e4be5fe
update zip
punkrokk Sep 15, 2023
0ebc82a
zip
punkrokk Sep 15, 2023
2bb7adb
update for all indicators
punkrokk Sep 16, 2023
75a2a7c
update for all indicators
punkrokk Sep 16, 2023
953e291
update zip
punkrokk Sep 16, 2023
742f8ff
daily fx sched
punkrokk Sep 16, 2023
3060637
update workbook
punkrokk Sep 16, 2023
97d0a2a
update zip for token
punkrokk Sep 19, 2023
ea05acd
fix zip
punkrokk Sep 19, 2023
d262563
update zip
punkrokk Sep 19, 2023
69b6225
update package and zip
punkrokk Sep 19, 2023
4af16f7
error handling/retries
punkrokk Sep 20, 2023
899786d
rebuild python cache
punkrokk Sep 20, 2023
0d0cd9b
fix limiter
punkrokk Sep 20, 2023
b201074
more rate limiting
punkrokk Sep 20, 2023
93ebdac
more rate limiting
punkrokk Sep 20, 2023
919febb
more rate limiting
punkrokk Sep 20, 2023
4404764
more rate limiting
punkrokk Sep 21, 2023
c80cbba
fix conflict
punkrokk Sep 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"GCPDNSDataConnector",
"GWorkspaceRAPI",
"GoogleWorkspaceReportsAPI",
"GreyNoise2SentinelAPI",
"IdentityInfo",
"ImpervaWAFCloudAPI",
"ImpervaWAFGateway",
Expand Down
42 changes: 42 additions & 0 deletions Logos/greynoise_logomark_black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 72 additions & 0 deletions Sample Data/Custom/GreyNoiseEvent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"ip": "1.1.2.2",
"metadata": {
"asn": "AS25000",
"city": "Ta’if",
"country": "Saudi Arabia",
"country_code": "SA",
"organization": "Saudi Telecom Company JSC",
"category": "isp",
"tor": false,
"rdns": "" ,
"os": "Windows 7/8",
"sensor_count": 78,
"sensor_hits": 433,
"region": "Mecca Region",
"destination_countries": [
"Belarus",
"United States",
"Saudi Arabia",
"Bulgaria",
"United Kingdom",
"Israel",
"Australia",
"Indonesia",
"South Korea"
],
"source_country": "Saudi Arabia",
"source_country_code": "SA",
"destination_country_codes": [
"BY",
"US",
"SA",
"BG",
"GB",
"IL",
"AU",
"ID",
"KR"
]
},
"bot": false,
"vpn": false,
"vpn_service": "N/A",
"spoofable": false,
"raw_data": {
"scan": [
{
"port": 445,
"protocol": "TCP"
},
{
"port": 1433,
"protocol": "TCP"
}
],
"web": {},
"ja3": [],
"hassh": []
},
"first_seen": "2023-08-23",
"last_seen": "2023-08-25",
"seen": true,
"tags": [
"MSSQL Bruteforcer",
"SMBv1 Crawler"
],
"actor": "unknown",
"classification": "malicious",
"cve": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type": "indicator", "spec_version": "2.1", "id": "indicator--849a9eaf-1b0f-556d-ab18-7b6a1d1978f6", "created_by_ref": "identity--90a30b13-e3e2-45e1-be2b-48a8b977ecbc", "created": "2023-09-11T17:54:10.07195Z", "modified": "2023-09-11T17:54:10.07195Z", "name": "GreyNoise Internet Scanner IOC", "description": "GreyNoise Indicator", "indicator_types": ["unknown"], "pattern": "[ipv4-addr:value = '1.1.1.2']", "pattern_type": "stix", "pattern_version": "2.1", "valid_from": "2023-09-11T00:00:00Z", "valid_until": "2023-09-12T17:54:03.846064Z", "confidence": 90}, {"type": "indicator", "spec_version": "2.1", "id": "indicator--20d96100-01cf-5753-8f5b-5ed2aa08f921", "created_by_ref": "identity--90a30b13-e3e2-45e1-be2b-48a8b977ecbc", "created": "2023-09-11T17:54:10.135856Z", "modified": "2023-09-11T17:54:10.135856Z", "name": "GreyNoise Internet Scanner IOC", "description": "GreyNoise Indicator", "indicator_types": ["unknown"], "pattern": "[ipv4-addr:value = '1.1.1.3']", "pattern_type": "stix", "pattern_version": "2.1", "valid_from": "2023-02-24T00:00:00Z", "valid_until": "2023-09-12T17:54:03.846064Z", "confidence": 100}, {"type": "indicator", "spec_version": "2.1", "id": "indicator--3d63ab74-3949-57f7-bf40-0a7c4f149a77", "created_by_ref": "identity--90a30b13-e3e2-45e1-be2b-48a8b977ecbc", "created": "2023-09-11T17:54:10.144328Z", "modified": "2023-09-11T17:54:10.144328Z", "name": "GreyNoise Internet Scanner IOC", "description": "GreyNoise Indicator", "indicator_types": ["unknown"], "pattern": "[ipv4-addr:value = '1.1.1.4']", "pattern_type": "stix", "pattern_version": "2.1", "valid_from": "2023-09-01T00:00:00Z", "valid_until": "2023-09-12T17:54:03.846064Z", "confidence": 100}, {"type": "indicator", "spec_version": "2.1", "id": "indicator--0c70e00d-e0a8-5144-8424-cd0fa3ecd5e3", "created_by_ref": "identity--90a30b13-e3e2-45e1-be2b-48a8b977ecbc", "created": "2023-09-11T17:54:10.150941Z", "modified": "2023-09-11T17:54:10.150941Z", "name": "GreyNoise Internet Scanner IOC", "description": "GreyNoise Indicator", "indicator_types": ["malicious"], "pattern": "[ipv4-addr:value = '1.1.1.5']", "pattern_type": "stix", "pattern_version": "2.1", "valid_from": "2023-09-08T00:00:00Z", "valid_until": "2023-09-12T17:54:03.846064Z", "labels": ["Mirai"], "confidence": 100}, {"type": "indicator", "spec_version": "2.1", "id": "indicator--b8dfd523-5156-5319-9375-53add8183ea4", "created_by_ref": "identity--90a30b13-e3e2-45e1-be2b-48a8b977ecbc", "created": "2023-09-11T17:54:10.157199Z", "modified": "2023-09-11T17:54:10.157199Z", "name": "GreyNoise Internet Scanner IOC", "description": "GreyNoise Indicator", "indicator_types": ["unknown"], "pattern": "[ipv4-addr:value = '1.1.1.1']", "pattern_type": "stix", "pattern_version": "2.1", "valid_from": "2018-12-23T00:00:00Z", "valid_until": "2023-09-12T17:54:03.846064Z", "labels": ["SMBv1 Crawler"], "confidence": 100}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
id: e50657d7-8bca-43ff-a647-d407fae440d6
name: GreyNoise TI Map IP Entity to CommonSecurityLog
description: |
This query maps GreyNoise IP indicators of compromise (IOCs) from threat intelligence (TI), by searching for matches in CommonSecurityLog.
severity: Medium
requiredDataConnectors:
- connectorId: ThreatIntelligence
dataTypes:
- ThreatIntelligenceIndicator
- connectorId: CEF
dataTypes:
- CommonSecurityLog
- connectorId: MicrosoftDefenderThreatIntelligence
dataTypes:
- ThreatIntelligenceIndicator
- connectorId: GreyNoise2SentinelAPI
dataTypes:
- ThreatIntelligenceIndicator
queryFrequency: 4h
queryPeriod: 14d
triggerOperator: gt
triggerThreshold: 0
tactics:
- Impact
query: |
let IPRegex = '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}';
let dt_lookBack = 1h; // Look back 1 hour for CommonSecurityLog events
let ioc_lookBack = 14d; // Look back 14 days for threat intelligence indicators
// Fetch threat intelligence indicators related to IP addresses
let IP_Indicators = ThreatIntelligenceIndicator
| where TimeGenerated >= ago(ioc_lookBack)
| summarize LatestIndicatorTime = arg_max(TimeGenerated, *) by IndicatorId
| where Active == true and ExpirationDateTime > now()
| where SourceSystem == 'GreyNoise'
| where isnotempty(NetworkIP) or isnotempty(EmailSourceIpAddress) or isnotempty(NetworkDestinationIP) or isnotempty(NetworkSourceIP)
| extend TI_ipEntity = iff(isnotempty(NetworkIP), NetworkIP, NetworkDestinationIP)
| extend TI_ipEntity = iff(isempty(TI_ipEntity) and isnotempty(NetworkSourceIP), NetworkSourceIP, TI_ipEntity)
| extend TI_ipEntity = iff(isempty(TI_ipEntity) and isnotempty(EmailSourceIpAddress), EmailSourceIpAddress, TI_ipEntity)
| where ipv4_is_private(TI_ipEntity) == false and TI_ipEntity !startswith "fe80" and TI_ipEntity !startswith "::" and TI_ipEntity !startswith "127.";
// Perform a join between IP indicators and CommonSecurityLog events
IP_Indicators
// Use innerunique to keep performance fast and result set low, as we only need one match to indicate potential malicious activity that needs investigation
| join kind=innerunique (
CommonSecurityLog
| where TimeGenerated >= ago(dt_lookBack)
| extend MessageIP = extract(IPRegex, 0, Message)
| extend CS_ipEntity = iff(isnotempty(SourceIP), SourceIP, DestinationIP)
| extend CS_ipEntity = iff(isempty(CS_ipEntity) and isnotempty(MessageIP), MessageIP, CS_ipEntity)
| extend CommonSecurityLog_TimeGenerated = TimeGenerated
)
on $left.TI_ipEntity == $right.CS_ipEntity
// Filter out logs that occurred after the expiration of the corresponding indicator
| where CommonSecurityLog_TimeGenerated < ExpirationDateTime
// Group the results by IndicatorId and CS_ipEntity, and keep the log entry with the latest timestamp
| summarize CommonSecurityLog_TimeGenerated = arg_max(CommonSecurityLog_TimeGenerated, *) by IndicatorId, CS_ipEntity
// Select the desired output fields
| project timestamp = CommonSecurityLog_TimeGenerated, SourceIP, DestinationIP, MessageIP, Message, DeviceVendor, DeviceProduct, IndicatorId, ThreatType, ExpirationDateTime, ConfidenceScore, TI_ipEntity, CS_ipEntity, LogSeverity, DeviceAction, Type
entityMappings:
- entityType: IP
fieldMappings:
- identifier: Address
columnName: CS_ipEntity
version: 1.0.0
kind: Scheduled
135 changes: 135 additions & 0 deletions Solutions/GreyNoiseThreatIntelligence/Data Connectors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Azure Functions artifacts
bin
obj
appsettings.json
local.settings.json

# Azurite artifacts
__blobstorage__
__queuestorage__
__azurite_db*__.json
.python_packages
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"scriptFile": "main.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 0 0 */0 * *"
}
]
}
Loading
Loading