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

Upload through Sliver-py is slow / not respecting timeouts. #37

Open
Laransec opened this issue Mar 7, 2023 · 2 comments
Open

Upload through Sliver-py is slow / not respecting timeouts. #37

Laransec opened this issue Mar 7, 2023 · 2 comments

Comments

@Laransec
Copy link

Laransec commented Mar 7, 2023

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.

  • OS: Ubuntu 20.04
@YeBottle
Copy link

YeBottle commented Aug 17, 2023

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)

@YeBottle
Copy link

YeBottle commented Aug 17, 2023

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

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

No branches or pull requests

2 participants