Kali Fu

Scripting

Bash

Grep

  • -i : Case insensitive

  • -R :Recursive

grep -iR filename .

#Prints line beginning with keyword, along with the next 3 lines.
grep -A 3 '^passwd' {} \*

awk

#Default
awk '{print}' employee.txt

#Print the lines which matches with the given pattern. 
awk '/manager/ {print}' employee.txt 

#Splitting a Line Into Fields
#Each word in a line,split by a whitespace is stored in $n)
awk '{print $1,$4}' employee.txt 
smbclient \\\\10.10.10.192\\profiles$ -u guest -c ls | awk '{print $1}'

Compare files

  • comm : outputs three space-offset columns:

    • Lines that are unique to the first file or argument(1)

    • Lines that are unique to the second file or argument(2)

    • Lines that are shared by both files.(3)

comm filea.txt fileb.txt
#Cisplay only the lines that were found in both files since we 
#suppressed the first and second columns.
comm -12 filea.txt fileb.txt
  • diff:

    • context format (-c) and the unified format (-u) [unified format does not show common lines]

    • “-” indicator to show that the line appears in the first file, but not in the second.

    • “+” indicator shows that the line appears in the second file, but not in the first.

kali@kali:~$ diff -c scan-a.txt scan-b.txt 
*** scan-a.txt  2018-02-07 14:46:21.557861848 -0700 
--- scan-b.txt  2018-02-07 14:46:44.275002421 -0700 
*************** 
*** 1,5 **** 
  192.168.1.1 
- 192.168.1.2 
  192.168.1.3 
  192.168.1.4 
  192.168.1.5 
--- 1,5 ---- 
  192.168.1.1 
  192.168.1.3 
  192.168.1.4 
  192.168.1.5 
+ 192.168.1.6 
 
kali@kali:~$ diff -u scan-a.txt scan-b.txt 
--- scan-a.txt  2018-02-07 14:46:21.557861848 -0700 
+++ scan-b.txt  2018-02-07 14:46:44.275002421 -0700 
@@ -1,5 +1,5 @@ 
 192.168.1.1 
-192.168.1.2 
 192.168.1.3 
 192.168.1.4 
 192.168.1.5 
+192.168.1.6 
  • vimdiff

vimdiff opens vim68 with multiple files, one in each window. The differences between files are highlighted, which makes it easier to visually inspect them.

  • do: gets changes from the other window into the current one

  • dp: puts the changes from the current window into the other one

  • ] + c: jumps to the next change

  • [ + c: jumps to the previous change •

  • Ctrl+ W: switches to the other split window.

Python Fu

Virtual Environments

pip install virtualenv
python -m venv env
source env/bin/activate

Pyenv

  • Installation Guide : Here

#Install Dependencies
sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev

#Install pyenv
curl https://pyenv.run | bash

#Set up environment variables - Append the below code to $HOME/.zshrc & run "source $HOME/.zshrc"
----
## pyenv configs
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init --path)"
fi
----

#Install required python versions
~/.pyenv/bin/pyenv install -l
~/.pyenv/bin/pyenv install <version>
echo "<version>" > ~/.pyenv/version

Vmware Configure Shared Folders

  • Enable sharing in Vmware settings.

  • Enable sharing on folder properties on Windows host.

  • In Kali : sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/ -o allow_other

Last updated