diff --git a/Makefile b/Makefile index 2c3ee4d..22ed186 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,59 @@ -all: build +SHELL := /bin/bash +PATH := /usr/local/go/bin:$(PATH) + +all: compile + +test: +# export PATH="$$PATH:/usr/local/go/bin" # put into ~/.profile + echo $(CURDIR) + echo $(HOME) # make dep runs without sudo dep: - sudo apt-get -y install git screen hostapd autossh bluez bluez-tools bridge-utils policykit-1 genisoimage iodine haveged - sudo apt-get -y install tcpdump - sudo apt-get -y install python-pip python-dev + sudo apt-get -y install git screen hostapd autossh bluez bluez-tools bridge-utils policykit-1 genisoimage iodine haveged + sudo apt-get -y install tcpdump + sudo apt-get -y install python-pip python-dev - # before installing dnsmasq, the nameserver from /etc/resolv.conf should be saved - # to restore after install (gets overwritten by dnsmasq package) - cp /etc/resolv.conf /tmp/backup_resolv.conf - sudo apt-get -y install dnsmasq - sudo /bin/bash -c 'cat /tmp/backup_resolv.conf > /etc/resolv.conf' + # before installing dnsmasq, the nameserver from /etc/resolv.conf should be saved + # to restore after install (gets overwritten by dnsmasq package) + cp /etc/resolv.conf /tmp/backup_resolv.conf + sudo apt-get -y install dnsmasq + sudo /bin/bash -c 'cat /tmp/backup_resolv.conf > /etc/resolv.conf' - # python dependencies for HIDbackdoor - sudo pip install pycrypto # already present on stretch - sudo pip install pydispatcher + # python dependencies for HIDbackdoor + sudo pip install pycrypto # already present on stretch + sudo pip install pydispatcher - # install go - wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz - sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz - export PATH=$PATH:/usr/local/go/bin # put into ~/.profile - echo export PATH=$PATH:/usr/local/go/bin >> ~/.profile - sudo bash -c 'echo export PATH=\$PATH:/usr/local/go/bin >> ~/.profile' + # install go + wget https://storage.googleapis.com/golang/go1.10.linux-armv6l.tar.gz + sudo tar -C /usr/local -xzf go1.10.linux-armv6l.tar.gz - # install gopherjs - go get -u github.com/gopherjs/gopherjs + export PATH="$$PATH:/usr/local/go/bin" - # we don't need protoc + protoc-grpc-web, because the proto file is shipped pre-compiled + # put into ~/.profile + # ToDo: check if already present + echo "export PATH=\$$PATH:/usr/local/go/bin" >> ~/.profile + sudo bash -c 'echo export PATH=\$$PATH:/usr/local/go/bin >> ~/.profile' - # go dependencies for webapp (without my own) - #go get google.golang.org/grpc - #go get -u github.com/improbable-eng/grpc-web/go/grpcweb - #go get -u github.com/gorilla/websocket + # install gopherjs + go get -u github.com/gopherjs/gopherjs -build: - go get -u github.com/mame82/P4wnP1_go # partially downloads again, but we need the library packages in go path to build - env GOBIN=$(pwd)/build go install ./... # compile all main packages to the build folder + # we don't need protoc + protoc-grpc-web, because the proto file is shipped pre-compiled + + # go dependencies for webapp (without my own) + #go get google.golang.org/grpc + #go get -u github.com/improbable-eng/grpc-web/go/grpcweb + #go get -u github.com/gorilla/websocket + +compile: + go get -u github.com/mame82/P4wnP1_go/... # partially downloads again, but we need the library packages in go path to build + # <--- second compilation, maybe -d flag on go get above is better + env GOBIN=$(CURDIR)/build go install ./cmd/... # compile all main packages to the build folder # compile the web app # ToDo: (check if dependencies have been fetched by 'go get', even with the build js tags) - gopherjs build -m -o build/webapp.js web_client/*.go + $(HOME)/go/bin/gopherjs get github.com/mame82/P4wnP1_go/web_client/... + $(HOME)/go/bin/gopherjs build -m -o build/webapp.js web_client/*.go install: cp build/P4wnP1_service /usr/local/bin/ @@ -56,7 +70,7 @@ install: # careful testing #sudo update-rc.d dhcpcd disable - #sudo update-rc.d dnsmasq disable + #sudo update-rc.d dnsmasq disable # reinit service daemon systemctl daemon-reload diff --git a/cmd/P4wnP1_service/P4wnP1_service.go b/cmd/P4wnP1_service/P4wnP1_service.go index ef1853d..f4542a1 100644 --- a/cmd/P4wnP1_service/P4wnP1_service.go +++ b/cmd/P4wnP1_service/P4wnP1_service.go @@ -43,7 +43,7 @@ func main() { */ // ToDo: The webroot has to be changed to /usr/local/P4wnP1/www - service.StartRpcServerAndWeb("0.0.0.0", "50051", "80", "/home/pi/P4wnP1_go/dist/www") //start gRPC service + service.StartRpcServerAndWeb("0.0.0.0", "50051", "80", "/usr/local/P4wnP1/www") //start gRPC service //Indicate servers up with LED blink count 1 state.Led.SetLed(&pb.LEDSettings{1}) diff --git a/cmd/testhid/testhid.go b/cmd/testhid/testhid.go new file mode 100644 index 0000000..c8fcf66 --- /dev/null +++ b/cmd/testhid/testhid.go @@ -0,0 +1,396 @@ +// +build linux,arm + +package main + +import( + "github.com/mame82/P4wnP1_go/hid" + + "log" + "fmt" + "time" + "math" + "os" + "runtime/trace" + "os/signal" + "syscall" + _ "net/http/pprof" + "net/http" + "runtime" + "context" + "io/ioutil" +) + +var ( + StringAscii = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" + StringSpecial1 = "§°üÜöÖäĵ€ß¹²³⁴⁵⁶⁷⁸⁹⁰¼½¬„“¢«»æſðđŋħĸł’¶ŧ←↓→øþ" + +) + +func TestMapCreation() { + //Define test keyboard map + mapDeASCII := hid.HIDKeyboardLanguageMap{ + Name: "DE", + Description: "German ASCII to USB Keyboard report mapping", + Mapping: map[string][]hid.KeyboardOutReport{}, + } + mapDeASCII.Mapping["c"] = []hid.KeyboardOutReport{ + hid.NewKeyboardOutReport(0, hid.HID_KEY_C), + } + mapDeASCII.Mapping["C"] = []hid.KeyboardOutReport{ + hid.NewKeyboardOutReport(hid.HID_MOD_KEY_LEFT_SHIFT, hid.HID_KEY_C), + } + + //Store map to file + err := mapDeASCII.StoreToFile("/tmp/DE_ASCII.json") + if err != nil { log.Fatal(err)} + + /* + testmap, err := hid.loadKeyboardLanguageMapFromFile("keymaps/DE_ASCII.json") + if err != nil { log.Fatal(err)} + fmt.Println(testmap) + */ +} + +func TestComboPress(hidCtl *hid.HIDController) { + testcombos := []string {"SHIFT 1", "ENTER", "ALT TAB", "ALT TABULATOR", " WIN ", "GUI "} + for _,comboStr := range testcombos { + fmt.Printf("Pressing combo '%s'\n", comboStr) + err := hidCtl.Keyboard.StringToPressKeyCombo(comboStr) + if err == nil { + fmt.Printf("... '%s' pressed sleeping 2s\n", comboStr) + time.Sleep(2000 * time.Millisecond) + } else { + fmt.Printf("Error pressing combo '%s': %v\n", comboStr, err) + } + } +} + +func TestLEDTriggers(hidCtl *hid.HIDController) { + fmt.Println("Initial sleep to test if we capture LED state changes from the past, as soon as we start waiting (needed at boot)") + time.Sleep(3 * time.Second) + + + ch := make(chan func(),0) + defer close(ch) + + //Test repeat trigger on any LED + fmt.Println("Waiting for any repeated LED state change (5 times frequently), wait timeout after 20 seconds...") + trigger, err := hidCtl.Keyboard.WaitLEDStateChangeRepeated(ch, hid.MaskAny, 5, time.Millisecond*500, 20*time.Second) + if err != nil { + fmt.Printf("Waiting aborted with error: %v\n", err) + } else { + fmt.Printf("Triggered by %+v\n", trigger) + } + + //Test single trigger on any LED + fmt.Println("Waiting for any LED single state change, timeout after 15 seconds") + trigger, err = hidCtl.Keyboard.WaitLEDStateChange(ch,hid.MaskAny, 15*time.Second) + if err != nil { + fmt.Printf("Waiting aborted with error: %v\n", err) + } else { + fmt.Printf("Triggered by %+v\n", trigger) + } + + + + + //Test single trigger on NUMLOCK LED (ignore CAPSLOCK, SCROLLLOCK etc.) + fmt.Println("Waiting for NUMLOCK LED state change, timeout after 15 seconds") + trigger, err = hidCtl.Keyboard.WaitLEDStateChange(ch,hid.MaskNumLock, 15*time.Second) + if err != nil { + fmt.Printf("Waiting aborted with error: %v\n", err) + } else { + fmt.Printf("Triggered by %+v\n", trigger) + } + + //Test single trigger on NUMLOCK LED (ignore CAPSLOCK, SCROLLLOCK etc.) + fmt.Println("Waiting for CAPSLOCK LED state change for 15 seconds") + trigger, err = hidCtl.Keyboard.WaitLEDStateChange(ch, hid.MaskCapsLock, 15*time.Second) + if err != nil { + fmt.Printf("Waiting aborted with error: %v\n", err) + } else { + fmt.Printf("Triggered by %+v\n", trigger) + } +} + +func TestMultiLEDTrigges(hidCtl *hid.HIDController, triggerMask byte) { + //Test repeat trigger on given LED + ch := make(chan func(),0) + defer close(ch) + fmt.Printf("Waiting for repeated LED state change (5 times frequently) of mask %v, wait timeout after 20 seconds...\n", triggerMask) + trigger, err := hidCtl.Keyboard.WaitLEDStateChangeRepeated(ch ,triggerMask, 5, time.Millisecond*500, 20*time.Second) + if err != nil { + fmt.Printf("Waiting aborted with error: %v\n", err) + } else { + fmt.Printf("Triggered by %+v\n", trigger) + } +} + +func TestConcurrentLEDTriggers(hidCtl *hid.HIDController) { + go TestMultiLEDTrigges(hidCtl, hid.MaskNumLock) + go TestMultiLEDTrigges(hidCtl, hid.MaskCapsLock) + go TestMultiLEDTrigges(hidCtl, hid.MaskCapsLock | hid.MaskScrollLock) + time.Sleep(2*time.Second) + go TestMultiLEDTrigges(hidCtl, hid.MaskAny) + TestMultiLEDTrigges(hidCtl, hid.MaskKana) + +} + + +func TestStringTyping(hidCtl *hid.HIDController) { + fmt.Println("Typing:") + fmt.Println(StringAscii) + //err := hidCtl.Keyboard.StringToPressKeySequence("Test:" + StringAscii + "\t" + StringSpecial1) + err := hidCtl.Keyboard.StringToPressKeySequence(StringAscii) + if err != nil { fmt.Println(err)} +} + +func TestCombinedScript(hidCtl *hid.HIDController) (err error) { + + testcript := ` + + console.log("HID Script test for P4wnP1 rework"); //Print to internal console + for (var i = 0; i<5; i++) { + move(128, 0); + delay(500); + move(0, -100.1); + delay(500); + move(-100, 0); + delay(500); + move(0, 100); + delay(500); + } + + console.log("HID Script test for P4wnP1 rework"); //Print to internal console + for (var i = 0; i<5; i++) { + moveTo(0.0, 0.0); + delay(500); + moveTo(0.8, 0.0); + delay(500); + moveTo(0.8, 0.8); + delay(500); + moveTo(0.8, 0.8); + delay(500); + } + waitLED(ANY) + + layout("US"); //Switch to US keyboard layout + type("Some ASCII test text QWERTZ\n") //Type text to target ('\n' translates to RETURN key) + + delay(200); //sleep 200 milliseconds + + //waitLEDRepeat test + var mask = NUM | SCROLL; + var repeatCount = 5; + var repeatIntervalMs = 800; + var timeout = 20; + + //result = waitLEDRepeat(mask, repeatCount, repeatIntervalMs, timeout) + result = waitLEDRepeat(mask, repeatCount) + console.log("Result: " + JSON.stringify(result)); //Log result object as JSON to internal console + + waitLED(NUM | SCROLL, 2); //Wait for NumLock or ScrollLock LED change, abort after 2 seconds + + layout("DE"); //Switch to German keyboard layout + type("Non ASCII: üÜöÖäÄ"); //Type non ASCII + press("ENTER"); //Introduce linebreak by pressing RETURN directly + press("RETURN"); //Alias + + counter = 4; //set a var ... + type("Pressing + "+ counter +" times\n"); //... and type it, along with a string + for (var i=0; i + Extended supported rates: 6.0 9.0 12.0 48.0 + RSN: * Version: 1 + * Group cipher: CCMP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c) + HT capabilities: + Capabilities: 0x1ad + RX LDPC + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 3839 bytes + No DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 4 usec (0x05) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 6 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 1 + * HT protection: no + * non-GF present: 0 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Extended capabilities: Extended Channel Switching, BSS Transition, 6 + WMM: * Parameter version 1 + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS 5c:dc:96:b4:59:af(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2437 + beacon interval: 100 TUs + capability: ESS Privacy ShortSlotTime RadioMeasure (0x1411) + signal: -38.00 dBm + last seen: 10 ms ago + SSID: WLAN-579086 + Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0 36.0 54.0 + DS Parameter set: channel 6 + Country: DE Environment: Indoor/Outdoor + Channels [1 - 13] @ 22 dBm + ERP: + ERP D4.0: + RSN: * Version: 1 + * Group cipher: CCMP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c) + Extended supported rates: 6.0 9.0 12.0 48.0 + HT capabilities: + Capabilities: 0x19fe + HT20/HT40 + SM Power Save disabled + RX Greenfield + RX HT20 SGI + RX HT40 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 7935 bytes + DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 16 usec (0x07) + HT RX MCS rate indexes supported: 0-15, 32 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 6 + * secondary channel offset: below + * STA channel width: any + * RIFS: 1 + * HT protection: no + * non-GF present: 0 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Overlapping BSS scan params: + * passive dwell: 20 TUs + * active dwell: 10 TUs + * channel width trigger scan interval: 300 s + * scan passive total per channel: 200 TUs + * scan active total per channel: 20 TUs + * BSS width channel transition delay factor: 5 + * OBSS Scan Activity Threshold: 0.25 % + Extended capabilities: HT Information Exchange Supported, Extended Channel Switching, 6 + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * Response Type: 3 (AP) + * UUID: 7470bfaa-0621-242d-7915-13686f9ded23 + * Manufacturer: ARCADYAN + * Model: DT724 + * Model Number: 1.0 + * Serial Number: 888 + * Primary Device Type: 6-0050f204-1 + * Device name: DT724 + * Config methods: + * RF Bands: 0x3 + * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20 + WMM: * Parameter version 1 + * u-APSD + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS 4e:66:41:a0:5b:35(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2462 + beacon interval: 100 TUs + capability: ESS SpectrumMgmt ShortSlotTime RadioMeasure (0x1501) + signal: -35.00 dBm + last seen: 10 ms ago + SSID: AndroidAP8905 + Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0 36.0 54.0 + DS Parameter set: channel 11 + TIM: DTIM Count 0 DTIM Period 2 Bitmap Control 0x0 Bitmap[0] 0x0 + Country: DE Environment: Indoor/Outdoor + Channels [1 - 13] @ 20 dBm + Power constraint: 0 dB + TPC report: TX power: 17 dBm + ERP: + Extended supported rates: 6.0 9.0 12.0 48.0 + HT capabilities: + Capabilities: 0x1ad + RX LDPC + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 3839 bytes + No DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 4 usec (0x05) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 11 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 1 + * HT protection: no + * non-GF present: 0 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Extended capabilities: Extended Channel Switching, BSS Transition, 6 + WMM: * Parameter version 1 + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS 88:e3:ab:9d:38:f5(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2412 + beacon interval: 100 TUs + capability: ESS Privacy ShortSlotTime RadioMeasure (0x1411) + signal: -84.00 dBm + last seen: 0 ms ago + SSID: WLAN-WGF3FG + Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0 36.0 54.0 + DS Parameter set: channel 1 + ERP: Barker_Preamble_Mode + ERP D4.0: Barker_Preamble_Mode + RSN: * Version: 1 + * Group cipher: CCMP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c) + Extended supported rates: 6.0 9.0 12.0 48.0 + HT capabilities: + Capabilities: 0x19ac + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 7935 bytes + DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 1 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 0 + * HT protection: no + * non-GF present: 1 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Overlapping BSS scan params: + * passive dwell: 20 TUs + * active dwell: 10 TUs + * channel width trigger scan interval: 300 s + * scan passive total per channel: 200 TUs + * scan active total per channel: 20 TUs + * BSS width channel transition delay factor: 5 + * OBSS Scan Activity Threshold: 0.25 % + Extended capabilities: HT Information Exchange Supported, Extended Channel Switching, 6 + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * Response Type: 3 (AP) + * UUID: 13082394-62d2-8063-e9de-c42e3a2d1071 + * Manufacturer: Broadcom + * Model: Broadcom + * Model Number: 123456 + * Serial Number: 1234 + * Primary Device Type: 6-0050f204-1 + * Device name: BroadcomAP + * Config methods: + * RF Bands: 0x3 + * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20 + WMM: * Parameter version 1 + * u-APSD + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS b8:bc:1b:63:33:d9(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2412 + beacon interval: 100 TUs + capability: ESS Privacy ShortSlotTime RadioMeasure (0x1411) + signal: -81.00 dBm + last seen: 0 ms ago + SSID: schmidtderhit + Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0 36.0 54.0 + DS Parameter set: channel 1 + ERP: Barker_Preamble_Mode + ERP D4.0: Barker_Preamble_Mode + RSN: * Version: 1 + * Group cipher: CCMP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c) + Extended supported rates: 6.0 9.0 12.0 48.0 + HT capabilities: + Capabilities: 0x19ac + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 7935 bytes + DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 1 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 0 + * HT protection: no + * non-GF present: 1 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Overlapping BSS scan params: + * passive dwell: 20 TUs + * active dwell: 10 TUs + * channel width trigger scan interval: 300 s + * scan passive total per channel: 200 TUs + * scan active total per channel: 20 TUs + * BSS width channel transition delay factor: 5 + * OBSS Scan Activity Threshold: 0.25 % + Extended capabilities: HT Information Exchange Supported, Extended Channel Switching, 6 + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * Response Type: 3 (AP) + * UUID: 8e998705-3ed2-399e-e43d-0d4c0a412fec + * Manufacturer: Broadcom + * Model: Broadcom + * Model Number: 123456 + * Serial Number: 1234 + * Primary Device Type: 6-0050f204-1 + * Device name: BroadcomAP + * Config methods: + * RF Bands: 0x3 + * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20 + WMM: * Parameter version 1 + * u-APSD + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS 88:e3:ab:9d:38:f6(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2412 + beacon interval: 100 TUs + capability: ESS ShortSlotTime RadioMeasure (0x1401) + signal: -84.00 dBm + last seen: 0 ms ago + SSID: Telekom_FON + Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0 36.0 54.0 + DS Parameter set: channel 1 + ERP: Barker_Preamble_Mode + ERP D4.0: Barker_Preamble_Mode + Extended supported rates: 6.0 9.0 12.0 48.0 + HT capabilities: + Capabilities: 0x19ac + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 7935 bytes + DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 1 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 0 + * HT protection: no + * non-GF present: 1 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Overlapping BSS scan params: + * passive dwell: 20 TUs + * active dwell: 10 TUs + * channel width trigger scan interval: 300 s + * scan passive total per channel: 200 TUs + * scan active total per channel: 20 TUs + * BSS width channel transition delay factor: 5 + * OBSS Scan Activity Threshold: 0.25 % + Extended capabilities: HT Information Exchange Supported, Extended Channel Switching, 6 + WMM: * Parameter version 1 + * u-APSD + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS b8:bc:1b:63:33:da(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2412 + beacon interval: 100 TUs + capability: ESS ShortSlotTime RadioMeasure (0x1401) + signal: -83.00 dBm + last seen: 0 ms ago + SSID: Telekom_FON + Supported rates: 1.0* 2.0* 5.5* 11.0* 18.0 24.0 36.0 54.0 + DS Parameter set: channel 1 + ERP: Barker_Preamble_Mode + ERP D4.0: Barker_Preamble_Mode + Extended supported rates: 6.0 9.0 12.0 48.0 + HT capabilities: + Capabilities: 0x19ac + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 7935 bytes + DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 1 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 0 + * HT protection: no + * non-GF present: 1 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Overlapping BSS scan params: + * passive dwell: 20 TUs + * active dwell: 10 TUs + * channel width trigger scan interval: 300 s + * scan passive total per channel: 200 TUs + * scan active total per channel: 20 TUs + * BSS width channel transition delay factor: 5 + * OBSS Scan Activity Threshold: 0.25 % + Extended capabilities: HT Information Exchange Supported, Extended Channel Switching, 6 + WMM: * Parameter version 1 + * u-APSD + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec +BSS 24:65:11:89:1c:28(on wlan0) -- associated + TSF: 0 usec (0d, 00:00:00) + freq: 2462 + beacon interval: 100 TUs + capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431) + signal: -40.00 dBm + last seen: 0 ms ago + SSID: spycki3 + Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0* 9.0 12.0* 18.0 + DS Parameter set: channel 11 + TIM: DTIM Count 0 DTIM Period 1 Bitmap Control 0x0 Bitmap[0] 0x1 + Country: DE Environment: Indoor/Outdoor + Channels [1 - 13] @ 20 dBm + ERP: + RSN: * Version: 1 + * Group cipher: TKIP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000) + Extended supported rates: 24.0* 36.0 48.0 54.0 + HT capabilities: + Capabilities: 0x11ce + HT20/HT40 + SM Power Save disabled + RX HT40 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 3839 bytes + DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT RX MCS rate indexes supported: 0-15 + HT TX MCS rate indexes are undefined + HT operation: + * primary channel: 11 + * secondary channel offset: below + * STA channel width: any + * RIFS: 1 + * HT protection: 20 MHz + * non-GF present: 1 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + WPA: * Version: 1 + * Group cipher: TKIP + * Pairwise ciphers: TKIP + * Authentication suites: PSK + WMM: * Parameter version 1 + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * UUID: 0cb4b30f-b5d6-7e18-4ec8-246511891c10 + * RF Bands: 0x3 +BSS c0:25:06:eb:8e:7d(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2437 + beacon interval: 100 TUs + capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431) + signal: -84.00 dBm + last seen: 0 ms ago + SSID: FRITZ!Box Fon WLAN 7390 + Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0* 9.0 12.0* 18.0 + DS Parameter set: channel 6 + Country: DE Environment: Indoor/Outdoor + Channels [1 - 13] @ 20 dBm + ERP: + Extended supported rates: 24.0* 36.0 48.0 54.0 + HT capabilities: + Capabilities: 0x18c + HT20 + SM Power Save disabled + TX STBC + RX STBC 1-stream + Max AMSDU length: 3839 bytes + No DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT TX/RX MCS rate indexes supported: 0-15 + HT operation: + * primary channel: 6 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 1 + * HT protection: no + * non-GF present: 0 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Extended capabilities: 6 + WMM: * Parameter version 1 + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec + RSN: * Version: 1 + * Group cipher: TKIP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000) + WPA: * Version: 1 + * Group cipher: TKIP + * Pairwise ciphers: TKIP + * Authentication suites: PSK + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * Response Type: 3 (AP) + * UUID: 76fc7d2e-2e0b-5c3b-7135-c02506eb8e7c + * Manufacturer: AVM + * Model: FBox + * Model Number: 0000 + * Serial Number: 0000 + * Primary Device Type: 6-0050f204-1 + * Device name: FBox + * Config methods: Display, PBC, Keypad + * RF Bands: 0x3 + * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20 +BSS c2:25:06:eb:8e:7d(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2437 + beacon interval: 100 TUs + capability: ESS Privacy ShortPreamble ShortSlotTime (0x0431) + signal: -82.00 dBm + last seen: 0 ms ago + SSID: SDK Gast + Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0* 9.0 12.0* 18.0 + DS Parameter set: channel 6 + Country: DE Environment: Indoor/Outdoor + Channels [1 - 13] @ 20 dBm + ERP: + Extended supported rates: 24.0* 36.0 48.0 54.0 + HT capabilities: + Capabilities: 0x18c + HT20 + SM Power Save disabled + TX STBC + RX STBC 1-stream + Max AMSDU length: 3839 bytes + No DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT TX/RX MCS rate indexes supported: 0-15 + HT operation: + * primary channel: 6 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 1 + * HT protection: no + * non-GF present: 0 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Extended capabilities: 6 + WMM: * Parameter version 1 + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec + RSN: * Version: 1 + * Group cipher: TKIP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000) + WPA: * Version: 1 + * Group cipher: TKIP + * Pairwise ciphers: TKIP + * Authentication suites: PSK + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * Response Type: 3 (AP) + * UUID: dfb77a7a-25b2-93f6-7ba8-01e7cd0bdb51 + * Manufacturer: AVM + * Model: FBox + * Model Number: 0000 + * Serial Number: 0000 + * Primary Device Type: 6-0050f204-1 + * Device name: FBox + * Config methods: Display, PBC, Keypad + * RF Bands: 0x3 + * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20 +BSS e0:28:6d:dd:b1:fc(on wlan0) + TSF: 0 usec (0d, 00:00:00) + freq: 2462 + beacon interval: 100 TUs + capability: ESS Privacy ShortPreamble (0x0031) + signal: -75.00 dBm + last seen: 0 ms ago + SSID: FRITZ!Box 7362 SL + Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0* 9.0 12.0* 18.0 + DS Parameter set: channel 11 + Country: DE Environment: Indoor/Outdoor + Channels [1 - 13] @ 20 dBm + ERP: + Extended supported rates: 24.0* 36.0 48.0 54.0 + HT capabilities: + Capabilities: 0x1ad + RX LDPC + HT20 + SM Power Save disabled + RX HT20 SGI + TX STBC + RX STBC 1-stream + Max AMSDU length: 3839 bytes + No DSSS/CCK HT40 + Maximum RX AMPDU length 65535 bytes (exponent: 0x003) + Minimum RX AMPDU time spacing: 8 usec (0x06) + HT TX/RX MCS rate indexes supported: 0-23 + HT operation: + * primary channel: 11 + * secondary channel offset: no secondary + * STA channel width: 20 MHz + * RIFS: 1 + * HT protection: no + * non-GF present: 1 + * OBSS non-GF present: 0 + * dual beacon: 0 + * dual CTS protection: 0 + * STBC beacon: 0 + * L-SIG TXOP Prot: 0 + * PCO active: 0 + * PCO phase: 0 + Extended capabilities: 6 + WMM: * Parameter version 1 + * BE: CW 15-1023, AIFSN 3 + * BK: CW 15-1023, AIFSN 7 + * VI: CW 7-15, AIFSN 2, TXOP 3008 usec + * VO: CW 3-7, AIFSN 2, TXOP 1504 usec + RSN: * Version: 1 + * Group cipher: CCMP + * Pairwise ciphers: CCMP + * Authentication suites: PSK + * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000) + WPS: * Version: 1.0 + * Wi-Fi Protected Setup State: 2 (Configured) + * Response Type: 3 (AP) + * UUID: 80ffd276-a392-0a84-6421-e0286dddb1fc + * Manufacturer: AVM + * Model: FBox + * Model Number: 0000 + * Serial Number: 0000 + * Primary Device Type: 6-0050f204-1 + * Device name: FBox + * Config methods: Display, PBC, Keypad + * RF Bands: 0x1 + * Unknown TLV (0x1049, 6 bytes): 00 37 2a 00 01 20` + + func main() { + //res, err := service.ParseIwScan(iw_scan_out) + res, err := service.WifiScan("wlan0") + if err != nil { + log.Fatal(err) + } + fmt.Printf("Parsed scan result:\n%v\n", res) + err = service.WifiCreateWpaSupplicantConfigFile("spycki1 2 3", "a b c c b b", "/tmp/wpa_supplicant.conf") + if err != nil { log.Fatal(err)} + + } \ No newline at end of file