{"id":2318,"date":"2024-09-25T17:23:12","date_gmt":"2024-09-25T17:23:12","guid":{"rendered":"https:\/\/xdr-mdr.lmntrix.com\/main_web\/?p=2318"},"modified":"2025-07-29T03:33:37","modified_gmt":"2025-07-29T03:33:37","slug":"red-teaming-phishing-101","status":"publish","type":"post","link":"https:\/\/lmntrix.com\/blog\/red-teaming-phishing-101\/","title":{"rendered":"Red Teaming: Phishing 101"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101.webp\" alt=\"Red Teaming - Phishing 101\"\/><\/figure>\n\n\n\n<p>We at LMNTRIX Active Offense love phishing activities. A new phishing activity means being more creative to get someone to execute our payload. In one of the previous blogs, we wrote <a href=\"https:\/\/lmntrix.com\/lab\/winapi-excel-4-0-macros-and-red-team-phishing\/\">an Excel 4.0 phishing macro to execute Cobalt Strike shellcode<\/a>. However, today we will setup a phishing infra using <a href=\"https:\/\/login.mailgun.com\/login\/\" target=\"_blank\" rel=\"noopener\">Mailgun<\/a> and <a href=\"https:\/\/getgophish.com\/\" target=\"_blank\" rel=\"noopener\">GoPhish<\/a> which can be used alongside the previously built macro to gain an initial foothold on our target.<\/p>\n\n\n\n<p>Mailgun is a transactional mail service provider. It has a powerful setup of APIs to automate sending and receiving of e-mails which can be extremely helpful for commercial applications. However, we will only be using it\u2019s core functionality of sending mails along with it\u2019s API key. We will use GoPhish which is a standalone executable to setup a UI for our phishing server where we can build crafty E-mail Templates and store them for phishing activity. The GoPhish will use the API keys of Mailgun to send mails via the Mail server. We will use Namecheap to setup our domain for the phishing activity, however you can use any other Domain Service Providers either.<\/p>\n\n\n\n<p>We will start by purchasing a Domain from Namecheap. In our case, the domain is <strong>myasiahotels.com<\/strong> \u2013 just a random domain for testing purpose. In Namecheap, by default there should only be one entry in the Host Records as follows:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"606\" height=\"299\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-1.webp\" alt=\"\" class=\"wp-image-2297\"\/><\/figure>\n<\/div>\n\n\n<p>We will register our new domain in Mailgun and add the entries requested by Mailgun in our domain\u2019s host records. To create a new domain entry in Mailgun, login to Mailgun and select <strong>Sending-&gt;Domains-&gt;Add New Domain<\/strong> as can be seen below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/lmntrix.com\/wp-content\/uploads\/2021\/01\/Red-Teaming-Phishing-101-2.png\" alt=\"\" class=\"wp-image-1762\"\/><\/figure>\n<\/div>\n\n\n<p>Add a new entry by clicking <strong>Add New Domain<\/strong>, and enter your domain name. Make sure you select <strong>Advanced Settings <\/strong>and enabled <strong>DKIM<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"247\" height=\"281\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-3-1.webp\" alt=\"\" class=\"wp-image-2299\"\/><\/figure>\n<\/div>\n\n\n<p>DKIM (Domain Keys Identified Mail) gives a digital signature to your email. This can be verified by the receiving server to verify that the email indeed came from the domain it is trying to represent. This signature is added to the e-mail headers and is always encrypted. Most email service providers provide this option and it also helps to verify that our domain is indeed a real one and not a spoofed one. This is however one of the many things that we need to do to make sure our email lands in the Inbox and not inside spam.<\/p>\n\n\n\n<p>After registering the domain, Mailgun will provide us multiple host records that we need to add to our domain in Namecheap. This is done to verify that we are only adding a domain that we own and not spoofing someone else\u2019s domain. The host records in Mailgun would look like this:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"590\" height=\"330\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-4.webp\" alt=\"\" class=\"wp-image-2300\"\/><\/figure>\n<\/div>\n\n\n<p>As you can see, the image above shows x-mark and question mark since we are yet to add these records to our domain. Once we add and verify them here, it should convert to green tick marks. The above host records won\u2019t exist in our domain records by default. We will have to create each of them and add them manually. Select <strong>Add New Record<\/strong> option in Namecheap to add new records. Once the records have been added as shown below, select <strong>Verify DNS Settings<\/strong> to get the settings verified in Mailgun.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"593\" height=\"420\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-5.webp\" alt=\"\" class=\"wp-image-2301\"\/><\/figure>\n<\/div>\n\n\n<p>Once we our registered domain verified in Mailgun, it\u2019s time to setup our GoPhish Server and use the SMTP credentials of our newly registered domain to our GoPhish Server. You can select <strong>Sending-&gt;Domains settings-&gt;SMTP Credentials-&gt;Reset Password<\/strong> in Mailgun to view the SMTP credentials for the root user of your domain. The root user by default will be <em>postmaster@&lt;your-domain-name&gt;<\/em> (which in our case would be myasiahotels.com).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"597\" height=\"122\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-6.webp\" alt=\"\" class=\"wp-image-2302\"\/><\/figure>\n<\/div>\n\n\n<p>Now we will download the latest GoPhish binary from <a href=\"https:\/\/github.com\/gophish\/gophish\/releases\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/gophish\/gophish\/releases<\/a>. At the time of writing this blog, the GoPhish version was v0.11.0. The best part about GoPhish is that it\u2019s written in Go and it always results in a single executable when compiled. So, we don\u2019t need to worry about any missing dependencies. We will host GoPhish on the same host which points to myasiahotels.com. GoPhish requires a json file from which it parses the configuration details from. Below is the json config which we will use. It will make the GoPhish admin portal run on port 1234 and the actual phishing server on port 443.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"256\" height=\"234\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-7.webp\" alt=\"\" class=\"wp-image-2303\"\/><\/figure>\n<\/div>\n\n\n<p>You can generate the necessary SSL keys using Let\u2019s Encrypt and provide them in the above configuration file. Some organizations which are pretty hard on their security, have lately started to filter out web servers which use Let\u2019s Encrypt SSL certificate on their organizational proxy servers. If you are doing an actual red team engagement, then you would be better of buying an actual SSL certificate instead of using a 4-month valid cert from Let\u2019s Encrypt and blowing your cover. In the above configuration, make sure you change the phish server\u2019s url to the actual IP address where your domain is pointing to. This is where you actual phishing page will be hosted. Alternatively, you can also disable this, if you believe in advanced threat tactics and want to use a more custom phishing config using ngnix or any other custom tool.<\/p>\n\n\n\n<p>Now we can execute GoPhish with the above config file as a parameter and visit 127.0.0.1:1234. This is the admin portal for GoPhish and you can find the login credentials on the terminal when you execute GoPhish. After login into the GoPhish server, select <strong>Sending Profiles-&gt;New Profile<\/strong>. Enter a profile name that you wish and the email you want to send the phishing email from. This email can be any name, but the email domain should be your domain registered in Mailgun. Enter your postmaster\u2019s mail ID and password provided by Mailgun above and use smtp.mailgun.org:587 (uses TLS) for mail server. This is how the configuration would look like:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"315\" height=\"287\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-8.webp\" alt=\"\" class=\"wp-image-2304\"\/><\/figure>\n<\/div>\n\n\n<p>And before you save the above config, select the <strong>Send Test Email<\/strong> button to check whether your mail lands in the inbox. We will send a test mail to our Gmail ID and check if our hosted server works. Gmail has a really good spam filter and this should give us a fair idea whether our mail would land in the Inbox or Spam.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"308\" height=\"389\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-9.webp\" alt=\"\" class=\"wp-image-2305\"\/><\/figure>\n<\/div>\n\n\n<p>And the Gmail Inbox:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"933\" height=\"647\" src=\"https:\/\/lmntrix.com\/blog\/wp-content\/uploads\/2024\/09\/Red-Teaming-Phishing-101-10.webp\" alt=\"\" class=\"wp-image-2306\"\/><\/figure>\n<\/div>\n\n\n<p>Great, now that our phishing server works, we can add a list of users that we want to phish by selecting <strong>Users-&gt;Groups<\/strong> in the GoPhish dashboard, and create an email template by selecting<strong> Email Templates<\/strong>. Now that we have everything set, the only pending task would be to use our creativity to build phishing templates and phish our target.<\/p>\n\n\n\n<p>For more information about the LMNTRIX Active Offense &#8211; Red Teaming capability or if you have any questions about this article, you can reach us at info@lmntrix.com.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We at LMNTRIX Active Offense love phishing activities. A new phishing activity means being more creative to get someone to execute our payload. In one of the previous blogs, we wrote an Excel 4.0 phishing macro to execute Cobalt Strike shellcode. However, today we will setup a phishing infra using Mailgun and GoPhish which can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2307,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-2318","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-labs"],"_links":{"self":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts\/2318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/comments?post=2318"}],"version-history":[{"count":3,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts\/2318\/revisions"}],"predecessor-version":[{"id":4238,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/posts\/2318\/revisions\/4238"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/media\/2307"}],"wp:attachment":[{"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/media?parent=2318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/categories?post=2318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lmntrix.com\/blog\/wp-json\/wp\/v2\/tags?post=2318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}