The accessibility permissions are stored in a sqlite database file at /Library/Application Support/com.apple.TCC/TCC.db.
Since sqlite3 is shipped with the later Mac OS X' by default, use it to modify the settings.
The db scheme looks like this:
sqlite> .schema
CREATE TABLE access (service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, allowed INTEGER NOT NULL, prompt_count INTEGER NOT NULL, csreq BLOB, CONSTRAINT key PRIMARY KEY (service, client, client_type));
CREATE TABLE access_overrides (service TEXT PRIMARY KEY NOT NULL);
CREATE TABLE access_times (service TEXT NOT NULL, client TEXT NOT NULL, client_type INTEGER NOT NULL, last_used_time INTEGER NOT NULL, CONSTRAINT key PRIMARY KEY (service, client, client_type));
CREATE TABLE admin (key TEXT PRIMARY KEY NOT NULL, value INTEGER NOT NULL);
The relevant table name is "access" and the relevant field name is "allowed". If allowed contains a "1" the app is granted permission to control the computer, if it contains a "0" the permission is not granted.
With the command:
sudo sqlite3 /Library/Application Support/com.apple.TCC/TCC.db '<---some SQL statement--->'
you can toggle permission on and off for all apps listed.