├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── base_variables.tf ├── data ├── c2_profiles │ └── .gitignore ├── certificates │ └── .gitignore ├── credentials │ └── .gitignore ├── oracle │ └── .gitignore ├── playbooks │ ├── cobalt_strike.yml │ ├── core_config.yml │ ├── gophish.yml │ ├── redirector.yml │ └── requirements.yml ├── ssh_configs │ └── .gitignore ├── ssh_keys │ └── .gitignore └── templates │ ├── gophish_templates │ ├── config.json.j2 │ └── gophish.service.j2 │ └── ssh_config.tpl ├── deployments └── aws │ ├── README.md │ ├── c2_dns │ ├── README.md │ ├── aws_c2_dns.auto.tfvars.json.template │ ├── aws_c2_dns.outputs.tf │ ├── aws_c2_dns.providers.tf │ ├── aws_c2_dns.tf │ └── aws_c2_dns.variables.tf │ ├── c2_http │ ├── README.md │ ├── aws_c2_http.auto.tfvars.json.template │ ├── aws_c2_http.outputs.tf │ ├── aws_c2_http.providers.tf │ ├── aws_c2_http.tf │ └── aws_c2_http.variables.tf │ ├── complete │ ├── README.md │ ├── aws_complete.auto.tfvars.json.template │ ├── aws_complete.outputs.tf │ ├── aws_complete.providers.tf │ ├── aws_complete.tf │ └── aws_complete.variables.tf │ └── phishing │ ├── README.md │ ├── aws_phishing.auto.tfvars.json.template │ ├── aws_phishing.outputs.tf │ ├── aws_phishing.providers.tf │ ├── aws_phishing.tf │ └── aws_phishing.variables.tf ├── environment_variables.auto.tfvars.json.template └── modules ├── ansible ├── cobalt-strike │ ├── README.md │ ├── base_variables.tf │ ├── main.tf │ └── variables.tf ├── core │ ├── README.md │ ├── main.tf │ └── variables.tf └── gophish │ ├── README.md │ ├── base_variables.tf │ ├── main.tf │ └── variables.tf └── aws ├── create-dns-record ├── README.md ├── main.tf ├── outputs.tf └── variables.tf ├── dns-c2 ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf ├── security_group.tf └── variables.tf ├── dns-cobalt-strike ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf └── variables.tf ├── dns-rdir ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf ├── security_group.tf └── variables.tf ├── domain-front ├── README.md ├── main.tf ├── outputs.tf └── variables.tf ├── http-c2 ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf ├── security_group.tf └── variables.tf ├── http-cobalt-strike ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf └── variables.tf ├── http-rdir ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf ├── security_group.tf └── variables.tf ├── letsencrypt └── create-cert-dns │ ├── README.md │ ├── main.tf │ ├── outputs.tf │ ├── providers.tf │ └── variables.tf ├── phishing-gophish ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf └── variables.tf ├── phishing-rdir ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf ├── security_group.tf └── variables.tf ├── phishing-server ├── README.md ├── base_variables.tf ├── main.tf ├── outputs.tf └── variables.tf └── smtp ├── README.md ├── main.tf ├── outputs.tf └── variables.tf /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/* 2 | terraform.tfvars.json 3 | deployments/aws/c2_dns/*.auto.tfvars.json 4 | deployments/aws/c2_http/*.auto.tfvars.json 5 | deployments/aws/phishing/*.auto.tfvars.json 6 | deployments/aws/complete/*.auto.tfvars.json 7 | modules/aws/create-hosted-zone/ 8 | modules/aws/create-vpc/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Red Ira 2 | Red Ira is an cloud automation system scheme for Red Teams, built on the work done in [Red Baron](https://github.com/Coalfire-Research/Red-Baron). It currently supports AWS only. The accompanying blog post can be [found here](https://blog.joeminicucci.com/2021/redira). 3 | 4 | ## Design Philosophy 5 | The design philosophy differs from Red Baron in the following : 6 | 7 | - Deployments only require modification of cut-and-dry configuration JSON templates. 8 | - All configuration is done by Ansible, automatically. 9 | - In-line scripts remain an option (recommended against). 10 | - Publicly facing assets only expose ports & services necessary for their core offensive function to the internet. 11 | - All administrative functions are exposed to the internal operators' network only. 12 | - Obscures the underlying operations infrasturcture to curious Blue teams. 13 | 14 | ## Improvements 15 | - Terraform upgrade to .14 16 | - Includes new Terraform syntax paradigms, such as : 17 | - Non-interpolated variable invocation 18 | - explicit `depends` patterns 19 | - local variables 20 | - Upgraded acme providers 21 | - Complete, hands-off Cobalt Strike and Gophish Ansible playbooks. 22 | - Added J2 templates & c2 profiles that can be fed into the playbooks. 23 | - Cleaned up code 24 | - Removed count where unnecessary 25 | - Simplified outputs 26 | - Simplified modules 27 | - Added explicit type constraints where possible 28 | - Boilerplate base variable files for unmanaged infrastructure declaration 29 | - Deployment specific module abstractions (infra as well as ansible modules) 30 | - Cobalt strike, Gophish 31 | - Ansible on python3 32 | 33 | ## Versioning 34 | This following components were leveraged for development and are stable for this release: 35 | - Terraform v0.14.4 36 | - Ansible v2.10.4 37 | - Cobalt Strike 4.2 38 | - Oracle JDK jdk-8u261-linux-x64.tar.gz 39 | - gophish 0.11.0 40 | 41 | The Ansible Playbooks are currently built for and tested on the latest Amazon Debian Buster AMIs. 42 | 43 | 44 | ## Install 45 | ### First Run - Dependencies 46 | apt-get -y install ansible terraform python3-pip 47 | ansible-galaxy install -r ./data/playbooks/requirements.yml 48 | 49 | ### First Run - AWS SES Verification 50 | 51 | SES requires verification before the relays can be used for Phishing. See the instructions in [the README](./modules/aws/smtp/README.md#initial-setup) 52 | ### First Run - AWS Environment Preparation 53 | Since this framework will isolate back-end operator actions from the internet, some manual setup is required in AWS before the framework can be deployed. 54 | 55 | In the root directory, copy the [environment variables template file](environment_variables.auto.tfvars.json.template) as: 56 | 57 | ```cp ./environment_variables.auto.tfvars.json.template ./environment_variables.auto.tfvars.json``` 58 | 59 | Then add the following properties: 60 | #### VPC 61 | Pick an existing VPC or create new one. Record `the vpc_id`. 62 | 63 | "vpc_id" : "vpc-aabbccdd", 64 | #### Private Subnet 65 | Create or select an existing subnet which will be used for the back-end infrastructure, and which is intended to be accessed by operators only. Record the `private_subnet_id`. 66 | 67 | "private_subnet_id" : "subnet-aabbccdd", 68 | #### Public Subnet 69 | Create a subnet in which publicly facing redirectors & assets will be placed. Record the `public_subnet_id`. 70 | 71 | "public_subnet_id" : "subnet-aabbccdd", 72 | #### Public Security Groups 73 | This will be the Security Group(s) which redirectors and publicly facing assets will inherit. They only need to define incoming traffic from internal sources to the public subnet, as public sources are resolved through Terraform at runtime depending on the chosen deployment. 74 | 75 | Create the SG or multiple, which allows incoming traffic from the private subnet you just created and optionally anywhere in the VPC which you would like to access the publicly facing assets from. 76 | 77 | The following is an example which additionally allows the required private subnet total access for managing redirectors, as well as the Terraform controller's subnet prefix from which to ssh in: 78 | 79 | | Type | Protocol | Port Range | Source | Description | 80 | |-------------|----------|------------|-----------------|--------------------------------------------------------------------------------| 81 | | All traffic | All | All | 172.14.130.0/24 | Private Subnet (required) | 82 | | SSH | TCP | 22 | 172.1.111.0/24 | Internal SSH access (from Terraform controller's subnet) | 83 | | | | | | | 84 | 85 | 86 | Record these SG(s) as `base-public-security-groups`. 87 | 88 | "base-public-security_groups" : ["sg-12345678912345678"] 89 | #### Internal Security Groups 90 | This will be the security group that allows operators to access the back-end infrastructure (the private subnet). 91 | 92 | The public SG is required (the one created above), as it allows all incoming traffic from the redirectors/public assets to communicate inbound. The VPN server addition in the example below is an example of how one may allow operators to connect to the internal red team assets from a VPN server. 93 | 94 | | Type | Protocol | Port Range | Source | Description | 95 | |-------------|----------|------------|----------------------|------------------------| 96 | | All traffic | All | All | sg-12345678912345678 | Public SG (required) | 97 | | All traffic | All | All | 172.12.130.101/32 | VPN Server | 98 | | | | | | | 99 | 100 | 101 | Record this SG as the `base-internal-security-groups`. 102 | 103 | "base-internal-security_groups" : ["sg-12345678912345678"], 104 | 105 | ## Deployment 106 | ### Prepare the environment for Terraform 107 | ```shell script 108 | export AWS_SECRET_ACCESS_KEY="" 109 | export AWS_DEFAULT_REGION="us-east-1" 110 | export AWS_ACCESS_KEY_ID="" 111 | ``` 112 | ### Deployment Prep 113 | 1. Reference the [AWS Deployment README](./deployments/aws/README.md) to select the desired deployment. 114 | 115 | 2. Clean the root of the previous deployment. 116 | > :warning: Be careful as to not clear out someone's pre-existing environment! 117 | ```shell script 118 | rm -f ./aws_* 119 | ``` 120 | 121 | 3. Copy the desired deployment folder from the [AWS Deployments folder](./deployments/aws/) to the root. 122 | ```shell script 123 | cp ./deployments/aws/complete/* ./ 124 | ``` 125 | 126 | 4. Rename the `auto.tfvars.json.template` file to `.json` for that deployment, and fill in the json variables with target values: 127 | ```shell script 128 | mv ./aws_complete.auto.tfvars.json.template ./aws_complete.auto.tfvars.json 129 | ``` 130 | 131 | 5. If working with Cobalt Strike, retrieve an Oracle JDK gz tar from the Oracle website and copy it to the [./data/oracle](./data/oracle) folder. This is necessary due to Oracle's licensing restrictions. 132 | 133 | ```cp jdk-8u261-linux-x64.tar.gz ./data/oracle/``` 134 | 135 | 6. If a custom c2 profile file is desired, copy the file to [./data/c2_profiles](./data/c2_profiles) fill in the filename within the c2-profile variable in the respective `.auto.tfvars.json` deployment config file you created. Otherwise, the default CS profile will be used (not recommended). 136 | 137 | ```cp ./data/c2_profiles/``` 138 | 139 | ### Deploy with Terraform 140 | From the root directory: 141 | ```shell script 142 | terraform init 143 | terraform plan -out 144 | terraform apply 145 | ``` 146 | 147 | ## Contributing to Red Ira 148 | ### Development Process 149 | GitHub is used to sync code, as well as to track issues, feature requests, and pull requests. 150 | 151 | ### Pull Requests 152 | Pull Requests are always welcome. The following procedure should be adhered to: 153 | 154 | 1. Fork the repo and create your branch from `master`. 155 | 2. If you've added code, please ensure that you have already deployed several times and tested successfully before submission. 156 | 3. If relevant, update the documentation. 157 | 4. Make sure your code lints. Currently the [Hashicorp HCL/Terraform plugin](https://plugins.jetbrains.com/plugin/7808-hashicorp-terraform--hcl-language-support) is used within a JetBrains IDE. 158 | 159 | ### Issues 160 | Use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue. 161 | 162 | ### Coding Style 163 | * Follow the current conventions in place for splitting up HCL elements in separate files 164 | * 2 spaces for indentation 165 | * Currently no line length restrictions in place due to the way HCL is handled, but try to keep it at a minimum where possible. 166 | * Use an HCL linter to ensure your code passes basic convention tests 167 | 168 | ### License 169 | By contributing to RedIra, you agree that your contributions will be licensed under its [GPLv3 license](./LICENSE). 170 | 171 | ## Known Issues 172 | ### Locals & Provisioners 173 | If the locals are changed, the paths in the destroy provisioners will need to be updated due to a limitation in terraform 174 | `https://github.com/hashicorp/terraform/issues/23675` 175 | ### Relative Paths 176 | Terraform doesn't support variables in module source paths, meaning that core modules must remain in place, and deployments must be copied to the root folder or else the module sources will not resolve properly. If Hashicorp implements it in the future, dynamic path resolution could be accomplished by modifying base variables. 177 | 178 | ## Credit 179 | - [Joe Minicucci](https://joeminicucci.com) - Author 180 | - [Red Baron](https://github.com/Coalfire-Research/Red-Baron) - Used as a starting point, built on Terraform architecture and coding style. 181 | - [ansible-role-cobalt-strike](https://github.com/chryzsh/ansible-role-cobalt-strike) - Built on with several additions. 182 | - [Richard Ira Bong](https://en.wikipedia.org/wiki/Richard_Bong) for name of the project. 183 | 184 | ## TODO 185 | 186 | ### Future Needs and Ideas 187 | #### Needs 188 | - Pwndrop for payload server 189 | - Domain Fronting Implementation 190 | - RedELK Implementation 191 | - Hosted Zone / Create VPC implementation, as needed or if requested 192 | - Molecule & InSpec integration tests 193 | #### Ideas 194 | - Remove ansible invocations entirely from terraform, and leverage the [terraform inventory tool](https://github.com/adammck/terraform-inventory) as explained by xpn [in this excellent blog post.](https://blog.xpnsec.com/testing-redteam-infra/) 195 | - For dynamic inventories, alternatively use template files in native terraform resources as [outlined here](https://www.linkbynet.com/produce-an-ansible-inventory-with-terraform) 196 | - Encapsulate JSON config with a micro-service, which can easily be leveraged for a ChatOps deployment approach 197 | - Web clone / APT - tailored website deployments with nginx redirectors on HTTP C2s 198 | - Domain name automation with evilurl / domaincheck 199 | - CLI implementation with https://github.com/amplify-education/terrawrap or https://github.com/beelit94/python-terraform if needed. TF CLI seems to suffice. 200 | -------------------------------------------------------------------------------- /base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "public_subnet_id" { 15 | type = string 16 | } 17 | 18 | variable "private_subnet_id" { 19 | type = string 20 | } 21 | variable "base-internal-security_groups"{ 22 | type = list(string) 23 | } 24 | 25 | variable "base-public-security_groups" { 26 | type = list(string) 27 | } 28 | 29 | variable "instance_type" { 30 | type = string 31 | default = "t2.micro" 32 | } 33 | variable "acme_server_urls" { 34 | type = map(string) 35 | default = { 36 | "staging" = "https://acme-staging-v02.api.letsencrypt.org/directory" 37 | "production" = "https://acme-v02.api.letsencrypt.org/directory" 38 | } 39 | } 40 | 41 | #staging or production 42 | variable "acme_server_type" { 43 | type = string 44 | default = "production" 45 | } 46 | 47 | variable "amis" { 48 | type = map(string) 49 | default = { 50 | // https://wiki.debian.org/Cloud/AmazonEC2Image/Buster amd64 51 | "af-south-1" = "ami-021ea31a882dc6e26" 52 | "ap-east-1" = "ami-09da9778" 53 | "ap-northeast-1" = "ami-048fd87c7ead0af9a" 54 | "ap-northeast-2" = "ami-0bc7e80fd49f70717" 55 | "ap-south-1" = "ami-074004b07f40bac7f" 56 | "ap-southeast-1" = "ami-0a37dc64b36bce463" 57 | "ap-southeast-2" = "ami-04472326bb46be1ce" 58 | "ca-central-1" = "ami-0f712cd4f98ca897f" 59 | "eu-central-1" = "ami-03173d987db03911c" 60 | "eu-north-1" = "ami-098e3e0c0e82384a8" 61 | "eu-south-1" = "ami-085d463c092d1d692" 62 | "eu-west-1" = "ami-02e64d6c81725f843" 63 | "eu-west-2" = "ami-085d463c092d1d692" 64 | "eu-west-3" = "ami-009d9923c983f524d" 65 | "me-south-1" = "ami-07472751c2eaf2429" 66 | "sa-east-1" = "ami-0bb7c15f6d611f64c" 67 | "us-east-1" = "ami-0e0161137b4b30900" 68 | "us-east-2" = "ami-06be10ae4a207f54a" 69 | "us-west-1" = "ami-06f4f25615eefbc7a" 70 | "us-west-2" = "ami-0cdf40a7f31926f5e" 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /data/c2_profiles/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/certificates/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/credentials/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /data/oracle/.gitignore: -------------------------------------------------------------------------------- 1 | jdk*.tar.gz 2 | !.gitignore -------------------------------------------------------------------------------- /data/playbooks/cobalt_strike.yml: -------------------------------------------------------------------------------- 1 | - name: Cobalt Strike Deployment 2 | hosts: all 3 | tasks: 4 | - set_fact: 5 | tls_pass: "{{ lookup('password', '/dev/null length=16 chars=ascii_letters') }}" 6 | - name: Cobalt Strike Deployment 7 | include_role: 8 | name: joeminicucci.cobalt_strike 9 | tags: always -------------------------------------------------------------------------------- /data/playbooks/core_config.yml: -------------------------------------------------------------------------------- 1 | - name: Core Configuration 2 | hosts: all 3 | tasks: 4 | 5 | - name: Install core deps 6 | apt: 7 | name: 8 | - curl 9 | - tmux 10 | - git 11 | - dirmngr 12 | - debconf-utils 13 | - wget 14 | - build-essential 15 | - vim 16 | - gcc 17 | update_cache: yes 18 | state: latest 19 | become: yes 20 | tags: update 21 | -------------------------------------------------------------------------------- /data/playbooks/gophish.yml: -------------------------------------------------------------------------------- 1 | #Gophish Phishing Server Deployment 2 | - hosts: all 3 | gather_facts: yes 4 | check_mode: no 5 | become: True 6 | tasks: 7 | - name : "Deploy Gophish Server" 8 | include_role: 9 | name: gophish 10 | vars: 11 | gophish_config_template_source: "{{ playbook_dir}}/../templates/gophish_templates/config.json.j2" 12 | gophish_service_template_source: "{{ playbook_dir }}/../templates/gophish_templates/gophish.service.j2" 13 | gophish_service_log_directory: "{{ gophish_install_destination }}/log" 14 | register: gophish_deploy 15 | 16 | - hosts: localhost 17 | gather_facts: yes 18 | check_mode: no 19 | become: True 20 | tasks: 21 | - debug: 22 | msg="{{ hostvars[hostvars.keys()|list|first]['gophish_log'].stdout }}" 23 | - name: "Extract Gophish Credentials to disk" 24 | check_mode: no 25 | become: True 26 | shell: 27 | cmd: | 28 | grep -oiP 'username[[:blank:]][A-Za-z0-9]+' <<< "{{ hostvars[hostvars.keys()|list|first]['gophish_log'].stdout }}" | cut -d ' ' -f2 > ../credentials/gophish_username_{{ hostvars.keys()|list|first }} 29 | grep -oiP 'password[[:blank:]][A-Za-z0-9]+' <<< "{{ hostvars[hostvars.keys()|list|first]['gophish_log'].stdout }}" | cut -d ' ' -f2 >> ../credentials/gophish_password_{{ hostvars.keys()|list|first }} 30 | args: 31 | executable: /bin/bash 32 | retries: 2 33 | delay: 5 34 | changed_when: False 35 | ignore_errors: yes 36 | register: gophish_credz 37 | until: hostvars[hostvars.keys()|list|first]['gophish_log'].stdout | length > -1 38 | -------------------------------------------------------------------------------- /data/playbooks/redirector.yml: -------------------------------------------------------------------------------- 1 | - name: Redirector Configuration 2 | hosts: all 3 | tasks: 4 | - name: Socat HTTP Config 5 | shell: 6 | cmd: tmux new -d "sudo socat TCP4-LISTEN:80,fork TCP4:{{ redirect_to }}:80" ';' split "sudo socat TCP4-LISTEN:443,fork TCP4:{{ redirect_to }}:443" 7 | become: yes 8 | when: redirector_type == 'http' 9 | 10 | - name: Socat gophish Config 11 | shell: 12 | cmd: tmux new -d "sudo socat TCP4-LISTEN:443,fork TCP4:{{ redirect_to }}:443" 13 | become: yes 14 | when: redirector_type == 'gophish' 15 | 16 | - name: Socat DNS Config 17 | shell: 18 | cmd: tmux new -d "sudo socat udp4-recvfrom:53,reuseaddr,fork udp4-sendto:{{ redirect_to }}:53" 19 | become: yes 20 | when: redirector_type == 'dns' 21 | -------------------------------------------------------------------------------- /data/playbooks/requirements.yml: -------------------------------------------------------------------------------- 1 | # Install a role from GitHub 2 | roles: 3 | - name: gophish 4 | #dev 5 | src: git+https://github.com/TUVOpenSky-THREATS/ansible-role-gophish.git 6 | version: dev 7 | #switch back to https://github.com/justin-p/ansible-role-gophish when PR is complete 8 | 9 | - name: joeminicucci.cobalt_strike 10 | src: git+https://github.com/joeminicucci/ansible-role-cobalt-strike.git 11 | #for development branch 12 | # version: dev 13 | -------------------------------------------------------------------------------- /data/ssh_configs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/ssh_keys/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore -------------------------------------------------------------------------------- /data/templates/gophish_templates/config.json.j2: -------------------------------------------------------------------------------- 1 | { 2 | "admin_server": { 3 | "listen_url": "0.0.0.0:3333", 4 | "use_tls": true, 5 | "cert_path": "gophish.crt", 6 | "key_path": "gophish.pem" 7 | }, 8 | "phish_server": { 9 | "listen_url": "0.0.0.0:443", 10 | "use_tls": true, 11 | "cert_path": "gophish.crt", 12 | "key_path": "gophish.pem" 13 | }, 14 | "db_name": "sqlite3", 15 | "db_path": "gophish.db", 16 | "migrations_prefix": "db/db_", 17 | "contact_address": "", 18 | "logging": { 19 | "filename": "{{ gophish_service_log_directory }}/gophish.log", 20 | "level": "" 21 | } 22 | } -------------------------------------------------------------------------------- /data/templates/gophish_templates/gophish.service.j2: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=gophish 3 | After=network.target 4 | [Service] 5 | Type=simple 6 | WorkingDirectory={{ gophish_install_destination }} 7 | ExecStart="{{ gophish_binary }}" 8 | User={{ gophish_user }} 9 | PIDFile="{{ gophish_binary }}.pid" 10 | [Install] 11 | WantedBy=multi-user.target -------------------------------------------------------------------------------- /data/templates/ssh_config.tpl: -------------------------------------------------------------------------------- 1 | Host ${name} 2 | HostName ${hostname} 3 | User ${user} 4 | IdentityFile ${identityfile} -------------------------------------------------------------------------------- /deployments/aws/README.md: -------------------------------------------------------------------------------- 1 | # AWS Deployments 2 | ## Phishing 3 | See [Phishing Deployment](./phishing/README.md) module. The current deployment deploys a GoPhish server with the following assumptions: 4 | - The server is on a private subnet, with a pre-programmed security group. It is not exposed to the internet, other than port 443. Port 443 is a TLS webserver used for GoPhish landing pages. 5 | - The server will forward SMTP traffic to a publicly facing SES relay. 6 | ## C2 - DNS 7 | See the [DNS C2 Deployment](./c2_dns/README.md) module. The current deployment deploys a server with the following assumptions: 8 | - The Cobalt Strike server is on a private subnet, with a pre-programmed security group. It is not exposed to the internet. 9 | - The deployment will place a redirector in front of the C2, from which front-facing internet traffic is forwarded over DNS to the hidden C2 back-end. 10 | ## HTTP - DNS 11 | See the [HTTP C2 Deployment](./c2_http/README.md) module. The current deployment deploys a server with the following assumptions: 12 | - The Cobalt Strike server is on a private subnet, with a pre-programmed security group. It is not exposed to the internet. It is pre-configured with TLS certificates using LetsEncrypt. 13 | - The deployment will place a redirector in front of the C2, from which front-facing internet traffic is forwarded over http/s to the hidden C2 back-end. 14 | ## Complete 15 | See the [Complete AWS Deployment](./complete/README.md) module. 16 | - Includes the Phishing, DNS and HTTP deployments, all-in-one. -------------------------------------------------------------------------------- /deployments/aws/c2_dns/README.md: -------------------------------------------------------------------------------- 1 | # aws_c2_dns 2 | 3 | Create a Cobalt Strike DNS server C2 in AWS 4 | 5 | ## Arguments 6 | 7 | | Name | Required | Value Type | Description | 8 | |------------------------|----------|--------------|---------------------------------| 9 | | dns-c2-amount | No | number | The amount of servers to add | 10 | | dns-c2-user | No | string | The User to authenticate as | 11 | | dns-c2-domain-mappings | Yes | list(string) | The domain names to deploy on | 12 | | cs-license | Yes | string | Cobalt Strike License Key | 13 | | dns-c2-profile | Yes | string | The name of the C2 profile file | 14 | 15 | ## Outputs 16 | 17 | | Name | Description | 18 | |------------------------|--------------------------| 19 | | cs-teamserver-password | Teamserver Password | 20 | | cs-dns-c2-private-ip | C2 Private IP | 21 | | cs-dns-rdr-private-ip | Redirector Private IP | 22 | | cs-dns-c2-domains | The domains to deploy to | 23 | | cs-dns-rdr-public-ip | Redirector Public IP | 24 | -------------------------------------------------------------------------------- /deployments/aws/c2_dns/aws_c2_dns.auto.tfvars.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "dns-c2-amount": 1, 3 | "dns-c2-user": "admin", 4 | "dns-c2-domain-mappings": [ 5 | "", 6 | ], 7 | "cs-license": "", 8 | "dns-c2-profile": "" 9 | } -------------------------------------------------------------------------------- /deployments/aws/c2_dns/aws_c2_dns.outputs.tf: -------------------------------------------------------------------------------- 1 | output "cs-teamserver-passwords" { 2 | value = module.cs-dns-c2[*].cs-teamserver-password 3 | } 4 | 5 | output "cs-dns-c2-private-ip"{ 6 | value = module.cs-dns-c2[*].cs-dns-c2-private-ip 7 | } 8 | 9 | output "cs-dns-rdr-private-ip"{ 10 | value = module.cs-dns-c2[*].cs-dns-rdr-private-ip 11 | } 12 | 13 | output "cs-dns-c2-domains"{ 14 | value = var.dns-c2-domain-mappings 15 | } 16 | 17 | output "cs-dns-rdr-public-ip"{ 18 | value = module.cs-dns-c2[*].cs-dns-rdr-public-ip 19 | } 20 | -------------------------------------------------------------------------------- /deployments/aws/c2_dns/aws_c2_dns.providers.tf: -------------------------------------------------------------------------------- 1 | terraform { required_version = ">= 0.14.0" } 2 | -------------------------------------------------------------------------------- /deployments/aws/c2_dns/aws_c2_dns.tf: -------------------------------------------------------------------------------- 1 | module "cs-dns-c2" { 2 | source = "./modules/aws/dns-cobalt-strike" 3 | count = var.dns-c2-amount 4 | 5 | #managed 6 | cs-dns-c2-user = var.dns-c2-user 7 | cs-dns-c2-domain = var.dns-c2-domain-mappings[count.index] 8 | cs-license = var.cs-license 9 | c2-profile = var.dns-c2-profile 10 | 11 | #base 12 | vpc_id = var.vpc_id 13 | amis = var.amis 14 | instance_type = var.instance_type 15 | public_subnet_id = var.public_subnet_id 16 | private_subnet_id = var.private_subnet_id 17 | base-internal-security_groups = var.base-internal-security_groups 18 | base-public-security_groups = var.base-public-security_groups 19 | } 20 | -------------------------------------------------------------------------------- /deployments/aws/c2_dns/aws_c2_dns.variables.tf: -------------------------------------------------------------------------------- 1 | variable "dns-c2-amount"{ 2 | type = number 3 | default = 1 4 | } 5 | 6 | variable "dns-c2-user" { 7 | type = string 8 | default = "admin" 9 | description = "User to authenticate as" 10 | } 11 | 12 | variable "dns-c2-domain-mappings" { 13 | type = list(string) 14 | } 15 | 16 | variable "cs-license"{ 17 | type = string 18 | } 19 | 20 | variable "dns-c2-profile" { 21 | type = string 22 | description = "The name of the C2 profile file" 23 | } 24 | -------------------------------------------------------------------------------- /deployments/aws/c2_http/README.md: -------------------------------------------------------------------------------- 1 | # aws_c2_http 2 | 3 | Create a Cobalt Strike HTTP server C2 in AWS 4 | 5 | ## Arguments 6 | 7 | | Name | Required | Value Type | Description | 8 | |-------------------------|----------|--------------|---------------------------------| 9 | | http-c2-amount | No | number | The amount of servers to add | 10 | | http-c2-user | No | string | The User to authenticate as | 11 | | http-c2-domain-mappings | Yes | list(string) | The domain names to deploy on | 12 | | cs-license | Yes | string | Cobalt Strike License Key | 13 | | http-c2-profile | Yes | string | The name of the C2 profile file | 14 | 15 | ## Outputs 16 | 17 | | Name | Description | 18 | |------------------------|--------------------------| 19 | | cs-teamserver-password | Teamserver Password | 20 | | cs-http-c2-private-ip | C2 Private IP | 21 | | cs-http-rdr-private-ip | Redirector Private IP | 22 | | cs-http-c2-domains | The domains to deploy to | 23 | | cs-http-rdr-public-ip | Redirector Public IP | 24 | -------------------------------------------------------------------------------- /deployments/aws/c2_http/aws_c2_http.auto.tfvars.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "http-c2-amount": 1, 3 | "http-c2-user": "admin", 4 | "http-c2-domain-mappings": [ 5 | "", 6 | ], 7 | "cs-license": "", 8 | "http-c2-profile": "" 9 | } -------------------------------------------------------------------------------- /deployments/aws/c2_http/aws_c2_http.outputs.tf: -------------------------------------------------------------------------------- 1 | output "cs-teamserver-passwords" { 2 | value = module.cs-http-c2[*].cs-teamserver-password 3 | } 4 | 5 | output "cs-http-c2-private-ip"{ 6 | value = module.cs-http-c2[*].cs-http-c2-private-ip 7 | } 8 | 9 | output "cs-http-rdr-private-ip"{ 10 | value = module.cs-http-c2[*].cs-http-rdr-private-ip 11 | } 12 | 13 | output "cs-http-c2-domains"{ 14 | value = var.http-c2-domain-mappings 15 | } 16 | 17 | output "cs-http-rdr-public-ip"{ 18 | value = module.cs-http-c2[*].cs-http-rdr-public-ip 19 | } 20 | -------------------------------------------------------------------------------- /deployments/aws/c2_http/aws_c2_http.providers.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14.0" 3 | required_providers { 4 | acme = { 5 | source = "vancluever/acme" 6 | version = "~> 2.0.0" 7 | } 8 | } 9 | } 10 | 11 | provider "acme" { 12 | server_url = lookup(var.acme_server_urls, var.acme_server_type) 13 | } -------------------------------------------------------------------------------- /deployments/aws/c2_http/aws_c2_http.tf: -------------------------------------------------------------------------------- 1 | module "cs-http-c2" { 2 | source = "./modules/aws/http-cobalt-strike" 3 | count = var.http-c2-amount 4 | 5 | #managed 6 | cs-http-c2-user = var.http-c2-user 7 | cs-http-c2-domain = var.http-c2-domain-mappings[count.index] 8 | cs-license = var.cs-license 9 | c2-profile = var.http-c2-profile 10 | 11 | #base 12 | vpc_id = var.vpc_id 13 | amis = var.amis 14 | instance_type = var.instance_type 15 | public_subnet_id = var.public_subnet_id 16 | private_subnet_id = var.private_subnet_id 17 | base-internal-security_groups = var.base-internal-security_groups 18 | base-public-security_groups = var.base-public-security_groups 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /deployments/aws/c2_http/aws_c2_http.variables.tf: -------------------------------------------------------------------------------- 1 | variable "http-c2-amount"{ 2 | type = number 3 | default = 1 4 | } 5 | 6 | variable "http-c2-user" { 7 | type = string 8 | default = "admin" 9 | description = "User to authenticate as" 10 | } 11 | 12 | variable "http-c2-domain-mappings" { 13 | type = list(string) 14 | } 15 | 16 | variable "cs-license"{ 17 | type = string 18 | } 19 | 20 | variable "http-c2-profile" { 21 | type = string 22 | description = "The name of the C2 profile file" 23 | } -------------------------------------------------------------------------------- /deployments/aws/complete/README.md: -------------------------------------------------------------------------------- 1 | # aws_complete 2 | 3 | Create a Cobalt Strike HTTP server C2 in AWS 4 | 5 | ## Arguments 6 | 7 | | Name | Required | Value Type | Description | 8 | |--------------------------|----------|--------------|---------------------------------| 9 | | http-c2-amount | No | number | The amount of servers to add | 10 | | http-c2-user | No | string | The User to authenticate as | 11 | | http-c2-domain-mappings | Yes | list(string) | The domain names to deploy on | 12 | | cs-license | Yes | string | Cobalt Strike License Key | 13 | | http-c2-profile | Yes | string | The name of the C2 profile file | 14 | | dns-c2-amount | No | number | The amount of servers to add | 15 | | dns-c2-user | No | string | The User to authenticate as | 16 | | dns-c2-domain-mappings | Yes | list(string) | The domain names to deploy on | 17 | | dns-c2-profile | Yes | string | The name of the C2 profile file | 18 | | phishing-amount | No | number | The amount of servers to add | 19 | | phishing-user | No | string | The User to authenticate as | 20 | | phishing-domain-mappings | Yes | list(string) | The domain names to deploy on | 21 | 22 | | Name | Description | 23 | |-------------------------------|----------------------------------------| 24 | | http-cs-teamserver-password | Teamserver Password | 25 | | dns-cs-teamserver-password | Teamserver Password | 26 | | http-c2-private-ip | C2 Private IP | 27 | | http-rdr-private-ip | Redirector Private IP | 28 | | cs-http-domains | The domains to deploy to | 29 | | http-rdr-public-ip | Redirector Public IP | 30 | | dns-c2-private-ip | C2 Private IP | 31 | | dns-rdr-private-ip | Redirector Private IP | 32 | | cs-dns-domains | The domains to deploy to | 33 | | dns-rdr-public-ip | Redirector Public IP | 34 | | gophish-ip | | 35 | | gophish-credentials-usernames | | 36 | | gophish-credentials-passwords | | 37 | | smtp-server | The SES SMTP server domain | 38 | | smtp-user | The SES username | 39 | | smtp-password | The SES smtp password | 40 | | phishing-domains | The phishing domains to deploy to | 41 | -------------------------------------------------------------------------------- /deployments/aws/complete/aws_complete.auto.tfvars.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "http-c2-amount": 1, 3 | "http-c2-user": "admin", 4 | "http-c2-domain-mappings": [ 5 | "", 6 | ], 7 | "http-c2-profile": "", 8 | 9 | 10 | "dns-c2-amount": 1, 11 | "dns-c2-user": "admin", 12 | "dns-c2-domain-mappings": [ 13 | "", 14 | ], 15 | "dns-c2-profile": "", 16 | 17 | "cs_license": "", 18 | 19 | "phishing-amount": 1, 20 | "phishing-user": "admin", 21 | "phishing-domain-mappings": [ 22 | "", 23 | ] 24 | } -------------------------------------------------------------------------------- /deployments/aws/complete/aws_complete.outputs.tf: -------------------------------------------------------------------------------- 1 | #c2 2 | output "http-cs-teamserver-passwords" { 3 | value = module.infra-cs-http-c2[*].cs-teamserver-password 4 | } 5 | output "dns-cs-teamserver-passwords" { 6 | value = module.infra-cs-dns-c2[*].cs-teamserver-password 7 | } 8 | 9 | 10 | output "http-c2-private-ip"{ 11 | value = module.infra-cs-http-c2[*].cs-http-c2-private-ip 12 | } 13 | output "dns-c2-private-ip"{ 14 | value = module.infra-cs-dns-c2[*].cs-dns-c2-private-ip 15 | } 16 | 17 | 18 | output "http-rdr-private-ip"{ 19 | value = module.infra-cs-http-c2[*].cs-http-rdr-private-ip 20 | } 21 | output "dns-rdr-private-ip"{ 22 | value = module.infra-cs-dns-c2[*].cs-dns-rdr-private-ip 23 | } 24 | 25 | 26 | output "http-rdr-public-ip"{ 27 | value = module.infra-cs-http-c2[*].cs-http-rdr-public-ip 28 | } 29 | output "dns-rdr-public-ip"{ 30 | value = module.infra-cs-dns-c2[*].cs-dns-rdr-public-ip 31 | } 32 | 33 | output "cs-http-domains" { 34 | value = var.http-c2-domain-mappings 35 | } 36 | output "cs-dns-domains" { 37 | value = var.dns-c2-domain-mappings 38 | } 39 | 40 | #phishing 41 | output "gophish-ip" { 42 | value = module.infra-phishing-gophish[*].gophish-ip 43 | } 44 | 45 | output "gophish-credentials-usernames" { 46 | value = module.infra-phishing-gophish[*].gophish-credentials-username 47 | } 48 | 49 | output "gophish-credentials-passwords" { 50 | value = module.infra-phishing-gophish[*].gophish-credentials-password 51 | } 52 | 53 | output "smtp-server" { 54 | value = module.infra-phishing-gophish[*].smtp-server 55 | } 56 | 57 | output "smtp-user" { 58 | value = module.infra-phishing-gophish[*].smtp-user 59 | } 60 | 61 | output "smtp-password" { 62 | value = module.infra-phishing-gophish[*].smtp-password 63 | } 64 | 65 | output "phishing-domains" { 66 | value = var.phishing-domain-mappings 67 | } 68 | -------------------------------------------------------------------------------- /deployments/aws/complete/aws_complete.providers.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14.0" 3 | required_providers { 4 | acme = { 5 | source = "vancluever/acme" 6 | version = "~> 2.0.0" 7 | } 8 | } 9 | } 10 | 11 | provider "acme" { 12 | server_url = lookup(var.acme_server_urls, var.acme_server_type) 13 | } 14 | 15 | -------------------------------------------------------------------------------- /deployments/aws/complete/aws_complete.tf: -------------------------------------------------------------------------------- 1 | module "infra-cs-http-c2" { 2 | source = "./modules/aws/http-cobalt-strike" 3 | count = var.http-c2-amount 4 | 5 | #managed 6 | cs-http-c2-user = var.http-c2-user 7 | cs-http-c2-domain = var.http-c2-domain-mappings[count.index] 8 | cs-license = var.cs-license 9 | c2-profile = var.http-c2-profile 10 | 11 | #base 12 | vpc_id = var.vpc_id 13 | amis = var.amis 14 | instance_type = var.instance_type 15 | public_subnet_id = var.public_subnet_id 16 | private_subnet_id = var.private_subnet_id 17 | base-internal-security_groups = var.base-internal-security_groups 18 | base-public-security_groups = var.base-public-security_groups 19 | } 20 | 21 | module "infra-cs-dns-c2" { 22 | source = "./modules/aws/dns-cobalt-strike" 23 | count = var.dns-c2-amount 24 | 25 | #managed 26 | cs-dns-c2-user = var.dns-c2-user 27 | cs-dns-c2-domain = var.dns-c2-domain-mappings[count.index] 28 | cs-license = var.cs-license 29 | c2-profile = var.dns-c2-profile 30 | 31 | #base 32 | vpc_id = var.vpc_id 33 | amis = var.amis 34 | instance_type = var.instance_type 35 | public_subnet_id = var.public_subnet_id 36 | private_subnet_id = var.private_subnet_id 37 | base-internal-security_groups = var.base-internal-security_groups 38 | base-public-security_groups = var.base-public-security_groups 39 | } 40 | 41 | module "infra-phishing-gophish"{ 42 | source = "./modules/aws/phishing-gophish" 43 | count = var.phishing-amount 44 | 45 | #managed 46 | phishing-user = var.phishing-user 47 | phishing-domain = var.phishing-domain-mappings[count.index] 48 | 49 | #base 50 | vpc_id = var.vpc_id 51 | amis = var.amis 52 | instance_type = var.instance_type 53 | public_subnet_id = var.public_subnet_id 54 | private_subnet_id = var.private_subnet_id 55 | base-internal-security_groups = var.base-internal-security_groups 56 | base-public-security_groups = var.base-public-security_groups 57 | 58 | } -------------------------------------------------------------------------------- /deployments/aws/complete/aws_complete.variables.tf: -------------------------------------------------------------------------------- 1 | variable "http-c2-amount"{ 2 | type = number 3 | default = 1 4 | } 5 | variable "dns-c2-amount"{ 6 | type = number 7 | default = 1 8 | } 9 | variable "phishing-amount"{ 10 | type = number 11 | default = 1 12 | } 13 | 14 | 15 | variable "dns-c2-user" { 16 | type = string 17 | default = "admin" 18 | description = "User to authenticate as" 19 | } 20 | variable "http-c2-user" { 21 | type = string 22 | default = "admin" 23 | description = "User to authenticate as" 24 | } 25 | variable "phishing-user" { 26 | type = string 27 | default = "admin" 28 | description = "User to authenticate as" 29 | } 30 | 31 | 32 | variable "dns-c2-domain-mappings" { 33 | type = list(string) 34 | } 35 | variable "http-c2-domain-mappings" { 36 | type = list(string) 37 | } 38 | variable "phishing-domain-mappings" { 39 | type = list(string) 40 | } 41 | 42 | variable "dns-c2-profile" { 43 | type = string 44 | description = "The name of the C2 profile file" 45 | } 46 | variable "http-c2-profile" { 47 | type = string 48 | description = "The name of the C2 profile file" 49 | } 50 | 51 | variable "cs-license"{ 52 | type = string 53 | #sensitive = true 54 | } 55 | -------------------------------------------------------------------------------- /deployments/aws/phishing/README.md: -------------------------------------------------------------------------------- 1 | # aws_phishing 2 | 3 | Create a Gophish server with an Amazon SES relay for phishing in AWS. 4 | 5 | ## Arguments 6 | 7 | | Name | Required | Value Type | Description | 8 | |--------------------------|----------|--------------|---------------------------------| 9 | | phishing-amount | No | number | The amount of servers to add | 10 | | phishing-user | No | string | The User to authenticate as | 11 | | phishing-domain-mappings | Yes | list(string) | The domain names to deploy on | 12 | 13 | ## Outputs 14 | 15 | | Name | Description | 16 | |------------------------------|----------------------------| 17 | | gophish-ip | | 18 | | gophish-credentials-username | | 19 | | gophish-credentials-password | | 20 | | smtp-server | The SES SMTP server domain | 21 | | smtp-user | The SES username | 22 | | smtp-password | The SES smtp password | 23 | -------------------------------------------------------------------------------- /deployments/aws/phishing/aws_phishing.auto.tfvars.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "phishing-amount": 1, 3 | "phishing-user": "admin", 4 | "phishing-domain-mappings": [ 5 | "", 6 | ] 7 | } -------------------------------------------------------------------------------- /deployments/aws/phishing/aws_phishing.outputs.tf: -------------------------------------------------------------------------------- 1 | output "gophish-ip" { 2 | value = module.infra-phishing-gophish[*].gophish-ip 3 | } 4 | 5 | output "gophish-credentials-usernames" { 6 | value = module.infra-phishing-gophish[*].gophish-credentials-username 7 | } 8 | 9 | output "gophish-credentials-passwords" { 10 | value = module.infra-phishing-gophish[*].gophish-credentials-password 11 | } 12 | 13 | output "smtp-server" { 14 | value = module.infra-phishing-gophish[*].smtp-server 15 | } 16 | 17 | output "smtp-user" { 18 | value = module.infra-phishing-gophish[*].smtp-user 19 | } 20 | 21 | output "smtp-password" { 22 | value = module.infra-phishing-gophish[*].smtp-password 23 | } 24 | 25 | output "phishing-domains" { 26 | value = var.phishing-domain-mappings 27 | } -------------------------------------------------------------------------------- /deployments/aws/phishing/aws_phishing.providers.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14.0" 3 | required_providers { 4 | acme = { 5 | source = "vancluever/acme" 6 | version = "~> 2.0.0" 7 | } 8 | } 9 | } 10 | 11 | provider "acme" { 12 | server_url = lookup(var.acme_server_urls, var.acme_server_type) 13 | } -------------------------------------------------------------------------------- /deployments/aws/phishing/aws_phishing.tf: -------------------------------------------------------------------------------- 1 | module "infra-phishing-gophish"{ 2 | source = "./modules/aws/phishing-gophish" 3 | count = var.phishing-amount 4 | 5 | #managed 6 | phishing-user = var.phishing-user 7 | phishing-domain = var.phishing-domain-mappings[count.index] 8 | 9 | #base 10 | vpc_id = var.vpc_id 11 | amis = var.amis 12 | instance_type = var.instance_type 13 | public_subnet_id = var.public_subnet_id 14 | private_subnet_id = var.private_subnet_id 15 | base-internal-security_groups = var.base-internal-security_groups 16 | base-public-security_groups = var.base-public-security_groups 17 | 18 | } -------------------------------------------------------------------------------- /deployments/aws/phishing/aws_phishing.variables.tf: -------------------------------------------------------------------------------- 1 | variable "phishing-amount"{ 2 | type = number 3 | default = 1 4 | } 5 | 6 | variable "phishing-user" { 7 | type = string 8 | default = "admin" 9 | description = "User to authenticate as" 10 | } 11 | 12 | variable "phishing-domain-mappings" { 13 | type = list(string) 14 | } 15 | -------------------------------------------------------------------------------- /environment_variables.auto.tfvars.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "vpc_id" : "", 3 | "public_subnet_id" : "", 4 | "private_subnet_id" : "", 5 | "base-internal-security_groups" : [""], 6 | "base-public-security_groups" : [""] 7 | } 8 | -------------------------------------------------------------------------------- /modules/ansible/cobalt-strike/README.md: -------------------------------------------------------------------------------- 1 | # cobalt-strike 2 | 3 | Deploys a Cobalt Strike Instance using Ansible 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "cs-ansible"{ 9 | source = "./modules/ansible/cobalt-strike" 10 | 11 | ansible-user = var.cs-dns-c2-user 12 | ip = module.dns-c2.dns-c2-private-ip 13 | domain = var.cs-dns-c2-domain 14 | bind-address = module.dns-rdir.dns-rdr-public-ip 15 | c2-profile = var.c2-profile 16 | cs-license = var.cs-license 17 | teamserver-password = random_password.dns-cs-teamserver-password.result 18 | } 19 | 20 | ``` 21 | 22 | ## Arguments 23 | 24 | | Name | Required | Value Type | Description | 25 | |---------------------|----------|--------------|-------------------------------------------------| 26 | | ansible-user | Yes | string | The User to authenticate as | 27 | | ip | Yes | string | The host IP to run the playbook on | 28 | | cs-license | Yes | string | Cobalt Strike License Key | 29 | | bind-address | Yes | string | The address to bind the CS listener to | 30 | | teamserver-password | Yes | string | The password for the CS teamserver | 31 | | c2-profile | Yes | string | The name of the C2 profile file | 32 | | domain | Yes | string | The domain name to deploy on | 33 | | arguments | No | list(string) | Any additional Ansible arguments to pass in | 34 | | envs | no | list(string) | Environment variables to pass in (-e delimited) | 35 | -------------------------------------------------------------------------------- /modules/ansible/cobalt-strike/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | } -------------------------------------------------------------------------------- /modules/ansible/cobalt-strike/main.tf: -------------------------------------------------------------------------------- 1 | module "cs-config-ansible"{ 2 | source = "../core" 3 | 4 | #managed 5 | user = var.ansible-user 6 | playbook = local.ansible-config-playbook 7 | ip = var.ip 8 | } 9 | 10 | module "cs-ansible"{ 11 | source = "../core" 12 | depends_on = [module.cs-config-ansible] 13 | 14 | user = var.ansible-user 15 | playbook = local.ansible-cs-playbook 16 | arguments = concat(["--extra-vars 'license_key=${var.cs-license} bind_address=${var.bind-address} teamserver_password=${var.teamserver-password} c2_profile=${var.c2-profile} domain=${var.domain}'"], var.arguments) 17 | ip = var.ip 18 | envs = var.envs 19 | } -------------------------------------------------------------------------------- /modules/ansible/cobalt-strike/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-config-playbook = "${local.playbook-path}/core_config.yml" 3 | ansible-cs-playbook = "${local.playbook-path}/cobalt_strike.yml" 4 | } 5 | 6 | variable "ansible-user" { 7 | type = string 8 | } 9 | 10 | variable "ip" { 11 | description = "Host to run playbook on" 12 | type = string 13 | } 14 | 15 | variable "domain" { 16 | description = "C2 Domain to host from" 17 | type = string 18 | } 19 | 20 | variable "cs-license"{ 21 | type = string 22 | } 23 | 24 | variable "bind-address"{ 25 | type = string 26 | } 27 | 28 | variable "teamserver-password"{ 29 | type = string 30 | } 31 | 32 | variable "c2-profile"{ 33 | type = string 34 | } 35 | 36 | variable "arguments" { 37 | default = [] 38 | type = list(string) 39 | description = "Any additional Ansible arguments to pass in." 40 | } 41 | 42 | variable "envs" { 43 | default = [] 44 | type = list(string) 45 | description = "Environment variables to pass in. Will be delimited by -e automatically." 46 | } 47 | -------------------------------------------------------------------------------- /modules/ansible/core/README.md: -------------------------------------------------------------------------------- 1 | # ansible 2 | 3 | Runs an ansible playbook on a specific resource 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "ansible"{ 9 | source = "../core" 10 | depends_on = [module.cs-config-ansible] 11 | 12 | user = var.ansible-user 13 | playbook = local.ansible-cs-playbook 14 | arguments = concat(["--extra-vars 'license_key=${var.cs-license} bind_address=${var.bind-address} teamserver_password=${var.teamserver-password} c2_profile=${var.c2-profile} domain=${var.domain}'"], var.arguments) 15 | ip = var.ip 16 | envs = var.envs 17 | } 18 | ``` 19 | 20 | ## Arguments 21 | 22 | | Name | Required | Value Type | Description | 23 | |-----------|----------|--------------|-------------------------------------------------| 24 | | playbook | Yes | string | Playbook to run | 25 | | user | Yes | string | The User to authenticate as | 26 | | ip | Yes | string | The host IP to run the playbook on | 27 | | arguments | No | list(string) | Any additional Ansible arguments to pass in | 28 | | envs | no | list(string) | Environment variables to pass in (-e delimited) | 29 | -------------------------------------------------------------------------------- /modules/ansible/core/main.tf: -------------------------------------------------------------------------------- 1 | resource "null_resource" "ansible_provisioner" { 2 | 3 | triggers = { 4 | policy_sha1 = sha1(file(var.playbook)) 5 | } 6 | 7 | provisioner "local-exec" { 8 | command = "ansible-playbook ${join(" ", compact(var.arguments))} --user=${var.user} --private-key=${local.ssh-keys-path}/${var.ip} -i ${var.ip},${join(" -e ", compact(var.envs))} --extra-vars 'ansible_python_interpreter=/usr/bin/python3' ${var.playbook}" 9 | 10 | environment = { 11 | ANSIBLE_HOST_KEY_CHECKING = "False" 12 | } 13 | } 14 | 15 | lifecycle { 16 | create_before_destroy = true 17 | } 18 | } -------------------------------------------------------------------------------- /modules/ansible/core/variables.tf: -------------------------------------------------------------------------------- 1 | locals{ 2 | data-path = "${path.root}/data" 3 | ssh-keys-path = "${local.data-path}/ssh_keys" 4 | } 5 | 6 | variable "playbook" { 7 | description = "Playbook to run" 8 | type = string 9 | } 10 | 11 | variable "ip" { 12 | description = "Host to run playbook on" 13 | type = string 14 | } 15 | 16 | variable "user" { 17 | default = "admin" 18 | description = "User to authenticate as" 19 | type = string 20 | } 21 | 22 | variable "arguments" { 23 | default = [] 24 | type = list(string) 25 | description = "Arguments" 26 | } 27 | 28 | variable "envs" { 29 | default = [] 30 | type = list(string) 31 | description = "Environment variables" 32 | } 33 | -------------------------------------------------------------------------------- /modules/ansible/gophish/README.md: -------------------------------------------------------------------------------- 1 | # gophish 2 | 3 | Deploys a GoPhish server using Ansible. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "infra-phishing-gophish"{ 9 | source = "./modules/aws/phishing-gophish" 10 | count = var.phishing-amount 11 | 12 | #managed 13 | phishing-user = var.phishing-user 14 | phishing-domain = var.phishing-domain-mappings[count.index] 15 | 16 | #base 17 | vpc_id = var.vpc_id 18 | amis = var.amis 19 | instance_type = var.instance_type 20 | public_subnet_id = var.public_subnet_id 21 | private_subnet_id = var.private_subnet_id 22 | base-internal-security_groups = var.base-internal-security_groups 23 | base-public-security_groups = var.base-public-security_groups 24 | } 25 | ``` 26 | 27 | ## Arguments 28 | 29 | | Name | Required | Value Type | Description | 30 | |----------------|----------|--------------|-------------------------------------------------| 31 | | ansible-user | Yes | string | The User to authenticate as | 32 | | ip | Yes | string | The host IP to run the playbook on | 33 | | gophish-domain | Yes | string | The domain to deploy on | 34 | | arguments | No | list(string) | Any additional Ansible arguments to pass in | 35 | | envs | no | list(string) | Environment variables to pass in (-e delimited) | 36 | -------------------------------------------------------------------------------- /modules/ansible/gophish/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | } -------------------------------------------------------------------------------- /modules/ansible/gophish/main.tf: -------------------------------------------------------------------------------- 1 | module "gophish-config-ansible"{ 2 | source = "../core" 3 | 4 | playbook = local.ansible-config-playbook 5 | user = var.ansible-user 6 | ip = var.ip 7 | } 8 | 9 | module "gophish-ansible"{ 10 | source = "../core" 11 | depends_on = [module.gophish-config-ansible] 12 | 13 | playbook = local.ansible-gophish-playbook 14 | user = var.ansible-user 15 | arguments = ["--extra-vars 'gophish_user=${var.ansible-user} gophish_tls_private_key_path=../certificates/${var.gophish-domain}_privkey.pem gophish_tls_public_key_path=../certificates/${var.gophish-domain}_cert.pem'"] 16 | ip = var.ip 17 | } 18 | -------------------------------------------------------------------------------- /modules/ansible/gophish/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-config-playbook = "${local.playbook-path}/core_config.yml" 3 | ansible-gophish-playbook = "${local.playbook-path}/gophish.yml" 4 | } 5 | 6 | variable "ansible-user" { 7 | type = string 8 | } 9 | 10 | variable "ip" { 11 | type = string 12 | description = "Host to run playbook on" 13 | } 14 | 15 | variable "gophish-domain" { 16 | type = string 17 | } 18 | 19 | variable "arguments" { 20 | default = [] 21 | type = list(string) 22 | description = "Any additional Ansible arguments to pass in." 23 | } 24 | 25 | variable "envs" { 26 | default = [] 27 | type = list(string) 28 | description = "Environment variables to pass in. Will be delimited by -e automatically." 29 | } 30 | -------------------------------------------------------------------------------- /modules/aws/create-dns-record/README.md: -------------------------------------------------------------------------------- 1 | # create-dns-record 2 | 3 | Adds records to a domain using AWS Route53 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "create_a_record" { 9 | source = "./modules/aws/create-dns-record" 10 | 11 | domain = "domain.com" 12 | type = "A" 13 | record = { 14 | "domain.com" = "192.168.0.1" 15 | } 16 | } 17 | ``` 18 | 19 | ## Arguments 20 | 21 | | Name | Required | Value Type | Description 22 | |---------------------------| -------- | ---------- | ----------- 23 | |`domain` | Yes | String | The domain to add records to 24 | |`type` | Yes | String | The record type to add. Valid values are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT. 25 | |`records` | Yes | Map | A map of records to add. Domains as keys and IPs as values. 26 | |`ttl` | No | Integer | The TTL of the record(s). Default value is 300 27 | 28 | ## Outputs 29 | 30 | | Name | Value Type | Description 31 | |---------------------------| ---------- | ----------- 32 | |`records` | Map | Map containing the records added to the domain. Domains as keys and IPs as values. 33 | 34 | -------------------------------------------------------------------------------- /modules/aws/create-dns-record/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_route53_zone" "selected_dns_zone" { 2 | name = var.domain 3 | } 4 | 5 | resource "aws_route53_record" "record" { 6 | zone_id = data.aws_route53_zone.selected_dns_zone.zone_id 7 | name = element(keys(var.record), 0) 8 | type = var.type 9 | ttl = var.ttl 10 | records = [lookup(var.record, element(keys(var.record), 0))] 11 | } 12 | 13 | #amount can be utilized to pass in a large map of records for a particular type. This method is being retired for the above which is more simplistic 14 | //resource "aws_route53_record" "record" { 15 | // count = var.amount 16 | // 17 | // zone_id = data.aws_route53_zone.selected_dns_zone.zone_id 18 | // name = element(keys(var.records), count.index) 19 | // type = var.type 20 | // ttl = var.ttl 21 | // records = [lookup(var.records, element(keys(var.records), count.index))] 22 | //} 23 | -------------------------------------------------------------------------------- /modules/aws/create-dns-record/outputs.tf: -------------------------------------------------------------------------------- 1 | output "record" { 2 | value = var.record 3 | } -------------------------------------------------------------------------------- /modules/aws/create-dns-record/variables.tf: -------------------------------------------------------------------------------- 1 | variable "domain" { 2 | type = string 3 | } 4 | 5 | variable "type" { 6 | type = string 7 | } 8 | 9 | variable "ttl" { 10 | type = number 11 | default = 300 12 | } 13 | 14 | variable "record" { 15 | type = map(string) 16 | } 17 | -------------------------------------------------------------------------------- /modules/aws/dns-c2/README.md: -------------------------------------------------------------------------------- 1 | # dns-c2 2 | 3 | Creates a DNS C2 server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "dns-c2" { 9 | source = "../dns-c2" 10 | 11 | #managed 12 | user = var.cs-dns-c2-user 13 | subnet_id = var.private_subnet_id 14 | security_groups = var.base-internal-security_groups 15 | security_groups_inbound_dns = var .base-public-security_groups 16 | 17 | #base 18 | vpc_id = var.vpc_id 19 | instance_type = var.instance_type 20 | amis = var.amis 21 | } 22 | ``` 23 | 24 | ## Arguments 25 | 26 | | Name | Required | Value Type | Description | 27 | |-----------------------------|----------|--------------|--------------------------------------------------------| 28 | | user | Yes | string | The User to authenticate as | 29 | | subnet_id | Yes | string | Subnet ID to create instance in | 30 | | security_groups | No | list(string) | Security groups to add | 31 | | security_groups_inbound_dns | No | list(string) | Security groups to allow inbound port 53UDP(DNS) from. | 32 | | install | No | list(string) | Scripts to install inline. Not recommended. | 33 | 34 | ## Outputs 35 | 36 | | Name | Description 37 | |---------------------------|----------- 38 | |`dns-c2-private-ip` | IP of created instance. 39 | -------------------------------------------------------------------------------- /modules/aws/dns-c2/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /modules/aws/dns-c2/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | resource "random_id" "server" { 4 | byte_length = 4 5 | } 6 | 7 | resource "tls_private_key" "ssh" { 8 | algorithm = "RSA" 9 | rsa_bits = 4096 10 | } 11 | 12 | resource "aws_key_pair" "dns-c2" { 13 | key_name = "dns-c2-key-${random_id.server.hex}" 14 | public_key = tls_private_key.ssh.public_key_openssh 15 | } 16 | 17 | resource "aws_instance" "dns-c2" { 18 | tags = { 19 | Name = "dns-c2-${random_id.server.hex}" 20 | } 21 | 22 | ami = var.amis[data.aws_region.current.name] 23 | instance_type = var.instance_type 24 | key_name = aws_key_pair.dns-c2.key_name 25 | vpc_security_group_ids = concat(var.security_groups, [aws_security_group.dns-c2.id]) 26 | subnet_id = var.subnet_id 27 | associate_public_ip_address = false 28 | 29 | #this provisioner exists for 2 reasons: 30 | # 1. To support custom scripts, which ideally should be included in an ansible role/task rather than invoked inline like this. 31 | # 2. To ensure that SSH is open before Ansible local-exec provisioner attempts its execution 32 | provisioner "remote-exec" { 33 | scripts = var.install 34 | 35 | connection { 36 | host = self.private_ip 37 | type = "ssh" 38 | user = var.user 39 | private_key = tls_private_key.ssh.private_key_pem 40 | } 41 | } 42 | 43 | provisioner "local-exec" { 44 | command = "echo \"${tls_private_key.ssh.private_key_pem}\" > ${local.ssh-keys-path}/${self.private_ip} && echo \"${tls_private_key.ssh.public_key_openssh}\" > ${local.ssh-keys-path}/${self.private_ip}.pub && chmod 600 ${local.ssh-keys-path}/*" 45 | } 46 | 47 | provisioner "local-exec" { 48 | when = destroy 49 | command = "rm ${path.root}/data/ssh_keys/${self.private_ip}*" 50 | } 51 | 52 | } 53 | 54 | data "template_file" "ssh_config" { 55 | depends_on = [aws_instance.dns-c2] 56 | 57 | template = file("${local.templates-path}/ssh_config.tpl") 58 | vars = { 59 | name = "dns_c2_${aws_instance.dns-c2.private_ip}" 60 | hostname = aws_instance.dns-c2.private_ip 61 | user = var.user 62 | identityfile = "${local.ssh-keys-path}/${aws_instance.dns-c2.private_ip}" 63 | } 64 | } 65 | 66 | resource "null_resource" "gen_ssh_config" { 67 | depends_on = [data.template_file.ssh_config] 68 | 69 | triggers = { 70 | template_rendered = data.template_file.ssh_config.rendered 71 | serverId = random_id.server.hex 72 | serverIp = aws_instance.dns-c2.private_ip 73 | } 74 | 75 | provisioner "local-exec" { 76 | command = "echo '${data.template_file.ssh_config.rendered}' > ${local.ssh-configs-path}/${self.triggers.serverIp}_config" 77 | } 78 | 79 | provisioner "local-exec" { 80 | when = destroy 81 | command = "rm ${path.root}/data/ssh_configs/${self.triggers.serverIp}_config" 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /modules/aws/dns-c2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "dns-c2-private-ip" { 2 | value = tostring(aws_instance.dns-c2.private_ip) 3 | } 4 | -------------------------------------------------------------------------------- /modules/aws/dns-c2/security_group.tf: -------------------------------------------------------------------------------- 1 | resource "aws_security_group" "dns-c2" { 2 | tags = { 3 | Name = "red-team-dns-c2-${random_id.server.hex}" 4 | } 5 | name = "red-team-dns-c2-${random_id.server.hex}" 6 | description = "Red Team Infra - DNS C2" 7 | vpc_id = var.vpc_id 8 | 9 | ingress { 10 | from_port = 53 11 | to_port = 53 12 | protocol = "udp" 13 | security_groups = var.security_groups_inbound_dns 14 | } 15 | 16 | egress { 17 | from_port = 53 18 | to_port = 53 19 | protocol = "udp" 20 | cidr_blocks = ["0.0.0.0/0"] 21 | } 22 | egress { 23 | from_port = 80 24 | to_port = 80 25 | protocol = "tcp" 26 | cidr_blocks = ["0.0.0.0/0"] 27 | } 28 | egress { 29 | from_port = 443 30 | to_port = 443 31 | protocol = "tcp" 32 | cidr_blocks = ["0.0.0.0/0"] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /modules/aws/dns-c2/variables.tf: -------------------------------------------------------------------------------- 1 | locals{ 2 | ansible-playbook = "${local.playbook-path}/core_config.yml" 3 | } 4 | 5 | variable "user" { 6 | description = "User to authenticate as" 7 | type = string 8 | } 9 | 10 | variable "subnet_id" { 11 | type = string 12 | } 13 | 14 | variable "security_groups"{ 15 | type = list(string) 16 | default=[""] 17 | } 18 | 19 | variable "security_groups_inbound_dns"{ 20 | type = list(string) 21 | default=[""] 22 | } 23 | 24 | variable "install" { 25 | type = list(string) 26 | default = [] 27 | } 28 | -------------------------------------------------------------------------------- /modules/aws/dns-cobalt-strike/README.md: -------------------------------------------------------------------------------- 1 | # dns-cobalt-strike 2 | 3 | Creates a Cobalt Strike DNS C2 server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "cs-dns-c2" { 9 | source = "./modules/aws/dns-cobalt-strike" 10 | 11 | #managed 12 | cs-dns-c2-user = var.dns-c2-user 13 | cs-dns-c2-domain = var.dns-c2-domain-mappings[count.index] 14 | cs-license = var.cs-license 15 | c2-profile = var.dns-c2-profile 16 | 17 | #base 18 | vpc_id = var.vpc_id 19 | amis = var.amis 20 | instance_type = var.instance_type 21 | public_subnet_id = var.public_subnet_id 22 | private_subnet_id = var.private_subnet_id 23 | base-internal-security_groups = var.base-internal-security_groups 24 | base-public-security_groups = var.base-public-security_groups 25 | } 26 | ``` 27 | 28 | ## Arguments 29 | 30 | | Name | Required | Value Type | Description | 31 | |------------------|----------|------------|---------------------------------| 32 | | cs-dns-c2-user | Yes | string | The User to authenticate as | 33 | | cs-dns-c2-domain | Yes | string | The domain name to deploy on | 34 | | cs-license | Yes | string | Cobalt Strike License Key | 35 | | c2-profile | Yes | string | The name of the C2 profile file | 36 | 37 | ## Outputs 38 | 39 | | Name | Description | 40 | |------------------------|-----------------------| 41 | | cs-teamserver-password | Teamserver Password | 42 | | cs-dns-c2-private-ip | C2 Private IP | 43 | | cs-dns-rdr-private-ip | Redirector Private IP | 44 | | cs-dns-rdr-public-ip | Redirector Public IP | -------------------------------------------------------------------------------- /modules/aws/dns-cobalt-strike/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | 22 | variable "public_subnet_id" { 23 | type = string 24 | } 25 | 26 | variable "private_subnet_id" { 27 | type = string 28 | } 29 | 30 | variable "base-internal-security_groups"{ 31 | type = list(string) 32 | } 33 | 34 | variable "base-public-security_groups" { 35 | type = list(string) 36 | } 37 | -------------------------------------------------------------------------------- /modules/aws/dns-cobalt-strike/main.tf: -------------------------------------------------------------------------------- 1 | resource "random_password" "dns-cs-teamserver-password" { 2 | length = 15 3 | special = true 4 | override_special = "@%)-_+[}:" 5 | } 6 | 7 | module "dns-c2" { 8 | source = "../dns-c2" 9 | 10 | #managed 11 | user = var.cs-dns-c2-user 12 | subnet_id = var.private_subnet_id 13 | security_groups = var.base-internal-security_groups 14 | security_groups_inbound_dns = var .base-public-security_groups 15 | 16 | #base 17 | vpc_id = var.vpc_id 18 | instance_type = var.instance_type 19 | amis = var.amis 20 | } 21 | 22 | module "dns-rdir" { 23 | source = "../dns-rdir" 24 | depends_on = [module.dns-c2] 25 | 26 | #managed 27 | user = var.cs-dns-c2-user 28 | subnet_id = var.public_subnet_id 29 | security_groups = var.base-public-security_groups 30 | redirect_to = module.dns-c2.dns-c2-private-ip 31 | 32 | #base 33 | vpc_id = var.vpc_id 34 | instance_type = var.instance_type 35 | amis = var.amis 36 | } 37 | 38 | module "dns-rdir-naked-A-record" { 39 | source = "../create-dns-record" 40 | depends_on = [module.dns-rdir] 41 | 42 | domain = local.cs-dns-c2-tld 43 | type = "A" 44 | record = { 45 | (var.cs-dns-c2-domain) = module.dns-rdir.dns-rdr-public-ip 46 | } 47 | } 48 | 49 | module "dns-rdir-nameserver-A-record" { 50 | source = "../create-dns-record" 51 | depends_on = [module.dns-rdir] 52 | 53 | domain = local.cs-dns-c2-tld 54 | type = "A" 55 | record = { 56 | "ns1.${var.cs-dns-c2-domain}" = module.dns-rdir.dns-rdr-public-ip 57 | } 58 | } 59 | 60 | module "dns-rdir-NS-record" { 61 | source = "../create-dns-record" 62 | depends_on = [module.dns-rdir] 63 | 64 | domain = local.cs-dns-c2-tld 65 | type = "NS" 66 | record = { 67 | "dns.${var.cs-dns-c2-domain}" = "ns1.${var.cs-dns-c2-domain}" 68 | } 69 | } 70 | 71 | module "dns-c2-create-certs" { 72 | source = "../letsencrypt/create-cert-dns" 73 | depends_on = [module.dns-rdir-naked-A-record] 74 | 75 | #managed 76 | domain = var.cs-dns-c2-domain 77 | subject_alternative_names = { 78 | (var.cs-dns-c2-domain) = ["*.${var.cs-dns-c2-domain}"] 79 | } 80 | 81 | reg_email = "${var.cs-dns-c2-user}@${local.cs-dns-c2-tld}" 82 | dns_provider = "route53" 83 | } 84 | 85 | module "dns-c2-ansible"{ 86 | source = "../../ansible/cobalt-strike" 87 | depends_on = [module.dns-c2, module.dns-c2-create-certs] 88 | 89 | #managed 90 | ansible-user = var.cs-dns-c2-user 91 | ip = module.dns-c2.dns-c2-private-ip 92 | domain = var.cs-dns-c2-domain 93 | bind-address = module.dns-rdir.dns-rdr-public-ip 94 | c2-profile = var.c2-profile 95 | cs-license = var.cs-license 96 | teamserver-password = random_password.dns-cs-teamserver-password.result 97 | } 98 | -------------------------------------------------------------------------------- /modules/aws/dns-cobalt-strike/outputs.tf: -------------------------------------------------------------------------------- 1 | output "cs-teamserver-password" { 2 | value = random_password.dns-cs-teamserver-password.result 3 | } 4 | 5 | output "cs-dns-c2-private-ip"{ 6 | value = module.dns-c2.dns-c2-private-ip 7 | } 8 | 9 | output "cs-dns-rdr-private-ip"{ 10 | value = module.dns-rdir.dns-rdr-private-ip 11 | } 12 | 13 | output "cs-dns-rdr-public-ip"{ 14 | value = module.dns-rdir.dns-rdr-public-ip 15 | } 16 | -------------------------------------------------------------------------------- /modules/aws/dns-cobalt-strike/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | // cs-ansible-playbook = "${local.playbook-path}/cobalt_strike.yml" 3 | cs-dns-c2-tld = join(".",tolist([reverse(split(".", var.cs-dns-c2-domain ))[1],reverse(split(".", var.cs-dns-c2-domain ))[0]])) 4 | } 5 | 6 | 7 | variable "cs-dns-c2-user" { 8 | type = string 9 | description = "User to authenticate as" 10 | } 11 | 12 | variable "cs-dns-c2-domain" { 13 | type = string 14 | } 15 | 16 | variable "cs-license"{ 17 | type = string 18 | } 19 | 20 | variable "c2-profile" { 21 | type = string 22 | description = "The name of the C2 profile file" 23 | } -------------------------------------------------------------------------------- /modules/aws/dns-rdir/README.md: -------------------------------------------------------------------------------- 1 | # dns-rdir 2 | 3 | Creates a DNS Redirector server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "dns-rdir" { 9 | source = "../dns-rdir" 10 | 11 | #managed 12 | user = var.cs-dns-c2-user 13 | subnet_id = var.public_subnet_id 14 | security_groups = var.base-public-security_groups 15 | redirect_to = module.dns-c2.dns-c2-private-ip 16 | 17 | #base 18 | vpc_id = var.vpc_id 19 | instance_type = var.instance_type 20 | amis = var.amis 21 | } 22 | ``` 23 | 24 | ## Arguments 25 | 26 | | Name | Required | Value Type | Description | 27 | |-----------------|----------|--------------|---------------------------------------------| 28 | | user | Yes | string | The User to authenticate as | 29 | | subnet_id | Yes | string | Subnet ID to create instance in | 30 | | redirect_to | Yes | string | The back-end C2 server to redirect to | 31 | | security_groups | No | list(string) | Security groups to add | 32 | | install | No | list(string) | Scripts to install inline. Not recommended. | 33 | 34 | ## Outputs 35 | 36 | | Name | Description | 37 | |--------------------|-----------------------------| 38 | | dns-rdr-private-ip | The redirector's private IP | 39 | | dns-rdr-public-ip | The redirector's public IP | -------------------------------------------------------------------------------- /modules/aws/dns-rdir/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /modules/aws/dns-rdir/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | resource "random_id" "server" { 4 | byte_length = 4 5 | } 6 | 7 | resource "tls_private_key" "ssh" { 8 | algorithm = "RSA" 9 | rsa_bits = 4096 10 | } 11 | 12 | data "aws_vpc" "selected" { 13 | id = var.vpc_id 14 | } 15 | 16 | resource "aws_key_pair" "dns-rdir" { 17 | key_name = "dns-rdir-key-${random_id.server.hex}" 18 | public_key = tls_private_key.ssh.public_key_openssh 19 | } 20 | 21 | resource "aws_instance" "dns-rdir" { 22 | tags = { 23 | Name = "dns-rdir-${random_id.server.hex}" 24 | } 25 | 26 | ami = var.amis[data.aws_region.current.name] 27 | instance_type = var.instance_type 28 | key_name = aws_key_pair.dns-rdir.key_name 29 | vpc_security_group_ids = concat(var.security_groups, [aws_security_group.dns-rdir.id]) 30 | subnet_id = var.subnet_id 31 | associate_public_ip_address = true 32 | 33 | #this provisioner exists for 2 reasons: 34 | # 1. To support custom scripts, which ideally should be included in an ansible role/task rather than invoked inline like this. 35 | # 2. To ensure that SSH is open before Ansible local-exec provisioner attempts its execution 36 | provisioner "remote-exec" { 37 | scripts = var.install 38 | 39 | connection { 40 | type = "ssh" 41 | user = var.user 42 | private_key = tls_private_key.ssh.private_key_pem 43 | host = self.private_ip 44 | } 45 | } 46 | 47 | provisioner "local-exec" { 48 | command = "echo \"${tls_private_key.ssh.private_key_pem}\" > ${local.ssh-keys-path}/${self.private_ip} && echo \"${tls_private_key.ssh.public_key_openssh}\" > ${local.ssh-keys-path}/${self.private_ip}.pub && chmod 600 ${local.ssh-keys-path}/*" 49 | } 50 | 51 | provisioner "local-exec" { 52 | when = destroy 53 | command = "rm ${path.root}/data/ssh_keys/${self.private_ip}*" 54 | } 55 | 56 | } 57 | 58 | data "template_file" "ssh_config" { 59 | depends_on = [aws_instance.dns-rdir] 60 | 61 | template = file("${local.templates-path}/ssh_config.tpl") 62 | vars = { 63 | name = "dns_rdir_${aws_instance.dns-rdir.private_ip}" 64 | hostname = aws_instance.dns-rdir.private_ip 65 | user = var.user 66 | identityfile = "${local.ssh-keys-path}/${aws_instance.dns-rdir.private_ip}" 67 | } 68 | } 69 | 70 | resource "null_resource" "gen_ssh_config" { 71 | depends_on = [data.template_file.ssh_config] 72 | 73 | triggers = { 74 | template_rendered = data.template_file.ssh_config.rendered 75 | serverId = random_id.server.hex 76 | serverIp = aws_instance.dns-rdir.private_ip 77 | } 78 | 79 | provisioner "local-exec" { 80 | command = "echo '${data.template_file.ssh_config.rendered}' > ${local.ssh-configs-path}/${self.triggers.serverIp}_config" 81 | } 82 | 83 | provisioner "local-exec" { 84 | when = destroy 85 | command = "rm ${path.root}/data/ssh_configs/${self.triggers.serverIp}_config" 86 | } 87 | } 88 | 89 | module "dns-rdir-config-ansible"{ 90 | source = "../../ansible/core" 91 | depends_on = [aws_instance.dns-rdir, null_resource.gen_ssh_config] 92 | 93 | user = var.user 94 | playbook = local.ansible-config-playbook 95 | ip = aws_instance.dns-rdir.private_ip 96 | } 97 | 98 | 99 | module "dns-rdir-ansible"{ 100 | source = "../../ansible/core" 101 | depends_on = [module.dns-rdir-config-ansible] 102 | 103 | user = var.user 104 | playbook = local.ansible-rdir-playbook 105 | arguments = ["--extra-vars 'redirect_to=${var.redirect_to} redirector_type=dns'"] 106 | ip = aws_instance.dns-rdir.private_ip 107 | } 108 | -------------------------------------------------------------------------------- /modules/aws/dns-rdir/outputs.tf: -------------------------------------------------------------------------------- 1 | output "dns-rdr-private-ip" { 2 | value = tostring(aws_instance.dns-rdir.private_ip) 3 | } 4 | 5 | output "dns-rdr-public-ip" { 6 | value = tostring(aws_instance.dns-rdir.public_ip) 7 | } 8 | -------------------------------------------------------------------------------- /modules/aws/dns-rdir/security_group.tf: -------------------------------------------------------------------------------- 1 | resource "aws_security_group" "dns-rdir" { 2 | tags = { 3 | Name = "red-team-dns-rdir-${random_id.server.hex}" 4 | } 5 | name = "red-team-dns-rdir-${random_id.server.hex}" 6 | description = "Red Team Infra - DNS C2 Redirector" 7 | vpc_id = var.vpc_id 8 | 9 | ingress { 10 | from_port = 53 11 | to_port = 53 12 | protocol = "udp" 13 | cidr_blocks = ["0.0.0.0/0"] 14 | } 15 | 16 | egress { 17 | from_port = 53 18 | to_port = 53 19 | protocol = "udp" 20 | cidr_blocks = ["0.0.0.0/0"] 21 | } 22 | egress { 23 | from_port = 80 24 | to_port = 80 25 | protocol = "tcp" 26 | cidr_blocks = ["0.0.0.0/0"] 27 | } 28 | egress { 29 | from_port = 443 30 | to_port = 443 31 | protocol = "tcp" 32 | cidr_blocks = ["0.0.0.0/0"] 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /modules/aws/dns-rdir/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-config-playbook = "${local.playbook-path}/core_config.yml" 3 | ansible-rdir-playbook = "${local.playbook-path}/redirector.yml" 4 | } 5 | 6 | variable "user" { 7 | type = string 8 | description = "User to authenticate as" 9 | } 10 | 11 | variable "subnet_id" { 12 | type = string 13 | } 14 | 15 | variable "redirect_to" { 16 | type = string 17 | description = "The back-end C2 server to redirect to" 18 | } 19 | 20 | variable "security_groups"{ 21 | type = list(string) 22 | default=[""] 23 | } 24 | 25 | variable "install" { 26 | type = list(string) 27 | default = [] 28 | } 29 | -------------------------------------------------------------------------------- /modules/aws/domain-front/README.md: -------------------------------------------------------------------------------- 1 | # Domain Fronting (Currently Unsupported) 2 | 3 | ``` 4 | #~ curl -A 'notcurl' http://d2x0m979j4p9ih.cloudfront.net/test 5 | this is my http/s c2 server 6 | ``` 7 | 8 | 9 | ``` 10 | #~ curl -A 'notcurl' http://a0.awsstatic.com/test -H 'Host: d2x0m979j4p9ih.cloudfront.net' 11 | this is my http/s c2 server 12 | ``` 13 | -------------------------------------------------------------------------------- /modules/aws/domain-front/main.tf: -------------------------------------------------------------------------------- 1 | resource "aws_cloudfront_distribution" "http-c2" { 2 | enabled = true 3 | is_ipv6_enabled = false 4 | 5 | origin { 6 | domain_name = "${var.domain}" 7 | origin_id = "domain-front" 8 | 9 | custom_origin_config { 10 | http_port = 80 11 | https_port = 443 12 | origin_protocol_policy = "match-viewer" 13 | origin_ssl_protocols = ["TLSv1", "TLSv1.1", "TLSv1.2"] 14 | } 15 | } 16 | 17 | default_cache_behavior { 18 | target_origin_id = "domain-front" 19 | allowed_methods = ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] 20 | cached_methods = ["GET", "HEAD"] 21 | viewer_protocol_policy = "allow-all" 22 | min_ttl = 0 23 | default_ttl = 86400 24 | max_ttl = 31536000 25 | 26 | forwarded_values { 27 | query_string = true 28 | headers = ["*"] 29 | 30 | cookies { 31 | forward = "all" 32 | } 33 | } 34 | 35 | } 36 | 37 | restrictions { 38 | geo_restriction { 39 | restriction_type = "whitelist" 40 | locations = ["US"] 41 | } 42 | } 43 | 44 | viewer_certificate { 45 | cloudfront_default_certificate = true 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /modules/aws/domain-front/outputs.tf: -------------------------------------------------------------------------------- 1 | output "cf-domain" { 2 | value = "${aws_cloudfront_distribution.http-c2.domain_name}" 3 | } -------------------------------------------------------------------------------- /modules/aws/domain-front/variables.tf: -------------------------------------------------------------------------------- 1 | variable "domain" { 2 | type = string 3 | } -------------------------------------------------------------------------------- /modules/aws/http-c2/README.md: -------------------------------------------------------------------------------- 1 | # http-c2 2 | 3 | Creates a HTTP C2 server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "http-c2" { 9 | source = "../http-c2" 10 | 11 | #managed 12 | user = var.cs-http-c2-user 13 | subnet_id = var.private_subnet_id 14 | instance_type = var.instance_type 15 | security_groups = var.base-internal-security_groups 16 | security_groups_inbound_http = var.base-public-security_groups 17 | 18 | #base 19 | vpc_id = var.vpc_id 20 | amis = var.amis 21 | } 22 | ``` 23 | 24 | ## Arguments 25 | 26 | | Name | Required | Value Type | Description | 27 | |------------------------------|----------|--------------|-------------------------------------------------------------| 28 | | user | Yes | string | The User to authenticate as | 29 | | subnet_id | Yes | string | Subnet ID to create instance in | 30 | | security_groups | No | list(string) | Security groups to add | 31 | | security_groups_inbound_http | No | list(string) | Security groups to allow inbound port 80/443TCP(HTTP) from. | 32 | | install | No | list(string) | Scripts to install inline. Not recommended. | 33 | 34 | ## Outputs 35 | 36 | | Name | Description 37 | |----------------------------|----------- 38 | |`http-c2-private-ip` | IP of created instance. 39 | -------------------------------------------------------------------------------- /modules/aws/http-c2/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /modules/aws/http-c2/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | resource "random_id" "server" { 4 | byte_length = 4 5 | } 6 | 7 | resource "tls_private_key" "ssh" { 8 | algorithm = "RSA" 9 | rsa_bits = 4096 10 | } 11 | 12 | resource "aws_key_pair" "http-c2" { 13 | key_name = "http-c2-key-${random_id.server.hex}" 14 | public_key = tls_private_key.ssh.public_key_openssh 15 | } 16 | 17 | resource "aws_instance" "http-c2" { 18 | 19 | tags = { 20 | Name = "http-c2-${random_id.server.hex}" 21 | } 22 | 23 | ami = var.amis[data.aws_region.current.name] 24 | instance_type = var.instance_type 25 | key_name = aws_key_pair.http-c2.key_name 26 | vpc_security_group_ids = concat(var.security_groups,[aws_security_group.http-c2.id]) 27 | subnet_id = var.subnet_id 28 | associate_public_ip_address = false 29 | 30 | #this provisioner exists for 2 reasons: 31 | # 1. To support custom scripts, which ideally should be included in an ansible role/task rather than invoked inline like this. 32 | # 2. To ensure that SSH is open before Ansible local-exec provisioner attempts its execution 33 | provisioner "remote-exec" { 34 | scripts = var.install 35 | 36 | connection { 37 | host = self.private_ip 38 | type = "ssh" 39 | user = var.user 40 | private_key = tls_private_key.ssh.private_key_pem 41 | } 42 | } 43 | 44 | provisioner "local-exec" { 45 | command = "echo \"${tls_private_key.ssh.private_key_pem}\" > ${local.ssh-keys-path}/${self.private_ip} && echo \"${tls_private_key.ssh.public_key_openssh}\" > ${local.ssh-keys-path}/${self.private_ip}.pub && chmod 600 ${local.ssh-keys-path}/*" 46 | } 47 | 48 | provisioner "local-exec" { 49 | when = destroy 50 | command = "rm ${path.root}/data/ssh_keys/${self.private_ip}*" 51 | } 52 | 53 | } 54 | 55 | data "template_file" "ssh_config" { 56 | depends_on = [aws_instance.http-c2] 57 | 58 | template = file("${local.templates-path}/ssh_config.tpl") 59 | vars = { 60 | name = "http_c2_${aws_instance.http-c2.private_ip}" 61 | hostname = aws_instance.http-c2.private_ip 62 | user = var.user 63 | identityfile = "${local.ssh-keys-path}/${aws_instance.http-c2.private_ip}" 64 | } 65 | } 66 | 67 | resource "null_resource" "gen_ssh_config" { 68 | depends_on = [data.template_file.ssh_config] 69 | 70 | triggers = { 71 | template_rendered = data.template_file.ssh_config.rendered 72 | serverId = random_id.server.hex 73 | serverIp = aws_instance.http-c2.private_ip 74 | } 75 | 76 | provisioner "local-exec" { 77 | command = "echo '${data.template_file.ssh_config.rendered}' > ${local.ssh-configs-path}/${self.triggers.serverIp}_config" 78 | } 79 | 80 | provisioner "local-exec" { 81 | when = destroy 82 | command = "rm ${path.root}/data/ssh_configs/${self.triggers.serverIp}_config" 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /modules/aws/http-c2/outputs.tf: -------------------------------------------------------------------------------- 1 | output "http-c2-private-ip"{ 2 | value = tostring(aws_instance.http-c2.private_ip) 3 | } 4 | -------------------------------------------------------------------------------- /modules/aws/http-c2/security_group.tf: -------------------------------------------------------------------------------- 1 | resource "aws_security_group" "http-c2" { 2 | tags = { 3 | Name = "red-team-http-c2-${random_id.server.hex}" 4 | } 5 | name = "red-team-http-c2-${random_id.server.hex}" 6 | description = "Red Team Infra - HTTP C2" 7 | vpc_id = var.vpc_id 8 | 9 | ingress { 10 | from_port = 80 11 | to_port = 80 12 | protocol = "tcp" 13 | security_groups = var.security_groups_inbound_http 14 | } 15 | ingress { 16 | from_port = 443 17 | to_port = 443 18 | protocol = "tcp" 19 | security_groups = var.security_groups_inbound_http 20 | } 21 | 22 | egress { 23 | from_port = 53 24 | to_port = 53 25 | protocol = "udp" 26 | cidr_blocks = ["0.0.0.0/0"] 27 | } 28 | egress { 29 | from_port = 80 30 | to_port = 80 31 | protocol = "tcp" 32 | cidr_blocks = ["0.0.0.0/0"] 33 | } 34 | egress { 35 | from_port = 443 36 | to_port = 443 37 | protocol = "tcp" 38 | cidr_blocks = ["0.0.0.0/0"] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /modules/aws/http-c2/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-playbook = "${local.playbook-path}/core_config.yml" 3 | } 4 | 5 | variable "user" { 6 | description = "User to authenticate as" 7 | } 8 | 9 | variable "subnet_id" { 10 | type = string 11 | } 12 | 13 | variable "security_groups"{ 14 | type = list(string) 15 | default=[""] 16 | } 17 | 18 | variable "security_groups_inbound_http"{ 19 | type = list(string) 20 | default=[""] 21 | } 22 | 23 | variable "install" { 24 | type = list(string) 25 | default = [] 26 | } 27 | -------------------------------------------------------------------------------- /modules/aws/http-cobalt-strike/README.md: -------------------------------------------------------------------------------- 1 | # http-cobalt-strike 2 | 3 | Creates a Cobalt Strike DNS C2 server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | ## Example 5 | 6 | ```hcl 7 | module "cs-http-c2" { 8 | source = "./modules/aws/http-cobalt-strike" 9 | count = var.http-c2-amount 10 | 11 | #managed 12 | cs-http-c2-user = var.http-c2-user 13 | cs-http-c2-domain = var.http-c2-domain-mappings[count.index] 14 | cs-license = var.cs-license 15 | c2-profile = var.http-c2-profile 16 | 17 | #base 18 | vpc_id = var.vpc_id 19 | amis = var.amis 20 | instance_type = var.instance_type 21 | public_subnet_id = var.public_subnet_id 22 | private_subnet_id = var.private_subnet_id 23 | base-internal-security_groups = var.base-internal-security_groups 24 | base-public-security_groups = var.base-public-security_groups 25 | } 26 | 27 | ``` 28 | 29 | ## Arguments 30 | 31 | | Name | Required | Value Type | Description | 32 | |-------------------|----------|------------|---------------------------------| 33 | | cs-http-c2-user | Yes | string | The User to authenticate as | 34 | | cs-http-c2-domain | Yes | string | The domain name to deploy on | 35 | | cs-license | Yes | string | Cobalt Strike License Key | 36 | | c2-profile | Yes | string | The name of the C2 profile file | 37 | 38 | ## Outputs 39 | 40 | | Name | Description | 41 | |------------------------|-----------------------| 42 | | cs-teamserver-password | Teamserver Password | 43 | | cs-http-c2-private-ip | C2 Private IP | 44 | | cs-http-rdr-private-ip | Redirector Private IP | 45 | | cs-http-rdr-public-ip | Redirector Public IP | -------------------------------------------------------------------------------- /modules/aws/http-cobalt-strike/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | 22 | variable "public_subnet_id" { 23 | type = string 24 | } 25 | 26 | variable "private_subnet_id" { 27 | type = string 28 | } 29 | 30 | variable "base-internal-security_groups"{ 31 | type = list(string) 32 | } 33 | 34 | variable "base-public-security_groups" { 35 | type = list(string) 36 | } 37 | -------------------------------------------------------------------------------- /modules/aws/http-cobalt-strike/main.tf: -------------------------------------------------------------------------------- 1 | resource "random_password" "http-cs-teamserver-password" { 2 | length = 15 3 | special = true 4 | override_special = "@%)-_+[}:" 5 | } 6 | 7 | module "http-c2" { 8 | source = "../http-c2" 9 | 10 | #managed 11 | user = var.cs-http-c2-user 12 | subnet_id = var.private_subnet_id 13 | instance_type = var.instance_type 14 | security_groups = var.base-internal-security_groups 15 | security_groups_inbound_http = var.base-public-security_groups 16 | 17 | #base 18 | vpc_id = var.vpc_id 19 | amis = var.amis 20 | } 21 | 22 | module "http-rdir" { 23 | source = "../http-rdir" 24 | depends_on = [module.http-c2] 25 | 26 | #managed 27 | user = var.cs-http-c2-user 28 | subnet_id = var.public_subnet_id 29 | instance_type = var.instance_type 30 | security_groups = var.base-public-security_groups 31 | redirect_to = module.http-c2.http-c2-private-ip 32 | 33 | #base 34 | vpc_id = var.vpc_id 35 | amis = var.amis 36 | } 37 | 38 | module "http-rdir-A-records" { 39 | source = "../create-dns-record" 40 | depends_on = [module.http-rdir] 41 | 42 | #managed 43 | domain = local.cs-http-c2-tld 44 | type = "A" 45 | record = { 46 | (var.cs-http-c2-domain) = module.http-rdir.http-rdr-public-ip 47 | } 48 | } 49 | 50 | module "http-c2-create-certs" { 51 | source = "../letsencrypt/create-cert-dns" 52 | depends_on = [module.http-rdir-A-records] 53 | 54 | #managed 55 | domain = var.cs-http-c2-domain 56 | subject_alternative_names = { 57 | (var.cs-http-c2-domain) = ["*.${var.cs-http-c2-domain}"] 58 | } 59 | 60 | reg_email = "${var.cs-http-c2-user}@${local.cs-http-c2-tld}" 61 | dns_provider = "route53" 62 | } 63 | 64 | module "http-c2-ansible"{ 65 | source = "../../ansible/cobalt-strike" 66 | depends_on = [module.http-c2, module.http-c2-create-certs] 67 | 68 | #managed 69 | ansible-user = var.cs-http-c2-user 70 | ip = module.http-c2.http-c2-private-ip 71 | domain = var.cs-http-c2-domain 72 | bind-address = module.http-rdir.http-rdr-public-ip 73 | c2-profile = var.c2-profile 74 | cs-license = var.cs-license 75 | teamserver-password = random_password.http-cs-teamserver-password.result 76 | } 77 | -------------------------------------------------------------------------------- /modules/aws/http-cobalt-strike/outputs.tf: -------------------------------------------------------------------------------- 1 | output "cs-teamserver-password" { 2 | value = random_password.http-cs-teamserver-password.result 3 | } 4 | 5 | output "cs-http-c2-private-ip"{ 6 | value = module.http-c2.http-c2-private-ip 7 | } 8 | 9 | output "cs-http-rdr-private-ip"{ 10 | value = module.http-rdir.http-rdr-private-ip 11 | } 12 | 13 | output "cs-http-rdr-public-ip"{ 14 | value = module.http-rdir.http-rdr-public-ip 15 | } 16 | -------------------------------------------------------------------------------- /modules/aws/http-cobalt-strike/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | cs-ansible-playbook = "${local.playbook-path}/cobalt_strike.yml" 3 | cs-http-c2-tld = join(".",tolist([reverse(split(".", var.cs-http-c2-domain ))[1],reverse(split(".", var.cs-http-c2-domain ))[0]])) 4 | } 5 | 6 | 7 | variable "cs-http-c2-user" { 8 | type = string 9 | default = "admin" 10 | description = "User to authenticate as" 11 | } 12 | 13 | variable "cs-http-c2-domain" { 14 | type = string 15 | } 16 | 17 | variable "cs-license"{ 18 | type = string 19 | #sensitive = true 20 | } 21 | 22 | variable "c2-profile" { 23 | type = string 24 | description = "The name of the C2 profile file" 25 | } 26 | -------------------------------------------------------------------------------- /modules/aws/http-rdir/README.md: -------------------------------------------------------------------------------- 1 | # http-rdir 2 | 3 | Creates a HTTP Redirector server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "http-rdir" { 9 | source = "../http-rdir" 10 | 11 | #managed 12 | user = var.cs-http-c2-user 13 | subnet_id = var.public_subnet_id 14 | instance_type = var.instance_type 15 | security_groups = var.base-public-security_groups 16 | redirect_to = module.http-c2.http-c2-private-ip 17 | 18 | #base 19 | vpc_id = var.vpc_id 20 | amis = var.amis 21 | } 22 | ``` 23 | 24 | ## Arguments 25 | 26 | | Name | Required | Value Type | Description | 27 | |-----------------|----------|--------------|---------------------------------------------| 28 | | user | Yes | string | The User to authenticate as | 29 | | subnet_id | Yes | string | Subnet ID to create instance in | 30 | | redirect_to | Yes | string | The back-end C2 server to redirect to | 31 | | security_groups | No | list(string) | Security groups to add | 32 | | install | No | list(string) | Scripts to install inline. Not recommended. | 33 | 34 | ## Outputs 35 | 36 | | Name | Description | 37 | |--------------------|-----------------------------| 38 | | http-rdr-private-ip | The redirector's private IP | 39 | | http-rdr-public-ip | The redirector's public IP | 40 | -------------------------------------------------------------------------------- /modules/aws/http-rdir/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /modules/aws/http-rdir/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | resource "random_id" "server" { 4 | byte_length = 4 5 | } 6 | 7 | resource "tls_private_key" "ssh" { 8 | algorithm = "RSA" 9 | rsa_bits = 4096 10 | } 11 | 12 | data "aws_vpc" "selected" { 13 | id = var.vpc_id 14 | } 15 | 16 | resource "aws_key_pair" "http-rdir" { 17 | key_name = "http-rdir-key-${random_id.server.hex}" 18 | public_key = tls_private_key.ssh.public_key_openssh 19 | } 20 | 21 | resource "aws_instance" "http-rdir" { 22 | tags = { 23 | Name = "http-rdir-${random_id.server.hex}" 24 | } 25 | 26 | ami = var.amis[data.aws_region.current.name] 27 | instance_type = var.instance_type 28 | key_name = aws_key_pair.http-rdir.key_name 29 | vpc_security_group_ids = concat(var.security_groups, [aws_security_group.http-rdir.id]) 30 | subnet_id = var.subnet_id 31 | associate_public_ip_address = true 32 | 33 | #this provisioner exists for 2 reasons: 34 | # 1. To support custom scripts, which ideally should be included in an ansible role/task rather than invoked inline like this. 35 | # 2. To ensure that SSH is open before Ansible local-exec provisioner attempts its execution 36 | provisioner "remote-exec" { 37 | scripts = var.install 38 | 39 | connection { 40 | type = "ssh" 41 | user = var.user 42 | private_key = tls_private_key.ssh.private_key_pem 43 | host = self.private_ip 44 | } 45 | } 46 | 47 | provisioner "local-exec" { 48 | command = "echo \"${tls_private_key.ssh.private_key_pem}\" > ${local.ssh-keys-path}/${self.private_ip} && echo \"${tls_private_key.ssh.public_key_openssh}\" > ${local.ssh-keys-path}/${self.private_ip}.pub && chmod 600 ${local.ssh-keys-path}/*" 49 | } 50 | 51 | provisioner "local-exec" { 52 | when = destroy 53 | command = "rm ${path.root}/data/ssh_keys/${self.private_ip}*" 54 | } 55 | 56 | } 57 | 58 | data "template_file" "ssh_config" { 59 | depends_on = [aws_instance.http-rdir] 60 | 61 | template = file("${local.templates-path}/ssh_config.tpl") 62 | vars = { 63 | name = "http_rdir_${aws_instance.http-rdir.private_ip}" 64 | hostname = aws_instance.http-rdir.private_ip 65 | user = var.user 66 | identityfile = "${local.ssh-keys-path}/${aws_instance.http-rdir.private_ip}" 67 | } 68 | 69 | } 70 | 71 | resource "null_resource" "gen_ssh_config" { 72 | depends_on = [data.template_file.ssh_config] 73 | 74 | triggers = { 75 | template_rendered = data.template_file.ssh_config.rendered 76 | serverId = random_id.server.hex 77 | serverIp = aws_instance.http-rdir.private_ip 78 | } 79 | 80 | provisioner "local-exec" { 81 | command = "echo '${data.template_file.ssh_config.rendered}' > ${local.ssh-configs-path}/${self.triggers.serverIp}_config" 82 | } 83 | 84 | provisioner "local-exec" { 85 | when = destroy 86 | command = "rm ${path.root}/data/ssh_configs/${self.triggers.serverIp}_config" 87 | } 88 | 89 | } 90 | 91 | 92 | module "http-rdir-config-ansible"{ 93 | source = "../../ansible/core" 94 | depends_on = [aws_instance.http-rdir, null_resource.gen_ssh_config] 95 | 96 | user = var.user 97 | playbook = local.ansible-config-playbook 98 | ip = aws_instance.http-rdir.private_ip 99 | } 100 | 101 | module "http-rdir-ansible"{ 102 | source = "../../ansible/core" 103 | depends_on = [module.http-rdir-config-ansible] 104 | 105 | user = var.user 106 | playbook = local.ansible-rdir-playbook 107 | arguments = ["--extra-vars 'redirect_to=${var.redirect_to} redirector_type=http'"] 108 | ip = aws_instance.http-rdir.private_ip 109 | } 110 | -------------------------------------------------------------------------------- /modules/aws/http-rdir/outputs.tf: -------------------------------------------------------------------------------- 1 | output "http-rdr-private-ip" { 2 | value = tostring(aws_instance.http-rdir.private_ip) 3 | } 4 | 5 | output "http-rdr-public-ip" { 6 | value = tostring(aws_instance.http-rdir.public_ip) 7 | } -------------------------------------------------------------------------------- /modules/aws/http-rdir/security_group.tf: -------------------------------------------------------------------------------- 1 | resource "aws_security_group" "http-rdir" { 2 | tags = { 3 | Name = "red-team-http-rdir-${random_id.server.hex}" 4 | } 5 | name = "red-team-http-rdir-${random_id.server.hex}" 6 | description = "Red Team Infra - HTTP C2 Redirector" 7 | vpc_id = var.vpc_id 8 | 9 | ingress { 10 | from_port = 80 11 | to_port = 80 12 | protocol = "tcp" 13 | cidr_blocks = ["0.0.0.0/0"] 14 | } 15 | ingress { 16 | from_port = 443 17 | to_port = 443 18 | protocol = "tcp" 19 | cidr_blocks = ["0.0.0.0/0"] 20 | } 21 | egress { 22 | from_port = 53 23 | to_port = 53 24 | protocol = "udp" 25 | cidr_blocks = ["0.0.0.0/0"] 26 | } 27 | egress { 28 | from_port = 80 29 | to_port = 80 30 | protocol = "tcp" 31 | cidr_blocks = ["0.0.0.0/0"] 32 | } 33 | egress { 34 | from_port = 443 35 | to_port = 443 36 | protocol = "tcp" 37 | cidr_blocks = ["0.0.0.0/0"] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /modules/aws/http-rdir/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-rdir-playbook = "${local.playbook-path}/redirector.yml" 3 | ansible-config-playbook = "${local.playbook-path}/core_config.yml" 4 | } 5 | 6 | variable "user" { 7 | description = "User to authenticate as" 8 | } 9 | 10 | variable "subnet_id" { 11 | type = string 12 | } 13 | 14 | variable "redirect_to" { 15 | description = "The back-end C2 server to redirect to" 16 | type = string 17 | } 18 | 19 | variable "security_groups"{ 20 | type = list(string) 21 | default=[""] 22 | } 23 | 24 | variable "install" { 25 | type = list(string) 26 | default = [] 27 | } 28 | -------------------------------------------------------------------------------- /modules/aws/letsencrypt/create-cert-dns/README.md: -------------------------------------------------------------------------------- 1 | # create-cert-dns 2 | 3 | Creates a Let's Encrypt TLS certificate for the specfied domain using the DNS challenge. 4 | 5 | # Example 6 | 7 | ```hcl 8 | module "http-c2-create-certs" { 9 | source = "../letsencrypt/create-cert-dns" 10 | 11 | #managed 12 | domain = var.cs-http-c2-domain 13 | subject_alternative_names = { 14 | (var.cs-http-c2-domain) = ["*.${var.cs-http-c2-domain}"] 15 | } 16 | 17 | reg_email = "${var.cs-http-c2-user}@${local.cs-http-c2-tld}" 18 | dns_provider = "route53" 19 | } 20 | ``` 21 | 22 | ## Arguments 23 | 24 | | Name | Required | Value Type | Description | 25 | |---------------------------|----------|-------------|---------------------------------------------------------------------| 26 | | dns_provider | No | string | The DNS provider. Defaults to route53 | 27 | | domain | Yes | string | The domain name to deploy on | 28 | | subject_alternative_names | Yes | map(string) | The SAN entries for certificate | 29 | | reg_email | No | string | The registration email for the cert. Defaults to nobody@example.com | 30 | | key_type | No | number | The TLS RSA key bit size. Defaults to 4096 | 31 | 32 | ## Outputs 33 | 34 | | Name | Description | 35 | |-----------------------------------|---------------------------------------------| 36 | | certificate_domain | | 37 | | certificate_url | | 38 | | certificate_pem | | 39 | | certificate_private_key_pem | | 40 | | certificate_issuer_pem | | 41 | | certificate_file_path | The output file path of the TLS public key | 42 | | certificate_private_key_file_path | The output file path of the TLS private key | -------------------------------------------------------------------------------- /modules/aws/letsencrypt/create-cert-dns/main.tf: -------------------------------------------------------------------------------- 1 | resource "tls_private_key" "private_key" { 2 | algorithm = "RSA" 3 | rsa_bits = var.key_type 4 | } 5 | 6 | resource "acme_registration" "reg" { 7 | account_key_pem = tls_private_key.private_key.private_key_pem 8 | email_address = var.reg_email 9 | } 10 | 11 | data "aws_region" "current" {} 12 | 13 | data "aws_route53_zone" "selected" { 14 | name = join(".",tolist([reverse(split(".",var.domain))[1],reverse(split(".",var.domain))[0]])) 15 | } 16 | 17 | resource "acme_certificate" "certificate" { 18 | account_key_pem = acme_registration.reg.account_key_pem 19 | common_name = var.domain 20 | subject_alternative_names = var.subject_alternative_names[var.domain] 21 | 22 | dns_challenge { 23 | provider = var.dns_provider 24 | config ={ AWS_HOSTED_ZONE_ID = data.aws_route53_zone.selected.zone_id } 25 | } 26 | 27 | provisioner "local-exec" { 28 | command = "echo \"${self.private_key_pem}\" > ./data/certificates/${self.common_name}_privkey.pem && echo \"${self.certificate_pem}\" > ./data/certificates/${self.common_name}_cert.pem" 29 | } 30 | 31 | provisioner "local-exec" { 32 | when = destroy 33 | command = "rm ./data/certificates/${self.common_name}*" 34 | } 35 | } -------------------------------------------------------------------------------- /modules/aws/letsencrypt/create-cert-dns/outputs.tf: -------------------------------------------------------------------------------- 1 | output "certificate_domain" { 2 | value = acme_certificate.certificate.certificate_domain 3 | } 4 | output "certificate_url" { 5 | value = acme_certificate.certificate.certificate_url 6 | } 7 | output "certificate_pem" { 8 | value = acme_certificate.certificate.certificate_pem 9 | } 10 | output "certificate_private_key_pem" { 11 | #sensitive = true 12 | value = acme_certificate.certificate.private_key_pem 13 | } 14 | output "certificate_issuer_pem" { 15 | value = acme_certificate.certificate.issuer_pem 16 | } 17 | output "certificate_file_path" { 18 | value = "./data/certificates/${tostring(acme_certificate.certificate.common_name)}_cert.pem" 19 | } 20 | output "certificate_private_key_file_path" { 21 | value = "./data/certificates/${tostring(acme_certificate.certificate.common_name)}_privkey.pem" 22 | } -------------------------------------------------------------------------------- /modules/aws/letsencrypt/create-cert-dns/providers.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_version = ">= 0.14.0" 3 | required_providers { 4 | acme = { 5 | source = "vancluever/acme" 6 | version = "~> 2.0.0" 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /modules/aws/letsencrypt/create-cert-dns/variables.tf: -------------------------------------------------------------------------------- 1 | variable "dns_provider" { 2 | type = string 3 | default = "route53" 4 | } 5 | 6 | variable "domain" { 7 | type = string 8 | } 9 | 10 | variable "subject_alternative_names" { 11 | type = any 12 | } 13 | 14 | variable "reg_email" { 15 | type = string 16 | default = "nobody@example.com" 17 | } 18 | 19 | variable "key_type" { 20 | type = number 21 | default = 4096 22 | } 23 | -------------------------------------------------------------------------------- /modules/aws/phishing-gophish/README.md: -------------------------------------------------------------------------------- 1 | # phishing-gophish 2 | 3 | Creates an GoPhish server instance in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | # Example 6 | 7 | ```hcl 8 | module "infra-phishing-gophish"{ 9 | source = "./modules/aws/phishing-gophish" 10 | 11 | #managed 12 | phishing-user = var.phishing-user 13 | phishing-domain = var.phishing-domain-mappings[count.index] 14 | 15 | #base 16 | vpc_id = var.vpc_id 17 | amis = var.amis 18 | instance_type = var.instance_type 19 | public_subnet_id = var.public_subnet_id 20 | private_subnet_id = var.private_subnet_id 21 | base-internal-security_groups = var.base-internal-security_groups 22 | base-public-security_groups = var.base-public-security_groups 23 | } 24 | ``` 25 | 26 | ## Arguments 27 | 28 | | Name | Required | Value Type | Description | 29 | |-----------------|----------|------------|-----------------------------| 30 | | phishing-user | Yes | string | The user to authenticate as | 31 | | phishing-domain | Yes | string | The domain to deploy on | 32 | 33 | ## Outputs 34 | 35 | | Name | Description | 36 | |------------------------------|----------------------------| 37 | | gophish_ip | | 38 | | gophish-credentials-username | | 39 | | gophish-credentials-password | | 40 | | smtp-server | The SES SMTP server domain | 41 | | smtp-user | The SES username | 42 | | smtp-password | The SES smtp password | 43 | -------------------------------------------------------------------------------- /modules/aws/phishing-gophish/base_variables.tf: -------------------------------------------------------------------------------- 1 | variable "vpc_id" { 2 | type = string 3 | } 4 | 5 | variable "amis" { 6 | type = map(string) 7 | } 8 | 9 | variable "instance_type" { 10 | type = string 11 | } 12 | 13 | variable "public_subnet_id" { 14 | type = string 15 | } 16 | 17 | variable "private_subnet_id" { 18 | type = string 19 | } 20 | 21 | variable "base-internal-security_groups"{ 22 | type = list(string) 23 | } 24 | 25 | variable "base-public-security_groups" { 26 | type = list(string) 27 | } 28 | -------------------------------------------------------------------------------- /modules/aws/phishing-gophish/main.tf: -------------------------------------------------------------------------------- 1 | module "phishing-create-certs" { 2 | source = "../letsencrypt/create-cert-dns" 3 | 4 | #managed 5 | domain = var.phishing-domain 6 | subject_alternative_names = { 7 | (var.phishing-domain) = ["*.${var.phishing-domain}"] 8 | } 9 | reg_email = "${var.phishing-user}@${local.phishing-tld}" 10 | dns_provider = "route53" 11 | } 12 | 13 | module "gophish-server" { 14 | source = "../phishing-server" 15 | depends_on = [module.phishing-create-certs] 16 | 17 | #managed 18 | user = var.phishing-user 19 | domain = var.phishing-domain 20 | subnet_id = var.private_subnet_id 21 | security_groups = var.base-internal-security_groups 22 | 23 | #base 24 | vpc_id = var.vpc_id 25 | instance_type = var.instance_type 26 | amis = var.amis 27 | } 28 | 29 | module "gophish-server-rdir" { 30 | source = "../phishing-rdir" 31 | depends_on = [module.gophish-server] 32 | 33 | #managed 34 | user = var.phishing-user 35 | subnet_id = var.public_subnet_id 36 | redirect_to = module.gophish-server.gophish-ip 37 | security_groups = var.base-public-security_groups 38 | 39 | #base 40 | vpc_id = var.vpc_id 41 | instance_type = var.instance_type 42 | amis = var.amis 43 | } 44 | 45 | module "phishing-rdir-A-records" { 46 | source = "../create-dns-record" 47 | depends_on = [module.gophish-server-rdir] 48 | 49 | #managed 50 | domain = local.phishing-tld 51 | type = "A" 52 | 53 | record = { 54 | (var.phishing-domain) = module.gophish-server-rdir.phishing-rdr-public-ip 55 | } 56 | } 57 | 58 | module "smtp-relay"{ 59 | source = "../smtp" 60 | depends_on = [module.gophish-server, module.gophish-server-rdir] 61 | 62 | #managed 63 | domain = var.phishing-domain 64 | mx_subdomain= "mail-relay" 65 | } -------------------------------------------------------------------------------- /modules/aws/phishing-gophish/outputs.tf: -------------------------------------------------------------------------------- 1 | output "gophish-ip" { 2 | value = module.gophish-server.gophish-ip 3 | } 4 | 5 | output "gophish-credentials-username" { 6 | value = module.gophish-server.gophish-credentials-username 7 | } 8 | 9 | output "gophish-credentials-password" { 10 | value = module.gophish-server.gophish-credentials-password 11 | } 12 | 13 | output "smtp-server" { 14 | value = module.smtp-relay.smtp-server 15 | } 16 | 17 | output "smtp-user" { 18 | value = module.smtp-relay.smtp-username 19 | } 20 | 21 | output "smtp-password" { 22 | value = module.smtp-relay.smtp-password 23 | } 24 | -------------------------------------------------------------------------------- /modules/aws/phishing-gophish/variables.tf: -------------------------------------------------------------------------------- 1 | locals{ 2 | phishing-tld = join(".",tolist([reverse(split(".", var.phishing-domain ))[1],reverse(split(".", var.phishing-domain ))[0]])) 3 | } 4 | 5 | variable "phishing-user" { 6 | type = string 7 | description = "User to authenticate as" 8 | } 9 | 10 | variable "phishing-domain" { 11 | type = string 12 | } 13 | -------------------------------------------------------------------------------- /modules/aws/phishing-rdir/README.md: -------------------------------------------------------------------------------- 1 | # phishing-rdir 2 | 3 | Creates a GoPhish Redirector server in AWS. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "gophish-server-rdir" { 9 | source = "../phishing-rdir" 10 | 11 | #managed 12 | user = var.phishing-user 13 | subnet_id = var.public_subnet_id 14 | redirect_to = module.gophish-server.gophish-ip 15 | security_groups = var.base-public-security_groups 16 | 17 | #base 18 | vpc_id = var.vpc_id 19 | instance_type = var.instance_type 20 | amis = var.amis 21 | } 22 | ``` 23 | 24 | ## Arguments 25 | 26 | | Name | Required | Value Type | Description | 27 | |-----------------|----------|--------------|---------------------------------------------| 28 | | user | Yes | string | The User to authenticate as | 29 | | subnet_id | Yes | string | Subnet ID to create instance in | 30 | | redirect_to | Yes | string | The back-end C2 server to redirect to | 31 | | security_groups | No | list(string) | Security groups to add | 32 | | install | No | list(string) | Scripts to install inline. Not recommended. | 33 | 34 | ## Outputs 35 | 36 | | Name | Description | 37 | |-------------------------|-----------------------------| 38 | | phishing-rdr-private-ip | The redirector's private IP | 39 | | phishing-rdr-public-ip | The redirector's public IP | -------------------------------------------------------------------------------- /modules/aws/phishing-rdir/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | playbook-path = "${local.data-path}/playbooks" 4 | ssh-configs-path = "${local.data-path}/ssh_configs" 5 | ssh-keys-path = "${local.data-path}/ssh_keys" 6 | templates-path = "${local.data-path}/templates" 7 | credentials-path = "${local.data-path}/credentials" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } -------------------------------------------------------------------------------- /modules/aws/phishing-rdir/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | resource "random_id" "server" { 4 | byte_length = 4 5 | } 6 | 7 | resource "tls_private_key" "ssh" { 8 | algorithm = "RSA" 9 | rsa_bits = 4096 10 | } 11 | 12 | data "aws_vpc" "selected" { 13 | id = var.vpc_id 14 | } 15 | 16 | resource "aws_key_pair" "phishing-rdir-kp" { 17 | key_name = "phishing-rdir-key-${random_id.server.hex}" 18 | public_key = tls_private_key.ssh.public_key_openssh 19 | } 20 | 21 | resource "aws_instance" "phishing-rdir" { 22 | tags = { 23 | Name = "phishing-rdir-${random_id.server.hex}" 24 | } 25 | 26 | ami = var.amis[data.aws_region.current.name] 27 | instance_type = var.instance_type 28 | key_name = aws_key_pair.phishing-rdir-kp.key_name 29 | vpc_security_group_ids = concat(var.security_groups, [aws_security_group.phishing-rdir.id]) 30 | subnet_id = var.subnet_id 31 | associate_public_ip_address = true 32 | 33 | #this provisioner exists for 2 reasons: 34 | # 1. To support custom scripts, which ideally should be included in an ansible role/task rather than invoked inline like this. 35 | # 2. To ensure that SSH is open before Ansible local-exec provisioner attempts its execution 36 | provisioner "remote-exec" { 37 | scripts = var.install 38 | 39 | connection { 40 | type = "ssh" 41 | user = var.user 42 | private_key = tls_private_key.ssh.private_key_pem 43 | host = self.private_ip 44 | } 45 | } 46 | 47 | provisioner "local-exec" { 48 | command = "echo \"${tls_private_key.ssh.private_key_pem}\" > ${local.ssh-keys-path}/${self.private_ip} && echo \"${tls_private_key.ssh.public_key_openssh}\" > ${local.ssh-keys-path}/${self.private_ip}.pub && chmod 600 ${local.ssh-keys-path}/*" 49 | } 50 | 51 | provisioner "local-exec" { 52 | when = destroy 53 | command = "rm ${path.root}/data/ssh_keys/${self.private_ip}*" 54 | } 55 | 56 | } 57 | 58 | data "template_file" "ssh_config" { 59 | depends_on = [aws_instance.phishing-rdir] 60 | 61 | template = file("${local.templates-path}/ssh_config.tpl") 62 | vars = { 63 | name = "phishing_rdir_${aws_instance.phishing-rdir.private_ip}" 64 | hostname = aws_instance.phishing-rdir.private_ip 65 | user = var.user 66 | identityfile = "${local.ssh-keys-path}/${aws_instance.phishing-rdir.private_ip}" 67 | } 68 | 69 | } 70 | 71 | resource "null_resource" "gen_ssh_config" { 72 | depends_on = [data.template_file.ssh_config] 73 | 74 | triggers = { 75 | template_rendered = data.template_file.ssh_config.rendered 76 | serverId = random_id.server.hex 77 | serverIp = aws_instance.phishing-rdir.private_ip 78 | } 79 | 80 | provisioner "local-exec" { 81 | command = "echo '${data.template_file.ssh_config.rendered}' > ${local.ssh-configs-path}/${self.triggers.serverIp}_config" 82 | } 83 | 84 | provisioner "local-exec" { 85 | when = destroy 86 | command = "rm ${path.root}/data/ssh_configs/${self.triggers.serverIp}_config" 87 | } 88 | 89 | } 90 | 91 | module "phishing-rdir-ansible-core-config"{ 92 | source = "../../ansible/core" 93 | depends_on = [aws_instance.phishing-rdir, null_resource.gen_ssh_config] 94 | 95 | playbook = local.ansible-config-playbook 96 | user = var.user 97 | ip = aws_instance.phishing-rdir.private_ip 98 | } 99 | 100 | module "phishing-rdir-ansible"{ 101 | source = "../../ansible/core" 102 | depends_on = [module.phishing-rdir-ansible-core-config] 103 | 104 | user = var.user 105 | playbook = local.ansible-rdir-playbook 106 | arguments = ["--extra-vars 'redirect_to=${var.redirect_to} redirector_type=gophish'"] 107 | ip = aws_instance.phishing-rdir.private_ip 108 | } 109 | -------------------------------------------------------------------------------- /modules/aws/phishing-rdir/outputs.tf: -------------------------------------------------------------------------------- 1 | output "phishing-rdr-private-ip" { 2 | value = tostring(aws_instance.phishing-rdir.private_ip) 3 | } 4 | 5 | output "phishing-rdr-public-ip" { 6 | value = tostring(aws_instance.phishing-rdir.public_ip) 7 | } -------------------------------------------------------------------------------- /modules/aws/phishing-rdir/security_group.tf: -------------------------------------------------------------------------------- 1 | resource "aws_security_group" "phishing-rdir" { 2 | tags = { 3 | Name = "red-team-phishing-rdir-${random_id.server.hex}" 4 | } 5 | name = "red-team-phishing-rdir-${random_id.server.hex}" 6 | description = "Red Team Infra - Gophish HTTP C2 Redirector" 7 | vpc_id = var.vpc_id 8 | 9 | ingress { 10 | from_port = 443 11 | to_port = 443 12 | protocol = "tcp" 13 | cidr_blocks = ["0.0.0.0/0"] 14 | } 15 | egress { 16 | from_port = 53 17 | to_port = 53 18 | protocol = "udp" 19 | cidr_blocks = ["0.0.0.0/0"] 20 | } 21 | egress { 22 | from_port = 80 23 | to_port = 80 24 | protocol = "tcp" 25 | cidr_blocks = ["0.0.0.0/0"] 26 | } 27 | egress { 28 | from_port = 443 29 | to_port = 443 30 | protocol = "tcp" 31 | cidr_blocks = ["0.0.0.0/0"] 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /modules/aws/phishing-rdir/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-config-playbook = "${local.playbook-path}/core_config.yml" 3 | ansible-rdir-playbook = "${local.playbook-path}/redirector.yml" 4 | } 5 | 6 | variable "user" { 7 | description = "User to authenticate as" 8 | type = string 9 | } 10 | 11 | variable "subnet_id" { 12 | type = string 13 | } 14 | 15 | variable "redirect_to" { 16 | description = "The back-end C2 server to redirect to" 17 | type = string 18 | } 19 | 20 | variable "security_groups"{ 21 | type = list(string) 22 | default=[""] 23 | } 24 | 25 | variable "install" { 26 | type = list(string) 27 | default = [] 28 | } 29 | -------------------------------------------------------------------------------- /modules/aws/phishing-server/README.md: -------------------------------------------------------------------------------- 1 | # phishing-server 2 | 3 | Creates an instance in AWS to be used as a phishing server. SSH keys for each instance will be outputted to the ssh_keys folder. 4 | 5 | ## Example 6 | 7 | ```hcl 8 | module "phishing_server" { 9 | source = "../phishing-server" 10 | depends_on = [module.phishing-create-certs] 11 | 12 | #managed 13 | user = var.phishing-user 14 | domain = var.phishing-domain 15 | subnet_id = var.private_subnet_id 16 | security_groups = var.base-internal-security_groups 17 | 18 | #base 19 | vpc_id = var.vpc_id 20 | instance_type = var.instance_type 21 | amis = var.amis 22 | } 23 | ``` 24 | 25 | ## Arguments 26 | 27 | | Name | Required | Value Type | Description | 28 | |-----------------|----------|--------------|---------------------------------------------| 29 | | user | Yes | string | The User to authenticate as | 30 | | domain | Yes | string | The domain to deploy to | 31 | | subnet_id | Yes | string | Subnet ID to create instance in | 32 | | security_groups | No | list(string) | Security groups to add | 33 | | install | No | list(string) | Scripts to install inline. Not recommended. | 34 | 35 | ## Outputs 36 | 37 | | Name | Description | 38 | |------------------------------|-------------| 39 | | gophish-ip | | 40 | | gophish-credentials-username | | 41 | | gophish-credentials-password | | -------------------------------------------------------------------------------- /modules/aws/phishing-server/base_variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | data-path = "${path.root}/data" 3 | ssh-configs-path = "${local.data-path}/ssh_configs" 4 | ssh-keys-path = "${local.data-path}/ssh_keys" 5 | templates-path = "${local.data-path}/templates" 6 | credentials-path = "${local.data-path}/credentials" 7 | playbook-path = "${local.data-path}/playbooks" 8 | } 9 | 10 | variable "vpc_id" { 11 | type = string 12 | } 13 | 14 | variable "amis" { 15 | type = map(string) 16 | } 17 | 18 | variable "instance_type" { 19 | type = string 20 | } 21 | -------------------------------------------------------------------------------- /modules/aws/phishing-server/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | resource "random_id" "server" { 4 | byte_length = 4 5 | } 6 | 7 | resource "tls_private_key" "ssh" { 8 | algorithm = "RSA" 9 | rsa_bits = 4096 10 | } 11 | 12 | resource "aws_key_pair" "phishing-server" { 13 | key_name = "phishing-server-key-${random_id.server.hex}" 14 | public_key = tls_private_key.ssh.public_key_openssh 15 | } 16 | 17 | resource "aws_instance" "phishing-server" { 18 | tags = { 19 | Name = "phishing-server-${random_id.server.hex}" 20 | } 21 | 22 | ami = var.amis[data.aws_region.current.name] 23 | instance_type = var.instance_type 24 | key_name = aws_key_pair.phishing-server.key_name 25 | vpc_security_group_ids = var.security_groups 26 | subnet_id = var.subnet_id 27 | associate_public_ip_address = false 28 | #security_groups = [] 29 | 30 | provisioner "remote-exec" { 31 | scripts = var.install 32 | 33 | connection { 34 | host = self.private_ip 35 | type = "ssh" 36 | user = var.user 37 | private_key = tls_private_key.ssh.private_key_pem 38 | } 39 | } 40 | 41 | provisioner "local-exec" { 42 | command = <<-EOT 43 | echo "${tls_private_key.ssh.private_key_pem}" > ${local.ssh-keys-path}/${self.private_ip} 44 | echo "${tls_private_key.ssh.public_key_openssh}" > ${local.ssh-keys-path}/${self.private_ip}.pub 45 | chmod 600 ${local.ssh-keys-path}/* 46 | EOT 47 | } 48 | 49 | provisioner "local-exec" { 50 | when = destroy 51 | command = "rm ${path.root}/data/ssh_keys/${self.private_ip}* && rm ${path.root}/data/credentials/gophish_*_${self.private_ip}" 52 | } 53 | 54 | } 55 | 56 | module "gophish-ansible" { 57 | source = "../../ansible/gophish" 58 | depends_on = [aws_instance.phishing-server] 59 | 60 | 61 | ansible-user = var.user 62 | ip = aws_instance.phishing-server.private_ip 63 | gophish-domain = var.domain 64 | } 65 | 66 | data "template_file" "ssh_config" { 67 | depends_on = [aws_instance.phishing-server] 68 | template = file("${local.templates-path}/ssh_config.tpl") 69 | 70 | vars = { 71 | name = "phishing_${aws_instance.phishing-server.private_ip}" 72 | hostname = aws_instance.phishing-server.private_ip 73 | user = var.user 74 | identityfile = "${path.root}/data/ssh_keys/${aws_instance.phishing-server.private_ip}" 75 | } 76 | 77 | } 78 | 79 | resource "null_resource" "gen_ssh_config" { 80 | depends_on = [data.template_file.ssh_config] 81 | 82 | triggers = { 83 | template_rendered = data.template_file.ssh_config.rendered 84 | serverId = random_id.server.hex 85 | serverIp = aws_instance.phishing-server.private_ip 86 | } 87 | 88 | provisioner "local-exec" { 89 | command = "echo '${data.template_file.ssh_config.rendered}' > ${local.ssh-configs-path}/${self.triggers.serverIp}_config" 90 | } 91 | 92 | provisioner "local-exec" { 93 | when = destroy 94 | command = "rm ${path.root}/data/ssh_configs/${self.triggers.serverIp}_config" 95 | } 96 | 97 | } 98 | 99 | data "local_file" "gophish-credentials-username" { 100 | depends_on = [aws_instance.phishing-server, module.gophish-ansible] 101 | 102 | filename = "${local.credentials-path}/gophish_username_${aws_instance.phishing-server.private_ip}" 103 | } 104 | 105 | data "local_file" "gophish-credentials-password" { 106 | depends_on = [aws_instance.phishing-server, module.gophish-ansible] 107 | 108 | filename = "${local.credentials-path}/gophish_password_${aws_instance.phishing-server.private_ip}" 109 | } 110 | -------------------------------------------------------------------------------- /modules/aws/phishing-server/outputs.tf: -------------------------------------------------------------------------------- 1 | output "gophish-ip" { 2 | value = tostring(aws_instance.phishing-server.private_ip) 3 | } 4 | 5 | output "gophish-credentials-username" { 6 | value = chomp(tostring(data.local_file.gophish-credentials-username.content)) 7 | } 8 | 9 | output "gophish-credentials-password" { 10 | value = chomp(tostring(data.local_file.gophish-credentials-password.content)) 11 | } 12 | -------------------------------------------------------------------------------- /modules/aws/phishing-server/variables.tf: -------------------------------------------------------------------------------- 1 | locals { 2 | ansible-gophish-playbook = "${local.playbook-path}/gophish.yml" 3 | ansible-playbook = "${local.playbook-path}/core_config.yml" 4 | } 5 | 6 | variable "user" { 7 | description = "User to authenticate as" 8 | } 9 | 10 | variable "domain" { 11 | type = string 12 | } 13 | 14 | variable "subnet_id" { 15 | type = string 16 | } 17 | 18 | variable "security_groups"{ 19 | type = list(string) 20 | default=[""] 21 | } 22 | 23 | variable "install" { 24 | type = list(string) 25 | default = [] 26 | } 27 | -------------------------------------------------------------------------------- /modules/aws/smtp/README.md: -------------------------------------------------------------------------------- 1 | # smtp 2 | 3 | Configures AWS SES relay to send e-mails via SMTP. Handles SPF and DKIM configuration. 4 | 5 | ## Initial Setup 6 | 7 | Note: Once the AWS name servers have been set in the domain registrar configuration, it can 8 | take up to 72 for Amazon to verify the SES domain. Once the domain is verified, a service 9 | limit increase request must be done to disable the SES sandbox and be able to send e-mails 10 | to unverified recipients, this process is documented in the [AWS SES sandbox documentation](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/request-production-access.html). 11 | 12 | ## Example 13 | 14 | ```hcl 15 | module "smtp-relay"{ 16 | source = "../smtp" 17 | 18 | #managed 19 | domain = var.phishing-domain 20 | mx_subdomain= "mail-relay" 21 | } 22 | ``` 23 | 24 | ## Arguments 25 | 26 | | Name | Required | Value Type | Description 27 | |---------------------------| -------- | ---------- | ----------- 28 | |`domain` | Yes | String | Sender domain name. 29 | |`mx_subdomain` | No | String | MX record subdomain (default: mx). 30 | 31 | ## Outputs 32 | 33 | | Name | Value Type | Description 34 | |---------------------------| ---------- | ----------- 35 | |`smtp-server` | String | Hostname of the SMTP server to use for sending e-mails. 36 | |`smtp-username` | String | User name to connect to the SMTP server. 37 | |`smtp-password` | String | Password to connect to the SMTP server. 38 | -------------------------------------------------------------------------------- /modules/aws/smtp/main.tf: -------------------------------------------------------------------------------- 1 | data "aws_region" "current" {} 2 | 3 | data "aws_route53_zone" "phishing_selected" { 4 | name = join(".",tolist([reverse(split(".", var.domain ))[1],reverse(split(".", var.domain ))[0]])) 5 | } 6 | 7 | resource "random_id" "username" { 8 | keepers = { 9 | zone_id = data.aws_route53_zone.phishing_selected.zone_id 10 | } 11 | 12 | byte_length = 6 13 | } 14 | 15 | resource "aws_iam_user" "smtp_user" { 16 | name = "ses-smtp-${random_id.username.hex}" 17 | } 18 | 19 | resource "aws_iam_user_policy" "smtp_policy" { 20 | name = "${aws_iam_user.smtp_user.name}-ses-smtp-policy" 21 | user = aws_iam_user.smtp_user.name 22 | 23 | policy = < ./data/credentials/smtp_credentials 99 | // echo '${aws_iam_access_key.smtp_access_key.id}' >> ./data/credentials/smtp_credentials 100 | // echo '${aws_iam_access_key.smtp_access_key.ses_smtp_password}' >> ./data/credentials/smtp_credentials 101 | // EOT 102 | // } 103 | 104 | -------------------------------------------------------------------------------- /modules/aws/smtp/outputs.tf: -------------------------------------------------------------------------------- 1 | output "smtp-server" { 2 | value = "email-smtp.${data.aws_region.current.name}.amazonaws.com" 3 | } 4 | 5 | output "smtp-username" { 6 | value = aws_iam_access_key.smtp_access_key.id 7 | } 8 | 9 | output "smtp-password" { 10 | value = aws_iam_access_key.smtp_access_key.ses_smtp_password_v4 11 | } 12 | -------------------------------------------------------------------------------- /modules/aws/smtp/variables.tf: -------------------------------------------------------------------------------- 1 | variable "domain" { 2 | type = string 3 | } 4 | 5 | variable "mx_subdomain" { 6 | type = string 7 | default = "mx" 8 | } 9 | --------------------------------------------------------------------------------