Renga's weBlog

December 21, 2009

Windows Command Prompt Tricks

Filed under: Windows — Tags: , , — Renga @ 11:28 AM

Useful Things to do on CMD!

First, open your Network Connection and right click and select Properties. Then Select TCP/IP and click on Properties again. Now Click on Advanced and WINS tab. Select Default for NeBIOS.

Now back to the main Local Area Connection window, select File and Print Sharing for Mic*ft Networks and hit enter………

Windows Vista Wallpaper pack

This is just to make sure you have NetBIOS enabled. We will have some fun with NetBIOS on CMD.
First thing you need to know is some very helpfull commands to use on CMD(Command Prompt).
In case you don’t know how to get CMD open in your box, then click on Start, then Run, then type “cmd” (no quotes, off course… you know the drill).

Back to commands:
nslookup
net view
net use
net user
ping
tracert
arp
route
nbtstat
netstat
ipconfig

1) ping : This command will allow you to know if the host you pinging is alive, which means if it is up at the time of executing the “ping” command.ping x.x.x.x (x is the IP address)
or
ping http://www.whatever.com (www.whatever.com is the website you want to ping, but you don’t know the IP)
OBS: Keep in mind that if the host you pinging is blocking ICMP packets, then the result will be host down.

2) nslookup : This command has many functionalities.One is for resolving DNS into IP.Lets say you know the website URL but you don’t know its IP(and you want to find out).
nslookup http://www.whatever.com (www.whatever.com is the website you want to find out the IP)Now, another really nice function of nslookup is to find out IP of specific Mail Severs
nslookup (enter)
set type=mx (enter)
yahoo.com
This command will give you the mail server IP of yahoo.com. You can use whatever server you want and if it is listed on DNS, then you get the IP. Simple, isn’t it?
OK, now why would you want to have an IP of a mail server?
To send spoofed mail to your friends or even for SE.In case you looking for “How to spoof email”, then look for my “How to spoof email tutorial” http://www.infowar.com/forums/showthread.php?s=&threadid=2360

3) tracert : This command will give you the hops that a packet will travel to reach its final destination.
OBS: This command is good to know the route a packet takes before it goes to the target box.tracert x.x.x.x (x is the IP address)
or
tracert http://www.whatever.com (www.whatever.com is the website you don’t know the IP)

4) arp : This command will show you the arp table. This is good to know if someone is doing arp poisoning in your LAN.arp -a

5) route : This command will show you the routing table, gateway, interface and metric.Code:route print

6) ipconfig : This command will show tons of very helpful things.
Your IP, gateway, dns in use.
Code:
ipconfig
or
Code
:ipconfig /all
this command will give all that info but for all networks you might have it.
Also, in case you have a dynamic IP and want to change it, then type…Code:ipconfig /release (this will release your IP)ipconfig /renew (this will renew your iP)
OBS: Keep in mind that those commands will change your IP, but the new IP will still be tighed up to you. So don’t do anything stupid.

7) netstat : This command will show you connection to your box.
Code:
netstat
or
Code:
netstat -a (this will show you all the listening ports and connection with DNS names)
netstat -n (this will show you all the open connection with IP addresses)
netstat -an (this will combined both of the above)
net view x.x.x.x or computername (will list the available sharing folders on the target box)

Now some hints:
Code:
net use \ipaddressipc$ “” /user:administrator
(this command will allow you to connect to the target box as administrator)
Now if you want to connect to the target box and browse the entire C drive, then use this command:
Code:net use K: \computernameC$
(this will create a virtual drive on your “my computer” folder)
OBS: Keep in mind that this will only works if the target box doesn’t have an administrator password set.
And least but not last, the “help” command.
Quote:whatevercommand /help
or
Quote:whatevercommand /?
This command will help you to understand what it does and all the switchs available for each command.Very useful if you know the command, but forgot the right switch.

Read more: http://www.hackingaday.com/2008/03/command-prompt-tricks.html#ixzz0aIMAraPi

November 24, 2009

PHP – MySQL Working with UTF-8

Filed under: MySQL, PHP — Tags: , , , , , , — Renga @ 9:45 AM

Heres a list of actions you should do in order to get PHP + MySQL working with UTF-8:

1. Database:

CREATE DATABASE db_name
 CHARACTER SET utf8
 DEFAULT CHARACTER SET utf8
 COLLATE utf8_general_ci
 DEFAULT COLLATE utf8_general_ci
 ;

or if the database was already created:

ALTER DATABASE db_name
 CHARACTER SET utf8
 DEFAULT CHARACTER SET utf8
 COLLATE utf8_general_ci
 DEFAULT COLLATE utf8_general_ci
 ;

CREATE TABLE table_name(
 ...
 )
 DEFAULT CHARACTER SET utf8   
 COLLATE utf8_general_ci;

Or if the tables are already created:

ALTER TABLE tbl_name
 DEFAULT CHARACTER SET utf8
 COLLATE utf8_general_ci
 ;

2. Enable this line in php.ini:

extension=php_mbstring.dll

and configure the following in the same file:

mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.encoding_translation = On
mbstring.http_input = auto
mbstring.http_output = UTF-8
mbstring.detect_order = auto
mbstring.substitute_character = none
default_charset = UTF-8

3. Use the following php functions instead:

mail()                -> mb_send_mail()
strlen()              -> mb_strlen()   
strpos()              -> mb_strpos()
strrpos()             -> mb_strrpos()
substr()              -> mb_substr()
strtolower()          -> mb_strtolower()
strtoupper()          -> mb_strtoupper()
substr_count()        -> mb_substr_count()
ereg()                -> mb_ereg()
eregi()               -> mb_eregi()
ereg_replace()        -> mb_ereg_replace()
eregi_replace()       -> mb_eregi_replace()   
split()               -> mb_split()
htmlentities($var)    -> htmlentities($var, ENT_QUOTES, 'UTF-8')

4. Use headers and meta tags like:

header('Content-type: text/html; charset=UTF-8') ;

<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />

5. Before any insert / update in the database you should perform the following:

mysql_query("SET NAMES 'utf8'");

May 30, 2009

Locating Countries from IP addresses

Filed under: PHP — Tags: , , — Renga @ 8:27 PM

1. Converting an IP address to an IP Number

IP address (IPv4 / IPv6) is divided into 4 sub-blocks. Each sub-block has a different weight number each powered by 256. IP number is being used in the database because it is efficient to search between a range of number in database.

Beginning IP number and Ending IP Number are calculated based on following formula:

IP Number = 16777216*w + 65536*x + 256*y + z     (Formula 1)

where
IP Address = w.x.y.z

For example, if IP address is “202.186.13.4″, then its IP Number “3401190660″ is based on the Formula 1.

IP Address = 202.186.13.4

So, w = 202, x = 186, y = 13 and z = 4

IP Number = 16777216*202 + 65536*186 + 256*13 + 4
= 3388997632 + 12189696 + 3328 + 4
= 3401190660

To reverse IP number to IP address,

w = int ( IP Number / 16777216 ) % 256
x = int ( IP Number / 65536    ) % 256
y = int ( IP Number / 256      ) % 256
z = int ( IP Number            ) % 256

where % is the mod operator and int is return the integer part of the division.

2. Retrieving the Country Name and Country Code from the IP Number

Search the IP-COUNTRY TABLE to match a unique record that has the IP number fits between From IP Number and To IP Number.

For example, IP Address “202.186.13.4″ is equivalent to IP Number “3401190660″. It falls in the following range of IP number in the table because it is between the “From IP number” and the “To IP number”.

“3401056256″,”3401400319″,”MY”,”MALAYSIA”

From the IP range, the Country Name is Malaysia and Country Code is MY.

IP-COUNTRY TABLE

From IP Number To IP Number Country Code Country Name
3400892416 3400925183 HK HONG KONG
3400925184 3400933375 TH THAILAND
3400941568 3400949759 AU AUSTRALIA
3400957952 3400966143 AU AUSTRALIA
3400982528 3400990719 HK HONG KONG
3400990720 3400998911 ID INDONESIA
3400998912 3401003007 PH PHILIPPINES
3401007104 3401011199 IN INDIA
3401023488 3401056255 TH THAILAND
3401056256 3401400319 MY MALAYSIA
3401408512 3401416703 HK HONG KONG
3401416704 3401420799 KR KOREA, REPU
3401441280 3401449471 PH PHILIPPINES
3401449472 3401515263 MY MALAYSIA
3401531392 3401539583 IN INDIA
3401547776 3401580543 MY MALAYSIA
3401580544 3402629119 CN CHINA
3402629120 3404464127 JP JAPAN
3405774848 3406434303 AU AUSTRALIA
3406436352 3409969151 AU AUSTRALIA
3409969152 3410755583 TW TAIWAN
3410755584 3410780159 AU AUSTRALIA
3410788352 3410796543 HK HONG KONG
3410796544 3410800639 LK SRI LANKA
3410812928 3410821119 AU AUSTRALIA
3410821120 3410853887 TW TAIWAN
3410853888 3410862079 HK HONG KONG
3410870272 3410874367 IN INDIA
3410878464 3410886655 ID INDONESIA
3410886656 3410887679 TW TAIWAN
3410894848 3410898943 HK HONG KONG
3410903040 3410911231 HK HONG KONG
3410919424 3410927615 IN INDIA
3410944000 3410952191 PH PHILIPPINES
3410952192 3410960383 TW TAIWAN
3410968576 3410984959 NZ NEW ZEALAND
3410984960 3411017727 TW TAIWAN
3411017728 3411018751 HK HONG KONG
3411034112 3411051519 HK HONG KONG
3411058688 3411062783 AU AUSTRALIA
3411066880 3411083775 HK HONG KONG
3411087360 3411091455 CN CHINA
3411091456 3411095551 SG SINGAPORE
3411099648 3411107839 MM MYANMAR
3411116032 3411124223 IN INDIA
3411132416 3411136511 PK PAKISTAN
3411147776 3411149311 HK HONG KONG
3411156992 3411161087 PH PHILIPPINES
3411165184 3411173375 MY MALAYSIA
3411181568 3411189759 JP JAPAN
3411197952 3411202047 BD BANGLADESH
3411213312 3411215359 HK HONG KONG
3411230720 3411247103 HK HONG KONG
3411247104 3411255295 AU AUSTRALIA
3411278848 3411296255 HK HONG KONG
3411312640 3411313151 HK HONG KONG
3411329024 3411337215 PH PHILIPPINES
3411337216 3411341311 AU AUSTRALIA
3411345408 3411411967 HK HONG KONG
3411435520 3411443711 IN INDIA
3411443712 3411460095 HK HONG KONG
3411475456 3411476479 HK HONG KONG
3411476480 3411509247 AU AUSTRALIA
3411509248 3411517439 PH PHILIPPINES
3411525632 3411529727 SG SINGAPORE
3411533824 3411543039 CN CHINA
3411558400 3411566591 AU AUSTRALIA
3411574784 3411582975 IN INDIA
3411591168 3411595263 HK HONG KONG
3411599360 3411607551 AU AUSTRALIA
3411607552 3411608575 CN CHINA
3411623936 3411632127 AU AUSTRALIA
3411640320 3411648511 PK PAKISTAN
3411656704 3411673087 AU AUSTRALIA
3411673088 3411674111 CN CHINA
3411689472 3411701759 IN INDIA
3411722240 3411726335 PH PHILIPPINES
3411730432 3411738623 HK HONG KONG
3411738624 3411739647 CN CHINA
3411755008 3411763199 AU AUSTRALIA
3411771392 3411779583 HK HONG KONG
3411795968 3411804159 AU AUSTRALIA
3411804160 3411805183 CN CHINA
3411820544 3411832831 SG SINGAPORE
3411836928 3411845119 MY MALAYSIA
3411853312 3411857407 IN INDIA
3411861504 3411869695 AU AUSTRALIA
3411869696 3411943423 CN CHINA
3411951616 3411967999 LK SRI LANKA
3411968000 3411984383 AU AUSTRALIA
3411984384 3412000767 IN INDIA
3412000768 3412002815 CN CHINA
3412017152 3412025343 SG SINGAPORE
3412033536 3412066303 TW TAIWAN
3412066304 3412213759 NZ NEW ZEALAND
3412213760 3412221951 AU AUSTRALIA
3412230144 3412246527 HK HONG KONG
3412254720 3412262911 NR NAURU
3412262912 3412273151 NZ NEW ZEALAND
3412279296 3412281343 NZ NEW ZEALAND

May 11, 2009

PHP Tips and Tricks

Filed under: PHP — Tags: , — Renga @ 3:45 PM

1. When you are looking for information on a specific PHP function, go to http://php.net/ . For example: http://php.net/join. That takes you directly to the right place in the online manual on a server geographically near you.

2. Try this: pear install apc . The pear command is a useful installer that can even be used to install PHP extensions written in C. In this case, it would install the APC opcode cache extension.

3. Use an opcode cache to improve performance. See #2.

4. There is nothing wrong with mixing OOP and procedural code in PHP. Use objects when they make sense, and go procedural for the rest.

5. Extending PHP with your own custom C or C++ extensions is easier than you might think. See README.EXT_SKEL in the PHP source distribution.

6. The echo <<

7. PATH_INFO is good! Use it to clean up ugly URLs.

8. Use a profiler, pear install apd.

9. Database abstraction is mostly a myth. There is nothing wrong with direct database calls’ making use of all the tricks and cheats your chosen database has to offer, to tweak as much performance as possible out of it.

10. Keep your base technology and building blocks simple. Stay with a nonthreaded Web server, and avoid complex frameworks and abstraction layers, to give yourself a chance to trace and debug any problems that may come up. Solving the Web problem is simple; don’t try to make it hard.

April 20, 2009

How to create HTTP based user authentication using .htacces

Filed under: PHP — Tags: , , — Renga @ 12:36 PM

How to create HTTP based user authentication using .htacces

1. Create .htacces file under the web folder

# touch /var/www/html/.htaccess

2. Add the below conten in /var/www/html/.htaccess

AuthType Basic
AuthName “phpMyAdmin”
AuthUserFile /var/www/html/.htpasswd
Require valid-user
AuthGroupFile /dev/null

require valid-user

3. Create password file

# touch /var/www/html/.htpasswd

4. Add user

# htpasswd -c /var/www/html/.htpasswd

Older Posts »

Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.