Adlice Software.

API

Die meisten APIs sind nicht dokumentiert (auch wenn Sie ihre Funktionsweise aus dem Code nachvollziehen können …), weil sie aus Sicht eines Kunden nicht relevant sind und nur zur Kommunikation zwischen dem Frontend und dem Backend verwendet werden.

Hier sind diejenigen, die wir dokumentieren wollten, die wirklich nützlich sind, wenn Sie vorhaben, Ihren eigenen Client zu erstellen, der mit einem MRF-Server arbeitet. Um eine API aufzurufen, verwenden Sie diese Vorlagen-URL: http://yourmrfserver.xyz/api.php?action=theapi&token=yourapikey&param1=value&param2=value&param

downloadfile

GET
http://localhost/api.php?token=my_token&action=downloadfile&file=the_md5
description:
Download a file by MD5
return data: 
Binary file

bulkdownload

GET
http://localhost/api.php?token=my_token&action=bulkdownload&files[]=the_md5&files[]=the_other_md5
return data: 
Binary data (Zip archive)

getfile

GET
http://localhost/api.php?token=my_token&action=getfile&hash=the_md5
return data: Json object with metadata of the file

uploadfiles

POST
http://localhost/api.php?token=my_token&action=uploadfilesT
parameters:
$FILES[]=(files upload)
vtsubmit[]=[true, false, ...]
cksubmit[]=[false, true, ...]
tags[]=["spam,malware", "another", ...]
comment=the_comment
return data: HTTP code 200 if success

addcomment

POST
http://localhost/api.php?token=my_token&action=addcomment
parameters:
hash=the_md5
comment={"content": "the content", "parent": parent_comment_id}
return data: HTTP code 201 if success

Upload-Skript-Beispiel

#!/usr/bin/python
import hashlib
import json
import ost
import logging
import requests
 
# Parameters, don't forget to modify
apikey      = "your_token"
host        = "mrf.yourserver.com"
urlserver   = "http://mrf.yourserver.com/api.php?action=uploadfiles"
 
def post_multipart(host, selector, fields, files):
    headers = {'user-agent': 'Dionaea honeypot'}
    r = requests.post(selector, headers=headers, data=fields, files=files)
 
def file_md5(fname):
    hash_md5 = hashlib.md5()
    with open(fname, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hash_md5.update(chunk)
    return hash_md5.hexdigest()
   
def UploadFile(pl):                 
    md5 = file_md5(pl)
    filename = os.path.basename(pl)
 
    parameters = {"hash": md5, "comment": "", "token": apikey, "tags":["honeypot"], "vtsubmit":[True], "cksubmit":[False]}
 
    # Send file to server API
    with open(pl, 'rb') as f:
        files = {filename: f}
        post_multipart(host, urlserver, parameters, files)