├── LICENSE ├── README.md ├── main.py └── requirements.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Joy 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 | # SMS Forwarder 2 | 3 | This is a Python script that forwards SMS messages to a Discord channel. It utilizes the Termux API to access SMS messages on an Android device and sends the messages to Discord using a webhook. 4 | 5 | ## Setup 6 | 7 | 1. Install [Termux](https://f-droid.org/repo/com.termux_118.apk) & [Termux Api](https://f-droid.org/repo/com.termux.api_51.apk) on your Android device. 8 | 2. Install the required packages by running the following command in Termux: 9 | 10 | ```shell 11 | pkg install python 12 | pkg install git 13 | ``` 14 | 15 | 3. Clone this repository by running the following command : 16 | 17 | ```shell 18 | git clone https://github.com/JOY6IX9INE/Sms-Forwarder 19 | ``` 20 | 21 | 4. Change to the cloned directory : 22 | 23 | ```shell 24 | cd SMS-FORWARDER 25 | ``` 26 | 27 | 5. Install the necessary Python packages by running the following command : 28 | 29 | ```shell 30 | pip install -r requirements.txt 31 | ``` 32 | 33 | 6. Open the script file `main.py` in a text editor and replace the `webhook_url` variable with your Discord webhook URL. Make sure the URL is valid and has the appropriate permissions. 34 | 35 | 7. Save the changes to the script file. 36 | 37 | ## Usage 38 | 39 | 1. Open Termux on your Android device. 40 | 2. Change to the directory where the script is located : 41 | 42 | ```shell 43 | cd path/to/Sms-Forwarder 44 | ``` 45 | 46 | 3. Run the script by executing the following command : 47 | 48 | ```shell 49 | python main.py 50 | ``` 51 | 52 | 4. The script will start monitoring SMS messages and forward any messages it detects to the specified Discord channel. 53 | 54 | ## Additional Notes 55 | 56 | - You can customize the filters used to detect OTP or other messages by modifying the `filters` list in the script. Add or remove keywords as needed. 57 | - Press `Ctrl + C` to stop the script. 58 | 59 | **Note:** This script is specifically designed for Android devices running Termux and may not work on other platforms. 60 | 61 | # Disclaimer 62 | This tool is created for educational purposes and ethical use only. Any misuse of this tool for malicious purposes is not condoned. The developers of this tool are not responsible for any illegal or unethical activities carried out using this tool. 63 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import os, json, datetime, time, requests, re 2 | 3 | class SMSForwarder: 4 | def __init__(self): 5 | self.webhook_url = "https://discord.com/api/webhooks/XXXX/XXXX" 6 | self.last_sms_time = self._get_last_sms_time() 7 | self.filters = ["otp", "one time password", "OTP"] 8 | 9 | def _get_last_sms_time(self): 10 | tmp_file = "tmpLastTime.txt" 11 | if os.path.exists(tmp_file): 12 | with open(tmp_file, "r") as file: 13 | return datetime.datetime.fromisoformat(file.read()) 14 | else: 15 | last_sms = datetime.datetime.now() 16 | with open(tmp_file, "w") as file: 17 | file.write(str(last_sms)) 18 | return last_sms 19 | 20 | def _update_last_sms_time(self, timestamp): 21 | tmp_file = "tmpLastTime.txt" 22 | with open(tmp_file, "w") as file: 23 | file.write(timestamp) 24 | 25 | def _send_to_discord(self, message, numbers): 26 | headers = {'Content-Type': 'application/json'} 27 | full_message = f"> {message}" 28 | numbers_str = ', '.join(numbers) 29 | embed = { 30 | "title": full_message, 31 | "description": f"```{numbers_str}```", 32 | "author": { 33 | "name": "OTP SMS FORWARDER", 34 | "icon_url": "https://cdn.discordapp.com/emojis/1052840053950402600.png" 35 | }, 36 | "thumbnail": { 37 | "url": "https://cdn.discordapp.com/emojis/1127296081710039180.png" 38 | }, 39 | "footer": { 40 | "text": "Forwarded From Smart Phone by SMS Forwarder", 41 | "icon_url": "https://cdn.discordapp.com/emojis/1095997599036739594.png" 42 | }, 43 | "color": 0x00FF00 44 | } 45 | payload = {"embeds": [embed]} 46 | response = requests.post(self.webhook_url, headers=headers, json=payload) 47 | return response 48 | 49 | def process_sms(self, sms): 50 | if datetime.datetime.fromisoformat(sms['received']) > self.last_sms_time: 51 | for f in self.filters: 52 | if f in sms['body'].lower() and sms['type'] == "inbox": 53 | print("[!] Found an OTP Message, Forwarding to Discord...") 54 | response = self._send_to_discord(sms['body'], re.findall(r'\d+', sms['body'])) 55 | if response.status_code == 204: 56 | print("[+] Successfully Forwarded Message to Discord") 57 | self._update_last_sms_time(sms['received']) 58 | else: 59 | print("[!] Failed to Forward Message to Discord\n[!] Please Double Check if Everything is OK") 60 | 61 | def main(): 62 | os.system('clear') 63 | print(""" 64 | _ _____ __ ___ _____ ____ 65 | | |/ _ \ \ / / / _ \_ _| _ \ 66 | _ | | | | \ V / | | | || | | |_) | 67 | | |_| | |_| || | | |_| || | | __/ 68 | \___/ \___/ |_| \___/ |_| |_|""") 69 | print("[!] Welcome to Joy SMS Forwarder") 70 | print("[!] You Can Press Ctrl + c To Exit The Script") 71 | 72 | forwarder = SMSForwarder() 73 | 74 | while True: 75 | time.sleep(1) 76 | jdata = os.popen("termux-sms-list").read() 77 | jd = json.loads(jdata) 78 | 79 | for j in jd: 80 | forwarder.process_sms(j) 81 | 82 | if __name__ == "__main__": 83 | main() 84 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | --------------------------------------------------------------------------------