Chapter 1: Understanding Emergency Response

0 21
Chapter 1: Understanding Emergency ResponseAs cybersecurity professionals, we ar...

Chapter 1: Understanding Emergency Response

As cybersecurity professionals, we are not unfamiliar with cybersecurity. Cybersecurity refers to the protection of the hardware, software, and data within the network system, ensuring that it is not destroyed, altered, or leaked due to accidental or malicious reasons, guaranteeing the continuous, reliable, and normal operation of the system, and uninterrupted network services. In the face of various strange viruses and countless security vulnerabilities, establishing an effective cybersecurity emergency response system and continuously improving it has become an inevitable requirement for the development of the information society.

So far, network security emergency response is on the horizon. Network security emergency response refers to the monitoring, analysis, coordination, handling, and protection of asset security for security incidents that have occurred or may occur. Network security emergency response is mainly to make people aware of and prepared for network security, so that they can respond in an orderly manner and handle properly when they encounter sudden network security incidents.

Chapter 2: Emergency Response Process

Chapter 1: Understanding Emergency Response

For beginners, first we should know how to deal with a real emergency response work, and learning through the full process is more conducive to our quick start.1677574216_63fdc04807f04bddfa197.png!small

First, response:

(1) Event type judgment:

1677574222_63fdc04e9b96ac2247a68.png!small

(2) Information collection
Information collection mainly involves: traffic, logs, memory of suspicious processes, compromised system images, malicious samples, customer asset collection, vulnerability test reports related to assets, and logs of defense equipment. Here is a recommended emergency response tool, link as follows:

https://github.com/ra66itmachine/GetInfo/

1677574238_63fdc05eb929967a4f004.png!small

  • Blocking
    So-called blocking only has three steps: shut down the site, shut down the service, and pull out the network cable.
    (1) Cutting off the network
    There are many situations: business operations are normal after collapse, business operations are delayed after collapse, and business operations are suspended after collapse. Different situations require different network cuts.
    The purpose of cutting off the network is to observe virus behavior, observe traffic characteristics, block internal communication, and block external connections.
    For example: a large-scale collapse of a hospital, but business operations are normal, at this time, you can choose to cut off some unimportant hosts to observe behavior.
    (2) Blocking spread
    Spread includes: internal spread (infection), external spread (external link)
    Internal spread (infection): process injection/migration, third-party software infection, service spread (ftp/ssh brute force, etc.)
    External communication (external link): mining behavior, external link attack, c2 communication
    Blocking the spread should start from: software level, traffic level, code level, and network level.

For example: investigate software hijacking, investigate traffic to find no file landing, use code audit to find container loading memory horses, and block the virus spreading through services.
(3) Isolation of core assets/Isolation of affected subject (group)
This step is the ultimate goal of emergency response, regardless of the implementation process or the tools used, it must be ensured that the isolated and compromised parties are isolated.
Isolating core assets is to achieve three principles: protection, avoidance of harm, and not causing harm.
Isolating the affected subject (group) is to protect the first scene, collect attacker information, and so on.

  • Analysis
    Analysis is the premise of abstraction, abstracting key information for analysis. The premise of abstraction is familiarity and understanding of attack methods.
    (1) Analysis of Logs, Traffic, and Samples
    Analyze the three major components: logs, traffic, and samples.
    The main points of logs are: time, action, result; when this behavior starts and ends, what kind of action is login, logout, modification, etc., and what kind of result is login success/failure, upload/downloaded files, executed code, etc.
    The main points of traffic are: status code, interaction process, data rationality; every status code of interaction, whether the interaction process conforms to the correct interaction process of this protocol, the filling of each field, whether the rendering of each traffic is normal.
    The main points of the sample are: startup method, disguise method, and function; choose a sandbox or analysis tool according to the startup method; judge whether to add a shell for anti-kill and strike method according to the disguise method; judge the scope of damage according to the function.
    Logs are static information, and emergency personnel need to clearly distinguish the content expressed by logs and quickly filter out suspicious points. Traffic and samples are dynamic information, and emergency personnel need to have certain penetration capabilities to distinguish interactive behavior.
    (2) Behavior Analysis & Attack Restoration Process
    Starting from behavior, restore the attack path and deduce the attack process.
    Behavior analysis is based on the analysis of the three major components, combined with the system's performance to make analysis, such as: startup items, startup scripts, processes, memory, etc.
    To restore the attack process, it is necessary to have a comprehensive judgment of the general situation of the attack and must possess penetration capabilities. On this basis, put the attack process into a sandbox to re-enact the attack process to provide assistance for subsequent steps.

①The following are the basic manual analysis and collection commands for emergency response to Windows and Linux that I have sorted out:

Step 1: System Troubleshooting

1. Windows system

Enter the command 【msinfo32】in the command line -- view services and drivers.

Enter the command 【systeminfo】in the command line -- simply view system version/host name.

2. Linux system

Enter the command 【lscpu】in the command line to view CPU-related information.

Enter the command 【uname -a】in the command line to view the current operating system information.

Enter the command 【cat /proc/version】in the command line to view the current operating system version information.

Enter the command 【lsmod】in the command line to view the information of all modules loaded into the system.

SecondStep: Startup Item

1. Windows system

Enter the command 【msconfig】in the command line to view the detailed information of startup items.

2. Linux system

By using the command 【cat /etc/init.d/rc.local】, you can view the content of the rc.local file under the init.d folder.

By using the command 【cat /etc/rc.local】, you can view the content of the rc.local file.

By using the command 【ls -alt /etc/init.d】, you can view the detailed information of all files under the init.d folder.

ThirdStep: Scheduled Task

1. Windows system

By entering the command 【Get-ScheduledTask】, you can view the information of all scheduled tasks in the current system.

Enter the command 【schtasks】in the command line to obtain information about task plans.

2. Linux system

Enter the command 【crontab -l】in the command line to view the current task plan.

Enter the command 【ls /etc/cron*】to view all task plan files under the etc directory.

FourthStep: Firewall

1. Windows system

Enter the command 【netsh】in the command line to view.

Use the command 【netsh Firewall show state】to display the current network configuration status of the firewall.

2. Linux system

None

Fifth step: Process investigation

1. Windows system

Enter the command 【tasklist】in the command line to display all processes running on the computer.

Enter the command 【tasklist /svc】to display the corresponding process and service for each process.

Enter the command 【tasklist /m】to query malicious processes that load DLLs.

Use the command 【netstat -ano | findstr "ESTABLISHED"】to view the current network connections and locate suspicious ESTABLISHED connections.

Use the command 【tasklist | find "2856"】to view the specific program.

The command 【Get-Wmi ObjectWin32_Process | select Name, ProcessId, ParentProcessId, Path】uses Get-WmiObject Win32_Process to represent obtaining all information about the process.

Use the command 【wmic process get name,parentprocessid,processid /format:csv】to display the process name, parent process ID, and process ID in csv format.

2. Linux system

Use the command 【ls -alt /proc/PID】to view the corresponding executable program.

Use the command 【kill -9 PID】to end the process.

SixthStep: Service investigation

1. Windows system

Enter the command 【services.msc】to open the 【Services】window.

2. Linux system

Entering the command 【chkconfig --list】in the command line can view the services running on the system.

SeventhStep: File trace investigation

1. Windows system

Check the related temp (tmp) directories under each disk, browser history, downloaded files, and cookie information.

The command 【forfiles /m *.exe /d +2020/2/12 /s /p c:\ /c "cmd /c echo @path @fdate @ftime" 2>null】is used to search for newly created exe files after 2020/2/12.

2. Linux system

Check the /tmp directory and the command directory /usr/bin /usr/sbin

Check the paths ~/.ssh and /etc/ssh, which are often used as some backdoor configuration paths

Use the command 【find / -ctime 0 -name "*.sh"】to find new sh files within a day

EighthStep: Log troubleshooting

1. Windows system

Use the command 【Get-WinEvent -FilterHashtable @{LogName='Security';ID='4625'}】

You can also obtain all log information under the security log with event ID 4625

FullEventLogView tool (green installation, easy to use)

2. Linux system

Logs in Linux systems are generally stored in the directory "/var/log/"

NinthStep: Memory troubleshooting and traffic analysis

Common extraction tools include Dumpit, Redline, RAM Capturer, FTK Imager, etc. -- upload the extracted files to the virustotal platform for scanning and judgment

Common memory analysis tools include Redline/Volatility, for example, wireshark

Use the command 【ip.addr ==ip】to filter specific IP addresses

Use the command 【ip.src==ip】to filter the specified source IP address

Directly enter protocols such as HTTP, HTTPS, SMTP, ARP, etc. for filtering

Use the command 【top.port==port number】or 【udp.port==port number】to filter ports

Use the command 【tcp contains strings】to search for keywords in data packets

TenthStep:Webshell in Linux system troubleshooting

find https://www.freebuf.com/articles/system/ -type f -name "*.jsp" |xargs grep "exec("

find https://www.freebuf.com/articles/system/ -type f -name "*.php" |xargs grep "eval("

find https://www.freebuf.com/articles/system/ -type f -name "*.asp" |xargs grep "execute("

find https://www.freebuf.com/articles/system/ -type f -name "*.aspx" |xargs grep "eval("

Search for web page files adapted to the current application under the directory, check if there are Webshell features, many trojans and large trojans are equipped with typical command execution feature functions, such as exec(), eval(), execute(), etc.

IV.、Clearing
What we need to do is no different from penetration - 'do a good job of cleaning up and hide yourself well'.
(1) In the case of non-resistance
In the absence of resistance, the most extreme is a complete reinstallation, slightly less is data migration followed by reinstallation of the system disk. In ordinary cases, we can carry out targeted process killing, file deletion, and anti-virus cleaning.
(2) In the case of resistance
The situation of resistance is: stubborn trojans and immortal trojans exist, or they are continuously attacked (APT).

In such a situation, the first choice is to apply patches if allowed, and then restore. Find the source of the attack behavior, patch the vulnerability first and then clear it.

V.Strengthening
Strengthening is to apply patches, impose restrictions on the system (network isolation, behavior management), upgrade defense equipment, and improve defense processes (deployment of defense equipment, personnel deployment, rule base upgrade)

Chapter 3: Emergency Response Practice

After understanding some basic concepts and guidance manuals of emergency response, of course, only practical operation can make us master the basic operations of emergency response more quickly.

Open the target machine, first look at the question, let's see what we need to do in emergency response~

1677574264_63fdc078aa48aa1e4d494.png!small

Let's get started, provide us with a remote connection to the host, don't worry about it, let's log in and take a look

1677574272_63fdc080497898e233c19.png!small

It was found that there was only one phpstudy_pro interface, and nothing else.

Step 1: Privilege escalation method

We first judge the type of emergency response event, then we can treat the symptoms accordingly. It's not a coincidence that the question asks to find a trojan, a backdoor, and the scenario provides the answer to find webshell. According to the套路, based on the webshell tools I have collected (as follows), let's get started~1677574295_63fdc0979ea273c731e9d.png!small

Horse scan the site directory as shown in Figure 1, scanned out 16 suspicious backdoors as shown in Figure 2, check these .php files as shown in Figure 3, manually confirmed and none of them are, and no trojan was found as claimed

1677574301_63fdc09deee63ed743ab0.png!small

Figure 1

1677574313_63fdc0a927dacf7819e59.png!small

Figure 2

1677574323_63fdc0b3054abf5bc5506.png!small

Figure 3

It seems that anti-virus bypassing has been done, let's check the apache logs

1677574332_63fdc0bcebed001bcb880.png!small

Through the logs, it can be found that at the beginning, SQL injection was being performed, various payloads, and then the directory scanning began

A preliminary look did not find the so-called trojan file, since he performed SQL injection, it is possible to get a shell through SQL and then escalate privileges, so I went to look under the sql folder

The result found the udf.dll file, then the first step of the hacker's privilege escalation should be udf privilege escalation

1677574338_63fdc0c228bddba906546.png!small

1677574350_63fdc0ce3d8440b4f9328.png!small

The second step is to find 'the webshell of hackers'

There is really nothing good to do here, you can only find it from the log analysis of Figure 1, which is a lot of work. The discovery is from a pile of post request logs, where a get request was found, and then a look was taken, and the result was indeed a webshell, the webshell is in /dede/inc/config_sys.php

1677574355_63fdc0d374d2caee4c819.png!small

Figure 1

1677574365_63fdc0ddd16fe09523749.png!small

1677574376_63fdc0e8d800329a934ba.png!small

1677574385_63fdc0f1722a0ea41a394.png!small

Step 3: Hacker's Account

This is relatively simple, the activity of viewing basic information in Windows and Linux, we use net user to view in Windows~

1677574389_63fdc0f5be19e97889291.png!small

There are two ways to delete it: ① Command line mode: net user xxx /delete; ② Graphical interface: Server Manager -> Configuration -> Local Users and Groups -> Users, and delete the user

1677574398_63fdc0fe7d0d27df6e2ec.png!small

1677574405_63fdc105179988a55b3eb.png!small

Step 4: Backdoor Trojan

We use the command netstat -ano to view it, which is universal in both Windows and Linux, as follows, netstat -ano to view the current connections, and directly lock 23.23.23.23

1677574414_63fdc10e0b8fa85123d33.png!small

1677574420_63fdc11433884a6457a29.png!small

Step 5: Strengthen the Server

It is also a relatively simple question, we can modify the minimum password length in the Local Security Policy -> Account Policy -> Password Policy under the Start Menu.

By the way, in Linux, in the basic operations of strengthening the server, we use the vim editor to edit the /etc/pam.d/system-auth parameters.

1677574427_63fdc11b376349bde2372.png!small

Step 6: Delete the Trojan

Find the process number 6184 through the IP obtained in step 4, use the command [tasklist | find "6184"] to view the specific program, and finally directly lock system6.exe, and the deletion is completed

1677574434_63fdc12292e187b2c08cb.png!small

1677574444_63fdc12c80dc8823849f5.png!small

1677574449_63fdc131d9e4a42695ea3.png!small

Ps: The system6.exe here is in the startup item, we can directly close the startup item in the system configuration and delete it, but it will not be successful. Here, I recommend D盾, after installation, you can also find system6.exe in the process view, and you can directly close the program and delete it.

1677574484_63fdc154ea65ce47715bb.png!small1677574489_63fdc159de6d4681f40f4.png!small

Step 7: Fix the Vulnerability

From the first step, it is known that it is a UDF privilege escalation, where UDF refers to the user-defined function. By adding new functions, the functionality of mysql is expanded. To use UDF for privilege escalation, file read and write operations need to be performed through sql, so limiting its file read and write permissions can fix the vulnerability. Here, searching for information, it is found that secure_file_priv can fix the vulnerability

1677574494_63fdc15e8676362d4d014.png!small

Below is the addition of secure_file_priv=null under the my.ini configuration file under the mysql configuration file [mysqld]:

1677574498_63fdc16264c8f70e337b6.png!small

1677574504_63fdc16810f9318c902df.png!small

Restart the mysql database, then check it, done!

1677574509_63fdc16d38991876fbf2e.png!small

Theory plus practice, take emergency response with ease!

Chapter 4: Summary of Emergency Response

  1. Emergency personnel should have their own methodology, model the threats of different attacks, possess threat intelligence analysis capabilities, and combine tool assistance for on-site response and remote support.
    Tools and investigation points are similar, the way to improve lies in whether the emergency personnel are familiar with this type of attack, and using features and behaviors to investigate can save more time.
    3. Red and blue origin, emergency response belongs to the blue team, but must have certain penetration capabilities.

Ps: Below are some tools for improving efficiency that I have organized and summarized.

01, Multi-engine Online Virus Scanning

When a suspicious abnormal file is found, scan and detect the file using multiple different virus engines to confirm whether the file is malicious code.

①VirSCAN: Free multi-engine online virus scanning version 1.02, supporting 47 antivirus engines.

https://www.virscan.org/

②VirusTotal: A website providing free suspicious file analysis services.

https://www.virustotal.com/

③Jotti: A malicious software scanning system that uses several antivirus programs to scan suspicious files.

https://virusscan.jotti.org

02, Virus Detection and Removal Software

Under the condition of network connection, directly download antivirus software for full disk scanning and removal.

①360 Antivirus: Integrating five leading detection and removal engines with a high detection and removal rate.

https://sd.360.cn/

②Huorong Security Software: A very refined software that includes Huorong Sword, an analysis tool very useful for security professionals.

https://www.huorong.cn/

03, Virus Removal Tool

When you cannot connect to the internet, you can use a green, no-install virus removal tool to scan all files on your computer.

①Dr.Web CureIt: A green, no-install version with all the features of the standalone Dr.Web.

https://free.drweb.ru/download+cureit+free/

②Rootkit Backdoor Detection Tool: Used to check the tools behind rootkit locally.

chkrootkit:http://www.chkrootkit.org

04, Ransomware Search Engine

The most powerful tool for ransomware self-help, by entering the virus name or the encrypted file extension, you can find the decryption tool or learn about the virus details.

①【Tencent】 Ransomware Search Engine, supporting the search of over 1000+ common ransomware.

https://guanjia.qq.com/pr/ls/

②【360】 Ransomware Search Engine, supporting the search of over 800 common ransomware.

http://lesuobingdu.360.cn05

05, Webshell Detection Tool

When a website is hacked, we need a Webshell detection tool to help us find webshells and further investigate potential security vulnerabilities in the system.

①D盾_Web detection: http://www.d99net.net/index.asp

②Baidu WEBDIR+: https://scanner.baidu.com/

③Horse webshell detection: http://www.shellpub.com

06, Security Analysis Tools

①SysinternalsSuite: It includes a series of free system analysis tools, such as Process Explorer, Startup Item Analysis Tool AutoRuns, etc.

https://docs.microsoft.com/zh-cn/sysinternals/downloads/

②PCHunter: A powerful manual antivirus auxiliary tool.

http://www.xuetr.com

07, Log Analysis Tools

We often need to deal with various logs, such as system logs, WEB logs, DNS logs, etc., a simple and convenient log analysis tool can greatly improve efficiency.

①Log Parser: A log analysis tool produced by Microsoft, it is powerful and easy to use.

https://www.microsoft.com/en-us/download/details.aspx?id=24659

②EmEditor: It may be the fastest Windows text editor in the world, supporting large text up to 248 GB.

https://www.emeditor.com/#download




你可能想看:
最后修改时间:
admin
上一篇 2025年03月27日 21:45
下一篇 2025年03月27日 22:07

评论已关闭