First public release
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
commands.raw
|
||||||
|
commands.state
|
||||||
90
README.md
Normal file
90
README.md
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
# Fast Memo Shell
|
||||||
|
|
||||||
|
'Fast Memo Shell' is a tool designed to boost productivity when using a ZSH shell.
|
||||||
|
|
||||||
|
It allows users to enhance their current shell with a customized list of commands by using the Alt+L key combination or by typing the command 'f'.
|
||||||
|
|
||||||
|
## How to install
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
FMS (Fast Memo Shell) a ZSH script based on three tools: [skim](https://github.com/lotabout/skim), [yq-go](https://github.com/mikefarah/yq) and [bat](https://github.com/sharkdp/bat).
|
||||||
|
|
||||||
|
All of them should be installed and available in your PATH with the commands 'sk', 'yq', and 'bat'.
|
||||||
|
|
||||||
|
For example, you can use Nix to install them:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
nix-env -i skim bat yq-go
|
||||||
|
```
|
||||||
|
|
||||||
|
Or use Parabola GNU/Linux-libre binaries (a compatible method for a Kali Linux VM out of the box):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
wget https://www.parabola.nu/packages/extra/x86_64/skim/download/ -O /tmp/skim.tar.zst
|
||||||
|
sudo tar --zstd -xvf /tmp/skim.tar.zst -C /usr/local/bin --strip-components=2 usr/bin/sk
|
||||||
|
|
||||||
|
wget https://www.parabola.nu/packages/extra/x86_64/go-yq/download/ -O /tmp/yq.tar.zst
|
||||||
|
sudo tar --zstd -xvf /tmp/yq.tar.zst -C /usr/local/bin --strip-components=2 usr/bin/yq
|
||||||
|
|
||||||
|
wget https://www.parabola.nu/packages/extra/x86_64/bat/download/ -O /tmp/bat.tar.zst
|
||||||
|
sudo tar --zstd -xvf /tmp/bat.tar.zst -C /usr/local/bin --strip-components=2 usr/bin/bat
|
||||||
|
```
|
||||||
|
|
||||||
|
### FMS
|
||||||
|
|
||||||
|
You should download the latest version and extract it in your home directory:
|
||||||
|
```sh
|
||||||
|
wget "https://git.hackade.org/ben/fms/archive/main.tar.gz" -O fms.tar.gz
|
||||||
|
tar zxvf fms.tar.gz -C ~
|
||||||
|
```
|
||||||
|
|
||||||
|
Then add the following line to your ZSH configuration file:
|
||||||
|
```sh
|
||||||
|
echo 'source ~/fms/integration.zsh' >> ~/.zshrc
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to configure
|
||||||
|
|
||||||
|
Each command is stored in the file commands.yaml. To add new commands or modify existing ones, edit commands.yaml with the following fields:
|
||||||
|
```yaml
|
||||||
|
- cmd: <the command to insert in your prompt>
|
||||||
|
lang: <the language of your command, sh, ps1>
|
||||||
|
tags: <a tag reprenting a group of commands>
|
||||||
|
desc: <the description of the command>
|
||||||
|
```
|
||||||
|
|
||||||
|
The tags and desc fields are only used to provide information to easily find your command when you search for it.
|
||||||
|
The lang field is used for syntax highlighting.
|
||||||
|
|
||||||
|
Here is an example of an entry:
|
||||||
|
```yaml
|
||||||
|
- cmd: find / -perm -u=s -type f 2>/dev/null
|
||||||
|
lang: sh
|
||||||
|
tags: security
|
||||||
|
desc: Search for executables with SUID permission
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, to update the database and apply the changes, run the following commands:
|
||||||
|
```sh
|
||||||
|
~/fms/fms.sh update
|
||||||
|
```
|
||||||
|
|
||||||
|
Fast Memo Shell comes with a list of commands as examples, but you are highly encouraged to update it according to your needs.
|
||||||
|
|
||||||
|
## How to use
|
||||||
|
|
||||||
|
To launch Fast Memo Shell, there are two possibilities: press Alt+L or enter the command 'f'.
|
||||||
|
|
||||||
|
To select the right command, you can:
|
||||||
|
|
||||||
|
* Enter a string to find your command.
|
||||||
|
* Use the up and down arrow keys.
|
||||||
|
* Enter '<string>' to display only the commands containing this substring.
|
||||||
|
* Once you have the desired command selected, just press Enter.
|
||||||
|
|
||||||
|
Fast Memo Shell can also display all available manuals. To switch between both modes, use Shift+Left and Shift+Right arrows."
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|

|
||||||
130
commands.yaml
Normal file
130
commands.yaml
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
title: Commands for Fast Memo Shell
|
||||||
|
commands:
|
||||||
|
- cmd: nmap -p- --min-rate 10000 192.168.56.30 -Pn
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: Fast scan all ports
|
||||||
|
- cmd: nmap -p 53,88,135,139,389,445,464,593,636,3268,3269,5985,5986,9389,49668,49670,49671,49673,49674,49687,49750 -sCV 192.168.56.30 -Pn
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: Scan with services and versions
|
||||||
|
- cmd: nmap -p80,443 --script http-title 192.168.218.0/24 --open -Pn
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: TCP scan HTTP/S and get page titles
|
||||||
|
- cmd: find /usr/share/nmap/scripts/ -type f | sk --preview 'bat -l lua --color=always {}'
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: search a NSE script
|
||||||
|
- cmd: gobuster dir -u http://<IP|HOST>/ -w /usr/share/wordlists/dirb/common.txt -t 5
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: enumerate pages on webserver
|
||||||
|
- cmd: feroxbuster --url http://<IP|Host>/
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: enumerate pages on webserver
|
||||||
|
- cmd: feroxbuster --url http://<IP|Host>/ -x pdf,php,txt
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: enumerate pages on webserver (check for pdf, php, txt files)
|
||||||
|
- cmd: smbclient --no-pass -L //192.168.194.10
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: list unprotected SMB shares
|
||||||
|
- cmd: snmpwalk -c public -v1 -t 10 192.168.50.151
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: SNMP enumeration
|
||||||
|
- cmd: rlwrap -cAr nc -lnvp 443
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: Bind netcat for reverse shell with completion
|
||||||
|
- cmd: impacket-psexec hackade.org/ben:fakepass@192.168.99.80
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: Using psexec to get an interactive shell
|
||||||
|
- cmd: systeminfo
|
||||||
|
lang: ps1
|
||||||
|
tags: Pentest
|
||||||
|
desc: Information about the operating system and architecture
|
||||||
|
- cmd: ipconfig /all
|
||||||
|
lang: ps1
|
||||||
|
tags: Pentest
|
||||||
|
desc: Information about the network configuration
|
||||||
|
- cmd: route print
|
||||||
|
lang: ps1
|
||||||
|
tags: Pentest
|
||||||
|
desc: Routing table
|
||||||
|
- cmd: exiftool -a -u old.pdf
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest
|
||||||
|
desc: Print all metadata from a file
|
||||||
|
- cmd: mitmproxy --set console_mouse=false --set anticache -p 8080
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: launch mitmproxy with options
|
||||||
|
- cmd: find / -xdev -type f \( -exec grep -xq "{}" /var/lib/dpkg/info/*.list \; -or -print \)
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: search for files not owned by any package
|
||||||
|
- cmd: sudo -l
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: Inspecting current user's sudo permissions
|
||||||
|
- cmd: socat -ddd TCP-LISTEN:2345,fork TCP:10.4.50.215:5432
|
||||||
|
lang: sh
|
||||||
|
tags: Pentest Linux
|
||||||
|
desc: Running the Socat port forward command.
|
||||||
|
- cmd: sudo lsof -nP -i tcp
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: list process listing tcp socket
|
||||||
|
- cmd: sudo lsof -u 1000
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: list files used by UID 1000
|
||||||
|
- cmd: sudo lsof -p 2658
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: list files used by PID 2658
|
||||||
|
- cmd: mysql -u root -p'root' -h 192.168.50.16 -P 3306
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: connect to mysql
|
||||||
|
- cmd: sudo setcap 'cap_net_bind_service=+ep' /usr/bin/python3.11
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: Allow bind for port < 1024, set capability CAP_NET_BIND_SERVICE
|
||||||
|
- cmd: vim --clean
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: launch vim without options and config files
|
||||||
|
- cmd: curl -s --head 'https://github.com/lotabout/skim/releases/latest' | grep '^location' | rev | cut -d'/' -f 1 | rev | tr -d '\r'
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: check the last tag from a github project
|
||||||
|
- cmd: grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: grep ip address
|
||||||
|
- cmd: grep -E -o "[[:alnum:]]{30,34}"
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: grep NTLM hash
|
||||||
|
- cmd: Set-WinUserLanguageList -Force 'fr-FR'
|
||||||
|
lang: ps1
|
||||||
|
tags: powershell winsetup
|
||||||
|
desc: change Keyboard Layout in French
|
||||||
|
- cmd: tail --pid=$(pgrep procname) -f /dev/null && ntf send finished
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: wait and send message when a process is fish
|
||||||
|
- cmd: cat ips | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sort | sponge ips
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: extract ips from file
|
||||||
|
- cmd: ping -M do -s <mtu-value> 192.168.1.1
|
||||||
|
lang: sh
|
||||||
|
tags: Linux
|
||||||
|
desc: check for the correct MTU value
|
||||||
92
fms.sh
Executable file
92
fms.sh
Executable file
@@ -0,0 +1,92 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
SCRIPT=$(readlink -f "$0")
|
||||||
|
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||||
|
cd "$SCRIPTPATH" || exit
|
||||||
|
|
||||||
|
for c in sk bat yq; do
|
||||||
|
if ! command -v ${c} &>/dev/null; then
|
||||||
|
echo "$command ${c} could not be found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
SWITCH_MENU=$(mktemp)
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
touch commands.state
|
||||||
|
if [[ "$(stat -c%Y commands.yaml)" != "$(cat commands.state)" ]] || [[ $1 == "force" ]]; then
|
||||||
|
cat /dev/null >commands.raw
|
||||||
|
i=1
|
||||||
|
#set -eux
|
||||||
|
while read -r line; do
|
||||||
|
cmd=$(echo "${line}" | yq -r .cmd)
|
||||||
|
lang=$(echo "${line}" | yq -r .lang)
|
||||||
|
tags=$(echo "${line}" | yq -r .tags)
|
||||||
|
desc=$(echo "${line}" | yq -r .desc)
|
||||||
|
if [[ $cmd == "null" ]] || [[ $lang == "null" ]] || [[ $tags == "null" ]] || [[ $desc == "null" ]]; then
|
||||||
|
echo "Error on line: ${line}"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo "${cmd} # [${tags} ${lang} ${i}] ${desc}" | tee -a commands.tmp.${lang} >/dev/null
|
||||||
|
i=$(($i + 1))
|
||||||
|
done < <(cat commands.yaml | yq e -o=j -I=0 .commands[])
|
||||||
|
for filename in $(ls -t commands.tmp.*); do
|
||||||
|
lang=$(echo ${filename} | rev | cut -d'.' -f1 | rev)
|
||||||
|
cat ${filename} | bat --color=always -l ${lang} -pp >>commands.raw
|
||||||
|
rm -f ${filename}
|
||||||
|
done
|
||||||
|
stat -c%Y commands.yaml >commands.state
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function notes() {
|
||||||
|
update
|
||||||
|
echo -n 0 >${SWITCH_MENU}
|
||||||
|
unset RES
|
||||||
|
RES=$(cat commands.raw | sk --reverse --ansi --inline-info \
|
||||||
|
--bind "shift-left:execute-silent(echo -n 1 > ${SWITCH_MENU})+abort" \
|
||||||
|
--bind "shift-right:execute-silent(echo -n 1 > ${SWITCH_MENU})+abort")
|
||||||
|
SWITCH=$(cat ${SWITCH_MENU})
|
||||||
|
if [[ ${SWITCH} -eq 1 ]]; then
|
||||||
|
manuals
|
||||||
|
fi
|
||||||
|
if [[ ! -z "${RES}" ]]; then
|
||||||
|
echo -n ${RES} | grep -o ".*#" | sed 's/ #$//g'
|
||||||
|
fi
|
||||||
|
rm -f ${SWITCH_MENU}
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function manuals() {
|
||||||
|
echo -n 0 >${SWITCH_MENU}
|
||||||
|
unset RES
|
||||||
|
RES=$(man -k . | bat --color=always -pp - | sk --reverse --ansi --inline-info --keep-right --print-query \
|
||||||
|
--bind "shift-left:execute-silent(echo -n 1 > ${SWITCH_MENU})+abort" \
|
||||||
|
--bind "shift-right:execute-silent(echo -n 1 > ${SWITCH_MENU})+abort")
|
||||||
|
SWITCH=$(cat ${SWITCH_MENU})
|
||||||
|
if [[ ${SWITCH} -eq 1 ]]; then
|
||||||
|
notes
|
||||||
|
fi
|
||||||
|
if [[ ! -z "${RES}" ]]; then
|
||||||
|
echo -n man $(echo ${RES} | cut -d' ' -f1)
|
||||||
|
fi
|
||||||
|
rm -f ${SWITCH_MENU}
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
function copy() {
|
||||||
|
cat "${COPY_SRC}" >"${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _usage() {
|
||||||
|
echo "Invalid command. Usage: ${0} <${actions[@]}> <context>"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
actions=$(declare -F | grep -v _ | cut -d' ' -f3 | xargs)
|
||||||
|
if [[ ! " ${actions[*]} " =~ [[:space:]]${1}[[:space:]] ]]; then
|
||||||
|
_usage
|
||||||
|
else
|
||||||
|
${1} ${2} ${3}
|
||||||
|
fi
|
||||||
27
integration.zsh
Normal file
27
integration.zsh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
function _notes_cmds {
|
||||||
|
FILE_OUTPUT=$(mktemp)
|
||||||
|
~/fms/fms.sh notes >${FILE_OUTPUT}
|
||||||
|
autoload -U edit-command-line
|
||||||
|
zle -N edit-command-line
|
||||||
|
export COPY_SRC=${FILE_OUTPUT}
|
||||||
|
export EDITOR="${HOME}/fms/fms.sh copy"
|
||||||
|
export VISUAL="${HOME}/fms/fms.sh copy"
|
||||||
|
edit-command-line
|
||||||
|
zle -D edit-command-line
|
||||||
|
rm -f $FILE_OUTPUT
|
||||||
|
}
|
||||||
|
zle -N _notes_cmds
|
||||||
|
bindkey '^[l' _notes_cmds
|
||||||
|
|
||||||
|
function _f {
|
||||||
|
if [[ $PREPROMPT_TOFILL -eq 1 ]]; then
|
||||||
|
CMD=$(~/fms/fms.sh notes)
|
||||||
|
LBUFFER="${CMD} $LBUFFER"
|
||||||
|
unset PREPROMPT_TOFILL
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function f {
|
||||||
|
export PREPROMPT_TOFILL=1
|
||||||
|
zle -N zle-line-init _f
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user