Rednote
GuidebooksTerminalCode
  • Welcome!
  • Utility
    • General
    • Server
    • Transferring File
      • Main
      • Code
      • Miscellaneous
    • Reverse & Bind Shells
      • Havoc
    • Metasploit
    • Service
      • FTP (21)
      • SSH (22)
      • DNS (53)
      • HTTP/HTTPS (80-443)
      • SMTP (25-465-587)
      • POP3 (110-995)
      • IMAP (143-993)
      • MySQL (3306)
      • MSSQL (1433-2433)
      • SMB (139-445)
      • RDP (3389)
      • WinRM (5985-5986)
      • WMI (135)
      • LLMNR & NBT-NS (5355-137)
      • NFS (111-2049)
      • SNMP (161-162)
      • VNC (5900)
      • Rsync (873)
      • R-Service (512-513-514)
      • IPMI (623)
      • Oracle TNS (1521)
  • Pentesting Process
    • Information Gathering
      • Passive
      • Active
      • OSINT
    • Vulnerability
    • Web Attacks
      • GENERAL
      • Crawling/Spidering & Fuzzing
      • Information Disclosure
      • Command Injection
      • Unrestricted File Upload
      • File Inclusion/Path Traversal
      • Request Smuggling
      • Clickjacking
      • Web Cache Poisoning
      • Web Cache Deception
      • Insecure Deserialization
      • Prototype Pollution
      • OAuth 2.0
      • JWT
      • SQLi
        • sqlmap
      • NoSQLi
      • GraphQL
      • XSS
      • SSRF
      • XXE
      • IDOR
      • API
      • SSTI
      • CSRF
      • CORS
      • AJP
      • SSI
      • ESI
      • XSLT
      • Cloud
      • LLM Prompt Security
    • Software Attacks
      • Binary
      • Shellcode
      • AV Evasion & Obfuscation
    • Network Attacks
      • ARP Poisoning
      • Local DNS Cache Poisoning
      • Baby Local DoS
    • Crypto Attacks
      • Utility
      • RSA
      • DSA/DSS
      • PRNG
        • LGC
        • MT
        • LFSR
    • Misc Attacks
    • Social Engineering
    • Password Cracking
      • Wordlist
      • Offline
      • Online
    • Pivoting & Tunneling
    • Local Enumeration
      • Linux
      • Windows
    • Privilege Escalation
      • Linux
        • Linux Privilege Escalation with Groups
        • Linux Privilege Escalation with Library
      • Windows
        • Windows Privilege Escalation with Groups and Privileges
        • Windows Privilege Escalation with DLL Hijacking
    • Active Directory
      • Enumeration
      • Abuse ACL
      • Extract Hash & Password
      • Pass The Hash
      • Pass The Ticket
      • Overpass the Hash
      • Relay Attack
      • Password Spraying Attack
      • AS-REP Roasting
      • Kerberoasting
      • Silver Ticket
      • Golden Ticket
      • DC Synchronization
      • AD Certificates
      • Attacking Domain Trusts
    • Reports
      • Bug Bounty Report
    • CVE
      • Linux
      • Windows
    • OTHER
      • CMS
        • WordPress
        • Joomla
        • Drupal
      • Tomcat
      • Jenkins
      • Splunk
      • Web Service
      • Navigating Python Objects
      • JavaScript Deobfuscation
  • Extra
    • My Books
    • My Exploits
    • Compiled Binaries
Powered by GitBook
On this page
  • Info Commands
  • Terminal
  • Vim
  • Tmux
  • Search & Filter
  • Manipulation
  • Regex
  • Encoding
  • Extract
  • Cross-Compiling
  • Environment
  • TOR
  • GIT
  • Docker
  • Networks

Was this helpful?

  1. Utility

General

Utilities that can always be useful in different contexts.

Info Commands

apropos <STRING>
man <COMMAND>
help <COMMAND>
<COMMAND> ?
<COMMAND> /?

Terminal

Command
Description

CTRL + ALT + T

Open terminal window

CTRL + SHIFT + T

New tabs

CTRL + SHIFT + W

Close tabs

ALT + <NUM_TAB>

Move between the tabs

Command
Description

CTRL + L

Clear screen

CTRL + SHIFT + C

Copy

CTRL + SHIFT + V

Paste

HOME or CTRL + A

Start line

END or CTRL + E

End line

ALT + <--

Go back one word

ALT + -->

Go forward one word

CTRL + D

Delete one character forward

CTRL + W

Delete one word back

ALT + D

Delete one word forward

CTRL + U

Delete to the start of the line

CTRL + K

Delete to the end of the line

Command
Description

CTRL + C

Open terminal window

CTRL + Z jobs fg <N> bg <N>

Background process View background processes Resume <N> in the foreground Resume <N> in the background

CTRL + S

Pause output

CTRL + Q

Resume output

Vim

Command
Description

:q!

Quit without saving

:wq

Save and quit

:w !sudo tee %

Save and quit when you forgot sudo

i

Insert mode before the cursor

a

Insert mode after the cursor

A

Insert mode at the end of the line

o

Add line above and Insert mode

O

Add line below and Insert mode

v

Visual mode

V

Select line and Visual mode

x

Delete character under cursor

dd

Delete line

r

Change one character under cursor

R

Change mode

u

Undo

CTRL + r

Redo

y " <REG> y

Copy Specific registers (+ or * for outside of vim)

p " <REG> p

Paste Specific registers (+ or * for outside of vim)

Command
Description

gg

Jump to first line

G

Jump to last line

<N>G :<N>

Jump to line N

/<STRING>

Search string forward (move with n and N)

?<STRING>

Search string backwards (move with n and N)

*

Search for the word under the cursor (move with n and N)

:set number :set nonumber

Set number of lines

:set ic :set noic

Ignore case in search

:set is :set nois

Shows partial occurrences during a search

Command
Description

:s/<OLD>/<NEW> :s/<OLD>/<NEW>/g :#,#s/<OLD>/<NEW>/g :%s/<OLD>/<NEW>/g :%s/<OLD>/<NEW>/gc

Replace the first <OLD> with <NEW> in the line Replace every <OLD> with <NEW> in the line Replace every <OLD> with <NEW> between the lines #,# Replace every <OLD> with <NEW> in the file Replace every <OLD> with <NEW> in the file, asking for confirm

:w <FILE>

Write the selected part or all to the file <FILE>

:r <FILE> :r !<COMMAND>

Read the file <FILE> and inserts it Execute the command and inserts the output

:Explore [<DIR>]

Vim file explorer

Operator [Number] Movement

  • w - Word

  • $ - End of line

  • 0 - Start of line

  • e - End word

Tmux

Command
Description

tmux

New session

tmux ls

List sessions

tmux new -s <NAME>

New session <NAME>

tmux kill-ses -t <NAME>

Delete session <NAME>

tmux kill-session

Delete all session

CTRL + b d

Detach from session

tmux a -t <NAME>

Attach to a session <NAME>

Command
Description

CTRL + b c

New window

CTRL + b ,

Rename window

CTRL + b n

Next window

CTRL + b p

Previous window

CTRL + b <N>

Select window <N>

CTRL + b w

List and Navigate in window

Command
Description

CTRL + b %

Split screen Vertically

CTRL + b "

Split screen Horizontally

CTRL + b <ARROW>

Move between screen split

CTRL + b <SPACE>

Change layout of the split

CTRL + b CTRL + <ARROW>

Resize current split

Command
Description

CTRL + b [

Copy mode

CTRL + b ]

Paste

g

Go top line

G

Go bottom line

w

Forward one word

b

Backward one word

/

Search forward (move with N and n)

?

Search backward (move with N and n)

<SPACE>

Start selection

<ENTER>

Copy selection

Search & Filter

Search File

sudo updatedb
locate <FILE>
which <FILE>
find <PathStart> -type <f/d> -name <NAME> 2>/dev/null

Search String

grep -rHin "<STRING>" <PathStart>

Filter

<COMMAND> | grep <STRING>
Grep Options
Description

-i

Case Insensitive

-v

Not contain

-A <N>

Also show the two lines below

-B <N>

Also show the two lines above

-l

View File Name

-o

View Content

Search File

dir /s *<STRING>*
Get-ChildItem -Path 'C:\' -Include *<STRING>*, *<STRING>* -Recurse -ErrorAction Ignore

Search String

findstr /s /i <STRING> *.*     # contain
findstr /s /i /v <STRING> *.*  # not contain
Get-ChildItem -Path 'C:\' [-Include *<STRING>*, *<STRING>*] -Recurse -ErrorAction Ignore | Select-String -Pattern '<STRING_IN_FILE>' -ErrorAction Ignore

Filter

<COMMAND> | findstr <STRING>
<COMMAND> | select <ATTR1>,<ATTR2>

Manipulation

Command
Description

<COMMAND> | cut -f <N> -d "<SEP>"

Split the output by single character <SEP> and return field <N>

<COMMAND> | awk -F “<SEP>” '{print $<N1>, $<N2>}'

Split the output by characters <SEP> and return field <N1> and <N2>

<COMMAND> | tr "X" ”Y”

Replaces certain characters X with others Y.

<COMMAND> | sort -u

Sort and Unique

<COMMAND> | wc -w -l -c

Word/Line/Char count

<COMMAND> | rev

Reverse String

<COMMAND> | tac

Print in Reverse, starting from the last lines

cat << EOF > /PATH/TO/FILE
Row 1
...
Row N
EOF

Regex

Regex
Description

<START>.+?<END>

Between <START> and <END> including them

<START>(.+?)<END>

RBetween <START> and <END> excluding them

<START>([^<END>]*)

Between <START> and one of the characters in <END>

+

At least 1 character

*

Even without

Encoding

Only alphanumeric characters and + /. Multiples of 4 with padding =.

Encode

<COMMAND> | base64

Decode

<COMMAND> | base64 -d

0-9 and a-f. Each character has its own hex value in the ASCII table.

man ascii

Encode

<COMMAND> | xxd -p

Decode

<COMMAND> | xxd -p -r

Cyclically moves characters forward 13 positions.

Encode

<COMMAND> | tr 'A-Za-z' 'N-ZA-Mn-za-m'

Decode

<COMMAND> | tr 'A-Za-z' 'N-ZA-Mn-za-m'

Encode special characters into URLs.

<COMMAND> | jq -sRr @uri

Use:

echo -n
base64 -w 0

Extract

extract.sh
function extract {
  if [ -z "$1" ]; then
    echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
  else
    if [ -f $1 ]; then
      case $1 in
        *.tar.bz2)   tar xvjf $1    ;;
        *.tar.gz)    tar xvzf $1    ;;
        *.tar.xz)    tar xvJf $1    ;;
        *.lzma)      unlzma $1      ;;
        *.bz2)       bunzip2 $1     ;;
        *.rar)       unrar x -ad $1 ;;
        *.gz)        gunzip $1      ;;
        *.tar)       tar xvf $1     ;;
        *.tbz2)      tar xvjf $1    ;;
        *.tgz)       tar xvzf $1    ;;
        *.zip)       unzip $1       ;;
        *.Z)         uncompress $1  ;;
        *.7z)        7z x $1        ;;
        *.xz)        unxz $1        ;;
        *.exe)       cabextract $1  ;;
        *)           echo "extract: '$1' - unknown archive method" ;;
      esac
    else
      echo "$1 - file does not exist"
    fi
  fi
}
extract.sh <FILE>

Cross-Compiling

C

sudo apt-get install gcc 
apt-get install gcc-multilib 
apt-get install g++-multilib
gcc <FILE.c> -o <NEW_NAME>  # 64 bit
gcc <FILE.c> -m32 -o <NEW-NAME>  # 32 bit
chmod +x <NEW_NAME>

Python

python3 <FILE.py>

SO

gcc -fPIC -shared -o <LIB_NAME.so> <FILE.c>

C

sudo apt-get install mingw-w64
x86_64-w64-mingw32-gcc <FILE.c> -o <NEW_NAME>   # 64 bit
i686-w64-mingw32-gcc <FILE.c> -o <NEW_NAME>   # 32 bit

Python

pip installa pyinstaller
python pyinstaller.py --onefile <FILE.py>

DLL

x86_64-w64-mingw32-gcc -shared <FILE.c> -o <NEW_NAME.dll> [-Wl,--out-implib,<NEW_NAME.a>] # 64 bit
i686-w64-mingw32-gcc -shared <FILE.c> -o <NEW_NAME.dll> [-Wl,--out-implib,<NEW_NAME.a>] # 32 bit

Environment

python3 -m venv myEnv
source myEnv/bin/activate
pip3 install NAME_PACKAGE
pip3 install -r requirements.txt
deactivate
rm -rf nome_ambiente
source ~/miniconda3/bin/activate
conda create -n myEnv python=3.11
conda activate myEnv
conda deactivate
conda install NAME_PACKAGE
conda install -c conda-forge NAME_PACKAGE
conda list
conda remove NAME_PACKAGE 
conda env export > environment.yml
conda env create -f environment.yml
conda remove -n myEnv --all 

TOR

Start service TOR

sudo service tor start
sudo service tor stop
sudo service tor restart

Set ProxyChains

vim /etc/proxychains4.conf
vim /etc/proxychains.conf
# at the end
socks4 127.0.0.1 9050
socks5 127.0.0.1 9050

Use command over TOR

proxychains <COMMAND>
Tools
Details

Routing all your system network traffic through the TOR network. sudo zerotrace --start sudo zerotrace --ip (Show current Tor IP and location) sudo zerotrace --stop sudo zerotrace --new-ip sudo zerotrace --auto --time 300 (change IP every 5 minutes)

GIT

Description
Command

Access by token

Create tokens in Settings/Developer > Settings/Personal > access > token Insert token git clone https://<USERNAME>:<TOKEN>@github.com/<USERNAME>/<REPOSITORY> Or git remote set-url origin https://<USERNAME>:<TOKEN>@github.com/<USERNAME>/<REPOSITORY>

Downloading GitHub repositories

git clone <LINK_REPOSITORY_GITHUB>

Download repository changes

git pull origin main

Loading repository changes

[git add -A] git commit -m "<DESCRIPTION>" git push origin [main/master]

With SSH

GIT_SSH_COMMAND='ssh [options]' [git command] GIT_SSH_COMMAND='ssh [options]' git clone <USER>@<IP>:/<REPO>

ex. GIT_SSH_COMMAND='ssh -i id_rsa -p 43022' git clone git@192.168.213.125:/git-server GIT_SSH_COMMAND='ssh -i /id_rsa -p 43022' git push origin master

Description
Command

See commit

git log

See the differences in commit

git show <COMMIT_ID> git show --all

List of branch

git branch

Switch to another branch

git switch <NAME_BRANCH> git checkout <NAME_BRANCH>

Read single git files in objects/X/number

git cat-file -p Xnumber

Docker

sudo systemctl start docker
sudo systemctl stop docker
Command
Description

docker build -t <name> .

docker --version

Docker version

docker search <STRING>

Search in the Docker Hub

docker login <DOMAIN>/<IMG_NAME>

It may require authentication if you are pulling unofficial images, so you need to authenticate for that domain and image first. See a domain's registry list at <DOMAIN>/v2/_catalog.

docker pull <IMG_NAME>[:<VERSION>]

Download image from Docker Hub

docker inspect <IMG_NAME>

View information about the Docker image.

docker image

View possible commands for managing Docker images, such as ls

docker volume

View possible commands for managing Docker volumes, such as ls

docker volume create <VOLUME_NAME>

Create a volume and give it a name. They are used to store data persistently.

docker network

View possible commands for managing Docker network, such as ls

docker network create (…) <NETWORK_NAME>

Creating a network. It is important to specify: --driver=bridge : Specify the type of driver --subnet=<ip/mask> : Specify the subnet to be used by the container (ex. 172.18. 0.0/16) --gateway=<ip/mask> : Specify the gateway to communicate outside the container (ex. typically 172.18. 0.1)

docker run <IMG_NAME>

Runs a container from a specified Docker image. --name=<NAME> : Give a name to the container. -d : Run the container in the background. -p <H_PORT>:<C_PORT> : Perform port mapping. connect my H port to the C container port. -v <VOLUME_NAME>:<C_PATH> : Use a volume. Associate a created volume with a container PATH. -v <H_PATH>:<C_PATH> : Use a volume. Associate a PATH on the HOST system with a container PATH. --network=<NETWORK_NAME> : Start the container on a previously created network -h <HOSTNAME> : Specify hostname

docker run -it <IMG_NAME> bash

Start container but in interactive mode, connect to the container terminal. CTRL+P and CTRL+Q : Exit from the container while leaving it running.

docker attach <ID>

Resume interaction with a container.

docker exec -it <ID_CONTAINER> bash

Runs a new interaction process with a container's terminal (also used to reconnect after exiting, like attach).

docker ps

Show running containers. -a : Also show stopped containers (if you want to remove them).

docker top <ID_CONTAINER>

View the processes running inside a container.

docker logs <ID_CONTAINER>

View logs of a container.

docker stat <ID_CONTAINER>

Provides real-time information about the resources used by a container.

docker stop <ID_CONTAINER>

Stops a running container.

docker start <ID_CONTAINER>

Run a stopped container.

docker rm <ID_CONTAINER>

Remove and delete a container.

docker container prune

Remove all stopped containers.

docker history <IMG_NAME>

View history of operations related to a Docker image.

docker system prune

Complete cleaning of everything, be careful! (does not delete images)

docker save -o <NAME>.tar <IMG_NAME>

Save a Docker image, including all its layers and metadata.

Command
Description

docker compose build

Builds or rebuilds Docker service images in docker-compose.yml. Required only if changes are made.

docker compose up

Creates and starts the containers listed in the docker-compose.yml file along with a custom network. -d : Runs the container in the background.

docker compose start

Start the service containers defined in the docker-compose.yml file.

docker compose stop

Stop all containers listed in the docker-compose.yml file.

docker compose down

Stop and delete all containers listed in the docker-compose.yml file and the created network.

docker compose logs [<SERVICE_NAME>]

Display logs of started services. -f : Follow. Listen and display logs continuously.

docker compose ps

View the status of Docker services managed by Docker Compose.

With ls -q it prints only the IDs.

Networks

Layer 2 Data Link : MAC address, Switch/bridge (Within Subnets) Layer 3 Network : IP address, Router (Between Networks) Layer 4 Transport : TCP/UDP

Enable/Disable interface

sudo ip link set dev <INTERFACE> up sudo ip link set dev <INTERFACE> down

Riname Interface

ip link set dev <OLD> name <NEW>

Add/Remove IP

ip addr add <IP>/<MASK> dev <INTERFACE> ip addr del <IP>/<MASK> dev <INTERFACE> ip addr change <IP>/<MASK> dev <INTERFACE> ip addr flush dev <INTERFACE>

Add/Remove Route

route -n ip route show ip route add <REMOTENET_IP>/<MASK> via <GATEWAY> ip route add <REMOTENET_IP>/<MASK> dev <INTERFACE> ip route del <REMOTENET_IP>/<MASK> via <GATEWAY> ip route del <REMOTENET_IP>/<MASK> dev <INTERFACE>

Clear ARP

arp ip neigh show ip neigh del <IP> dev <INTERFACE> ip neigh flush dev <INTERFACE>

DHCP

sudo dhclient <INTERFACE> (request IP from DHCP)

Last updated 17 hours ago

Was this helpful?

Manages single containere.

Orchestration of multi-container applications.

dockerfile
docker-compose.yml
ZeroTrace
regex101: build, test, and debug regexregex101
Logo