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

Issues logging in with Warp as the client. #2115

Closed
zenire opened this issue Feb 29, 2024 · 2 comments
Closed

Issues logging in with Warp as the client. #2115

zenire opened this issue Feb 29, 2024 · 2 comments

Comments

@zenire
Copy link

zenire commented Feb 29, 2024

Describe the bug
Connecting to Cowrie using Warp.dev terminal throws error. Using macOS standard terminal works fine.
SSH Terminal throws: exec request failed on channel 1

Cowrie container logs:

2024-02-29T08:26:46+0000 [twisted.conch.ssh.session#critical] Error executing command "b'\nexport TERM_PROGRAM=\'WarpTerminal\'\nhook=$(printf "{\\"hook\\": \\"SSH\\", \\"value\\": {\\"socket_path\\": \\"~/.ssh/17091927992246\\", \\"remote_shell\\": \\"%s\\"}}" "${SHELL##*/}" | command -p od -An -v -tx1 | command -p tr -d " \\n")\nprintf \'\x1bP$d%s\x9c\' $hook\nif test "${SHELL##*/}" != "bash" -a "${SHELL##*/}" != "zsh"; then\n if test ! -e $HOME/.hushlogin; then\n if test -r /etc/motd; then\n command -p cat /etc/motd\n elif test -r /run/motd; then\n command -p cat /run/motd\n elif test -r /run/motd.dynamic; then\n command -p cat /run/motd.dynamic\n elif test -r /usr/lib/motd; then\n command -p cat /usr/lib/motd\n elif test -r /usr/lib/motd.dynamic; then\n command -p cat /usr/lib/motd.dynamic\n fi\n fi\n if test -r /etc/profile; then\n . /etc/profile\n fi\n exec $SHELL\nfi\ncase ${SHELL##*/} in\n bash)\n exec -a bash bash --rcfile <(echo \'\n command -p stty raw\n HISTCONTROL=ignorespace\n HISTIGNORE=" *"\n WARP_SESSION_ID="$(command -p date +%s)$RANDOM"\n WARP_COMBINED_PROMPT_COMMAND_GRID="0"\n WARP_HONOR_PS1="0"\n _hostname=$(command -pv hostname >/dev/null 2>&1 && command -p hostname 2>/dev/null || command -p uname -n)\n _user=$(command -pv whoami >/dev/null 2>&1 && command -p whoami 2>/dev/null || echo $USER)\n _msg=$(printf "{\\"hook\\": \\"InitShell\\", \\"value\\": {\\"session_id\\": $WARP_SESSION_ID, \\"shell\\": \\"bash\\", \\"user\\": \\"$_user\\", \\"hostname\\": \\"$_hostname\\"}}" | command -p od -An -v -tx1 | command -p tr -d " \\n")\n printf \'\\\'\'\\eP$d%s\\x9c\'\\\'\' "$_msg"\'\n unset _hostname _user _msg\n )\n ;;\n zsh) WARP_TMP_DIR=$(command -p mktemp -d warptmp.XXXXXX)\n local ZSH_ENV_SCRIPT=\'REDACTED\'\n local WARP_COMBINED_PROMPT_COMMAND_GRID=\'0\'\n local WARP_HONOR_PS1=\'0\'\n if [[ $? == 0 ]]; then\n if command -pv xxd >/dev/null 2>&1; then\n echo $ZSH_ENV_SCRIPT | command -p xxd -p -r > $WARP_TMP_DIR/.zshenv\n else\n for i in {0..$((${#ZSH_ENV_SCRIPT} - 1))..2}; do\n builtin printf "\\x${ZSH_ENV_SCRIPT:$i:2}"\n done > $WARP_TMP_DIR/.zshenv\n fi\n else\n echo "Failed to bootstrap warp. Continuing with a non-bootstrapped shell."\n fi\n TMPPREFIX=$HOME/.zshtmp- WARP_SSH_RCFILES=${ZDOTDIR:-$HOME} WARP_COMBINED_PROMPT_COMMAND_GRID=$WARP_COMBINED_PROMPT_COMMAND_GRID WARP_HONOR_PS1=$WARP_HONOR_PS1 ZDOTDIR=$WARP_TMP_DIR exec -l zsh -g \n ;;\nesac\n'"
	Traceback (most recent call last):
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/python/log.py", line 80, in callWithContext
	    return context.call({ILogContext: newCtx}, func, *args, **kw)
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/python/context.py", line 117, in callWithContext
	    return self.currentContext().callWithContext(ctx, func, *args, **kw)
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/python/context.py", line 82, in callWithContext
	    return func(*args, **kw)
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/conch/ssh/channel.py", line 162, in requestReceived
	    return f(data)
	--- <exception caught here> ---
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/conch/ssh/session.py", line 98, in request_exec
	    self.session.execCommand(pp, f)
	  File "/cowrie/cowrie-git/src/cowrie/shell/session.py", line 76, in execCommand
	    self.protocol.makeConnection(processprotocol)
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/internet/protocol.py", line 509, in makeConnection
	    self.connectionMade()
	  File "/cowrie/cowrie-git/src/cowrie/insults/insults.py", line 91, in connectionMade
	    insults.ServerProtocol.connectionMade(self)
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/conch/insults/insults.py", line 512, in connectionMade
	    self.terminalProtocol.makeConnection(self)
	  File "/cowrie/cowrie-env/lib/python3.9/site-packages/twisted/conch/insults/insults.py", line 63, in makeConnection
	    self.connectionMade()
	  File "/cowrie/cowrie-git/src/cowrie/shell/protocol.py", line 243, in connectionMade
	    self.cmdstack[0].lineReceived("; ".join(self.execcmd.split("\n")))
	builtins.AttributeError: 'HoneyPotExecProtocol' object has no attribute 'execcmd'

To Reproduce
Steps to reproduce the behavior:

  1. Download & start warp.dev terminal
  2. SSH to your Cowrie instance & try to login with the valid credentials
  3. See error

Expected behavior
Connect, stay connected, and be able to navigate through the Cowrie Honeypot.

Server (please complete the following information):

  • Docker container: cowrie/cowrie:latest
  • Client OS: macOS
@micheloosterhof
Copy link
Member

micheloosterhof commented May 16, 2024

export TERM_PROGRAM=\'WarpTerminal\'\nhook=$(printf "{\\"hook\\": \\"SSH\\", \\"value\\": {\\"socket_path\\": \\"~/.ssh/17091927992246\\", \\"remote_shell\\": \\"%s\\"}}" "${SHELL##*/}" | command -p od -An -v -tx1 | command -p tr -d " \\n")\nprintf \'\x1bP$d%s\x9c\' $hook\nif test "${SHELL##*/}" != "bash" -a "${SHELL##*/}" != "zsh"; then\n if test ! -e $HOME/.hushlogin; then\n if test -r /etc/motd; then\n command -p cat /etc/motd\n elif test -r /run/motd; then\n command -p cat /run/motd\n elif test -r /run/motd.dynamic; then\n command -p cat /run/motd.dynamic\n elif test -r /usr/lib/motd; then\n command -p cat /usr/lib/motd\n elif test -r /usr/lib/motd.dynamic; then\n command -p cat /usr/lib/motd.dynamic\n fi\n fi\n if test -r /etc/profile; then\n . /etc/profile\n fi\n exec $SHELL\nfi\ncase ${SHELL##*/} in\n bash)\n exec -a bash bash --rcfile <(echo \'\n command -p stty raw\n HISTCONTROL=ignorespace\n HISTIGNORE=" *"\n WARP_SESSION_ID="$(command -p date +%s)$RANDOM"\n WARP_COMBINED_PROMPT_COMMAND_GRID="0"\n WARP_HONOR_PS1="0"\n _hostname=$(command -pv hostname >/dev/null 2>&1 && command -p hostname 2>/dev/null || command -p uname -n)\n _user=$(command -pv whoami >/dev/null 2>&1 && command -p whoami 2>/dev/null || echo $USER)\n _msg=$(printf "{\\"hook\\": \\"InitShell\\", \\"value\\": {\\"session_id\\": $WARP_SESSION_ID, \\"shell\\": \\"bash\\", \\"user\\": \\"$_user\\", \\"hostname\\": \\"$_hostname\\"}}" | command -p od -An -v -tx1 | command -p tr -d " \\n")\n printf \'\\\'\'\\eP$d%s\\x9c\'\\\'\' "$_msg"\'\n unset _hostname _user _msg\n )\n ;;\n zsh) WARP_TMP_DIR=$(command -p mktemp -d warptmp.XXXXXX)\n local ZSH_ENV_SCRIPT=\'REDACTED\'\n local WARP_COMBINED_PROMPT_COMMAND_GRID=\'0\'\n local WARP_HONOR_PS1=\'0\'\n if [[ $? == 0 ]]; then\n if command -pv xxd >/dev/null 2>&1; then\n echo $ZSH_ENV_SCRIPT | command -p xxd -p -r > $WARP_TMP_DIR/.zshenv\n else\n for i in {0..$((${#ZSH_ENV_SCRIPT} - 1))..2}; do\n builtin printf "\\x${ZSH_ENV_SCRIPT:$i:2}"\n done > $WARP_TMP_DIR/.zshenv\n fi\n else\n echo "Failed to bootstrap warp. Continuing with a non-bootstrapped shell."\n fi\n TMPPREFIX=$HOME/.zshtmp- WARP_SSH_RCFILES=${ZDOTDIR:-$HOME} WARP_COMBINED_PROMPT_COMMAND_GRID=$WARP_COMBINED_PROMPT_COMMAND_GRID WARP_HONOR_PS1=$WARP_HONOR_PS1 ZDOTDIR=$WARP_TMP_DIR exec -l zsh -g \n ;;\nesac\n'"

Warp seems to run in this quite unusual way. Not sure this will be supported.

@micheloosterhof micheloosterhof changed the title 'HoneyPotExecProtocol' object has no attribute 'execcmd' Issues logging in with Warp as the client. May 16, 2024
@zenire
Copy link
Author

zenire commented Jun 7, 2024

@micheloosterhof I saw you closed this issue. Do I understand correctly it's a wontfix for now, or has it been fixed (both are fine obviously, but just clarifying the result of this GH issue).

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