Skip to main content

0302 | Setup

How to install VirtualBox

  • simple default install

How to install Kali Linux

  • download iso from "Bare Metal" | Installer 64
  • VirtualBox | Kali settings
    • RAM: 2GB
    • Disk: 40GB
  • Kali install settings
    • graphical install
    • user:notroot | pwd:notroot
    • use defaults for partitions -- no separate for /var ...
    • install grub boot loader
  • Devices>Shared Clipboard>Bidirectional
  • Devices>Drag and Drop>Bidirectional

The Python interpreter

  • start the python interpreter
    • python3
  • or start version 2
    • python2
  • check cli options
    • man python3
  • print hello world
    • python3 -c 'print("hello world")'
  • spawn a bash shell
    • python3 -c 'import pty; pty.spawn("/bin/bash");'

How to run a Python script

  • example | "calculate-demo.py"
    #!/bin/python3

    print(1 + 1)
    print(__name__)

    if __name__ == "__main__":
    print("do something")
  • running it (python3)
    • python3 calculate-demo.py
  • running it (python2)
    • python2 calculate-demo.py
  • or with shebang
    • place it on the first line
      • #!/bin/python3
    • make script executable
      • chmod +x calculate-demo.py
    • run the script
      • ./calculate-demo.py
  • main program | __name__ == "__main__":
    • if the interpreter is running the current file as the main program --> __name__ is set to __main__
    • if the file is being imported from somewhere else --> __name__ is set as the imported modules name

How to install Sublime

  • navigate to "sublimetext.com"
  • download for linux
  • install instructions
    wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/sublimehq-archive.gpg > /dev/null
    # select the channel to use
    echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
    # update sources and install
    sudo apt-get update
    sudo apt-get install sublime-text
  • start sublime
    • subl calculate-demo.py

Python syntax

  • example | "syntax-demo.py"

    def test():
    print("test")

    print("test2")

    string = "string"
    number = 10

    test()

    x = 1 + 2 \
    + 3

    print(x)

    y = 1 + 1
    print(y)
  • python indentation is used to indicate a code block

  • at least 1 space | here: double spacing

  • but it must be the same everywhere

  • blank lines are ignored by python

  • \ for multi line

  • looking for help --> built-in help

    • python3 > help(print)
    • dir(print) --> the list of attributes or defined symbols for the function
  • use the PEP 8 | Style Guide