Open Laransec opened 1 year ago
i met the same problem, i use implant to execute a python file, when the cost time is over 30s , grpc returns the same error as above; i set session timeout to 120/60s , but it does not work; cat i set this through any other ways? the code is this:
TIMEOUT = 120
async def interact_session(self, session_id: str, timeout=TIMEOUT) -> Union[InteractiveSession, None]:
'''Interact with a session, returns an :class:`AsyncInteractiveSession`
:param session_id: Session ID
:type session_id: str
:param timeout: gRPC timeout, defaults to 60 seconds
:return: An interactive session
:rtype: Union[AsyncInteractiveSession, None]
'''
session = await self.session_by_id(session_id, timeout)
if session is not None:
return InteractiveSession(session, self._channel, timeout)
my great master friend Caiyong sent me a solution, and it works:
add en extended method execute_timeout
in interractive.py near the execute
method
async def execute_timeout(self, exe: str, args: List[str], output: bool, timeout: int = 60) -> sliver_pb2.Execute:
execute_req = sliver_pb2.ExecuteReq(Path=exe, Args=args, Output=output)
req = self._request(execute_req)
# transform seconds to nanoseconds
req.Request.Timeout = timeout * 1000000000
rpc_timeout = timeout + self.timeout
return (await self._stub.Execute(req, timeout=rpc_timeout))
Describe the bug Attempting to upload another sliver (~14mb) through a sliver-py session results in timeout after ~30 seconds no matter what the session.timeout is set to. Its also markedly slower than doing an upload through the command line. Interactively uploading the same sliver through the interactive command line is very fast and does not time out.
To Reproduce Sliver 1.5.34 in multiplayer mode. pip install sliver-py session.timeout set to 240 for the large upload.
Sliverpy Code snippet: with open (Sliver_Path, mode='rb') as file: file=file.read() print(session.timeout) #This winds up saying whatever I set it to. await session.upload(remote_path=Remote_Path, data=file, is_ioc=True)
Errors out after 30 seconds with
status = StatusCodeUNKNOWN details = "Implant timeout" and a grpc error
Its dead on at 30 seconds so Its almost a TCP timeout somehow.
Expected behavior A successful upload following the session.timeout value set.