There was a requirement to not install anything else on a CentOS machine, but to discover what ports are open from the terminal. So without having netstat or any other tools I tried to find a workaround, which I will put it here for future references:

# Get all open ports in hex format
declare -a open_ports=($(cat /proc/net/tcp | grep -v "local_address" | awk '{ print $2 }' | cut -d':' -f2))
# Show all open ports and decode hex to dec
for port in ${open_ports[*]}; do echo $((0x${port})); done