Dialysis Linux Log query intrusion

Source: Internet
Author: User
Tags syslog
Article Title: Dialysis Linux Log query intrusion. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Logs are undoubtedly very important for network security. They record all kinds of events that occur in the system every day. You can use them to check the causes of errors, or traces left by attackers after being attacked. The main functions of logs include auditing and monitoring. At the same time, logs can monitor the system status and intruders in real time.

Log subsystem category

In Linux, there are three major log subsystems:

Connection time log-the log is executed by multiple programs and written to/var/log/Wtmp and/var/run/Utmp, Login and other programs to update the Wtmp and Utmp files, enables the system administrator to track who is logged on to the system at any time.

Process statistics-executed by the system kernel. When a process terminates, each process writes a record to the process Statistics file (Pacct or Acct. Process statistics are used to provide command usage statistics for basic services in the system.

Error Log -- executed by Syslogd (8. Various system Daemon Processes, user programs, and kernels report noteworthy events to files/var/log/messages through Syslog (3. In addition, many UNIX programs create logs. Servers that provide network services such as HTTP and FTP also maintain detailed logs.

Common log files are as follows:

Access-log: records the transmission of HTTP/WEB data.

Acct/pacct: record user commands.

Aculog: records MODEM activities.

Btmp: the record of failure.

Lastlog: records the last successful logon events and the last unsuccessful logon events.

Messages: records information from syslogs (some links to the Syslog file ).

Sudolog: records the commands issued by using Sudo.

Sulog: records the use of "su.

Utmp: records every user currently logged on.

Wtmp: a permanent record of the time a user logs on to and exits.

Xferlog: records FTP sessions.

Basic Logging Process

Utmp, Wtmp, and Lastlog log files are the key for most UNIX log subsystems to be reused-keep records of user logon entry and exit. The information about the current logon user is recorded in the file Utmp; the logon entry and exit records are recorded in the file Wtmp; the last logon file can be viewed using the "Lastlog" command. Data exchange, shutdown, and restart are also recorded in the Wtmp file. All records contain timestamps. These files (Lastlog is usually not large) grow rapidly in systems with a large number of users. For example, the Wtmp file can grow infinitely unless it is intercepted regularly. Many systems configure Wtmp to be used cyclically in units of one day or one week. It is usually modified by the script run by Cron. These scripts are renamed and the Wtmp file is recycled.

TIPS: Generally, Wtmp is named Wtmp.1 after the first day. After the second day, Wtmp.1 is changed to Wtmp.2 until Wtmp.7.

Each time a user logs on, the Login program checks the user's UID in the Lastlog file. If the logon time is found, the user's Last Logon Time, exit time, and host name are written to the standard output, and the Login program records the new Logon Time in Lastlog. After a new Lastlog is written, the Utmp file is opened and the user's Utmp record is inserted. This record is always used when a user logs on and exits. The Utmp file is used by various command files, including Who, Users, and Finger. Next, the Login program opens the file Wtmp and appends the user's Utmp record. When a user logs on and exits, the same Utmp record with the updated timestamp is appended to the file. The Wtmp file is used by the program Last and AC.

View specific logs

Wtmp and Utmp files are binary files, which cannot be cut or merged by Tail commands (Cat commands are required ), you need to use the information contained in the two files by Who, W, Users, Last, and AC.

1. Who: This command queries the Utmp file and reports to each user currently logged on. The default output of Who includes the user name, terminal type, logon date, and remote host. For example, enter Who and press enter to display:

Chyang pts/0 Aug 18 :06

Ynguo pts/2 Aug 18 :32

Ynguo pts/3 Aug 18 :55

Lewis pts/4 Aug 18 :35

Ynguo pts/7 Aug 18

Ylou pts/8 Aug 18

If the Wtmp file name is specified, the Who command queries all previous records. Run the "Who/var/log/Wtmp" command to report every logon attempt since the Wtmp file was created or deleted.

2. W: This command queries the Utmp file and displays information about each user in the current system and the processes it runs.

3. Users: Users displays the currently logged-on user with a single line. Each displayed user name corresponds to a logon session. If a user has more than one login session, the user name will display the same number of times. For example, enter Users and press enter to display:

Chyang lewis ylou ynguo

4. Last: run the Last command to search for Wtmp and display the users who have logged on since the first file creation. For example:

Chyang pts/9 202.38.68.242 Tue Aug 1)

Cfan pts/6 202.38.64.20.tue Aug 1)

Chyang pts/4 202.38.68.242 Tue Aug 1)

Lewis pts/3 202.38.64.233 Tue Aug 1)

Lewis pts/2 202.38.64.233 Tue Aug 1)

If the user is specified, only recent activities of the user are reported Last time. For example: last ynguo display:

Ynguo pts/4 simba. nic. ustc. e Fri Aug 4)

Ynguo pts/4 simba. nic. ustc. e Thu Aug 3)

Ynguo pts/11 simba. nic. ustc. e Thu Aug 3)

Ynguo pts/0 simba. nic. ustc. e Thu Aug 3)

5. AC: the AC Command reports the user connection time (hours) based on the logon entry and exit times in the current/var/log/Wtmp file. If no signs are used, the total time is reported. For example: ac, display:

Total 5177.47

Ac-d (Press ENTER) to display the total connection time of each day:

Aug 12 all 261.87

Aug 13 total 351.39

Aug 14 Overall 396.09

Aug 15 total 462.63

Aug 16 total 270.45

Ac-p (Press ENTER) to display the total connection time of each user:

Ynguo 193.23

Yucao 3.35

Rong 1, 133.40

Hdai 1, 10.52

[1] [2] Next page

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.