Giter Club home page Giter Club logo

telegram-osint-lib's Introduction

Telegram OSINT scenario library

Gitpod ready-to-code

codecov

Description

A lot of Telegram API libraries around, but none of them demonstrates how to execute complex scenarios like draining all photos from channels, monitor users presence or register new account. This projects aims to correct situation: now you can easily create new scenarios and one-click execute existing ones.

Using Telegram API from official Android client.

Rationale

Telegram protocol https://core.telegram.org/ has technically thorough and detailed documentation, but does not cover usage scenarios. Our goal is to make a library that implements some real-life OSINT usage scenarios, including:

  • searching user in specific groups;
  • parsing group members;
  • monitoring user online status;
  • downloading photos from channel;
  • monitoring user profile changes (photo/bio/etc.);
  • fetching messages by specific user.

Requirements

  • PHP 7.4+
  • Composer
    • phpseclib

Docs

QuickStart

First of all, add library to your app user composer:

composer require postuf/telegram-api-lib

To check out usage examples, go to examples dir. You need auth keys generated, run php registration.php to get this. Now you are all set, you can run any of examples, for example, php parseGroupMembers.php, and check the output.

Verbose logging (all messages sent/received) is enabled by default, add --info to arguments to suppress it.

Docker container

docker build -t telegram-osint-lib .
docker run -d -t --name tg-osint-lib telegram-osint-lib
docker exec -it tg-osint-lib /bin/bash
php examples/registration.php

When you get AuthKey in registration script, you can use it the following way:

docker exec  --env BOT=your-auth-key -i tg-osint-lib php examples/monitorNumbers.php -n 123123123
# if you save key to file
docker exec  --env BOT=@auth-key-filename-in-docker -i tg-osint-lib php examples/monitorNumbers.php -n 123123123

Limitations

2FA not supported.

telegram-osint-lib's People

Contributors

asenosen avatar ctorowir avatar danealau avatar dependabot[bot] avatar ginemiagl avatar kirkins avatar qusonann avatar ririconj avatar siliariy avatar tombouctou avatar ttakeleif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-osint-lib's Issues

authkey format

Какой формат должен быть у ключа? Можно ли как-то получить его из tdata?

No AuthKey

I see only this while registration

`SMS code: 12592

05.11.2020 12:27:50 | Write_Message_Binary: 8115d5bc0b373931363030353637353912306566656562386235643162343963306632000531323539320000

05.11.2020 12:27:50 | Write_Message_ID: 6891553640960966000

05.11.2020 12:27:50 | Write_Message_TL: Array

(
[_] => auth.signIn
[phone_number] => 79160056759
[phone_code_hash] => 0efeeb8b5d1b49c0f2
[phone_code] => 12592
)
`

Uncaught TelegramOSINT\Exception\TGException: ERR_REG_USER_ALREADY_EXISTS

Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_REG_USER_ALREADY_EXISTS: TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage Object
(
[object:TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage:private] => Array
(
[] => auth.sentCode
[flags] => 2
[type] => Array
(
[
] => auth.sentCodeTypeApp
[length] => 5
)

        [phone_code_hash] => 258747dd89b4c93658
        [next_type] => Array
            (
                [_] => auth.codeTypeSms
            )

        [timeout] =>
    )

[type:TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage:private] => auth.sentCode

)
in /app/src/Registration/RegistrationFromTgApp.php:120
Stack trace:
#0 /app/src/TGConnection/SocketMessenger/EncryptedSocketCallbacks/CallbackMessageListener.php(22): TelegramOSINT\Registration\RegistrationFromTgApp->TelegramOSINT\Registration{clos in /app/src/Registration/RegistrationFromTgApp.php on line 120

I have already logged in mobile telegram client with this phone number. Does it mean I can't use the number in lib?

ERR_MSG_PHONE_MIGRATE

Getting the following after I enter phone number when running examples/registration in Docker.

Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_MSG_PHONE_MIGRATE: phone n2xzIwQuwaUVXybXwzv4nuLAgbXR7q9Yu/mrkzoxC5hAxRrsM33zl2fsTOgh+MB1/1icuMt0pV9NRTM/mP5CrhvxVpjZjleuOEwro3Nabu7FgYajeKHwm9QJlaoV61OWZCUdyWDdYC0MGu+SfFWyvB5bKOVZHFR/qGiQXKgebS+dHULEyYTh76r3fu2ff0ljaPrL7xAbffN68ENyYF45ZhI6ryvEnXLMTai9TuRTg0tfP9szNayh4ZOb2h+sKvvFS/0VCodDTw3vEPCIYdFSg3Ic6/iKZvsCGhZSGRSpDzu3HGGVlVyZmFzKFJC0hSGGm6aRGItDjivWKnDjBu6+2g== already used in another DataCenter in /app/src/TGConnection/SocketMessenger/EncryptedSocketMessenger.php:356
Stack trace:
#0 /app/src/TGConnection/SocketMessenger/EncryptedSocketMessenger.php(299): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->analyzeRpcError(Object(TelegramOSINT\TLMessage\TLMessage\ServerMessages\Rpc\RpcError))
#1 /app/src/TGConnection/SocketMessenger/EncryptedSocketMessenger.php(147): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->processServiceMessage(Object(TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage))
#2 /ap in /app/src/TGConnection/SocketMessenger/EncryptedSocketMessenger.php on line 356
v

Fatal error using lib in docker container

root@f3a47aeb7681:/app# php examples/registration.php
Phone number: **********

Fatal error: Uncaught Error: Typed property TelegramOSINT\Registration\RegistrationFromTgApp::$socketMessenger must not be accessed before initialization in /app/src/Registration/RegistrationFromTgApp.php:314
Stack trace:
#0 /app/src/Registration/AccountRegistrar.php(45): TelegramOSINT\Registration\RegistrationFromTgApp->pollMessages()
#1 /app/examples/registration.php(33): TelegramOSINT\Registration\AccountRegistrar->pollMessages()
#2 /app/examples/registration.php(50): {closure}(Object(TelegramOSINT\Registration\AccountRegistrar))
#3 {main}
thrown in /app/src/Registration/RegistrationFromTgApp.php on line 314
root@f3a47aeb7681:/app#

Hardcoded usernames

Hey guys!

In the sourcecode I can see a bunch of hardcoded usernames -
Asen_17
asensio_17
phuketrusa
a_averyanova_m
ru2chnews

and phone numbers -
79265558802
79803100357
79264598639

What was the reason for putting them there and have you obtained any permission from the original owners of these accounts?

getInfoByPhone()

В статье на habr.com сказано:
"... однако его массовое применение несколько затруднительно “из коробки“"

А как добиться массового применения?

How to get in touch about a security issue?

Hey there,

As there isn't a SECURITY.md with an email on your repository, I am unsure how to contact you regarding a potential security issue.

Would you kindly add a SECURITY.md file with an e-mail to your repository? GitHub recommends this as the best way to ensure security issues are responsibly disclosed, and it would massively help security researchers get in touch next time.

Thank you so much and I look forward to hearing from you!

Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_REG_USER_ALREADY_EXISTS: TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage Object

Trying to run php examples/registration.php without success


20.05.2021 14:52:09 | Read_Message_Binary: 016d5cf318ac07009977a6600225005e020000008659bb3d0500000012656134353865623664613731653237303739008c15a372
20.05.2021 14:52:09 | Read_Message_TL: Array
(
    [_] => rpc_result
    [req_msg_id] => 6964385372789255192
    [result] => Array
        (
            [_] => auth.sentCode
            [flags] => 2
            [type] => Array
                (
                    [_] => auth.sentCodeTypeApp
                    [length] => 5
                )

            [phone_code_hash] => ea458eb6da71e27079
            [next_type] => Array
                (
                    [_] => auth.codeTypeSms
                )

            [timeout] =>
        )

)


Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_REG_USER_ALREADY_EXISTS: TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage Object
(
    [object:TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage:private] => Array
        (
            [_] => auth.sentCode
            [flags] => 2
            [type] => Array
                (
                    [_] => auth.sentCodeTypeApp
                    [length] => 5
                )

            [phone_code_hash] => ea458eb6da71e27079
            [next_type] => Array
                (
                    [_] => auth.codeTypeSms
                )

            [timeout] =>
        )

    [type:TelegramOSINT\MTSerialization\OwnImplementation\OwnAnonymousMessage:private] => auth.sentCode
)
 in /app/src/Registration/RegistrationFromTgApp.php:122
Stack trace:
#0 /app/src/TGConnection/SocketMessenger/EncryptedSocketCallbacks/CallbackMessageListener.php(22): TelegramOSINT\Registration\RegistrationFromTgApp->TelegramOSINT\Registration\{clos in /app/src/Registration/RegistrationFromTgApp.php on line 122

Fatal error: Declaration of TelegramOSINT

Hello! what am I doing wrong?

Fatal error: Declaration of TelegramOSINT\Registration\RegistrationFromTgApp::onMessage(TelegramOSINT\MTSerialization\AnonymousMessage $message) must be compatible with TelegramOSINT\TGConnection\SocketMessenger\MessageListener::onMessage(TelegramOSINT\MTSerialization\AnonymousMessage $message): void in /app/src/Registration/RegistrationFromTgApp.php on line 285

Need help with registration

Hi! Thank you very much for the library. I tried running the registration script with a phone number that had not been registered in Telegram, but with no success.

This is what I did:

  1. php examples/registration.php
  2. Entered the phone
  3. Entered the received code

This is the last piece of the output I saw:
Screenshot 2020-08-29 at 17 23 51

I then tried adding this phone number to my Telegram contacts. It wasn't found, which means the registration process wasn't finished.
After that I also tried logging in with the same phone using the official app. I wanted to see if maybe the phone got banned after the signup attempt. However, the app didn't say that the phone was banned.

Please see the full logs attached too.
postuf-osint-registration-logs.txt

Uncaught TelegramOSINT\Exception\TGException: ERR_CANT_CONNECT

I use your docker container with my proxy settings, and I can curl telegram API inside container. But when I'm trying to register using php examples/registration.php an error appears:

Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_CANT_CONNECT: in /app/src/TGConnection/Socket/TcpSocket.php:37 Stack trace: #0 /app/src/Auth/Protocol/BaseAuthorization.php(85): TelegramOSINT\TGConnection\Socket\TcpSocket->__construct(Object(TelegramOSINT\TGConnection\DataCentre)) #1 /app/src/Auth/Protocol/AppAuthorization.php(20): TelegramOSINT\Auth\Protocol\BaseAuthorization->__construct(Object(TelegramOSINT\TGConnection\DataCentre)) #2 /app/src/Registration/RegistrationFromTgApp.php(171): TelegramOSINT\Auth\Protocol\AppAuthorization->__construct(Object(TelegramOSINT\TGConnection\DataCentre)) #3 /app/src/Registration/RegistrationFromTgApp.php(119): TelegramOSINT\Registration\RegistrationFromTgApp->requestBlankAuthKey(Object(Closure)) #4 /app/src/Registration/AccountRegistrar.php(39): TelegramOSINT\Registration\RegistrationFromTgApp->requestCodeForPhone('******', Object(Closure)) #5 /app/examples/registration.php(24): TelegramOSINT\Registration\AccountRegistrar->requestCodeForPhone('********', Obje in /app/src/TGConnection/Socket/TcpSocket.php on line 37 root@ac21a5713014:/app# php examples/registration.php

auth.codeType

auth.codeTypeCall и auth.codeTypeFlashCall планируется? почему то автоматически не всем дает подобные флаги
image

Uncaught TelegramOSINT\Exception\TGException: ERR_TL_CONTAINER_BAD_AUTHKEY_ID:

PHP Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_TL_CONTAINER_BAD_AUTHKEY_ID: in C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php:189
Stack trace:
#0 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php(155): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->decryptPayload(false)
#1 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php(133): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->readMessageFromSocket()
#2 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\Registration\RegistrationFromTgApp.php(287): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->readMessage()
#3 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\Registration\AccountRegistrar.php(27): TelegramOSINT\Regist in C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php on line 189

Fatal error: Uncaught TelegramOSINT\Exception\TGException: ERR_TL_CONTAINER_BAD_AUTHKEY_ID: in C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php:189
Stack trace:
#0 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php(155): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->decryptPayload(false)
#1 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php(133): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->readMessageFromSocket()
#2 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\Registration\RegistrationFromTgApp.php(287): TelegramOSINT\TGConnection\SocketMessenger\EncryptedSocketMessenger->readMessage()
#3 C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\Registration\AccountRegistrar.php(27): TelegramOSINT\Regist in C:\Program Files\Ampps\www\telegram\vendor\postuf\telegram-api-lib\src\TGConnection\SocketMessenger\EncryptedSocketMessenger.php on line 189

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.