├── .deepsource.toml ├── .github └── ISSUE_TEMPLATE │ └── bug_report.md ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── captcha ├── PwwDvtQdNY.jpg ├── UWSNxarfQF.jpg ├── WWVlyLtFFW.jpg ├── aaUowQrqih.jpg ├── cmnCgoRzdr.jpg ├── lSrMgaZmcW.jpg └── xGnxSJPGCh.jpg ├── dump └── tokens.yaml ├── requirements.txt ├── run.sh └── src ├── __init__.py ├── getcontact ├── __init__.py ├── cipher.py ├── config.py ├── config_updater.py ├── decode_captcha.py ├── getcontact.py ├── logger.py ├── phone_negative.py └── requester.py └── main.py /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "python" 5 | enabled = true 6 | 7 | [analyzers.meta] 8 | runtime_version = "3.x.x" 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Desktop (please complete the following information):** 21 | - Docker [true, false] 22 | - OS [Windows 10, Ubuntu 18.04] 23 | 24 | **Additional context** 25 | Add any other context about the problem here. 26 | 27 | **Log** 28 | ```bash 29 | Some error log 30 | ``` 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | 132 | # PyCharm 133 | .idea 134 | 135 | # vscode 136 | .vscode 137 | 138 | captcha/ -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | RUN apt-get update && apt install -y software-properties-common 4 | RUN add-apt-repository ppa:deadsnakes/ppa 5 | RUN apt-get install -y --no-install-recommends python3.8-dev python3-pip libsm6 libxext6 build-essential ffmpeg libsm6 libxext6 tesseract-ocr 6 | 7 | RUN pip3 install pillow 8 | RUN pip3 install pytesseract 9 | RUN pip3 install opencv-contrib-python 10 | 11 | 12 | # Copy project 13 | COPY ./ ./ 14 | 15 | RUN pip3 install -r requirements.txt 16 | 17 | 18 | ENTRYPOINT ["./run.sh"] 19 | CMD [] 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Kovynev Maxim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/433da7bd8f1f4eddaf339aeb30989e18)](https://app.codacy.com/manual/kovinevmv/getcontact?utm_source=github.com&utm_medium=referral&utm_content=kovinevmv/getcontact&utm_campaign=Badge_Grade_Dashboard) 2 | [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/kovinevmv/getcontact.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/kovinevmv/getcontact/context:python) 3 | 4 | ## Update [01.02.2021] 5 | 6 | - Captcha not working in GetContact App, therefore my scripts doesn't pass verification too :( Please, use another tokens 7 | 8 | ## Warning 9 | 10 | This project is not intended for downloading GetContact database. This project provides the opportunity to receive information by phone number **with a limited number of requests for one token per month**. Several examples of tokens are posted in the repository. 11 | **If the script does not work, use your tokens, run script in debug mode** 12 | 13 | ## About 14 | 15 | After decompiling the application [GetContact](https://www.getcontact.com/ru/), I created simple API to get information directly without installing this application. Unfortunately, the application sends your contacts from the smartphone notebook to public database, but this problem does not occur using this script :) 16 | 17 | ## How to get keys 18 | 19 | If script doesn't run properly try to update token\`s inforamation in `dump/tokens.yaml` file. Or if you want to run with Premium Account enter your auth data in this file. 20 | 21 | Requirements: Android with ROOT-rights (or emulator). 22 | 23 | Open in filemanager of phone ` /data/data/app.source.getcontact/shared_prefs/GetContactSettingsPref.xml` 24 | 25 | * AES key: `FINAL_KEY` 26 | * token: `TOKEN` 27 | 28 | Edit `dump/tokens.yaml` with your data by: 29 | * `AES_KEY`: AES key from `GetContactSettingsPref.xml` 30 | * `ANDROID_OS`: For example `android 5.0` 31 | * `DEVICE_ID`: For example `14130e29cebe9c39` 32 | * `IS_ACTIVE`: `true` if your token is valid 33 | * `REMAIN_COUNT`: Any natural num if your token is valid 34 | * `TOKEN`: token from `GetContactSettingsPref.xml` 35 | 36 | ## How to run 37 | 38 | Install [tesseract](https://github.com/tesseract-ocr/tesseract/wiki) to bypass captcha 39 | 40 | ### Python3 41 | 42 | #### Create and run venv 43 | ```shell script 44 | [ ! -d venv ] && python3 -m venv venv; source venv/bin/activate 45 | ``` 46 | 47 | #### Install requirements 48 | ```shell script 49 | pip3 install -r requirements.txt 50 | ``` 51 | 52 | #### Console output 53 | ```shell script 54 | python3 ./src/main.py -p +792910453XX 55 | ``` 56 | Output: 57 | ``` 58 | Phone: +792910453XX 59 | User: Андрей Тимофеев 60 | Tag list: 61 | Андрей Тимофеев 62 | Андрей Спб 63 | Андрей Челентос 64 | Андрей Катин 65 | Андрей 66 | Онлрей 67 | Экс Бойфренд Aka Реальный Долбоеб 68 | Андрей Chelentos 69 | Andrey Tymofeev 70 | Андрей Тим 71 | Андрюша : 72 | Андрей 💑 73 | .andrey 74 | Andrey 75 | Remain count: 194 76 | ``` 77 | 78 | #### Console JSON-format output 79 | ```shell script 80 | python3 ./src/main.py -j -p +792910453XX 81 | ``` 82 | Output: 83 | ```json5 84 | {'name': None, 'phoneNumber': '+792910453XX', 'country': 'RU', 'displayName': 'Андрей Тимофеев', 'profileImage': None, 'email': None, 'is_spam': False, 'remain_count': 194, 'tags': ['Андрей Тимофеев', 'Андрей Спб', 'Андрей Челентос', 'Андрей Катин', 'Андрей', 'Онлрей', 'Экс Бойфренд Aka Реальный Долбоеб', 'Андрей Chelentos', 'Andrey Tymofeev', 'Андрей Тим', 'Андрюша :', 'Андрей 💑', '.andrey', 'Andrey']} 85 | ``` 86 | 87 | #### Debug mode 88 | ```shell script 89 | python3 ./src/main.py -v -p +792910453XX 90 | ``` 91 | Output: 92 | ``` 93 | [2020-08-09 21:19:30] Call print_information_by_phone with phone +792910453XX 94 | [2020-08-09 21:19:30] Call get_information_by_phone with phone +792910453XX 95 | [2020-08-09 21:19:30] Call get_name_by_phone with phoneNumber +792910453XX 96 | [2020-08-09 21:19:30] Call _send_post with url: https://pbssrv-centralevents.com/v2.5/search data: {"data": "IntagsrX4IGrPHP7pfJfl9jBqULuZK25pFdPYdCGjSEovlUiPr9rdM/O1rcOcW6WPKUONujPcQKWBlEVzv5R6sFelyff9c5su48kI6fqBZpjVGohthrvzOKtuCC0Tne9N1v30b0PL4HKQrmWPlik8kGCSqajsivlJ01a+e9ELkXk/AjaHrm9cZVxyCfZpx4D"} 97 | ... 98 | 'Try premium free', 'subsInfoButtonIntroText': 'Try Getcontact Premium now to increase tag view limit and enjoy other Premium Benefits.'}}} 99 | [2020-08-09 21:19:31] Call _print_beauty_output with data {'name': None, 'phoneNumber': '+792910453XX', 'country': 'RU', 'displayName': 'Not Found', 'profileImage': None, 'email': None, 'is_spam': False, 'tags': []} 100 | Phone: +792910453XX 101 | User: Not Found 102 | ``` 103 | 104 | 105 | 106 | ### Docker 107 | ```shell script 108 | chmod +x ./run.sh 109 | sudo docker build . -t getcontact 110 | sudo docker run -t getcontact -p +792910453XX 111 | ``` 112 | 113 | ### Donate for coffee 114 | 115 | | Boosty | 116 | | ------------- | 117 | | | 118 | -------------------------------------------------------------------------------- /captcha/PwwDvtQdNY.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/PwwDvtQdNY.jpg -------------------------------------------------------------------------------- /captcha/UWSNxarfQF.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/UWSNxarfQF.jpg -------------------------------------------------------------------------------- /captcha/WWVlyLtFFW.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/WWVlyLtFFW.jpg -------------------------------------------------------------------------------- /captcha/aaUowQrqih.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/aaUowQrqih.jpg -------------------------------------------------------------------------------- /captcha/cmnCgoRzdr.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/cmnCgoRzdr.jpg -------------------------------------------------------------------------------- /captcha/lSrMgaZmcW.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/lSrMgaZmcW.jpg -------------------------------------------------------------------------------- /captcha/xGnxSJPGCh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/captcha/xGnxSJPGCh.jpg -------------------------------------------------------------------------------- /dump/tokens.yaml: -------------------------------------------------------------------------------- 1 | user_1: 2 | AES_KEY: 5d0bd387b95f2ced93278dd00f475578aba6dfc7b8a858b7c26e361c6e7d1b87 3 | ANDROID_OS: android 5.0 4 | DEVICE_ID: 14130e29cebe9c39 5 | IS_ACTIVE: true 6 | REMAIN_COUNT: 197 7 | TOKEN: gyUhx4ef008c825588f49362f6e6bb6fd59ee19742ee7f8002dde3f3906 8 | user_2: 9 | AES_KEY: 208507eb36f0adbd9648b0ceb37ad0ffbf28a82103e2cbbaa8b9596e33437f2e 10 | ANDROID_OS: android 5.0 11 | DEVICE_ID: 14130e29cebe9c39 12 | IS_ACTIVE: true 13 | REMAIN_COUNT: 200 14 | TOKEN: gyWGCfe3a09d5f75ec67178d8b5e13c70bb1ed8fa69050cd4f5c8171a92 15 | user_3: 16 | AES_KEY: d05ebd64b9d2bea5de2b7a91ab3391c678224e32e4b617af2da649e74ac5327e 17 | ANDROID_OS: android 5.0 18 | DEVICE_ID: 14130e29cebe9c39 19 | IS_ACTIVE: true 20 | REMAIN_COUNT: 200 21 | TOKEN: gSdxMf0882317a683ed083abbfa5ecf3ea6caf8422e4d976ba944335b1e 22 | user_4: 23 | AES_KEY: 764fe50cdb21a07c4c049377754c2f50f127febb3aa67e03c7334f414e0fa7db 24 | ANDROID_OS: android 5.0 25 | DEVICE_ID: 8edbe110a4079828 26 | IS_ACTIVE: false 27 | REMAIN_COUNT: 200 28 | TOKEN: hphofd5757307f5dbffce25ae9ef4bd54dc56e770bc763215e7dc4f02e3 29 | user_5: 30 | AES_KEY: fcf0ea030e7c03ea507417bd7508e8cf36bbe867e1e5fdb8d506e9aae9d45a10 31 | ANDROID_OS: android 6.0 32 | DEVICE_ID: 14130e29cebe9c40 33 | IS_ACTIVE: true 34 | REMAIN_COUNT: 98 35 | TOKEN: rJpPb662955e6c63ea25dbb180afbbdcebfe63f99cf829053eeaea1c4cb 36 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | crypto==1.4.1 2 | pytesseract==0.3.2 3 | PyYAML==5.3 4 | requests~=2.24.0 5 | pycryptodome==3.9.6 6 | numpy~=1.19.4 7 | bs4~=0.0.1 8 | beautifulsoup4~=4.9.3 9 | opencv-python~=4.4.0.46 10 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | python3 ./src/main.py "$@" 4 | -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/src/__init__.py -------------------------------------------------------------------------------- /src/getcontact/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kovinevmv/getcontact/86900c219001e3703d776197f21a3a82742b85fa/src/getcontact/__init__.py -------------------------------------------------------------------------------- /src/getcontact/cipher.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import codecs 3 | import hashlib 4 | import hmac 5 | from Crypto.Cipher import AES 6 | 7 | from getcontact.config import config 8 | 9 | 10 | class Cipher: 11 | def __init__(self, config_=None): 12 | self.update_config(config_) 13 | self.BS = 16 14 | 15 | def update_config(self, config_): 16 | self.config = config_ if config_ else config 17 | self.update_cipher() 18 | 19 | def update_cipher(self): 20 | self.cipher_aes = AES.new( 21 | codecs.decode(self.config.AES_KEY, "hex"), AES.MODE_ECB 22 | ) 23 | 24 | def pad_data(self, s): 25 | return bytes( 26 | s + (self.BS - len(s) % self.BS) * chr(self.BS - len(s) % self.BS), "utf8" 27 | ) 28 | 29 | def unpad_data(self, s): 30 | return s[0 : -ord(s[-1])] 31 | 32 | def create_signature(self, payload, timestamp): 33 | message = bytes(self.format_message_to_hmac(payload, timestamp), "utf8") 34 | secret = bytes(self.config.HMAC_KEY, "utf8") 35 | signature = self.encode_b64( 36 | hmac.new(secret, msg=message, digestmod=hashlib.sha256).digest() 37 | ) 38 | return signature.decode() 39 | 40 | def format_message_to_hmac(self, msg, timestamp): 41 | return f"{timestamp}-{msg}" 42 | 43 | def encode_b64(self, data): 44 | return base64.b64encode(data) 45 | 46 | def decode_b64(self, data): 47 | return base64.b64decode(data) 48 | 49 | def decrypt_AES(self, data): 50 | return self.unpad_data(self.cipher_aes.decrypt(data).decode()) 51 | 52 | def encrypt_AES(self, data): 53 | return self.cipher_aes.encrypt(self.pad_data(data)) 54 | 55 | def encrypt_AES_b64(self, data): 56 | return self.encode_b64(self.encrypt_AES(data)).decode() 57 | 58 | def decrypt_AES_b64(self, data): 59 | return self.decrypt_AES(self.decode_b64(data)) 60 | 61 | 62 | if __name__ == "__main__": 63 | pass 64 | -------------------------------------------------------------------------------- /src/getcontact/config.py: -------------------------------------------------------------------------------- 1 | class Config: 2 | """ 3 | Change TOKEN, AES_KEY to your in tokens.yaml. 4 | Find it in /data/data/app.source.getcontact/shared_prefs/GetContactSettingsPref.xml 5 | Required ROOT on your device. 6 | 7 | Actual settings information at time of GetContact application version 4.9.1 8 | 9 | Other parameters can be changed as desired or if script does not work with default values :) 10 | 11 | * TOKEN: TOKEN 12 | * AES_KEY: FINAL_KEY 13 | * APP_VERSION: version of installed GetContact apk. 14 | * API_VERSION: API version of current app, can be found in intercepted packets 15 | * ANDROID_OS: version of your Android OS, can be found in intercepted packets 16 | * DEVICE_ID: ID of your ANDROID device, can be found in intercepted packets or *#*#8255#*#* 17 | * COUNTRY: country 18 | * HMAC_KEY: HMAC key for generation secure data sending 19 | * MOD_EXP: Mod exponent or AES key generation 20 | """ 21 | 22 | # Will be changed using dump/tokens.yaml data 23 | TOKEN = "rJrKc01a26b9a013ff3a35f6753820971f63c3f9f8571c8012e3c9633ba" 24 | AES_KEY = "dd074ed6e8c64bc65cabdfdca052f16b187e5cbbc501e22d98dae2f9899fe543" 25 | 26 | # May need to be changed 27 | APP_VERSION = "5.6.2" 28 | API_VERSION = "v2.8" 29 | ANDROID_OS = "android 6.0" 30 | DEVICE_ID = "8edbe110a4079830" 31 | 32 | # Default values 33 | COUNTRY = "RU" 34 | HMAC_KEY = "y1gY|J%&6V kTi$>_Ali8]/xCqmMMP1$*)I8FwJ,*r_YUM 4h?@7+@#<>+w-e3VW" 35 | MOD_EXP = 900719925481 36 | 37 | VERBOSE = False 38 | 39 | 40 | config = Config() 41 | -------------------------------------------------------------------------------- /src/getcontact/config_updater.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | import os 3 | 4 | from getcontact.config import config 5 | from getcontact.logger import Log 6 | 7 | 8 | class UpdateConfig: 9 | def __init__(self): 10 | self.config = config 11 | self.tokens_file = ( 12 | os.path.dirname(os.path.abspath(__file__)) + "/../../dump/tokens.yaml" 13 | ) 14 | self.tokens_dict = self.read_yaml() 15 | self.update_status() 16 | 17 | def read_yaml(self): 18 | with open(self.tokens_file, "r") as f: 19 | data = yaml.safe_load(f.read()) 20 | return data if data else {} 21 | 22 | def write_yaml(self, data): 23 | with open(self.tokens_file, "w") as f: 24 | f.write(yaml.dump(data, default_flow_style=False)) 25 | 26 | def update_remain_count_by_token(self, token, remain_count): 27 | for values in self.tokens_dict.values(): 28 | if values["TOKEN"] == token: 29 | values["REMAIN_COUNT"] = remain_count 30 | self.update_status() 31 | 32 | def decrease_remain_count_by_token(self, token): 33 | for values in self.tokens_dict.values(): 34 | if values["TOKEN"] == token: 35 | values["REMAIN_COUNT"] -= 1 36 | self.update_status() 37 | 38 | def update_status(self): 39 | for values in self.tokens_dict.values(): 40 | values["IS_ACTIVE"] = values["REMAIN_COUNT"] > 0 41 | self.save_dict() 42 | self.set_new_token(self.get_active()) 43 | 44 | def save_dict(self): 45 | self.write_yaml(self.tokens_dict) 46 | 47 | def get_all_active(self): 48 | return list( 49 | filter(lambda x: x["IS_ACTIVE"], [i[1] for i in self.tokens_dict.items()]) 50 | ) 51 | 52 | def get_any_active(self): 53 | tokens = self.get_all_active() 54 | if tokens: 55 | return tokens[0] 56 | 57 | Log.error("No valid token detected. Script will crash") 58 | return {} 59 | 60 | def get_new_active(self): 61 | current_token = self.config.TOKEN 62 | active = self.get_all_active() 63 | for values in active: 64 | if values["TOKEN"] != current_token: 65 | return values 66 | return None 67 | 68 | def get_active(self): 69 | active = self.get_all_active() 70 | return self.get_new_active() if len(active) >= 2 else self.get_any_active() 71 | 72 | def set_new_token(self, token): 73 | if "TOKEN" in token: 74 | self.config.TOKEN = token["TOKEN"] 75 | self.config.AES_KEY = token["AES_KEY"] 76 | self.config.ANDROID_OS = token["ANDROID_OS"] 77 | self.config.DEVICE_ID = token["DEVICE_ID"] 78 | 79 | def get_config(self): 80 | return self.config 81 | -------------------------------------------------------------------------------- /src/getcontact/decode_captcha.py: -------------------------------------------------------------------------------- 1 | import base64 2 | import random 3 | import re 4 | import string 5 | 6 | import cv2 7 | import numpy as np 8 | import pytesseract 9 | 10 | 11 | class CaptchaDecode: 12 | def decode_response(self, response): 13 | image_b64 = response["result"]["image"] 14 | image_data = self.decode_b64(image_b64) 15 | path = self.generate_random_name() 16 | self.write_data_image(image_data, path) 17 | return self.decrypt(path), path 18 | 19 | def decode_path(self, path): 20 | return self.decrypt(path) 21 | 22 | @staticmethod 23 | def generate_random_name(): 24 | return ( 25 | "captcha/" 26 | + "".join([random.choice(string.ascii_letters) for _ in range(10)]) 27 | + ".jpg" 28 | ) 29 | 30 | @staticmethod 31 | def write_data_image(data, path): 32 | with open(path, "wb") as f: 33 | f.write(data) 34 | 35 | @staticmethod 36 | def decode_b64(data): 37 | return base64.b64decode(data) 38 | 39 | @staticmethod 40 | def decrypt(path): 41 | try: 42 | frame = cv2.imread(path) 43 | hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) 44 | 45 | mask = cv2.inRange(hsv, np.array([30, 120, 0]), np.array([255, 255, 255])) 46 | text = pytesseract.image_to_string( 47 | mask, 48 | config=f"--psm 8 tessedit_char_whitelist={string.ascii_letters + string.digits}", 49 | ) 50 | text = re.sub("[^A-Za-z0-9]", "", text) 51 | except Exception as e: 52 | print(e) 53 | return "" 54 | 55 | return text 56 | -------------------------------------------------------------------------------- /src/getcontact/getcontact.py: -------------------------------------------------------------------------------- 1 | from getcontact.config import config 2 | from getcontact.config_updater import UpdateConfig 3 | from getcontact.logger import Log 4 | from getcontact.requester import Requester 5 | 6 | 7 | def parse_none(data): 8 | return "" if data is None else data 9 | 10 | 11 | class GetContactAPI: 12 | def __init__(self): 13 | self.updater = UpdateConfig() 14 | self.requester = Requester(self.updater.get_config()) 15 | 16 | def get_name_by_phone(self, phoneNumber): 17 | Log.d("Call get_name_by_phone with phoneNumber ", phoneNumber) 18 | response = self.requester.get_phone_name(phoneNumber) 19 | if response: 20 | name = response["result"]["profile"]["name"] 21 | surname = response["result"]["profile"]["surname"] 22 | if not name and not surname: 23 | user_name = None 24 | else: 25 | user_name = f"{parse_none(name)} {parse_none(surname)}" 26 | 27 | country_code = response["result"]["profile"]["countryCode"] 28 | country = response["result"]["profile"]["country"] 29 | 30 | if not country: 31 | country_name = f"{parse_none(country_code)}" 32 | else: 33 | country_name = f"{country} {parse_none(country_code)}" 34 | 35 | result = { 36 | "name": user_name, 37 | "phoneNumber": response["result"]["profile"]["phoneNumber"], 38 | "country": country_name, 39 | "displayName": response["result"]["profile"]["displayName"], 40 | "profileImage": response["result"]["profile"]["profileImage"], 41 | "email": response["result"]["profile"]["email"], 42 | "is_spam": response["result"]["spamInfo"]["degree"] == "high", 43 | } 44 | 45 | remain_count = response["result"]["subscriptionInfo"]["usage"]["search"][ 46 | "remainingCount" 47 | ] 48 | self.updater.update_remain_count_by_token(config.TOKEN, remain_count) 49 | 50 | return result 51 | 52 | return { 53 | "name": None, 54 | "phoneNumber": phoneNumber, 55 | "country": config.COUNTRY, 56 | "displayName": "Not Found", 57 | "profileImage": None, 58 | "email": None, 59 | "is_spam": False, 60 | } 61 | 62 | def get_tags_by_phone(self, phoneNumber): 63 | Log.d("Call get_tags_by_phone with phoneNumber ", phoneNumber) 64 | response = self.requester.get_phone_tags(phoneNumber) 65 | if response: 66 | result = {"tags": [tag["tag"] for tag in response["result"]["tags"]]} 67 | return result 68 | 69 | return {"tags": []} 70 | 71 | def update_config(self): 72 | self.requester.update_config(self.updater.get_config()) 73 | 74 | def get_name_by_phone_with_change_token(self, phone): 75 | Log.d("Call get_name_by_phone_with_change_token with phone ", phone) 76 | result = self.get_name_by_phone(phone) 77 | self.update_config() 78 | return result 79 | 80 | def get_information_by_phone(self, phone): 81 | Log.d("Call get_information_by_phone with phone ", phone) 82 | result_name = self.get_name_by_phone(phone) 83 | result_tags = self.get_tags_by_phone(phone) 84 | 85 | self.update_config() 86 | 87 | return dict(**result_name, **result_tags) 88 | 89 | def print_information_by_phone(self, phone): 90 | Log.d("Call print_information_by_phone with phone ", phone) 91 | data = self.get_information_by_phone(phone) 92 | self._print_beauty_output(data) 93 | 94 | def get_from_file(self, file): 95 | Log.d("Call get_from_file with file ", file) 96 | with open(file, "r") as f: 97 | phones = f.read().split("\n") 98 | for phone in phones: 99 | self.print_information_by_phone(phone) 100 | 101 | def _print_beauty_output(self, data): 102 | Log.d("Call _print_beauty_output with data ", data) 103 | print("Phone:", data["phoneNumber"]) 104 | print("User:", data["displayName"]) 105 | if "tags" in data.keys() and data["tags"]: 106 | print("Tag list: ") 107 | for tag in data["tags"]: 108 | print( 109 | "\t", 110 | tag.encode("utf-8", errors="replace").decode( 111 | "utf-8", errors="replace" 112 | ), 113 | ) 114 | -------------------------------------------------------------------------------- /src/getcontact/logger.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from getcontact.config import config 3 | 4 | 5 | class Log: 6 | @staticmethod 7 | def d(*args): 8 | if config.VERBOSE: 9 | print( 10 | datetime.now().strftime("[%Y-%m-%d %H:%M:%S]"), 11 | " ".join([str(arg) for arg in args]), 12 | ) 13 | 14 | @staticmethod 15 | def error(*args): 16 | if config.VERBOSE: 17 | print( 18 | datetime.now().strftime("[%Y-%m-%d %H:%M:%S]"), 19 | "error", 20 | " ".join([str(arg) for arg in args]), 21 | ) 22 | -------------------------------------------------------------------------------- /src/getcontact/phone_negative.py: -------------------------------------------------------------------------------- 1 | import re 2 | import requests 3 | from bs4 import BeautifulSoup 4 | 5 | 6 | def parse_page(text): 7 | soup = BeautifulSoup(text, "html.parser") 8 | categories = soup.findAll("div", {"class": "categories"}) 9 | ratings = soup.findAll("div", {"class": "ratings"}) 10 | comments = soup.findAll("span", {"class": "review_comment"}) 11 | return {"categories": categories, "ratings": ratings, "comments": comments} 12 | 13 | 14 | def extract_text(data): 15 | categories = data["categories"] 16 | ratings = data["ratings"] 17 | comments = data["comments"] 18 | 19 | tags_categories = [] 20 | if categories: 21 | for category in categories: 22 | info = category.findAll("li", {"class": "active"}, text=True) 23 | tags_categories.extend([re.sub(r"\d+x ", "", i.text) for i in info]) 24 | 25 | tags_ratings = [] 26 | if ratings: 27 | for rating in ratings: 28 | info = rating.findAll("li", {"class": "active"}, text=True) 29 | tags_ratings.extend([i.text for i in info]) 30 | 31 | tags_comments = [] 32 | if comments: 33 | for comment in comments: 34 | comment = comment.text 35 | if not comment: 36 | continue 37 | comment = comment if len(comment) < 40 else comment[:40] + "..." 38 | tags_comments.append(comment) 39 | return { 40 | "category": tags_categories[0] if tags_categories else tags_categories, 41 | "rating": tags_ratings[0] if tags_ratings else tags_ratings, 42 | "comments": list(set(tags_comments))[:7], 43 | } 44 | 45 | 46 | def is_spam(data): 47 | rating = data["rating"] 48 | is_spam_ = False 49 | if rating: 50 | count, status = rating.split(" ") 51 | if "отрицател" in status and int(count[:-1]) > 10: 52 | is_spam_ = True 53 | return is_spam_ 54 | 55 | 56 | def convert(data): 57 | is_spam_ = is_spam(data) 58 | rating = data["rating"] 59 | data["rating"] = rating.split(" ")[1] if rating else rating 60 | 61 | return {**data, "is_spam": is_spam_} 62 | 63 | 64 | def get_info(phone): 65 | response = requests.get(f"https://www.neberitrubku.ru/nomer-telefona/{phone}") 66 | data = parse_page(response.text) 67 | data = extract_text(data) 68 | return convert(data) 69 | -------------------------------------------------------------------------------- /src/getcontact/requester.py: -------------------------------------------------------------------------------- 1 | import json 2 | import time 3 | 4 | import requests 5 | from getcontact.cipher import Cipher 6 | from getcontact.config import config 7 | from getcontact.config_updater import UpdateConfig 8 | from getcontact.logger import Log 9 | 10 | 11 | class Requester: 12 | def __init__(self, config_=None): 13 | current_config = config_ if config_ else config 14 | self.cipher = Cipher(current_config) 15 | self.updater = UpdateConfig() 16 | self.update_timestamp() 17 | self.set_dict() 18 | 19 | def set_dict(self): 20 | self.base_url = "https://pbssrv-centralevents.com" 21 | self.base_uri_api = f"/{config.API_VERSION}/" 22 | self.methods = { 23 | "number-detail": "details", 24 | "search": "search", 25 | "verify-code": "", 26 | "register": "", 27 | } 28 | 29 | self.headers = { 30 | "X-App-Version": config.APP_VERSION, 31 | "X-Token": config.TOKEN, 32 | "X-Os": config.ANDROID_OS, 33 | "X-Client-Device-Id": config.DEVICE_ID, 34 | "Content-Type": "application/json; charset=utf-8", 35 | "Connection": "close", 36 | "Accept-Encoding": "gzip, deflate", 37 | "X-Req-Timestamp": self.timestamp, 38 | "X-Req-Signature": "", 39 | "X-Encrypted": "1", 40 | } 41 | 42 | self.request_data = { 43 | "countryCode": config.COUNTRY, 44 | "source": "", 45 | "token": config.TOKEN, 46 | } 47 | 48 | def update_config(self, config_): 49 | self.cipher.update_config(config_) 50 | self.set_dict() 51 | 52 | def update_timestamp(self): 53 | self.timestamp = str(time.time()).split(".")[0] 54 | 55 | def prepare_payload(self, data): 56 | return json.dumps(data).replace(" ", "").replace("~", " ") 57 | 58 | def _send_post(self, url, data): 59 | Log.d("Call _send_post with url:", url, "data:", data) 60 | response = requests.post(url, data=data, headers=self.headers) 61 | self.update_timestamp() 62 | return self._parse_response(response) 63 | 64 | def send_request_encrypted(self, url, data): 65 | self.headers["X-Encrypted"] = "1" 66 | return self._send_post( 67 | url, json.dumps({"data": self.cipher.encrypt_AES_b64(data)}) 68 | ) 69 | 70 | def send_request_no_encrypted(self, url, data): 71 | self.headers["X-Encrypted"] = "0" 72 | return self._send_post(url, data) 73 | 74 | def _parse_response(self, response): 75 | Log.d("Call _parse_response with response:", response.text) 76 | 77 | if response.status_code == 200: 78 | return True, response.json()["data"] 79 | if response.status_code == 201: 80 | return True, response.json() 81 | 82 | Log.d("Not correct answer from server.") 83 | response = response.json() 84 | if "data" in response.keys(): 85 | response = response["data"] 86 | Log.d("Response: ", response) 87 | 88 | response = json.loads(self.cipher.decrypt_AES_b64(response)) 89 | Log.d("Response decrypted: ", response) 90 | 91 | errorCode = response["meta"]["errorCode"] 92 | 93 | if errorCode == "403004": 94 | print("Captcha is detected. ") 95 | from getcontact.decode_captcha import CaptchaDecode 96 | 97 | c = CaptchaDecode() 98 | code, path = c.decode_response(response) 99 | self.decode_captcha(code) 100 | print("Try to decode:", code, path) 101 | 102 | return False, {"repeat": True} 103 | if errorCode == "404001": 104 | print("No information about phone in database") 105 | if errorCode == "403021": 106 | # Token dead 107 | Log.d("Token is dead.", config.TOKEN) 108 | self.updater.update_remain_count_by_token(config.TOKEN, 0) 109 | else: 110 | Log.d("Unhandled error with response", response) 111 | Log.d("Try to use correct token") 112 | return False, {} 113 | 114 | def send_req_to_the_server(self, url, payload, no_encryption=False): 115 | payload = self.prepare_payload(payload) 116 | self.headers["X-Req-Signature"] = self.cipher.create_signature( 117 | payload, self.timestamp 118 | ) 119 | if no_encryption: 120 | is_ok, response = self.send_request_no_encrypted(url, payload) 121 | else: 122 | is_ok, response = self.send_request_encrypted(url, payload) 123 | 124 | if is_ok: 125 | # print(json.loads(self.cipher.decrypt_AES_b64(response))) 126 | return json.loads(self.cipher.decrypt_AES_b64(response)) 127 | if not is_ok and "repeat" in response.keys() and response["repeat"]: 128 | return self.repeat_last_task() 129 | 130 | return response 131 | 132 | def repeat_last_task(self): 133 | function = self.current_task["function"] 134 | phone = self.current_task["phone"] 135 | 136 | if function == "get_phone_name": 137 | return self.get_phone_name(phone) 138 | if function == "get_phone_tags": 139 | return self.get_phone_tags(phone) 140 | 141 | Log.error("Incorrect task for repeat") 142 | return None 143 | 144 | def get_phone_name(self, phoneNumber): 145 | self.current_task = {"function": "get_phone_name", "phone": phoneNumber} 146 | self.update_config(config) 147 | method = "search" 148 | self.request_data["source"] = self.methods[method] 149 | self.request_data["phoneNumber"] = phoneNumber 150 | return self.send_req_to_the_server( 151 | self.base_url + self.base_uri_api + method, self.request_data 152 | ) 153 | 154 | def get_phone_tags(self, phoneNumber): 155 | self.current_task = {"function": "get_phone_tags", "phone": phoneNumber} 156 | 157 | self.update_config(config) 158 | method = "number-detail" 159 | self.request_data["source"] = self.methods[method] 160 | self.request_data["phoneNumber"] = phoneNumber 161 | return self.send_req_to_the_server( 162 | self.base_url + self.base_uri_api + method, self.request_data 163 | ) 164 | 165 | def decode_captcha(self, code): 166 | self.update_config(config) 167 | captcha_data = {"token": config.TOKEN, "validationCode": code} 168 | return self.send_req_to_the_server( 169 | self.base_url + self.base_uri_api + "verify-code", captcha_data 170 | ) 171 | -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from getcontact.getcontact import GetContactAPI 4 | from getcontact.config import config 5 | 6 | description = "Get information about phone number from databases of GetContact" 7 | 8 | parser = argparse.ArgumentParser( 9 | description=description, formatter_class=argparse.RawTextHelpFormatter 10 | ) 11 | parser.add_argument("-p", "--phone", help="Phone number (example: +78005553535)") 12 | parser.add_argument( 13 | "-j", "--json", help="Print output in JSON format", action="store_true" 14 | ) 15 | parser.add_argument("-v", "--verbose", help="Log", action="store_true") 16 | 17 | args = parser.parse_args() 18 | 19 | phone = args.phone 20 | getcontact = GetContactAPI() 21 | config.VERBOSE = args.verbose 22 | 23 | if args.json: 24 | print(getcontact.get_information_by_phone(phone)) 25 | else: 26 | getcontact.print_information_by_phone(phone) 27 | --------------------------------------------------------------------------------