1. Home
  2. Docs
  3. MRF
  4. Getting Started
  5. API

API

Most of the APIs are undocumented (even though you can understand how they work from the code…) because they are not relevant from a client’s standpoint, and are only used to communicate between the front and the back end.

Here’s the ones we decided to document, that are really useful if you plan to make your own client working with a MRF server. To call an API, use this template 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 script example

#!/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)

How can we help?