Skip to content

Commit

Permalink
Let's see if this works at all
Browse files Browse the repository at this point in the history
  • Loading branch information
lkarlslund committed Nov 16, 2023
1 parent 50b2a1d commit 6fcf4b9
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build and publish pre-release

on:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Build
run: ./build.ps1
shell: pwsh

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "prerelease"
prerelease: true
title: "Development Build"
files: |
binaries/*
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build and publish release

on:
push:
tags: [ "*.*.*" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.21"

- name: Build
run: ./build.ps1
shell: pwsh

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
binaries/*
33 changes: 33 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function BuildVariants {
param (
$ldflags,
$compileflags,
$prefix,
$suffix,
$arch,
$os,
$path
)

foreach ($currentarch in $arch) {
foreach ($currentos in $os) {
Write-Output "Building $currentarch for $currentos"
$env:GOARCH = $currentarch
$env:GOOS = $currentos
$outputfile = "binaries/$prefix-$currentos-$currentarch$suffix"
if ($currentos -eq "windows") {
$outputfile += ".exe"
}
go build -ldflags "$ldflags" -o $outputfile $compileflags $path
if (Get-Command "cyclonedx-gomod" -ErrorAction SilentlyContinue)
{
cyclonedx-gomod app -json -licenses -output $outputfile.bom.json -main $path .
}
}
}
}

Set-Location $PSScriptRoot

# Release
BuildVariants -ldflags "$LDFLAGS -s" -prefix inhaler -path . -arch @("amd64") -os @("linux", "openbsd", "darwin", "freebsd", "windows")
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/lkarlslund/inhaler

go 1.21.4

require (
github.com/spf13/pflag v1.0.5
golang.org/x/crypto v0.15.0
)

require github.com/mmcloughlin/md4 v0.1.2 // indirect
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/mmcloughlin/md4 v0.1.2 h1:kGYl+iNbxhyz4u76ka9a+0TXP9KWt/LmnM0QhZwhcBo=
github.com/mmcloughlin/md4 v0.1.2/go.mod h1:AAxFX59fddW0IguqNzWlf1lazh1+rXeIt/Bj49cqDTQ=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
61 changes: 61 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main

import (
"bufio"
"encoding/hex"
"fmt"
"os"
"runtime"
"strings"
"sync"
"unicode/utf16"

"github.com/mmcloughlin/md4"
"github.com/spf13/pflag"
)

func main() {
hash := pflag.String("hash", "ntlm", "hash type to generate (ntlm)")
parallel := pflag.Int("parallel", runtime.NumCPU(), "number of threads to use")
pflag.Parse()

queue := make(chan string, *parallel*4)
var wg sync.WaitGroup

for i := 0; i < *parallel; i++ {
wg.Add(1)
go func() {
defer wg.Done()
switch *hash {
case "ntlm":
u16 := make([]byte, 128)
mdfour := md4.New()
for password := range queue {
/* Add all bytes, as well as the 0x00 of UTF-16 */
utf16encoded := utf16.Encode([]rune(password))
u16 = u16[:len(utf16encoded)*2]
for i, b := range utf16encoded {
u16[i*2] = byte(b)
u16[i*2+1] = byte(b >> 8)
}

/* Hash the byte array with MD4 */
mdfour.Reset()
mdfour.Write(u16)
md4 := mdfour.Sum(nil)

/* Return the output */
fmt.Println(password + ":" + hex.EncodeToString(md4))
}
}
}()
}

// read lines from stdin and put them in the queue
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
queue <- strings.Trim(scanner.Text(), "\r\n")
}
close(queue)
wg.Wait()
}
13 changes: 13 additions & 0 deletions readme.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# inhaler

Inhales plaintext passwords from stdin, exhales hashed passwords to stdout

## Usage

```
inhaler [--hash ntml] [--parallel 4]
```

Only supports x64 systems for performance reasons.

Made with ❤️ for mRr3b00t

0 comments on commit 6fcf4b9

Please sign in to comment.