【渗透测试学习笔记2】主机信息搜集

系统信息收集

  • 基本信息 - systeminfo

systeminfo

重点关注:

  1. 补丁信息 - 后续提权需要关注

  2. 信息 - 是否加入域,加入了会显示域的名字,未加入显示WORKGROUP

  3. IP信息

  • 查看目标系统下安装的软件和版本

win10已弃用wmic

win10下使用powershell:Get-WmiObject -Class win32_product | Select-Object -Property name,version

win10查看软件版本

win10以下版本使用wmic:wmic product get name,version

  • 查看目标服务

wmic service list brief

  • 进程相关

tasklist - 查看进程

wmic process list brief - 查看进程

findstr - windows中的grep

taskkill /f /pid <pid> - 用pid结束进程

taskkill /f /im - 用进程名结束进程

技巧:使用tasklist /svc导出系统的进程信息,放到在线杀软比对中可以看到目标系统安装了哪些杀毒软件

  • 补丁

wmic qfe get caption,description,hotfixid,installedon

补丁信息

  • 查看网络共享

net share or wmic share get name,path,status

  • 查看防火墙配置

netsh firewall show config

查看防火墙配置

  • 查看网络代理

reg query "HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionInternet Settings"

  • 查看远程桌面的端口

reg query "HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp" /v PortNumber

  • 敏感信息
  1. 文件查找

dir /s /c - 递归查看文件,约等于tree

dir /s /b "<str>" - 查找制定字符串

findstr /I /C:"<query>" /C:"<query>" /si *.conf *.asp *.php - 使用findstr查找敏感信息

  1. 注册表查找
  • 查VNC密码

reg query "HKCU:SoftwareORLwinVNC3password"

  • 通配符查敏感信息

reg query HKLM /f password /t REG_SZ /s

  • 查看凭据

cmdkey /list - 查看凭据

runas /savecred /user:contoso/administrator cmd.exe - 利用凭据(本地账户)

powershell

win7+
内存加载

版本问题:版本之间可能存在不兼容问题

win7 - 2.0
win8 - 3.0
win8.1 - 4.0
win10 - 5.0

Get-Host可以查看PS版本

运行策略

Get-ExecutionPolicy - 查看运行策略

策略有四种,关注两种:

  1. restricted:禁止所有脚本运行
  2. unrestricted:允许所有脚本运行

Set-ExecutionPolicy Unrestricted - 设置运行策略,需要管理员权限

绕过策略的方法:https://zhuanlan.zhihu.com/p/27714164

PowerShell的基本加载方法:

Import-Module <file>
<function>

非常好用的powershell脚本集合:https://github.com/PowerShellMafia/PowerSploit
速查表:https://github.com/HarmJ0y/CheatSheets/blob/master/PowerView.pdf

CMD混淆

  • 使用环境变量
set a=cmd /c whoami
%a%
  • 双引号
who"""""""""""""am""""""""i
  • 转义符

windows下^是转义符

who^ami

  • 管道符

|是管道符
@向前传递参数

管道符和环境变量结合使用

  • 字符串截取

:~<start>,<length>
eg:set a=abcd & %a:~2,1%alc

  • 逗号+分号

cmd,asjadhwehifhwfwoivhioehroheiohgoheiogho,,,,,,,,,,,,,,,,,,,,,,,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;/c whoami

  • for循环

for /f "条件" in "范围"
tokens:标识第几列
delims:标识切割符

for /f "tokens=4 delims=" %g in ("C:windowssystem32powershell") do %g - 用切割后面的字符串,选取第四个分块

  • 混淆工具:Invoke-DOSfuscation

https://github.com/danielbohannon/Invoke-DOSfuscation

原文地址:https://www.cnblogs.com/yux1a0/p/14858571.html