Bash Learning ahead

Source: Internet
Author: User

#!/bin/sh

#!/bin/bash

View Shell version

Bash--version

Bash vulnerability

The Bash vulnerability is a vulnerability in software that controls the command prompt for a Linux computer. exploiting this vulnerability, an attacker could take over the entire operating system of a computer, access confidential information, make changes to the system, and so on. Anyone's computer system, if you use bash software, you need to patch it up immediately.

This burst of bash vulnerability is that bash handles such "function environment variables" and does not end with the function End "}", but executes the subsequent shell commands! For example

Envx= ' () {:;}; Echovulnerable ' Bash-c "Echothisisatest"

If you return
Vulnerable
This is a test
If such a result, please upgrade as soon as possible


echo $USER (System variable)

Defining global Variables in/etc/profile

source/path/file.sh =. /path/file.sh is different from sh

You can bring the variables in the current script to the current shell

Vim a.sh

#!/bin/sh

Source/etc/init.d/functions

Action "It is a test Deamon"/bin/true

Troubleshooting commands

Dmesg

Cat/var/log/message

Script Cleanup/var/log/messages

#!/bin/sh

User=0

dir=/var/log/

If ["$USER"-ne "$UID"]then

echo "You must root"

Exit 1

Fi

CD $DIR

Cat/dev/null >messages && echo "It is clear"

Exit 0


Bash Learning ahead

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.