-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason Talon
committed
May 24, 2022
1 parent
8bed47b
commit 3523441
Showing
8 changed files
with
635 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea | ||
bin | ||
**/*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
build/mac/m1: | ||
GOOS=darwin GOARCH=arm64 go build -o ./bin/mac/m1/tasmotalist | ||
|
||
build/win/amd64: | ||
GOOS=windows GOARCH=amd64 go build -o ./bin/win/amd64/tasmotalist | ||
|
||
build/win/arm64: | ||
GOOS=windows GOARCH=arm64 go build -o ./bin/win/arm64/tasmotalist | ||
|
||
build: | ||
rimraf bin | ||
make build/mac/m1 | ||
make build/win/amd64 | ||
make build/win/arm64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module github.com/jasontalon/tasmotalist | ||
|
||
go 1.18 | ||
|
||
require github.com/PuerkitoBio/goquery v1.8.0 | ||
|
||
require ( | ||
github.com/andybalholm/cascadia v1.3.1 // indirect | ||
github.com/briandowns/spinner v1.18.1 // indirect | ||
github.com/fatih/color v1.7.0 // indirect | ||
github.com/mattn/go-colorable v0.1.2 // indirect | ||
github.com/mattn/go-isatty v0.0.8 // indirect | ||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 // indirect | ||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U= | ||
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI= | ||
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c= | ||
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA= | ||
github.com/briandowns/spinner v1.18.1 h1:yhQmQtM1zsqFsouh09Bk/jCjd50pC3EOGsh28gLVvwY= | ||
github.com/briandowns/spinner v1.18.1/go.mod h1:mQak9GHqbspjC/5iUx3qMlIho8xBS/ppAL/hX5SmPJU= | ||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= | ||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= | ||
github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= | ||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= | ||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE= | ||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | ||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8 h1:/6y1LfuqNuQdHAm0jjtPtgRcxIxjVZgm5OTu8/QhZvk= | ||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= | ||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c= | ||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path" | ||
"strings" | ||
"time" | ||
|
||
"github.com/briandowns/spinner" | ||
) | ||
|
||
func main() { | ||
|
||
if !CheckNmap() { | ||
panic("nmap not installed") | ||
} | ||
|
||
wd, err := os.Getwd() | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
nmapFile := "nmap.xml" | ||
|
||
nmapFullPath := path.Join(wd, nmapFile) | ||
|
||
currentIp := GetOutboundIP().String() | ||
|
||
ipRange := currentIp[0:strings.LastIndex(currentIp, ".")] + ".0-255" | ||
|
||
spin := spinner.New(spinner.CharSets[2], 100*time.Millisecond) | ||
|
||
spin.Prefix = "Scanning network " + ipRange + " " | ||
|
||
spin.Start() | ||
|
||
_, err = ExecuteCmd("nmap", "--script-timeout", "2", "-d", "-oX", nmapFile, "-p", "80", ipRange) | ||
spin.Stop() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
if _, err := os.Stat(nmapFullPath); err != nil { | ||
panic(err) | ||
} | ||
|
||
spin.Prefix = "Looking for tasmota devices... " | ||
|
||
spin.Start() | ||
|
||
nmapOutput, err := GetNmapOutput(nmapFullPath) | ||
|
||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
devices := FindTasmotaDevices(FindPotentialHosts(nmapOutput.Hosts)) | ||
|
||
ResolveTasmotaDeviceName(devices) | ||
|
||
spin.Stop() | ||
|
||
if len(devices) == 0 { | ||
fmt.Println("nothing found.") | ||
return | ||
} | ||
|
||
results := "" | ||
|
||
for _, device := range devices { | ||
results += fmt.Sprintf("%-15s %s\n", device.Address.Addr, device.Hostnames.Hostname.Name) | ||
} | ||
|
||
fmt.Println(results) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package main | ||
|
||
import "encoding/xml" | ||
|
||
type Port struct { | ||
Protocol string `xml:"protocol,attr"` | ||
Portid string `xml:"portid,attr"` | ||
State struct { | ||
State string `xml:"state,attr"` | ||
Reason string `xml:"reason,attr"` | ||
ReasonTtl string `xml:"reason_ttl,attr"` | ||
} `xml:"state"` | ||
Service struct { | ||
Name string `xml:"name,attr"` | ||
Method string `xml:"method,attr"` | ||
Conf string `xml:"conf,attr"` | ||
} `xml:"service"` | ||
} | ||
|
||
type Host struct { | ||
Starttime string `xml:"starttime,attr"` | ||
Endtime string `xml:"endtime,attr"` | ||
Status struct { | ||
State string `xml:"state,attr"` | ||
Reason string `xml:"reason,attr"` | ||
ReasonTtl string `xml:"reason_ttl,attr"` | ||
} `xml:"status"` | ||
Address struct { | ||
Addr string `xml:"addr,attr"` | ||
Addrtype string `xml:"addrtype,attr"` | ||
} `xml:"address"` | ||
Hostnames struct { | ||
Hostname struct { | ||
Name string `xml:"name,attr"` | ||
Type string `xml:"type,attr"` | ||
} `xml:"hostname"` | ||
} `xml:"hostnames"` | ||
Ports struct { | ||
Port []Port `xml:"port"` | ||
} `xml:"ports"` | ||
Times struct { | ||
Srtt string `xml:"srtt,attr"` | ||
Rttvar string `xml:"rttvar,attr"` | ||
To string `xml:"to,attr"` | ||
} `xml:"times"` | ||
} | ||
|
||
type NmapOutput struct { | ||
XMLName xml.Name `xml:"nmaprun"` | ||
Scanner string `xml:"scanner,attr"` | ||
Args string `xml:"args,attr"` | ||
Start string `xml:"start,attr"` | ||
Startstr string `xml:"startstr,attr"` | ||
Version string `xml:"version,attr"` | ||
Xmloutputversion string `xml:"xmloutputversion,attr"` | ||
Scaninfo struct { | ||
Type string `xml:"type,attr"` | ||
Protocol string `xml:"protocol,attr"` | ||
Numservices string `xml:"numservices,attr"` | ||
Services string `xml:"services,attr"` | ||
} `xml:"scaninfo"` | ||
Verbose struct { | ||
Level string `xml:"level,attr"` | ||
} `xml:"verbose"` | ||
Debugging struct { | ||
Level string `xml:"level,attr"` | ||
} `xml:"debugging"` | ||
HostHints []struct { | ||
Status struct { | ||
State string `xml:"state,attr"` | ||
Reason string `xml:"reason,attr"` | ||
ReasonTtl string `xml:"reason_ttl,attr"` | ||
} `xml:"status"` | ||
Address struct { | ||
Addr string `xml:"addr,attr"` | ||
Addrtype string `xml:"addrtype,attr"` | ||
} `xml:"address"` | ||
Hostnames string `xml:"hostnames"` | ||
} `xml:"hosthint"` | ||
Hosts []Host `xml:"host"` | ||
Runstats struct { | ||
Finished struct { | ||
Time string `xml:"time,attr"` | ||
Timestr string `xml:"timestr,attr"` | ||
Summary string `xml:"summary,attr"` | ||
Elapsed string `xml:"elapsed,attr"` | ||
Exit string `xml:"exit,attr"` | ||
} `xml:"finished"` | ||
Hosts struct { | ||
Up string `xml:"up,attr"` | ||
Down string `xml:"down,attr"` | ||
Total string `xml:"total,attr"` | ||
} `xml:"hosts"` | ||
} `xml:"runstats"` | ||
} |
Oops, something went wrong.