在Tomcat中,應用程序的部署很簡單,只需將你的WAR放到Tomcat的webapp目錄下,Tomcat會自動檢測到這個文件,並將其解壓。在瀏覽器中訪問這個應用的Jsp時,通常第一次會很慢,因為Tomcat要將Jsp轉化為Servlet文件,然后編譯。編譯以后,訪問將會很快。另外Tomcat也提供了一個應用:manager,訪問這個應用需要用戶名和密碼,用戶名和密碼存儲在一個xml文件中。通過這個應用,輔助於Ftp,可以在遠程通過Web部署和撤銷應用,當然本地也可以,本案例就是利用這個特性來構建后門程序的。
Tomcat不僅僅是一個Servlet容器,它也具有傳統的Web服務器的功能:處理Html頁面。但是與Apache相比,它的處理靜態Html的能力就不如Apache。可以將Tomcat和Apache集成到一塊,讓Apache處理靜態Html,而Tomcat處理Jsp和Servlet.這種集成只需要修改一下Apache和Tomcat的配置文件即可。
一、檢查Tomcat設置
服務器安裝了Apache Tomcat后會默認開放8080端口供外部連接,一般在瀏覽器中輸入“IP:8080”或者域名來訪問Apache Tomcat頁面,如下圖所示。
二、查看
Tomcat用戶配置文件
Tomcat安裝完成后有一個配置文件“tomcat-users.xml”,它位於Tomcat程序安裝目錄下的conf目錄下,直接打開該文件可以看到其中關於用戶名和密碼的明文值,文件如下。
<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <tomcat-users xmlns="http://tomcat.apache.org/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd" version="1.0"> <!-- NOTE: By default, no user is included in the "manager-gui" role required to operate the "/manager/html" web application. If you wish to use this app, you must define such a user - the username and password are arbitrary. It is strongly recommended that you do NOT use one of the users in the commented out section below since they are intended for use with the examples web application. --> <!-- NOTE: The sample user and role entries below are intended for use with the examples web application. They are wrapped in a comment and thus are ignored when reading this file. If you wish to configure these users for use with the examples web application, do not forget to remove the <!.. ..> that surrounds them. You will also need to set the passwords to something appropriate. --> <!-- <role rolename="tomcat"/> <role rolename="role1"/> <user username="tomcat" password="<must-be-changed>" roles="tomcat"/> <user username="both" password="<must-be-changed>" roles="tomcat,role1"/> <user username="role1" password="<must-be-changed>" roles="role1"/> --> <!-- 配置角色 --> <role rolename="manager-gui"/> <role rolename="admin-gui"/> <!-- 配置管理員賬號,密碼及其權限 --> <user username="你的用戶名" password="你的密碼" roles="admin-gui,manager-gui"/> </tomcat-users>
說明:
(1)有很多對tomcat不是很了解的管理員在安裝完Tomcat后並沒有修改默認密碼,用戶名是admin,密碼為空,如果是這種情況可以直接登錄。
(2)如果用戶修改了該密碼,那么其密碼一定保存在“tomcat-users.xml”中,因此可以通過Webshell來獲取這個文件的內容。
注釋上寫的很清楚,要進入
Manager App就需要manage-gui具有角色權限的用戶,具有admin-gui角色的用戶可以進入Host Manager,暫時就簡單這樣理解了,具體的這邊就不去深究了。進入到Tomcat Web Application Manager,效果如下:
三、進入Tomcat管理
Tomcat提供了在線管理,本案例也正式利用在線管理來構建后門的。在第一個圖中單擊左上角下面的“Tomcat Manager”鏈接后,會彈出一個要求輸入用戶名和密碼的窗口,如下圖所示。
四、查看部署情況
在上圖中輸入從“tomcat-users.xml”文件中獲取的具有管理員權限的用戶名和密碼,驗證通過后進入部署管理頁面,如下圖所示。
說明:
(1)在部署管理頁面中可以“Start”(啟動)、“Stop”(停止)、“Reload”(重載)、“Undeploy”(刪除部署)已經部署的項目,單擊“Undeploy”會對文件進行物理刪除。
(2)
部署的文件夾是以*.war文件的名稱,例如上傳的文件是esite.war,則在Tomcat目錄中會對應生成一個“esite”文件夾(將war解壓出來的文件夾) 。
五、部署JSP WebShell后門程序
在部署管理頁面的下方有一個“WAR file to deploy”,單擊瀏覽選擇一個已經設置好的后門war文件,在本例中的后門程序為esite.war,單擊“deploy”將該文件部署到服務器上。
說明:
(1)部署是其文件必須是war文件。
(2)將winzip軟件安裝在系統中,然后將單一或者多個jsp后門文件壓縮成一個壓縮文件,壓縮成功后,將“*.zip”文件更名為“*.war”即可。
(3)上傳文件后,tomcat會自動進行部署並運行。
六、測試后門程序
在地址欄中輸入“
部署文件名稱
/jsp文件”,例如在本例中其正確的訪問是“[url]http://127.0.0.1:8080/esite/test.jsp[/url]”
致謝:感謝您的耐心閱讀!
