r"""system(process, tty = True, cwd = None, env = None, timeout = Timeout.default, raw = True) -> ssh_channel Open a new channel with a specific process inside. If `tty` is True, then a TTY is requested on the remote server. If `raw` is True, terminal control codes are igno
(self, process, tty = True, cwd = None, env = None, timeout = None, raw = True, wd = None)
| 1047 | return packing._decode(result) |
| 1048 | |
| 1049 | def system(self, process, tty = True, cwd = None, env = None, timeout = None, raw = True, wd = None): |
| 1050 | r"""system(process, tty = True, cwd = None, env = None, timeout = Timeout.default, raw = True) -> ssh_channel |
| 1051 | |
| 1052 | Open a new channel with a specific process inside. If `tty` is True, |
| 1053 | then a TTY is requested on the remote server. |
| 1054 | |
| 1055 | If `raw` is True, terminal control codes are ignored and input is not |
| 1056 | echoed back. |
| 1057 | |
| 1058 | Return a :class:`pwnlib.tubes.ssh.ssh_channel` object. |
| 1059 | |
| 1060 | Examples: |
| 1061 | |
| 1062 | >>> s = ssh(host='example.pwnme') |
| 1063 | >>> py = s.system('python3 -i') |
| 1064 | >>> _ = py.recvuntil(b'>>> ') |
| 1065 | >>> py.sendline(b'print(2+2)') |
| 1066 | >>> py.sendline(b'exit()') |
| 1067 | >>> print(repr(py.recvline())) |
| 1068 | b'4\n' |
| 1069 | >>> s.system('env | grep -a AAAA', env={'AAAA': b'\x90'}).recvall() |
| 1070 | b'AAAA=\x90\n' |
| 1071 | >>> io = s.system('pwd', cwd='/tmp') |
| 1072 | >>> io.recvall() |
| 1073 | b'/tmp\n' |
| 1074 | >>> io.cwd |
| 1075 | '/tmp' |
| 1076 | """ |
| 1077 | if wd is not None: |
| 1078 | self.warning_once("The 'wd' argument to ssh.system() is deprecated. Use 'cwd' instead.") |
| 1079 | if cwd is None: |
| 1080 | cwd = wd |
| 1081 | if cwd is None: |
| 1082 | cwd = self.cwd |
| 1083 | |
| 1084 | if timeout is None: |
| 1085 | timeout = self.timeout |
| 1086 | |
| 1087 | return ssh_channel(self, process, tty, cwd, env, timeout = timeout, level = self.level, raw = raw) |
| 1088 | |
| 1089 | #: Backward compatibility. Use :meth:`system` |
| 1090 | run = system |
no test coverage detected