procblockweb


Nameprocblockweb JSON
Version 0.12 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/procblockweb
SummaryDisables internet access temporarily for a specified executable and executes it with certain arguments.
upload_time2024-03-29 06:38:57
maintainerNone
docs_urlNone
authorJohannes Fischer
requires_pythonNone
licenseMIT
keywords disable internet
VCS
bugtrack_url
requirements rlogfi
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Disables internet access temporarily for a specified executable and executes it with certain arguments.

## pip install procblockweb

### Tested against Windows 10 / Python 3.11 / Anaconda


## Needs admin rights!

### How does it work?

#### Firewall Control:

The script checks the status of the Windows firewall. If it's off, it temporarily enables it before executing the main task.


#### Execution:

It generates a temporary PowerShell script to create a local user, block outbound and inbound traffic for a specified executable, and then executes the executable with specific arguments.
The script monitors the execution of the specified process and cleans up (e.g., removes the added firewall rules, deletes the created local user) after the process finishes. If you don't close the process before shutting down your PC, this won't happen! It won't hurt, but you will end up with a lot of zombie firewall rules.
    The Python process can be closed after the function returns. The cleanup is done by a background powershell script.

#### Security:

It uses PowerShell to execute tasks, allowing for fine-grained control over system operations.
The script removes added firewall rules and deletes the created local user after the task is completed, ensuring no residual changes are left behind.


#### Flexibility:

The script allows passing arguments to the executed executable and handles both inbound and outbound traffic blocking.
It uses temporary files and directories for operations, ensuring that the system's integrity is maintained.


#### Error Handling:

The script incorporates error handling mechanisms, such as waiting for processes to finish and catching exceptions during cleanup operations.

#### Hidden Execution:

It sets the PowerShell window style to "Hidden" during execution, making the process less conspicuous to users.
Overall, this script provides a robust way to temporarily disable internet access and execute a specified executable with controlled network access, ensuring security and clean-up afterward. It's particularly useful in scenarios where fine-grained control over network traffic and system operations is required.


## Example

```py
from procblockweb import disable_internet_and_run

(
    new_username, # firewall dummy data
    new_password, # firewall dummy data
    new_display_name1, # firewall dummy data
    new_display_name2, # firewall dummy data
    pidofproc, # pid of the process
) = disable_internet_and_run(
    exepath=r"C:\Program Files\BlueStacks_nxt\HD-Player.exe",
    args=("--instance", "Rvc64_26"),
)


(
    new_username_1,
    new_password_1,
    new_display_name1_1,
    new_display_name2_1,
    pidofproc_1,
) = disable_internet_and_run(
    exepath=r"C:\Program Files\Chromium\Application\chrome.exe"
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/procblockweb",
    "name": "procblockweb",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "Disable, internet",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6b/99/7ae54776d02c6114398828fdf4553036af12f6c6d94bc8348f47d4e3f844/procblockweb-0.12.tar.gz",
    "platform": null,
    "description": "\r\n# Disables internet access temporarily for a specified executable and executes it with certain arguments.\r\n\r\n## pip install procblockweb\r\n\r\n### Tested against Windows 10 / Python 3.11 / Anaconda\r\n\r\n\r\n## Needs admin rights!\r\n\r\n### How does it work?\r\n\r\n#### Firewall Control:\r\n\r\nThe script checks the status of the Windows firewall. If it's off, it temporarily enables it before executing the main task.\r\n\r\n\r\n#### Execution:\r\n\r\nIt generates a temporary PowerShell script to create a local user, block outbound and inbound traffic for a specified executable, and then executes the executable with specific arguments.\r\nThe script monitors the execution of the specified process and cleans up (e.g., removes the added firewall rules, deletes the created local user) after the process finishes. If you don't close the process before shutting down your PC, this won't happen! It won't hurt, but you will end up with a lot of zombie firewall rules.\r\n    The Python process can be closed after the function returns. The cleanup is done by a background powershell script.\r\n\r\n#### Security:\r\n\r\nIt uses PowerShell to execute tasks, allowing for fine-grained control over system operations.\r\nThe script removes added firewall rules and deletes the created local user after the task is completed, ensuring no residual changes are left behind.\r\n\r\n\r\n#### Flexibility:\r\n\r\nThe script allows passing arguments to the executed executable and handles both inbound and outbound traffic blocking.\r\nIt uses temporary files and directories for operations, ensuring that the system's integrity is maintained.\r\n\r\n\r\n#### Error Handling:\r\n\r\nThe script incorporates error handling mechanisms, such as waiting for processes to finish and catching exceptions during cleanup operations.\r\n\r\n#### Hidden Execution:\r\n\r\nIt sets the PowerShell window style to \"Hidden\" during execution, making the process less conspicuous to users.\r\nOverall, this script provides a robust way to temporarily disable internet access and execute a specified executable with controlled network access, ensuring security and clean-up afterward. It's particularly useful in scenarios where fine-grained control over network traffic and system operations is required.\r\n\r\n\r\n## Example\r\n\r\n```py\r\nfrom procblockweb import disable_internet_and_run\r\n\r\n(\r\n    new_username, # firewall dummy data\r\n    new_password, # firewall dummy data\r\n    new_display_name1, # firewall dummy data\r\n    new_display_name2, # firewall dummy data\r\n    pidofproc, # pid of the process\r\n) = disable_internet_and_run(\r\n    exepath=r\"C:\\Program Files\\BlueStacks_nxt\\HD-Player.exe\",\r\n    args=(\"--instance\", \"Rvc64_26\"),\r\n)\r\n\r\n\r\n(\r\n    new_username_1,\r\n    new_password_1,\r\n    new_display_name1_1,\r\n    new_display_name2_1,\r\n    pidofproc_1,\r\n) = disable_internet_and_run(\r\n    exepath=r\"C:\\Program Files\\Chromium\\Application\\chrome.exe\"\r\n)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Disables internet access temporarily for a specified executable and executes it with certain arguments.",
    "version": "0.12",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/procblockweb"
    },
    "split_keywords": [
        "disable",
        " internet"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6284636bb64ab0f379d6947873214985a03d75b8a1cd5e775aed9ca9a477810e",
                "md5": "bd31c689b4f924d5a4757d8dd8642085",
                "sha256": "da49d017282b348b7431065b75c932a0829d80bf31b983d453e9a5c57b27ad8f"
            },
            "downloads": -1,
            "filename": "procblockweb-0.12-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bd31c689b4f924d5a4757d8dd8642085",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8317,
            "upload_time": "2024-03-29T06:38:56",
            "upload_time_iso_8601": "2024-03-29T06:38:56.389192Z",
            "url": "https://files.pythonhosted.org/packages/62/84/636bb64ab0f379d6947873214985a03d75b8a1cd5e775aed9ca9a477810e/procblockweb-0.12-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6b997ae54776d02c6114398828fdf4553036af12f6c6d94bc8348f47d4e3f844",
                "md5": "afc97ca68304a9eadd5f8a6243614bd5",
                "sha256": "74f71b020eca9ef71fa18893018516ec1e47a41add2dd435a9733b6375cc7603"
            },
            "downloads": -1,
            "filename": "procblockweb-0.12.tar.gz",
            "has_sig": false,
            "md5_digest": "afc97ca68304a9eadd5f8a6243614bd5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6890,
            "upload_time": "2024-03-29T06:38:57",
            "upload_time_iso_8601": "2024-03-29T06:38:57.532615Z",
            "url": "https://files.pythonhosted.org/packages/6b/99/7ae54776d02c6114398828fdf4553036af12f6c6d94bc8348f47d4e3f844/procblockweb-0.12.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-29 06:38:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "procblockweb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "rlogfi",
            "specs": []
        }
    ],
    "lcname": "procblockweb"
}
        
Elapsed time: 0.22423s