Skip to content

Commit

Permalink
Updated badges, libs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyclone-github authored Dec 8, 2024
1 parent 173aaa0 commit eef16ed
Show file tree
Hide file tree
Showing 6 changed files with 323 additions and 317 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=cyclone-github&repo=crackmon&theme=gruvbox)](https://github.com/cyclone-github/)
[![Readme Card](https://github-readme-stats.vercel.app/api/pin/?username=cyclone-github&repo=crackmon&theme=gruvbox)](https://github.com/cyclone-github/crackmon/)

[![Go Report Card](https://goreportcard.com/badge/github.com/cyclone-github/crackmon)](https://goreportcard.com/report/github.com/cyclone-github/crackmon)
[![GitHub issues](https://img.shields.io/github/issues/cyclone-github/crackmon.svg)](https://github.com/cyclone-github/crackmon/issues)
[![License](https://img.shields.io/github/license/cyclone-github/crackmon.svg)](LICENSE)
[![GitHub release](https://img.shields.io/github/release/cyclone-github/crackmon.svg)](https://github.com/cyclone-github/crackmon/releases)
<!-- [![Go Reference](https://pkg.go.dev/badge/github.com/cyclone-github/crackmon.svg)](https://pkg.go.dev/github.com/cyclone-github/crackmon) -->

# crackmon
Hashcat wrapper tool to bypass current attack if crack rate drops below threshold.
Expand Down
96 changes: 48 additions & 48 deletions func_linux.go
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)
}
120 changes: 60 additions & 60 deletions func_windows.go
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)
}
6 changes: 3 additions & 3 deletions go.mod
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
12 changes: 6 additions & 6 deletions go.sum
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=
Loading

0 comments on commit eef16ed

Please sign in to comment.