Friday, November 30, 2012

DOS/Windows Commans


Below, you’ll find a list of the most common IP commands for Windows and DOS. These include ipconfig, trace route, netstat, arp, route, hostname, control netconnections, and other popular DOS and Windows IP commands.
Display Connection Configuration: ipconfig /all
Display DNS Cache Info: ipconfig /displaydns
Clear DNS Cache: ipconfig /flushdns
Release All IP Address Connections: ipconfig /release
Renew All IP Address Connections: ipconfig /renew


Re-Register the DNS connections: ipconfig /registerdns
Change/Modify DHCP Class ID: ipconfig /setclassid
Network Connections: control netconnections
Network Setup Wizard: netsetup.cpl
Test Connectivity: ping whatismyip.com
Trace Route: tracert
Displays the TCP/IP protocol sessions: netstat
Display Local Route: route
Display Resolved MAC Addresses: arp
Display Name of Computer Currently on: hostname
Display DHCP Class Information: ipconfig /showclassid
NameServer Lookup: nslookup whatismyip.com


Tuesday, November 27, 2012

Linux creating CD-ROM ISO image


dd is a perfect tool for copy a file, converting and formatting according to the operands. It can create exact CD-ROM ISO image.
This is useful for making backup as well as for hard drive installations require a working the use of ISO images.

How do I use dd command to create an ISO image?

Put CD into CDROM
Do not mount CD. Verify if cd is mounted or not with mount command:
# mount
If cd was mouted automatically unmout it with umount command:
# umount /dev/cdrom
OR
# umount /mnt/cdrom
Create CD-ROM ISO image with dd command:
# dd if=/dev/cdrom of=/tmp/cdimg1.iso
Where,
  • if=/dev/cdrom: Read from /dev/cdrom (raw format)
  • of=/tmp/cdimg1.iso: write to FILE cdimg1.iso i.e. create an ISO image
Now you can use cdimg1.iso for hard disk installation or as a backup copy of cd. Please note that dd command is standard UNIX command and you should able to create backup/iso image under any UNIX like operating system.

How to Disable / Restrict Use of USB Storage Devices in Windows?


Many times we want to restrict users from using USB drives in our systems. Suppose you have some important data and a friend comes and takes the data in his USB drive. This tutorial will help you in completely disable the use of USB drives in system.
After applying this tutorial, users will not be able to use USB drives. Windows will not detect it.
The tutorial is divided into 2 parts:
  • If the USB storage device is not installed in system
  • If the USB storage device is already installed in system
So lets start this tutorial:
If the USB storage device is not installed in system:
1. Type %windir%\inf in Explorer addressbar or RUN dialog box and press Enter. It'll open "inf" folder.
2. Now look for following 2 files:
  • usbstor.inf
  • usbstor.pnf
3. Now you have to change their user permissions setting. Do as following for each file:
Right-click on the file and select "Properties". Go to "Security" tab and select the desired user or group in "Group or user names" list which you want to restrict from using USB drives. Now in "Permissions for Users" list, click on "Deny" checkbox next to "Full control" option and then click on OK.
Change_Permissions_for_usbstor_file.jpg
NOTE: In Windows Vista, you'll have to click on "Edit" button after selecting the user or group in "Group or user names" list and then again select the same user or group in new dialog box. Now you can click on "Deny" checkbox.
4. That's it. Now users will not be able to install any USB storage device in system.
If the USB storage device is already installed in system:
1. Type regedit in RUN dialog box and press Enter. Now go to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
2. In right-side pane, change value of "Start" to 4
Change_Start_Value_for_USBStor_in_R.jpg
3. Now whenever a user will attach a USB storage device which is already installed in system, Windows will not detect it and it'll not be shown in My Computer.
NOTE: If you want to revert it back to default, then change the value of "Start" to 3
BONUS TIP: If you want to restrict only writing to USB storage devices, then take a look at Point 21 in following tutorial:

Monday, November 26, 2012

Some random shell tips and tricks.

Some random shell tips and tricks. 

Display all established ssh connection. Replace ssh with http / other protocols:

ss -o state established '( dport = :ssh or sport = :ssh )' 
ss -o state established '( dport = :http or sport = :http )'
See http://www.cyberciti.biz/tips/linux-investigate-sockets-network-connections.html

Reboot your wireless or home router from the command line without login using a browser (replace user:pass and ip/url as per your router make and model):
curl -u 'USER:PASS' 'http://192.168.1.154/setup.cgi?todo=reboot'

Count number of open files per user. In this case count for the Apache user:
lsof -u apache | wc -l
lsof -u root | wc -l

Software speech synthesizer i.e. text to speech:
espeak "1 2 3"
espeak "This is a test."

Pass the --reason parameter to nmap command to see the reason why a port is considered to be in the given state such as closed / open and so on:
nmap --reason ip-here
nmap --reason your.example.com