PDA

View Full Version : Basic Commands



g0tmi1k
2014-03-22, 11:05
Table of Contents
Basic commands for:

Opertating System (OS) (https://forums.kali.org/showthread.php?20807-Basic-Commands&p=32649&viewfull=1#post32649)
Networking (https://forums.kali.org/showthread.php?20807-Basic-Commands&p=32652&viewfull=1#post32652)
Hardware (https://forums.kali.org/showthread.php?20807-Basic-Commands&p=32659&viewfull=1#post32659)
Wi-Fi (https://forums.kali.org/showthread.php?20807-Basic-Commands&p=33038&viewfull=1#post33038)





Basic commands for the Opertating System (OS)
**QUICK**

id; uname -a; lsb_release -a



id (man page (http://www.linuxmanpages.com/man1/id.1.php))
Displays the user who executed the program.

root@kali:~# id
uid=0(root) gid=0(root) groups=0(root)
root@kali:~#



uname -a (man page (http://www.linuxmanpages.com/man1/uname.1.php))
Displays the kernel name, hostname, kernel release, kernel version, machine name, processor (if known), hardware (if known) and operating system.

root@kali:~# uname -a
Linux kali 4.9.0-kali3-686-pae #1 SMP Debian 4.9.18-1kali1 (2017-04-04) i686 GNU/Linux
root@kali:~#


lsb_release -a (man page (http://www.linuxmanpages.com/man1/lsb_release.1.php))
Displays which version of Kali-Linux is currently installed

root@kali:~# lsb_release -a
No LSB modules are available.
Distributor ID: Kali
Description: Kali GNU/Linux Rolling
Release: kali-rolling
Codename: kali-rolling
root@kali:~#

g0tmi1k
2014-03-22, 11:31
Basic commands for networking
**QUICK**

ifconfig; route -n; cat /etc/resolv.conf; cat /etc/network/interfaces; cat /etc/hosts


ifconfig (man page (http://www.linuxmanpages.com/man8/ifconfig.8.php))
Displays various bits of information about the NIC (e.g. IP addresses, subnet, MAC address etc).
Note: ifconfig -a, will display information about ALL NICs (including the ones that are currently down).

root@kali:~# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0b:29:9c:c9:b3
inet addr:192.168.1.23 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:ff9b:c9a3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:292216 errors:0 dropped:0 overruns:0 frame:0
TX packets:135628 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:431730275 (411.7 MiB) TX bytes:7398306 (7.0 MiB)
Interrupt:19 Base address:0x2000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:26 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1648 (1.6 KiB) TX bytes:1648 (1.6 KiB)

root@kali:~#

You can also alter the state of the NIC by place it in either 'down' or 'up' state, which disables or enables the NIC


root@kali ~$ ifconfig eth0 down
root@kali ~$ ping -c 1 google.com
ping: unknown host google.com
root@kali ~$ ifconfig eth0 up
root@kali ~$ ping -c 1 google.com
PING google.com (62.252.173.153) 56(84) bytes of data.
64 bytes from m409-mp1-cvx1c.lan.ntl.com (62.252.173.153): icmp_req=1 ttl=128 time=18.0 ms

--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 18.061/18.061/18.061/0.000 ms
root@kali ~$



route -n (man page (http://www.linuxmanpages.com/man8/route.8.php))
Displays the routing table (gateways information)

root@kali:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.2 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
root@kali:~#



cat /etc/resolv.conf (man page (http://www.linuxmanpages.com/man5/resolv.conf.5.php))
Displays the DNS information

root@kali:~# cat /etc/resolv.conf
# Generated by NetworkManager
domain localdomain
search localdomain
nameserver 192.168.1.2
root@kali:~#


cat /etc/network/interfaces (more information (http://www.cyberciti.biz/faq/setting-up-an-network-interfaces-file/))
Displays the network interface configuration
Note: eth0 is setup to use DHCP.

root@kali:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
root@kali:~#


cat /etc/hosts (man page (http://www.linuxmanpages.com/man5/hosts.5.php))
Static values for hostname lookups
Note: Editing these values, will NOT change your hostname (for that look into hostname & /etc/hostname).

root@kali:~# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 kali-offsec

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@kali:~#

g0tmi1k
2014-03-22, 14:03
Basic commands for hardware
**QUICK**

lspci; lsusb; dmesg; lsmod


lspci (man page (http://www.linuxmanpages.com/man8/lspci.8.php))
List all PCI devices (e.g. Internal devices).

root@kali:~# lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)
00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
00:11.0 PCI bridge: VMware PCI bridge (rev 02)
00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:15.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:16.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:17.7 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.0 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.1 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.2 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.3 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.4 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.5 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.6 PCI bridge: VMware PCI Express Root Port (rev 01)
00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)
02:00.0 USB controller: VMware USB1.1 UHCI Controller
02:01.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
02:02.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)
02:03.0 USB controller: VMware USB2 EHCI Controller
02:05.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
root@kali:~#


lsusb (man page (http://www.linuxmanpages.com/man8/lsusb.8.php))
List all USB devices (e.g. External devices).

root@kali:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@kali:~#


dmesg (man page (http://www.linuxmanpages.com/man8/dmesg.8.php))
Displays the contents of the kernel buffer (Whats in the kernel log).
Note: Warning, this may produce a very large output

root@kali:~# dmesg
[ 0.000000] Initializing cgroup subsys cpuset
[ 0.000000] Initializing cgroup subsys cpu
[ 0.000000] Initializing cgroup subsys cpuacct
[ 0.000000] Linux version 3.12-kali1-686-pae ([email protected]) (gcc version 4.7.2 (Debian 4.7.2-5) ) #1 SMP Debian 3.12.6-2kali1 (2014-01-06)
[ 0.000000] Disabled fast string operations
...snip...
[ 3.367400] EXT4-fs (sda1): re-mounted. Opts: (null)
[ 3.407412] EXT4-fs (sda1): re-mounted. Opts: errors=remount-ro
[ 3.499360] loop: module loaded
[ 4.180582] Netfilter messages via NETLINK v0.30.
[ 4.350865] pcnet32 0000:02:01.0 eth0: link up
[ 5.224520] pcnet32 0000:02:05.0 eth1: link up
[ 7.826665] [drm] width 1024
[ 7.826704] [drm] height 768
[ 7.826716] [drm] bpp 32
[ 7.826771] [drm] Fifo max 0x00200000 min 0x00001000 cap 0x0000077f
[ 7.843755] [drm] width 1024
[ 7.843764] [drm] height 768
[ 7.843771] [drm] bpp 32
[ 7.843827] [drm] Fifo max 0x00200000 min 0x00001000 cap 0x0000077f
[ 187.769500] sda1: WRITE SAME failed. Manually zeroing.
root@kali:~#


lsmod (man page (http://www.linuxmanpages.com/man8/lsmod.8.php))
Displays the status of modules in the Linux Kernel (e.g. what drivers have been loaded)

root@kali:~# lsmod
Module Size Used by
nfnetlink_log 17065 0
nfnetlink 12853 1 nfnetlink_log
binfmt_misc 12733 1
loop 21962 0
dm_crypt 22008 0
hid_generic 12369 0
usbhid 39684 0
hid 80998 2 hid_generic,usbhid
vmw_balloon 12502 0
psmouse 76538 0
serio_raw 12737 0
coretemp 12734 0
evdev 17172 4
parport_pc 25991 0
parport 35171 1 parport_pc
processor 27662 0
battery 12949 0
ac 12588 0
thermal_sys 22960 1 processor
snd_ens1371 22679 2
snd_ac97_codec 96188 1 snd_ens1371
snd_rawmidi 22278 1 snd_ens1371
snd_seq_device 12980 1 snd_rawmidi
snd_pcm 69436 2 snd_ac97_codec,snd_ens1371
snd_page_alloc 12882 1 snd_pcm
snd_timer 22002 1 snd_pcm
vmwgfx 109623 1
snd 50767 10 snd_ac97_codec,snd_timer,snd_pcm,snd_rawmidi,snd_e ns1371,snd_seq_device
soundcore 12890 1 snd
button 12824 0
ac97_bus 12462 1 snd_ac97_codec
gameport 13316 1 snd_ens1371
ttm 55536 1 vmwgfx
drm 198264 3 ttm,vmwgfx
i2c_piix4 12592 0
i2c_core 23371 2 drm,i2c_piix4
shpchp 30673 0
vmw_vmci 54642 0
ext4 442562 1
crc16 12327 1 ext4
mbcache 12938 1 ext4
jbd2 73110 1 ext4
dm_mod 78673 1 dm_crypt
sr_mod 21563 0
cdrom 34540 1 sr_mod
sg 25628 0
ata_generic 12450 0
sd_mod 43598 3
crct10dif_generic 12517 1
crc_t10dif 12399 1 sd_mod
crct10dif_common 12340 2 crct10dif_generic,crc_t10dif
crc32_pclmul 12809 0
crc32c_intel 12659 0
aesni_intel 17934 0
aes_i586 16647 1 aesni_intel
xts 12583 1 aesni_intel
lrw 12645 1 aesni_intel
gf128mul 12834 2 lrw,xts
ablk_helper 12508 1 aesni_intel
cryptd 14160 1 ablk_helper
floppy 51966 0
ehci_pci 12432 0
uhci_hcd 26356 0
ehci_hcd 43677 1 ehci_pci
pcnet32 34875 0
usbcore 137931 4 uhci_hcd,ehci_hcd,ehci_pci,usbhid
mii 12595 1 pcnet32
usb_common 12408 1 usbcore
ata_piix 29336 0
libata 153595 2 ata_generic,ata_piix
mptspi 21663 2
scsi_transport_spi 23201 1 mptspi
mptscsih 22262 1 mptspi
mptbase 68288 2 mptspi,mptscsih
scsi_mod 151284 7 sg,scsi_transport_spi,libata,mptspi,sd_mod,sr_mod, mptscsih
root@kali:~#

g0tmi1k
2014-04-07, 09:58
Basic commands for Wi-Fi troubleshooting
**QUICK**

airmon-ng --verbose; rfkill list; iwconfig





Please also see 'hardware (https://forums.kali.org/showthread.php?20807-Basic-Commands&p=32659&viewfull=1#post32659)'.




airmon-ng --verbose
A modified version of airmon-ng, which helps with troubleshooting and monitor mode.


root@kali ~$ airmon-ng --verbose

Linux kali 3.12-kali1-686-pae #1 SMP Debian 3.12.6-2kali1 (2014-01-06) i686 GNU/Linux
Detected VM using lscpu
This appears to be a VMware Virtual Machine
If your system supports VT-d, it may be possible to use PCI devices
If your system does not support VT-d, you can only use USB wifi cards

K indicates driver is from 3.12-kali1-686-pae
V indicates driver comes directly from the vendor, almost certainly a bad thing
S indicates driver comes from the staging tree, these drivers are meant for reference not actual use, BEWARE
? indicates we do not know where the driver comes from... report this


X[PHY]Interface Driver[Stack]-FirmwareRev Chipset Extended Info

K[phy0]wlan0 rt73usb[mac80211]-1.7 Linksys WUSB54GC v1 802.11g Adapter [Ralink RT73]

root@kali ~$

By using the "--verbose", airmon-ng provide a large amount of very useful information when trying to troubleshoot 802.11 NIC issues.


rfkill (man page (http://linux.die.net/man/1/rfkill))
Enables (and disables) wireless devices.


root@kali ~$ rfkill list
2: phy2: Wireless LAN
Soft blocked: no
Hard blocked: no
root@kali ~$



iwconfig (man page (http://www.linuxmanpages.com/man8/iwconfig.8.php))
Displays & controls 802.11 NICs.


root@kali ~$ iwconfig
wlan0 IEEE 802.11bg ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:on

root@kali ~$



airmon-ng (man page (http://linux.die.net/man/1/airmon-ng))
Automates turning wireless cards into monitor mode


root@kali ~$ airmon-ng


Interface Chipset Driver

wlan0 Ralink 2573 USB rt73usb - [phy1]

root@kali ~$

Note: "airmon-ng --verbose" displays the same amount of information and more.