TechShizz | All posts tagged 'Linux'

CeWL: How to use

CeWL can be used to generate a custom password list by crawling a website for words that match s specific criteria.

cewl -w customwordlist.txt -d 5 -m 7 www.techshizz.com

The above command will crawl www.techshizz.com, 5 pages deep for any word 7 letters long or greater.

This method can be effective as it builds a list of possible passwords that are specific to a certain industry.
(PS. Don't bother trying this on my website - I can assure you my password is not on this website.)


CRUNCH: How to use

Crunch can be used to create password lists to any length, pattern or character set you define. This tool is useful for creating password lists for cracking passwords if you know some of the characteristics of the target password.

crunch <min> <max> <charset> <options> -t <pattern>

For the pattern the following symbols are used:
@ = Lowe case characters only
, = Upper case characters only
% = Numbers only
^ = Symbols only

Example:

crunch 8 8 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ -t ,@@@@%%^ -o /root/pass.lst



Linux: Editing user account with usermod

Here are all of the switches we can use for usermod followed by some examples of how to use them,

-c = We can add comment field for the useraccount.
-d = To modify the directory for any existing user account.
-e = Using this option we can make the account expiry in specific period.
-g = Change the primary group for a User.
-G = To add a supplementary groups.
-a = To add anyone of the group to a secondary group.
-l = To change the login name
-L = To lock the user account. This will lock the password so we can’t use the account.
-m = moving the contents of the home directory from existing home dir to new dir.
-p = To Use un-encrypted password for the new password. (NOT Secured).
-s = Create a Specified shell for new accounts.
-u = Used to Assigned UID for the user account between 0 to 999.
-U = To unlock the user accounts. This will remove the password lock and allow us to use the user account.

Modify the home directory of a user
usermod -d /home/techshizz

Add a user to additional groups
usermod -G sudo,admins

Unlock a user account
usermod -U rich

Linux: useradd and userdel

Create a user
useradd <username>

Create a user with different home directory
useradd -d /Engineers/Projects/ <username>

Create a user with an account expiry date
This is useful if you need to create a temporary account.
useradd -e 2016-02-07 <username>

Add a user to multiple groups
useradd -G admins,webadmin,developer

Delete a user
userdel <username>


Linux Terminal Basics

Here are some of the basics for using Linux Terminal.

To run some of the following commands you need to have administrative access. Once Linux is installed, create a new user and log in as that, this will be the standard account. To run commands that require elevation precede the command with 'sudo'.

Before a standard user can do this they must first be added into the group 'sudo'. Once the user is created run:

usermod -aG wheel USERNAME

Basic Navigation
pwd - To see which folder you are in

dir - lists files and folders in the current directory

ls - lists files and folders in the current directory

cd    - Change Directory
example: cd Desktop/
cd .. - move up one level

mv - Move a file or it can be used to rename a file too.
Move example: mv sampletext.txt Desktop/
Rename example: mv sampletext.txt justsampletext.txt

cp - justsampletext.txt /root

rm - justsampletext.txt  - Deletes the text file.

Help functions
We can get help on commands and apps. Here we get help on VIM text editor.

vim --help

Or we could use a 'Man page' which is a more verbose help function.

man vim

Network configuration

ifconfig - Interface configuration

Change IP address
First run an ifconfig and identify the interface you need to configure. Ethernet interfaces are named 'eth0' , 'eth1' and so on. 

ifconfig eth0 10.0.0.99

Any changes wont take effect untill the machine is rebooted or the NIC is disabled and re-enabled.

ifconfig eth0 down
ifconfig eth0 up
Reboot

All of this can also be done in the GUI.

GREP
GREP is used to get an end result. In the example below we can use grep to filter the results of the ls command to anything with 'NTFS' in it in the sbin folder.

ls | grep ntfs

ls-grep

Kill
The kill command can be used to terminate processes. I have started VIM and opened another Terminal.

ps -A - Shows list of all running processes. 

We could pipe this into grep to narrow down our search.

ps -A | grep vim

ps -A | grep vim

Now we have the process ID we can terminate it. The "-9" is a semi-graceful way to terminate the process.

kill - 9 1786

If kill -9 does now work, -15 is the most efficient kill value.

Installing applications

If we know the name of an application we can simply install it from the terminal; here we install an text editor called 'kate'.

apt-get install kate