Skip to content

Instantly share code, notes, and snippets.

@tehmoon
tehmoon / flags.go
Last active April 26, 2018 00:54
Bootstrap go
package main
import (
"flag"
"fmt"
"os"
)
type Flags struct {
}
@tehmoon
tehmoon / git.md
Last active August 22, 2018 19:40
Git/github stuff

extract the whole forked branch from merge commit:

git log @~1..@^2

Get all the tags that contain the commit:

git tag --contain 
@tehmoon
tehmoon / compiling_on_alpine.md
Last active September 9, 2018 17:57
Go stuff

This is specific to Alpine using the go apk.

Compiling go binaries in same arch:

go build -buildmode exe -ldflags '-linkmode external -extldflags "-static"' .

Compiling go binaries in other arch:

@tehmoon
tehmoon / client.go
Last active April 15, 2018 01:31
Reverse shell client/server in go!
package main
import (
"io"
"os"
"net/http"
"net/http/httputil"
"net"
"golang.org/x/crypto/ssh/terminal"
@tehmoon
tehmoon / main.go
Created April 11, 2018 01:45
Simple https server in go with self-signed certificate
package main
import (
"net/http"
"fmt"
"io"
"os"
"log"
"crypto/x509"
"crypto/x509/pkix"
@tehmoon
tehmoon / main.go
Created March 20, 2018 01:29
Reallocate stdin after injecting file/buffer to cmd
package main
import (
"os"
"os/exec"
"io"
"strings"
"github.com/kr/pty"
)
@tehmoon
tehmoon / format0.md
Last active March 30, 2018 16:56
protostar exploits write ups

Format0 introduces format string vulnerabilities.

The vuln relies on the fact that user input is not sanitized and can be used as format string fed into the printf family.

In this example sprintf() is used. It takes at least 2 arguments, the destination's string and the source's string. The idea is to do a classic buffer overflow and write 0xdeadbeef to target.

Here's the following exploit:

@tehmoon
tehmoon / main.go
Last active March 1, 2018 02:16
Tests with socketpair in go
package main
import (
"io"
"syscall"
"os"
"errors"
)
func main() {
@tehmoon
tehmoon / .zshrc
Created February 15, 2018 01:23
Simple basic zsh config
export WORDCHARS='*?_[]~=&;!#$%^(){}'
setopt HIST_IGNORE_SPACE
@tehmoon
tehmoon / main.go
Last active April 27, 2018 18:43
Using Go templating engine with JSON
package main
import (
"encoding/json"
"os"
"text/template"
)
var data = map[string]interface{}{
"blih": true,