Welcome to mirror list, hosted at ThFree Co, Russian Federation.

parameters « include - github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3bbd02ffc313556554c33ea62e65d070dfe3b40f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
#!/bin/sh

#################################################################################
#
#   Lynis
# ------------------
#
# Copyright 2007-2013, Michael Boelen
# Copyright 2013-2016, CISOfy
#
# Website  : https://cisofy.com
# Blog     : http://linux-audit.com
# GitHub   : https://github.com/CISOfy/lynis
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
#################################################################################
#
# Parameter checks
#
#################################################################################
#
    # Check number of parameters submitted (at least one is needed)
    PARAMCOUNT=$#
    while [ $# -ge 1 ]; do
        case $1 in
            # Helpers first
            audit)
                CHECK_BINARIES=0
                RUN_HELPERS=1
                HELPER="audit"
                SKIP_PLUGINS=1
                RUN_TESTS=0
                if [ $# -gt 1 ]; then
                    case $2 in
                        "dockerfile")
                            if [ "$3" = "" ]; then
                                echo "${RED}Error: ${WHITE}Missing file name or URL${NORMAL}"
                                echo "Example: $0 audit dockerfile /root/Dockerfile"
                                ExitFatal
                              else
                                shift; shift
                                HELPER_PARAMS="$1"
                                HELPER="audit_dockerfile"
                                break
                            fi
                        ;;
                        "system")
                            if [ $# -gt 2 ]; then
                                if [ "$3" = "remote" ]; then
                                    shift
                                    if [ "$3" = "" ]; then
                                        echo "${RED}Error: ${WHITE}Missing remote location${NORMAL}"
                                        echo "Example: $0 audit system remote 192.168.1.100"
                                        ExitFatal
                                      else
                                        REMOTE_TARGET="$3"
                                        shift; shift; shift  # shift out first three arguments
                                        EXTRA_PARAMS=""
                                        if [ ! "$1" = "" ]; then EXTRA_PARAMS=" $@"; fi
                                        # --quick is added to be non-interactive
                                        REMOTE_COMMAND="./lynis audit system --quick${EXTRA_PARAMS}"
                                        echo ""
                                        echo "  How to perform a remote scan:"
                                        echo "  ============================="
                                        echo "  Target  : ${REMOTE_TARGET}"
                                        echo "  Command : ${REMOTE_COMMAND}"
                                        HELPER="system_remote_scan"
                                        HELPER_PARAMS="$@"
                                        CHECK_BINARIES=0
                                        QUIET=1
                                        RUN_HELPERS=1
                                        SKIP_PLUGINS=1
                                        RUN_TESTS=0
                                        SHOW_PROGRAM_DETAILS=0
                                        break
                                    fi
                                fi
                            fi
                            CHECK=1
                            CHECK_BINARIES=1
                            HELPER=""
                            SKIP_PLUGINS=0
                            RUN_TESTS=1
                            shift

                        ;;
                    esac
                  else
                    echo "${RED}Error: ${WHITE}Need a target to audit${NORMAL}"
                    echo " "
                    echo "Examples:"
                    echo "lynis audit dockerfile"
                    echo "lynis audit system"
                    ExitFatal
                fi
            ;;

            # Configure Lynis
            configure)
                CHECK_BINARIES=0
                RUN_HELPERS=1
                QUIET=1
                SKIP_PLUGINS=1
                RUN_TESTS=0
                SHOW_PROGRAM_DETAILS=0
                if [ $# -gt 0 ]; then shift; fi
                HELPER="configure"
                HELPER_PARAMS="$@"
                break
            ;;

            # Show Lynis details
            show)
                CHECK_BINARIES=0
                HELPER="show"
                LOGTEXT=0
                QUIET=1
                RUN_HELPERS=1
                RUN_TESTS=0
                RUN_UPDATE_CHECK=0
                SKIP_PLUGINS=1
                SHOW_PROGRAM_DETAILS=0
                SHOW_TOOL_TIPS=0
                shift; HELPER_PARAMS="$@"
                break
            ;;

            update)
                CHECK_BINARIES=0
                RUN_HELPERS=1
                HELPER="update"
                QUIET=1
                SKIP_PLUGINS=1
                RUN_TESTS=0
                RUN_UPDATE_CHECK=0
                SHOW_PROGRAM_DETAILS=0
                SHOW_TOOL_TIPS=0
                if [ $# -gt 1 ]; then
                    shift
                    HELPER_PARAMS="$1"
                    break
                else
                    echo "${RED}Error: ${WHITE}Need a target for update${NORMAL}"
                    echo " "
                    echo "Examples:"
                    echo "lynis update check"
                    echo "lynis update info"
                    echo "lynis update release"
                    ExitFatal
                fi
            ;;

            # Perform just the upload
            "upload-only" | "only-upload")
                CHECK_BINARIES=1
                CREATE_REPORT_FILE=0
                #QUIET=1
                LOGTEXT=0
                RUN_HELPERS=0
                RUN_TESTS=0
                RUN_UPDATE_CHECK=0
                SKIP_PLUGINS=1
                SHOW_REPORT=0
                SHOW_TOOL_TIPS=0
                SHOW_PROGRAM_DETAILS=0
                UPLOAD_DATA=1
                if [ $# -gt 1 ]; then echo "No other parameters or options are allowed when using 'upload-only' command"; ExitFatal; fi
            ;;

            # Assign auditor to report
            --auditor)
                shift
                AUDITORNAME=$1
            ;;

            # Binary directories (useful for incident response)
            --bindirs | --bin-dirs)
                if [ $# -gt 1 ]; then
                    shift
                    DIRS="$1"
                    for DIR in $1; do
                        if [ ! -d ${DIR} ]; then
                            echo "Invalid bindir '${DIR}' provided (does not exist)"
                            exit 1
                        fi
                    done
                    BIN_PATHS="${DIRS}"
                else
                    echo "Need one or more directories (e.g. \"/mnt/cert/bin /mnt/cert/sbin\")"
                    exit 1
                fi
            ;;

            # Perform tests (deprecated, use audit system)
            --check-all | --checkall | -c)
                DisplayToolTip "Usage of option -c is deprecated. Please use: lynis audit system [options]"
                CHECK=1
            ;;

            # Cronjob support
            --cron-job | --cronjob | --cron)
                CRONJOB=1
                CHECK=1; QUICKMODE=1; COLORS=0; NEVERBREAK=1 # Use some defaults (-c, -Q, no colors)
                RemoveColors
            ;;

            # Perform tests with additional debugging information on screen
            --debug)
                DEBUG=1
            ;;

            # Developer mode (more details when creating tests)
            --developer)
                DEVELOPER_MODE=1
            ;;

            # Display all available options with short alias
            --dump-options | --dumpoptions)
                OPTIONS="--auditor
                         --check-all_(-c) --cronjob_(--cron)
                         --debug
                         --help_(-h)
                         --info
                         --license-key --log-file
                         --manpage_(--man)
                         --no-colors --no-log
                         --pentest --profile --plugins-dir
                         --quiet_(-q) --quick_(-Q)
                         --report-file --reverse-colors
                         --tests
                         --upload
                         --version_(-V)"
                for I in ${OPTIONS}; do
                    echo "${I}" | tr '_' ' '
                done
                ExitClean
            ;;

            # View help
            --help | -h | "-?")
                VIEWHELP=1
            ;;

            # View program/database information
            --check-update | --check-updates | --info)
                echo "This option is deprecated"
                echo "Use: lynis update info"
                ExitClean
            ;;

            # License key for Lynis Enterprise
            --license-key)
                shift
                LICENSE_KEY=$1
            ;;

            # Adjust default logfile location
            --logfile | --log-file)
                shift
                LOGFILE=$1
            ;;

            # Don't use colors
            --no-colors | --nocolors)
                COLORS=0
                RemoveColors
            ;;

            # Disable logging
            --no-log | --nolog)
                LOGFILE="/dev/null"
            ;;

            --pen-test | --pentest)
                PENTESTINGMODE=1
            ;;

            # Define a custom profile file
            --profile)
                shift
                SEARCH_PROFILES=$1
            ;;

            # Define a custom plugin directory
            --plugindir | --plugin-dir | --plugins-dir)
                shift
                PLUGINDIR=$1
                LASTCHAR=`echo $1 | awk '{ print substr($0, length($0))}'`
                if [ "${LASTCHAR}" = "/" ]; then
                    echo "${RED}Error:${WHITE} plugin directory path should not end with a slash${NORMAL}"
                    ExitCustom 65
                fi
                if [ ! -d ${PLUGINDIR} ]; then
                    echo "${RED}Error:${WHITE} invalid plugin directory ${PLUGINDIR}${NORMAL}"
                    ExitCustom 66
                fi
            ;;

            # Quiet mode
            --quiet | -q)
                QUIET=1
                QUICKMODE=1 # Run non-interactive
            ;;

            # Non-interactive mode
            --quick | -Q)
                QUICKMODE=1
            ;;

            # Define alternative report file
            --report-file)
                shift
                REPORTFILE=$1
            ;;

            # Strip the colors which aren't clearly visible on light backgrounds
            --reverse-colors)
                BLUE="${NORMAL}";
                SECTION="${NORMAL}";
                NOTICE="${NORMAL}";
                CYAN="${NORMAL}";
                GREEN="${NORMAL}";
                YELLOW="${NORMAL}";
                WHITE="${NORMAL}";
                PURPLE="${NORMAL}";
            ;;

            # Root directory (useful for forensics)
            --rootdir | --root-dir)
                if [ $# -gt 1 ]; then
                    shift
                    if [ -d $1 ]; then
                        ROOTDIR="$1"
                    else
                        echo "Invalid rootdir provided (does not exist)"
                        exit 1
                    fi
                else
                    echo "Need a root directory (e.g. /mnt/forensics)"
                    exit 1
                fi
            ;;

            # Skip execution of plugins
            --skip-plugins | --no-plugins)
                SKIP_PLUGINS=1
            ;;

            # Only scan these tests
            --tests)
                shift
                TESTS_TO_PERFORM=$1
            ;;

            # Scan one or more tests from just one category (e.g. security)
            --tests-from-category)
                shift
                TEST_CATEGORY_TO_CHECK=$1
            ;;

            # Scan one or more tests from just on group
            --tests-from-group | --tests-from-groups | --test-from-group | --test-from-group)
                shift
                TEST_GROUP_TO_CHECK=$1
            ;;

            # Lynis Enterprise: upload data to central node
            --upload)
                UPLOAD_DATA=1
            ;;

            --verbose)
                VERBOSE=1
            ;;

            # Version number
            --version | -V)
                echo "${PROGRAM_VERSION}"
                exit 0
            ;;

            # View man page
            --view-manpage | --man-page | --manpage | --man)
                if [ -f lynis.8 ]; then
                    nroff -man lynis.8
                    exit 0
                  else
                    echo "Error: man page file not found (lynis.8)"
                    echo "If you are running an installed version of Lynis, use 'man lynis'"
                    exit 1
                fi
            ;;

            --wait)
                QUICKMODE=0
            ;;

            # Warnings
            --warnings-only | --show-warnings-only)
                SHOW_WARNINGS_ONLY=1
                QUICKMODE=1
                QUIET=1
            ;;

            --tests-category | --tests-categories | --view-categories | --list-categories | --show-categories)
                echo "Error: Deprecated option ($1)"
                exit 1
            ;;

            # Drop out when using wrong option(s)
            *)
                # Wrong option used, we bail out later
                WRONGOPTION=1
                WRONGOPTION_value=$1
            ;;

        esac
        shift

    done

#================================================================================
# Lynis - Security Auditing and System Hardening for Linux and UNIX - https://cisofy.com