mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Implement Steam TOTP support using github.com/fortis/go-steam-totp
This commit is contained in:
@@ -3,6 +3,7 @@ module github.com/rwinkhart/MUTN
|
|||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/fortis/go-steam-totp v0.0.0-20171114202746-18e928674727
|
||||||
github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481
|
github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481
|
||||||
golang.org/x/crypto v0.20.0
|
golang.org/x/crypto v0.20.0
|
||||||
gopkg.in/ini.v1 v1.67.0
|
gopkg.in/ini.v1 v1.67.0
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBW
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/fortis/go-steam-totp v0.0.0-20171114202746-18e928674727 h1:1RkPJqfzrncAuh9xgoslr9OplZskm+VRA9lkucHPQZ4=
|
||||||
|
github.com/fortis/go-steam-totp v0.0.0-20171114202746-18e928674727/go.mod h1:wRAWHbTlpt0C4kwnKoa42L2Phrv6uIq+c50P2uKpb7I=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481 h1:FkxbO331O7mS5EJkP+MCi0o2gswh/Aezs+//NmefrR8=
|
github.com/pquerna/otp v1.4.1-0.20231130234153-3357de7c0481 h1:FkxbO331O7mS5EJkP+MCi0o2gswh/Aezs+//NmefrR8=
|
||||||
|
|||||||
+25
-4
@@ -3,8 +3,10 @@ package offline
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
steamtotp "github.com/fortis/go-steam-totp"
|
||||||
"github.com/pquerna/otp/totp"
|
"github.com/pquerna/otp/totp"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,9 +29,19 @@ func CopyArgument(targetLocation string, field int, executableName string) {
|
|||||||
if field != 5 { // TODO Update field after removed from notes (breaking sshyp entry compatibility)
|
if field != 5 { // TODO Update field after removed from notes (breaking sshyp entry compatibility)
|
||||||
copySubject = decryptedEntry[field]
|
copySubject = decryptedEntry[field]
|
||||||
} else { // TOTP mode
|
} else { // TOTP mode
|
||||||
|
var secret string // stores secret for TOTP generation
|
||||||
|
var forSteam bool // indicates whether to generate TOTP in Steam format
|
||||||
|
|
||||||
|
if strings.HasPrefix(decryptedEntry[5], "steam@") {
|
||||||
|
secret = decryptedEntry[5][6:]
|
||||||
|
forSteam = true
|
||||||
|
} else {
|
||||||
|
secret = decryptedEntry[5]
|
||||||
|
}
|
||||||
|
|
||||||
for { // keep field copied to clipboard, refresh on 30-second intervals
|
for { // keep field copied to clipboard, refresh on 30-second intervals
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
copyField(genTOTP(decryptedEntry[5], currentTime), "")
|
copyField(genTOTP(secret, currentTime, forSteam), "")
|
||||||
// sleep until next 30-second interval
|
// sleep until next 30-second interval
|
||||||
time.Sleep(time.Duration(30-(currentTime.Second()%30)) * time.Second)
|
time.Sleep(time.Duration(30-(currentTime.Second()%30)) * time.Second)
|
||||||
}
|
}
|
||||||
@@ -56,12 +68,21 @@ func ClipClearArgument() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// genTOTP generates a TOTP token from a secret
|
// genTOTP generates a TOTP token from a secret (supports standard and Steam TOTP)
|
||||||
func genTOTP(secret string, time time.Time) string {
|
func genTOTP(secret string, time time.Time, forSteam bool) string {
|
||||||
totpToken, err := totp.GenerateCode(secret, time)
|
var totpToken string
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if forSteam {
|
||||||
|
totpToken, err = steamtotp.GenerateAuthCode(secret, time)
|
||||||
|
} else {
|
||||||
|
totpToken, err = totp.GenerateCode(secret, time)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(AnsiError + "Error generating TOTP code" + AnsiReset)
|
fmt.Println(AnsiError + "Error generating TOTP code" + AnsiReset)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return totpToken
|
return totpToken
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user