Shell Scripting

From Kicksecure
Jump to navigation Jump to search
Documentation Previous page: Stdisplay Index page: Documentation Next page: Essential Host Security Shell Scripting

How to detect if a Command contains Shell Scripting

Introduction

[edit]

Warning: Copying and pasting commands from the Internet and executing them can lead to system compromise. This risk is higher when commands contain shell scripting and when the copied text contains hidden characters such as malicious Unicode.

See also:

How to detect if a Command contains Shell Scripting

[edit]

Non-exhaustive list if common sh / bash scripting features.

  • Any command that includes shell scripting such as
    • Pipes: |; |&;
    • Command chaining / separators: &&; ||; ;; a newline between commands;
    • Background execution: &;
    • Redirection (input/output): <; >; >>; <<; <>;
    • Redirection (file descriptors): 0<; 1>; 2>; 2>>; &>; 2>&1; 1>&2; <&; >&;
    • Here-doc and here-string: <<EOF; <<-EOF; <<<;
    • Subshell / grouping: ( ); { };
    • Process substitution: <(; >(;
    • Command substitution: $(...); `...`;
    • Variable expansion: $NAME; ${NAME};
    • Parameter expansion operators: ${NAME:-...}; ${NAME:=...}; ${NAME:+...}; ${NAME:?...}; ${NAME#...}; ${NAME##...}; ${NAME%...}; ${NAME%%...};
    • Arithmetic: $((...)); ((...)); let;
    • Test / conditions: [ ]; [[ ]]; test;
    • Conditional keywords: if; then; elif; else; fi;
    • Case statements: case; in; esac;
    • Loops: for; select; while; until; do; done;
    • Functions: function; name() { ...; };
    • Common shell builtins that execute or control execution: eval; exec; source; .; trap;
    • Environment / variable control: NAME=value (variable assignment); export; unset; readonly; local; declare; typeset;
    • Flow control: break; continue; return; exit; shift; getopts;
    • Globbing and expansions: *; ?; [...]; {a,b}; ~;

Documentation Previous page: Stdisplay Index page: Documentation Next page: Essential Host Security

Notification image

We believe security software like Kicksecure needs to remain Open Source and independent. Would you help sustain and grow the project? Learn more about our 14 year success story and maybe DONATE!