initial commit

This commit is contained in:
Cadey Ratio 2019-11-30 16:40:22 +00:00
commit 2d322f5093
6 changed files with 107 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.env

12
LICENSE Normal file
View File

@ -0,0 +1,12 @@
Copyright (c) 2019 Christine Dodrill <me@christine.website>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# yubidude
Yubidude is a small yubikey OTP tester and username extractor sample.

15
go.mod Normal file
View File

@ -0,0 +1,15 @@
module tulpa.dev/cadey/yubidude
go 1.13
require (
github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e
github.com/conformal/yubikey v0.0.0-20140117205816-65ac3de5ed8f
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 // indirect
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 // indirect
github.com/joho/godotenv v1.3.0
github.com/kr/pretty v0.1.0
)

21
go.sum Normal file
View File

@ -0,0 +1,21 @@
github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e h1:Bqtt5C+uVk+vH/t5dmB47uDCTwxw16EYHqvJnmY2aQc=
github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e/go.mod h1:njRCDrl+1RQ/A/+KVU8Ho2EWAxUSkohOWczdW3dzDG0=
github.com/conformal/yubikey v0.0.0-20140117205816-65ac3de5ed8f h1:6arIzlpAngUFbjJmFwqdKXCr0iQZkaiAzpDPprqM3Ss=
github.com/conformal/yubikey v0.0.0-20140117205816-65ac3de5ed8f/go.mod h1:zVcG9twkhqcPdA/KivDkevbYHZFWN3gAJkHuxqH4OCc=
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/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ=
github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456 h1:CkmB2l68uhvRlwOTPrwnuitSxi/S3Cg4L5QYOcL9MBc=
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456/go.mod h1:zFhibDvPDWmtk4dAQ05sRobtyoffEHygEt3wSNuAzz8=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y=
github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=

55
main.go Normal file
View File

@ -0,0 +1,55 @@
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"strings"
"github.com/GeertJohan/yubigo"
"github.com/facebookgo/flagenv"
_ "github.com/joho/godotenv/autoload"
)
var (
clientID = flag.String("client-id", "", "yubikey client ID")
secretKey = flag.String("secret-key", "", "yubikey secret key")
)
func main() {
flagenv.Parse()
flag.Parse()
ya, err := yubigo.NewYubiAuth(*clientID, *secretKey)
if err != nil {
log.Fatal("bad creds:", err)
}
reader := bufio.NewReader(os.Stdin)
fmt.Print("Enter text: ")
otp, err := reader.ReadString('\n')
if err != nil {
log.Fatal("error reading OTP:", err)
}
otp = strings.TrimSpace(otp)
fmt.Println("input: ", otp)
pubID, _, err := yubigo.ParseOTP(otp)
if err != nil {
log.Fatal("error parsing OTP:", err)
}
fmt.Println("prefix:", string(pubID))
_, ok, err := ya.Verify(otp)
if err != nil {
log.Fatal("bad response:", err)
}
if !ok {
log.Fatal("not ok")
}
fmt.Println("code is valid")
}