1. 程式人生 > 其它 >netsh 無檔案攻擊

netsh 無檔案攻擊

netsh濫用例子:

https://any.run/report/f77d0ef3d5aa74b233cb642fa5b6dab1c57c9cde503e1a3dd085dba621fbb45c/aa925b1d-19c8-497f-b328-3364e85297b4

==》 刪除防火牆規則:C:\Windows\system32\netsh.exe advfirewall firewall delete rule profile=any name="ragent.exe"

https://any.run/report/6333aaa3b8d8dd2dfb449065a012b50d177048d1fec943a4ab2ebaf02eefd6dc/d4aed934-1cb6-44d2-97e3-f0239406ca85

==》新增防火牆白名單:netsh firewall add allowedprogram "C:\Users\admin\AppData\Local\Temp\Server2.exe" "Server2.exe" ENABLE

 

 

Netsh 命令語法、上下文和格式設定

 

適用於: Windows server 2022,Windows Server 2019,Windows Server 2016,Azure Stack HCI,版本21H2 和20H2

你可以使用本主題來學習如何輸入 netsh 上下文和子上下文、瞭解 netsh 語法和命令格式,以及如何在本地和遠端計算機上執行 netsh 命令。

Netsh 是命令列指令碼實用工具,可讓你顯示或修改當前正在執行的計算機的網路配置。 可以通過在 netsh 提示符下鍵入命令來執行 Netsh 命令,並且可以在批處理檔案或指令碼中使用 Netsh 命令。 可以使用 netsh 命令來配置遠端計算機和本地計算機。

Netsh 還提供指令碼功能,可讓你在批處理模式下對指定的計算機執行一組命令。 你可以使用 Netsh 將配置指令碼儲存在文字檔案中,以便存檔或者幫助你配置其他計算機。

Netsh 上下文

Netsh 通過使用動態連結庫 (DLL) 檔案與其他作業系統元件進行互動。

每個 netsh 幫助程式 DLL 提供一組稱為“上下文”的廣泛功能,這是一組特定於網路伺服器角色或功能的命令 。 這些上下文通過為一個或多個服務、實用工具或協議提供配置和監視支援來擴充套件 netsh 的功能。 例如,Dhcpmon.dll 向 netsh 提供配置和管理 DHCP 伺服器所需的上下文和命令集。

獲取上下文列表

可以通過在執行 Windows Server 2016 或 Windows 10 的計算機上開啟命令提示符或 Windows PowerShell 來獲取 netsh 上下文列表。 鍵入命令 netsh ,然後按 enter。 鍵入 /?,然後按 Enter 。

下面是執行 Windows Server 2016 Datacenter 的計算機上的這些命令的示例輸出。

PS C:\Windows\system32> netsh
netsh>/?

The following commands are available:

Commands in this context:
..            - Goes up one context level.
?             - Displays a list of commands.
abort         - Discards changes made while in offline mode.
add           - Adds a configuration entry to a list of entries.
advfirewall   - Changes to the `netsh advfirewall' context.
alias         - Adds an alias.
branchcache   - Changes to the `netsh branchcache' context.
bridge        - Changes to the `netsh bridge' context.
bye           - Exits the program.
commit        - Commits changes made while in offline mode.
delete        - Deletes a configuration entry from a list of entries.
dhcpclient    - Changes to the `netsh dhcpclient' context.
dnsclient     - Changes to the `netsh dnsclient' context.
dump          - Displays a configuration script.
exec          - Runs a script file.
exit          - Exits the program.
firewall      - Changes to the `netsh firewall' context.
help          - Displays a list of commands.
http          - Changes to the `netsh http' context.
interface     - Changes to the `netsh interface' context.
ipsec         - Changes to the `netsh ipsec' context.
ipsecdosprotection - Changes to the `netsh ipsecdosprotection' context.
lan           - Changes to the `netsh lan' context.
namespace     - Changes to the `netsh namespace' context.
netio         - Changes to the `netsh netio' context.
offline       - Sets the current mode to offline.
online        - Sets the current mode to online.
popd          - Pops a context from the stack.
pushd         - Pushes current context on stack.
quit          - Exits the program.
ras           - Changes to the `netsh ras' context.
rpc           - Changes to the `netsh rpc' context.
set           - Updates configuration settings.
show          - Displays information.
trace         - Changes to the `netsh trace' context.
unalias       - Deletes an alias.
wfp           - Changes to the `netsh wfp' context.
winhttp       - Changes to the `netsh winhttp' context.
winsock       - Changes to the `netsh winsock' context.

The following sub-contexts are available:
 advfirewall branchcache bridge dhcpclient dnsclient firewall http interface ipsec ipsecdosprotection lan namespace netio ras rpc trace wfp winhttp winsock

To view help for a command, type the command, followed by a space, and then type ?.

子上下文

Netsh 上下文可以同時包含命令和其他上下文(稱為“子上下文” )。 例如,在 Routing 上下文中可以更改為 IP 和 IPv6 子上下文。

若要顯示可以在上下文中使用的命令和子上下文列表,請在 netsh 提示符下鍵入上下文名稱,然後鍵入 /? 或 help。 例如,若要顯示可以在路由上下文中使用的子上下文和命令的列表,請在 netsh 提示符 (即netsh ) ,鍵入以下命令之一:

routing /?

routing help

若要在不更改當前上下文的情況下在另一個上下文中執行任務,請在 netsh 提示符下鍵入要使用的命令的上下文路徑。 例如,若要在 IGMP 上下文中新增名為“Local Area Connection”的介面,且無需提前更改為 IGMP 上下文,請在 netsh 提示符下鍵入:

routing ip igmp add interface "Local Area Connection" startupqueryinterval=21

執行 netsh 命令

若要執行 netsh 命令,則必須在命令提示符下鍵入 netsh,然後按 Enter 以啟動 netsh 。 接下來可以更改為包含要使用的命令的上下文。 可用的上下文取決於已安裝的網路元件。 例如,如果在 netsh 提示符下鍵入 dhcp 並按 Enter,則 netsh 將更改為 DHCP 伺服器上下文 。 但如果未安裝 DHCP,則會顯示以下訊息:

找不到以下命令:dhcp 。