0
此代碼應該嘗試比較上傳文件中的字符串。如果我上傳文件並匹配字符串是否存在並顯示一些信息,但運行後無法顯示什麼如何比較上傳文件中的字符串
的servlet:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Logger;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class WebPageSourceServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger log = Logger
.getLogger(WebPageSourceServlet.class.getName());
@SuppressWarnings("resource")
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String phish = req.getParameter("phish");
PrintWriter out = resp.getWriter();
resp.setContentType("text/html");
try {
String imageurl = "<img src=https://";
String amb = "@";
String action = "<form action=http://";
String frame = "<iframe";
String script = "<script";
String popup = "popUp";
String popup1 = "window.open";
String actions = "<form action=https://";
File f = new File(req.getParameter("phish"));
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
phish = br.readLine();
while (phish != null) {
// phish=br.readLine();
if (phish.equalsIgnoreCase(popup) || phish.equals(amb)
|| phish.equalsIgnoreCase(popup1)
|| phish.equalsIgnoreCase(frame)) {
out.println("<p>WARNING:This May Cause a Phishing Attacks!!!</p>");
} else {
out.println("<p>INFO:This is Secure Website!!!</p>");
}
if (phish.equalsIgnoreCase(script)) {
out.println("<p>WARNING:This may Cause a Doubtful and Phishing attacks</p>");
} else {
out.println("<p>This is Phishing</p>");
}
if (phish.equalsIgnoreCase(actions)) {
out.println("<p>INFO:This is a Secure Website</p>");
} else {
out.println("WARNING:<p>This may cause a Possible to Phishing attacks:</p>");
br.close();
return;
}
}
} catch (FileNotFoundException f)
{
System.out.println(f);
log.info("file not found");
} catch (Exception e) {
System.out.println(e);
e.printStackTrace();
log.info("exception occured");
}
}
}
JSP文件:
<form action="/UploadServlet" method="post"
enctype="multipart/form-data">
<input type="file" name="phish" size="50" /><br />
<input type="submit" value="Upload File" />
</form>
IAM使用的JSP文件名是網絡釣魚使用REQ用於獲得parameter.so,怎麼會這樣處理到上傳的文件。