2025/05/07

Comprehensive Experiment 1 - Experiment of Cyber Security Lesson in Wuhan University

【Experiment description】

The task of this experiment is to penetrate the host of the intranet through the proxy through the host of the external network. During the penetration process, it is generally necessary to first scan the port to guess the services running on the host, and then further determine the existence of the vulnerability through vulnerability scripts and other scanning tools, so as to complete the host penetration and obtain permissions.

The task of this experiment is to penetrate the host of the intranet through the proxy through the host of the external network. During the penetration process, it is generally necessary to first scan the port to guess the services running on the host, and then further determine the existence of the vulnerability through vulnerability scripts and other scanning tools, so as to complete the host penetration and obtain permissions.

In this experiment, you need to find a string with the word flag{32-bit MD5} as a credential for completing the task, and put the flag into the form to submit it.


【Purpose of experiment】

【Experimental Environment】

Operating SystemIP AddressServer RoleLogin Account Password
Windows7192.168.1.200Operating machineUsername: administrator; Password: Simplexue123
centos 7192.168.1.10Target machineUsername: root; Password: Simplexue123
Windows2012192.168.2.10Target machineUsername: administrator; Password: Simplexue123
Windows2012192.168.2.11Target machineUsername: administrator; Password: Simplexue123

 

Task 1 Backend file upload

First, use the nmap tool to scan the target IP provided by the experimental platform, check open familiar ports, and look for web services.

192.168.1.10

192.168.2.10

192.168.2.11

image-20250429102253156

image-20250429102650776

image-20250429103434219

From the scan results, we find the target machine192.168.1.10(centos7) The HTTP service is opened on port 80 in the machine, and use the browser to view the web page

image-20250429154132183

Confirm that the web page does exist. Next, use wwwscan to scan the website directory and discover the background path./manager/login.phpand/member/login.php

image-20250429110844264

/manager/login.php

image-20250429151235917

/member/login.php

image-20250429151205997

Using Burp Suite pair/manager/login.phpPerform blasting. Configure the proxy of Burp Suite and start the interception function to send POST requests to the Intruder tool for blasting.

When the username and password are not determined, the Cluster Bomb mode is used for blasting. Combine common user names (such as admin, administrator, root, etc.) with common passwords (selected from the commonly used password files that come with the platform).

image-20250429155239043

In the picture aboveuseridLoading admin, administrator, root (including initial case variants),pwdCommonly used 1000 password files included in the location loading platform system

image-20250429155552862

At the end of the attack, sort by the returned length, analyze the returned results and determine the correct username and password combination based on the returned response length.

image-20250429161324182

The login user cookie is set in the account name admin (case insensitive) password 1q2w3e4r situation, so it can be determined that this is the correct username and password combination. Now the proxy is closed successfully and enters the website management background, which can be seen from it.flag1{5d41402abc4b2a76b9719d911017c592}

image-20250429161801163

Then, use the file manager in attachment management -> file upload to upload a sentence in the tool folder Trojan 'shell.php', note that the current directory here is/uploads

image-20250429162228869

Try to use the kitchen knife tool to connect to the webshell, the connection is successful and the WebShell permission is obtained

image-20250429162934118

image-20250429163315075

Task 2 sql injection

By observing/sqlThe directory, found that this page shows the SQL statements that handle URL query parameters in the backend. The default return information is as follows

image-20250429163904023

Try to modify the query parameters, try to limit the id value here, and try to use the previous login formuseridFields

It was found that the background may only be able to parse id query parameters, but this is enough for us to implement SQL injection

image-20250429164018475

image-20250429164101519

In the previous chapter, nmap has scanned the website to use mysql. In order to obtain basic information of the website database, you need to first determine how many columns this select statement returns.

useORDER BYThe clause detects the number of columns returned by the result and determines the database structure. . When an index exceeds the actual number of columns is written, the database will report an error like "Unknown column index", and gradually increase the number from 5 to try

It is found that when sorted in column 10, you can query normally

image-20250429165510096

However, when sorting in column 11, the backend reports an error, and the total number of 10 columns in the dede_admin table is determined.

image-20250429165529192

Now confirm the display position

image-20250429165839226

It can be seen that the user ID should be in the first position of the table and the account number should be in the third position.

Now build the SQL statement to find the database user and database name currently used

image-20250429170036099

Now use this vulnerability to upload webshell. From the previous chapter, we know that the 80 port service is Apache Httpd. When querying relevant information, we know that the configuration file is located in the path./etc/httpd/conf/httpd.conf

Refer to https://cloud.tencent.com/developer/article/1918345, you can inject it into mysql database.LOAD_FILE()Functions read file contents and obtain web server configuration file

image-20250429170556555

searchDocumentRoot, confirm the path/var/www/htmlFolders are the root directory of the website

image-20250429170720494

Now you need to store a sentence Trojan in this directory, you can use mysqlINTO OUTFILEUpload a sentence Trojan to the root directory of the web server

image-20250430112336827

image-20250430112426895

You can see that a text file was successfully uploaded to the website root directory. Now replace the content with the most commonly used Trojan horse and upload it to the website root directory.webshell.phpdocument.

Discover the returned SQL statement<Escaped but>The symbols are not transferred, so the problem of encoding and decoding is excluded.

image-20250430113329484

Try putting it in the query parameters again<, found that the corresponding body should have been<Replaced with&#39;(single quotation mark in HTML code), guess all in the backend processing logic<Replaced.

image-20250430113603590

However, mysql supports writing using hexadecimal literal blobs,

image-20250430120554274

Convert a sentence Trojan into hexadecimal ascii encoding and then pass the functionUNHEX()Write, so as to avoid the countermeasures in the back-end business before executing the "sql statement written to the database"<Filter of

image-20250430122901514

Now you can try to connect through the kitchen knife and get the flagflag3{fd5d4d5a199e9e8bfadead5f5e52895a}

image-20250430122950178

 

Task 3 phpmyadmin write shell

In Task 1, the path of PHPMyAdmin was successfully discovered through wwwscan scan.

Test PhpMyAdmin default username and password root/root, and found that the direct login was successful

image-20250430123240611

 

image-20250430123352246

 

Can be used in this pageSQLStatements are executed online to obtain various information, for example

SELECT load_file("/etc/httpd/conf/httpd.conf");

image-20250502012712668

image-20250502012911754

Query the location of the root directory of the website DocumentRoot,/var/www/html

Directly use PHPMyAdmin's SQL execution function to pass a sentence TrojanINTO OUTFILEUpload to the web root directory,

image-20250502015326104

 

image-20250502015341896

Successfully obtained shell permissions and at the same time in the website databasededecmsv57utf8sp1Search in the search indicatesflagCan be foundflag2{912ec803b2ce49e4a541068d495ab570}

image-20250502015520018

 

Task 4. Scan the PC and log in

In the web port scan foldersocks.pyandRASscan.pyTwo files, of whichsocks.pyAs a tool function,RASscan.pyScan the script main portal for intranet

image-20250502021032562

implementpython RASscan.py 192.168.2.1 192.168.2.255 -t 16Scan the intranet segment 192.168.2.0/24. This process is unexpectedly slow. Pay attention to interacting with the desktop regularly during the experiment to prevent the system from recycling virtual machine resources.

image-20250502125917453

 

image-20250502130353887

 

Found some192.168.2.10and192.168.2.11The two machines have port 3389 open and can log in remotely, but these two intranet addresses are located under the same intranet as the web server and cannot be directly accessed through the user machine. Therefore, the proxy service needs to be enabled on the server.

Refer to the experimental platform tips, upload the regeorg tool to the web machine to enable proxy services

image-20250502130905760

 

image-20250502131214380

Use the proxifier tool on the client to proxy remote connection access 2.11 (2.11 means ip192.168.2.11) After configuring the proxy, use rdp to connect to the desktop

image-20250502131446789

image-20250502131646729

I found that I needed a password to log in, and I thought of looking for a password in the server's file or database. Before that, I added direct rules for firefox.exe in the proxifier.

image-20250502131841358

After exporting the database, searching for the administrator field, and discovering a suspected passwordtopsec.123

image-20250502133049554

Try two scanned machines in turn, and find192.168.2.11You can use this password to log in on the machine, and find the flag in the c disk,flag4{238fb735876083b832229d279b995062}

image-20250502133335325

Task 5: Crawl the domain control password and log in to the domain control

The experimental task requires the machine logged in to a remote desktop using mimikatz.192.168.2.11Crawl password

Connecting to via RDP successfully192.168.2.11After that, select the C disk of the shared user machine on rdp to upload the user machine's tools to the attacked desktop machine, upload the Mimikatz tool and execute itsekurlsa::logonpasswordsCommand to grab plaintext passwordSimplexue123

Reference heremimikatz抓取明文密码 | ssooking's notebookCrawl password

mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords full"

image-20250502134029695

image-20250502134441391

Use this password to log in to other intranet hosts192.168.2.10, successfully obtained flagflag5{6aa16f9b07f2d00b16b94aa797488b38}

image-20250502134622210

 


Final

Through the above steps, this experiment gradually completed the penetration test of the target host, successfully obtained multiple flags, and verified different types of vulnerabilities and attack methods.

0 评论:

发表评论