# Random Commands

```
grep -oE "flagF{.*}"

       -o, --only-matching
              Print  only  the matched (non-empty) parts of a matching line, with each such part on a separate output line.

       -E, --extended-regexp
              Interpret PATTERNS as extended regular expressions (EREs, see below).
```

```
# bc: basic calculator

$ echo "scale=2 ; $TOTAL_DST / $TOTAL_FILES" | bc

$ bc <<<"scale=2; $var1 / $var2"

$ echo "12+5" | bc
17
```

```
# jq for json manipulation

$ TOTAL_FILES=$(cat incidents.json | jq '.[][] .file_hash' | tr -d '"' | sort | uniq -c | wc -l)
$ TOTAL_DST=$(cat incidents.json | jq '.[][] .ticket_id' | tr -d '"' | sort | uniq -c | wc -l)
```

```
 lsattr - list existing file attributes
$ lsattr /bin/nsh
----i---------e---- /bin/nsh

chattr - change attribute
$ sudo chattr -i /bin/nsh

$ lsattr /bin/nsh
--------------e---- /bin/nsh
```

```
# shows all running processes and the command lines used to startup the processes 
ps -eafw
```

```
# ooked up google bots @https://support.google.com/webmasters/answer/1061943?hl=en
# chose user agent "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" to pretend to be google

$ curl -s --user-agent "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" http://2018shell.picoctf.com:46162/flag | grep -oE "picoCTF{.*}"
picoCTF{s3cr3t_ag3nt_m4n_ac87e6a7}
```

```
$ readelf -h be-quick-or-be-dead-1 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x4005a0
  Start of program headers:          64 (bytes into file)
  Start of section headers:          7312 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         9
  Size of section headers:           64 (bytes)
  Number of section headers:         31
  Section header string table index: 28

```

```
EOG(1)                               General Commands Manual                              EOG(1)

NAME
       eog - a GNOME image viewer

SYNOPSIS
       eog [options] files...
```

```
paste - merge lines of files

$ cat scores | sort | uniq -c | sort -nk1,1 | awk '{print $2}' | paste -sd,
4730,4755,4780,4785,4855,4864,4879,4884,4905,4930,4994,5003,5030,5054,5094,5124
```

```
nl - number lines of files
$ searchsploit ProFtpd 1.3.5 | nl | sed -n '4,6p'
     4  ProFTPd 1.3.5 - 'mod_copy' Command Execution (Metasploit)                               | linux/remote/37262.rb
     5  ProFTPd 1.3.5 - 'mod_copy' Remote Command Execution                                     | linux/remote/36803.py
     6  ProFTPd 1.3.5 - File Copy                                                               | linux/remote/36742.txt
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.zacheller.dev/shell-scripting/random-commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
