Skip to content

Instantly share code, notes, and snippets.

@weshouman
Last active September 7, 2022 20:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weshouman/e149141bdc4e01e662599151ed67e27e to your computer and use it in GitHub Desktop.
Save weshouman/e149141bdc4e01e662599151ed67e27e to your computer and use it in GitHub Desktop.
Automating Synology Disk Station

Following are the steps I followed to have further understanding

  1. Know the architecture from this link. Whether the API totally encapsulates the CGI or there are some differences, that is not the topic of this guide, so it's better to be always aware of the Disk Station Architecture your script would support, so that when we have to read the sources we'll know which source to check

  2. Try a working ansible role. That will give a pretty good overview of how the interaction is implemented.

  3. Check the official docs for the

NOTE: these docs don't cover all the API, they're only a subset.
Here is a list of all the APIs I know of

  • Covered APIs in docs
    • Survellience Station: including SYNO.SurveillanceStation.*
    • File Station: including SYNO.FileStation.*
    • Auth: including SYNO.API.Auth
    • Synology Calendar: including SYNO.Cal.* [Not found in the following syno package]
    • Virtual Machine Manager: including SYNO.Virtualization.API.* [Not found in the following syno package]
  • Uncovered APIs in docs
    • Download Station: including SYNO.DownloadStation.*
    • Disk Station Manager: including SYNO.Core.* & SYNO.DSM.*
    • Audio Station: including SYNO.VideoStation.*
    • Video Station: including SYNO.VideoStation.*
    • Video Station DTV: including SYNO.DTV.* The covered docs have a listing of the methods and their attributes available for each API. For the uncovered APIs we have no way to figure out the available methods unless ... we reach the source code ... but how can we find it, and are there any software that was able to extract such API, the answer is yes for methods but not directly for attributes :/
  1. Try syno package locally; install the dependencies and add the config file as described in the README.md. Following this package we can finally reach the point where we can search for all the methods available for an API by checking the scripts directory in which the downloading and extraction of the methods occur. Notice that here one will need to know both the architecture and the desired packages.

  2. Check the sources found in the link captured from the syno package Try to download the spks of interest, and extracting them.
    Then prettyprint the json found in the packages/*.lib files which will the methods.
    As for the attributes, we have got one of 2 options (and half).

Getting the attributes for each API method

  1. Check the source code, that should be the first resort upon figuring out that the documentation is totally messed up. However, due to the fact that Synology doesn't upload the many of sources too, this solution won't work :/

  2. Reverse engineer the webapi by creating requests to the synology and checking the network, then capturing the sent params and trying to mimic it. The bad thing is that, if there are 2 consecutive requests, or some ciphered param, there's no way to tell what was missing or how to cipher a similar one :|

  3. If one has time, he could reverse engineer the .so files to get the behavior, so that pseudo-source codes are available :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment