前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >内网渗透-信息收集

内网渗透-信息收集

作者头像
Gamma实验室
发布2020-12-23 11:59:43
1.7K0
发布2020-12-23 11:59:43
举报

前言:

内网渗透的本质,是信息收集!,信息收集这一环节其实贯穿了整个内网渗透!

强烈建议收藏本文,内网渗透不再迷路!

01

立足点

立足点:

Foothold,就是我们拿到内网中一台主机权限,作为内网渗透的突破口,我们所有的操作,包括流量转发,端口扫描,漏扫等操作,都会利用此主机为我们搭桥铺路,为以后的内网横向打下坚实的基础。

02

立足点的信息收集

立足点信息收集包括:

OS、权限、内网IP段、杀软、端口、服务、补丁更新频率、网络连接、共享、

会话等

注:

如果是域内主机,OS、应用软件、补丁、服务、杀软这些一般都是批量安装的。

前方干货来袭,注意注意!

1.查询网络配置命令

  Windows:
            ipconfig /all

  Linux:    
            ifconfig /all
            cat /etc/resolv.conf
            cat /etc/sysconfig/network
            cat /etc/networks

2.查询操作系统及软件的信息

1)查看操作系统和版本信息

    windows:
              systeminfo | findstr /B /C:"OS Name" /C:"OS Version"//适用于英文的操作系统,中文的:systeminfo | findstr /B /C:"OS 名称" /C:"OS 版本"'
    
    Linux:    
               查看服务器版本信息:
               Cat /etc/issue
               Cat /etc/*-release
               Cat /etc/lsb-release #基于debian
               Cat /etc/radhat-release #基于redhat
               查看内核版本信息:
               Cat /proc/vesion
               Uname -a
               Uname -mrs
               Rpm -q kernel
               Dmesg | grep linux
               Ls /boot | grep vmlinuz-

2)查看系统体系结构

    windows:
              echo %PROCESSOR_ARCHITECTURE%
    
    Linux:    
              uname -a
              dpkg --print-architecture  //此命令只适用于基于 Debian 和 Ubuntu 的                                   Linux 发行版。
              getconf LONG_BIT
              arch
              file /sbin/init
        
       查看安装的软件及版本、路径等


    windows:
              wmic product get name,version
              Powershell版本:
              powershell.exe "Get-WmiObject -class Win32_Product | Select-Object -Property name,Version
    
    Linux:    
              Ls -alh /usr/bin/
              Ls -alh /sbin/
              Dpkg -l
              Rpm -qa
              Ls -alh /var/cache/apt/archivesO
              Ls -alh /var/cache/yum/

3.查询本机服务信息

     windows:
               wmic service list brief
    
     Linux:   
               service --status-all
               chkconfig --list
               ps aux
               进入init.d目录查看
               netstat -lntp
               ntsysv

4.查询进程列表

     windows:           
              tasklist//或者wmic process list brief 
   
     Linux:    
              ps aux 
               
     常见杀毒软件进程:                  
     360sd.exe                    
     360tray.exe                   
     ZhuDongFangYu.exe                   
     KSafeTray.exe                   
     SafeDogUpdateCenter.exe                   
     McAfee McShield.exe                   
     egui.exe //NOD32                    
     AVP.EXE  //卡巴斯基                   
     avguard.exe    //小红伞                   
     bdagent.exe    //BitDefender

5.查看启动程序信息

     windows:
               wmic startup get command,caption
     
     Linux:    
               PS
               ps aux | less  
               top
               pstree
               htop
               atop

6.查看计划任务

    windows:
              schtasks /query /fo LIST /v
   
    Linux:    
              crontab -l               

7.查看主机开机时间

    windows:
               net statistics workstation
   
    Linux:    
               last  reboot //查看历史启动时间
               W//系统到目前运行了多久时间。反过来推算系统重启时间
               uptime
               TOP//up后表示系统到目前运行了多久时间。反过来推算时间
               who -b 查看最后一次系统启动的时间。
               who -r 查看当前系统运行时间

8.查询用户列表

    windows:
              net user
              net localgroup adinistrators//获取本地管理员组成员
              query user || qwinsta//查看当前再线用户
   
    Linux:    
              cat /etc/passwd
              cat /etc/group
              延申:cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F":"'{ print $1"|"$3"|"$4 }'|more

9.列出或断开本地计算机与所连接的客户端之间的会话

   windows:
             net session
   
   Linux:    
             who -a

10.查询端口列表

netstat -ano

11.查询补丁列表

  windows:
            systeminfo
            //查找提权补丁信息
            systeminfo>C:\Temp>micropoor.txt&(for %i in ( KB977165 KB2160329 KB2503665 KB2592799
            KB2707511 KB2829361 KB2850851 KB3000061 KB3045171 KB3077657 KB3079904
            KB3134228 KB3143141 KB3141780 ) do @type micropoor.txt|@find /i
            "%i"|| @echo %i you can fuck)&del /f /q /a micropoor.txt        //里面可以任意添加删除补丁编号

   Linux:  
            linux需要查看内核版本信息,查看安装的软件包,然后进行对比

12.查询本机共享列表

   windows:
             net share//wmic:
             wmic share get name,path,status
  
   Linux:   
             在/mnt/hgfs目录下查看

13.查询路由表及所有可用接口的ARP缓存表

  windows:
            route print
            arp -a
  
  Linux:    
            arp –a
            Route
            /sbin/route -nee

14.查询防火墙相关配置

1)关闭防火墙

   windows:  
             //windows server 2003之前
             netsh firewall set opmode disable                                  
             //Windows server 2003之后
             netsh advfirewall set allprofile state off
  
   Linux:    
             //暂时关闭防火墙
             systemctl stop firewalld
             service iptables stop
             //永久关闭防火墙
             systemctl disable firewalld
             chkconfig iptables  off        

2)查看防火墙配置

  windows:
            netsh firewall show config
 
  Llinux:   
            Iptables-save >ipt.txt           

3) 修改防火墙配置

  windows:
           //windows server 2003之前允许指定程序全部连接
           netsh firewall add allowedprogram c:\nc.exe "allow nc" enable
           //windows server 2003之后的版本
           netsh advfirewall firewall add rule name="pass nc" dir=in action=allow program="c:\nc.exe"
           //允许指定程序退出
           netsh advfirewall firewall add rule name="Allow nc" dir=out action=allow program="C:\nc.exe"
           //允许3389端口放行
           netsh advfirewall firewall add rule name="Remote Desktop" protocol=TCP dir=in localport=3389 action=allow
 
 linux:   
           //查看防火墙状态
           systemctl status firewalld
           //启动防火墙
           systemctl start firewalld.service
           //开放TCP的80端口,并重载防火墙
           firewall-cmd --zone=public --add-port=80/tcp --permanent
           //重载防火墙 
           firewall-cmd --reload
           //查看防火墙开放端口
           firewall-cmd --zone=public --list-ports

4)自定义防火墙日志的存储位置

   windows:
             netsh advfirewall set currentprofile logging filename "C:\windows\temp\fw.log"
   Linux:  
             参考文章https://blog.csdn.net/xiexievv/article/details/48001261

15.查看代理配置情况

   windows:
             reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
   
   Linux:    
             source /etc/profile     

16.查询并开启远程连接服务

1)查看远程连接端口

reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /V PortNumber

2)在Windows server 2003中开启3389

wmic path win32_terminalservicesetting where (__CLASS !="") call setallowtsconnections 1

3)在Windows server 2008和2012中

wmic /namespace:\\root\cimv2\terminalservices path win32_terminalservicesetting where (__CLASS !="") call setallowtsconnections 1//修改注册表方式reg query "HKLM\System\CURRENT\CONTROLSET\CONTROL\TERMINAL SERVER" /v fSingleSessionPerUser /t REG_DWORD /d 0 /f

17.自动收集信息

Empire下的主机信息收集,输出到格式为html文件

使用模块:

usemodule situational_awareness/host/winenum
execute

18.查询当前权限

  windows:
            whoami /all
            //查询指定用户的详细信息
            net user xxx /domain
  
  Linux:    
            id
            whoami

03

域内的信息收集

1.判断是否存在域

  查看dns服务器
                 ipconfig /all
                 nslookup dc.test.local//将查看到的DNS服务器用nslookup进行解析
        
  查看系统详细信息
                  systeminfo | findstr /B /C:"登录服务器"//如果结果不为"WORKGROUP"则主机为域主机                      
                  //查询当前登录域及登录用户信息
                  net group workstation                     
                  //判断主域
                  net time /domain//命令用于查看域内时间,同时也可以查看域控制器     

2. 探测域内存活主机

  使用nbtscan(http://www.unixwiz.net/tools/nbtscan.html)探测当前网段主机
                      nbt.exe 192.168.2.0/20
        
  使用ICMP探测
                      for /L %I in (1,1,254) DO @ping -w 1 -n 1 192.168.2.%I | findstr "TTL="
        
  通过ARPscan工具扫描探测内网
                      arp.exe -t 192.168.2.0/20
        
  Empire中的ARPscan模块
                      usemode situational_awareness/network/arpscan
                      execute
  Nishang中的Invoke-ARPScan.ps1 
                      powershell.exe -exec bypass -Command "& (Import-module c:\windows\temp\Invoke-ARPscan.ps1; Invoke-ARPScan -CIDR 192.168.1.0/20)" >> c:\windows\temp\log.txt
                      type c:\windows\temp\log.txt
        
  通过常规的TCP/UDP端口扫描探测内网
                      上传ScanLine进行扫描:
                      scanline -h -t 22,80-90,110,445 -u 53,161 -O c:\windows\temp\log.txt -p 192.168.1.1-254 /b

3.扫描域内端口

  telnet(但是这个速度太慢了点)


  Metasploit端口扫描:
                      auxiliary/scanner/portscan/tcp
                      set ports 1-1000
                      set RHOST 192.168.1.1
                      set THREADS 10
                      run
        
  PowerSploit、NiShang的Invoke-portscan脚本

  注:msf记得添加路由或代理
                      autoroute添加路由
                      run autoroute –h #查看帮助
                      run autoroute -s 192.168.159.0/24  #添加到目标环境网络
                      run autoroute –p  #查看添加的路由
                      
  当然msf不止有扫描端口的脚本,这里在列举几个其他脚本:
                      1. use auxiliary/scanner/http/dir_scanner
                      2. use auxiliary/scanner/http/jboss_vulnscan
                      3. use auxiliary/scanner/mssql/mssql_login
                      4. use auxiliary/scanner/mysql/mysql_version
                      5. use auxiliary/scanner/oracle/oracle_login
                      //扫描的脚本位于:
                      /usr/share/metasploit-framework/modules/auxiliary/scanner/

4. 收集域内基础信息

  net view /domain//查询域
  net view /domain:test//查询域内所有计算机
  net group /domain//查询域内所有用户组列表 
  net group "domain computers" /domain//查询所有域成员计算机列表
  net accounts /domain//获取域内密码信息
  nltest /domain_trusts//域内信任信息

5. 查找域控

  nltest /DCLIST:test

  net time /domain
  
  Nslookup -type=SRV _ldap._tcp
  
  net group "Domain Controllers" /domain
  
  netdom query pdc//查看主控制器

6. 获取域内的用户和管理员信息

  //查询所有域用户列表
  net user /domain 
  //获取域内用户的详细信息
  wmic useraccount get /all 
  //查看存在的用户,但是这个只能在域控或者安装了对应服务的主机使用,否则会提示命令不存在
  dsquery user 
  //查找目录中的计算机
  dsquery computer 
  //查询本地管理员组用户
  net localgroup administrators 
  //查询域管理员用户组
  net group "domain admins" /domain 
  //查询管理员用户组
  net group "Enterprise Admins" /domain

7. 定位域管理员

在获取了Windows域中的普通权限在进行横向渗透时,需要知道域内用户登录的位置,是否是任何系统/主机的本地管理员,以及所属组等关键信息。 这里直接用前辈们造的轮子吧,能够使用的轮子有:psloggedon.exe、PVEFindADUser.exe、netness.exe、hunter、NetView、PowerView。

  psloggedon.exe
          //能够通过此工具查看远程计算机的资源,也就是说能够查看目标主机有哪些账户在登录状态        
          下载地址:https://docs.microsoft.com/zh-cn/sysinternals/downloads/psloggedon
          使用:psloggedon.exe \\dc2012
  
  PVEFindADUser
           //PVEFindADUser能够用于查找活动目录用户登录的位置,枚举与用户,以及查找在特定计算机上登录的用户。包括本地用户、通过RDP登录的用户、用于运行服务和计划任务的用户。(这个工具需要.NET 3.5)Windows Server 2012安装.NET 3.5可能不成功,需要指定安装源:https://www.cr173.com/soft/921507.html
           下载地址:https://github.com/chrisdee/Tools/tree/master/AD/ADFindUsersLoggedOn
            PVEFindADUser.exe -current
        
  NetView
           //NetView是一个枚举工具,使用WinAPI枚举系统,利用NetSessionEnum找寻登陆会话,利用NetShareEnum找寻共享,利用NetWkstaUserEnum枚举登录的用户。同时还能够查询共享入口和有价值的用户。
           下载地址:https://github.com/mubix/netview
           
  PowerView
            使用Powerview的Invoke-UserHunter。
            
  Empire
            //Empire中也存在此类型的脚本:
            usemodule situational_awareness/network/powerview/user_hunter
            execute
            
  Nmap的NSE脚本
            //通过Nmap的NSE脚本获取远程机器的登陆会话。
            smb-enum-sessions.nse获取域内主机的用户登录会话,查看当前是否有用户登录。下载地址:https://nmap.org/nsedoc/scripts/smb-enum-sessions.html
            smb-enum-domains.nse对域控制器进行信息收集,可以获取主机信息用户、可使用密码策略的用户等。
            smb-enum-users.nse可以使用此脚本对域控进行扫描。

8. 查找域管理进程

参考文章:https://yq.aliyun.com/articles/599377?type=2

  本机检查:
                //获取域管理员列表
                net group "Domain Admins" /domain
                //列出本机的所有进程和进程用户
                tasklist /v
                //查询域控的域用户会话
                //查询域控列表
                net group "Domain Controllers" /domain
                //收集所有活动域的会话列表
                netsess -h

9. 补充一点linux信息收集姿势

   常见的配置文件有那些?有没有可攻击的插件:
        Cat /etc/syslog.conf
        Cat /etc/chttp.conf
        Cat /etc/lighttpd.conf
        Cat /etc/cups/cupsd.conf
        Cat /etc/inetd.conf
        Cat /etc/apache2/apache2.conf
        Cat /etc/my.conf
        Cat /etc/http/conf/http.conf
        Cat /opt/lampp/etc/httpd.conf
        Ls -aRl /etc/ | awk '$1 ~ /^.r./
        
  查找系统内跟用户名和密码的有关的文件
        Grep -I user [filename]
        grep -i pass [filename] grep -C 5 “password” [filename] find . -name “*.php” -print0 | xargs     -0 grep -i -n “var $password” # Joomla

转载此文章,请标明出处。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-09-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Gamma安全实验室 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档