레이블이 명령어인 게시물을 표시합니다. 모든 게시물 표시
레이블이 명령어인 게시물을 표시합니다. 모든 게시물 표시

2012년 8월 14일 화요일

Metasploit unleashed - Msfconsole 명령어 [3]



metasploit-unleashed 튜토리얼 중 msfconsole 명령어 부분을 정리한 글입니다.



search

msfconsole은 강력한 검색 기능을 포함하고 있습니다. 만약 여러분이 찾고 있는 것이 있다면 'search' 명령어를 사용할 수 있습니다. 아래에 예시는 MS 취약점인 MS09-011를 찾는 경우입니다. msfconsole은 여러분이 검색하진 스트링을 모듈 이름, 설명, 레퍼런스 등에서 찾습니다. 메타스플로잇 모듈은 '-' 대신 '_'을 사용하니 'search' 명령어를 사용할 때 참고하시기 바랍니다.
msf > search ms09-001

Matching Modules
================

   Name                                      Disclosure Date  Rank    Description
   ----                                      ---------------  ----    -----------
   auxiliary/dos/windows/smb/ms09_001_write                   normal  Microsoft SRV.SYS WriteAndX Invalid DataOffset

help

여러분은 'help search' 명령어를 통해 더 정확한 검색을 위한 옵션을 볼 수 있습니다.
msf > help search
Usage: search [keywords]

Keywords:
  name      :  Modules with a matching descriptive name
  path      :  Modules with a matching path or reference name
  platform  :  Modules affecting this platform
  type      :  Modules of a specific type (exploit, auxiliary, or post)
  app       :  Modules that are client or server attacks
  author    :  Modules written by this author
  cve       :  Modules with a matching CVE ID
  bid       :  Modules with a matching Bugtraq ID
  osvdb     :  Modules with a matching OSVDB ID

Examples:
  search cve:2009 type:exploit app:client

msf > 

name

이름을 검색하시려면 search 뒤에 name: 을 입력하시면 됩니다.
msf > search name:illustrator

Matching Modules
================

   Name                                                  Disclosure Date  Rank   Description
   ----                                                  ---------------  ----   -----------
   exploit/windows/fileformat/adobe_illustrator_v14_eps  2009-12-03       great  Adobe Illustrator CS4 v14.0.0


msf > 

path

경로를검색하시려면 search 뒤에 path: 를 입력하시면 됩니다.
msf > search path:scada

Matching Modules
================

   Name                                                 Disclosure Date  Rank     Description
   ----                                                 ---------------  ----     -----------
   auxiliary/admin/scada/igss_exec_17                   2011-03-21       normal   Interactive Graphical SCADA System Remote Command Injection
   exploit/windows/scada/citect_scada_odbc              2008-06-11       normal   CitectSCADA/CitectFacilities ODBC Buffer Overflow
...snip...

platform

플랫폼란에서 검색하시려면 search 뒤에 platform: 을 입력하시면 됩니다.
msf > search platform:aix

Matching Modules
================

   Name                                  Disclosure Date  Rank    Description
   ----                                  ---------------  ----    -----------
   payload/aix/ppc/shell_bind_tcp                         normal  AIX Command Shell, Bind TCP Inline
   payload/aix/ppc/shell_find_port                        normal  AIX Command Shell, Find Port Inline
   payload/aix/ppc/shell_interact                         normal  AIX execve shell for inetd
...snip...

type

모듈이나 보조모듈을 검색하시려면 search 뒤에 type: 을 입력하시면 됩니다.
msf > search type:post

Matching Modules
================

   Name                                                Disclosure Date  Rank    Description
   ----                                                ---------------  ----    -----------
   post/linux/gather/checkvm                                            normal  Linux Gather Virtual Environment Detection
   post/linux/gather/enum_cron                                          normal  Linux Cron Job Enumeration
   post/linux/gather/enum_linux                                         normal  Linux Gather System Information
...snip...

author

저자의 이름을 검색하시려면 search 뒤에 author: 을 입력하시면 됩니다.
msf > search author:dookie

Matching Modules
================

   Name                                                       Disclosure Date  Rank     Description
   ----                                                       ---------------  ----     -----------
   exploit/osx/http/evocam_webserver                          2010-06-01       average  MacOS X EvoCam HTTP GET Buffer Overflow
   exploit/osx/misc/ufo_ai                                    2009-10-28       average  UFO: Alien Invasion IRC Client Buffer Overflow Exploit
   exploit/windows/browser/amaya_bdo                          2009-01-28       normal   Amaya Browser v11.0 bdo tag overflow
...snip...

multiple

여러가지 범위에서 검색하시려면 search 뒤에 여러개의 옵션을 차례로 입력하시면 됩니다.
msf > search cve:2011 author:jduck platform:linux

Matching Modules
================

   Name                                         Disclosure Date  Rank     Description
   ----                                         ---------------  ----     -----------
   exploit/linux/misc/netsupport_manager_agent  2011-01-08       average  NetSupport Manager Agent Remote Buffer Overflow


show

msfconsole 프롬프트 환경에서 show를 입력하시면 메타스플로잇의 모든 모듈을 보실 수 있습니다.
msf > show

Encoders
========

   Name                    Disclosure Date  Rank       Description
   ----                    ---------------  ----       -----------
   cmd/generic_sh                           good       Generic Shell Variable Substitution Command Encoder
   cmd/ifs                                  low        Generic ${IFS} Substitution Command Encoder
   cmd/printf_php_mq                        manual     printf(1) via PHP magic_quotes Utility Command Encoder
...snip...

show 명령어를 사용하는 방법에는 여러가지가 있지만, 여러분은 'show auxiliary', 'show exploits', 'show payloads', 'show encoders', 그리고 'show nops' 와 같은 명령어를 자주 사용하실 겁니다.


auxiliary

'show auxiliary' 명령어를 실행하면 메타스플로잇의 모든 보조 모듈을 보여줄 것입니다. 참고로 보조 모듈은 스케너, DoS 모듈, fuzzer 등을 포함합니다.
msf > show auxiliary
Auxiliary
=========

   Name                                                  Disclosure Date  Rank    Description
   ----                                                  ---------------  ----    -----------
   admin/2wire/xslt_password_reset                       2007-08-15       normal  2Wire Cross-Site Request Forgery Password Reset Vulnerability
   admin/backupexec/dump                                                  normal  Veritas Backup Exec Windows Remote File Access
   admin/backupexec/registry                                              normal  Veritas Backup Exec Server Registry Access
...snip...

exploits

'show exploits'는 메타스플로잇의 가장 핵심 부분이며 여러분이 가장 많이 사용하시고 관심을 가지실 명령어일 것입니다. 'show exploits'을 실행하시면 프레임워크가 가지고 있는 모든 exploit을 나열 합니다.
msf > show exploits

Exploits
========

   Name                                                           Disclosure Date  Rank       Description
   ----                                                           ---------------  ----       -----------
   aix/rpc_cmsd_opcode21                                          2009-10-07       great      AIX Calendar Manager Service Daemon (rpc.cmsd) Opcode 21 Buffer Overflow
   aix/rpc_ttdbserverd_realpath                                   2009-06-17       great      ToolTalk rpc.ttdbserverd _tt_internal_realpath Buffer Overflow (AIX)
   bsdi/softcart/mercantec_softcart                               2004-08-19       great      Mercantec SoftCart CGI Overflow
...snip...

payloads

'show payloads'는 메타스플로잇에서 사용 가능한 모든 플랫폼의 payload를 나열해 줍니다.
msf > show payloads

Payloads
========

   Name                                             Disclosure Date  Rank    Description
   ----                                             ---------------  ----    -----------
   aix/ppc/shell_bind_tcp                                            normal  AIX Command Shell, Bind TCP Inline
   aix/ppc/shell_find_port                                           normal  AIX Command Shell, Find Port Inline
   aix/ppc/shell_interact                                            normal  AIX execve shell for inetd
...snip...

payloads
여러분이 특정 exploit을 사용하고 있는 경우 'show payload' 명령어는 여러분이 선택하신 exploit에서 사용할 수 있는 payload만 나열할 것입니다. 예를들어, 윈도우 exploit에서는 리눅스 payload들은 보이지 않을 것 입니다.
msf  exploit(ms08_067_netapi) > show payloads

Compatible Payloads
===================

   Name                                             Disclosure Date  Rank    Description
   ----                                             ---------------  ----    -----------
   generic/custom                                                    normal  Custom Payload
   generic/debug_trap                                                normal  Generic x86 Debug Trap
   generic/shell_bind_tcp                                            normal  Generic Command Shell, Bind TCP Inline
...snip...

options
만약 여러분이 모듈을 선택하셨으면, 'show options' 명령어를 통해 여러분이 설정해야할 세팅 값들을 보실 수 있습니다. Setting 란에 yes 라고 되어 있는 부분은 여러분이 모듈을 사용하기 위해선 반드시 입력하거나 수정해야 할 부분입니다.
msf exploit(ms08_067_netapi) > show options

Module options:

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOST                     yes       The target address
   RPORT    445              yes       Set the SMB service port
   SMBPIPE  BROWSER          yes       The pipe name to use (BROWSER, SRVSVC)


Exploit target:

   Id  Name
   --  ----
   0   Automatic Targeting

targets
여러분이 사용하시려는 exploit이 어떤 운영체제에서 사용할 수 있는지가 궁금하시면, 모듈을 선택하신 후 'show target' 명령어를 사용하시기 바랍니다.
msf  exploit(ms08_067_netapi) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Automatic Targeting
   1   Windows 2000 Universal
   10  Windows 2003 SP1 Japanese (NO NX)
   11  Windows 2003 SP2 English (NO NX)
   12  Windows 2003 SP2 English (NX)
...snip...

advanced
만약 여러분이 exploit을 좀 더 수정하고 싶을 때, 'show advanced' 명령어를 입력하시면 고급 설정들을 보실 수 있습니다.
msf exploit(ms08_067_netapi) > show advanced

Module advanced options:

   Name           : CHOST
   Current Setting:
   Description    : The local client address

   Name           : CPORT
   Current Setting:
   Description    : The local client port

...snip...

encoders

'show encoders' 명령어는 메타스플로잇에서 사용할 수 있는 인코더를 나열할 것입니다.
msf > show encoders
Compatible Encoders
===================

   Name                    Disclosure Date  Rank       Description
   ----                    ---------------  ----       -----------
   cmd/generic_sh                           good       Generic Shell Variable Substitution Command Encoder
   cmd/ifs                                  low        Generic ${IFS} Substitution Command Encoder
   cmd/printf_php_mq                        manual     printf(1) via PHP magic_quotes Utility Command Encoder
   generic/none                             normal     The "none" Encoder
   mipsbe/longxor                           normal     XOR Encoder
   mipsle/longxor                           normal     XOR Encoder
   php/base64                               great      PHP Base64 encoder
   ppc/longxor                              normal     PPC LongXOR Encoder
   ppc/longxor_tag                          normal     PPC LongXOR Encoder
   sparc/longxor_tag                        normal     SPARC DWORD XOR Encoder
   x64/xor                                  normal     XOR Encoder
   x86/alpha_mixed                          low        Alpha2 Alphanumeric Mixedcase Encoder
   x86/alpha_upper                          low        Alpha2 Alphanumeric Uppercase Encoder
   x86/avoid_utf8_tolower                   manual     Avoid UTF8/tolower
   x86/call4_dword_xor                      normal     Call+4 Dword XOR Encoder
   x86/context_cpuid                        manual     CPUID-based Context Keyed Payload Encoder
   x86/context_stat                         manual     stat(2)-based Context Keyed Payload Encoder
   x86/context_time                         manual     time(2)-based Context Keyed Payload Encoder
   x86/countdown                            normal     Single-byte XOR Countdown Encoder
   x86/fnstenv_mov                          normal     Variable-length Fnstenv/mov Dword XOR Encoder
   x86/jmp_call_additive                    normal     Jump/Call XOR Additive Feedback Encoder
   x86/nonalpha                             low        Non-Alpha Encoder
   x86/nonupper                             low        Non-Upper Encoder
   x86/shikata_ga_nai                       excellent  Polymorphic XOR Additive Feedback Encoder
   x86/single_static_bit                    manual     Single Static Bit
   x86/unicode_mixed                        manual     Alpha2 Alphanumeric Unicode Mixedcase Encoder
   x86/unicode_upper                        manual     Alpha2 Alphanumeric Unicode Uppercase Encoder

nops

마지막으로 'show nops' 명령어는 메타스플로잇이 제공하는 NOP Generators 를 보여줄 것입니다.
msf > show nops
NOP Generators
==============

   Name             Disclosure Date  Rank    Description
   ----             ---------------  ----    -----------
   armle/simple                      normal  Simple
   php/generic                       normal  PHP Nop Generator
   ppc/simple                        normal  Simple
   sparc/random                      normal  SPARC NOP generator
   tty/generic                       normal  TTY Nop Generator
   x64/simple                        normal  Simple
   x86/opty2                         normal  Opty2
   x86/single_byte                   normal  Single Byte

setg

모의 침투중에 여러번 변수 지정을 해 주는것 대신에, 여러분은 'setg' 명령어를 통해 msfconsole에서 전역 변수를 설정하실 수 있습니다. 전역변수가 설정되고 나면 여러분은 그 변수를 어떤 공격이나 모듈에서도 사용하실 수 있습니다. 또한 여러분은 다음번 msfconsole 실행에서도 이 전역 변수를 사용하실 수 있습니다. 하지만 여러분이 전역 변수를 설정하신 것을 잊지 않기 위해선, 반드시 공격을 수행하기 전에 옵션을 확인하는 과정을 잊지 마시기 바랍니다. 반대로 'unsetg' 명령어를 통해서 여러분이 설정하신 전역변수를 제거할 수 있습니다. 아래의 예시의 경우 모든 변수를 대문자로 사용하고 있지만, 메타스플로잇은 대문자와 소문자를 구분하지 않으므로 굳이 대문자를 사용하실 필요는 없습니다.
msf > setg LHOST 192.168.1.101
LHOST => 192.168.1.101
msf > setg RHOSTS 192.168.1.0/24
RHOSTS => 192.168.1.0/24
msf > setg RHOST 192.168.1.136
RHOST => 192.168.1.136

모든 변수를 설정하시고 나서 'save' 명령어를 입력하시면 여러분이 지정한 환경과 설정들이 모두 저장 됩니다. 이후 msfconsole을 실행할 때 마다 저장된 설정을 사용하실 수 있습니다.

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

use

여러분이 특정 모듈을 사용하기로 결심했다면 'use' 명령어를 사용해 그 모듈을 선택하시기 바랍니다. 'use' 명령어는 여러분이 특정 모듈을 사용할 수 있는 환경을 제공하며, 이 환경에서만 제공하는 명령어를 사용할 수 있도록 합니다. 아래의 예시는 전역변수들이 이미 설정되어 있는 경우의 msfconsole을 보여줍니다.
msf > use dos/windows/smb/ms09_001_write
msf auxiliary(ms09_001_write) > show options

Module options:

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   RHOST                   yes       The target address
   RPORT  445              yes       Set the SMB service port

msf auxiliary(ms09_001_write) >



참고 : http://www.offensive-security.com/metasploit-unleashed/Msfconsole



Metasploit unleashed - msfconsole 명령어 [2]


metasploit-unleashed 튜토리얼 중 msfconsole 명령어 부분을 정리한 글입니다.


back

만약 여러분이 특정 모듈 사용이 끝나면, 혹은 실수로 잘못된 모듈을 선택했다면, 여러분은 'back' 멸령어를 사용해 그 전 상황으로 돌아가실 수 있습니다. 하지만 모듈을 사용중인 상황에서 모듈을 바로 바꿀수 있기 때문에, 굳이 back 명령어를 사용하지 않으셔도 됩니다. 그리고 변수들은 전역으로 설정되어 있을때만 유지되고 그렇지 않은 경우엔 보존되지 않습니다.
msf auxiliary(ms09_001_write) > back
msf >


check

check명령어는 실제로 exploit하는 대신 타겟이 여러분이 사용하려고 하는 공격에 취약한지 그렇지 않은지를 확인해 줍니다. 
msf exploit(ms04_045_wins) > show options

Module options:

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   RHOST  192.168.1.114    yes       The target address
   RPORT  42               yes       The target port


Exploit target:

   Id  Name
   --  ----
   0   Windows 2000 English


msf exploit(ms04_045_wins) > check
[-] Check failed: The connection was refused by the remote host (192.168.1.114:42)

connect

이것은 SSL, 프록시, 피봇, 그리고 파일 전송을 지원하는 netcat의 작은 사본입니다. 'connect' 명령어와 IP 주소, 그리고 포트 넘버를 입력하시면, 여러분은 netcat과 telnet과 같이 다른 호스트 네트워크에 접속할 수 있습니다.
msf > connect 192.168.1.1 23
[*] Connected to 192.168.1.1:23
DD-WRT v24 std (c) 2008 NewMedia-NET GmbH
Release: 07/27/08 (SVN revision: 10011)
DD-WRT login:

사용가능한 다른 옵션은 -h 를 입력하시면 보실 수 있습니다.
msf > connect -h
Usage: connect [options]  

Communicate with a host, similar to interacting via netcat, taking advantage of
any configured session pivoting.

OPTIONS:

    -C        Try to use CRLF for EOL sequence.
    -P   Specify source port.
    -S   Specify source address.
    -c   Specify which Comm to use.
    -h        Help banner.
    -i   Send the contents of a file.
    -p   List of proxies to use.
    -s        Connect with SSL.
    -u        Switch to a UDP socket.
    -w   Specify connect timeout.
    -z        Just try to connect, then return.

msf > 


irb

'irb' 명령어를 실행하면 명령어를 사용할 수 있고, 메타스플로잇 스크립트를 만들 수 있는 루비 인터프리터 셀을 제공합니다. 이 기능은 프레임 워크의 내부를 이해하는데 매우 유용한 기능입니다.
msf > irb
[*] Starting IRB shell...

>> puts "Hello, metasploit!"
Hello, metasploit!
=> nil
>> Framework::Version
=> "4.2.0-dev"
>> framework.modules.keys.length
=> 1579
>>


jobs

Jobs는 백그라운드에서 실행되고 있는 모듈을 말합니다. 'jobs' 명령어를 입력하시면 백그라운드에서 실행되고 있는 Job을 종료할 수 있습니다.
msf > jobs -h
Usage: jobs [options]

Active job manipulation and interaction.

OPTIONS:

    -K        Terminate all running jobs.
    -h        Help banner.
    -i   Lists detailed information about a running job.
    -k   Terminate the specified job name.
    -l        List all running jobs.
    -v        Print more detailed info.  Use with -i and -l

msf > 


load

'load' 명령어는 메타스플로잇의 'plugin 디렉토리에서 플러그인을 로드합니다. 변수들은 다음의 'key=val'와 같은 형식으로 입력하시면 쉘에 넘겨줄 수 있습니다.
msf > load
Usage: load  [var=val var=val ...]

Loads a plugin from the supplied path.  If path is not absolute, fist looks
in the user's plugin directory (/root/.msf4/plugins) then
in the framework root plugin directory (/opt/framework/msf3/plugins).
The optional var=val options are custom parameters that can be passed to plugins.

msf > load pcap_log
[*] PcapLog plugin loaded.
[*] Successfully loaded plugin: pcap_log


loadpath

'loadpath' 명령어는 여러분의 페이로드, 제로 데이 스크립트, 인코더와 같은 외부 모듈을 로드해 메타스플로잇이 사용 할 수 있도록  합니다.
msf > loadpath /home/secret/modules

Loaded 0 modules.


unload

'loadpath'와는 반대로 'unload'는 로드한 플러그인과 확장 명령어들을 언로드 합니다.
msf > unload pcap_log
Unloading plugin pcap_log...unloaded.

resource

'resource' 명령어는 실행파일을 로드해 msfconsole에서 사용할 수 있도록 합니다.
msf > resource
Usage: resource path1 [path2 ...]

Run the commands stored in the supplied files.  Resource files may also contain
ruby code between  tags.

See also: makerc

msf >
Karmetasploit과 같은 공격은 karma.rc 와 같은 리소스 파일을 사용합니다.
msf > resource karma.rc
[*] Processing karma.rc for ERB directives.
resource (karma.rc)> db_connect msf3:PASSWORD@127.0.0.1:7175/msf3
resource (karma.rc)> use auxiliary/server/browser_autopwn
...snip...

실행 파일을 msfconsole에 로드하면 파일 실행과 개발시간을 단축시켜주며 자동으로 여러가지 명령어를 실행할 수 있도록 도와줍니다. msfconsole의 콘솔환경에서 실행파일을 로드 하는 방법 외에, msfconsole을 실행할 때 '-r' 옵션을 사용해 로드하는 방법도 있습니다.

root@bt:~# echo version > version.rc
root@bt:~# msfconsole -r version.rc


 _                                                      _
/  \  / \        __                          _   __    /_/ __
| |\ /  | _____  \ \            ___   _____ | | /   \  _   \ \
| | \/| | | ___\ |- -|   /\    / __\ | -__/ | | | |  || | |- -|
|_|   | | | _|__  | |_  / -\ __\ \   | |    | |_ \__/ | |  | |_
      |/  |____/  \___\/ /\  \___/   \/      \__|     |_\  \___\


       =[ metasploit v4.2.0-dev [core:4.2 api:1.0]
+ -- --=[ 775 exploits - 411 auxiliary - 120 post
+ -- --=[ 238 payloads - 27 encoders - 8 nops
       =[ svn r14414 updated 6 days ago (2011.12.14)

[*] Processing version.rc for ERB directives.
resource (version.rc)> version
Framework: 4.2.0-dev.14161
Console  : 4.2.0-dev.14065
msf > 


route

"route" command in Metasploit allows you to route sockets through a session or 'comm', providing basic pivoting capabilities. To add a route, you pass the target subnet and network mask followed by the session (comm) number.
meterpreter > route -h
Usage: route [-h] command [args]

Display or modify the routing table on the remote machine.

Supported commands:

   add    [subnet] [netmask] [gateway]
   delete [subnet] [netmask] [gateway]
   list

meterpreter >
meterpreter > route

Network routes
==============

    Subnet           Netmask          Gateway
    ------           -------          -------
    0.0.0.0          0.0.0.0          172.16.1.254
    127.0.0.0        255.0.0.0        127.0.0.1
    172.16.1.0       255.255.255.0    172.16.1.100
    172.16.1.100     255.255.255.255  127.0.0.1
    172.16.255.255   255.255.255.255  172.16.1.100
    224.0.0.0        240.0.0.0        172.16.1.100
    255.255.255.255  255.255.255.255  172.16.1.100


info

'info'명령어는 특정 모듈의 옵션과 타겟, 그리고 기타 정보를 제공합니다. 여러분이 의도하지 않은 결과를 초래하는것을 원하지 않는다면, 모듈 사용전에 그 모듈의 정보를 확인하는 습관을 가집시다.
'info' 명령어는 다음과 같은 정보도 제공합니다:
  • 작성자와 문서의 라이센스 정보
  • Vulnerability references (ie: CVE, BID, etc)
  • 모듈이 가지고 있는 페이로드 제한 정보
msf  exploit(ms08_067_netapi) > info auxiliary/dos/windows/smb/ms09_001_write 

       Name: Microsoft SRV.SYS WriteAndX Invalid DataOffset
     Module: auxiliary/dos/windows/smb/ms09_001_write
    Version: 10394
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  j.v.vallejo 

Basic options:
  Name   Current Setting  Required  Description
  ----   ---------------  --------  -----------
  RHOST                   yes       The target address
  RPORT  445              yes       Set the SMB service port

Description:
  This module exploits a denial of service vulnerability in the 
  SRV.SYS driver of the Windows operating system. This module has been 
  tested successfully against Windows Vista.

References:
  http://www.microsoft.com/technet/security/bulletin/MS09-001.mspx
  http://www.osvdb.org/48153
  http://cve.mitre.org/cgi-bin/cvename.cgi?name=2008-4114
  http://www.securityfocus.com/bid/31179


set

'set' 명령어는 현재 사용중인 모듈에서 이용하는 프레임 워크 옵션과 파라미터를 수정할 때 사용합니다.
msf auxiliary(ms09_001_write) > set RHOST 192.168.1.1
RHOST => 192.168.1.1
msf auxiliary(ms09_001_write) > show options

Module options:

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   RHOST  192.168.1.1      yes       The target address
   RPORT  445              yes       Set the SMB service port

메타스플로잇은 또한 여러분에게 인코더를 제공합니다. 여러분이 어떤 페이로드 인코딩 방식을 사용해야 할지 확실하지 않을때 이 인코더는 여러분에게 유용한 도움을 줄 것입니다.

msf  exploit(ms08_067_netapi) > show encoders

Compatible Encoders
===================

   Name                    Disclosure Date  Rank       Description
   ----                    ---------------  ----       -----------
   cmd/generic_sh                           good       Generic Shell Variable Substitution Command Encoder
   cmd/ifs                                  low        Generic ${IFS} Substitution Command Encoder
   cmd/printf_php_mq                        manual     printf(1) via PHP magic_quotes Utility Command Encoder
   generic/none                             normal     The "none" Encoder
   mipsbe/longxor                           normal     XOR Encoder
   mipsle/longxor                           normal     XOR Encoder
   php/base64                               great      PHP Base64 encoder
   ppc/longxor                              normal     PPC LongXOR Encoder
   ppc/longxor_tag                          normal     PPC LongXOR Encoder
   sparc/longxor_tag                        normal     SPARC DWORD XOR Encoder
   x64/xor                                  normal     XOR Encoder
   x86/alpha_mixed                          low        Alpha2 Alphanumeric Mixedcase Encoder
   x86/alpha_upper                          low        Alpha2 Alphanumeric Uppercase Encoder
   x86/avoid_utf8_tolower                   manual     Avoid UTF8/tolower
   x86/call4_dword_xor                      normal     Call+4 Dword XOR Encoder
   x86/context_cpuid                        manual     CPUID-based Context Keyed Payload Encoder
   x86/context_stat                         manual     stat(2)-based Context Keyed Payload Encoder
   x86/context_time                         manual     time(2)-based Context Keyed Payload Encoder
   x86/countdown                            normal     Single-byte XOR Countdown Encoder
   x86/fnstenv_mov                          normal     Variable-length Fnstenv/mov Dword XOR Encoder
   x86/jmp_call_additive                    normal     Jump/Call XOR Additive Feedback Encoder
   x86/nonalpha                             low        Non-Alpha Encoder
   x86/nonupper                             low        Non-Upper Encoder
   x86/shikata_ga_nai                       excellent  Polymorphic XOR Additive Feedback Encoder
   x86/single_static_bit                    manual     Single Static Bit
   x86/unicode_mixed                        manual     Alpha2 Alphanumeric Unicode Mixedcase Encoder
   x86/unicode_upper                        manual     Alpha2 Alphanumeric Unicode Uppercase Encoder


unset


'unset' 명령어는 'set'명령어와 반대의 기능을 제공합니다. 'set'을 통해 수정했던 파라미터를 'unset'을 통해 제거하며, 'unset all' 명령어를 통해 수정된 모든 파라미터를 원래대로 바꿀 수 있습니다.

msf > set RHOSTS 192.168.1.0/24
RHOSTS => 192.168.1.0/24
msf > set THREADS 50
THREADS => 50
msf > set

Global
======

  Name     Value
  ----     -----
  RHOSTS   192.168.1.0/24
  THREADS  50

msf > unset THREADS
Unsetting THREADS...
msf > unset all
Flushing datastore...
msf > set

Global
======

No entries in data store.

msf > 


sessions

'sessions' 명령어는 스폰된 세션을 나열하고, 사용하고, 정지시킬 때 사용합니다. 이런 세션은 쉘, Meterpreter 세션, VNC 등이 될 수 있습니다.
msf > sessions -h
Usage: sessions [options]

Active session manipulation and interaction.

OPTIONS:

    -K        Terminate all sessions
    -c   Run a command on the session given with -i, or all
    -d   Detach an interactive session
    -h        Help banner
    -i   Interact with the supplied session ID
    -k   Terminate session
    -l        List all active sessions
    -q        Quiet mode
    -r        Reset the ring buffer for the session given with -i, or all
    -s   Run a script on the session given with -i, or all
    -u   Upgrade a win32 shell to a meterpreter session
    -v        List verbose fields
실행중인 세션을 활성화 하기 위해선 'sessions -l' 명령어를 입력합니다.
msf exploit(3proxy) > sessions -l

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

  Id  Description    Tunnel
  --  -----------    ------
  1   Command shell  192.168.1.101:33191 -> 192.168.1.104:4444

주어진 세셜을 사용하기 위해선, 'session -i' 뒤에 사용하고자 하는 세션 아이디 넘버를 입력합니다.

msf exploit(3proxy) > sessions -i 1
[*] Starting interaction with 1...

C:\WINDOWS\system32>



참고 : http://www.offensive-security.com/metasploit-unleashed/Msfconsole

Metasploit unleashed - msfconsole 명령어 [1]



metasploit-unleashed 튜토리얼 중 msfconsole 명령어 부분을 정리한 글입니다.


Msfconsole

Msfcon-00.png


msfconsole은 메타스플로잇 프레임워크의 인터페이스 중 가장 널리 사용되는 인터페이스 입니다. msfconsole은 콘솔 환경을 통해 메타스플로잇 프레임 워크에서 사용할 수 있는 모든 옵션을 효율적으로 접근할 수 있습니다. 처음엔 콘솔 환경이 어려워 보일 수 있지만, 명령어 문법에 대해 조금만 공부하시면 msfconsole 인터페이스의 진가를 알 수 있을겁니다.

이점 :

  • 메타스플로잇에서 제공하는 대부분의 기능을 사용할 수 있는 유일한 방법입니다.
  • 콘솔 환경 인터페이스를 제공합니다.
  • 안정적인 메타스플로잇 인터페이스의 장점을 모두 가지고 있습니다.
  • msfconsole 안에서 외부 명령어의 실행이 가능합니다 :
      예시)
msf > ping -c 1 192.168.1.100
[*] exec: ping -c 1 192.168.1.100

PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=128 time=10.3 ms

--- 192.168.1.100 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 10.308/10.308/10.308/0.000 ms
msf >


실행

msfconsole을 실행하려면 단지 커맨드라인에 'msfconsole' 이라고 입력하시면 됩니다. msfconsole은 디렉토리 the /opt/framework/msf3 에 있습니다.
root@bt:~# msfconsole

 _                                                      _
/  \  / \        __                          _   __    /_/ __
| |\ /  | _____  \ \            ___   _____ | | /   \  _   \ \
| | \/| | | ___\ |- -|   /\    / __\ | -__/ | | | |  || | |- -|
|_|   | | | _|__  | |_  / -\ __\ \   | |    | |_ \__/ | |  | |_
      |/  |____/  \___\/ /\  \___/   \/      \__|     |_\  \___\


       =[ metasploit v4.2.0-dev [core:4.2 api:1.0]
+ -- --=[ 775 exploits - 411 auxiliary - 120 post
+ -- --=[ 238 payloads - 27 encoders - 8 nops
       =[ svn r14414 updated today (2011.12.14)

msf > 


도움말

만약 도움이 필요하시면 msfconsole 뒤에 '-h' 명령어를 입력하세요. '-h' 명령어는 msfconsole 실행시 사용가능한 옵션들을 보여줍니다.
root@bt:~# msfconsole -h
Usage: msfconsole [options]

Specific options:
    -d                               Execute the console as defanged
    -r                     Execute the specified resource file
    -o                     Output to the specified file
    -c                     Load the specified configuration file
    -m                    Specifies an additional module search path
    -p                       Load a plugin on startup
    -y, --yaml         Specify a YAML file containing database settings
    -e ,     Specify the database environment to load from the YAML
        --environment
    -v, --version                    Show version
    -L, --real-readline              Use the system Readline library instead of RbReadline
    -n, --no-database                Disable database support
    -q, --quiet                      Do not print the banner on start up

Common options:
    -h, --help                       Show this message

msfconsole을 실행한후 명령어 프롬프트에서 'help'나 '?'를 입력하시면 콘솔환경에서 사용가능한 명령어와 그 명령어에 대한 설명을 보여줍니다.

msf > help

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

    Command       Description
    -------       -----------
    ?             Help menu
    back          Move back from the current context
    banner        Display an awesome metasploit banner
    cd            Change the current working directory
    color         Toggle color
    connect       Communicate with a host
    exit          Exit the console
    help          Help menu
    info          Displays information about one or more module
    irb           Drop into irb scripting mode
    jobs          Displays and manages jobs
    kill          Kill a job
    load          Load a framework plugin
    loadpath      Searches for and loads modules from a path
    makerc        Save commands entered since start to a file
    quit          Exit the console
    reload_all    Reloads all modules from all defined module paths
    resource      Run the commands stored in a file
...snip...


탭 자동 완성

msfconsole은 사용자가 빠르게 사용할 수 있도록 디자인 되었으며 이 목표를 달성하기 위해 탭 자동완성 기능을 제공합니다. 수많은 모듈들의 정확한 이름과 위치를 정확하게 기억한다는 것은 어려운 일입니다. 다른 쉘처럼, 여러분이 기억하고 있는 부분을 입력하고 탭을 입력하시면 사용가능한 옵션을 보여줍거나, 완성할 수 있는 단어가 하나 뿐일땐 그 단어를 자동으로 완성해 줍니다. msfconsole의 자동 완성기능은 ruby readline 확장프로그램을 기본으로 하며, 거의 모든 명령어에서 자동 완성 기능을 지원합니다.
  • use exploit/windows/dce
  • use .*netapi.*
  • set LHOST
  • show
  • set TARGET
  • set PAYLOAD windows/shell/
  • exp

msf > use exploit/windows/smb/ms
use exploit/windows/smb/ms03_049_netapi
use exploit/windows/smb/ms04_007_killbill
use exploit/windows/smb/ms04_011_lsass
use exploit/windows/smb/ms04_031_netdde
use exploit/windows/smb/ms05_039_pnp
use exploit/windows/smb/ms06_025_rasmans_reg
use exploit/windows/smb/ms06_025_rras
use exploit/windows/smb/ms06_040_netapi
use exploit/windows/smb/ms06_066_nwapi
use exploit/windows/smb/ms06_066_nwwks
use exploit/windows/smb/ms06_070_wkssvc
use exploit/windows/smb/ms07_029_msdns_zonename
use exploit/windows/smb/ms08_067_netapi
use exploit/windows/smb/ms09_050_smb2_negotiate_func_index
use exploit/windows/smb/ms10_061_spoolss
msf > use exploit/windows/smb/ms08_067_netapi


참고 : http://www.offensive-security.com/metasploit-unleashed/Msfconsole