0 people like it.
Like the snippet!
DNS, Async
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:
|
(* Just a simple A wordlister for now, srv needs to be re-written *)
open System.Diagnostics
open System
open System.Net
open System.Text
open System.Net.Sockets
open System.Threading
let args = Environment.GetCommandLineArgs()
ThreadPool.SetMaxThreads(128,128)
ThreadPool.SetMinThreads(24,22)
printfn "Max Threads: %d" 128
printfn "MinThreads: %d" 22
(* Modified from http://alexhumphrey.me.uk/dot-net/host-name-lookups-with-f/ *)
let getHostNamesAsync : string seq -> 'a seq =
Seq.map (fun hn -> (hn, Dns.BeginGetHostEntry(hn, null, null)))
>> Seq.toArray
>> Seq.map (fun (hn,ias) -> try Some(hn, Dns.EndGetHostEntry(ias)) with ex -> None)
>> Seq.choose id
let printResult (targ,(hn:IPHostEntry)) =
printfn "%s - %s" targ hn.HostName
let get targ =
let inputFile = (System.IO.File.ReadAllLines @"dnsbig.txt")
printfn "Words to try: %d" (Array.length inputFile)
inputFile
|> Array.map(fun x -> sprintf "%s.%s" x targ)
|> getHostNamesAsync
|> Seq.iter printResult
if args.Length < 2 then printf "dns.exe host"
else
let sWatch = new Stopwatch()
sWatch.Start()
get args.[1]
let ts = sWatch.Elapsed
let elapsedTime =
String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10)
Console.WriteLine("RunTime " + elapsedTime)
|
namespace System
namespace System.Diagnostics
namespace System.Net
namespace System.Text
namespace System.Net.Sockets
namespace System.Threading
val args : string []
Full name: Script.args
type Environment =
static member CommandLine : string
static member CurrentDirectory : string with get, set
static member Exit : exitCode:int -> unit
static member ExitCode : int with get, set
static member ExpandEnvironmentVariables : name:string -> string
static member FailFast : message:string -> unit + 1 overload
static member GetCommandLineArgs : unit -> string[]
static member GetEnvironmentVariable : variable:string -> string + 1 overload
static member GetEnvironmentVariables : unit -> IDictionary + 1 overload
static member GetFolderPath : folder:SpecialFolder -> string + 1 overload
...
nested type SpecialFolder
nested type SpecialFolderOption
Full name: System.Environment
Environment.GetCommandLineArgs() : string []
type ThreadPool =
static member BindHandle : osHandle:nativeint -> bool + 1 overload
static member GetAvailableThreads : workerThreads:int * completionPortThreads:int -> unit
static member GetMaxThreads : workerThreads:int * completionPortThreads:int -> unit
static member GetMinThreads : workerThreads:int * completionPortThreads:int -> unit
static member QueueUserWorkItem : callBack:WaitCallback -> bool + 1 overload
static member RegisterWaitForSingleObject : waitObject:WaitHandle * callBack:WaitOrTimerCallback * state:obj * millisecondsTimeOutInterval:uint32 * executeOnlyOnce:bool -> RegisteredWaitHandle + 3 overloads
static member SetMaxThreads : workerThreads:int * completionPortThreads:int -> bool
static member SetMinThreads : workerThreads:int * completionPortThreads:int -> bool
static member UnsafeQueueNativeOverlapped : overlapped:NativeOverlapped -> bool
static member UnsafeQueueUserWorkItem : callBack:WaitCallback * state:obj -> bool
...
Full name: System.Threading.ThreadPool
ThreadPool.SetMaxThreads(workerThreads: int, completionPortThreads: int) : bool
ThreadPool.SetMinThreads(workerThreads: int, completionPortThreads: int) : bool
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
val getHostNamesAsync : (seq<string> -> seq<string * IPHostEntry>)
Full name: Script.getHostNamesAsync
Multiple items
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = String
Full name: Microsoft.FSharp.Core.string
Multiple items
val seq : sequence:seq<'T> -> seq<'T>
Full name: Microsoft.FSharp.Core.Operators.seq
--------------------
type seq<'T> = Collections.Generic.IEnumerable<'T>
Full name: Microsoft.FSharp.Collections.seq<_>
module Seq
from Microsoft.FSharp.Collections
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>
Full name: Microsoft.FSharp.Collections.Seq.map
val hn : string
type Dns =
static member BeginGetHostAddresses : hostNameOrAddress:string * requestCallback:AsyncCallback * state:obj -> IAsyncResult
static member BeginGetHostByName : hostName:string * requestCallback:AsyncCallback * stateObject:obj -> IAsyncResult
static member BeginGetHostEntry : hostNameOrAddress:string * requestCallback:AsyncCallback * stateObject:obj -> IAsyncResult + 1 overload
static member BeginResolve : hostName:string * requestCallback:AsyncCallback * stateObject:obj -> IAsyncResult
static member EndGetHostAddresses : asyncResult:IAsyncResult -> IPAddress[]
static member EndGetHostByName : asyncResult:IAsyncResult -> IPHostEntry
static member EndGetHostEntry : asyncResult:IAsyncResult -> IPHostEntry
static member EndResolve : asyncResult:IAsyncResult -> IPHostEntry
static member GetHostAddresses : hostNameOrAddress:string -> IPAddress[]
static member GetHostByAddress : address:string -> IPHostEntry + 1 overload
...
Full name: System.Net.Dns
Dns.BeginGetHostEntry(address: IPAddress, requestCallback: AsyncCallback, stateObject: obj) : IAsyncResult
Dns.BeginGetHostEntry(hostNameOrAddress: string, requestCallback: AsyncCallback, stateObject: obj) : IAsyncResult
val toArray : source:seq<'T> -> 'T []
Full name: Microsoft.FSharp.Collections.Seq.toArray
val ias : IAsyncResult
union case Option.Some: Value: 'T -> Option<'T>
Dns.EndGetHostEntry(asyncResult: IAsyncResult) : IPHostEntry
val ex : exn
union case Option.None: Option<'T>
val choose : chooser:('T -> 'U option) -> source:seq<'T> -> seq<'U>
Full name: Microsoft.FSharp.Collections.Seq.choose
val id : x:'T -> 'T
Full name: Microsoft.FSharp.Core.Operators.id
val printResult : targ:string * hn:IPHostEntry -> unit
Full name: Script.printResult
val targ : string
val hn : IPHostEntry
Multiple items
type IPHostEntry =
new : unit -> IPHostEntry
member AddressList : IPAddress[] with get, set
member Aliases : string[] with get, set
member HostName : string with get, set
Full name: System.Net.IPHostEntry
--------------------
IPHostEntry() : unit
property IPHostEntry.HostName: string
val get : targ:string -> unit
Full name: Script.get
val inputFile : string []
namespace System.IO
type File =
static member AppendAllLines : path:string * contents:IEnumerable<string> -> unit + 1 overload
static member AppendAllText : path:string * contents:string -> unit + 1 overload
static member AppendText : path:string -> StreamWriter
static member Copy : sourceFileName:string * destFileName:string -> unit + 1 overload
static member Create : path:string -> FileStream + 3 overloads
static member CreateText : path:string -> StreamWriter
static member Decrypt : path:string -> unit
static member Delete : path:string -> unit
static member Encrypt : path:string -> unit
static member Exists : path:string -> bool
...
Full name: System.IO.File
IO.File.ReadAllLines(path: string) : string []
IO.File.ReadAllLines(path: string, encoding: Encoding) : string []
type Array =
member Clone : unit -> obj
member CopyTo : array:Array * index:int -> unit + 1 overload
member GetEnumerator : unit -> IEnumerator
member GetLength : dimension:int -> int
member GetLongLength : dimension:int -> int64
member GetLowerBound : dimension:int -> int
member GetUpperBound : dimension:int -> int
member GetValue : [<ParamArray>] indices:int[] -> obj + 7 overloads
member Initialize : unit -> unit
member IsFixedSize : bool
...
Full name: System.Array
val length : array:'T [] -> int
Full name: Microsoft.FSharp.Collections.Array.length
val map : mapping:('T -> 'U) -> array:'T [] -> 'U []
Full name: Microsoft.FSharp.Collections.Array.map
val x : string
val sprintf : format:Printf.StringFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.sprintf
val iter : action:('T -> unit) -> source:seq<'T> -> unit
Full name: Microsoft.FSharp.Collections.Seq.iter
property Array.Length: int
val printf : format:Printf.TextWriterFormat<'T> -> 'T
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printf
val sWatch : Stopwatch
Multiple items
type Stopwatch =
new : unit -> Stopwatch
member Elapsed : TimeSpan
member ElapsedMilliseconds : int64
member ElapsedTicks : int64
member IsRunning : bool
member Reset : unit -> unit
member Restart : unit -> unit
member Start : unit -> unit
member Stop : unit -> unit
static val Frequency : int64
...
Full name: System.Diagnostics.Stopwatch
--------------------
Stopwatch() : unit
Stopwatch.Start() : unit
val ts : TimeSpan
property Stopwatch.Elapsed: TimeSpan
val elapsedTime : string
Multiple items
type String =
new : value:char -> string + 7 overloads
member Chars : int -> char
member Clone : unit -> obj
member CompareTo : value:obj -> int + 1 overload
member Contains : value:string -> bool
member CopyTo : sourceIndex:int * destination:char[] * destinationIndex:int * count:int -> unit
member EndsWith : value:string -> bool + 2 overloads
member Equals : obj:obj -> bool + 2 overloads
member GetEnumerator : unit -> CharEnumerator
member GetHashCode : unit -> int
...
Full name: System.String
--------------------
String(value: nativeptr<char>) : unit
String(value: nativeptr<sbyte>) : unit
String(value: char []) : unit
String(c: char, count: int) : unit
String(value: nativeptr<char>, startIndex: int, length: int) : unit
String(value: nativeptr<sbyte>, startIndex: int, length: int) : unit
String(value: char [], startIndex: int, length: int) : unit
String(value: nativeptr<sbyte>, startIndex: int, length: int, enc: Encoding) : unit
String.Format(format: string, [<ParamArray>] args: obj []) : string
String.Format(format: string, arg0: obj) : string
String.Format(provider: IFormatProvider, format: string, [<ParamArray>] args: obj []) : string
String.Format(format: string, arg0: obj, arg1: obj) : string
String.Format(format: string, arg0: obj, arg1: obj, arg2: obj) : string
property TimeSpan.Hours: int
property TimeSpan.Minutes: int
property TimeSpan.Seconds: int
property TimeSpan.Milliseconds: int
type Console =
static member BackgroundColor : ConsoleColor with get, set
static member Beep : unit -> unit + 1 overload
static member BufferHeight : int with get, set
static member BufferWidth : int with get, set
static member CapsLock : bool
static member Clear : unit -> unit
static member CursorLeft : int with get, set
static member CursorSize : int with get, set
static member CursorTop : int with get, set
static member CursorVisible : bool with get, set
...
Full name: System.Console
Console.WriteLine() : unit
(+0 other overloads)
Console.WriteLine(value: string) : unit
(+0 other overloads)
Console.WriteLine(value: obj) : unit
(+0 other overloads)
Console.WriteLine(value: uint64) : unit
(+0 other overloads)
Console.WriteLine(value: int64) : unit
(+0 other overloads)
Console.WriteLine(value: uint32) : unit
(+0 other overloads)
Console.WriteLine(value: int) : unit
(+0 other overloads)
Console.WriteLine(value: float32) : unit
(+0 other overloads)
Console.WriteLine(value: float) : unit
(+0 other overloads)
Console.WriteLine(value: decimal) : unit
(+0 other overloads)
More information