---
- hosts: OSCp
  gather_facts: False
  tasks: 
  - raw: sudo apt install -y python aptitude

- hosts: oscp
  tasks:

  - name: create folders
    file: 
      path: "{{ item }}"
      state: directory
    with_items:
    - ~/vpn/
    - ~/git/

  - name: deploy openvpn files
    copy:
      src: "{{ item }}" 
      dest: ~/vpn 
      mode: 0400
    with_items:
    - OS-27706-PWK.ovpn
    - oscp.passwd

  - name: apt ppa repos
    apt_repository:
      repo: "{{ item }}"
      state: present
    become: True
    with_items:
    # msf framework apt repos, seriously... get your shit together
    # get it all together, and put it in a backpack all your shit, 
    # so it's together.  and if you got to take it somewhere, 
    # take it somewhere, you know, take it to the shit store and sell it, 
    # or put it in shit museum i dont care what you do, you just got 
    # to get it together. 
    # Get you shit together.
    - deb [trusted=yes] http://downloads.metasploit.com/data/releases/metasploit-framework/apt lucid main
    - ppa:mrazavi/openvas
    - ppa:ricotz/unstable

  - name: add i386 arch (for wine)
    command:
      dpkg --add-architecture i386
    become: True

  - name: apt upgrade
    apt: 
      update_cache: True
      cache_valid_time: 3600
      upgrade: safe
      allow_unauthenticated: True # msf framework ಠ_ಠ  
    become: True

  - name: apt packages
    apt:
      name: "{{ item }}"
      state: latest
      update_cache: True
      cache_valid_time: 3600
      autoremove: True
      allow_unauthenticated: True # msf framework ಠ_ಠ  
    become: True
    with_items:
    # personal
    - htop
    - vim
    - bmon
    # oscp requirements
    - openvpn
    - mtr
    - netcat-traditional
    - nmap # and ncat
    - onesixtyone
    - nbtscan
    - snmp # and snmpcheck
    - whois
    - gdb
    - build-essential
    - libc6-dev-i386
    - mingw-w64
    - wine2.0
    - openjdk-8-jre-headless
    - openjdk-8-jdk-headless
    - atftpd
    - sqlmap
    - cewl
    - john
    - medusa
    - hydra
    - socat
    - cadaver
    - smbclient
    # documentation
    - pandoc
    - texlive-xetex
    # openvas
    - sqlite3
    - openvas
    # metasploit
    - metasploit-framework
    # pwntools
    - python2.7
    - python-pip
    - python-dev
    - git
    - libssl-dev
    - libffi-dev

  - name: pip packages
    pip:
      name: "{{ item }}"
      state: latest
    become: yes
    with_items:
    - pip
    - pwntools
    - pyinstaller
    - httplib2 # fimap



  - name: update alternatives
    alternatives:
      name: nc
      path: /bin/nc.traditional
    become: True
  
  - name: git repos (tools)
    git: 
      repo: "{{ item.repo }}"
      dest: "{{ item.dest }}" 
    become: True
    with_items:
      - {"repo": "https://github.com/byt3bl33d3r/pth-toolkit.git",
         "dest": "/opt/pth-toolkit"}
      - {"repo": "https://github.com/maurosoria/dirsearch.git",
         "dest": "/opt/dirsearch"}
      - {"repo": "https://github.com/offensive-security/exploit-database.git",
         "dest": "/opt/exploit-database"}
      - {"repo": "https://github.com/byt3bl33d3r/pth-toolkit.git",
         "dest": "/opt/pth-toolkit"}
      - {"repo": "https://github.com/kurobeats/fimap.git",
         "dest": "/opt/fimap/"}

  - name: git repos - create symlinks
    file:
      state: link
      src: "{{ item.src }}"
      dest: "{{ item.dest }}"
    become: True
    with_items:
      - {"dest": "/usr/local/bin/pth-net", "src": "/opt/pth-toolkit/pth-net"}
      - {"dest": "/usr/local/bin/pth-smbclient", "src": "/opt/pth-toolkit/pth-smbclient"}
      - {"dest": "/usr/local/bin/pth-rpcclient", "src": "/opt/pth-toolkit/pth-rpcclient"}
      - {"dest": "/usr/local/bin/pth-smbget", "src": "/opt/pth-toolkit/pth-smbget"}
      - {"dest": "/usr/local/bin/pth-winexe", "src": "/opt/pth-toolkit/pth-winexe"}
      - {"dest": "/usr/local/bin/pth-wmic", "src": "/opt/pth-toolkit/pth-wmic"}
      - {"dest": "/usr/local/bin/pth-wmis", "src": "/opt/pth-toolkit/pth-wmis"}
      - {"dest": "/usr/local/bin/dirsearch", "src": "/opt/dirsearch/dirsearch.py"}
      - {"dest": "/usr/local/bin/searchsploit", "src": "/opt/exploit-database/searchsploit"}
      - {"dest": "/usr/local/bin/fimap", "src": "/opt/fimap/src/fimap.py"}

         
  - name: create windows binaries folder
    file: 
      path: /usr/share/windows-biniaries/
      state: directory
      mode: 0755
    become: True
  - name: deploy windows binaries
    unarchive:
      src: http://git.kali.org/gitweb/?p=packages/windows-binaries.git;a=snapshot;h=refs/heads/master;sf=tgz
      dest: /usr/share/windows-biniaries
      extra_opts: ['--strip-components=1', '--show-stored-names'] # magic fu to make it deploy to the dir we want
      remote_src: True 
    become: True

  - name: systemd openvas services
    systemd:
      name: "{{ item }}"
      state: started
    with_items:
    - openvas-scanner
    - openvas-manager
    - openvas-gsa

    #  - name: openvas startup commands
    #    command: "{{ item }}" 
    #    become: True
    #    with_items:
    #    - openvas-nvt-sync
    #    - openvasmd --rebuild
  
  - name: vim setup
    git: 
      repo: "{{ item.repo }}"
      dest: "{{ item.dest }}" 
    with_items:
      - {"repo": "https://github.com/VundleVim/Vundle.vim.git",
         "dest": "~/.vim/bundle/Vundle.vim"}
      - {"repo": "https://github.com/bryfry/home.git",
         "dest": "~/.home"}

  - name: vimrc symlink
    file: 
      src: ~/.home/vimrc 
      dest: ~/.vimrc
      state: link

