Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush file buffer when using stdout #811

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rafa-br34
Copy link

@rafa-br34 rafa-br34 commented Jan 25, 2025

Currently, Masscan does not flush the file buffer when using the -oL - flags. This does not allow other programs (in my case, Python) to easily parse the output stream.

Here's the code I'm using in case anyone wants to reproduce the issue.

import subprocess

def masscan_iterate(path, port, rate=1000):
        process = subprocess.Popen(
                [
                        path,
                        "-oL", "-",
                        "-p", str(port),
                        "--rate", str(rate),
                        "--exclude", "255.255.255.255",
                        "0.0.0.0/0"
                ],
                stdout = subprocess.PIPE,
                stderr = subprocess.DEVNULL
        )

        while process.poll() == None:
                line = process.stdout.readline() # Hangs with the current Masscan version, works with the patch

                if line != b'':
                        print(line)

masscan_iterate("./masscan", 22)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant