-
Notifications
You must be signed in to change notification settings - Fork 477
/
Default.aspx
66 lines (63 loc) · 2.55 KB
/
Default.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<%@ Page Language="C#" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e) {
if (FileUpload1.HasFile) {
try {
System.Web.HttpContext context = System.Web.HttpContext.Current;
String filename = FileUpload1.FileName;
String extension = System.IO.Path.GetExtension(filename).ToLower();
String[] blacklists = {".aspx", ".config", ".ashx", ".asmx", ".aspq", ".axd", ".cshtm", ".cshtml", ".rem", ".soap", ".vbhtm", ".vbhtml", ".asa", ".asp", ".cer"};
if (blacklists.Any(extension.Contains)) {
Label1.Text = "What do you do?";
} else {
String ip = context.Request.ServerVariables["REMOTE_ADDR"];
String upload_base = Server.MapPath("/") + "files/" + ip + "/";
if (!System.IO.Directory.Exists(upload_base)) {
System.IO.Directory.CreateDirectory(upload_base);
}
filename = Guid.NewGuid() + extension;
FileUpload1.SaveAs(upload_base + filename);
Label1.Text = String.Format("<a href='files/{0}/{1}'>This is file</a>", ip, filename);
}
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
} else {
Label1.Text = "You have not specified a file.";
}
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="bootstrap.min.css">
<title>Why so Serials?</title>
</head>
<body>
<div class="container">
<div class="jumbotron" style='background: #f7f7f7'>
<h1>Why so Serials?</h1>
<p>May the <b><a href='Default.aspx.txt'>source</a></b> be with you!</p>
<br />
<form id="form1" runat="server">
<div class="input-group">
<asp:FileUpload ID="FileUpload1" runat="server" class="form-control"/>
<span class="input-group-btn">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="GO" class="btn"/>
</span>
</div>
<br />
<br />
<br />
<div class="alert alert-primary text-center">
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
</form>
</div>
</div>
</body>
</html>