Skip to content

Commit

Permalink
Fix error big async data (#70)
Browse files Browse the repository at this point in the history
* increase buffer

* remove raw request and response
  • Loading branch information
h3xitsec authored Dec 2, 2024
1 parent 7393d04 commit db02b0d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/h3xrecon/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-present h3xit <[email protected]>
#
# SPDX-License-Identifier: MIT
__version__ = "0.0.3.dev1"
__version__ = "0.0.3.dev3"
24 changes: 18 additions & 6 deletions src/h3xrecon/plugins/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,24 @@ async def execute(self, params: dict) -> AsyncGenerator[Dict[str, Any], None]:
async def _read_subprocess_output(self, process: asyncio.subprocess.Process) -> AsyncGenerator[str, None]:
"""Helper method to read and process subprocess output."""
while True:
line = await process.stdout.readline()
if not line:
try:
# Increase buffer limit to handle larger outputs
line = await process.stdout.readuntil(b'\n', limit=1024*1024) # 1MB buffer
output = line.decode().strip()
if output:
yield output
except asyncio.exceptions.IncompleteReadError:
break
except asyncio.exceptions.LimitOverrunError:
# If we hit the limit, read the remaining data
partial = await process.stdout.read(1024*1024)
if partial:
output = partial.decode().strip()
if output:
yield output
continue
except Exception as e:
logger.error(f"Error reading subprocess output: {str(e)}")
break
output = line.decode().strip()
if output:
#logger.debug(f"{self.name} output: {output}")
yield output

await process.wait()
2 changes: 1 addition & 1 deletion src/h3xrecon/plugins/plugins/nuclei.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def execute(self, params: Dict[str, Any], program_id: int = None, executio
function_params = asdict(FunctionParams(**params))
logger.info(f"Running {self.name} on {function_params.get("target", {})}")
command = f"""
nuclei -u {function_params.get("target", {})} -j {" ".join(function_params.get("extra_params", []))}
nuclei -or -u {function_params.get("target", {})} -j {" ".join(function_params.get("extra_params", []))}
"""
logger.debug(f"Running command: {command}")
process = await asyncio.create_subprocess_shell(
Expand Down

0 comments on commit db02b0d

Please sign in to comment.