-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from CybercentreCanada/assemblyline/issues/181
Move url_analysis from NetRep → URLCreator
- Loading branch information
Showing
8 changed files
with
357 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true, | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.rulers": [ | ||
120 | ||
], | ||
"editor.tabSize": 4, | ||
"editor.wordWrap": "wordWrapColumn", | ||
"editor.wordWrapColumn": 120, | ||
"files.insertFinalNewline": true, | ||
"files.trimFinalNewlines": true, | ||
"files.trimTrailingWhitespace": true, | ||
"isort.args": [ | ||
"-l", | ||
"120", | ||
"--profile=black", | ||
// "--src=${workspaceFolder}" | ||
], | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
}, | ||
"black-formatter.args": [ | ||
"--line-length=120" | ||
], | ||
"flake8.args": [ | ||
"--max-line-length=120", | ||
//Added the ignore of E203 for now : https://github.com/PyCQA/pycodestyle/issues/373 | ||
"--ignore=E203,W503" | ||
], | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
}, | ||
"editor.formatOnSave": true, | ||
"editor.rulers": [120], | ||
"editor.tabSize": 4, | ||
"editor.wordWrap": "wordWrapColumn", | ||
"editor.wordWrapColumn": 120, | ||
"files.insertFinalNewline": true, | ||
"files.trimFinalNewlines": true, | ||
"files.trimTrailingWhitespace": true, | ||
"isort.args": [ | ||
"-l", | ||
"120", | ||
"--profile=black" | ||
// "--src=${workspaceFolder}" | ||
], | ||
"[python]": { | ||
"editor.defaultFormatter": "ms-python.black-formatter" | ||
}, | ||
"black-formatter.args": ["--line-length=120"], | ||
"flake8.args": [ | ||
"--max-line-length=120", | ||
//Added the ignore of E203 for now : https://github.com/PyCQA/pycodestyle/issues/373 | ||
"--ignore=E203,W503" | ||
], | ||
"python.testing.pytestArgs": [ | ||
"tests" | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
multidecoder==1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from utils.network import url_analysis | ||
|
||
|
||
def test_unicode_characters(): | ||
# Shouldn't crash due to non-ASCII characters being in the URL | ||
url = "https://hello:world@écoute.com/" | ||
res_section, network_iocs = url_analysis(url) | ||
assert network_iocs == {"uri": ["https://écoute.com/"], "domain": ["écoute.com"], "ip": []} | ||
assert '"OBFUSCATION": "Embedded credentials"' in res_section.body | ||
|
||
|
||
def test_embedded_base64(): | ||
url = "https://somedomain.com/some/path?u=a1aHR0cHM6Ly9iYWQuY29t#dGVzdEBleGFtcGxlLmNvbQ==" | ||
res_section, network_iocs = url_analysis(url) | ||
assert network_iocs == {"uri": ["https://bad.com"], "domain": ["bad.com"], "ip": []} | ||
assert res_section.tags == { | ||
# Encoded URL in query | ||
"network.static.uri": ["https://bad.com"], | ||
# Domain from encoded URL | ||
"network.static.domain": ["bad.com"], | ||
# Encoded email in fragment | ||
"network.email.address": ["[email protected]"], | ||
} | ||
|
||
# Handle garbage base64 strings, this shouldn't generate any results | ||
url = "https://somedomain.com/some/path?u=2F4wOWl6vSIfij9tBVr7MyOThiV1" | ||
res_section, network_iocs = url_analysis(url) | ||
assert network_iocs == {"uri": [], "domain": [], "ip": []} | ||
assert not res_section.body | ||
|
||
|
||
def test_safelinks(): | ||
# Ref: https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/safe-links-about?view=o365-worldwide | ||
url = "https://safelinks.com/?url=https%3A%2F%2Fhelloworld%2Ecom%2Fbad%7C01%7Ctest%40example%2Ecom" | ||
res_section, network_iocs = url_analysis(url) | ||
assert network_iocs == { | ||
# URL to be redirected to | ||
"uri": ["https://helloworld.com/bad"], | ||
"domain": ["helloworld.com"], | ||
"ip": [], | ||
} | ||
assert res_section.tags == { | ||
# URL to be redirected to | ||
"network.static.uri": ["https://helloworld.com/bad"], | ||
"network.static.domain": ["helloworld.com"], | ||
# Recipient email address | ||
"network.email.address": ["[email protected]"], | ||
} | ||
|
||
|
||
def test_hexed_ip(): | ||
# Ref: https://www.darkreading.com/cloud/shellbot-cracks-linux-ssh-servers-debuts-new-evasion-tactic | ||
url = "http://0x7f000001" | ||
res_section, network_iocs = url_analysis(url) | ||
assert network_iocs["ip"] == ["127.0.0.1"] | ||
assert res_section.tags == {"network.static.ip": ["127.0.0.1"]} | ||
|
||
|
||
def test_phishing(): | ||
# Ref: https://www.vmray.com/cyber-security-blog/detection-signature-updates-2/#elementor-toc__heading-anchor-9 | ||
url = "https://[email protected]@[email protected]@bad.com/malicious.zip?evil=true" | ||
res_section, network_iocs = url_analysis(url) | ||
# Should reveal the true target URL for reputation checking | ||
assert network_iocs["uri"] == ["https://bad.com/malicious.zip?evil=true"] | ||
assert network_iocs["domain"] == ["bad.com"] | ||
assert '"OBFUSCATION": "URL masquerade"' in res_section.body | ||
|
||
url = "https://[email protected]/" | ||
res_section, network_iocs = url_analysis(url) | ||
assert network_iocs["uri"] == ["https://bad.com/"] | ||
assert network_iocs["domain"] == ["bad.com"] | ||
assert '"OBFUSCATION": "Embedded credentials"' in res_section.body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.