-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
173aaa0
commit eef16ed
Showing
6 changed files
with
323 additions
and
317 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
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 |
---|---|---|
@@ -1,48 +1,48 @@ | ||
//go:build linux | ||
// +build linux | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/creack/pty" // used for sending user keyboard commands to hashcat | ||
) | ||
|
||
/* | ||
v2023-10-07.1520 | ||
v2023-10-13.1445; refactored sendX commands | ||
*/ | ||
|
||
// sendX func | ||
func linuxSendCmd(cmd string, stdin io.Writer) { | ||
io.WriteString(stdin, cmd) | ||
} | ||
|
||
// initialize OS specific logic | ||
func initializeAndExecute(cmdStr string, timeT int, crackT int, debug bool) { | ||
cmdSlice := strings.Fields(cmdStr) | ||
cmdName := cmdSlice[0] | ||
cmdArgs := cmdSlice[1:] | ||
|
||
cmd := exec.Command(cmdName, cmdArgs...) | ||
ptmx, err := pty.Start(cmd) // start hashcat command with pty | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Error starting command with PTY:", err) | ||
return | ||
} | ||
defer func() { _ = ptmx.Close() }() // close pty | ||
|
||
sendB = func(stdin io.Writer) { linuxSendCmd("b", stdin) } | ||
sendQ = func(stdin io.Writer) { linuxSendCmd("q", stdin) } | ||
|
||
// listen for user commands | ||
go ReadUserInput(ptmx) | ||
|
||
// initialize common logic | ||
initializeAndExecuteCommon(cmdStr, timeT, crackT, debug, ptmx, ptmx, checkOS) | ||
} | ||
//go:build linux | ||
// +build linux | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
|
||
"github.com/creack/pty" // used for sending user keyboard commands to hashcat | ||
) | ||
|
||
/* | ||
v2023-10-07.1520 | ||
v2023-10-13.1445; refactored sendX commands | ||
*/ | ||
|
||
// sendX func | ||
func linuxSendCmd(cmd string, stdin io.Writer) { | ||
io.WriteString(stdin, cmd) | ||
} | ||
|
||
// initialize OS specific logic | ||
func initializeAndExecute(cmdStr string, timeT int, crackT int, debug bool) { | ||
cmdSlice := strings.Fields(cmdStr) | ||
cmdName := cmdSlice[0] | ||
cmdArgs := cmdSlice[1:] | ||
|
||
cmd := exec.Command(cmdName, cmdArgs...) | ||
ptmx, err := pty.Start(cmd) // start hashcat command with pty | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Error starting command with PTY:", err) | ||
return | ||
} | ||
defer func() { _ = ptmx.Close() }() // close pty | ||
|
||
sendB = func(stdin io.Writer) { linuxSendCmd("b", stdin) } | ||
sendQ = func(stdin io.Writer) { linuxSendCmd("q", stdin) } | ||
|
||
// listen for user commands | ||
go ReadUserInput(ptmx) | ||
|
||
// initialize common logic | ||
initializeAndExecuteCommon(cmdStr, timeT, crackT, debug, ptmx, ptmx, checkOS) | ||
} |
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 |
---|---|---|
@@ -1,60 +1,60 @@ | ||
//go:build windows | ||
// +build windows | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"time" | ||
|
||
"github.com/UserExistsError/conpty" | ||
) | ||
|
||
/* | ||
v2023-10-07.1520 | ||
v2023-10-13.1445; refactored sendX commands | ||
*/ | ||
|
||
var cptyInstance *conpty.ConPty | ||
|
||
// conpty func for windows pty support | ||
func initializeConPTY(fullCmd string) error { | ||
var err error | ||
cptyInstance, err = conpty.Start(fullCmd) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// sendX func | ||
func windowsSendCmd(cmd string, stdin io.Writer) { | ||
_, err := cptyInstance.Write([]byte(cmd + "\n")) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Failed to send '%s' command: %v", cmd, err) | ||
} | ||
} | ||
|
||
// initialize OS specific logic | ||
func initializeAndExecute(cmdStr string, timeT int, crackT int, debug bool) { | ||
err := initializeConPTY(cmdStr) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Error initializing ConPTY:", err) | ||
return | ||
} | ||
sendB = func(stdin io.Writer) { windowsSendCmd("b", stdin) } | ||
sendQ = func(stdin io.Writer) { | ||
windowsSendCmd("q", stdin) | ||
cptyInstance.Close() | ||
time.Sleep(1 * time.Second) | ||
os.Exit(0) | ||
} | ||
|
||
// listen for user commands | ||
go ReadUserInput(cptyInstance) | ||
|
||
// initialize common logic | ||
initializeAndExecuteCommon(cmdStr, timeT, crackT, debug, cptyInstance, cptyInstance, checkOS) | ||
} | ||
//go:build windows | ||
// +build windows | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
"time" | ||
|
||
"github.com/UserExistsError/conpty" | ||
) | ||
|
||
/* | ||
v2023-10-07.1520 | ||
v2023-10-13.1445; refactored sendX commands | ||
*/ | ||
|
||
var cptyInstance *conpty.ConPty | ||
|
||
// conpty func for windows pty support | ||
func initializeConPTY(fullCmd string) error { | ||
var err error | ||
cptyInstance, err = conpty.Start(fullCmd) | ||
if err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// sendX func | ||
func windowsSendCmd(cmd string, stdin io.Writer) { | ||
_, err := cptyInstance.Write([]byte(cmd + "\n")) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Failed to send '%s' command: %v", cmd, err) | ||
} | ||
} | ||
|
||
// initialize OS specific logic | ||
func initializeAndExecute(cmdStr string, timeT int, crackT int, debug bool) { | ||
err := initializeConPTY(cmdStr) | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, "Error initializing ConPTY:", err) | ||
return | ||
} | ||
sendB = func(stdin io.Writer) { windowsSendCmd("b", stdin) } | ||
sendQ = func(stdin io.Writer) { | ||
windowsSendCmd("q", stdin) | ||
cptyInstance.Close() | ||
time.Sleep(1 * time.Second) | ||
os.Exit(0) | ||
} | ||
|
||
// listen for user commands | ||
go ReadUserInput(cptyInstance) | ||
|
||
// initialize common logic | ||
initializeAndExecuteCommon(cmdStr, timeT, crackT, debug, cptyInstance, cptyInstance, checkOS) | ||
} |
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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
module crackmon | ||
|
||
go 1.21.1 | ||
go 1.22.4 | ||
|
||
require ( | ||
github.com/UserExistsError/conpty v0.1.1 | ||
github.com/creack/pty v1.1.18 | ||
github.com/UserExistsError/conpty v0.1.4 | ||
github.com/creack/pty v1.1.24 | ||
) | ||
|
||
require golang.org/x/sys v0.8.0 // 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
github.com/UserExistsError/conpty v0.1.1 h1:cHDsU/XeoeDAQmVvCTV53SrXLG39YJ4++Pp3iAi1gXE= | ||
github.com/UserExistsError/conpty v0.1.1/go.mod h1:PDglKIkX3O/2xVk0MV9a6bCWxRmPVfxqZoTG/5sSd9I= | ||
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= | ||
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= | ||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= | ||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||
github.com/UserExistsError/conpty v0.1.4 h1:+3FhJhiqhyEJa+K5qaK3/w6w+sN3Nh9O9VbJyBS02to= | ||
github.com/UserExistsError/conpty v0.1.4/go.mod h1:PDglKIkX3O/2xVk0MV9a6bCWxRmPVfxqZoTG/5sSd9I= | ||
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= | ||
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= | ||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= | ||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
Oops, something went wrong.