Showing posts with label Linux Commands. Show all posts
Showing posts with label Linux Commands. Show all posts

Sunday, May 12, 2013

Linux Hackers Command Reference

Linux Command Reference for Pen-testers



This part of the blog is dedicated to Linux and Unix-like commands that can be used from Penetration Testers (yea who is your tester?) and Information Security Administrators. In this page I will periodically post Linux tiny simple scripts and commands that a Penetration tester or a Security Administrator can use to:


1. Perform Administration Security tasks (e.g use windows/linux netcat to bind shells e.t.c).

2. Run Vulnerability Scans (e.g Identify null sessions, test for LANMAN services e.t.c).

3. Do pivoting (e.g after compromising a machine use windows tools to escalate e.t.c).



Using Netcat to Bind Shell




Launching a listening shell in windows and binding from linux:

nc.exe -L -p <listening port> -e cmd.exe - Running in windows box

nc <windows box ip> <windows port> - Run in Linux/Unix-like box

Launching a listening shell in Linux/Unix-like and binding from Windows:

nc -l -p <listening port> -e /bin/sh - Running in Linux/Unix-like box

nc.exe <linux box ip> <linux port> - Run in Windows box


Using Netcat to transfer files

Friday, May 3, 2013

CRYPTOGRAPHY COMMANDS







Encryption tools

gpg - Encrypts data using GNU Privacy Guard.
mcrypt - Encrypts the specified file.
mimencode - Encodes the specified binary file to on eof the ASCII encoding formats.
mpack - Pack a file in MIME format.
uuencode - Encodes the specified binary file so that it can be transferred over a medium which does not support non-ASCII characters.

---------------------------------------------------

Decryption tools

gpg -
Decrypts data using GNU Privacy Guard.
mdecrypt - Decrypts any file with the .enc suffix, that was encrypted by mcrypt.
munpack - unpack messages in MIME or split-uuencode format.
uudecode - Decodes the uuencode coded file.
uudeview - a powerful decoder for binary files.

INTERNET AND NETWORK COMMANDS







ethtool
ftp

command to show if a network cable is plugged in e.a

Used to establish a connection with a specified host using the File Transfer Protocol.

ifconfig

Displays/establishes information about the network interfaces.

ifup

Bring up network interface.

ifdown

Bring up network interface.

iptraf

Interactive IP LAN monitor

iwconfig

Displays/establishes information about the wireless interfaces.

ip

Used to manage IP network interfaces.

lsof

Command to show what processes are making use of a port e.a.

nmap

Command to show which ports are open e.a.

netstat

Displays information about the Linux networking subsystem.

nslookup

Looks up the numerical IP address of the specified host.

ping

Sends a packet to a designated address and waits for a response.

route

Configure IP4 routing

scp

Copy files over the network.

showmount

Displays the Network Filesystem mounts available.

smbclient

Launches an interactive samba utility which resembles ftp.

smbmount

Mounts a remote Samba service at the specified mount point.

smbumount

Unmounts the specified Samba mount point.

ssh

Control a remote computer over the network.
telnet
Opens a terminal window on the remote host and starts an interactive session.

traceroute

Prints the route that packets take to network host

wvdial

Initiates a PPP dial-up connection.

DIRECTORY COMMANDS


cd - Change directories
df - print the free space available in a directory
du - print the size of a directory
ln - Create a link to a file or directory
ls - Lists the files contained in the directory
mkdir - Create a new directory
pwd - Print the current working directory
rmdir - Remove the specified directory
symlinks - Find symbolic links

DISK AND TAPE DRIVE COMMANDS




Partitioning 

cfdisk - Interactive hard disc partition utility for text mode.
fdisk - Launches a menu-driven program that partitions a hard disk.
parted - command line partitioning tool. (parted sometimes complains about boundaries of partitions created with fdisk. parted can format a partitionof type ext2 or fat32 partition while creating it.)

Formatting


mkfs - front-end to various filesystem-creation tools
parted can create a filesystem while partitioning
mkfs.vfat /dev/sde1 to format a fat32 partition sde1
mkfs.ext2 /dev/sde2 to format an ext2 partition sde2

Tuning


tune2fs - command to tune ext2/ext3 filesystems
tune2fs -j /dev/sde2 to convert an ext2 filesystem sde2 to ext3 by adding a journal
tune2fs -L /dev/sde2 bulkdata to set the volume label of sde2 to "bulkdata"
debugfs - Interactive utility to repair the ext2 filesystem on specified drive.
e2fsck- Performs an analysis of the filesystem's integrity and optionally repairs errors.
badblocks - Scans the specified drive for bad blocks.

Using a configured hard drive or tape


df - Displays the amount of disc space used and remaining on all mounted filesystems.
hwinfo - Automatically recognizes all available CD-ROM drives.
mount - Attaches the device to a specified directory, which will serve as the filesystem's mount point.
sync - Flushes the filesystem buffers.
umount - Unmounts the filesystem specified by the device.
du - Displays the amount of disc space used in the current directory.
duchs - Lists the largest directories in human readable format
eject - Ejects the media in the specified drive.

Rescuing


mc (midnight commander) - Command line file manager. Can undelete files in unmounted ext2 filesystems.

Backing-up


partimage - Backs up disk partitions into image files and restores them.

Logical Volume Management

LVM - LVM is an abbreviation for Logical Volume Manager which has been available under Linux for some time; the 2.4 kernel has the original LVM whilst 2.6 has LVM2 although both essentially do the same job. LVM allows one or more physical devices to be treated as a storage pool from which logical drives may be created whose size can altered dynamically. Assuming your file system supports dynamic resizing the upshot of this is you can grow/shrink logical drives (mount points) as your wish. In addition to combining drives in to logical devices you can also control the spread of data amongst devices through the use of striping, however this is often better left to a RAID implementation. LVM works on top of Software-RAID just fine by the way.

USER COMMANDS






date - Print or set the system date and time.
finger - Display information about a user. May be turned off by default.
id - Display UID and group info about a user.
passwd - Change a user's password.
quota - Assign quota for users and groups.
su - Change to root or another user id.
useradd - Add a new user to the system.
userdel - Delete a user from the system.
usermod - Modify user information on the system.
users - Display a list of current users.
who - Display a list of current users.
whoami - Print the user name associated with the effective UID.
w - Display who is logged on and what they are doing.

STARTUP/SHUTDOWN-RELATED COMMANDS



dmesg - display bootup messages.
halt - halt the system. (not recommened - use shutdown -h now instead)
init - set runlevel, or define processes that are begun on a specific runlevel.
reboot - reboot the system.
runlevel - show the current system runlevel.
shutdown - shutdown the system.
swapoff - disable the paging hardware.
swapon - enable the paging hardware.
sync - write buffered memory out to disk.
telinit - move the system to a new runlevel.

SHELL COMMAND







A shell, also known as a command interpreter, is a specialized program for accepting typed user commands, translating those into programs to run, running those programs, and displaying (or doing something) with the results. A "common" example of a shell is the DOS shell, called COMMAND.COM, which was the complete user interface before Windows.

Different shells exist, offering different feature sets. Two main families of shell exist: the Bourne shell and its variants (sh, bash, ksh) and the C shell and its variants (csh, tcsh). Though many shells have features common to others, the way they make use of those features is unique, so that (for example) Bourne shell conventions don't usually apply to C shells.
bash - The Bourne-Again SHell - feature-rich default Linux shell.
csh - A shell with C-like syntax, with file name completion and command line editing - usually tcsh on modern Linux.
fish - 'friendly' interactive shell
ksh - Korn SHell - part of the sh rather than csh family.
sh - the original shell, often a symlink to bash on modern Linux and the most portable.
tcsh - An extended version of csh, with all its features and some additional ones.
zsh - One of the newest and most feature-rich shells.

Thursday, May 2, 2013

PROGRAMMING-RELATED COMMANDS





Compiling


g++ -- C++ front-end to GCC.

gcc -- "GNU Compiler Collection". Also C compiler.

gcj -- Java front-end to GCC.

as - the portable GNU assembler

linking and libraries (see also Library-related_Commands_and_Files)

ar - tool for creating, modifying, and extracting from archives

ld - the GNU linker

ldconfig

ldd

ld.so

pkg-config - tool for outputting linker and compiler flags for a given library

dealing with object files

nm - lists symbols from object files

objcopy - copies and translates object files

objdump - display information from object files

readelf - displays information about ELF files

lexical analyzer and parser

bisOn (the yacc replacement)

flex (the lex replacement)



Debugging Main article: debuggers 

ddd
gdb
lInt
valgrind


gprof - fight performance problems using profiling

build tools

autoconf - generates configuration scripts

automake - automatically generates 'Makefile.in's from 'Makefile.am's

ant
jam
libtool


make, makefile, configure script

scons

source code tagging

ctags -- for vim- and NEdit-compatible tag files

etags -- for emacs-compatible tag files

revision control

GNU Arch

Bazaar-NG -- aka "Bazaar 2", aka "bzr"

CVS
git
RCS
Subversion

misc

addr2line - converts addresses into file names and line numbers

file - find out file type (like "link", "executable" or shared object)

strings - finds printable strings in a file

Wednesday, May 1, 2013

KERNEL COMMANDS


Note, some of the following commands refer to kernel modules, which are dynamically loadable objects that the kernel uses for a variety of tasks, such as hardware drivers.


depmod - Create a module dependency list.
insmod - Install a module.
modinfo - Display information about a module.
lsmod - List installed modules.
modprobe - Load or list loadable modules.
rmmod - Remove specified module.
sysctl - Configure kernel parameters at runtime.
uname - Display system information

BASIC LINUX COMMANDS



mkdir - make directories

Usage

mkdir [OPTION] DIRECTORY

Options

Create the DIRECTORY(ies), if they do not already exist.

Mandatory arguments to long options are mandatory for short options too.

-m, mode=MODE set permission mode (as in chmod), not rwxrwxrwx - umask

-p, parents no error if existing, make parent directories as needed

-v, verbose print a message for each created directory

BASIC LINUX COMMANDS WITH MAN PAGES


Here are some basic commands to get you started in the wonderful world of Linux and other UNIX variants. All of these commands should work from your command prompt (regardless which shell you’re using).You MUST press enter to invoke the command.All UNIX and Linux commands are case sensitive. There are of course thousands of Linux related commands and procedures.



You can also execute multiple commands by separating each one with a ; for example cd newdir; mkdir thatdir ; ls -la will first change directories to the newdir directory, then create a directory called thatdir, then list all the files in long format. You can string together as many commands as you like but caution should be used not to inadvertently do anything harmful.
If you think some thing need to be added to this list let me know.
access - determine whether a file can be accessed
Syntax
access -mode file
For more options and how to use check access man page

alias - define or display aliases
Syntax
alias [alias-name[=string] …]
For more options and how to use check alias man page

bg - run jobs in the background
Syntax
bg [job_id ...]
For more options and how to use check bg man page
cal - displays a calendar
Syntax
cal [-smjy13 ] [[ month ] year ]
For more options and how to use check cal man page

cd - change directories
Use cd to change directories. Type cd followed by the name of a directory to access that directory.Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below.
Syntax
cd [-L | -P] [directory]
For more options and how to use check cd man page

chown - change file owner and group
Syntax
chown [OPTION] OWNER[:[GROUP]] FILE
chown [OPTION] :GROUP FILE
chown [OPTION] --reference=RFILE FILE
For more options and how to use check chown man page

chmod - change file access permissions
Syntax
chmod [-r] permissions filenames
Options
r Change the permission on files that are in the subdirectories of the directory that you are currently in. permission Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha numeric format.filenames File or directory that you are associating the rights with Permissions
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.
r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.
Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
For more options and how to use check chmod man page

Monday, April 29, 2013

Linux Complete Command


                                        Download Linux Complete Command Reference by J Purcell
                                                                        size: 8.24 MB





Overview:
Part I User Commands 2
Part II System Calls 738
Part III Library Functions 892
Part IV Special Files 1064
Part V File Formats 1104
Part VI Games 1210
Part VII Miscellaneous 1214
Part VIII Administration and Privileged Commands 1258
Part IX Kernel Reference Guide 1424

DOWNLOAD FULL BOOK

SSH AND SCP: HOW TO, TIPS & TRICKS




This tutorial is about SSH and SCP. You will learn how to connect to a remote host and how to copy between hosts. This tutorial also documents a few important differences between the commands.
Difficulty: Basic
Before we start: in this tutorial, you will come across both SSH and ssh. The difference is this: SSH is the general protocol, and ssh is the linux SSH client command.
SSH
SSH is some kind of an abbreviation of Secure SHell. It is a protocol that allows secure connections between computers. In this tutorial, we'll be dealing with the ssh command on Linux, the OpenSSH version. Most Linux distributions feature the OpenSSH client today, but if you want to be sure, have a look at the SSH manpage on your system. You can do this by typing:

---------------------
[rechosen@localhost ~]$ man ssh
--------------------