Hey, amazing hackers welcome to my experiment zone.

In this blog, I will show you how to install and configure tomnomnom's gf tool. So, let's get started.

What is gf?

A wrapper around grep to avoid typing common patterns. It's really easy to mess up when typing all of that, and it can be hard to know if you haven't got any results because there are non to find, or because you screwed up writing the pattern or chose the wrong flags.

This tool helps audit code bases or just generally deal with large amounts of data.

First, make sure you have go language installed.

To install go language just type if you are on Debian(Kali, Ubuntu) based distro:

sudo apt install golang

If you are on arch (Manjaro, BlackArch) based distro then :

sudo pacman -S go

After, you have installed go language now set your GOPATH

export PATH=$PATH:$(go env GOPATH)/bin

Now, it's time to install gf tool. Just copy and paste the command:

go install github.com/tomnomnom/gf@latest

As we added go to our path, we can use tools now without copying the binary file to /usr/bin.

Now it's time for gf patterns

create a .gf directory

mkdir ~/.gf

clone the 1ndianl33t (Shiv Chouhan)'s Gf-Patterns git repository:

git clone https://github.com/1ndianl33t/Gf-Patterns.git

Now go inside the GF-Patterns folder and copy all files to ~/.gf folder

cd Gf-Patterns

cp *.json ~/.gf

and also copy the pre-done patterns from tomnomnom

cd ~/go/pkg/mod/github.com/tomnomnom/gf*/examples

cp *.json ~/.gf

If you think that's not enough then there is a collection of gf-patterns here Gf-Patterns-Collection

And it's done now you will be able to use gf command but wait we need to configure gf completion that will give suggestions when you can hit 'tab' and it'll show you what your options are:

So, let's do it.

First of all, check which shell you are using (Kali-Linux by default uses ZSH). There are three different shell auto-completion script available for gf tool namely Bash, ZSH, and Fish.

Go one directory back using

cd ..

If you use bash, then copy all the content of gf-completion.bash file and paste it to your ~/.bashrc file and source the ~/.bashrc file for autocompletion.

For bash:

cat gf-completion.bash >> ~/.bashrc 

source ~/.bashrc

If you use another shell like ZSH or Fish shell then do the same with their respective file extensions

For ZSH:

cat gf-completion.zsh >> ~/.zshrc

source ~/.zshrc

For Fish:

cat gf-completion.fish >> ~/.config/fish/config.fish

exec fish

Note: if you're using oh-my-zsh or oh-my-fish or similar you may find that gf is an alias for git fetch. You can either alias the gf binary to something else, or unalias gf to remove the git fetch alias.

And that's it now you can use gf tool with its full potential.

Thanks for coming here say hello if you like it, Goodbye.