@@ -30,6 +30,13 @@ const (
3030 LLMNRPort = 5355
3131)
3232
33+ const (
34+ def = 0x00
35+ newComp = 0x01
36+ randCom = 0x02
37+ randStr = 0x03
38+ )
39+
3340var (
3441 // stdout is default output
3542 outFile = os .Stdout
@@ -40,10 +47,18 @@ var (
4047 // argument flags
4148 jsonPtr = flag .Bool ("json" , false ,
4249 `Prints a JSON to STDOUT if a responder is detected on
43- network. Other text is sent to STDERR` )
50+ network. Other text is sent to STDERR` )
4451
4552 debugPtr = flag .Bool ("debug" , false ,
4653 `Creates a debug.log file with a trace of the program` )
54+
55+ compPtr = flag .String ("computername" , "aweirdcomputername" ,
56+ `Overrides the default computer name, requires at least 16 charcter hostname` )
57+ randCompPtr = flag .Bool ("rcomputername" , false ,
58+ `Overrides the default computer name, with a random choice of words` )
59+ randStrPtr = flag .Bool ("rstring" , false ,
60+ `Overrides the default computer name, with a completely random string` )
61+ comNameType byte
4762)
4863
4964func init () {
@@ -52,6 +67,17 @@ func init() {
5267
5368func main () {
5469 initFlags ()
70+ flag .Parse ()
71+
72+ if * compPtr != "aweirdcomputername" {
73+ comNameType = newComp
74+ } else if * randCompPtr {
75+ comNameType = randCom
76+ } else if * randStrPtr {
77+ comNameType = randStr
78+ } else {
79+ comNameType = def
80+ }
5581
5682 fmt .Fprintln (os .Stderr , Banner )
5783
@@ -109,12 +135,22 @@ func checkResponderOnInterface(inf net.Interface) map[string]string {
109135
110136// Creates and sends a LLMNR request to the UDP multicast address.
111137func sendLLMNRProbe (ip net.IP ) string {
138+ var cName string
112139 responderIP := ""
113140 // 2 byte random transaction id eg. 0x8e53
114141 randomTransactionID := fmt .Sprintf ("%04x" , rand .Intn (65535 ))
115- computerName := getComputerName ()
116- cNameLen := fmt .Sprintf ("%2x" , len (computerName ))
117- encCName := hex .EncodeToString ([]byte (computerName ))
142+ switch comNameType {
143+ case def :
144+ cName = string (* compPtr )
145+ case newComp :
146+ cName = string (* compPtr )
147+ case randCom :
148+ cName = getComputerName ()
149+ case randStr :
150+ cName = randomString ()
151+ }
152+ cNameLen := fmt .Sprintf ("%2x" , len (cName ))
153+ encCName := hex .EncodeToString ([]byte (cName ))
118154 // LLMNR request in raw bytes
119155 llmnrRequest := randomTransactionID +
120156 "00000001000000000000" + cNameLen + encCName + "0000010001"
@@ -162,7 +198,7 @@ func getValidIPv4Addr(addrs []net.Addr) net.IP {
162198func initFlags () {
163199 flag .Usage = func () {
164200 fmt .Fprintf (os .Stderr , "Respounder version %1.1f\n " , Version )
165- fmt .Fprintf (os .Stderr , "Usage: $ respounder [-json] [-debug]" )
201+ fmt .Fprintf (os .Stderr , "Usage: $ respounder [-json] [-debug] [-computername anewcomputername! | -rcomputername | -rstring] " )
166202 fmt .Fprintf (os .Stderr , "\n \n Flags:\n " )
167203 flag .PrintDefaults ()
168204 }
0 commit comments