{"id":22665223,"url":"https://github.com/volkansah/tor-network-application-with-stem-and-scapy","last_synced_at":"2025-04-12T08:43:53.987Z","repository":{"id":248493996,"uuid":"805720028","full_name":"VolkanSah/Tor-Network-Application-with-Stem-and-Scapy","owner":"VolkanSah","description":"This project demonstrates how to use the Stem library to interact with the Tor network and the Scapy library for network packet manipulation. The goal is to create an application that can leverage Tor for anonymized network analysis, including scanning both Onion and regular websites.","archived":false,"fork":false,"pushed_at":"2024-07-15T09:15:19.000Z","size":414,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T22:51:27.210Z","etag":null,"topics":["example-code","examples","hacking","network","nikto","nmap","python","scapy","security","socat","stem","tor"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VolkanSah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["volkansah"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"custom":null}},"created_at":"2024-05-25T09:18:38.000Z","updated_at":"2025-03-20T15:18:27.000Z","dependencies_parsed_at":"2024-11-27T06:30:59.909Z","dependency_job_id":null,"html_url":"https://github.com/VolkanSah/Tor-Network-Application-with-Stem-and-Scapy","commit_stats":null,"previous_names":["volkansah/tor-network-application-with-stem-and-scapy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FTor-Network-Application-with-Stem-and-Scapy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FTor-Network-Application-with-Stem-and-Scapy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FTor-Network-Application-with-Stem-and-Scapy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VolkanSah%2FTor-Network-Application-with-Stem-and-Scapy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VolkanSah","download_url":"https://codeload.github.com/VolkanSah/Tor-Network-Application-with-Stem-and-Scapy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543825,"owners_count":21121837,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["example-code","examples","hacking","network","nikto","nmap","python","scapy","security","socat","stem","tor"],"created_at":"2024-12-09T13:29:32.924Z","updated_at":"2025-04-12T08:43:53.965Z","avatar_url":"https://github.com/VolkanSah.png","language":null,"funding_links":["https://github.com/sponsors/volkansah"],"categories":[],"sub_categories":[],"readme":"# Tor Network Application with Stem and Scapy (TNASS)\n###### update 07/2024\n![TNA-SS](tnass.jpg)\nSecurity comes at a high price in life. Freedom, security, and democracy are not guaranteed. Small tools always bring advantages to the user that can be used to automate processes. These creative scripts aim to show you how simple functions can save a lot of time and money, eliminating the need to purchase expensive security packages for basic scanning tasks.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Connecting to a Running Tor Process](#connecting-to-a-running-tor-process)\n  - [Starting a New Tor Process](#starting-a-new-tor-process)\n  - [Sending Packets through Tor with Scapy](#sending-packets-through-tor-with-scapy)\n  - [Single Domain Security Check](#single-domain-security-check)\n  - [Multiple Domains Security Check from File](#multiple-domains-security-check-from-file)\n- [Credits](#credits)\n- [License](#license)\n\n## Introduction\n\nThis project provides an example of how to use Python libraries Stem and Scapy to work with the Tor network. Stem is a library for interacting with Tor, while Scapy is used for creating and manipulating network packets. Together, they allow for anonymized network operations.\n\n## Requirements\n\n- Python 3.x\n- Stem\n- Scapy\n- Tor\n\n## Installation\n\n1. Install Python 3.x from [Python's official website](https://www.python.org/).\n2. Install Stem using pip:\n    ```bash\n    pip install stem\n    ```\n3. Install Scapy using pip:\n    ```bash\n    pip install scapy\n    ```\n4. Ensure Tor is installed and running. You can download and install Tor from [Tor Project's official website](https://www.torproject.org/).\n\n## Usage\n\n### Connecting to a Running Tor Process\n\nTo connect to an existing Tor process and retrieve basic information:\n\n```python\nfrom stem import Signal\nfrom stem.control import Controller\n\nwith Controller.from_port(port = 9051) as controller:\n    controller.authenticate()  # Authenticate if necessary\n    \n    print(\"Tor Version:\", controller.get_version())\n    print(\"Allowed SocksPort:\", controller.get_conf(\"SocksPort\"))\n    \n    # Request a new identity\n    controller.signal(Signal.NEWNYM)\n    print(\"New identity requested\")\n```\n\n### Starting a New Tor Process\n\nTo start a new Tor process directly from your Python script:\n\n```python\nfrom stem.process import launch_tor_with_config\n\ntor_process = launch_tor_with_config(\n    config = {\n        'SocksPort': '9050',\n        'ControlPort': '9051',\n    },\n    init_msg_handler = lambda line: print(line),\n)\n\nprint(\"Tor process started\")\n\n# Terminate the Tor process\ntor_process.terminate()\n``` \n\n### Sending Packets through Tor with Scapy\n\nTo send network packets through the Tor network using Scapy:\n\n```python\nfrom scapy.all import *\nimport socks\nimport socket\n\n# Set up Tor Socks proxy\nsocks.set_default_proxy(socks.SOCKS5, \"127.0.0.1\", 9050)\nsocket.socket = socks.socksocket\n\n# Create and send a simple ICMP packet\npacket = IP(dst=\"8.8.8.8\")/ICMP()\nresponse = sr1(packet, timeout=10)\n\nif response:\n    response.show()\nelse:\n    print(\"No response received\")\n```\n\n### Single Domain Security Check\n\nThe `single.py` script starts a Tor process, requests a new Tor identity, and performs security checks on a specified domain (both Onion and regular websites) using various tools. The script runs the following steps:\n\n1. **Start Tor Process:** Initializes a Tor process with a specified configuration for `SocksPort` and `ControlPort`.\n2. **Authenticate with Tor Controller:** Connects to the Tor control port and authenticates.\n3. **Request New Identity:** Requests a new Tor identity using the `NEWNYM` signal.\n4. **Perform Security Checks:** Executes security tools (`nmap`, `nikto`, `socat`) on the specified domain and prints the results.\n5. **Terminate Tor Process:** Ends the Tor process after completing the checks.\n\n### Multiple Domains Security Check from File\n\nThe `from_file.py` script extends the functionality of `single.py` by reading multiple domains from a text or CSV file and performing security checks on each. The script follows these steps:\n\n1. **Start Tor Process:** Initializes a Tor process with a specified configuration for `SocksPort` and `ControlPort`.\n2. **Authenticate with Tor Controller:** Connects to the Tor control port and authenticates.\n3. **Read Domains from File:** Reads a list of domains from a text or CSV file.\n4. **Iterate Over Domains:**\n   - Requests a new Tor identity for each domain.\n   - Executes security tools (`nmap`, `nikto`, `socat`) on each domain and prints the results.\n5. **Terminate Tor Process:** Ends the Tor process after processing all domains.\n\n## Possible Automation with These Scripts\n\nThese scripts can be used to automate security testing of both Onion and regular domains. They demonstrate how to:\n- Integrate Tor with security tools.\n- Automate the process of changing Tor identities.\n- Perform repeated security checks on multiple domains.\n\nAdditional tools and tasks that could be automated with similar scripts include:\n- Vulnerability scanning with other tools like OpenVAS.\n- Web application security testing with OWASP ZAP.\n- Network traffic analysis with Wireshark.\n- Automated penetration testing with Metasploit.\n\nBy leveraging these scripts, various security testing and network analysis tasks can be performed automatically within the Tor network.\n\n## Your Support\nIf you find this project useful and want to support it, there are several ways to do so:\n\n- If you find the white paper helpful, please ⭐ it on GitHub. This helps make the project more visible and reach more people.\n- Become a Follower: If you're interested in updates and future improvements, please follow my GitHub account. This way you'll always stay up-to-date.\n- Learn more about my work: I invite you to check out all of my work on GitHub and visit my developer site https://volkansah.github.io. Here you will find detailed information about me and my projects.\n- Share the project: If you know someone who could benefit from this project, please share it. The more people who can use it, the better.\n**If you appreciate my work and would like to support it, please visit my [GitHub Sponsor page](https://github.com/sponsors/volkansah). Any type of support is warmly welcomed and helps me to further improve and expand my work.**\n\nThank you for your support! ❤️\n\n### Credits\nS. Volkan Kücükbudak\n- [Source of this repository](https://github.com/VolkanSah/Tor-Network-Application-with-Stem-and-Scapy)\n\n### License\n\nThis project is licensed under the GPLv3 License.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolkansah%2Ftor-network-application-with-stem-and-scapy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvolkansah%2Ftor-network-application-with-stem-and-scapy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvolkansah%2Ftor-network-application-with-stem-and-scapy/lists"}