<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Pentagrid AG (Posts about Portswigger)</title><link>https://www.pentagrid.ch/</link><description></description><atom:link href="https://www.pentagrid.ch/en/categories/portswigger.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2026 Pentagrid AG </copyright><lastBuildDate>Wed, 17 Jun 2026 19:14:55 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Hackvertor EAN-13 and TOTP tags for web-application penetration testing with Burp</title><link>https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;Hackvertor is a &lt;a class="reference external" href="https://hackvertor.co.uk/"&gt;standalone tool&lt;/a&gt; and more importantly for us an &lt;a class="reference external" href="https://portswigger.net/bappstore/65033cbd2c344fbabe57ac060b5dd100"&gt;extension for the penetration testing tool Portswigger Burp Suite&lt;/a&gt; by &lt;a class="reference external" href="https://garethheyes.co.uk/"&gt;Gareth Heyes&lt;/a&gt; of the Portswigger Research team, which performs dynamic data conversions. For example, the tool can be used to encode data fields as Base64 before Burp sends a HTTP POST request to a server. This happens automatically and there is no need to manually convert anything or copy and pasting between different windows.&lt;/p&gt;
&lt;p&gt;We had an example in our blog, where we &lt;a class="reference external" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/"&gt;generated Swiss social security numbers for a pentest and explained how to program custom Hackvertor tags&lt;/a&gt;. There are all kinds of tags already available inside Hackvertor and users can also code their own custom tags. Nowadays Hackvertor has it's own &lt;a class="reference external" href="https://github.com/hackvertor/hackvertor/tree/master/tag-store"&gt;public tag store&lt;/a&gt;, where users can submit custom tags. Pentagrid provided two custom tags that made it into the Hackvertor tag store. One tag is for calculating the &lt;a class="reference external" href="https://en.wikipedia.org/wiki/International_Article_Number#Check_digit"&gt;check-digit of EAN-13 numbers&lt;/a&gt; and another is for &lt;a class="reference external" href="https://en.wikipedia.org/wiki/Time-based_one-time_password"&gt;Time-based one-time password (TOTP)&lt;/a&gt; calculation.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;p&gt;As already explained in our blog post &lt;a class="reference external" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/"&gt;Teaching Burp a new HTTP Transport Encoding&lt;/a&gt;, being able to customise Burp like this is a helpful instrument to automate and increase test coverage during a security analysis.&lt;/p&gt;
&lt;section id="ean-13-hackvertor-tag"&gt;
&lt;h2&gt;EAN-13 Hackvertor tag&lt;/h2&gt;
&lt;p&gt;EAN is the European Article Number, a standard to encode article numbers. And while it became more international than European and is now called Global Trade Item Number, it is often still referred as EAN-13. Swiss AHV/AVS numbers use the check-sum calculation from EAN-13 and store the check-sum as the 13th digit.&lt;/p&gt;
&lt;p&gt;The custom tag code from our &lt;a class="reference external" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/"&gt;blog post&lt;/a&gt; was made available as a &lt;a class="reference external" href="https://github.com/hackvertor/hackvertor/pull/112/"&gt;Hackvertor tag in the tag store&lt;/a&gt;. To use the EAN-13 tag, see the following two examples:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_b83e705325f24e94b5a2143fdd9791ec-1" name="rest_code_b83e705325f24e94b5a2143fdd9791ec-1" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_b83e705325f24e94b5a2143fdd9791ec-1"&gt;&lt;/a&gt;# the "append" parameter can be set to 0 or 1.
&lt;a id="rest_code_b83e705325f24e94b5a2143fdd9791ec-2" name="rest_code_b83e705325f24e94b5a2143fdd9791ec-2" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_b83e705325f24e94b5a2143fdd9791ec-2"&gt;&lt;/a&gt;&amp;lt;@_ean13(1,'[...]')&amp;gt;756.9217.0769.8&amp;lt;/@_ean13&amp;gt; # -&amp;gt; 756.9217.0769.85
&lt;a id="rest_code_b83e705325f24e94b5a2143fdd9791ec-3" name="rest_code_b83e705325f24e94b5a2143fdd9791ec-3" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_b83e705325f24e94b5a2143fdd9791ec-3"&gt;&lt;/a&gt;&amp;lt;@_ean13(0,'[...]')&amp;gt;756.9217.0769.8&amp;lt;/@_ean13&amp;gt; # -&amp;gt; 5
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The omission [...] is the place where a so-called Hackvertor code execution key must be inserted. The Hackvertor Burp extension will add the code execution key automatically, if the tags are used and prepared in the Hackvertor tab in the Burp UI. The execution key is a random 40-hex character string that prevents websites processed by Burp from triggering harmful actions. The code execution key is unique to your Burp application start. Only code execution tags (with custom code such as the ones in the tag store) require code execution keys.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="totp-hackvertor-tag"&gt;
&lt;h2&gt;TOTP Hackvertor tag&lt;/h2&gt;
&lt;p&gt;Pentagrid also implemented a TOTP tag. This time-based one-time password is used for second factor authentication. If such a second factor is required during the penetration test, this Hackvertor tag can be used. The code was recently &lt;a class="reference external" href="https://github.com/hackvertor/hackvertor/pull/121"&gt;added to the tag store&lt;/a&gt;. To use the TOTP tag, extract the seed from the QR code that was handed over to you to scan it with an authenticator app. The command line tool &lt;cite&gt;zbarimg&lt;/cite&gt; can dump QR code content from an image file:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_a537a9cac8cb42efbc062c990c6c2330-1" name="rest_code_a537a9cac8cb42efbc062c990c6c2330-1" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_a537a9cac8cb42efbc062c990c6c2330-1"&gt;&lt;/a&gt;% zbarimg ~/Authenticator-QR-Code.png
&lt;a id="rest_code_a537a9cac8cb42efbc062c990c6c2330-2" name="rest_code_a537a9cac8cb42efbc062c990c6c2330-2" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_a537a9cac8cb42efbc062c990c6c2330-2"&gt;&lt;/a&gt;QR-Code:otpauth://totp/SomeOrg:something?secret=MYSEEDMYSEED2342&amp;amp;issuer=SomeOrg
&lt;a id="rest_code_a537a9cac8cb42efbc062c990c6c2330-3" name="rest_code_a537a9cac8cb42efbc062c990c6c2330-3" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_a537a9cac8cb42efbc062c990c6c2330-3"&gt;&lt;/a&gt;scanned 1 barcode symbols from 1 images in 0.05 seconds
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The tag can then be used analogue to this example:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_edbc1bfdeeca4d049640c71ae105314e-1" name="rest_code_edbc1bfdeeca4d049640c71ae105314e-1" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/#rest_code_edbc1bfdeeca4d049640c71ae105314e-1"&gt;&lt;/a&gt;&amp;lt;@_totp('[...]')&amp;gt;MYSEEDMYSEED2342&amp;lt;/@_totp&amp;gt; # -&amp;gt; 797723
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There are several parameters for TOTP. In practise, the tag only supports the commonly used parameters SHA1, 30 seconds, 6 digits. Let us know if you find a different configuration in the wild, it should be fairly simple to adapt the custom tag in that case.&lt;/p&gt;
&lt;p&gt;In order to access the tag store, just go to the menu entry "View tag store" from the Hackvertor menu in Burp and install the plugins you want. Then also make sure to allow code execution tags via the menu entry "Allow code execution tags" from the Hackvertor menu in Burp.&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202412_hackvertor-tag-store.png"&gt;
&lt;img alt="Hackvertor tag store and installed custom tags in the background." class="align-center" src="https://www.pentagrid.ch/images/202412_hackvertor-tag-store.thumbnail.png"&gt;
&lt;/a&gt;
&lt;p&gt;Update 2025-06-04: An update of Hackvertor in 2025 changed the style of closing elements from &lt;cite&gt;&amp;lt;@/name&amp;gt;&lt;/cite&gt; to &lt;cite&gt;&amp;lt;/@name&amp;gt;&lt;/cite&gt;. Therefore, we updated the post.&lt;/p&gt;
&lt;/section&gt;</description><category>Burp</category><category>Hackvertor</category><category>Multi-Factor Authentication</category><category>OWASP</category><category>Pentesting</category><category>Portswigger</category><guid>https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/</guid><pubDate>Fri, 06 Dec 2024 08:42:00 GMT</pubDate></item><item><title>Teaching Burp a new HTTP Transport Encoding</title><link>https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;Today we would like to talk about Burp Suite Professional and extensions again. In this blog post we explain how we can teach Burp Suite to handle a custom Transport Encoding that is spoken between an HTTP client and a server by using Burp extensions.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;section id="introduction"&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Burp has many nice features, but sometimes it lacks a feature we would like to have or our target application is customized so that it is necessary to teach Burp new things. More specifically:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Burp has &lt;a class="reference external" href="https://forum.portswigger.net/thread/brotli-compression-is-not-supported-988bf33f"&gt;no support for the standard HTTP brotli Transport-Encoding&lt;/a&gt;, but all modern browsers do. This problem is handled by Burp by removing brotli from the Accept-Encoding request header (see Proxy - Options - Miscellaneous - Remove unsupported encodings from Accept-Encoding headers in incoming requests), which works for modern browsers. However, we encountered situations during tests where a non-browser HTTP client software required brotli and refused to talk to the server when brotli encoding is missing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Java fat clients sometimes zlib-encode the entire HTTP body when talking to a server and vice-versa. They also often refuse to speak non-zlib and do not signal it at all in an HTTP header, therefore it is necessary to implement zlib-decoding and encoding to be able to use Burp properly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If a website uses JavaScript to encrypt all HTTP bodies when talking to a server and vice-versa, we also would like to implement a decryption and encryption routing to use the Burp tools. We also encountered the same situation with other HTTP clients that used additional transport encryption, such as mobile banking apps.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The biggest issue for us was to figure out how we approach these situations consistently and we show our approach in this blog post.&lt;/p&gt;
&lt;p&gt;In this blog post we often refer to "encoding" or "encrypting", which obviously is not the same, but both operations have to be done at the same place inside Burp. Encryption or encoding is merely an implementation detail in this blog post. Also "cleartext" is used to indicate decoded or decrypted content.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="why-are-you-doing-all-of-this"&gt;
&lt;h2&gt;Why are you doing all of this?&lt;/h2&gt;
&lt;p&gt;If Burp is not seeing decoded messages for one of the reasons above, it won't work properly. Tools such as Burp Scanner, Repeater, Intruder and other extensions will often fail to interpret the encoded HTTP content and will for sure fail with encrypted content. It won't matter if you use the scanner or not, in many cases it won't do anything useful if you don't implement this custom decoder/encoder. On the contrary, very often a tester's task is to make their tools work. This might be rewarded in the end by simply pressing the active scan button in Burp and then finding security issues. To us, this is a huge difference between a good and a bad security analysis.&lt;/p&gt;
&lt;p&gt;Usually we would suggest to solve this problem with features or extensions that are already present, for example the Hackvertor extension would be a good candidate. However, Hackvertor won't modify responses, so this isn't an option here.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="burp-s-api-for-extensions"&gt;
&lt;h2&gt;Burp's API for extensions&lt;/h2&gt;
&lt;p&gt;Burp provides several &lt;a class="reference external" href="https://portswigger.net/burp/extender/api/"&gt;APIs an extension can use&lt;/a&gt;. The API code didn't get much love in the last few years, but this is hopefully changing when Burp releases the &lt;a class="reference external" href="https://portswigger.net/blog/burp-suite-roadmap-for-2022"&gt;New API and multi-language extensibility&lt;/a&gt;. Let's hope for the best, but for now we're stuck with the API we have. There are two main API hooks that matter in the situation of a missing Transport Encoding. We'll use the name of the function name in the rest of this blog post, but the interfaces that provide the functionality are called:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://portswigger.net/burp/extender/api/burp/IProxyListener.html"&gt;IProxyListener&lt;/a&gt;, which means you have to implement the function &lt;code class="docutils literal"&gt;processProxyMessage&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a class="reference external" href="https://portswigger.net/burp/extender/api/burp/IHttpListener.html"&gt;IHttpListener&lt;/a&gt;, which means you have to implement the function &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While both interfaces sound similar, the proxy listener will only see requests and responses going through the proxy (e.g. from the browser), whereas the HTTP listener will see the requests and responses of all tools (Proxy, Crawler, Scanner, Repeater, Intruder, other extensions, etc.). However, there's one little detail that is important to mention: If you want to change messages going throught the proxy, you have to do that in the &lt;code class="docutils literal"&gt;processProxyMessage&lt;/code&gt; function and you can't do that in the &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt;. It's just a Burp API limitation that you can't modify messages from TOOL_PROXY in the &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt;. That means we have to get around this limitation by choosing the correct API.&lt;/p&gt;
&lt;p&gt;While we think it is better to use Kotlin to write large Burp extensions nowadays, rapid prototyping is still quicker with Python. Therefore we use Python (or rather, Jython 2.7 in Burp) in this blog post.&lt;/p&gt;
&lt;p&gt;Here's a little Python sample extension that handles the API confusion of &lt;code class="docutils literal"&gt;processProxyMessage&lt;/code&gt; and &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt;, so we don't need to care about it anymore and can just modify messages in the newly created &lt;code class="docutils literal"&gt;processMessage&lt;/code&gt; function:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_773268b73f2b497380611e55069e938d-1" name="rest_code_773268b73f2b497380611e55069e938d-1" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-1"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IBurpExtender&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-2" name="rest_code_773268b73f2b497380611e55069e938d-2" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-2"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IHttpListener&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-3" name="rest_code_773268b73f2b497380611e55069e938d-3" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-3"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IProxyListener&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-4" name="rest_code_773268b73f2b497380611e55069e938d-4" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-4"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-5" name="rest_code_773268b73f2b497380611e55069e938d-5" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-6" name="rest_code_773268b73f2b497380611e55069e938d-6" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-6"&gt;&lt;/a&gt;&lt;span class="n"&gt;NAME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Pentagrid Extension Template"&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-7" name="rest_code_773268b73f2b497380611e55069e938d-7" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-8" name="rest_code_773268b73f2b497380611e55069e938d-8" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-8"&gt;&lt;/a&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;BurpExtender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IBurpExtender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IProxyListener&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IHttpListener&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-9" name="rest_code_773268b73f2b497380611e55069e938d-9" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-10" name="rest_code_773268b73f2b497380611e55069e938d-10" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-10"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;registerExtenderCallbacks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-11" name="rest_code_773268b73f2b497380611e55069e938d-11" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-11"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# keep a reference to our callbacks object&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-12" name="rest_code_773268b73f2b497380611e55069e938d-12" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-12"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-13" name="rest_code_773268b73f2b497380611e55069e938d-13" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-14" name="rest_code_773268b73f2b497380611e55069e938d-14" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-14"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# set our extension name&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-15" name="rest_code_773268b73f2b497380611e55069e938d-15" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-15"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setExtensionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-16" name="rest_code_773268b73f2b497380611e55069e938d-16" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-16"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-17" name="rest_code_773268b73f2b497380611e55069e938d-17" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-17"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# register ourselves as an Proxy listener&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-18" name="rest_code_773268b73f2b497380611e55069e938d-18" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-18"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registerProxyListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-19" name="rest_code_773268b73f2b497380611e55069e938d-19" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-19"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-20" name="rest_code_773268b73f2b497380611e55069e938d-20" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-20"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# register ourselves as an HTTP listener&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-21" name="rest_code_773268b73f2b497380611e55069e938d-21" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-21"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registerHttpListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-22" name="rest_code_773268b73f2b497380611e55069e938d-22" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-22"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-23" name="rest_code_773268b73f2b497380611e55069e938d-23" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-23"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Loaded "&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s2"&gt;" successfully!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-24" name="rest_code_773268b73f2b497380611e55069e938d-24" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-24"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-25" name="rest_code_773268b73f2b497380611e55069e938d-25" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-25"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-26" name="rest_code_773268b73f2b497380611e55069e938d-26" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-26"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# implement IHttpListener&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-27" name="rest_code_773268b73f2b497380611e55069e938d-27" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-27"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-28" name="rest_code_773268b73f2b497380611e55069e938d-28" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-28"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-29" name="rest_code_773268b73f2b497380611e55069e938d-29" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-29"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processHttpMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-30" name="rest_code_773268b73f2b497380611e55069e938d-30" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-30"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TOOL_PROXY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-31" name="rest_code_773268b73f2b497380611e55069e938d-31" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-31"&gt;&lt;/a&gt;            &lt;span class="c1"&gt;# DONT'T DO ANYTHING HERE&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-32" name="rest_code_773268b73f2b497380611e55069e938d-32" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-32"&gt;&lt;/a&gt;            &lt;span class="c1"&gt;# Instead, use processProxyMessage below&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-33" name="rest_code_773268b73f2b497380611e55069e938d-33" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-33"&gt;&lt;/a&gt;            &lt;span class="c1"&gt;# https://github.com/nccgroup/BurpSuiteLoggerPlusPlus/issues/42&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-34" name="rest_code_773268b73f2b497380611e55069e938d-34" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-34"&gt;&lt;/a&gt;            &lt;span class="k"&gt;return&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-35" name="rest_code_773268b73f2b497380611e55069e938d-35" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-35"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-36" name="rest_code_773268b73f2b497380611e55069e938d-36" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-36"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-37" name="rest_code_773268b73f2b497380611e55069e938d-37" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-37"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-38" name="rest_code_773268b73f2b497380611e55069e938d-38" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-38"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# implement IProxyListener&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-39" name="rest_code_773268b73f2b497380611e55069e938d-39" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-39"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-40" name="rest_code_773268b73f2b497380611e55069e938d-40" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-40"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processProxyMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-41" name="rest_code_773268b73f2b497380611e55069e938d-41" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-41"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;processMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TOOL_PROXY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getMessageInfo&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-42" name="rest_code_773268b73f2b497380611e55069e938d-42" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-42"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-43" name="rest_code_773268b73f2b497380611e55069e938d-43" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-43"&gt;&lt;/a&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-44" name="rest_code_773268b73f2b497380611e55069e938d-44" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-44"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-45" name="rest_code_773268b73f2b497380611e55069e938d-45" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-45"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# TODO: Implement whatever you would like to do&lt;/span&gt;
&lt;a id="rest_code_773268b73f2b497380611e55069e938d-46" name="rest_code_773268b73f2b497380611e55069e938d-46" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_773268b73f2b497380611e55069e938d-46"&gt;&lt;/a&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;As a bonus, the Burp UI will show the "Edited request" or "Edited response" option in the Proxy tool whenever we change a proxy message. However, for &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt; we are partially blind, the request and responses will simply be changed, but depending on where we measure we might see them in a different state in the UI (discussed in the next section).&lt;/p&gt;
&lt;/section&gt;
&lt;section id="burp-s-hooking-locations"&gt;
&lt;h2&gt;Burp's hooking locations&lt;/h2&gt;
&lt;p&gt;We would like to hook as early as possible and as late as possible. We would like to make sure that we decode or decrypt early, so that all other Burp tools can work with readable non-compressed HTTP requests and responses. We also want to encode or encrypt as late as possible, just before the request leaves Burp for the same reason. The problem here is that &lt;code class="docutils literal"&gt;processProxyMessage&lt;/code&gt; is called before &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt; for requests, but for responses &lt;code class="docutils literal"&gt;processHttpMessage&lt;/code&gt; is called before &lt;code class="docutils literal"&gt;processProxyMessage&lt;/code&gt;. When analysing the exact behavior, we saw it's a non-trivial setup. For example, the built-in Burp Logger is a tab in the Burp UI showing all requests/responses that flow through Burp. But the question is, where does the Burp Logger hook the API itself? Moreover, users who have advanced knowledge of Burp also know that the extension order in the loaded extension list matters. So where should we put our decoder or decrypter and where should we put our encoder or encrypter? This is not easy to explain and it took us a little trial and error, but we figured out that this diagram should be accurate:&lt;/p&gt;
&lt;figure class="align-center"&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202204_burp_handling_of_messages.png"&gt;
&lt;img alt="Diagram showing how requests and responses are processed inside Burp when we load our Burp extensions. Green is for cleartext (decoded or decrypted) traffic, red for encoded or encrypted traffic." src="https://www.pentagrid.ch/images/202204_burp_handling_of_messages.thumbnail.png"&gt;
&lt;/a&gt;
&lt;figcaption&gt;
&lt;p&gt;Diagram showing how requests and responses are processed inside Burp when we load our Burp extensions. Green is for cleartext (decoded or decrypted) traffic, red for encoded or encrypted traffic.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;This diagram shows several interesting details:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;We achieve what we want: Target, Intruder, Repeater, Scanner and other extensions can deal with "cleartext" requests. However, we can't make it work with Proxy match/replace rules for requests (they are applied to the encoded content).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Burp's built-in Logger is not last in the chain for responses, it's possible that Burp extensions modify the responses. This means you don't necessarily see what was delivered to the client/server in Logger. You should better use Logger++ and put it last in the extension list to see which requests are sent to the server and which responses are returned after processing in Burp. Of course it depends on what you want to see, but that's what is the most logical setup.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Our extension we would like to write for our purpose has to be first &lt;em&gt;and&lt;/em&gt; last (well, second-last before Logger++) to make sure it does its job well. This means we need to write two extensions, an early-decoder that is first in the list for requests (see DECRYPTER top left in the diagram) and responses (see DECRYPTER bottom right) and a late-reencoder that is last in the list for requests (see ENCRYPTER bottom left) and responses (see ENCRYPTER top right). So the order of the extensions has to be like in the following image:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;figure class="align-center"&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202204_burp_extension_order.png"&gt;
&lt;img alt="Extension order is important to make sure all extensions see the correct traffic. Early decoder as the first extension, late encoder as the second-last." src="https://www.pentagrid.ch/images/202204_burp_extension_order.thumbnail.png"&gt;
&lt;/a&gt;
&lt;figcaption&gt;
&lt;p&gt;Extension order is important to make sure all extensions see the correct traffic. Early decoder as the first extension, late encoder as the second-last.&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Now that we know we need two extensions, how would the Python extensions look like? Here's the early decoder:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-1" name="rest_code_dfe7432a4980464381e3ff25cfac818b-1" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-1"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IBurpExtender&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-2" name="rest_code_dfe7432a4980464381e3ff25cfac818b-2" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-2"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IHttpListener&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-3" name="rest_code_dfe7432a4980464381e3ff25cfac818b-3" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-3"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IProxyListener&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-4" name="rest_code_dfe7432a4980464381e3ff25cfac818b-4" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-4"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-5" name="rest_code_dfe7432a4980464381e3ff25cfac818b-5" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-6" name="rest_code_dfe7432a4980464381e3ff25cfac818b-6" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-6"&gt;&lt;/a&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Pentagrid early decoder"&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-7" name="rest_code_dfe7432a4980464381e3ff25cfac818b-7" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-8" name="rest_code_dfe7432a4980464381e3ff25cfac818b-8" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-8"&gt;&lt;/a&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;BurpExtender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IBurpExtender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IHttpListener&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IProxyListener&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-9" name="rest_code_dfe7432a4980464381e3ff25cfac818b-9" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-10" name="rest_code_dfe7432a4980464381e3ff25cfac818b-10" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-10"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;registerExtenderCallbacks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-11" name="rest_code_dfe7432a4980464381e3ff25cfac818b-11" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-11"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-12" name="rest_code_dfe7432a4980464381e3ff25cfac818b-12" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-12"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# keep a reference to our callbacks object&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-13" name="rest_code_dfe7432a4980464381e3ff25cfac818b-13" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-13"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-14" name="rest_code_dfe7432a4980464381e3ff25cfac818b-14" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-14"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-15" name="rest_code_dfe7432a4980464381e3ff25cfac818b-15" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-15"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# obtain an extension helpers object&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-16" name="rest_code_dfe7432a4980464381e3ff25cfac818b-16" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-16"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_helpers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getHelpers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-17" name="rest_code_dfe7432a4980464381e3ff25cfac818b-17" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-17"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-18" name="rest_code_dfe7432a4980464381e3ff25cfac818b-18" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-18"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# set our extension name&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-19" name="rest_code_dfe7432a4980464381e3ff25cfac818b-19" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-19"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setExtensionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-20" name="rest_code_dfe7432a4980464381e3ff25cfac818b-20" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-20"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-21" name="rest_code_dfe7432a4980464381e3ff25cfac818b-21" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-21"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# register ourselves as an HTTP listener&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-22" name="rest_code_dfe7432a4980464381e3ff25cfac818b-22" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-22"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registerHttpListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-23" name="rest_code_dfe7432a4980464381e3ff25cfac818b-23" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-23"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registerProxyListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-24" name="rest_code_dfe7432a4980464381e3ff25cfac818b-24" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-24"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-25" name="rest_code_dfe7432a4980464381e3ff25cfac818b-25" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-25"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Loaded "&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s2"&gt;" successfully!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-26" name="rest_code_dfe7432a4980464381e3ff25cfac818b-26" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-26"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-27" name="rest_code_dfe7432a4980464381e3ff25cfac818b-27" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-27"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-28" name="rest_code_dfe7432a4980464381e3ff25cfac818b-28" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-28"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# implement IHttpListener&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-29" name="rest_code_dfe7432a4980464381e3ff25cfac818b-29" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-29"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-30" name="rest_code_dfe7432a4980464381e3ff25cfac818b-30" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-30"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-31" name="rest_code_dfe7432a4980464381e3ff25cfac818b-31" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-31"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processHttpMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-32" name="rest_code_dfe7432a4980464381e3ff25cfac818b-32" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-32"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TOOL_PROXY&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-33" name="rest_code_dfe7432a4980464381e3ff25cfac818b-33" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-33"&gt;&lt;/a&gt;            &lt;span class="c1"&gt;# Already processed in processProxyMessage&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-34" name="rest_code_dfe7432a4980464381e3ff25cfac818b-34" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-34"&gt;&lt;/a&gt;            &lt;span class="k"&gt;return&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-35" name="rest_code_dfe7432a4980464381e3ff25cfac818b-35" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-35"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-36" name="rest_code_dfe7432a4980464381e3ff25cfac818b-36" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-36"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-37" name="rest_code_dfe7432a4980464381e3ff25cfac818b-37" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-37"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-38" name="rest_code_dfe7432a4980464381e3ff25cfac818b-38" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-38"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# implement IProxyListener&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-39" name="rest_code_dfe7432a4980464381e3ff25cfac818b-39" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-39"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-40" name="rest_code_dfe7432a4980464381e3ff25cfac818b-40" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-40"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processProxyMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-41" name="rest_code_dfe7432a4980464381e3ff25cfac818b-41" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-41"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# Responses are handled as early as possible in processHttpMessage&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-42" name="rest_code_dfe7432a4980464381e3ff25cfac818b-42" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-42"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-43" name="rest_code_dfe7432a4980464381e3ff25cfac818b-43" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-43"&gt;&lt;/a&gt;            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TOOL_PROXY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getMessageInfo&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-44" name="rest_code_dfe7432a4980464381e3ff25cfac818b-44" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-44"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-45" name="rest_code_dfe7432a4980464381e3ff25cfac818b-45" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-45"&gt;&lt;/a&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-46" name="rest_code_dfe7432a4980464381e3ff25cfac818b-46" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-46"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;filter_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-47" name="rest_code_dfe7432a4980464381e3ff25cfac818b-47" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-47"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# TODO: implement decoding&lt;/span&gt;
&lt;a id="rest_code_dfe7432a4980464381e3ff25cfac818b-48" name="rest_code_dfe7432a4980464381e3ff25cfac818b-48" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_dfe7432a4980464381e3ff25cfac818b-48"&gt;&lt;/a&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And here's the late encoder:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-1" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-1" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-1"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IBurpExtender&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-2" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-2" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-2"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IHttpListener&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-3" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-3" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-3"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IProxyListener&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-4" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-4" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-4"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;burp&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-5" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-5" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-6" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-6" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-6"&gt;&lt;/a&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Pentagrid late encoder"&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-7" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-7" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-7"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-8" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-8" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-8"&gt;&lt;/a&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;BurpExtender&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IBurpExtender&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IHttpListener&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IProxyListener&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-9" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-9" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-9"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-10" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-10" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-10"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;registerExtenderCallbacks&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-11" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-11" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-11"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-12" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-12" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-12"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# keep a reference to our callbacks object&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-13" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-13" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-13"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_callbacks&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-14" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-14" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-14"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-15" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-15" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-15"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# obtain an extension helpers object&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-16" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-16" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-16"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;_helpers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getHelpers&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-17" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-17" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-17"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-18" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-18" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-18"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# set our extension name&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-19" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-19" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-19"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;setExtensionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-20" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-20" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-20"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-21" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-21" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-21"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# register ourselves as an HTTP listener&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-22" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-22" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-22"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registerHttpListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-23" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-23" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-23"&gt;&lt;/a&gt;        &lt;span class="n"&gt;callbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;registerProxyListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-24" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-24" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-24"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-25" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-25" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-25"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Loaded "&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;NAME&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="s2"&gt;" successfully!"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-26" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-26" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-26"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-27" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-27" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-27"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-28" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-28" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-28"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# implement IHttpListener&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-29" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-29" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-29"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-30" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-30" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-30"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-31" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-31" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-31"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processHttpMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-32" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-32" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-32"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TOOL_PROXY&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-33" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-33" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-33"&gt;&lt;/a&gt;            &lt;span class="c1"&gt;# Requests are handled as late as possible in processProxyMessage&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-34" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-34" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-34"&gt;&lt;/a&gt;            &lt;span class="k"&gt;return&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-35" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-35" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-35"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-36" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-36" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-36"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-37" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-37" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-37"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-38" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-38" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-38"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# implement IProxyListener&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-39" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-39" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-39"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-40" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-40" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-40"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;processProxyMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-41" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-41" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-41"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# Responses are handled as late as possible in processHttpMessage&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-42" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-42" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-42"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-43" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-43" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-43"&gt;&lt;/a&gt;            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;filter_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IBurpExtenderCallbacks&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TOOL_PROXY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;getMessageInfo&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-44" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-44" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-44"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-45" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-45" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-45"&gt;&lt;/a&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-46" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-46" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-46"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;filter_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toolFlag&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageIsRequest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messageInfo&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-47" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-47" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-47"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;# TODO: implement encoding&lt;/span&gt;
&lt;a id="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-48" name="rest_code_a6988cdcaff644c6b73b98e3c1897e6e-48" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_a6988cdcaff644c6b73b98e3c1897e6e-48"&gt;&lt;/a&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/section&gt;
&lt;section id="bonus"&gt;
&lt;h2&gt;Bonus&lt;/h2&gt;
&lt;p&gt;To make this a little more convenient for you, we've set up a &lt;a class="reference external" href="https://github.com/pentagridsec/PentagridBurpTransportEncoding"&gt;Github repository&lt;/a&gt; with all the examples from above (in the "minimal" subfolder). However, that's not all:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;A fully working example for the zlib-body encoding/decoding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A template that has some more helpful functions if you want to implement your own decoding/encoding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An additional extension that implements an IMessageEditorTabFactory, so if you encounter an encoded message in Burp you can click the message viewer option of the extension and will see it in decoded form.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="more-advanced-examples"&gt;
&lt;h2&gt;More advanced examples&lt;/h2&gt;
&lt;p&gt;With the above examples it should be no problem for you to also create extensions that do decryption/encryption instead of decoding/encoding in more complicated setups. In one of our security analysis, we were able to implement the decryption/encryption and hardcoded the key at first. However, then we realised we could additionally inject a JavaScript tag into the HTML single-page response of the server to "steal" our own encryption key from our browser. This removed the requirement to hard-code the encryption key. We did this by replacing &lt;code class="docutils literal"&gt;&amp;lt;/body&amp;gt;&lt;/code&gt; with:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code html"&gt;&lt;a id="rest_code_7e2805ef1f8a40cdb3156ff57c596351-1" name="rest_code_7e2805ef1f8a40cdb3156ff57c596351-1" href="https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/#rest_code_7e2805ef1f8a40cdb3156ff57c596351-1"&gt;&lt;/a&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;lastKey&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;pentagrid&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;nowKey&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;encryptionKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;nowKey&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;nowKey&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;!==&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;lastKey&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;&lt;span class="nx"&gt;lastKey&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;nowKey&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;pentagrid2&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ow"&gt;new&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;pentagrid2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/pentagridDiscloseKey="&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;nowKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;pentagrid2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;);}};&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pentagrid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;500&lt;/span&gt;&lt;span class="p"&gt;);&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This JavaScript extracted the encryption key from the browser DOM and sent it through Burp, so we could catch it in our decrypter/encrypter extensions and therefore fully intercept cleartext traffic.&lt;/p&gt;
&lt;p&gt;Happy hacking!&lt;/p&gt;
&lt;/section&gt;</description><category>API</category><category>Burp</category><category>Encryption</category><category>Extensions</category><category>Pentesting</category><category>Portswigger</category><category>Transport Encoding</category><guid>https://www.pentagrid.ch/en/blog/teaching_burp_a_new_http_transport_encoding/</guid><pubDate>Wed, 13 Apr 2022 10:42:00 GMT</pubDate></item><item><title>Response Overview Burp Extension</title><link>https://www.pentagrid.ch/en/blog/response_overview_burp_extension/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;Today we would like to announce the release of an updated BurpSuite extension in the BApp store.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;p&gt;In the last few months we've been busy improving some of our own tools. One of them was the Response Overview (used to be called "Response Clusterer") Burp extension. We did a complete rewrite from Jython to Kotlin. Jython has some huge compatibility issues inside Burp, just to mention some of them:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Extensions break depending on if Jython version 2.7.0 or 2.7.2 is installed.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type issues as Jython needs to convert Java arrays to Python string, which is not trivial in deeply-nested objects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Jython is not available for Python 3, which is okay, but when our extensions grew large, we missed the type hinting feature of Python 3.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cool features of Kotlin such as null-checking or automatically generated getter and setter methods are missing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The only real downside we see is that Kotlin extensions need to be compiled before they can be used, whereas changing a line in a Python script is much easier.&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202201_burp_response_overview.png"&gt;
&lt;img alt="Screenshot of the Response Overview Burp plugin" class="align-center" src="https://www.pentagrid.ch/images/202201_burp_response_overview.thumbnail.png"&gt;
&lt;/a&gt;
&lt;p&gt;This extension groups all response bodies by similarity and shows a summary, one request/response per group. The extension will allow a tester to get an overview of the tested website's responses from all tools (scanner, proxy, etc.). It provides an additional "semi-automated detection method" (compared to the usual detection methods response-based, time-based, interaction-based, etc.).&lt;/p&gt;
&lt;p&gt;The new Response Overview extension has some huge memory, performance and UI improvements. This includes being able to sort the overview table as well as hiding items in it.&lt;/p&gt;
&lt;p&gt;Moreover, according to Portswigger, this was the first Kotlin-only extension that was submitted to the Burp internal BApp store. They changed their build-pipeline to make sure Kotlin extensions can be auto-built in the future when submitted to the BApp store. So if you write an extension in Kotlin, make sure to have a look at our &lt;a class="reference external" href="https://github.com/pentagridsec/PentagridResponseOverview"&gt;Github repository&lt;/a&gt;. Moreover, include the API files found in the &lt;a class="reference external" href="https://github.com/bao7uo/burp-extender-api-kotlin"&gt;burp-extender-api-kotlin Github repository&lt;/a&gt; as we did in the Response Overview extension.&lt;/p&gt;
&lt;p&gt;During the journey of learning Kotlin and writing the extension, we encountered two annoying Kotlin compiler bugs. &lt;a class="reference external" href="https://youtrack.jetbrains.com/issue/KT-6653"&gt;One bug&lt;/a&gt; could be circumvented because Portswigger agreed that Kotlin extension can provide their own API files (see above). The &lt;a class="reference external" href="https://youtrack.jetbrains.com/issue/KT-19861"&gt;other bug&lt;/a&gt; was fixed when a new compiler version came out. We still haven't figured out another Serialization bug we encountered. So if you are a Java/Kotlin wizard, we would also be interested to hear from you why the Java Serialization (or rather the deserialization) of the boolean "hidden" flag in the &lt;a class="reference external" href="https://github.com/pentagridsec/PentagridResponseOverview/blob/main/src/main/kotlin/LogEntry.kt"&gt;LogEntry&lt;/a&gt; class is not working (hidden flag is always false when deserialized).&lt;/p&gt;
&lt;p&gt;The &lt;a class="reference external" href="https://github.com/pentagridsec/PentagridResponseOverview"&gt;Github repository&lt;/a&gt; also features more technical information about the extension. The extension can be found in BApp now and the BApp store listing can be found on the &lt;a class="reference external" href="https://portswigger.net/bappstore/e63f09f290ad4d9ea20031e84767b303"&gt;Portswigger website&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Have fun with the extension and happy bug hunting!&lt;/p&gt;</description><category>API</category><category>Burp</category><category>Extensions</category><category>Grouping</category><category>Overview</category><category>Pentesting</category><category>Portswigger</category><guid>https://www.pentagrid.ch/en/blog/response_overview_burp_extension/</guid><pubDate>Wed, 12 Jan 2022 13:30:00 GMT</pubDate></item><item><title>Password reset code brute-force vulnerability in AWS Cognito</title><link>https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;The password reset function of AWS Cognito allows attackers to change the account password if a six-digit number (reset code) sent out by E-mail is correctly entered. By using concurrent HTTP request techniques, it was shown that an attacker can do more guesses on this number than mentioned in the AWS documentation (1587 instead of 20). If the attack succeeds and the attacked accounts do not have multi-factor authentication enabled, a full take-over of the attacked AWS Cognito user accounts would have been possible. The issue was fixed by AWS on 2021-04-20.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;section id="impact"&gt;
&lt;h2&gt;Impact&lt;/h2&gt;
&lt;p&gt;An attacker who guessed the correct reset code can set a new password for the attacked AWS Cognito account. This allows attackers to take over the account that is not using additional multi-factor authentication.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="timeline"&gt;
&lt;h2&gt;Timeline&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;2021-03-17: Discovery of the issue by Pentagrid&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-03-22: Initial contact of AWS security according to the &lt;a class="reference external" href="https://aws.amazon.com/security/vulnerability-reporting/"&gt;vulnerability reporting website&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-03-23: AWS responds the issue is being investigated, Pentagrid responds with vulnerability details&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-03-24: AWS requests more details, Pentagrid responds with more vulnerability details&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-03-25: AWS requests more details about late invalidation of password-reset codes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-03-26: Pentagrid responds with more details regarding late invalidation of password-reset codes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-04-01: AWS responds the issue is still being investigated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-04-08: AWS responds the issue is still being investigated and asks for a phone call&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-04-13: to 2021-04-19: More E-mails regarding organisation of the phone call&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-04-22: Phone call between AWS security and Pentagrid AG: Issue has been fixed for all AWS customers on 2021-04-20&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-04-27: Pentagrid verifies the fix, only 20 code mismatches could be provoked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;2021-04-30: Advisory published&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="affected-components"&gt;
&lt;h2&gt;Affected Components&lt;/h2&gt;
&lt;p&gt;AWS Cognito user accounts are affected.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="technical-details"&gt;
&lt;h2&gt;Technical details&lt;/h2&gt;
&lt;p&gt;AWS Cognito is an AWS Service that provides user account management. This includes a password reset functionality as a self-service for Cognito end-users.&lt;/p&gt;
&lt;p&gt;The attack described here assumes that the AWS Cognito service is directly exposed to the web without custom filtering in the program code of the AWS customer. This is likely to be a common configuration. In the setup that was tested, an AWS Lambda instance forwarded requests to the AWS Cognito service by using the Python Chalice library.&lt;/p&gt;
&lt;p&gt;If no attack happens, the user's workflow is as following:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;The user enters his account's E-mail address in the password forgotten web form&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The user receives an E-mail that includes a six digit password reset code (from now on this is referred to as "code")&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By entering them into forms, the user sends the code, his account's E-mail address and a new password to the password forgotten functionality. This triggers the confirm_forgot_password function shown below.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As the code is the only secret value, it is crucial that an attacker can not guess its value. The codes have six digits, therefore the key space is 1'000'000, which corresponds to around 20 bits of security. As this is not sufficient from a generic security perspective because an attacker could potentially brute-force the code, AWS has to limit the number of times it can be entered.&lt;/p&gt;
&lt;p&gt;After the three-step process is done, the server will respond with one of the following responses:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;If the code is correct, the password for the account is immediately changed to the new value (HTTP 200 response)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the code is incorrect, the server responds with a &lt;cite&gt;cognito_client.exceptions.CodeMismatchException&lt;/cite&gt;, further referenced as &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt; (HTTP 500 response)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the confirm_forgot_password function was called too many times, the server responds with a &lt;cite&gt;cognito_client.exceptions.LimitExceededException&lt;/cite&gt;, further referenced as &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; (HTTP 500 response)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An internal server error if something went wrong, the source of this error is unknown to Pentagrid (HTTP 500 response)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;An attacker would like to trigger the &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt; as many times as possible until the password is changed, without triggering the limit exceeded response. The &lt;a class="reference external" href="https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-recover-a-user-account.html"&gt;AWS documentation about password resets of AWS Cognito&lt;/a&gt; accounts states:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;In a given hour, we allow between 5 and 20 attempts for a user to request or enter
a password reset code as part of forgot-password and confirm-forgot-password actions.
The exact value depends on the risk parameters associated with the requests. Please
note that this behaviour is subject to change.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There is no more information from AWS about how exactly the rate limiting is implemented. During our testing the behaviour of this rate limiting was non-deterministic in two ways:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;The amount of times the &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt; message could be triggered before a &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; message was received was non-deterministic. In our tests we were able to trigger between 20 and 1587 &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt; responses with the used concurrency technique.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even after the &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; message was received, this does not mean that the code was invalidated. Although an attacker has to wait until the AWS rate limiting cool-down is expired, he can then repeat the attack until a &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; value is received again. In our tests, the &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; could be received at least twice for the same code before the entire attack had to be restarted.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;We were able to show that, using a concurrency technique that sends requests simultaneously, it was possible to try up to 1587 codes before being blocked with a &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; message for the first time. 1587 attempts corresponds to a 0.16 % chance to guess the correct code in one attack. As the attacks conducted allowed anywhere between 20 and 1587 guesses, it is unclear how successful an attacker would be if multiple user accounts would be attacked simultaneously.&lt;/p&gt;
&lt;p&gt;The approach we used is based on opening several hundred TCP connections simultaneously, send all bytes except the last byte in each of the HTTP requests and then try to simultaneously send the last byte of the requests at once. This technique was developed by &lt;a class="reference external" href="https://github.com/PortSwigger/turbo-intruder"&gt;James Kettle&lt;/a&gt; of PortSwigger and is described in the corresponding &lt;a class="reference external" href="https://portswigger.net/research/turbo-intruder-embracing-the-billion-request-attack"&gt;blog post "Embracing the billion-request attack"&lt;/a&gt;. The attack was conducted by using the Turbo Intruder tool created by James Kettle. More specifically, the race.py script of Turbo Intruder was used.&lt;/p&gt;
&lt;p&gt;The Turbo Intruder setup is shown in the following picture:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202104_turbo_intruder.png"&gt;
&lt;img alt="Screenshot of the Burp Turbo Intruder showing the attack configuration." class="align-center" src="https://www.pentagrid.ch/images/202104_turbo_intruder.thumbnail.png"&gt;
&lt;/a&gt;
&lt;p&gt;For demonstration purposes, in some of the guesses sent during the attacks, the known correct code was sent which returned an HTTP 200 response, changing the password of the attacked account immediately, which proofed that the attack did work.&lt;/p&gt;
&lt;p&gt;The likelihood that an attack succeeds depends on how the undeterministic parts of AWS Cognito would behave during the attack, but we assume successful attacks would have been possible. First, a single attack with a 0.16 % chance means that every 625th attack would succeed. Second, the attack could be repeated at least once for the same code after the cool-down, meaning every 312th attack could succeed. Moreover, the entire attack could be repeated and additionally applied to different AWS Cognito user accounts in parallel to increase the likelihood to succeed at all.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="preconditions"&gt;
&lt;h2&gt;Preconditions&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The attacker's requests have to be forwarded to AWS Cognito quickly without disturbing the attack (e.g. no delays or heavy processing)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attacker has to know valid E-mail addresses with an account on the AWS Cognito instance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attacker has to be able to turn the attack into a feasible attack, for example by attacking many accounts at the same time or find a way to trigger the attacker's best-case situation more often and therefore improving the probabilities for the attacker.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attacked accounts cannot have multi-factor authentication enabled, otherwise the attack fails (although the password will be changed, a login is not possible without the second factor).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attacked user will get at least one E-mail and depending on how many times the attack is repeated will get several E-mails that include reset codes. The attacked user has to ignore the reset E-mails sent to his mailbox and not alert the AWS customer or AWS about the suspicious E-mails the user did not trigger himself.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="recommendation"&gt;
&lt;h2&gt;Recommendation&lt;/h2&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;The issue was fixed by AWS on 2021-04-20. According to AWS the issue was not actively exploited.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It is recommended to all AWS Cognito customers to require multi-factor authentication on AWS Cognito accounts to improve security.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AWS customers can implement their own rate-limiting before sending requests to AWS Cognito.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="steps-to-reproduce"&gt;
&lt;h2&gt;Steps to reproduce&lt;/h2&gt;
&lt;p&gt;As the issues is fixed, it is not reproducible any more. But for future reference we include the steps here:&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;Setup AWS Lambda with the Chalice library and the necessary AWS Cognito components. The Python program code used in the setup was similar to what is explained on &lt;a class="reference external" href="https://medium.com/@houzier.saurav/aws-cognito-with-python-6a2867dd02c6"&gt;this blog post about AWS cognito with Python&lt;/a&gt; but instead of the boto3 library the Chalice library was used. The concurrency and speed of the library might be important for the attack, as concurrency issues in the AWS Cognito service will be exploited. The attack was only tested with the Chalice library. Here is some pseudo-code that shows the most important function that was exploited during our research:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-1" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-1" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-1"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;chalicelib.common.app&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-2" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-2" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-2"&gt;&lt;/a&gt;&lt;span class="kn"&gt;from&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;chalicelib.common.auth&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cognito_client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;get_hmac_digest&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-3" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-3" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-4" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-4" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-4"&gt;&lt;/a&gt;&lt;span class="c1"&gt;# route the HTTP request to this function&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-5" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-5" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-5"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;confirm_forgot_password&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-6" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-6" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-6"&gt;&lt;/a&gt;    &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current_request&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-7" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-7" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-7"&gt;&lt;/a&gt;    &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json_body&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-8" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-8" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-8"&gt;&lt;/a&gt;    &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'username'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-9" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-9" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-9"&gt;&lt;/a&gt;    &lt;span class="n"&gt;password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'password'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-10" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-10" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-10"&gt;&lt;/a&gt;    &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'code'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-11" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-11" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-11"&gt;&lt;/a&gt;    &lt;span class="n"&gt;digest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;get_hmac_digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-12" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-12" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-12"&gt;&lt;/a&gt;    &lt;span class="n"&gt;resp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cognito_client&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confirm_forgot_password&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-13" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-13" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-13"&gt;&lt;/a&gt;        &lt;span class="n"&gt;ClientId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;APP_CLIENT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-14" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-14" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-14"&gt;&lt;/a&gt;        &lt;span class="n"&gt;SecretHash&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-15" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-15" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-15"&gt;&lt;/a&gt;        &lt;span class="n"&gt;Username&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-16" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-16" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-16"&gt;&lt;/a&gt;        &lt;span class="n"&gt;Password&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-17" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-17" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-17"&gt;&lt;/a&gt;        &lt;span class="n"&gt;ConfirmationCode&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_563d6d2816a24c25ac142a86e16eebf0-18" name="rest_code_563d6d2816a24c25ac142a86e16eebf0-18" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_563d6d2816a24c25ac142a86e16eebf0-18"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# Now make sure that the response from the AWS Cognito server is sent back in the response to the client of this API&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ol class="arabic simple" start="2"&gt;
&lt;li&gt;&lt;p&gt;Setup an AWS Cognito user account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Request a password reset via E-mail for the AWS Cognito user account.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prepare BurpSuite that allows you to repeat HTTP requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send an HTTP request to the confirm_forgot_password AWS Lambda function with an incorrect code, some new password you would like to set and the correct username of the AWS Cognito user account (for example the E-mail address). Make sure you also see the request in BurpSuite. You get an HTTP response that includes &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send an HTTP request to the confirm_forgot_password AWS Lambda function with a correct code. You should get an HTTP response with no error message in it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send the incorrect code HTTP request from point 5 about 30 times (e.g. Repeater functionality in BurpSuite). At one point you should get the error &lt;cite&gt;cognito_client.exceptions.LimitExceededException&lt;/cite&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wait several hours or use a different AWS Cognito user account, so the limit exceeded does not apply any more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Request a password reset via E-mail for the AWS Cognito user account&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Turbo Intruder in BurpSuite.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Send the HTTP request that is sent to the confirm_forgot_password AWS Lambda function to Turbo Intruder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Choose the &lt;code class="docutils literal"&gt;race.py&lt;/code&gt; preinstalled script of Turbo Intruder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace the code in the HTTP request (for example 123123) with %s to tell Turbo Intruder where to inject&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Replace the &lt;code class="docutils literal"&gt;race.py&lt;/code&gt; script part with the following script:&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-1" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-1" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-1"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;queueRequests&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wordlists&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-2" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-2" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-2"&gt;&lt;/a&gt;    &lt;span class="n"&gt;tries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-3" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-3" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-3"&gt;&lt;/a&gt;    &lt;span class="n"&gt;engine&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RequestEngine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;endpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;endpoint&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-4" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-4" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-4"&gt;&lt;/a&gt;                           &lt;span class="n"&gt;concurrentConnections&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;tries&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-5" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-5" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-5"&gt;&lt;/a&gt;                           &lt;span class="n"&gt;requestsPerConnection&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-6" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-6" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-6"&gt;&lt;/a&gt;                           &lt;span class="n"&gt;pipeline&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-7" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-7" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-7"&gt;&lt;/a&gt;                           &lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-8" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-8" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-8"&gt;&lt;/a&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-9" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-9" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-9"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# the 'gate' argument blocks the final byte of each request until openGate is invoked&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-10" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-10" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-10"&gt;&lt;/a&gt;    &lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100100&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-11" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-11" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-11"&gt;&lt;/a&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;float&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)):&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-12" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-12" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-12"&gt;&lt;/a&gt;        &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;queue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;zfill&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;gate&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'race1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-13" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-13" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-13"&gt;&lt;/a&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-14" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-14" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-14"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# wait until every 'race1' tagged request is ready&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-15" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-15" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-15"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# then send the final byte of each request&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-16" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-16" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-16"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;# (this method is non-blocking, just like queue)&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-17" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-17" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-17"&gt;&lt;/a&gt;    &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;openGate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'race1'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-18" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-18" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-18"&gt;&lt;/a&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-19" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-19" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-19"&gt;&lt;/a&gt;    &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;complete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-20" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-20" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-20"&gt;&lt;/a&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-21" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-21" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-21"&gt;&lt;/a&gt;&lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nf"&gt;handleResponse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;interesting&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-22" name="rest_code_e3b895f544ad48159e0c0b9b2a2c3393-22" href="https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/#rest_code_e3b895f544ad48159e0c0b9b2a2c3393-22"&gt;&lt;/a&gt;    &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;ol class="arabic simple" start="15"&gt;
&lt;li&gt;&lt;p&gt;Click the "Attack" button.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You should see all the HTTP responses after a while. Usually there are at least 20 answers that include the message &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt;. If you are lucky you can see up to 800 &lt;code class="docutils literal"&gt;code mismatch&lt;/code&gt; responses.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The attack can be repeated until one &lt;code class="docutils literal"&gt;limit exceeded&lt;/code&gt; response is triggered. When it is received, repeat the attack after waiting some time (for example an hour). If you get an answer saying the reset code expired, you have to start the entire attack from scratch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you get an HTTP 200 answer, you successfully attacked the user account and reset the password.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/section&gt;
&lt;section id="credits"&gt;
&lt;h2&gt;Credits&lt;/h2&gt;
&lt;p&gt;This issue was found by Tobias Ospelt of Pentagrid AG. Pentagrid AG would also like to thank the AWS Security team for the collaboration on this issue.&lt;/p&gt;
&lt;/section&gt;</description><category>Advisory</category><category>AWS Cognito</category><category>Burp</category><category>Multi-Factor Authentication</category><category>Portswigger</category><category>Turbo Intruder</category><guid>https://www.pentagrid.ch/en/blog/password-reset-code-brute-force-vulnerability-in-AWS-Cognito/</guid><pubDate>Fri, 30 Apr 2021 08:00:00 GMT</pubDate></item><item><title>Burp Suite  - solving E-mail and SMS TAN multi-factor authentication with Hackvertor custom tags</title><link>https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;Why bother investing time to automate work when doing IT security testing? On one hand,
manual testing is a tedious work, where you spend time doing vulnerability tests that
could be done by a machine. On the other hand, letting a machine decide fully on its
own on how to do tests will mostly result in the machine doing nothing useful. This
is especially true for security testing, where manually checking every parameter for
injection attacks is very laborious and automated security scanners go on scanning
for hours while a human would have aborted the scan for various reasons. However,
if we teach automated tools to do things correctly each time, we get the sweet middle
spot of semi-automated security testing, where the tools do the automatic and systematic
security tests and the analyst can focus on the parts of a security test, where the tools
are likely insufficient.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://portswigger.net"&gt;Burp Suite Pro&lt;/a&gt; is one of the main tools to do all kind of
HTTP related security analysis and that supports a semi-automated testing. But now
and then it lacks certain features. Burp
extensions can again add some of them. In this post we would like to show how to use
one of the most powerful extensions, &lt;a class="reference external" href="https://portswigger.net/bappstore/65033cbd2c344fbabe57ac060b5dd100"&gt;Hackvertor&lt;/a&gt;
by &lt;a class="reference external" href="https://twitter.com/garethheyes"&gt;Gareth Hayes&lt;/a&gt; and its relatively new feature
of Python scripting.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;section id="use-hackvertor-to-generate-swiss-social-security-numbers"&gt;
&lt;h2&gt;Use Hackvertor to generate Swiss social security numbers&lt;/h2&gt;
&lt;p&gt;Let's start with a simple example. Imagine you are security testing a website and you
found an HTTP-API that expects the de facto Swiss social security number &lt;a class="brackets" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#ahv" id="footnote-reference-1" role="doc-noteref"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;1&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/a&gt; as a
parameter. Nearly every adult in Switzerland has such a number. After
researching, you find out this unique number always starts with 756, followed by two
times four random characters and ending with another two random characters like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_0a10fc73f5214b6cbc6e043af6c7ce84-1" name="rest_code_0a10fc73f5214b6cbc6e043af6c7ce84-1" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_0a10fc73f5214b6cbc6e043af6c7ce84-1"&gt;&lt;/a&gt;756.9217.0769.85
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you would just like to brute-force random social security numbers in HTTP requests,
you could use Burp's Intruder feature that allows you to try generate different numbers.
But what if you would like to send a new random number each time you send the request in
Burp's Repeater? This is where Hackvertor can be used. In Hackvertor's UI you can search
for tags and you should quickly find the &lt;code class="docutils literal"&gt;random_num&lt;/code&gt; tag. The purpose is simply to
generate a random number as shown in the input and output field in the following picture:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_1_hackvertor_randomnum.png"&gt;
&lt;img alt="Screenshot of the Burp Hackvertor showing the random_num Hackvertor tag in the input window and and a random number in the output widget." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_1_hackvertor_randomnum.thumbnail.png" style="width: 100%;"&gt;
&lt;/a&gt;
&lt;p&gt;So generating a new random social security number is as easy as pasting the following value
into an HTTP request in Burp's Repeater:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_9777fa44ad7c42efb43ddc77ee36fbaf-1" name="rest_code_9777fa44ad7c42efb43ddc77ee36fbaf-1" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_9777fa44ad7c42efb43ddc77ee36fbaf-1"&gt;&lt;/a&gt;756.&amp;lt;@random_num_0(4) /&amp;gt;.&amp;lt;@random_num_1(4) /&amp;gt;.&amp;lt;@random_num_2(2) /&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For example, the following request can be created in the Burp Repeater:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_2_repeater_hackvertor_randomnum.png"&gt;
&lt;img alt="Screenshot of the Burp Repeater showing several random_num Hackvertor tags in a HTTP request to create a Swiss social security number." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_2_repeater_hackvertor_randomnum.thumbnail.png" style="width: 700px;"&gt;
&lt;/a&gt;
&lt;p&gt;However, it will not be sent out from Burp as-is and the tags will be replaced by
Hackvertor. How does an example request look like when it leaves Burp? This can be
observed in the Logger++ extension (another very helpful extension you should use)
as shown in the following picture:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_3_loggerpp_replaced_values.png"&gt;
&lt;img alt="Screenshot of the Burp Logger++ logging widget showing a HTTP request with a Swiss social security number generated by the Hackvertor tags that have been inserted into the Burp Repeater." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_3_loggerpp_replaced_values.thumbnail.png" style="width: 700px;"&gt;
&lt;/a&gt;
&lt;p&gt;This was just an easy example to start. But the truth is, Swiss social security numbers
are not fully random and the last character is an EAN13 checksum over the other characters.
And instead of sending incorrect social security numbers to a website, how about
calculating that checksum in Hackvertor? That's where custom Hackvertor code execution
tags come into play. You can write them in JavaScript or Python, we'll use Python here.
Hackvertor code execution tags allow you to write code that takes an input (passed in
the variable &lt;code class="docutils literal"&gt;input&lt;/code&gt;, that's whatever is put between the tags) and define the &lt;code class="docutils literal"&gt;output&lt;/code&gt;
variable. A no-transformation example looks like this:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_4_hackvertor_no_transformation.png"&gt;
&lt;img alt="Screenshot of the Hackvertor widget showing a dialog for the creation of a custom tag. You select Python as language and can enter program code into a text area. Currently the text area just assigns the input to the output." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_4_hackvertor_no_transformation.thumbnail.png" style="width: 400px;"&gt;
&lt;/a&gt;
&lt;p&gt;So here's a little Python one-liner that calculates the checksum number from the nine
random numbers that were passed as &lt;code class="docutils literal"&gt;input&lt;/code&gt; and assigns the value to the variable &lt;code class="docutils literal"&gt;output&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_e218f2601b5c4190aed9e522c925546b-1" name="rest_code_e218f2601b5c4190aed9e522c925546b-1" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_e218f2601b5c4190aed9e522c925546b-1"&gt;&lt;/a&gt;z=input;y=z.replace('.','');output=z+str(10-(sum([3*int(x) for x in y[1:][::-2]])+sum([int(x) for x in y[::-1][1::2]]))%10)[-1]
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Defining it as the tag name &lt;code class="docutils literal"&gt;ean13&lt;/code&gt; and you should get the following picture when
you open the tag in the edit window:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_5_hackvertor_ean13.png"&gt;
&lt;img alt="Screenshot of the Hackvertor widget for editing a custom tag. It is the same dialog type as above, but now it edits the ``ean13`` tag with the Python code shown above." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_5_hackvertor_ean13.thumbnail.png" style="width: 400px;"&gt;
&lt;/a&gt;
&lt;p&gt;Note that the leading underscore is used for every custom tag, so Hackvertor knows it is
not a built-in Hackvertor tag. So how do we use such a custom tag?&lt;/p&gt;
&lt;p&gt;First of all, there is a security measure so other people that send traffic through your
Burp can't execute the custom tag on your Burp machine. Code execution tags are only
executed when a certain random token is included in the tag. This means you'll need to
create a custom tag in the Hackvertor UI first to get that random token. Creating the
custom tag for our &lt;code class="docutils literal"&gt;ean13&lt;/code&gt; tag in the Hackvertor UI will result in something like this:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_6_hackvertor_random_token.png"&gt;
&lt;img alt="Screenshot of the Hackvertor Burp plugin showing an EAN13 tag and with an error message in the output window. The error message describes that code execution is disabled and how to enable it." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_6_hackvertor_random_token.thumbnail.png" style="width: 100%;"&gt;
&lt;/a&gt;
&lt;p&gt;So keep in mind that for your Burp installation, that random number in double qutoes will
be different. As the output windows in the above picture tells you, code execution tags
are still disabled by default for security reasons. This is a second setting you'll need
to change. You can enable them in the top main menu of Burp under the Hackvertor item.
What you need to do then is to allow code execution tags in Hackvertor:&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202103_burp_hackvertor_7_hackvertor_in_toplevel_menu.png"&gt;
&lt;img alt="Screenshot of the Hackvertor menu showing how to enable code execution tags." class="align-center" src="https://www.pentagrid.ch/images/202103_burp_hackvertor_7_hackvertor_in_toplevel_menu.thumbnail.png" style="width: 300px;"&gt;
&lt;/a&gt;
&lt;p&gt;After that you will probably not see much in the output window of Hackvertor. That's because
we have to give our custom tag the correct input. For example:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_7aae1655da1440078939628d0894d749-1" name="rest_code_7aae1655da1440078939628d0894d749-1" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_7aae1655da1440078939628d0894d749-1"&gt;&lt;/a&gt;&amp;lt;@_ean13_3("83a52168fad35b2d85f6972b0eb1db91")&amp;gt;756.9217.0769.8&amp;lt;/@_ean13_3&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now you should see the correct social security number being generated, namely 756.9217.0769.85.
And here comes the real power of Hackvertor. Now you can combine the generation of random
numbers feature of Hackvertor and our custom tag in a nested form:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_145981cd81bf4c8088ce940c4aed96c8-1" name="rest_code_145981cd81bf4c8088ce940c4aed96c8-1" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_145981cd81bf4c8088ce940c4aed96c8-1"&gt;&lt;/a&gt;&amp;lt;@_ean13_3("83a52168fad35b2d85f6972b0eb1db91")&amp;gt;756.&amp;lt;@random_num_0(4) /&amp;gt;.&amp;lt;@random_num_1(4) /&amp;gt;.&amp;lt;@random_num_2(1) /&amp;gt;&amp;lt;/@_ean13_3&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Whenever you send this value in the Burp Repeater, it will be replaced with a random social
security number with a correct checksum. Of course you can now not only generate random social
security numbers, but you can also generate the random numbers with Burp Intruder and brute-force
with valid EAN13 checksums.&lt;/p&gt;
&lt;p&gt;In some cases it might be even possible to simply paste the above tags into the browser you use with
Burp and the web server will receive a random social security number. However, this only works if the
web application you are testing does not encode the values we put into HTML fields and Hackvertor is
still able to see the tag exactly as written above. This is rather a rare case, but it might work.&lt;/p&gt;
&lt;p&gt;Update 2024-12-06: The &lt;a class="reference external" href="https://www.pentagrid.ch/en/blog/hackervertor-ean13-and-totp-tags-for-web-application-penetration-testing-with-burp/"&gt;EAN-13 tag is available via the Hackvertor tag store&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="use-hackvertor-to-fetch-second-factor-authentication-token"&gt;
&lt;h2&gt;Use Hackvertor to fetch second-factor authentication token&lt;/h2&gt;
&lt;p&gt;Let's do a more advanced custom tag example. Could you use the scripting capabilities of Hackvertor
to automatically solve TAN second factor verification in multi-factor authentication web forms? At
Pentagrid we have an &lt;a class="reference external" href="https://www.pentagrid.ch/en/blog/open-source-sms-gateway-for-pentest-projects/"&gt;SMS to E-mail gateway for pentesting purposes&lt;/a&gt;, meaning if second factor TANs are
sent out via SMS or E-mail, they will always land in one of our testing E-mail inboxes. Can we
retrieve the second factor TAN tokens from the E-mail inbox with a Hackvertor tag? Yes we can, with
the very useful Python &lt;code class="docutils literal"&gt;imaplib&lt;/code&gt; and an E-mail server that supports IMAP. Of course the entire
parsing logic for the incoming TANs is highly dependent on the web application and how the SMS or
E-mails look like. You will need to change the parsing code according to your needs. So here's a
quick'n'dirty example that worked for us for a certain web application. We created the new Hackvertor
tag like this:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code python"&gt;&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-1" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-1" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-1"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;getpass&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;imaplib&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-2" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-2" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-2"&gt;&lt;/a&gt;&lt;span class="kn"&gt;import&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nn"&gt;time&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-3" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-3" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-3"&gt;&lt;/a&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-4" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-4" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-4"&gt;&lt;/a&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-5" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-5" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-5"&gt;&lt;/a&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-6" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-6" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-6"&gt;&lt;/a&gt;&lt;span class="k"&gt;class&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nc"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-7" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-7" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-7"&gt;&lt;/a&gt;    &lt;span class="k"&gt;def&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="fm"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-8" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-8" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-8"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;decode&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-9" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-9" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-9"&gt;&lt;/a&gt;        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\r\n\r\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\r\n\r\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-10" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-10" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-10"&gt;&lt;/a&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-11" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-11" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-11"&gt;&lt;/a&gt;&lt;span class="n"&gt;M&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;imaplib&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IMAP4_SSL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'use-your-own-mail-host'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# warning: no certificate verification&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-12" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-12" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-12"&gt;&lt;/a&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;login&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pentagrid@example.org"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"email-password"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-13" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-13" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-13"&gt;&lt;/a&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-14" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-14" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-14"&gt;&lt;/a&gt;&lt;span class="n"&gt;typ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'ALL'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-15" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-15" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-15"&gt;&lt;/a&gt;&lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"NO TOKEN WAS FOUND"&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-16" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-16" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-16"&gt;&lt;/a&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;()[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-17" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-17" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-17"&gt;&lt;/a&gt;    &lt;span class="n"&gt;typ&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'(RFC822)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-18" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-18" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-18"&gt;&lt;/a&gt;    &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-19" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-19" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-19"&gt;&lt;/a&gt;    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-20" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-20" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-20"&gt;&lt;/a&gt;        &lt;span class="c1"&gt;#print(line)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-21" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-21" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-21"&gt;&lt;/a&gt;        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Your TAN is: "&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-22" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-22" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-22"&gt;&lt;/a&gt;            &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Your TAN is: "&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-23" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-23" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-23"&gt;&lt;/a&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-24" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-24" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-24"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-25" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-25" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-25"&gt;&lt;/a&gt;        &lt;span class="k"&gt;break&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-26" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-26" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-26"&gt;&lt;/a&gt;    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-27" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-27" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-27"&gt;&lt;/a&gt;        &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"No token found"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-28" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-28" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-28"&gt;&lt;/a&gt;    &lt;span class="c1"&gt;#print('Message %s\n%s\n' % (num, data[0][1]))&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-29" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-29" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-29"&gt;&lt;/a&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Final token:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-30" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-30" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-30"&gt;&lt;/a&gt;&lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-31" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-31" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-31"&gt;&lt;/a&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;a id="rest_code_aae1983aaba646c78e710a6dd7fa15a4-32" name="rest_code_aae1983aaba646c78e710a6dd7fa15a4-32" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#rest_code_aae1983aaba646c78e710a6dd7fa15a4-32"&gt;&lt;/a&gt;&lt;span class="n"&gt;M&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;logout&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Python code will login to the IMAP mailbox, retrieve E-mails starting with the newest,
quick'n'dirty parse the TAN from the E-mail by interating through each line of the E-mail
and assign the the first token found to the &lt;code class="docutils literal"&gt;output&lt;/code&gt; variable that Hackvertor expects.
You might need to play with the sleep delay we introduced at the beginning of the script
to make sure the E-mail reaches the mailbox before you try to retrieve it. Otherwise you
could change the script to only consider the very newest E-mail but you would need to take
care to delete old E-mails. And of course you need to change your E-mail server, username
and password. Please be aware that this is as well not thread-safe, you would need a
seperate E-mail mailbox for each thread to make it concurrent.&lt;/p&gt;
&lt;p&gt;Configuring a search and replace rule in the Burp Proxy to replace any second factor you enter
with the Hackvertor tab is left as an exercise to the reader. We were able to test websites
without ever entering the second factor manually again, as the entered token was replaced
with a Hackvertor tag and Hackvertor fetched the token from the mailbox.&lt;/p&gt;
&lt;p&gt;Hackvertor is therefore the perfect solution if you would like to script things that are
sent in HTTP requests. With the new scripting capabilities, it is not necessary to write
extensions when you want to change things sent out. Or do you? Unfortunately, there are
certain limitations with this approach and in Burp. The search and replace rule for the
Proxy of course only works for the Burp Proxy. But what if we want to make the Burp Crawler
be able to login with second-factor TANs? We can't use session handling rules (another
advanced topic of Burp), as they don't apply for Burp Crawler. But we were able to write
an extension that handles that part, but that's for another blog post (it is really cool
to see the headed browser of Burp login correctly). And what if you would also like to
modify HTTP responses? Or what if you would like to even enhance Burp with a Transfer-Encoding
feature it does not yet support? Do you want to know how you could set up an SMS to E-mail
gateway? Stay tuned for our next blog posts, subscribe to our &lt;a class="reference external" href="https://www.pentagrid.ch/en/rss.xml"&gt;RSS feed&lt;/a&gt;
or follow us on &lt;a class="reference external" href="https://twitter.com/pentagridsec"&gt;Twitter&lt;/a&gt; or
&lt;a class="reference external" href="https://www.linkedin.com/company/67698060/"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Update 2025-06-04: An update of Hackvertor in 2025 changed the style of closing elements from &lt;cite&gt;&amp;lt;@/name&amp;gt;&lt;/cite&gt; to &lt;cite&gt;&amp;lt;/@name&amp;gt;&lt;/cite&gt;. Therefore, we updated the post, but not the screenshots.&lt;/p&gt;
&lt;aside class="footnote-list brackets"&gt;
&lt;aside class="footnote brackets" id="ahv" role="doc-footnote"&gt;
&lt;span class="label"&gt;&lt;span class="fn-bracket"&gt;[&lt;/span&gt;&lt;a role="doc-backlink" href="https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/#footnote-reference-1"&gt;1&lt;/a&gt;&lt;span class="fn-bracket"&gt;]&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;The de facto Swiss social security number, respectively German: AHV Alters- und Hinterbliebenenversicherung, Rumantsch: AVS - Sgüranza da vegls e relatschats, Italian: AVS - Assicurazione per la vecchiaia e per i superstiti, French: AVS - L'assurance-vieillesse et survivants&lt;/p&gt;
&lt;/aside&gt;
&lt;/aside&gt;
&lt;/section&gt;</description><category>Burp</category><category>Hackvertor</category><category>Multi-Factor Authentication</category><category>OWASP</category><category>Pentesting</category><category>Portswigger</category><category>Python</category><guid>https://www.pentagrid.ch/en/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/</guid><pubDate>Wed, 17 Mar 2021 08:00:00 GMT</pubDate></item><item><title>Block browser requests to Google during security analysis in Burp</title><link>https://www.pentagrid.ch/en/blog/block_browser_requests_to_google_during_security_analysis_in_burp/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;How to stop Portswigger's Burp Proxy's built-in Chromium browser to leak information to Google's Safe Browsing during a web application penetration test?&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;p&gt;When doing web application security research and penetration tests for customers, we sometimes get insights into tools we use that seem weird and undesired. A while ago we were testing a financial website with confidential data with the Mozilla Firefox browser and Firefox was sending the following requests whenever we downloaded a PDF from the website:&lt;/p&gt;
&lt;pre class="literal-block"&gt;POST /safebrowsing/clientreport/download?key=%GOOGLE_SAFEBROWSING_API_KEY% HTTP/1.1
Host: sb-ssl.google.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/octet-stream
Content-Length: 189
Connection: close

blob:https://www.example.org/6f75423b-3828-5e4b-8241-3e633c684041___________
Dblob:https://www.example.org/6f75423b-3828-5e4b-8241-3e633c684041___
txt_download_name_file_overview.pdf
[...]&lt;/pre&gt;
&lt;p&gt;As you can see, Firefox leaks the PDF file name we were downloading, the hostname of the website we were testing and some more binary data that could include a file hash. On one side we were happy that we found this privacy issue and could report it to our customer, because this browser behaviour affects normal users. On the other side we do not want our testing tools to behave like this. Safebrowsing can be disabled via the pentest browser's settings menu or by setting these values in &lt;code class="docutils literal"&gt;about:config&lt;/code&gt; and it must be done for every web application test browser in use:&lt;/p&gt;
&lt;pre class="literal-block"&gt;browser.safebrowsing.malware.enabled = false
browser.safebrowsing.phishing.enabled = false&lt;/pre&gt;
&lt;p&gt;In the meantime the &lt;a class="reference external" href="https://portswigger.net/burp"&gt;Portswigger Burp proxy&lt;/a&gt; we use regularly and write extensions for was updated to include &lt;a class="reference external" href="https://portswigger.net/burp/releases/professional-community-2020-7"&gt;a new feature: A builtin Chromium browser&lt;/a&gt;. We really appreciate the added usability and were happy to use this feature in a security analysis in a corporate Windows AD environment, where changing proxy settings was not allowed for the preinstalled browser. Fortunately because we asked our customer to install Burp with administrative privileges, the built-in Chromium browser of Burp could be used. However, we noticed that the preconfigured Chromium browser was again very verbose and contacted Google servers, especially during startup. As we would like to keep all information about our security analysis to our customers and ourselves, we avoid any third-party services wherever feasible. That's why we operate and use our own Burp Collaborator server, for example.&lt;/p&gt;
&lt;p&gt;It is possible to disable the Safe Browsing feature in the browser used to perform web application pentests. However, if it is necessary to switch the browser, these settings must be changed there as well and the approach does not really work for the the built-in Chromium browser, because its settings are reset on every start. The easiest solution is to control traffic in the Burp Proxy: We can abuse the Upstream-Proxy setting found in "User options - Connections" in Burp for this purpose. While the following approach will block the requests from reaching the Google servers, they will still show up in the history tab of Burp.&lt;/p&gt;
&lt;ol class="arabic simple"&gt;
&lt;li&gt;&lt;p&gt;Download &lt;a class="reference external" href="https://www.pentagrid.ch/files/code/google-blocking.json"&gt;google-blocking.json&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In Burp, go to "User options - Connection".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the left of the "Upstream Proxy Servers" headline, click the settings and chose "Load options".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Chose the file you just downloaded and press "OK". Then, the upstream proxy settings look like in the screenshot below.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;img alt="/images/202011_Burp_Settings_Google_Blocking.png" src="https://www.pentagrid.ch/images/202011_Burp_Settings_Google_Blocking.png"&gt;
&lt;p&gt;This configuration will redirect requests to most Google domains to TCP port 1337 on localhost, which is (hopefully) a dead end. It is possible to use the file as a Burp startup configuration, or even better, merge it with your existing startup configuration by editing the Burp settings JSON file manually. Then, your are able to use these Burp settings in new projects as well.&lt;/p&gt;
&lt;p&gt;A drawback of the approach is that your test browser cannot be used for Google searches afterwards and it may break functionality if the tested sites requires resources from Google of course. However, it is recommended to use separate browsers for regular work and for web application testing anyway, because they are configured for different purposes.&lt;/p&gt;</description><category>Burp</category><category>Chromium</category><category>Firefox</category><category>Google</category><category>Information Disclosure</category><category>OWASP</category><category>Pentesting</category><category>Portswigger</category><guid>https://www.pentagrid.ch/en/blog/block_browser_requests_to_google_during_security_analysis_in_burp/</guid><pubDate>Wed, 04 Nov 2020 09:00:00 GMT</pubDate></item></channel></rss>