Skip to main content

Disables internet access temporarily for a specified executable and executes it with certain arguments.

Project description

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

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"
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

procblockweb-0.12.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

procblockweb-0.12-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file procblockweb-0.12.tar.gz.

File metadata

  • Download URL: procblockweb-0.12.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for procblockweb-0.12.tar.gz
Algorithm Hash digest
SHA256 74f71b020eca9ef71fa18893018516ec1e47a41add2dd435a9733b6375cc7603
MD5 afc97ca68304a9eadd5f8a6243614bd5
BLAKE2b-256 6b997ae54776d02c6114398828fdf4553036af12f6c6d94bc8348f47d4e3f844

See more details on using hashes here.

File details

Details for the file procblockweb-0.12-py3-none-any.whl.

File metadata

  • Download URL: procblockweb-0.12-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for procblockweb-0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 da49d017282b348b7431065b75c932a0829d80bf31b983d453e9a5c57b27ad8f
MD5 bd31c689b4f924d5a4757d8dd8642085
BLAKE2b-256 6284636bb64ab0f379d6947873214985a03d75b8a1cd5e775aed9ca9a477810e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page