Created
March 6, 2020 00:46
-
-
Save Shadow0ps/7f8a1ce13b4a124d7c51eb516fd3f17c to your computer and use it in GitHub Desktop.
PHOTODNA API PYTHON SCRIPT FOR AUTOMATED NOTIFICATION TO NCMEC WITH ALL REQUIRED METADATA. REQUIRES DATA GUARDIAN OR OTHER 3RD PARTY INTEGRATION FEED LEARN MORE SECURITY@CONDITION.BLACK
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
##### ####### # # ###### ### ####### ### ####### # # # ###### # # ##### # # | |
# # # # ## # # # # # # # # ## # ### # # # # # # # # # | |
# # # # # # # # # # # # # # # # # # # # # # # # # | |
# # # # # # # # # # # # # # # # ###### # # # # ### | |
# # # # # # # # # # # # # # # # # # # # ####### # # # | |
# # # # # ## # # # # # # # # ## ### # # # # # # # # # | |
##### ####### # # ###### ### # ### ####### # # # ###### ####### # # ##### # # | |
# # ##### # # ####### ##### ###### ####### ###### ####### ###### ####### ####### ###### | |
## # # # ## ## # # # # # # # # # # # # # # # # | |
# # # # # # # # # # # # # # # # # # # # # # # | |
# # # # # # # ##### # ###### ##### ###### # # ###### # ##### ###### | |
# # # # # # # # # # # # # # # # # # # # | |
# ## # # # # # # # # # # # # # # # # # # # | |
# # ##### # # ####### ##### # # ####### # ####### # # # ####### # # | |
###### # # ### # ####### ####### ####### ###### ###### # # ####### ####### ####### ###### # # # # # ##### ####### ###### ##### | |
# # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # # | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
###### # # # # # ##### # # ###### ###### ####### # # # # # # # # # # # # # # ##### ##### ###### ##### | |
# # # # # # # # # # # # # # # # # # # # # # # # # ####### # # # # # # # | |
# # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # | |
###### ##### ### ####### # # ####### # # # # # ####### # ####### ###### # # # # ##### ##### ####### # # ##### | |
# Install the Python Requests library: | |
# `pip install requests` | |
import requests | |
import json | |
def send_request(): | |
# Report Violation | |
# POST https://api.microsoftmoderator.com/photodna/v1.0/Report | |
try: | |
response = requests.post( | |
url="https://api.microsoftmoderator.com/photodna/v1.0/Report", | |
headers={ | |
"Content-Type": "", | |
"Ocp-Apim-Subscription-Key": "", | |
"subscription-key": "", | |
}, | |
data=json.dumps({ | |
"AdditionalMetadata": [ | |
{ | |
"Key": "IsTest", | |
"Value": "<Optional KeyValue pair to route the request to NCMEC's Test Endpoint. Set the value to true to point to NCMEC's Test Endpoint.>" | |
} | |
], | |
"OrgName": "CONDITION:BLACK", | |
"ReporterName": "NCMEC DATA GUARDIAN SOFTWARE", | |
"ReporterEmail": "NCMECREPORTING@CONDITION.BLACK", | |
"ReporteeName": "USERNAME", | |
"IncidentTime": "03/05/2020 9:08:14 PM", | |
"ViolationContentCollection": [ | |
{ | |
"UploadDateTime": "<Timestamp for upload - when UploadIpAddress & UploadDateTime is provided, this information would be sent to NCMEC as filedetails for this file.>", | |
"Name": "FILENAME", | |
"Value": "Base 64 image string", | |
"Location": { | |
"Latitude": "0", | |
"Altitude": "0", | |
"Longitude": "0" | |
}, | |
"UploadIpAddress": "<IP Address of the Image Upload Source - when UploadIpAddress & UploadDateTime is provided, this information would be sent to NCMEC as filedetails for this file.>", | |
"AdditionalMetadata": [ | |
{ | |
"Key": "viewedByEsp", | |
"Value": "true" | |
}, | |
{ | |
"Key": "publiclyAvailable", | |
"Value": "true" | |
}, | |
{ | |
"Key": "additionalInfo", | |
"Value": "<some additional text content>" | |
} | |
] | |
} | |
], | |
"ReporteeIPAddress": "SERVER IP" | |
}) | |
) | |
print('Response HTTP Status Code: {status_code}'.format( | |
status_code=response.status_code)) | |
print('Response HTTP Response Body: {content}'.format( | |
content=response.content)) | |
except requests.exceptions.RequestException: | |
print('HTTP Request failed') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment