752 palabras
4 minutos
Notas sobre linux
Setting up laboratory for pentesting
Sistema operativo
- Debian 12 LTS
- O el más reciente con un kernel estable. Kernels recientes tienen problemas para virtualizar en vmWare, Android Studio y GenyMotion
- Linux 6.1.0-27
- Instalar build-essential
- Linux headers
sudo apt -y install build-essential git vimsudo apt -y install linux-headers-$(uname -r)
Rutas para nuevos programas en PATH
- /usr/local/bin/
- /opt/new_program/
Amenidades para el sistema operativo
- touchegg - Linux multi-touch gesture recognizer
- Custom Shortcut for open terminal - gnome-terminal
- System Monitor Next
- sudo apt install gir1.2-gtop-2.0 gir1.2-nm-1.0 gir1.2-clutter-1.0 gnome-system-monitor
- gnome-shell-extension-manager
- Flameshot - flameshot gui
- Git
- Linux-headers
- Build Essentials
- vim
- KeePass
Manejo de evidencia
- CherryTree 1.2.0
- Flameshot
Editor de texto
- vsCode
Navegadores
- Brave
- Google Chrome
- Firefox
Administración remota
- AnyDesk
Proxy y temas de red
- BurpSuite
- Wireshark
Virtualizadores
- VMware® Workstation 17 Pro 17.6.0
- Docker
- GenyMotion
- Android Studio
Máquinas virtuales
- Windows 10
- Kali Linux
- Parrot OS
Imágenes de Docker
- MobSF
- NextCloud
Password Cracking
- Hashcat
- CUDA drivers for graphics cards
ScreenRecorder
- Simple Screen Recorder
Web
- whatweb
- dirb
Misc
- exiftool
Utilidades
Compartir carpeta en máquina virtual (Linux host - Linux guest)
# Para montaje manual de la carpeta compartida:sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
# Para averiguar si esta compartida la carpeta:vmware-hgfsclient
Anexo - Fuentes y más información
Amenidades para el sistema operativo
- https://github.com/JoseExposito/touchegg?tab=readme-ov-file
- https://github.com/priyaranjankumar/touchegg.conf
Manejo de evidencia
Editor de texto
Virtualizadores
- https://blogs.vmware.com/workstation/2024/05/vmware-workstation-pro-now-available-free-for-personal-use.html
- https://www.docker.com/
- https://www.genymotion.com/
- https://developer.android.com/studio/?hl=es-419
Notas generales sobre Linux
Variables
# Variable pathexport PATH=$PATH:/new_route# También puede serexport PATH=new_route:$PATH
Cargar variables
# Dependiendo de la ruta que quieras como origensource ~/.profilesource ~/.bashrc
Para guardar la variables de forma permanente
/etc/profile
(for all users)~/.bash_profile
(for current user)~/.bash_login
(for current user)~/.profile
(for current user)~/.bashrc
(for current user)/etc/environment
to set a permanent PATH environment variable, but it does not support variable expansion.
Más información:
Administración básica
# Crear un grupogroupadd grupo
# Crear usuarios # adduser => Script # useradd => Manual
useradd -ms /bin/bash superadmin# -m Crea carpeta home# -s Asigna shell
# Añadir un usuario a grupousermod -a -G sudo soporte
# Cambia passwordpasswd superadmin
## Agregamos contraseña al usuario appuserRUN echo 'user:password' | chpasswd
Información del sistema
# Check system versionlsb_release -acat /etc/issuecat /etc/os-releasehostnamectl
Teclado
# 1) Configurar tecladodpkg-reconfigure keyboard-configuration
# 2) Aplicar la configuración del teclado (solo funciona para esa sesión)setupcon
# 3) Para un cambio permantentedpkg-reconfigure console-setup
Descargar archivos
wget
# Descarga un archivowget <URL>
# Descarga y renombra un archivowget -O <filename> <URL>
# Descarga varios archivos desde un archivo de texto con las urlswget -i download_files.txt
# Descarga una carpetawget -r ftp://server-address.com/directory
# Descargar de manera recursiva esos elementoswget -nd -r -A pdf,doc,docx,xls,xlsx,jpg www.rediris.es
curl
# Descarga un archivocurl --location --request GET 'https://github.com/frida/frida/releases/download/17.2.11/frida-server-17.2.11-android-arm.xz' --output file.name
Otros
Exfiltración de información
Archivos importantes
- /etc/passwd
- /etc/shadow
- /etc/resolv.conf
- /etc/hosts
- /etc/hostname
Comprimir información
# Respaldo omitiendo erroes, tipos de archivos y carpetastar --warning=no-file-changed --exclude={*.mp4,*.mp3,'./public_html'} --ignore-failed-read -zcvf respaldo.tar.gz .
Entornos virtuales en python
Python Virtual Environment (venv)
# Virtual Environment Installationpython -m venv esptoolenv# esptoolenv = name
# Activate Virtual Environmentsource esptoolenv/bin/activate
# deactivate Virtual Environmentdeactivate
# Borrar rm -r esptoolenv en la carpeta
# Instalar frida-tools <herramienta>pip install frida-tools
# Instalar una versión en especificapip install frida-tools==16.7.13
Python Virtual Environment (pipx)
# Instalar pipxsudo apt install pipx
# Instalar frida-tools <herramienta>pipx install frida-tools
# Instalar una versión en especificapipx install frida-tools==16.7.13
# Solamente si no lo detecta el PATHpipx ensurepath # Note: '/home/user/.local/bin' is not on your PATH environment variable. These apps will not be globally accessible until your PATH is updated. Run `pipx ensurepath` to automatically add it, or manually
# Obtener la versión de Frida frida --version # 16.7.13
# Actualizar frida-tools <herramienta>pipx upgrade frida-tools
# Desinstalar frida-tools <herramienta>pipx uninstall frida-tools
Utilerías
Read a do anything
#!/bin/bashwhile IFS= read -r linedo user=$(echo $line | cut -d ":" -f1) password=$(echo $line | cut -d ":" -f2 | base64 -d | base64 -d) echo "$user:$password"done < $1
Insertar caracteres antes de una línea
awk '{print "Insertar al inicio " $0 " insertar al final\n"}' archivo.txt
Dividir un archivo en varios
split -l 200000 -d --additional-suffix=.txt input_file.txt output_file
Imprimir todo lo que no es comentario
awk '!/#/' file
Referencias:
Remover caracteres repetidos
tr -s 'character'tr -s ' 'tr -s '\n'
Borrar un caracter de un string
tr -d ".|,"
Reemplazar una cadena por nada
sed "s/|a|//g"sed "s/|a|/~b~/g"
Remover la última letra del string
sed 's/.$//'
Descargar un archivo con scp
scp user@192.168.100.100:path/file.txt /local/dir
Subir un archivo con scp
scp file user@192.168.100.100:path/file.txt
Descarga con FTP
sftp root@<IP>get -r /var/root/<file>.txt
Con llave publica
scp -i key_file.pem user@192.168.100.100:path/file.txt /local/dir
Control con systemctl
# Systemctlsudo systemctl status sshsudo systemctl start sshsudo systemctl stop sshsudo systemctl restart ssh
# Preguntar si está activosudo systemctl is-active apache
# Preguntar si está habilitadosudo systemctl is-enable apache
Hexedit
- Utiliza Ctrl-S para buscar hacia adelante y Ctrl-R para buscar hacia atrás.
- Usa Inicio, Fin, AvPág y Repág para movimientos más amplios.
- Guardar los cambios: Presiona F2 para guardar los cambios realizados en el archivo.
- Salir del programa: Normalmente, se sale presionando Ctrl-X o cerrando la ventana de la terminal.
Nota final¡Gracias por terminar de leer este artículo! uwur
— El Capitán
Notas sobre linux
https://elcaza.github.io/posts/apuntes/linux/