Back to Articles

Learning Go for Security Work: A Deep Dive into parsiya/Hacking-with-Go

[ View on GitHub ]

Learning Go for Security Work: A Deep Dive into parsiya/Hacking-with-Go

Hook

Most programming tutorials teach you how to build web apps. But what if you need to intercept SSH credentials, fuzz image parsers, or build a TCP proxy to analyze malware traffic?

Context

Security professionals have long relied on Python for rapid tool development—it's why books like Black Hat Python became staples on red team bookshelves. But as Go gained traction in the security tooling ecosystem (with projects like CobaltStrike beacons, offensive frameworks, and cloud-native security tools being rewritten in Go), a knowledge gap emerged. Security practitioners needed Go skills, but traditional Go learning resources focused on web services, APIs, and concurrent server architectures—not the practical, script-like tooling that pentesters and security researchers actually build.

parsiya/Hacking-with-Go addresses this exact gap. Created by Parsia Hakimian, a security professional who documented his own Go learning journey, the repository takes a security-first approach to teaching the language. Instead of teaching Go through building REST APIs or microservices, it teaches through building SSH harvesters, network proxies, file format parsers, and fuzzers. The structure mirrors the beloved Black Hat Python approach: minimal theory, maximum practical application, with working code examples you can immediately adapt for security assessments.

Technical Insight

Learner

Content Directory

Code Directory

Chapter Markdown

Tutorials

Working Go Examples

Learning Path

Go Fundamentals

Security Context

Network Programming

TCP/UDP/SSH

File Parsing

Techniques

Fuzzing with

go-fuzz

Hands-on Practice

Security Tools

Development

System architecture — auto-generated

The repository's architecture reveals its pedagogical strength: it's organized as sequential chapters that progressively build complexity while maintaining a security focus. The 'content/' directory contains markdown tutorials while 'code/' holds corresponding working examples—a structure that encourages hands-on experimentation rather than passive reading.

Early chapters cover Go fundamentals but frame them through security lenses. Rather than teaching variables through calculator examples, you learn them through parsing command-line arguments for security tools. Slices and maps aren't taught through generic data manipulation—they're introduced through building data structures to store extracted credentials or network traffic metadata. This contextualization makes the learning stick because every concept has immediate application.

The networking chapters showcase where this approach truly shines. Here's an example of a simple TCP proxy from the repository that demonstrates Go's straightforward approach to network programming:

func handleConnection(src net.Conn, dest string) {
    defer src.Close()
    
    // Connect to destination
    dst, err := net.Dial("tcp", dest)
    if err != nil {
        log.Printf("Could not connect to %s: %v", dest, err)
        return
    }
    defer dst.Close()
    
    // Bidirectional copy
    go io.Copy(dst, src)
    io.Copy(src, dst)
}

func main() {
    listener, err := net.Listen("tcp", ":8080")
    if err != nil {
        log.Fatal(err)
    }
    defer listener.Close()
    
    for {
        conn, err := listener.Accept()
        if err != nil {
            log.Printf("Accept error: %v", err)
            continue
        }
        go handleConnection(conn, "example.com:80")
    }
}

This 30-line proxy is production-adjacent—you could deploy this for basic traffic inspection during a security assessment. The code demonstrates several Go idioms that security professionals need to understand: defer for resource cleanup, goroutines for concurrent connection handling, and the elegance of io.Copy for bidirectional data forwarding. Most importantly, it shows how Go's standard library eliminates the need for external dependencies that plague Python security tools.

The fuzzing chapter deserves special attention because it introduces go-fuzz with real-world targets. Rather than fuzzing toy examples, the tutorial walks through fuzzing actual libraries like PNG parsers—exactly what security researchers do when hunting for vulnerabilities. The approach teaches both Go and practical vulnerability research methodology. You learn about coverage-guided fuzzing, crash deduplication, and corpus management while simultaneously deepening your Go knowledge.

The SSH chapters are particularly valuable for red teamers. The repository demonstrates building SSH clients and servers from scratch using Go's crypto/ssh package, showing how to harvest credentials, tunnel traffic, or create reverse shells. This isn't theoretical—these are building blocks for actual post-exploitation tools. The code examples show how Go's strong typing and explicit error handling (while verbose) actually prevent the kinds of subtle bugs that plague Python-based offensive tools.

What makes the repository effective is its acknowledgment that security professionals think differently about code. They don't need perfectly idiomatic Go with comprehensive testing and graceful degradation—they need tools that work quickly, handle binary data cleanly, and cross-compile to target systems. The examples reflect this pragmatism: they prioritize readability and adaptability over optimization, making them easy templates for rapid tool development during engagements.

Gotcha

The most significant limitation is the repository's age. Last substantive updates occurred around 2017-2019, meaning it predates major Go developments like generics (Go 1.18), the modern module system's maturity, and contemporary security tooling patterns. Some code examples use older conventions that would be written differently today—though the fundamentals remain sound since Go maintains backward compatibility aggressively.

Several chapters remain marked as work-in-progress, most notably the "Useful Packages" section that would presumably cover essential security libraries. This means you're getting an incomplete picture of the Go security ecosystem. The repository won't teach you about modern frameworks like gVisor for sandboxing, contemporary exploit development with Go, or integration with cloud-native security platforms. It's frozen as a snapshot of 2017-era security Go programming. Additionally, as a learning project rather than a professionally edited publication, the code examples lack production-grade considerations: comprehensive error handling, security hardening against edge cases, performance optimization for large-scale operations, and thorough documentation. If you're building tools for enterprise security operations rather than quick assessment scripts, you'll need to supplement heavily with production Go practices and security-specific hardening techniques.

Verdict

Use if: You're a security professional comfortable with Python who needs to quickly ramp up on Go for building offensive tools, understanding Go-based malware, or contributing to Go security projects. The practical, hands-on approach will feel familiar if you learned from Black Hat Python, and the code examples provide immediate templates for common security tasks. It's ideal for pentesters who need to write custom tooling during engagements or security researchers exploring Go-based attack surfaces. Skip if: You need comprehensive, modern Go education with current best practices, or if you're building production-grade security platforms rather than assessment scripts. The incomplete chapters and dated patterns mean you'll hit walls quickly when dealing with contemporary Go development. Instead, invest in Black Hat Go (the completed book) for polished security-focused Go content, or combine official Go documentation with studying mature open-source security projects like Nuclei or Gosec for modern patterns. Also skip if you're completely new to programming—this assumes security domain knowledge and treats Go as a tool to amplify existing skills rather than teaching security fundamentals.

// ADD TO YOUR README
[![Featured on Starlog](https://starlog.is/api/badge/cybersecurity/parsiya-hacking-with-go.svg)](https://starlog.is/api/badge-click/cybersecurity/parsiya-hacking-with-go)