Wednesday, March 24, 2010

Beetel 220x ADSL router (Broadcom BCM6338) : Hack #

The router is based upon Broadcom BCM6338 chipset. This router is used by Airtel, BSNL and other ISPs in India.

Hack # 1 : How to Login into Router

 
 

Login over telnet. Is a common feature of all router these days and this the only way to hack into box:

Default IP: 192.168.1.1

Default Username: admin

Default Password: password

 
 

I have changed IP of router to 192.168.1.254 so here is my first session:

$ telnet 192.168.1.254

 
 

Trying 192.168.1.254...

Connected to 192.168.1.254.

Escape character is '^]'.

BCM96338 ADSL Router

Login: admin

password: ********

Once you are logged in you will see menu:

 
 

Main Menu

 
 

1. ADSL Link State

2. LAN

3. WAN

4. DNS Server

5. Route Setup

6. NAT

7. Firewall

8. Quality Of Service

9. Management

10. Passwords

11. Reset to Default

12. Save and Reboot

13. Exit

->

 
 

Hack # 2: Get out of this stupid shell menu script/program

Yup, it is stupid stuff and don't waste your time hitting CTRL+C, CTRL+D keys, to get out of this script/program (break shell script), just type sh and hit enter key at arrow prompt ->

-> sh

 
 

And you will be taken to shell

BusyBox v1.00 (2005.09.20-19:57+0000) Built-in shell (msh)

Enter 'help' for a list of built-in commands.

#

 
 

Hack # 3: But where is my ls command...

Type ls or dir command,

# ls

 
 

ls: not found

# dir

 
 

dir: not found

 
 

They have removed the ls and dir command. But don't worry you can use old echo command trick:

# echo *

 
 

bin dev etc lib linuxrc mnt proc sbin usr var webs

 
 

echo * is old trick which displays list of all files in current directory without using ls or dir command.

 
 

Hack #4: Looking for advanced web based configuration, use main.html

Yet another stupid thing, they have removed main.html from web based configuration. Basically main.html is use to configure advanced options of router like port forwarding, DNS setting, firewall etc.

 
 

Just type http://192.168.1.254/main.html (replace 192.168.1.254 with your actual router IP address) to get all advanced options.

 
 

Hack # 5: Get more information about router hardware and Linux

Since this is tiny device most of the userland command such as free, uname etc are removed. However /proc file system provides all information:

 
 

Display CPU Information

# cat /proc/cpuinfo

 
 

Display RAM Information

# cat /proc/meminfo

 
 

Display Linux versions

# cat /proc/version

 
 

Linux version 2.6.8.1 (root@localhost.localdomain) (gcc version 3.4.2) #1 Tue Sep 20 15:52:07 EDT 2005

 
 

Display list of running Processes:

# ps

 
 

Display list of all kernel module (drivers):

# cat /proc/modules

 
 

Hack # 6: Get more information about your network configuration

Display list of network interfaces

# ifconfig

 
 

Get default routing information i.e. find out your ISP's router:

# route

 
 

Display Iptables rules

# iptables -L -n

 
 

Hack 6 : Secure your router

(A) Fire web browser such as firefox and login to web based interface. Type url http://192.168.1.1/ main.html (or 192.168.1.254/main.html)

 
 

(B) Enable Firewall

Click on Security > Ip filtering > Outgoing or Incoming > Click add

 
 

(C) Change default admin password

Click on Tools > Select Administrator and type the password. > Click apply

 
 

(D) Save changes and reboot router

Click on Management > Access Control > Password > Select Admin > Setup new password

 
 

Save changes and reboot router.

 
 

Quick reboot router with reboot command:

# reboot

Wednesday, March 10, 2010

Create MySql Database

MySQL create database

 
 

What is a MySQL database?

Today, modern web applications like Joomla, Moodle and 4images, are dynamic. They are designed to store articles, posts, stories, pictures, movies and other content. To keep all that data organized and to have it displayed faster, those applications are using MySQL databases. The MySQL database consists of tables and every MySQL table stores specific information for the application. To better understand how the MySQL database stores your site's data let's take a look at a common Joomla database:

 
 

 
 


 
 

As you can see, Joomla keeps the database information separated in many tables. The users' data information (such as names, login credentials and passwords) is kept in the table jos_users and the content data (articles, news, posts) is in jos_content. The 'jos_' part of the database table's name is called prefix and is used to determine the application which is using the table. For example, 'jos_' is the default prefix for all tables created by Joomla, but if you want to host a second installation of Joomla and use the same database (not recommended) you can change the prefix (for example) to 'jo2_'. So, your first Joomla website will use the tables which start with jos_ and the second installation - the ones which start with jo2_.

 
 


 
 

How to add a new database using PHPMyAdmin?

Since the use of SQL databases and MySQL databases, in particular, is vital for content rich websites, it is crucial that website owners have the possibility to create such databases and manage their settings at any time. As we already mentioned, there is a possibility to host more than one application by using a single database. Actually, in practice this is not very convenient and also lowers you applications' security. That's why it is recommended to have separate databases for every application.

 
 

There are several ways to create a new database on a MySQL5 Server. The two basic ones are - through the phpMyAdmin interface and via the SQL command line, both requiring some basic MySQL administration skills from the users. In order to create a new database using the PHPMyAdmin tool, first you need to log in using your MySQL server's ROOT user account or another account with the appropriate privileges. Once logged in you will see the "Create new database" form on PHPMyAdmin's home page:

 
 

An example of the 'Create new database' section form in PHPMyAdmin


 
 

Put your new database name in the first field (my_db in our example) and then choose an encoding from the drop down list. When ready, click on the Create button to create your database.

 
 

How to create a database using the SQL command line?

As we have seen above, it is pretty easy to create a database using the PHPMyAdmin graphic user environment, but sometimes PHPMyAdmin is not accessible or not present on a web server. In such cases it is good to know how to create a database using the SQL command line. To enter the command line you need to be logged on to the MySQL Server as ROOT user or through an account which has enough privileges. To establish a root connection, start an SSH session using the terminal/console application if you're using Linux or MacOS, or use PuTTY (or other SSH client) on a Windows PC, then enter the following command:

 
 

An example of starting an SSH connection to a MySQL server


 

$ssh databasehost

Then you need to log in using your ROOT account by using the following line:

 
 

How to log in as ROOT on a MySQL server


 

$ mysql -u root -p

Now we are ready to create the new database. To do so, use a line similar to this:

 
 

An example of how to Create a Database in MySQL


 

CREATE DATABASE mydatabasename

We, at NTC Hosting, have simplified the MySQL database creation process for you to the maximum. Now you can create new MySQL databases and manage them directly from your web hosting
Control Panel coming with our packages. There is no need to deal with the phpMyAdmin interface, nor bother yourself with the SQL query window or the shell prompt program. We ensure a quick and user-friendly MySQL database set-up process.

 
 

An example of how to Create a Database in MySQL


 

CREATE DATABASE mydb

Now your newly created database is accessible only for your ROOT user. To allow another user to access your database you need to use a query similar to this:


 

An example of how to GRANT privileges to a user for a new database


 

GRANT USAGE ON mydb.* to db_user@localhost IDENTIFIED BY 'db_passwd';

Now the user has some basic privileges but they are not enough to install a PHP script. If you need to use MySQL grant to add ALL privileges for the database to a user, use the following query:

 
 

An example of how to GRANT ALL privileges to a user


 

GRANT ALL  ON mydb.* to db_user@localhost ;

Now let's try to establish a connection to our new database 'mydb' using the 'db_user' account via the SSH command line:

 
 

How to log in to a specific database on a MySQL server:


 

mysql -u db_user -p'db_passwd' mydb

How to create a database using NTC Hosting's Control Panel

As you can see, creating a database using the PHPMyAdmin tool is simpler than using the SSH and SQL command line. To keep the process even simpler than that, NTC Hosting provides all users with a MySQL Database management tool. Here is a video tutorial on how to create a database using our Control Panel

 
 

Movie tutorial on how to create a database

 
 

In short, to quickly create a MySQL database, simply log into your Control Panel and go to the MySQL Databases section under Site Management. There we'll need only two entries from you - the name of your new database and its password. Simply fill in the empty fields and hit the 'Create Database' button. That's all. Repeat the same simple steps anytime you need a new MySQL database added to your web hosting account.


 

Tuesday, March 9, 2010

Windows 7 PowerShell

Comparison of cmdlets with similar commands

The following table contains a selection of the cmdlets that ship with PowerShell noting the most similar commands in other well known command line interpreters.

Windows PowerShell

(Cmdlet)

Windows PowerShell

(Alias)

cmd.exe / COMMAND.COM

(MS-DOS, Windows, OS/2, etc.)

Bash

(Unix, BSD, Linux, Mac OS X etc.)

Description

Get-Location

gl, pwd

cd

pwd

Display the current directory/present working directory.

Set-Location

sl, cd, chdir

cd, chdir

cd

Change the current directory

Clear-Host

cls, clear

cls

clear

Clear the screen[35]

Copy-Item

cpi, copy, cp

copy

cp

Copy one or several files / a whole directory tree

Get-Help

help, man

help

man

Help on commands

Remove-Item

ri, del, erase, rmdir, rd, rm

del, erase, rmdir, rd

rm, rmdir

Delete a file / a directory

Rename-Item

rni, ren

ren, rename

mv

Rename a file / a directory

Move-Item

mi, move, mv

move

mv

Move a file / a directory to a new location

Get-ChildItem

gci, dir, ls

dir

ls

List all files / directories in the (current) directory

Write-Output

echo, write

echo

echo

Print strings, variables etc. to standard output

Pop-Location

popd

popd

popd

Change the current directory to the directory most recently pushed onto the stack

Push-Location

pushd

pushd

pushd

Push the current directory onto the stack

Set-Variable

sv, set

set

set

Set the value of a variable / create a variable

Get-Content

gc, type, cat

type

cat

Get the content of a file

Select-String

  

find, findstr

grep

Print lines matching a pattern

Get-Process

gps, ps

tlist,[36] tasklist[37]

ps

List all currently running processes

Stop-Process

spps, kill

kill,[36] taskkill[37]

kill

Stop a running process

Tee-Object

tee

n/a

tee

Pipe input to a file or variable, then pass the input along the pipeline

Examples

Examples are provided first using the long-form canonical syntax and then using more terse UNIX-like and DOS-like aliases that are set up in the default configuration.

  • Stop all processes that begin with the letter "p":

PS> get-process p* | stop-process

PS> ps p* | kill

  • Find the processes that use more than 1000 MB of memory and kill them:

PS> get-process | where-object { $_.WS -gt 1000MB } | stop-process

PS> ps | ? { $_.WS -gt 1000MB } | kill

  • Calculate the number of bytes in the files in a directory:

PS> get-childitem | measure-object -property length -sum

PS> ls | measure length -s

PS> dir | measure length -s

  • Determine whether a specific process is no longer running:

PS> $processToWatch = get-process notepad
PS> $processToWatch.WaitForExit()

PS> (ps notepad).WaitForExit()

  • Change the case of a string from lower to upper:

PS> "hello, world!".ToUpper()

  • Insert the string "ABC" after the first character in the word "string" to have the result "sABCtring":

PS> "string".Insert(1, "ABC")

  • Download a specific RSS feed and show the titles of the 8 most recent entries:

PS> $rssUrl = "http://blogs.msdn.com/powershell/rss.aspx"
PS> $blog = [xml](new-object System.Net.WebClient).DownloadString($rssUrl)
PS> $blog.rss.channel.item | select title -first 8

$x=new-object xml;$x.load("http://blogs.msdn.com/powershell/rss.aspx");$x.rss.channel.item|select title -f 8

  • Sets $UserProfile to the value of the UserProfile environment variable

PS> $UserProfile = $env:UserProfile

  • Cast a .Net Namespace, and call a method exposed by the cast

PS> [System.Windows.Forms.MessageBox]::Show("Hello, World!")

  • Run a command line executable, with arguments.

PS> [Array]$arguments = "-h", "15", "www.google.com"
PS> tracert $arguments

File extensions

  • PS1 – Windows PowerShell shell script
  • PS1XML – Windows PowerShell format and type definitions
  • PSC1 – Windows PowerShell console file
  • PSD1 – Windows PowerShell data file (for Version 2)
  • PSM1 – Windows PowerShell module file (for Version 2)

Application support

SnapIns and hosts

Application

Version

Cmdlets

Provider

Management GUI

Exchange Server

2007

402

Yes

Yes

Windows Server

2008

Yes

Yes

No

Microsoft SQL Server

2008

Yes

Yes

No

System Center Operations Manager

2007

74

Yes

No

System Center Virtual Machine Manager

2007

Yes

Yes

Yes

System Center Data Protection Manager

2007

Yes

No

No

Windows Compute Cluster Server

2007

Yes

Yes

No

Microsoft Transporter Suite for Lotus Domino[38]

08.02.0012

47

No

No

Microsoft PowerTools for Open XML[39]

1.0

33

No

No

IBM WebSphere MQ[40]

6.0.2.2

44

No

No

Quest Management Shell for Active Directory[41]

1.1

40

No

No

Special Operations Software Specops Command[42]

1.0

Yes

No

Yes

VMware
Infrastructure Toolkit[43]

1.5

157

No

No

Internet Information Services[44]

7.0

54

Yes

No

Ensim Unify Enterprise Edition[45]

1.6

Yes

No

Yes

Windows 7 Troubleshooting Center[46]

6.1

Yes

No

Yes

Microsoft Deployment Toolkit

  

  

  

  

 
 

 
 

Monday, March 8, 2010

Copy Audio CDs Using Windows Media Player

Windows Media Player


 10, at the time of this writing, is Microsoft's latest release of media management software. It is available free of charge for Windows customers. The most popular feature is its ability to copy an audio CD and convert the copied audio files to be played on a digital audio device. The steps below will show you how to accomplish this:

  • Insert the audio CD into your computer's CD drive.

Note: If your CD player is set to auto-start, a window titled "Audio CD" pops up. Just select "Take No Action" and click OK.