|
1 | | -# NessusAPI |
2 | | - |
3 | | -This project creates provides a couple utilities that culminate in a shrunken-down version of [TenableCore + Nessus](https://docs.tenable.com/tenable-core/Nessus/Content/TenableCore/Introduction_Nessus.htm) |
4 | | - |
5 | | -It's annoying that without any of the paid options by Tenable, I can't have a monolithic config file that instantiates scans, and imports credentials into a policy file. |
6 | | - |
7 | | -***This fixes that*** |
8 | | - |
9 | | -The only thing you still have to do is install or rebuild plugins (useful for troubleshooting): |
10 | | - |
11 | | -```sh |
12 | | -# Install new plugins |
13 | | -$ nessuscli update PLUGINS.tar.gz |
14 | | - |
15 | | -# Recompile plugins manually |
16 | | -$ nessusd -R |
17 | | -``` |
18 | | - |
19 | | -## NessusAPI |
20 | | - |
21 | | -An extension of the [pyTenable](https://github.com/tenable/pyTenable) library for Python written for Python 3.9+. |
22 | | - |
23 | | -### [`nessusapi.py`](src/NessusAPI/nessusapi.py) |
24 | | -The [nessusapi](src/NessusAPI/nessusapi.py) implements a few methods, namely `import_policy()` and `add_credentials()` which send a PUT/POST request to the Nessus backend API to add credentials to a specific policy. |
25 | | - |
26 | | -The [`example-config.json`](src/NessusAPI/configs/example-config.json) is an example config file. The `credentials` object inside it closely mimics the PUT request data that Nessus executes when it adds credentials to a policy file. |
27 | | - |
28 | | -### [`nessus-configure.py`](src/NessusAPI/nessus-configure.py) |
29 | | -Creates a `Nessus` API instance using [`pyTenable`](https://github.com/tenable/pyTenable) and loads Policies/Credentials and scans in using a passed `config.json` |
30 | | - |
31 | | -```sh |
32 | | - |
33 | | -# Load the Policies/Configs into Nessus |
34 | | -$ nessus-configure -i /path/to/config.json |
35 | | - |
36 | | -# Export Complete or Imported Scans |
37 | | -$ nessus-configure -e /path/to/config.json |
38 | | - |
39 | | -# You can also programatically interact with nessus: |
40 | | -$ nessus-configure --interactive /path/to/config.json |
41 | | -``` |
42 | | -**TODO:** Update nessus-configure to pass args to allow exporting as pdf and csv with all columns. |
43 | | - |
44 | | -***NOTE:*** I have a TODO to document the code properly later -- this was a rush job needed for another project of mine. |
45 | | - |
46 | | - |
47 | | -## "TenableCore" Imitation |
48 | | - |
49 | | -This is broken into a couple parts. |
50 | | - |
51 | | -- [TenableCore.sh](src/TenableCore/TenableCore.sh) automates installing a built VDI image in virtualbox. |
52 | | -- [build.sh](build.sh) packages this project into `./dist/installer/TenableCore-Builder.tar.gz` which can be installed using this script from within an Oracle 9 VM |
53 | | -- [build_tenablecore.sh](install/build_tenablecore.sh) extracts the tar and configures Nessus for automation provided you have the right pip packages and RPMs from the [DoD Patch Repository](https://patches.csd.disa.mil/) |
54 | | - |
55 | | -## NetworkCtl |
56 | | - |
57 | | -A small utility script that wraps `nmcli` to clear, list, and load network profiles.</br> |
58 | | -All you need to do is create a `*.nmconnection` file manually or with `nmtui` and put it in `./TenableCore/NetworkManager` and the `build.sh` will install it with permissions: `rw------- root:root /etc/NetworkManager/system-connections/*.nmconnection` |
59 | | - |
60 | | -Make sure the syntax is good otherwise it won't load. |
61 | | - |
62 | | -The main benefit here is `networkctl load PROFILE` will load all profiles starting with `PROFILE` -- a useful utility for loading an interface and all its VLANs simultaneously. |
63 | | - |
64 | | -```sh |
65 | | -# list connection profiles (nmcli con show) |
66 | | -$ networkctl list |
67 | | - |
68 | | -# restart networking only loading connections starting with the name eth0_vlan |
69 | | -$ sudo networkctl load eth0_vlan |
70 | | - |
71 | | -# clear all network connection profiles |
72 | | -$ sudo networkctl clear |
73 | | -``` |
74 | | - |
75 | | -*** |
76 | | - |
77 | | -## Build Process |
78 | | - |
79 | | -This is currently in process to be **fully** automated |
80 | | - |
81 | | -Recreate distribution files and `scp` them to the VM: |
82 | | -```sh |
83 | | -$ ./build.sh |
84 | | -$ scp ./dist/installer/* root@192.168.56.101:/opt |
85 | | -``` |
86 | | - |
87 | | -Log into the VM and install/configure ACAS: |
88 | | -```sh |
89 | | -$ cd /opt |
90 | | -$ sudo ./build_tenablecore.sh |
91 | | -``` |
92 | | - |
93 | | -Watch the prompts in the output to: |
94 | | -- Create and administrative Nessus account |
95 | | -- Set your ACAS classification and other options |
96 | | -- Set 'Enable XML Plugin Attributes' to yes |
97 | | -- exit the nessus configuration script |
98 | | - |
99 | | -You can install plugins at this point, load additional configs into `/opt/NessusAPI/configs`, or shut down. </br> |
100 | | -To load plugins, run: `nessuscli update <plugins.tar.gz>` |
101 | | - |
102 | | -Remove the build script: |
103 | | -```sh |
104 | | -# rm /tmp/build_tenablecore.sh |
105 | | -``` |
106 | | - |
107 | | -Once complete, copy the VM virtual disk into `./dist/vm/`. Pack this entire folder to make the portable installation. </br> |
108 | | -You can compress the VM and copy the archive instead using this example: |
109 | | -```sh |
110 | | -$ tar -czvf ./dist/vm/TenableCore.tar.gz -C "~/VirtualBox VMs/TenableCore" TenableCore.vdi |
111 | | -``` |
112 | | - |
113 | | -*** |
114 | | -*** |
115 | | - |
116 | | -## Test Setup |
117 | | - |
118 | | -Note that the purpose of this VM is to scan things on-demand --- as in you plug it in, scan, export, and delete it. |
119 | | - |
120 | | -- VirtualBox 7.1 |
121 | | -- 8 GB RAM |
122 | | -- 4 Threads |
123 | | -- No usb, shared folders, or audio |
124 | | -- No optical/floppy drives |
125 | | - |
126 | | -The VM in use is Oracle 9.4 with the Unbreakable Enterprise Kernel (UEK). <br> |
127 | | -I install using LVM Thin Partitioning on a 20GB disk. KDump is turned off with no security policy enabled. |
128 | | - |
129 | | -*** |
130 | | - |
131 | | -**Side Note:** *I should **probably** rename this to ACAS-API since it's more fitting and I don't want to get sued by Tenable* |
| 1 | +# NessusAPI |
| 2 | + |
| 3 | +This project creates provides a couple utilities that culminate in a shrunken-down version of [TenableCore + Nessus](https://docs.tenable.com/tenable-core/Nessus/Content/TenableCore/Introduction_Nessus.htm) |
| 4 | + |
| 5 | +It's annoying that without any of the paid options by Tenable, I can't have a monolithic config file that instantiates scans, and imports credentials into a policy file. |
| 6 | + |
| 7 | +***This fixes that*** |
| 8 | + |
| 9 | +The only thing you still have to do is install or rebuild plugins (useful for troubleshooting): |
| 10 | + |
| 11 | +```sh |
| 12 | +# Install new plugins |
| 13 | +$ nessuscli update PLUGINS.tar.gz |
| 14 | + |
| 15 | +# Recompile plugins manually |
| 16 | +$ nessusd -R |
| 17 | +``` |
| 18 | + |
| 19 | +## NessusAPI |
| 20 | + |
| 21 | +An extension of the [pyTenable](https://github.com/tenable/pyTenable) library for Python written for Python 3.9+. |
| 22 | + |
| 23 | +### [`nessusapi.py`](src/NessusAPI/nessusapi.py) |
| 24 | +The [nessusapi](src/NessusAPI/nessusapi.py) implements a few methods, namely `import_policy()` and `add_credentials()` which send a PUT/POST request to the Nessus backend API to add credentials to a specific policy. |
| 25 | + |
| 26 | +The [`example-config.json`](src/NessusAPI/configs/example-config.json) is an example config file. The `credentials` object inside it closely mimics the PUT request data that Nessus executes when it adds credentials to a policy file. |
| 27 | + |
| 28 | +### [`nessus-configure.py`](src/NessusAPI/nessus-configure.py) |
| 29 | +Creates a `Nessus` API instance using [`pyTenable`](https://github.com/tenable/pyTenable) and loads Policies/Credentials and scans in using a passed `config.json` |
| 30 | + |
| 31 | +```sh |
| 32 | + |
| 33 | +# Load the Policies/Configs into Nessus |
| 34 | +$ nessus-configure -i /path/to/config.json |
| 35 | + |
| 36 | +# Export Complete or Imported Scans |
| 37 | +$ nessus-configure -e /path/to/config.json |
| 38 | + |
| 39 | +# You can also programatically interact with nessus: |
| 40 | +$ nessus-configure --interactive /path/to/config.json |
| 41 | +``` |
| 42 | +**TODO:** Update nessus-configure to pass args to allow exporting as pdf and csv with all columns. |
| 43 | + |
| 44 | +***NOTE:*** I have a TODO to document the code properly later -- this was a rush job needed for another project of mine. |
| 45 | + |
| 46 | + |
| 47 | +## "TenableCore" Imitation |
| 48 | + |
| 49 | +This is broken into a couple parts. |
| 50 | + |
| 51 | +- [TenableCore.sh](src/TenableCore/TenableCore.sh) automates installing a built VDI image in virtualbox. |
| 52 | +- [build.sh](build.sh) packages this project into `./dist/installer/TenableCore-Builder.tar.gz` which can be installed using this script from within an Oracle 9 VM |
| 53 | +- [build_tenablecore.sh](install/build_tenablecore.sh) extracts the tar and configures Nessus for automation provided you have the right pip packages and RPMs from the [DoD Patch Repository](https://patches.csd.disa.mil/) |
| 54 | + |
| 55 | +## NetworkCtl |
| 56 | + |
| 57 | +A small utility script that wraps `nmcli` to clear, list, and load network profiles.</br> |
| 58 | +All you need to do is create a `*.nmconnection` file manually or with `nmtui` and put it in `./TenableCore/NetworkManager` and the `build.sh` will install it with permissions: `rw------- root:root /etc/NetworkManager/system-connections/*.nmconnection` |
| 59 | + |
| 60 | +Make sure the syntax is good otherwise it won't load. |
| 61 | + |
| 62 | +The main benefit here is `networkctl load PROFILE` will load all profiles starting with `PROFILE` -- a useful utility for loading an interface and all its VLANs simultaneously. |
| 63 | + |
| 64 | +```sh |
| 65 | +# list connection profiles (nmcli con show) |
| 66 | +$ networkctl list |
| 67 | + |
| 68 | +# restart networking only loading connections starting with the name eth0_vlan |
| 69 | +$ sudo networkctl load eth0_vlan |
| 70 | + |
| 71 | +# clear all network connection profiles |
| 72 | +$ sudo networkctl clear |
| 73 | +``` |
| 74 | + |
| 75 | +*** |
| 76 | + |
| 77 | +## Build Process |
| 78 | + |
| 79 | +This is currently in process to be **fully** automated |
| 80 | + |
| 81 | +Recreate distribution files and `scp` them to the VM: |
| 82 | +```sh |
| 83 | +$ ./build.sh |
| 84 | +$ scp ./dist/installer/* root@192.168.56.101:/opt |
| 85 | +``` |
| 86 | + |
| 87 | +Log into the VM and install/configure ACAS: |
| 88 | +```sh |
| 89 | +$ cd /opt |
| 90 | +$ sudo ./build_tenablecore.sh |
| 91 | +``` |
| 92 | + |
| 93 | +Watch the prompts in the output to: |
| 94 | +- Create and administrative Nessus account |
| 95 | +- Set your ACAS classification and other options |
| 96 | +- Set 'Enable XML Plugin Attributes' to yes |
| 97 | +- exit the nessus configuration script |
| 98 | + |
| 99 | +You can install plugins at this point, load additional configs into `/opt/NessusAPI/configs`, or shut down. </br> |
| 100 | +To load plugins, run: `nessuscli update <plugins.tar.gz>` |
| 101 | + |
| 102 | +Remove the build script: |
| 103 | +```sh |
| 104 | +# rm /tmp/build_tenablecore.sh |
| 105 | +``` |
| 106 | + |
| 107 | +Once complete, copy the VM virtual disk into `./dist/vm/`. Pack this entire folder to make the portable installation. </br> |
| 108 | +You can compress the VM and copy the archive instead using this example: |
| 109 | +```sh |
| 110 | +$ tar -czvf ./dist/vm/TenableCore.tar.gz -C "~/VirtualBox VMs/TenableCore" TenableCore.vdi |
| 111 | +``` |
| 112 | + |
| 113 | +*** |
| 114 | +*** |
| 115 | + |
| 116 | +## Test Setup |
| 117 | + |
| 118 | +Note that the purpose of this VM is to scan things on-demand --- as in you plug it in, scan, export, and delete it. |
| 119 | + |
| 120 | +- VirtualBox 7.1 |
| 121 | +- 8 GB RAM |
| 122 | +- 4 Threads |
| 123 | +- No usb, shared folders, or audio |
| 124 | +- No optical/floppy drives |
| 125 | + |
| 126 | +The VM in use is Oracle 9.4 with the Unbreakable Enterprise Kernel (UEK). <br> |
| 127 | +I install using LVM Thin Partitioning on a 20GB disk. KDump is turned off with no security policy enabled. |
| 128 | + |
| 129 | +*** |
| 130 | + |
| 131 | +**Side Note:** *I should **probably** rename this to ACAS-API since it's more fitting and I don't want to get sued by Tenable* |
0 commit comments