Skip to content

Instantly share code, notes, and snippets.

@tehmoon
tehmoon / script.sh
Last active December 12, 2017 20:27
Disk space size of each remote branch in git
for a in $(git branch -a | grep remotes | awk '{print $1}' | sed 's/remotes\/origin\///'); do echo -n ${a} -\ ; git clean -d -x -f > /dev/null 2>&1 ;git checkout ${a} > /dev/null 2>&1; du -hs -I .git .;done
@tehmoon
tehmoon / main.go
Created December 12, 2017 20:47
Handling errors in go
package main
import (
"github.com/tehmoon/errors"
"fmt"
)
// This example is similar to "github.com/pkg/errors" from Dave Cheney
// The idea is to declare simple error and have them chained using WrapErr
// so it's easy to have the complete chain of errors if needed.
@tehmoon
tehmoon / main.go
Last active December 31, 2017 15:24
Create and start http server in go
package main
import (
"github.com/pkg/errors"
"github.com/gorilla/mux"
"time"
"net/http"
"net"
"log"
"fmt"
@tehmoon
tehmoon / README.txt
Created January 24, 2018 01:43
DNS rebinding PoC
Check if the process is vulnerable to DNS rebinding attack.
First run the server after changing the code:
$> go server.go
Find the ip address of one of you iface and then add this line to /etc/hosts:
x.x.x.x blihblah
@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 March 1, 2018 02:16
Tests with socketpair in go
package main
import (
"io"
"syscall"
"os"
"errors"
)
func main() {
@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 April 10, 2018 01:39
Drop privileges Go
package main
// From https://play.golang.org/p/dXBizm4xl3
import (
"io"
"fmt"
"net"
"net/http"
"os"
@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"