DarkCat09 / python-aternos

[UNMAINTAINED] Unofficial Aternos API written in Python
https://pypi.org/project/python-aternos/
Apache License 2.0
92 stars 13 forks source link

whitelist.add() does nothing #30

Closed KarsonTheFoxx closed 2 years ago

KarsonTheFoxx commented 2 years ago

This command literally does nothing it seems

my code

from python_aternos import Client, atplayers
client = Client.from_credentials("username", "password")
server = client.list_servers()[0]
whitelist = server.players(atplayers.Lists.whl)

whitelist.add("Karsonthefoxx")
DarkCat09 commented 2 years ago

Add before from python-aternos this code:

import logging
logging.basicConfig(level=logging.DEBUG)

Run your python script and send me all output.

KarsonTheFoxx commented 2 years ago

DEBUG:root:Requesting(GET)https://aternos.org/go/ DEBUG:root:headers={} DEBUG:root:params={} DEBUG:root:data={} DEBUG:root:req-cookies={'ATERNOS_SESSION': ''} DEBUG:root:session-cookies=<RequestsCookieJar[]> DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): aternos.org:443 DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /go/ HTTP/1.1" 200 None INFO:root:GET completed with 200 status DEBUG:root:Requesting(POST)https://aternos.org/panel/ajax/account/login.php DEBUG:root:headers={'X-Requested-With': 'XMLHttpRequest'} DEBUG:root:params={'TOKEN': '6rHFHPAzqfSfHXz2kTQC', 'SEC': '1939v851h3n00000:15zeqfngrjv00000'} DEBUG:root:data={'user': 'ABot1234567', 'password': '727c3e94f304bbec54637c9d113aaf93'} DEBUG:root:req-cookies={'ATERNOS_SESSION': ''} DEBUG:root:session-cookies=<RequestsCookieJar[, ]> DEBUG:urllib3.connectionpool:https://aternos.org:443 "POST /panel/ajax/account/login.php?TOKEN=6rHFHPAzqfSfHXz2kTQC&SEC=1939v851h3n00000%3A15zeqfngrjv00000 HTTP/1.1" 200 None INFO:root:POST completed with 200 status DEBUG:root:Requesting(GET)https://aternos.org/servers/ DEBUG:root:headers={} DEBUG:root:params={} DEBUG:root:data={} DEBUG:root:req-cookies={'ATERNOS_SESSION': '2qx19hSszDqVe8EyDqosYhc4cShNT2WATvFDDyu3HlJWGkcmOyNF3dShxSKVR2RMvh7cppKWsxnkOXeelIwv5nwa2TkTZcyuSUhH'} DEBUG:root:session-cookies=<RequestsCookieJar[, ]> DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /servers/ HTTP/1.1" 200 None INFO:root:GET completed with 200 status DEBUG:root:Requesting(GET)https://aternos.org/panel/ajax/status.php DEBUG:root:headers={'X-Requested-With': 'XMLHttpRequest'} DEBUG:root:params={'TOKEN': '6rHFHPAzqfSfHXz2kTQC', 'SEC': '1939v851h3n00000:15zeqfngrjv00000'} DEBUG:root:data={} DEBUG:root:req-cookies={'ATERNOS_SERVER': '0QqkULTj6FINLVgW', 'ATERNOS_SESSION': '2qx19hSszDqVe8EyDqosYhc4cShNT2WATvFDDyu3HlJWGkcmOyNF3dShxSKVR2RMvh7cppKWsxnkOXeelIwv5nwa2TkTZcyuSUhH'} DEBUG:root:session-cookies=<RequestsCookieJar[, ]> DEBUG:urllib3.connectionpool:https://aternos.org:443 "GET /panel/ajax/status.php?TOKEN=6rHFHPAzqfSfHXz2kTQC&SEC=1939v851h3n00000%3A15zeqfngrjv00000 HTTP/1.1" 200 None INFO:root:GET completed with 200 status DEBUG:root:Requesting(POST)https://aternos.org/panel/ajax/players/add.php DEBUG:root:headers={'X-Requested-With': 'XMLHttpRequest'} DEBUG:root:params={'TOKEN': '6rHFHPAzqfSfHXz2kTQC', 'SEC': '1939v851h3n00000:15zeqfngrjv00000'} DEBUG:root:data={'list': 'whitelist', 'name': 'Karsonthefoxx'} DEBUG:root:req-cookies={'ATERNOS_SERVER': '0QqkULTj6FINLVgW', 'ATERNOS_SESSION': '2qx19hSszDqVe8EyDqosYhc4cShNT2WATvFDDyu3HlJWGkcmOyNF3dShxSKVR2RMvh7cppKWsxnkOXeelIwv5nwa2TkTZcyuSUhH'} DEBUG:root:session-cookies=<RequestsCookieJar[, ]> DEBUG:urllib3.connectionpool:https://aternos.org:443 "POST /panel/ajax/players/add.php?TOKEN=6rHFHPAzqfSfHXz2kTQC&SEC=1939v851h3n00000%3A15zeqfngrjv00000 HTTP/1.1" 200 None INFO:root:POST completed with 200 status

KarsonTheFoxx commented 2 years ago

even with the 200 status code im seeing this on the allowlist

Screenshot 2022-06-28 11 28 25 AM

DarkCat09 commented 2 years ago

@KarsonTheFoxx, I added displaying responses in atconnect.request_cloudflare and logged in with your session
(sorry, it is needed for debugging, I didn't do anything, just viewed some info, you should logout now).
Here's the log:

>>> whl.add('Karsonthefoxx')
DEBUG:root:Requesting(POST)https://aternos.org/panel/ajax/players/add.php
DEBUG:root:headers={'X-Requested-With': 'XMLHttpRequest'}
DEBUG:root:params={'TOKEN': 'qJFhVPXGQtAGEEPtdSZU', 'SEC': 'rkc9k0ab7n000000:10ihs9uvatn00000'}
DEBUG:root:data={'list': 'whitelist', 'name': 'Karsonthefoxx'}
DEBUG:root:req-cookies={'ATERNOS_SERVER': '0QqkULTj6FINLVgW', 'ATERNOS_SESSION': '2qx19hSszDqVe8EyDqosYhc4cShNT2WATvFDDyu3HlJWGkcmOyNF3dShxSKVR2RMvh7cppKWsxnkOXeelIwv5nwa2TkTZcyuSUhH'}
DEBUG:root:session-cookies=<RequestsCookieJar[<Cookie ATERNOS_LANGUAGE=en for aternos.org/>, <Cookie ATERNOS_SEC_rkc9k0ab7n000000=10ihs9uvatn00000 for aternos.org/>]>
DEBUG:urllib3.connectionpool:https://aternos.org:443 "POST /panel/ajax/players/add.php?TOKEN=qJFhVPXGQtAGEEPtdSZU&SEC=rkc9k0ab7n000000%3A10ihs9uvatn00000 HTTP/1.1" 200 None
DEBUG:root:AternosConnect received: {"success":false}
INFO:root:POST completed with 200 status

Aternos responded with {"success": false}. It also usually specifies the reason, but here is just success:false.
Maybe, this server is not yours ("shared access") and the right to manage allowlist wasn't given to you?

KarsonTheFoxx commented 2 years ago

Although not having permission would explain a lot, it cant be this because the account im using owns this server

DarkCat09 commented 2 years ago

Then... can you try this:

  1. Go to https://aternos.org/players/whitelist
  2. Open DevTools with Ctrl+Shift+I and switch to the "Network" tab.
  3. Add someone to the list.
  4. add.php request will appear in Developers Tools window.
  5. Click on it, copy all information from tabs "Headers" and "Payload" and send me.

I won't ask you if I could reproduce this problem and check some info by myself.
But adding players works for me.

DarkCat09 commented 2 years ago

And you should log out after posting request data here because it contains your session cookies (using which anyone can log in to your account without password).

KarsonTheFoxx commented 2 years ago

{success: true, entry: {name: "Karsonthefoxx", icon: "fas fa-user-check"}} entry: {name: "Karsonthefoxx", icon: "fas fa-user-check"} success: true

KarsonTheFoxx commented 2 years ago

headers


Request URL: https://aternos.org/panel/ajax/players/add.php?SEC=r9c2loljmmj00000%3Aprcw691wju800000&TOKEN=xeQsZggxArz6R1ZTdS24
Request Method: POST
Status Code: 200 
Remote Address: [2606:4700:10::6816:ea3]:443
Referrer Policy: strict-origin-when-cross-origin
cf-cache-status: DYNAMIC
cf-ray: 7238fcdd7c0e0881-SEA
content-encoding: br
content-type: text/html; charset=UTF-8
date: Thu, 30 Jun 2022 18:33:00 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
set-cookie: ATERNOS_SESSION=WcayB8QcNj1RfwgIJzHKqhv0APQsuXJ5zPtUEyRVRmJ28VSn9XH0LmT3imYn0pgtty7BCiVvsUBaHmC4IW6IlfPekLiXpv46MYLJ; expires=Sat, 30-Jul-2022 18:33:00 GMT; Max-Age=2592000; path=/; HttpOnly; SameSite=Lax
set-cookie: ATERNOS_SEC_r9c2loljmmj00000=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/panel/ajax/players/add.php
strict-transport-security: max-age=15552000; includeSubDomains; preload
x-content-type-options: nosniff
:authority: aternos.org
:method: POST
:path: /panel/ajax/players/add.php?SEC=r9c2loljmmj00000%3Aprcw691wju800000&TOKEN=xeQsZggxArz6R1ZTdS24
:scheme: https
accept: */*
accept-encoding: gzip, deflate, br
accept-language: en-CA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7
content-length: 33
content-type: application/x-www-form-urlencoded; charset=UTF-8
cookie: ATERNOS_SEC_hrv7hc2vwy700000=qm0k4d114zg00000; ATERNOS_SEC_r9c2loljmmj00000=prcw691wju800000; ATERNOS_LANGUAGE=en; _ga=GA1.2.1625273628.1655494968; ATERNOS_GA=1625273628.1655494968; _pbjs_userid_consent_data=6683316680106290; _lr_env_src_ats=false; __gads=ID=34a414ad717d8266:T=1655494990:S=ALNI_Ma26IdoN1tqKvxBDBej6DqYsC9c1g; _cc_id=59793dbd111adfaac77900ddddf49202; ATERNOS_SESSION=WcayB8QcNj1RfwgIJzHKqhv0APQsuXJ5zPtUEyRVRmJ28VSn9XH0LmT3imYn0pgtty7BCiVvsUBaHmC4IW6IlfPekLiXpv46MYLJ; cto_bundle=gik6s19kODUyYzZCZ1RaYlk3dEJGOFd5Vkl2aUIlMkI4QkUzUXRiT2s4QldOTmNQSkxHTjgxRyUyQmQwMGslMkIlMkIycDJPZUJXVFR2NmNaRkFYRXRVN05EU0VvdEhHWjFxSWZHQVJuRmliaTgyQXolMkZ4WEczc09tM0dkUmt0cjVWQ3hWbTJUWGtFTUVHa1M3RTNTZXhJalJmQk11Q3hvWmpBJTNEJTNE; cto_bidid=zzYwol93S0RDQVVENnVLWmMzWjlpa1prVXBLbWhtbFM2RHklMkZ0d2RUU1dzaDFrS0EwNWFFQmFVVmk0UzAzblVXU3dJQU5oUFZlWFpWcTVNS2cxYThiMnZHNmp0TTdaTG13Vm9CRVVYUFltZWo0Nmg4JTNE; ATERNOS_SERVER=0QqkULTj6FINLVgW; _gid=GA1.2.32633930.1656613859; _lr_retry_request=true; __cf_bm=mhuKbI2iEJcNhYG6zYRTAs0AT5c77Du8PCKTjoTc2Gw-1656613863-0-AasqZfdz6S+D8O0OLP8eMvpJXO36RmCq259KdDqL4pcvj7wmcRIw3+MzTsB2FQVekL6BxNZIye6KwApt9UjaSvuKsELe46BDD+um5urzzOeDayGKqTGe62kpVeqgMdlnAQ==; __gpi=UID=0000066863bb7aa7:T=1655494990:RT=1656613863:S=ALNI_MbPP0qFzpBhOjMbYXud4PZw5cZI_g; cto_bundle=SdJmNF9kODUyYzZCZ1RaYlk3dEJGOFd5VkloNFp4Vkc2c1BzT20ydW9HR1AlMkZDTDVyOUgybFRqMiUyRnhlVm16ZUNPd1dvajFWVU8lMkI5d1FhM0N0eGhreHNmejMlMkZpdWNMenQlMkZxRUJpJTJCZ3IlMkY0blUzOHRjWlRDJTJCNiUyRmdydmlMSzF2a3lIeFJoNnMwcGswJTJGcHFObHE5RjVmT1BEdTdsUSUzRCUzRA
origin: https://aternos.org
referer: https://aternos.org/players/allowlist
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="102", "Google Chrome";v="102"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "ChromeOS"
sec-fetch-dest: empty
sec-fetch-mode: cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (X11; CrOS x86_64 14695.107.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
x-requested-with: XMLHttpRequest
KarsonTheFoxx commented 2 years ago

payload


SEC: r9c2loljmmj00000:prcw691wju800000
TOKEN: xeQsZggxArz6R1ZTdS24
list: allowlist
name: Karsonthefoxx
DarkCat09 commented 2 years ago

Thanks.
You have a Bedrock server, haven't you?
I noticed that on JE used "whitelist", but on BE "allowlist".
The version with fix will be released soon.

KarsonTheFoxx commented 2 years ago

alright thank you, is there any way i can a solution right away? even if i have to edit the files myself? also bedrock only recently started calling it allowlist

KarsonTheFoxx commented 2 years ago

also can you reply to this when the updates out? i'll probably forget, also i appreciate this module, its literally a one of a kind

DarkCat09 commented 2 years ago

To fix it by yourself, add to atplayers.py one more enum key (e.g. whl_be) with value allowlist, like in the code below:

# atplayers.py
class Lists(enum.Enum):
    whl = 'whitelist'
    whl_be = 'allowlist'  # <-- added
    ops = 'ops'
    ...

And then use it in your code instead of whl:

from python_aternos import Client, atplayers

at = Client.from_credentials('user', 'pswd')
serv = at.list_servers()[0]

# `Lists.whl_be` instead of `Lists.whl`
lst = serv.players(atplayers.Lists.whl_be)
lst.add('Karsonthefoxx')
lst.remove('Notch')
print(lst.list_players())
KarsonTheFoxx commented 2 years ago

hey whats the file path to the module? i've been looking around my /usr/local and i cant find any mention of python_aternos

DarkCat09 commented 2 years ago

It's /usr/local/share/python3.10/site-packages/python-aternos-version if I don't mistake.
For user-level installation: ~/.local/share/python3.10/site-packages/python-aternos-version.

KarsonTheFoxx commented 2 years ago

That path doesnt exist, the closest path is /usr/local/lib/python3.10 and python aternos is not one of the files

KarsonTheFoxx commented 2 years ago

found it in .local/lib/python3.9/site-packages/python_aternos/atplayers.py