aboutsummaryrefslogtreecommitdiff
path: root/old/attackbox/tasks/tor_install.yaml
blob: 54f83844f7e8d79bdc2c6df8395ed5bccd8fea5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
- name: install tor and required packages
  apt:
    name:
      - tor
      - tor-geoipdb
      - torsocks
      - proxychains
    state: present
    update_cache: yes

- name: check if /etc/tor/torrc exists
  stat:
    path: /etc/tor/torrc
  register: torrc_stat

- name: back up /etc/tor/torrc
  copy:
    src: /etc/tor/torrc
    dest: /etc/tor/torrc.bak
    remote_src: yes
    force: no
  when:
    - torrc_stat.stat.exists

- name: deploy custom tor configuration
  template:
    src: templates/torrc.j2
    dest: /etc/tor/torrc
    owner: debian-tor
    group: debian-tor
    mode: '0644'
  notify: restart tor

- name: check if tor is routing traffic correctly
  command: curl --socks5-hostname 127.0.0.1:9050 https://check.torproject.org/api/ip
  register: tor_check
  changed_when: false

- name: print tor check json response
  debug:
    msg: "tor check response: {{ tor_check.stdout }}"

- name: verify tor is active
  fail:
    msg: "tor is not routing traffic correctly: istor is {{ tor_check.stdout | from_json | json_query('IsTor') }}"
  when:
    - tor_check.stdout | from_json | json_query('IsTor') != true