-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Kali backport #180
Open
josephcardillo-akamai
wants to merge
14
commits into
akamai-compute-marketplace:develop
Choose a base branch
from
josephcardillo-akamai:kali-backport
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add Kali backport #180
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
79239ab
kali initial commit
josephcardillo-akamai 797d56b
fix typo in deploy script
josephcardillo-akamai 7882d91
kali linux tasks
josephcardillo-akamai e478dd2
uncomment vnc tasks
josephcardillo-akamai 559023e
cleanup
josephcardillo-akamai 4c83c26
Merge branch 'develop' into kali-backport
josephcardillo-akamai 742f791
Update Kali README
josephcardillo-akamai 47871e0
Update stackscript to be non-interactive
josephcardillo-akamai 5b3cb0d
Merge branch 'develop' into kali-backport
josephcardillo-akamai 9ff175b
revise deploy script
josephcardillo-akamai 4133cfd
cleanup
josephcardillo-akamai 198ccf2
remove everything related to domain/ssl since kali doesn't have a pub…
josephcardillo-akamai ce461d7
fix unbalanced quotes
josephcardillo-akamai 9f43fca
cleanup
josephcardillo-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
skip_list: | ||
- command-instead-of-shell | ||
- no-changed-when | ||
- no-jinja-when | ||
- fqcn-builtins | ||
exclude_paths: | ||
- .cache/ | ||
- .github/ | ||
- tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
# Based on ansible-lint config | ||
extends: default | ||
|
||
ignore: | | ||
.github/* | ||
.cache/* | ||
tests/* | ||
|
||
rules: | ||
braces: | ||
max-spaces-inside: 1 | ||
level: error | ||
brackets: | ||
max-spaces-inside: 1 | ||
level: error | ||
colons: | ||
max-spaces-after: -1 | ||
level: error | ||
commas: | ||
max-spaces-after: -1 | ||
level: error | ||
comments: disable | ||
comments-indentation: disable | ||
document-start: disable | ||
empty-lines: | ||
max: 3 | ||
level: error | ||
hyphens: | ||
level: error | ||
indentation: disable | ||
key-duplicates: enable | ||
line-length: disable | ||
new-line-at-end-of-file: disable | ||
new-lines: | ||
type: unix | ||
trailing-spaces: disable | ||
truthy: disable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Linode Kali Deployment One-Click APP | ||
|
||
|
||
|
||
## Software Included | ||
|
||
| Software | Version | Description | | ||
| :--- | :---- | :--- | | ||
| Kali | latest | | | ||
|
||
**Supported Distributions:** | ||
|
||
- Ubuntu 22.04 LTS | ||
|
||
## Linode Helpers Included | ||
|
||
| Name | Action | | ||
| :--- | :--- | | ||
| Hostname | The Hostname module uses `dnsdomainname -A` to detect the Linode's FQDN and write to the `/etc/hosts` file. This defaults to the Linode's automatically assigned rDNS. To use a custom FQDN see [Configure your Linode for Reverse DNS](https://www.linode.com/docs/guides/configure-your-linode-for-reverse-dns/). | | ||
| Update Packages | The Update Packages module performs apt update and upgrade actions as root. | | ||
| UFW | The UFW module will utilize a list generated by `linode_helpers/ufw/ufwgen.yml` in the `group_vars/linode/vars` and enables the service. | | ||
| Fail2Ban | The Fail2Ban module installs, activates and enables the Fail2Ban service. | | ||
|
||
## Use our API | ||
|
||
Customers can choose to the deploy the Kali app through the Linode Marketplace or directly using API. Before using the commands below, you will need to create an [API token](https://www.linode.com/docs/products/tools/linode-api/get-started/#create-an-api-token) or configure [linode-cli](https://www.linode.com/products/cli/) on an environment. | ||
|
||
Make sure that the following values are updated at the top of the code block before running the commands: | ||
- TOKEN | ||
- ROOT_PASS | ||
|
||
SHELL: | ||
``` | ||
export TOKEN="YOUR API TOKEN" | ||
export ROOT_PASS="aComplexP@ssword" | ||
export SOA_EMAIL_ADDRESS="[email protected]" | ||
|
||
curl -H "Content-Type: application/json" \ | ||
-H "Authorization: Bearer ${TOKEN}" \ | ||
-X POST -d '{ | ||
"backups_enabled": true, | ||
"swap_size": 512, | ||
"image": "linode/ubuntu2204", | ||
"root_pass": "${ROOT_PASS}", | ||
"stackscript_id": 00000000000, | ||
"stackscript_data": { | ||
"disable_root": "no/yes", | ||
"soa_email_address": "${SOA_EMAIL_ADDRESS}" | ||
}, | ||
"authorized_users": [ | ||
"myUser", | ||
"secondaryUser" | ||
], | ||
"booted": true, | ||
"label": "linode123", | ||
"type": "g6-standard-2", | ||
"region": "us-east", | ||
"group": "Linode-Group" | ||
}' \ | ||
https://api.linode.com/v4/linode/instances | ||
``` | ||
|
||
CLI: | ||
``` | ||
export TOKEN="YOUR API TOKEN" | ||
export ROOT_PASS="aComplexP@ssword" | ||
export SOA_EMAIL_ADDRESS="[email protected]" | ||
|
||
linode-cli linodes create \ | ||
--label linode123 \ | ||
--root_pass ${ROOT_PASS} \ | ||
--booted true \ | ||
--stackscript_id 00000000000 \ | ||
--stackscript_data '{"soa_email_address": "${SOA_EMAIL_ADDRESS}", "disable_root": "no/yes" }' \ | ||
--region us-east \ | ||
--type g6-standard-2 \ | ||
--authorized_keys "ssh-rsa AAAA_valid_public_ssh_key_123456785== user@their-computer" | ||
--authorized_users "myUser" | ||
--authorized_users "secondaryUser" | ||
``` | ||
|
||
## Resources | ||
|
||
- [Create Linode via API](https://www.linode.com/docs/api/linode-instances/#linode-create) | ||
- [Stackscript referece](https://www.linode.com/docs/guides/writing-scripts-for-use-with-linode-stackscripts-a-tutorial/#user-defined-fields-udfs) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[defaults] | ||
host_key_checking = False | ||
enable_plugins = linode | ||
deprecation_warnings = False | ||
interpreter_python = /usr/bin/python3 | ||
roles_path=./roles:../linode_helpers/roles | ||
# relative or absolute roles_paths are required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
collections: | ||
- name: linode.cloud | ||
version: 0.16.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
# kali | ||
- name: Setting up environment | ||
hosts: localhost | ||
connection: local | ||
any_errors_fatal: true | ||
user: root | ||
vars_files: | ||
- group_vars/linode/vars | ||
tasks: | ||
- name: Generating sudo user and password | ||
import_tasks: ../linode_helpers/roles/sudouser/tasks/main.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ansible==8.3.0 | ||
ansible-lint==6.18.0 | ||
linode-api4==5.9.0 | ||
dnspython==2.4.2 | ||
pyyaml==6.0.1 | ||
pexpect==4.8.0 | ||
jmespath==1.0.1 |
Empty file.
37 changes: 37 additions & 0 deletions
37
apps/linode-marketplace-kali-linux/roles/common/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
# set_hostname | ||
- name: setting up hostname | ||
import_role: | ||
name: hostname | ||
|
||
- name: set ssh pubkey | ||
import_role: | ||
name: sshkey | ||
|
||
- name: write _domain to vars | ||
lineinfile: | ||
insertafter: EOF | ||
path: group_vars/linode/vars | ||
line: | | ||
_domain: {{ _domain }} | ||
when: _domain is defined | ||
|
||
- name: secure ssh | ||
import_role: | ||
name: securessh | ||
when: disable_root is defined | ||
|
||
- name: update system packages | ||
import_role: | ||
name: update_pkgs | ||
|
||
- name: enabling ufw | ||
import_role: | ||
name: ufw | ||
|
||
- name: apply ufw rules | ||
import_tasks: ufw_rules.yml | ||
|
||
- name: enabling fail2ban | ||
import_role: | ||
name: fail2ban_install |
20 changes: 20 additions & 0 deletions
20
apps/linode-marketplace-kali-linux/roles/common/tasks/ufw_rules.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
# set app specific ufw rules | ||
- name: Allow all access to tcp port 22 | ||
community.general.ufw: | ||
rule: allow | ||
port: '22' | ||
proto: tcp | ||
|
||
# allow certbot | ||
- name: Allow all access to tcp port 80 | ||
community.general.ufw: | ||
rule: allow | ||
port: '80' | ||
proto: tcp | ||
|
||
- name: Allow all access to tcp port 443 | ||
community.general.ufw: | ||
rule: allow | ||
port: '443' | ||
proto: tcp |
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions
36
apps/linode-marketplace-kali-linux/roles/kali/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
- name: Add non-free repository | ||
apt_repository: | ||
repo: deb http://http.kali.org/kali kali-rolling main contrib non-free non-free-firmware | ||
state: present | ||
filename: kali-nonfree | ||
|
||
- name: Update apt cache | ||
apt: | ||
update_cache: yes | ||
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove this task. This is redundant with the next task. |
||
|
||
- name: Install firmware-misc-nonfree | ||
apt: | ||
name: firmware-misc-nonfree | ||
state: present | ||
update_cache: yes | ||
environment: | ||
DEBIAN_FRONTEND: noninteractive | ||
|
||
- name: Fix broken packages | ||
apt: | ||
clean: true | ||
autoclean: true | ||
autoremove: true | ||
environment: | ||
DEBIAN_FRONTEND: noninteractive | ||
|
||
- name: Install Kali Linux | ||
apt: | ||
name: "{{ kali_package }}" | ||
state: present | ||
when: kali_package is defined | ||
|
||
- name: Set up VNC | ||
import_tasks: vnc_setup.yml | ||
when: vnc_enabled | bool |
44 changes: 44 additions & 0 deletions
44
apps/linode-marketplace-kali-linux/roles/kali/tasks/vnc_setup.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
- name: Install XFCE and VNC packages | ||
apt: | ||
name: | ||
- xfce4 | ||
- xfce4-goodies | ||
- dbus-x11 | ||
- tigervnc-standalone-server | ||
- expect | ||
state: present | ||
|
||
- name: Create VNC user | ||
user: | ||
name: "{{ vnc_username }}" | ||
password: "{{ vnc_password | password_hash('sha512') }}" | ||
shell: /bin/bash | ||
|
||
- name: Set up VNC password | ||
expect: | ||
command: vncserver | ||
responses: | ||
Password: "{{ vnc_password }}" | ||
Verify: "{{ vnc_password }}" | ||
"Would you like to enter a view-only password (y/n)?": "n" | ||
become: yes | ||
become_user: "{{ vnc_username }}" | ||
Comment on lines
+12
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This output to the log. Use no_log to avoid leaking secrets to the stackscript log. |
||
|
||
- name: Kill VNC process | ||
shell: | | ||
killall Xtigervnc | ||
ignore_errors: yes | ||
|
||
- name: Create VNC service file | ||
template: | ||
src: [email protected] | ||
dest: /etc/systemd/system/[email protected] | ||
mode: '0644' | ||
|
||
- name: Start and enable VNC service | ||
systemd: | ||
name: [email protected] | ||
state: started | ||
enabled: yes | ||
daemon_reload: yes |
Empty file.
16 changes: 16 additions & 0 deletions
16
apps/linode-marketplace-kali-linux/roles/kali/templates/[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[Unit] | ||
Description=Start TigerVNC server at startup | ||
After=syslog.target network.target | ||
|
||
[Service] | ||
Type=forking | ||
User={{ vnc_username }} | ||
Group={{ vnc_username }} | ||
WorkingDirectory=/home/{{ vnc_username }} | ||
|
||
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1 | ||
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i | ||
ExecStop=/usr/bin/vncserver -kill :%i | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
14 changes: 14 additions & 0 deletions
14
apps/linode-marketplace-kali-linux/roles/post/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
# motd and creds gen | ||
- name: copy MOTD template to /etc/motd | ||
template: | ||
src: templates/motd.j2 | ||
dest: /etc/motd | ||
|
||
- name: writing credentials into file | ||
template: | ||
src: templates/credentials.j2 | ||
dest: '/home/{{ username }}/.credentials' | ||
mode: '0600' | ||
owner: '{{ username }}' | ||
group: '{{ username }}' |
13 changes: 13 additions & 0 deletions
13
apps/linode-marketplace-kali-linux/roles/post/templates/credentials.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Sudo Credentials: | ||
Username: {{ username }} | ||
Password: {{ password }} | ||
|
||
{% if vnc_enabled | bool %} | ||
VNC Credentials: | ||
Username: {{ vnc_username }} | ||
Password: {{ vnc_password }} | ||
{% endif %} | ||
|
||
{% if kali_package is defined and kali_package != '' %} | ||
Kali Linux Package Installed: {{ kali_package }} | ||
{% endif %} |
24 changes: 24 additions & 0 deletions
24
apps/linode-marketplace-kali-linux/roles/post/templates/motd.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
********************************************************* | ||
Akamai Connected Cloud Kali Marketplace App | ||
|
||
################################### | ||
# VNC SSH Tunnel Instructions # | ||
################################### | ||
|
||
* Ensure you have a VNC Client installed on your local machine | ||
* Run the command below to start the SSH tunnel for VNC | ||
|
||
ssh -L 61000:127.0.0.1:5901 -N -l {{ vnc_username }} {{ ansible_default_ipv4.address }} | ||
|
||
* For more Detailed documentation please visit the official Documentation below | ||
|
||
https://www.linode.com/docs/marketplace-docs/guides/kali-linux/ | ||
|
||
### To remove this message, you can edit the /etc/motd file ### | ||
|
||
Credentials File: /home/{{ username }}/.credentials | ||
********************************************************* | ||
To delete this message of the day: rm /etc/motd | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing that we should have in this file is
import_tasks
. Break everything out into their own task file if possible to stick to the standard.