mirror of
https://github.com/PC-Admin/matrix-moderation-tool.git
synced 2024-12-19 07:00:27 -05:00
Compare commits
13 Commits
a38e042b33
...
1be96637ee
Author | SHA1 | Date | |
---|---|---|---|
|
1be96637ee | ||
|
827ea1d2e9 | ||
|
7b1f79cf7f | ||
|
72cae1f88b | ||
|
612f67dd70 | ||
|
c8e96bf82d | ||
|
f3ed15068e | ||
|
771d1b78e4 | ||
|
811c6d2b35 | ||
|
401206c8c5 | ||
|
e8c9f7f9a1 | ||
|
7afa95e888 | ||
|
34c3dc503a |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
hardcoded_variables.py
|
||||
__pycache__
|
234
README.md
234
README.md
@ -15,17 +15,26 @@ This work is published under the MIT license, for more information on this licen
|
||||
***
|
||||
## Setup script
|
||||
|
||||
You can hard code the server URL, federation port and access token into the [hardcoded_variables.py](./hardcoded_variables.py) file for faster use, it will prompt you for these values if you don't.
|
||||
Firstly, you need hard code the 'server URL', 'federation port' and 'access token' into the [hardcoded_variables.py](./hardcoded_variables.py) file
|
||||
```
|
||||
$ cp ./hardcoded_variables.py.sample ./hardcoded_variables.py
|
||||
$ nano ./hardcoded_variables.py
|
||||
```
|
||||
|
||||
Your access token can be found in Element > Settings > Help & About, your user account must first be upgraded to a server admin.
|
||||
|
||||
This script also requires you to install the following PIP packages:
|
||||
```
|
||||
pip3 install python-whois
|
||||
pip3 install requests
|
||||
$ pip3 install python-whois && \
|
||||
pip3 install requests && \
|
||||
pip3 install matrix-nio
|
||||
```
|
||||
|
||||
***
|
||||
## Running the script
|
||||
|
||||
`$ python3 moderation_tool.py`
|
||||
|
||||
|
||||
***
|
||||
## Upgrade user to 'server admin'
|
||||
@ -77,38 +86,6 @@ With the popular [matrix-docker-ansible-deploy](https://github.com/spantaleev/ma
|
||||
`matrix_synapse_admin_enabled: true`
|
||||
|
||||
|
||||
***
|
||||
## Roadmap
|
||||
|
||||
To do:
|
||||
1) Add the following functions:
|
||||
- https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#find-a-user-based-on-their-id-in-an-auth-provider
|
||||
- https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#find-a-user-based-on-their-third-party-id-threepid-or-3pid
|
||||
- https://github.com/matrix-org/synapse/blob/master/docs/admin_api/delete_group.md
|
||||
2) Add fully automated (should just return a web link and decryption password) reporting functions for users:
|
||||
- Description of why the report was made (what happened), include key information
|
||||
- User's ID - DONE
|
||||
- Whois Data - DONE
|
||||
- Account Data - DONE
|
||||
- Query Data - DONE
|
||||
- Pushers List - DONE
|
||||
- IPs + ipinfo Data - DONE
|
||||
- List of the rooms the user is participating in, divided into 1:1 conversations and larger rooms - DONE
|
||||
- Any other usernames associated with that IP
|
||||
- Timestamp for when illegal material was accessed
|
||||
- Description of report format and contents (to guide the reader)
|
||||
- Collect state event dumps of recently read rooms as well (as they may have looked at other suss rooms recently)
|
||||
3) Have recommended rdlist function:
|
||||
- return a list of offending accounts and the tags they accessed (for creating incident_dict's)
|
||||
- add the shadowban function to prevent members alerting others after mass shutdowns - DONE
|
||||
4) Only email reportID in incident report?
|
||||
5) Add a room report function to create a properly formatted report for rdlist
|
||||
6) Expand the incident reporting to also issue reports over Matrix
|
||||
7) Automated public room joining and reminder if reporting email is not available?
|
||||
8) Refine ipinfo module to also return extra details about the IP
|
||||
9) Make existing functions compatible with JSON formatted inputs
|
||||
|
||||
|
||||
***
|
||||
## rdlist Functionality
|
||||
|
||||
@ -118,171 +95,13 @@ This script can automatically load and block/purge abusive rooms from rdlist, ma
|
||||
|
||||
If you are running a public server, please dm me at [@michael:perthchat.org](https://matrix.to/#/@michael:perthchat.org) and I can invite you to the 'Legion of Janitors' room.
|
||||
|
||||
Once you have read access to the [rdlist repository](https://code.glowers.club/loj/rdlist), this script can be used for multiple rdlist related functions.
|
||||
|
||||
|
||||
***
|
||||
## Collect User Reports on local users in rdlist rooms
|
||||
|
||||
This script can automatically generate 'User Reports' for each one of your local users in rdlist rooms that have the 'recommended tags'.
|
||||
|
||||
These user reports can be given to law enforcement or shared in [#janitor-dumps](https://matrix.to/#/#janitor-dumps:glowers.club) to help us locate more abusive users/rooms.
|
||||
|
||||
```
|
||||
130
|
||||
|
||||
rdlist repo already cloned...
|
||||
Fetching origin
|
||||
Pulling latest changes from rdlist repo...
|
||||
|
||||
WARNING! The following local users are current members of rooms tagged in rdlist: ['@fatweeb23838:perthchat.org', '@somecreep29330:perthchat.org']
|
||||
|
||||
Do you want to generate a user report file for each of these users? y/n? y
|
||||
|
||||
Generating user report for fatweeb23838...
|
||||
Report generated successfully on user: "fatweeb23838"
|
||||
|
||||
You can send this .zip file when reporting a user to law enforcement.
|
||||
.zip file location: /home/pcadmin/projects/matrix-moderation-tool/reports/fatweeb23838_2023-08-01_23-19-24.zip
|
||||
.zip file size: 0.00966 MB
|
||||
|
||||
|
||||
Generating user report for somecreep29330...
|
||||
Report generated successfully on user: "somecreep29330"
|
||||
|
||||
You can send this .zip file when reporting a user to law enforcement.
|
||||
.zip file location: /home/pcadmin/projects/matrix-moderation-tool/reports/somecreep29330_2023-08-01_23-19-27.zip
|
||||
.zip file size: 0.29578 MB
|
||||
```
|
||||
|
||||
|
||||
***
|
||||
## Send Incident Reports for remote users in rdlist rooms
|
||||
|
||||
This script can automatically generate 'Incident Reports' for every remote homeserver admin with users in rdlist rooms that have the 'recommended tags'.
|
||||
|
||||
It examines the homeserver involved to find a admin contact method via [MSC1929](https://github.com/matrix-org/matrix-spec-proposals/pull/1929). If an MXID is returned it will attempt to send the Incident Report over Matrix. If an email is provided it will send the Incident Report over email. If neither is found a whois lookup is performed and the Incident Report are sent to the domain registrar via email.
|
||||
|
||||
```
|
||||
131
|
||||
|
||||
rdlist repo already cloned...
|
||||
Fetching origin
|
||||
Pulling latest changes from rdlist repo...
|
||||
|
||||
WARNING! The following remote users are current members of rooms tagged in rdlist: ['@pedobear:matrix.org', '@randomcreep:perthchat.org']
|
||||
|
||||
Do you want to send out incident reports for these users to every homeserver admin involved? y/n? y
|
||||
|
||||
Sending Incident Report for users from matrix.org to abuse@matrix.org
|
||||
|
||||
Sending Incident Report for users from perthchat.org to @michael:perthchat.org
|
||||
|
||||
```
|
||||
|
||||
![A preview of an Incident Report being sent over Matrix.](https://github.com/PC-Admin/matrix-moderation-tool/assets/29645145/db5a4a56-fd66-413a-ac44-1216c7b2f1fd)
|
||||
|
||||
|
||||
## rdlist Block/Purge all rooms with recommended rdlist tags
|
||||
|
||||
Finally this script can be used to shutdown rooms with the recommended rdlist tags.
|
||||
|
||||
This function is much larger and will ask you if you also want to create user/incident reports before the shutdowns. (Recommended) It'll also ask you if you want to shadowban the users in these rooms to prevent them from alerting others. (Recommended) Finally it'll ask if you want to shutdown the local accounts located in these rooms.
|
||||
|
||||
```
|
||||
$ python3 moderation_tool.py
|
||||
|
||||
Please select one of the following options:
|
||||
...
|
||||
Please enter a number from the above menu, or enter 'q' or 'e' to exit.
|
||||
|
||||
132
|
||||
|
||||
@mod_team:perthchat.org account already exists. Resetting account password.
|
||||
|
||||
Ensuring @mod_team:perthchat.org account is a server admin.
|
||||
|
||||
rdlist repo already cloned...
|
||||
Fetching origin
|
||||
rdlist repo is up-to-date, no need to pull changes.
|
||||
|
||||
Using recommended rdlist tags. Rooms matching the following tags will be purged and/or blocked:
|
||||
['hub_room_links', 'hub_room_trade', 'preban', 'degen_misc', 'beastiality', 'degen_porn', 'gore', 'snuff', 'degen_larp', 'hub_room_sussy', 'bot_spam', 'cfm', 'jailbait', 'bot_porn', 'toddlercon', 'loli', 'csam', 'tfm', 'degen_meet', 'stylized_3d_loli', '3d_loli']
|
||||
|
||||
WARNING! The following local users are current members of rooms tagged in rdlist: ['@***REDACTED***:perthchat.org']
|
||||
|
||||
Do you want to generate a user report file for each of these users? y/n? n
|
||||
|
||||
Skipping user report generation...
|
||||
|
||||
WARNING! The following remote users are current members of rooms tagged in rdlist: ['@***REDACTED***:matrix.org']
|
||||
|
||||
Do you want to send out incident reports for these users to every homeserver admin involved? y/n? n
|
||||
|
||||
Skipping incident report generation...
|
||||
|
||||
|
||||
Number of rdlist rooms being shutdown: 346
|
||||
|
||||
Are you sure you want to block/shutdown these rooms? y/n? y
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Blocking unknown room: !***REDACTED***:matrix.org
|
||||
Successfully blocked room !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Blocking unknown room: !***REDACTED***:matrix.org
|
||||
Successfully blocked room !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Shutting down known room: !***REDACTED***:sibnsk.net
|
||||
Sleeping for 2 seconds...
|
||||
Sleeping for 4 seconds...
|
||||
Sleeping for 8 seconds...
|
||||
!***REDACTED***:sibnsk.net has been successfully shutdown!
|
||||
List of kicked users:
|
||||
@***REDACTED***:perthchat.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:anontier.nl
|
||||
|
||||
|
||||
Room shutdowns completed!
|
||||
|
||||
User login details for your moderator account:
|
||||
|
||||
Username: mod_team
|
||||
Password: ***REDACTED***
|
||||
|
||||
Print rdlist statistics:
|
||||
|
||||
Number of rooms blocked: 4
|
||||
Number of rooms purged: 2
|
||||
Number of local users located in rdlist rooms and kicked: 1
|
||||
|
||||
The following users were current members of rooms tagged in rdlist: ['@***REDACTED***:perthchat.org']
|
||||
|
||||
Do you want to also deactivate all these accounts that were kicked from rdlist rooms? y/n?
|
||||
...
|
||||
```
|
||||
For more information on rdlist related function consult the [support document](./docs/rdlist_functions.md).
|
||||
|
||||
|
||||
***
|
||||
## One-touch Reporting
|
||||
|
||||
WARNING: This section is under heavy development and shouldn't be used by anyone!!!
|
||||
CAUTION: This section is under heavy development and probably shouldn't be used by anyone!
|
||||
|
||||
This script can automatically generate reports about user accounts for law enforcement.
|
||||
|
||||
@ -304,3 +123,28 @@ You can send this .zip file and password when reporting a user to law enforcemen
|
||||
.zip file location: ./reports/pedobear_2023-07-23_02-21-56.zip
|
||||
.zip file size: 0.503927 MB
|
||||
```
|
||||
|
||||
|
||||
***
|
||||
## Roadmap
|
||||
|
||||
To do:
|
||||
1) Add the following functions:
|
||||
- https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#find-a-user-based-on-their-id-in-an-auth-provider
|
||||
- https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html#find-a-user-based-on-their-third-party-id-threepid-or-3pid
|
||||
- https://github.com/matrix-org/synapse/blob/master/docs/admin_api/delete_group.md
|
||||
2) Add fully automated (should just return a web link and decryption password) reporting functions for users:
|
||||
- Description of why the report was made (what happened), include key information
|
||||
- Any other usernames associated with that IP
|
||||
- Timestamp for when illegal material was accessed
|
||||
- Description of report format and contents (to guide the reader)
|
||||
- Collect state event dumps of recently read rooms as well (as they may have looked at other suss rooms recently)
|
||||
3) Have recommended rdlist function:
|
||||
- return a list of offending accounts and the tags they accessed (for creating incident_dict's) - DONE
|
||||
- add the shadowban function to prevent members alerting others after mass shutdowns - DONE
|
||||
4) Only email reportID in incident report?
|
||||
5) Add a room report function to create a properly formatted report for rdlist
|
||||
6) Expand the incident reporting to also issue reports over Matrix
|
||||
7) Automated public room joining and reminder if reporting email is not available?
|
||||
8) Refine ipinfo module to also return extra details about the IP
|
||||
9) Make existing functions compatible with JSON formatted inputs
|
||||
|
182
docs/rdlist_functions.md
Normal file
182
docs/rdlist_functions.md
Normal file
@ -0,0 +1,182 @@
|
||||
|
||||
# rdlist Functions
|
||||
|
||||
'rdlist' is a comprehensive list of child abuse related rooms on Matrix, it's a safety initiative led by the [Legion of Janitors](https://matrix.to/#/#janitors:glowers.club).
|
||||
|
||||
This script can automatically load and block/purge abusive rooms from rdlist, making it **very easy** for inexperienced administrators to block this harmful content.
|
||||
|
||||
If you are running a public server, please dm me at [@michael:perthchat.org](https://matrix.to/#/@michael:perthchat.org) and I can invite you to the 'Legion of Janitors' room.
|
||||
|
||||
***
|
||||
## Collect User Reports on local users in rdlist rooms
|
||||
|
||||
This script can automatically generate 'User Reports' for each one of your local users in rdlist rooms that have the 'recommended tags'.
|
||||
|
||||
These user reports can be given to law enforcement or shared in [#janitor-dumps](https://matrix.to/#/#janitor-dumps:glowers.club) to help us locate more abusive users/rooms.
|
||||
|
||||
```
|
||||
130
|
||||
|
||||
rdlist repo already cloned...
|
||||
Fetching origin
|
||||
Pulling latest changes from rdlist repo...
|
||||
|
||||
WARNING! The following local users are current members of rooms tagged in rdlist: ['@fatweeb23838:perthchat.org', '@somecreep29330:perthchat.org']
|
||||
|
||||
Do you want to generate a user report file for each of these users? y/n? y
|
||||
|
||||
Generating user report for fatweeb23838...
|
||||
Report generated successfully on user: "fatweeb23838"
|
||||
|
||||
You can send this .zip file when reporting a user to law enforcement.
|
||||
.zip file location: /home/pcadmin/projects/matrix-moderation-tool/reports/fatweeb23838_2023-08-01_23-19-24.zip
|
||||
.zip file size: 0.00966 MB
|
||||
|
||||
|
||||
Generating user report for somecreep29330...
|
||||
Report generated successfully on user: "somecreep29330"
|
||||
|
||||
You can send this .zip file when reporting a user to law enforcement.
|
||||
.zip file location: /home/pcadmin/projects/matrix-moderation-tool/reports/somecreep29330_2023-08-01_23-19-27.zip
|
||||
.zip file size: 0.29578 MB
|
||||
```
|
||||
|
||||
'rdlist' is a comprehensive list of child abuse related rooms on Matrix, it's a safety initiative led by the [Legion of Janitors](https://matrix.to/#/#janitors:glowers.club).
|
||||
|
||||
This script can automatically load and block/purge abusive rooms from rdlist, making it **very easy** for inexperienced administrators to block this harmful content.
|
||||
|
||||
If you are running a public server, please dm me at [@michael:perthchat.org](https://matrix.to/#/@michael:perthchat.org) and I can invite you to the 'Legion of Janitors' room.
|
||||
|
||||
Once you have read access to the [rdlist repository](https://code.glowers.club/loj/rdlist), this script can be used for multiple rdlist related functions.
|
||||
|
||||
***
|
||||
## Send Incident Reports for remote users in rdlist rooms
|
||||
|
||||
This script can automatically generate 'Incident Reports' for every remote homeserver admin with users in rdlist rooms that have the 'recommended tags'.
|
||||
|
||||
It examines the homeserver involved to find a admin contact method via [MSC1929](https://github.com/matrix-org/matrix-spec-proposals/pull/1929). If an MXID is returned it will attempt to send the Incident Report over Matrix. If an email is provided it will send the Incident Report over email. If neither is found a whois lookup is performed and the Incident Report are sent to the domain registrar via email.
|
||||
|
||||
```
|
||||
131
|
||||
|
||||
rdlist repo already cloned...
|
||||
Fetching origin
|
||||
Pulling latest changes from rdlist repo...
|
||||
|
||||
WARNING! The following remote users are current members of rooms tagged in rdlist: ['@pedobear:matrix.org', '@randomcreep:perthchat.org']
|
||||
|
||||
Do you want to send out incident reports for these users to every homeserver admin involved? y/n? y
|
||||
|
||||
Sending Incident Report for users from matrix.org to abuse@matrix.org
|
||||
|
||||
Sending Incident Report for users from perthchat.org to @michael:perthchat.org
|
||||
|
||||
```
|
||||
|
||||
![A preview of an Incident Report being sent over Matrix.](https://github.com/PC-Admin/matrix-moderation-tool/assets/29645145/db5a4a56-fd66-413a-ac44-1216c7b2f1fd)
|
||||
|
||||
|
||||
## rdlist Block/Purge all rooms with recommended rdlist tags
|
||||
|
||||
Finally this script can be used to shutdown rooms with the recommended rdlist tags.
|
||||
|
||||
This function is much larger and will ask you if you also want to create user/incident reports before the shutdowns. (Recommended) It'll also ask you if you want to shadowban the users in these rooms to prevent them from alerting others. (Recommended) Finally it'll ask if you want to shutdown the local accounts located in these rooms.
|
||||
|
||||
```
|
||||
$ python3 moderation_tool.py
|
||||
|
||||
Please select one of the following options:
|
||||
...
|
||||
Please enter a number from the above menu, or enter 'q' or 'e' to exit.
|
||||
|
||||
132
|
||||
|
||||
@mod_team:perthchat.org account already exists. Resetting account password.
|
||||
|
||||
Ensuring @mod_team:perthchat.org account is a server admin.
|
||||
|
||||
rdlist repo already cloned...
|
||||
Fetching origin
|
||||
rdlist repo is up-to-date, no need to pull changes.
|
||||
|
||||
Using recommended rdlist tags. Rooms matching the following tags will be purged and/or blocked:
|
||||
['hub_room_links', 'hub_room_trade', 'preban', 'degen_misc', 'beastiality', 'degen_porn', 'gore', 'snuff', 'degen_larp', 'hub_room_sussy', 'bot_spam', 'cfm', 'jailbait', 'bot_porn', 'toddlercon', 'loli', 'csam', 'tfm', 'degen_meet', 'stylized_3d_loli', '3d_loli']
|
||||
|
||||
WARNING! The following local users are current members of rooms tagged in rdlist: ['@***REDACTED***:perthchat.org']
|
||||
|
||||
Do you want to generate a user report file for each of these users? y/n? n
|
||||
|
||||
Skipping user report generation...
|
||||
|
||||
WARNING! The following remote users are current members of rooms tagged in rdlist: ['@***REDACTED***:matrix.org']
|
||||
|
||||
Do you want to send out incident reports for these users to every homeserver admin involved? y/n? n
|
||||
|
||||
Skipping incident report generation...
|
||||
|
||||
|
||||
Number of rdlist rooms being shutdown: 346
|
||||
|
||||
Are you sure you want to block/shutdown these rooms? y/n? y
|
||||
|
||||
Do you want to also shadow ban all your local users in these rooms before performing these shutdowns? (This is recommended as it prevents them from alerting others about these mass shutdown.) y/n? y
|
||||
|
||||
Shadow banning user: @***REDACTED***:perthchat.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Blocking unknown room: !***REDACTED***:matrix.org
|
||||
Successfully blocked room !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Blocking unknown room: !***REDACTED***:matrix.org
|
||||
Successfully blocked room !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:matrix.org
|
||||
|
||||
|
||||
Shutting down known room: !***REDACTED***:sibnsk.net
|
||||
Sleeping for 2 seconds...
|
||||
Sleeping for 4 seconds...
|
||||
Sleeping for 8 seconds...
|
||||
!***REDACTED***:sibnsk.net has been successfully shutdown!
|
||||
List of kicked users:
|
||||
@***REDACTED***:perthchat.org
|
||||
|
||||
|
||||
Skipping already blocked room: !***REDACTED***:anontier.nl
|
||||
|
||||
|
||||
Room shutdowns completed!
|
||||
|
||||
User login details for your moderator account:
|
||||
|
||||
Username: mod_team
|
||||
Password: ***REDACTED***
|
||||
|
||||
Print rdlist statistics:
|
||||
|
||||
Number of rooms blocked: 4
|
||||
Number of rooms purged: 2
|
||||
Number of local users located in rdlist rooms and kicked: 1
|
||||
|
||||
The following users were current members of rooms tagged in rdlist: ['@***REDACTED***:perthchat.org']
|
||||
|
||||
Do you want to also deactivate all these accounts that were kicked from rdlist rooms? y/n?
|
||||
|
||||
https://matrix.perthchat.org/_synapse/admin/v1/deactivate/@***REDACTED***:perthchat.org
|
||||
|
||||
Successfully deactivated account.
|
||||
|
||||
These accounts have been deactivated.
|
||||
...
|
||||
```
|
64
docs/room_functions.md
Normal file
64
docs/room_functions.md
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
#### Room Commands ####
|
||||
|
||||
50) **List details of a room.**
|
||||
- Shows comprehensive information about a specific room.
|
||||
|
||||
51) **List the members of a room.**
|
||||
- Displays all the members who are part of a particular room.
|
||||
|
||||
52) **Export the state events of a room.**
|
||||
- Retrieves and saves the state events (such as topic changes, member joins) of a specific room.
|
||||
|
||||
53) **Export the state events of multiple rooms.**
|
||||
- Gathers and saves the state events from several rooms simultaneously.
|
||||
|
||||
54) **List rooms in public directory.**
|
||||
- Displays all the rooms that are publicly available and listed in the directory.
|
||||
|
||||
55) **Remove a room from the public directory.**
|
||||
- Takes a specific room off the public directory, making it less accessible to users browsing the directory.
|
||||
|
||||
56) **Remove multiple rooms from the public directory.**
|
||||
- Removes several rooms from the public directory at once.
|
||||
|
||||
57) **Redact a room event.**
|
||||
- Conceals specific events in a room, such as messages or media, from being visible.
|
||||
|
||||
58) **List/Download all media in a room.**
|
||||
- Displays and offers the option to download all media files shared in a specific room.
|
||||
|
||||
59) **Download media from multiple rooms.**
|
||||
- Enables downloading of media files shared across several rooms.
|
||||
|
||||
60) **Quarantine all media in a room.**
|
||||
- Isolates and restricts access to all media files in a specific room, usually due to concerns over inappropriate content.
|
||||
|
||||
61) **Shutdown a room.**
|
||||
- Terminates a room, preventing further activities or messages in it.
|
||||
|
||||
62) **Shutdown multiple rooms.**
|
||||
- Closes several rooms simultaneously, halting any ongoing activity in them.
|
||||
|
||||
63) **Delete a room.**
|
||||
- Permanently removes a room and all its content.
|
||||
|
||||
64) **Delete multiple rooms.**
|
||||
- Erases several rooms and their content from the server at once.
|
||||
|
||||
65) **Purge the event history of a room to a specific timestamp.**
|
||||
- Deletes all events in a room up to a certain point in time, preserving events after that timestamp.
|
||||
|
||||
66) **Purge the event history of multiple rooms to a specific timestamp.**
|
||||
- Clears the events in several rooms up to a specified timestamp.
|
||||
|
||||
67) **Get blocked status for room.**
|
||||
- Checks if a room is blocked and restricted from user access.
|
||||
|
||||
68) **Block a room.**
|
||||
- Restricts access to a room, preventing users from joining or interacting in it.
|
||||
|
||||
69) **Unblock a room.**
|
||||
- Restores access to a previously blocked room, allowing users to join and participate once more.
|
||||
|
||||
> **Note:** Managing rooms is a sensitive operation, especially when dealing with content and user privacy. Ensure you have the required permissions and handle operations with care.
|
84
docs/server_functions.md
Normal file
84
docs/server_functions.md
Normal file
@ -0,0 +1,84 @@
|
||||
|
||||
# Server Commands Guide
|
||||
|
||||
This guide provides detailed steps for server-side operations that use the database and SSH. The commands and scripts are essential for handling specific server operations related to Matrix's Synapse server.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [1. Delete and Block Specific Media](#1-delete-and-block-specific-media)
|
||||
- [2. Purge Remote Media Repository](#2-purge-remote-media-repository)
|
||||
- [3. Prepare Database for Copying Events of Multiple Rooms](#3-prepare-database-for-copying-events-of-multiple-rooms)
|
||||
|
||||
---
|
||||
|
||||
### 1. Delete and Block Specific Media
|
||||
|
||||
This command allows an admin to delete a specific media on their Matrix Synapse server and block it to prevent future accesses.
|
||||
|
||||
#### Process Flow:
|
||||
|
||||
1. Take `media_id` and remote server URL from the user.
|
||||
2. Use SSH to query the Synapse PostgreSQL database for the associated `filesystem_id`.
|
||||
3. Locate the target media files and thumbnails on the server's file system.
|
||||
4. Zero out (empty) each file and make them immutable, meaning they cannot be modified or deleted.
|
||||
|
||||
#### Example:
|
||||
|
||||
For a media with ID `eDmjusOjnHyFPOYGxlrOsULJ`, the process would involve:
|
||||
|
||||
```bash
|
||||
$ ssh matrix.perthchat.org "... SQL query to get filesystem_id..."
|
||||
$ ssh matrix.perthchat.org "... command to locate files ..."
|
||||
$ ssh matrix.perthchat.org "true > ...path to file..."
|
||||
$ ssh matrix.perthchat.org "chattr +i ...path to file..."
|
||||
```
|
||||
|
||||
### 2. Purge Remote Media Repository
|
||||
|
||||
This command purges the remote media repository for a certain range of days.
|
||||
Process Flow:
|
||||
|
||||
Ask the user for the range of days to purge.
|
||||
Calculate the epoch timestamp for each day in the range.
|
||||
Send a request to the Synapse server to purge media for that day.
|
||||
Repeat for each day in the range.
|
||||
|
||||
Example:
|
||||
```bash
|
||||
$ date --date '149 days ago' +%s
|
||||
$ curl -X POST --header "Authorization: Bearer ACCESS_TOKEN" '... Matrix Synapse purge endpoint ...'
|
||||
```
|
||||
|
||||
### 3. Prepare Database for Copying Events of Multiple Rooms
|
||||
|
||||
This command prepares the PostgreSQL database to export events from multiple Matrix rooms.
|
||||
Process Flow:
|
||||
|
||||
Prompt for a list of room IDs.
|
||||
Create a RAM disk on the server to store the export.
|
||||
For each room ID:
|
||||
Create a SQL query to extract room events.
|
||||
Write the query to a file on the RAM disk.
|
||||
Provide instructions for running the queries in the PostgreSQL container.
|
||||
|
||||
Notes:
|
||||
|
||||
This function is compatible with Spantaleev's Matrix deploy script.
|
||||
Ensure proper permissions and consider the impact on the server when copying a large amount of data.
|
||||
|
||||
Example:
|
||||
```bash
|
||||
# As the root user on the target server:
|
||||
$ mkdir /matrix/postgres/data/ramdisk
|
||||
$ ... commands to set up RAM disk ...
|
||||
$ ... commands to generate SQL queries for each room ...
|
||||
$ docker exec -it matrix-postgres /bin/bash
|
||||
bash-5.0$ ... commands to execute SQL queries ...
|
||||
```
|
||||
|
||||
After copying the data, ensure to clean up the RAM disk:
|
||||
|
||||
```bash
|
||||
$ rm -r /matrix/postgres/data/ramdisk/*
|
||||
$ umount /matrix/postgres/data/ramdisk
|
||||
```
|
118
docs/user_functions.md
Normal file
118
docs/user_functions.md
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
#### User Account Commands ####
|
||||
|
||||
1) **Deactivate a user account.**
|
||||
|
||||
> This function disables a specific user's account, making it unusable for the owner.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#deactivate-account
|
||||
|
||||
2) **Deactivate multiple user accounts.**
|
||||
|
||||
> Allows you to disable several user accounts at once. Requires a room list file with room_ids separated by newlines, see the example [./examples/room_list.txt](./examples/room_list.txt) file.
|
||||
|
||||
3) **Create a user account.**
|
||||
|
||||
> Use this to generate a new user account.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#create-or-modify-account
|
||||
|
||||
4) **Create multiple user accounts.**
|
||||
|
||||
> This facilitates the creation of several user accounts simultaneously. Requires a user list file with user_ids separated by newlines, see the example [./examples/user_list.txt](./examples/user_list.txt) file.
|
||||
|
||||
5) **Reset a user's password.**
|
||||
|
||||
> If a user forgets their password, this function helps set a new one.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#reset-password
|
||||
|
||||
6) **Whois user account.**
|
||||
|
||||
> Provides detailed information about a specific user's account.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#query-current-sessions-for-a-user
|
||||
|
||||
7) **Whois multiple user accounts.**
|
||||
|
||||
> Retrieves detailed information for multiple user accounts at once. Requires a user list file with user_ids separated by newlines, see the example [./examples/user_list.txt](./examples/user_list.txt) file.
|
||||
|
||||
8) **Query user account.**
|
||||
|
||||
> Allows you to get specific details or attributes of a user account.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#query-user-account
|
||||
|
||||
9) **Query multiple user accounts.**
|
||||
|
||||
> Retrieve specific details for several user accounts simultaneously. Requires a user list file with user_ids separated by newlines, see the example [./examples/user_list.txt](./examples/user_list.txt) file.
|
||||
|
||||
10) **List room memberships of user.**
|
||||
|
||||
> Displays the list of rooms that a user is a part of.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#list-room-memberships-of-a-user
|
||||
|
||||
11) **Promote a user to server admin.**
|
||||
|
||||
> Elevates a user's privileges, making them an administrator on the server.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#change-whether-a-user-is-a-server-administrator-or-not
|
||||
|
||||
12) **List all user accounts.**
|
||||
|
||||
> Displays or prints to file a comprehensive list of all user accounts on the server.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#list-accounts
|
||||
|
||||
13) **Quarantine all media a user uploaded.**
|
||||
|
||||
> This API quarantines all local media that a local user has uploaded. That is to say, if you would like to quarantine media uploaded by a user on a remote homeserver, you should instead use one of the other APIs. Useful for potential harmful or inappropriate content.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.40/admin_api/media_admin_api.html#quarantining-all-media-of-a-user
|
||||
|
||||
14) **Collect account data.**
|
||||
|
||||
> Retrieves all available data associated with a user's account.
|
||||
|
||||
15) **List account pushers.**
|
||||
|
||||
> Shows devices and services that have push access to a user's account.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#list-all-pushers
|
||||
|
||||
16) **Get rate limit of a user account.**
|
||||
|
||||
> Displays the frequency at which a user can make requests or actions.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#get-status-of-ratelimit
|
||||
|
||||
17) **Set rate limit of a user account.**
|
||||
|
||||
> Adjusts the frequency rate at which a user can make requests or actions.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#set-ratelimit
|
||||
|
||||
18) **Delete rate limit of a user account.**
|
||||
|
||||
> Removes any rate limits set on a user's account, granting them unrestricted action frequency.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#delete-ratelimit
|
||||
|
||||
19) **Check if user account exists.**
|
||||
|
||||
> Verifies the existence of a specific user_id, for example "@johndoe:example.org" on the homeserver.
|
||||
|
||||
20) **Shadow ban a user.**
|
||||
|
||||
> Shadow-banning is a useful tool for moderating malicious or egregiously abusive users. A shadow-banned users receives successful responses to their client-server API requests, but the events are not propagated into rooms. This can be an effective tool as it (hopefully) takes longer for the user to realise they are being moderated before pivoting to another account.
|
||||
|
||||
> Shadow-banning a user should be used as a tool of last resort and may lead to confusing or broken behaviour for the client. A shadow-banned user will not receive any notification and it is generally more appropriate to ban or kick abusive users. A shadow-banned user will be unable to contact anyone on the server.
|
||||
|
||||
https://matrix-org.github.io/synapse/v1.38/admin_api/user_admin_api.html#shadow-banning-users
|
||||
|
||||
21) **Find a user by their 3PID (Third-party ID).**
|
||||
|
||||
> Allows you to locate a user based on their third-party identifiers, such as email or phone number.
|
||||
|
||||
**Note:** All these commands utilize the Synapse API. Always exercise caution and ensure you have the necessary permissions when accessing and modifying user accounts.
|
@ -1,5 +1,14 @@
|
||||
|
||||
#!/bin/env python3
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
# Check if ./hardcoded_variables.py file exists
|
||||
if not os.path.exists("./hardcoded_variables.py"):
|
||||
print("ERROR: The file './hardcoded_variables.py' does not exist. It must be configured before using this script.")
|
||||
exit()
|
||||
|
||||
import user_commands
|
||||
import room_commands
|
||||
import server_commands
|
||||
@ -7,24 +16,31 @@ import ipinfo_commands
|
||||
import rdlist_commands
|
||||
import report_commands
|
||||
import bot_commands
|
||||
|
||||
# Importing the module only after verifying its existence
|
||||
import hardcoded_variables
|
||||
|
||||
# check if homeserver url is hard coded, if not set it
|
||||
# If it does exist... check if the variables are configured:
|
||||
|
||||
# check if homeserver url is the default
|
||||
|
||||
if hardcoded_variables.homeserver_url == "matrix.example.org":
|
||||
homeserver_url = input("What is the URL of your server? Eg: matrix.example.org ")
|
||||
print("ERROR: homeserver_url not configured, please configure your './hardcoded_variables.py' file!")
|
||||
exit()
|
||||
|
||||
# check if base url is hard coded, if not set it
|
||||
# check if base url is the default
|
||||
|
||||
if hardcoded_variables.base_url == "example.org":
|
||||
base_url = input("What is the URL of your server? Eg: example.org ")
|
||||
print("ERROR: base_url not configured, please configure your './hardcoded_variables.py' file!")
|
||||
exit()
|
||||
|
||||
# check if access token is hard coded, if not set it
|
||||
# check if access token is the default
|
||||
|
||||
length_access_token = len(hardcoded_variables.access_token)
|
||||
|
||||
if length_access_token == 0:
|
||||
access_token = input("Please enter access token for server admin account: ")
|
||||
print("ERROR: access_token not configured, please configure your './hardcoded_variables.py' file!")
|
||||
exit()
|
||||
|
||||
# loop menu for various moderation actions
|
||||
|
||||
@ -96,7 +112,7 @@ while pass_token == False:
|
||||
elif menu_input == "7":
|
||||
user_commands.whois_multiple_accounts()
|
||||
elif menu_input == "8":
|
||||
query_account_dict = user_commands.query_account()
|
||||
query_account_dict = user_commands.query_account('')
|
||||
print(json.dumps(query_account_dict, indent=4, sort_keys=True))
|
||||
elif menu_input == "9":
|
||||
user_commands.query_multiple_accounts()
|
||||
|
@ -432,6 +432,7 @@ def list_account_pushers(preset_username):
|
||||
|
||||
def get_rate_limit():
|
||||
username = input("\nPlease enter the username to get its ratelimiting: ")
|
||||
username = parse_username(username)
|
||||
|
||||
url = f"https://{hardcoded_variables.homeserver_url}/_synapse/admin/v1/users/@{username}:{hardcoded_variables.base_url}/override_ratelimit?access_token={hardcoded_variables.access_token}"
|
||||
|
||||
@ -450,6 +451,7 @@ def get_rate_limit():
|
||||
|
||||
def set_rate_limit():
|
||||
username = input("\nPlease enter the username to adjust its ratelimiting: ")
|
||||
username = parse_username(username)
|
||||
|
||||
messages_per_second = input("\nPlease enter the desired messages per second: ")
|
||||
burst_count = input("\nPlease enter the desired burst count: ")
|
||||
@ -478,6 +480,7 @@ def set_rate_limit():
|
||||
|
||||
def delete_rate_limit():
|
||||
username = input("\nPlease enter the username to delete its ratelimiting: ")
|
||||
username = parse_username(username)
|
||||
|
||||
url = f"https://{hardcoded_variables.homeserver_url}/_synapse/admin/v1/users/@{username}:{hardcoded_variables.base_url}/override_ratelimit?access_token={hardcoded_variables.access_token}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user