Shell Commands

Snr comes with many commands, mostly to help with not having to exit the shell to run a system shell command and then running snr again. A full list of commands can be retrieved using help, here we list them all, alongside examples to help you understand them better.

Note that here, the command results are commented out to avoid highlighting issues.

Filesystem Commands

pwd

Prints the current working directory:

pwd
# /home/user/workspace

chdir

Changes the current working directory:

chdir /home/user/workspace/snr
pwd
# /home/user/workspace/snr

list

Lists files and directories. By default lists the content of the current working directory:

list
# file1
# file2
# dir1/
# dir2/

Also accepts a directory to list the content of:

list /home/user/workspace/my_payloads
# file12
# file13

read

Reads the content of a file:

read /home/user/workspace/data.txt
# Sample data inside data.txt

checksum

Generates checksum of a file. Syntax:

checksum <algorithm> <file>

List of valid algorithms:

  • blake2b

  • md5

  • sha1

  • sha224

  • sha256

  • sha384

  • sha512

For example:

checksum md5 test.txt
# d8e8fca2dc0f896fd7cb4cb0031ba249

Variable Commands

unset

Removes a variable, it’s an alternative syntax to set variable_name which does the same:

unset my_var

set

See it as the variable manager, it allows you to set variables:

set my_var my_value

Set also has a special ability, it can tie the output of a command to a variable:

set !my_var checksum md5 test.txt

Note that this syntax is only used by set and no other commands support it.

But also it can remove variables:

set my_var

You can also list all variables with it:

set

Payload Commands

use

The use command allows you to load and unload payloads.

To load a payload, pass its path to use:

use misc/run_command
# [+] Payload loaded

It can also be used to unload a payload:

use

You may also reload a payload with just loading the same payload again.

generate

Generates the selected payload onto the device or file you pass to it.

generate /dev/sdb

Miscellaneous Commands

clear

Clears the screen.

clear

echo

Prints back what you give it. Mostly useful for getting value of variables.

echo Snr rocks!
# Snr rocks!
set my_var Snr rocks!
echo $my_var
# Snr rocks!

exit

Used to exit the shell, optionally printing whatever you want it to print.

exit

The above example prints nothing.

help

It can give you a lot of information.

To get a list of all commands:

help

Help on a specific command:

help checksum

Help on a specific variable (assuming we have loaded the misc/run_command payload):

help COMMANDS

Help on the loaded payload (again assuming we have loaded the misc/run_command payload):

help payload
# Payload path: misc/run_command
# Input: COMMANDS
# Authors: GlobularOne
# License: gpl-3.0
# Dependencies: No dependencies specified
# Run a command or executable on boot, the executable must exist on the host filesystem.
# If you want to run an executable that is locally available. Use run_executable.
# It finds the executable and copies it onto the host filesystem.

info

Alternative syntax for help payload (again assuming we have loaded the misc/run_command payload):

info
# Payload path: misc/run_command
# Input: COMMANDS
# Authors: GlobularOne
# License: gpl-3.0
# Dependencies: No dependencies specified
# Run a command or executable on boot, the executable must exist on the host filesystem.
# If you want to run an executable that is locally available. Use run_executable.
# It finds the executable and copies it onto the host filesystem.

Added in version 0.1.0.

pdb

Drop to a debug shell, useful for debugging if something is not behaving correctly. If you are getting an error, instead pass –debug to snr when running, which drops to a debug shell when encountering an error.

pdb
# ...

Added in version 1.0.0.

reload

Reloads the shell, note that no state will be saved (variables, loaded payload.) This also loads any active configuration changes.

reload
# [!] Reloading shell, shell state will not be saved!