Curso Metasploit - Part. 2.1 - Comandos de metasploit

Iniciado por puntoCL, Octubre 05, 2017, 12:58:06 AM

Tema anterior - Siguiente tema

0 Miembros y 1 Visitante están viendo este tema.

Octubre 05, 2017, 12:58:06 AM Ultima modificación: Abril 13, 2018, 08:49:01 PM por puntoCL



En esta segunda parte le estaré hablando sobre los comando de metasploit. Quiero recordarle que en este curso estaré ocupando kali Linux y estaré ocupado la interfaz consola.

Antes de abrir nuestro metasploit, nosotros tenemos que arrancar nuestro servicio de base de datos de postgresql.

PostgreSQL: Es un sistema de gestión de bases de datos relacional orientado a objetos y libre.

Escribimos en la consola o terminal

Código: php
service postgresql start


Ya. una vez que postgresql está funcionando, necesitamos crear la base de datos de msf. Escribimos el siguiente comando

Código: php
msfdb init




Cuando ya se ha ya creado la base de datos iniciaremos nuestro metasploit ingresamos el siguiente comando.

Código: php
msfconsole




y verificaremos la conectividad de la base de datos con el siguiente comando.

Código: php
db_status




Y listo. El postgresql esta conectado con msf

Ahora varemos los comando, para ver todos los comandos podemos escribir "help" o "?" (Claramente sin las comillas), como se puede apreciar más abajo escribí help y no salió todos los comandos con su descripciones.



Código: php
msf > help

Core Commands
=============

    Command       Description
    -------       -----------
    ?             Help menu
    banner        Display an awesome metasploit banner
    cd            Change the current working directory
    color         Toggle color
    connect       Communicate with a host
    exit          Exit the console
    get           Gets the value of a context-specific variable
    getg          Gets the value of a global variable
    grep          Grep the output of another command
    help          Help menu
    history       Show command history
    irb           Drop into irb scripting mode
    load          Load a framework plugin
    quit          Exit the console
    route         Route traffic through a session
    save          Saves the active datastores
    sessions      Dump session listings and display information about sessions
    set           Sets a context-specific variable to a value
    setg          Sets a global variable to a value
    sleep         Do nothing for the specified number of seconds
    spool         Write console output into a file as well the screen
    threads       View and manipulate background threads
    unload        Unload a framework plugin
    unset         Unsets one or more context-specific variables
    unsetg        Unsets one or more global variables
    version       Show the framework and console library version numbers


Module Commands
===============

    Command       Description
    -------       -----------
    advanced      Displays advanced options for one or more modules
    back          Move back from the current context
    edit          Edit the current module with the preferred editor
    info          Displays information about one or more modules
    loadpath      Searches for and loads modules from a path
    options       Displays global options or for one or more modules
    popm          Pops the latest module off the stack and makes it active
    previous      Sets the previously loaded module as the current module
    pushm         Pushes the active or list of modules onto the module stack
    reload_all    Reloads all modules from all defined module paths
    search        Searches module names and descriptions
    show          Displays modules of a given type, or all modules
    use           Selects a module by name


Job Commands
============

    Command       Description
    -------       -----------
    handler       Start a payload handler as job
    jobs          Displays and manages jobs
    kill          Kill a job
    rename_job    Rename a job


Resource Script Commands
========================

    Command       Description
    -------       -----------
    makerc        Save commands entered since start to a file
    resource      Run the commands stored in a file


Database Backend Commands
=========================

    Command           Description
    -------           -----------
    db_connect        Connect to an existing database
    db_disconnect     Disconnect from the current database instance
    db_export         Export a file containing the contents of the database
    db_import         Import a scan result file (filetype will be auto-detected)
    db_nmap           Executes nmap and records the output automatically
    db_rebuild_cache  Rebuilds the database-stored module cache
    db_status         Show the current database status
    hosts             List all hosts in the database
    loot              List all loot in the database
    notes             List all notes in the database
    services          List all services in the database
    vulns             List all vulnerabilities in the database
    workspace         Switch between database workspaces


Credentials Backend Commands
============================

    Command       Description
    -------       -----------
    creds         List all credentials in the database

msf >


En esta ocasión le estaré hablando sobre estos comandos, dejando en claro que algunos comando voy a ser más específico que otros. Igual si yo me equivoco en algunos o si quieren agregar algo me avisan  ;)




Core Commands - Comandos Básicos

Lo que estare mostrando son los comandos basicos.

?: Como ya podemos apreciar nos muestra todos los comandos de metasploit
banner: Con este comando cambiamos los banner de nuestro metasploit. Los banner son los dibujitos. Esto dibujitos se llaman "ascii banner". Si googlean podrán encontrar generadores de esto banner y lo podrán agregar a su metasploit a si quedara algo más personal.[/color]

cd: Este comando es igual que el cd de nuestro linux, no tiene nada diferente.
color: Puedes activar o desactivar los colores de metasploit.
Activar color
Código: php

color true

Desactivar color
Código: php

color false


connect: Nos conectaremos a un host como a un Netcat o Telnet, esta igual soporta SSL, proxies, pivoting y trasferencias de archivo.
exit: Obviamente salir de metasploit.
get: Obtiene el valor de una variable específica
getg: Obtiene el valor de una variable global
grep: El comando grep es similar a Linux grep. Concuerda con un patrón dado de la salida de otro comando msfconsole
help: Hace lo mismo que el comando "?"
history: Este comando nos mostrara de forma de una lista enumerada todos los comandos que hemos digitado en metasploit de menor a mayor
Código: php

msf > history
10   banner
11   db_status
12   db_rebuild_cache
13   exit
14   db_status
15   db_rebuild_cache
16   db_rebuild_cache
17   search samba
18   db_rebuild_cache
19   exit
20   exit
21   banner
22   banner
23   banner
24   banner
25   banner
26   banner
27   banner
28   banner
29   banner
30   banner
31   banner
32   ?
33   ?
34   banner
35   banner
36   banner
37   banner
38   cd
39   color
40   color true
41   cd
42   color fals
43   color false
44   cd
45   cd
46   cd /
47   cd
48   cd search joomla
49   search joomla
50   cd auxiliary
51   cd auxiliary/admin/
52   ls
53   clear
54   ls
55   cd Desktp
56   cd Desktop
57   ls
58   clear
59   colir
60   color
61   clear
62   color
63   color true
64   ls
65   color false
66   ls
67   color auto
68   ls
69   clear
70   search joomla
71   ls
72   clear
73   ls
74   banner
75   color
76   color false
77   color
78   banner
79   color true
80   banner
81   connect
82   clear
83   ?
84   clear
85   get
86   get var1
87   get
88   clear
89   go_pro
90   clear
91   ?
92   grep
93   clear
94   grep
95   clear
96   clear
97   clear
98   clear
99   grep
100  help
101  history
102  clear
103  clear
104  ruby
105  clear
106  irb
107  puts "Hello, Underc0de.org!! :D"
108  exit
109  history

irb: Al ejecutar el comando irb te abrirá una shell de intérprete de Ruby en vivo donde puedes emitir comand6os y crear scripts de Metasploit. Esta característica también es muy útil para comprender los aspectos internos.
Código: php

msf > irb
[*] Starting IRB shell...

>> puts "Hello, Underc0de.org!! :D"
Hello, Underc0de.org!! :D
=> nil
>>

load: Carga plugin desde desde el directorio de plugin de metasploit
quit: Salir de metasploit
route: Ruta el tráfico a través de una sesión proporcionando capacidades pivoting básicas. Para agregar una ruta, pasa la subred de destino y la máscara de red, seguida del número de sesión
Código: php

msf > route -h
Route traffic destined to a given subnet through a supplied session.

Usage:
  route [add/remove] subnet netmask [comm/sid]
  route [add/remove] cidr [comm/sid]
  route [get] <host or network>
  route [flush]
  route [print]

Subcommands:
  add - make a new route
  remove - delete a route; 'del' is an alias
  flush - remove all routes
  get - display the route for a given target
  print - show all active routes

Examples:
  Add a route for all hosts from 192.168.0.0 to 192.168.0.0 through session 1
    route add 192.168.0.0 255.255.255.0 1
    route add 192.168.0.0/24 1

  Delete the above route
    route remove 192.168.0.0/24 1
    route del 192.168.0.0 255.255.255.0 1

  Display the route that would be used for the given host or network
    route get 192.168.0.11

msf >


save: Esta nos salva o guarda nuestros datos en la DB de metasploit
Código: php

msf > save
Saved configuration to: /root/.msf4/config
msf >

sessions: Con este comando se puede enumera, interactuar y matar las sessiones que ya hemos generado. Como las sessiones de meterpreter, shell etc...
a si aparece cuando tengo una session. Ósea una maquina comprometida
Código: php

msf > sessions

Active sessions
===============

ID   Type           Information                    Connection
--   ----           -----------                    ----------
1    meterpreter    WINXPSP3\Student @ WINXPSP3    192.168.0.101:4444 -> 192.168.0.102


y asi aparece cuando no tenemos una session
Código: php

msf > sessions

Active sessions
===============

No active sessions.

msf >


Código: php

msf > sessions -h
Usage: sessions [options] or sessions [id]

Active session manipulation and interaction.

OPTIONS:

    -C <opt>  Run a Meterpreter Command on the session given with -i, or all
    -K        Terminate all sessions
    -S <opt>  Row search filter.
    -c <opt>  Run a command on the session given with -i, or all
    -h        Help banner
    -i <opt>  Interact with the supplied session ID
    -k <opt>  Terminate sessions by session ID and/or range
    -l        List all active sessions
    -q        Quiet mode
    -r        Reset the ring buffer for the session given with -i, or all
    -s <opt>  Run a script on the session given with -i, or all
    -t <opt>  Set a response timeout (default: 15)
    -u <opt>  Upgrade a shell to a meterpreter session on many platforms
    -v        List sessions in verbose mode
    -x        Show extended information in the session table

Many options allow specifying session ranges using commas and dashes.
For example:  sessions -s checkvm -i 1,3-5  or  sessions -k 1-2,5,6

msf >


set: Este comando sirve para configurar los parámetros de los módulos en que estamos trabajando. "más adelante veremos más en detalle sobre esto"
Código: php

msf > use auxiliary/scanner/http/joomla_version
msf auxiliary(joomla_version) > show options

Module options (auxiliary/scanner/http/joomla_version):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   Proxies                     no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                      yes       The target address range or CIDR identifier
   RPORT      80               yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The base path to the Joomla application
   THREADS    1                yes       The number of concurrent threads
   VHOST                       no        HTTP server virtual host

msf auxiliary(joomla_version) > set RHOSTS www.paginaweb.com
RHOSTS => www.paginaweb.com
msf auxiliary(joomla_version) > show options

Module options (auxiliary/scanner/http/joomla_version):

   Name       Current Setting    Required  Description
   ----       ---------------    --------  -----------
   Proxies                       no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS     www.paginaweb.com  yes       The target address range or CIDR identifier
   RPORT      80                 yes       The target port (TCP)
   SSL        false              no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                  yes       The base path to the Joomla application
   THREADS    1                  yes       The number of concurrent threads
   VHOST                         no        HTTP server virtual host


setg: Lo más agradable de este comando que ahorras un montón en escribir durante un pentest, puede establecer variable globales dentro de msfconsole. claro, una vez que se hayan configurado.
Código: php

msf > setg LHOST 10.10.10.1
LHOST => 10.10.10.1
msf > setg RHOSTS 20.20.20.1/24
RHOSTS => 20.20.20.1/24
msf > setg RHOST 30.30.30.1
RHOST => 30.30.30.1

sleep: duerme o deja en modo stand by a metasploit en segundos, ósea o dejar en stand by en x segundos
threads: Ver y manipular los subprocesos de fondo.
Código: php

msf > threads

Background Threads
==================

   ID  Status  Critical  Name                Started
   --  ------  --------  ----                -------
   0   sleep   True      SessionScheduler-1  2017-10-05 03:21:09 +0000
   1   sleep   True      SessionScheduler-2  2017-10-05 03:21:09 +0000
   2   sleep   True      SessionScheduler-3  2017-10-05 03:21:09 +0000
   3   sleep   True      SessionScheduler-4  2017-10-05 03:21:09 +0000
   4   sleep   True      SessionScheduler-5  2017-10-05 03:21:09 +0000
   5   sleep   True      SessionManager      2017-10-05 03:21:09 +0000

msf >

unload: El comando unload descarga un complemento previamente cargado y elimina los comandos extendidos..
Código: php

msf > unload
Usage: unload <plugin name>

Unloads a plugin by its symbolic name.  Use 'show plugins' to see a list of
currently loaded plugins.

msf > Interrupt: use the 'exit' command to quit


unset: Es lo contrario del comando "set". Este comando elimina un parámetro previamente configurado con set. Se pueden eliminar todas las variables asignadas con "unset all" sin comillas.
unsetg: Lo que hace es desarmar una variable global. si las variables se introducen en mayúscula (metasploit es insensible a mayúsculas y minúsculas).
version: Muestra la versión  del framework y la consola.
Código: php

msf > version
Framework: 4.15.8-dev
Console  : 4.15.8-dev
msf >


En la segunda vuelta estaré hablando sobre los otros comandos que deje al debe.



No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Curso Metasploit - Part. 2.1 - Comandos de metasploit
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
No tienes permitido ver los links. Registrarse o Entrar a mi cuenta