Skip to content
  • Categories
  • Recent
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Slate)
  • No Skin
Collapse
Brand Logo

hashpwn

  1. Home
  2. Tools
  3. Text / Wordlist / Rules
  4. pcfg-go - The Fast PCFG

pcfg-go - The Fast PCFG

Scheduled Pinned Locked Moved Text / Wordlist / Rules
6 Posts 1 Posters 437 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cycloneC Online
    cycloneC Online
    cyclone
    Admin Trusted
    wrote on last edited by cyclone
    #1

    Title: pcfg-go
    Author: cyclone
    URL: https://github.com/cyclone-github/pcfg-go
    Description: Probabilistic Context Free Grammar (PCFG) password generator in Pure Go

    GitHub issues License GitHub release

    pcfg-go - The Fast PCFG

    • Probabilistic Context-Free Grammar (PCFG) password generator - Pure Go Edition
      • pcfg-go is a Pure Go rewrite of the Python3 pcfg_cracker
      • The goal of this Go implementation is to provide a substantial performance improvement for both trainer and guesser over the original Python3 version, while also adding features such as supporting $HEX[] input and multi-byte character support — which is not implemented in the Pure C pcfg_guesser
      • Credits for the original python3 pcfg_cracker belong to the author @lakiw
      • Rules trained by pcfg_trainer are compatible with hashcat's new PCFG -a 4 attack mode. See the hashcat PCFG implementation commit for details.

    Install

    pcfg_trainer:

    go install -ldflags="-s -w" github.com/cyclone-github/pcfg-go/cmd/pcfg_trainer@main
    

    pcfg_guesser:

    go install -ldflags="-s -w" github.com/cyclone-github/pcfg-go/cmd/pcfg_guesser@main
    

    Additions & improvements

    • Performance — ~53.94× faster pcfg_trainer and ~12.16× faster pcfg_guesser vs Python 3 (see Benchmarks below)
    • $HEX[] input — Trainer accepts $HEX encoded passwords in the training wordlist (multi-byte support)
    • Ctrl+C handling — Pressing Ctrl+C auto-saves the session in pcfg_guesser
    • Multi-keyboard layouts — QWERTY, AZERTY, QWERTZ, Dvorak, JCUKEN (Russian Cyrillic)
    • Expanded TLD list — Legacy TLDs, ccTLDs, gTLDs (.info, .xyz, .app, .dev, etc.), and short TLDs (.co, .io, .ai, .me, .gg); improves both website and email detection
    • Improved website detection — Broader URL/prefix detection (http://, https://, www., etc.) and host extraction
    • Multi-threaded architecture — pcfg_guesser is multi-threaded for increased performance
    • Compiled binary — No fuss; pcfg-go uses compiled binaries for speed and easy deployment

    Benchmarks on rockyou training set

    pcfg_trainer -r rockyou -t rockyou.txt

    • Python3 trainer: 13m21s (801s)
    • Go pcfg_trainer: 14.85s
    • Speedup: ~53.94×

    pcfg_guesser -r rockyou -n 100000000 (100 million guesses written to stdout)

    • Python3 pcfg_guesser: 195.5s
    • Go pcfg_guesser: 16.08s
    • Speedup: ~12.16×

    Usage

    pcfg_trainer

    Train a new ruleset from wordlist:

    pcfg_trainer -r rule_name -t wordlist.txt
    

    pcfg_guesser

    Generate guesses from a trained ruleset:

    pcfg_guesser -r rule_name
    

    Session save/restore:

    pcfg_guesser -r rule_name -s my_session   # save to my_session.sav on exit
    pcfg_guesser -r rule_name -s my_session -l # load and resume
    

    Press Ctrl+C to save session and exit.

    Piping into hashcat

    pcfg_guesser -r rule_name -s my_session | hashcat -m 0 hashes.txt...
    

    Using trained rules with hashcat -a 4 PCFG mode

    hashcat -m 0 -a 4 hashes.txt path_to_pcfg_rule_dir ...
    

    Flags

    pcfg_trainer

    pcfg-go vs pcfg-python3 flags

    Go Python3 Description
    -r --rule Ruleset name
    -t --training Training wordlist (required)
    -e --encoding File encoding
    -C --comments Config comments
    -S --save_sensitive Save emails, URLs
    -p --prefixcount Lines prefixed with count
    -n --ngram OMEN ngram size (2-5)
    -a --alphabet Alphabet size for Markov
    -c --coverage PCFG vs OMEN coverage
    -m --multiword Pre-train multiword file
    -h --help Help
    -version --version Version info

    pcfg_guesser

    pcfg-go vs pcfg-python3 flags

    Go Python3 Description
    -r --rule Ruleset name
    -s --session Session name
    -l --load Load previous session
    -n --limit Max guesses
    -b --skip_brute Skip OMEN/Markov
    -a --all_lower No case mangling
    -d --debug Debug output
    -h --help Help
    -version --version Version info

    Sysadmin by day | Ethical hacker by night | Go Dev | hashpwn
    3x RTX 4090 3x RTX 2080ti
    Forum Rules

    1 Reply Last reply
    0
    • cycloneC Online
      cycloneC Online
      cyclone
      Admin Trusted
      wrote on last edited by
      #2

      https://github.com/cyclone-github/pcfg-go/releases/tag/v0.5.0

      v0.5.0; 2026-03-16

      initial github release
      
      ### Overview
      Pure Go rewrite of the Python3 `pcfg_cracker`, designed as a near drop-in replacement with significant performance gains and expanded features
      
      ### Highlights
      ~3× faster trainer
      ~40× faster pcfg_guesser
      `$HEX[]` input/output support
      Full multi-byte / Unicode support (not supported in Compiled C Edition)
      Improved and expanded keyboard detection: Fixed/tuned: QWERTY, JCUKEN Added: AZERTY, QWERTZ, Dvorak
      Expanded detection for TLDs, URLs, and emails in trainer
      Auto-save and resume support in pcfg_guesser
      Multi-threaded for high-throughput performance
      

      Sysadmin by day | Ethical hacker by night | Go Dev | hashpwn
      3x RTX 4090 3x RTX 2080ti
      Forum Rules

      1 Reply Last reply
      👍
      0
      • cycloneC Online
        cycloneC Online
        cyclone
        Admin Trusted
        wrote on last edited by
        #3

        v0.5.1; 2026-03-17
        https://github.com/cyclone-github/pcfg-go/releases/tag/v0.5.1

        fix: unicode handling
        tweak: session save/restore
        

        Sysadmin by day | Ethical hacker by night | Go Dev | hashpwn
        3x RTX 4090 3x RTX 2080ti
        Forum Rules

        1 Reply Last reply
        0
        • cycloneC Online
          cycloneC Online
          cyclone
          Admin Trusted
          wrote on last edited by
          #4

          v0.5.2; 2026-03-23
          https://github.com/cyclone-github/pcfg-go/releases/tag/v0.5.2

          Fixed Issue #5 -n {nth} not outputting
          

          Sysadmin by day | Ethical hacker by night | Go Dev | hashpwn
          3x RTX 4090 3x RTX 2080ti
          Forum Rules

          1 Reply Last reply
          0
          • cycloneC Online
            cycloneC Online
            cyclone
            Admin Trusted
            wrote on last edited by cyclone
            #5

            v0.5.3; 2026-07-25
            https://github.com/cyclone-github/pcfg-go/releases/tag/v0.5.3

            • pcfg_guesser ~2× faster than v0.5.2
            • Reduce long-run RAM growth in pcfg_guesser (priority-queue frontier)
              • Compact parse-tree representation (interned type IDs, packed nodes, arena reuse)
              • Contiguous index-based heap (fewer per-item allocations)
              • Reuse OMEN optimizer cache per worker
              • Prefer []byte guess building to cut string churn
            • Same generation logic; parallel stdout interleaving may differ across runs
            • Rename trainer to pcfg_trainer

            Sysadmin by day | Ethical hacker by night | Go Dev | hashpwn
            3x RTX 4090 3x RTX 2080ti
            Forum Rules

            1 Reply Last reply
            👍
            0
            • cycloneC Online
              cycloneC Online
              cyclone
              Admin Trusted
              wrote last edited by cyclone
              #6

              pcfg-go v0.6.0-dev (upcoming release)
              https://github.com/cyclone-github/pcfg-go/commit/8fb59c2

              While I was testing hashcat's new -a 4 PCFG mode with different hash lists and Rules trained with pcfg-go, @atom mentioned something to me that I couldn't shake: "that needs a fast trainer".
              But, pcfg-go was already fast, right? How much faster did it need to be? I was determined to find the answer to this question and pored over possible optimizations in pcfg-go, optimizing keyboard walks, buffers, worker scheduling, profiling hot paths and reducing GC pressure, testing / benchmarking / and comparing Rule outputs to make sure the optimized trainer still produced 1:1 byte-level-identical Rules to v0.5.3.

              The result? Let's first back up a minute to run a few comparisons.

              • The original python3 pcfg_cracker trainer.py by @lakiw took 13m21s to train rockyou on my Debian 13 benchmarks
              • pcfg-go v0.5.3 brought rockyou training down to 2m38s
              • And finally, pcfg-go v0.6.0-dev brings rockyou training down to 14.8s

              Yes, from 13m21s to 14.8s. Now, that's a fast trainer. 😎

              9dc5d6d5-4ed8-4d6b-826f-b095be9997b0-image.jpeg

              A big thanks to @atom for his support, suggestions, and kindness, and @lakiw for giving the world pcfg_cracker in the first place.

              Sysadmin by day | Ethical hacker by night | Go Dev | hashpwn
              3x RTX 4090 3x RTX 2080ti
              Forum Rules

              1 Reply Last reply
              👍 🔥
              0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              homogenous-expeditionary
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent