有MM问木马通过网页把空间文件设为只读属性后,是否可以用网页设回去(文件只读用FTP操作不了文件)。我试验是可以的。
<%@ Import Namespace="Microsoft.VisualBasic" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="设置只读" />
<asp:Button ID="Button2" runat="server" Text="去掉只读" onclick="Button2_Click" />
</div>
</form>
</body>
<script language="VB" runat=server>
Public Sub FindFile(ByVal dir As String, ByVal boIsReadOnly As Boolean) '参数为指定的目录
Dim Dirpath As New DirectoryInfo(dir)
Try
Dim d As DirectoryInfo
For Each d In Dirpath.GetDirectories() '查找子目录
FindFile((dir & d.ToString() & "\"), boIsReadOnly)
Next d
Dim f As FileInfo
Dim temp As String = ""
For Each f In Dirpath.GetFiles("*.*") '查找文件
temp = dir & f.ToString()
Dim file1 As New System.IO.FileInfo(temp)
If boIsReadOnly = True Then
file1.Attributes = System.IO.FileAttributes.ReadOnly
Else
file1.Attributes = System.IO.FileAttributes.Normal
End If
If file1.Attributes = System.IO.FileAttributes.ReadOnly Then
Context.Response.Write(temp & "---只读<br />")
ElseIf file1.Attributes = System.IO.FileAttributes.Normal Then
Context.Response.Write(temp & "---非只读<br />")
Else
Context.Response.Write(temp & "---未知<br />")
End If
Next f
Catch e As Exception
Context.Response.Write(e.Message)
End Try
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
FindFile(Server.MapPath("~"), True)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
FindFile(Server.MapPath("~"), False)
End Sub
</script>
</html>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="设置只读" />
<asp:Button ID="Button2" runat="server" Text="去掉只读" onclick="Button2_Click" />
</div>
</form>
</body>
<script language="VB" runat=server>
Public Sub FindFile(ByVal dir As String, ByVal boIsReadOnly As Boolean) '参数为指定的目录
Dim Dirpath As New DirectoryInfo(dir)
Try
Dim d As DirectoryInfo
For Each d In Dirpath.GetDirectories() '查找子目录
FindFile((dir & d.ToString() & "\"), boIsReadOnly)
Next d
Dim f As FileInfo
Dim temp As String = ""
For Each f In Dirpath.GetFiles("*.*") '查找文件
temp = dir & f.ToString()
Dim file1 As New System.IO.FileInfo(temp)
If boIsReadOnly = True Then
file1.Attributes = System.IO.FileAttributes.ReadOnly
Else
file1.Attributes = System.IO.FileAttributes.Normal
End If
If file1.Attributes = System.IO.FileAttributes.ReadOnly Then
Context.Response.Write(temp & "---只读<br />")
ElseIf file1.Attributes = System.IO.FileAttributes.Normal Then
Context.Response.Write(temp & "---非只读<br />")
Else
Context.Response.Write(temp & "---未知<br />")
End If
Next f
Catch e As Exception
Context.Response.Write(e.Message)
End Try
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
FindFile(Server.MapPath("~"), True)
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
FindFile(Server.MapPath("~"), False)
End Sub
</script>
</html>