Skip to content

Commit 50ca203

Browse files
committed
List unauthed methods
1 parent d4b1a54 commit 50ca203

5 files changed

Lines changed: 22 additions & 3 deletions

File tree

docs

Submodule docs updated 796 files

src/MTProto.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,9 @@ public function getSelf(): array|false
16031603
*/
16041604
public function isSelfBot(): bool
16051605
{
1606+
if ($this->loginState->getState()->state !== API::LOGGED_IN) {
1607+
throw new Exception('Not logged in!');
1608+
}
16061609
return $this->authorization['user']['bot'];
16071610
}
16081611
/**

src/RPCErrorException.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class RPCErrorException extends \Exception
5050
'USER_DEACTIVATED_BAN' => true,
5151
'INPUT_METHOD_INVALID' => true,
5252
'INPUT_FETCH_ERROR' => true,
53-
'AUTH_KEY_UNREGISTERED' => true,
5453
'SESSION_REVOKED' => true,
5554
'USER_DEACTIVATED' => true,
5655
'RPC_SEND_FAIL' => true,

tools/fuzzer.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php declare(strict_types=1);
22

33
use danog\MadelineProto\API;
4+
use danog\MadelineProto\Exception;
45
use danog\MadelineProto\Logger;
56
use danog\MadelineProto\PTSException;
67
use danog\MadelineProto\RPCErrorException;
@@ -62,6 +63,11 @@ function getTL(TLSchema $schema)
6263
$settings->setSchema($schema);
6364
$settings->getLogger()->setLevel(Logger::ULTRA_VERBOSE);
6465

66+
$unauthed = new \danog\MadelineProto\API('fuzz_unauth.madeline');
67+
$unauthed->updateSettings($settings);
68+
Assert::false($unauthed->getSelf(), "fuzz_unauth.madeline is authed!");
69+
$unauthed->restart();
70+
6571
echo "Bot login:".PHP_EOL;
6672
$bot = new \danog\MadelineProto\API('fuzz_bot.madeline');
6773
$bot->start();
@@ -138,6 +144,17 @@ function call(API $API, string $method, array $args = []): void
138144

139145
foreach ($layer['methods']->by_id as $constructor) {
140146
$name = $constructor['method'];
147+
if (strtolower($name) === 'account.deleteaccount'
148+
|| !str_contains($name, '.')) {
149+
continue;
150+
}
151+
$methods["unauthed $name"]= async(static function () use ($unauthed, $name, &$methods): void {
152+
try {
153+
call($unauthed, $name);
154+
} catch (RPCErrorException|PTSException|Exception) {
155+
}
156+
unset($methods["unauthed $name"]);
157+
});
141158
if (strtolower($name) === 'account.deleteaccount'
142159
|| strtolower($name) === 'auth.logout'
143160
|| $name === 'auth.resetAuthorizations'

0 commit comments

Comments
 (0)