Skip to content

Instantly share code, notes, and snippets.

@Shadow0ps
Created March 6, 2020 00:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shadow0ps/7f8a1ce13b4a124d7c51eb516fd3f17c to your computer and use it in GitHub Desktop.
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
##### ####### # # ###### ### ####### ### ####### # # # ###### # # ##### # #
# # # # ## # # # # # # # # ## # ### # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # ###### # # # # ###
# # # # # # # # # # # # # # # # # # # # ####### # # #
# # # # # ## # # # # # # # # ## ### # # # # # # # # #
##### ####### # # ###### ### # ### ####### # # # ###### ####### # # ##### # #
# # ##### # # ####### ##### ###### ####### ###### ####### ###### ####### ####### ######
## # # # ## ## # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # #
# # # # # # # ##### # ###### ##### ###### # # ###### # ##### ######
# # # # # # # # # # # # # # # # # # # #
# ## # # # # # # # # # # # # # # # # # # #
# # ##### # # ####### ##### # # ####### # ####### # # # ####### # #
###### # # ### # ####### ####### ####### ###### ###### # # ####### ####### ####### ###### # # # # # ##### ####### ###### #####
# # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
###### # # # # # ##### # # ###### ###### ####### # # # # # # # # # # # # # # ##### ##### ###### #####
# # # # # # # # # # # # # # # # # # # # # # # # # ####### # # # # # # #
# # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # # #
###### ##### ### ####### # # ####### # # # # # ####### # ####### ###### # # # # ##### ##### ####### # # #####
# 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