<?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 (Einträge über Multi-Factor Authentication)</title><link>https://www.pentagrid.ch/</link><description></description><atom:link href="https://www.pentagrid.ch/de/categories/multi-factor-authentication.xml" rel="self" type="application/rss+xml"></atom:link><language>de</language><copyright>Contents © 2026 Pentagrid AG </copyright><lastBuildDate>Wed, 17 Jun 2026 19:14:50 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>EAN-13- und TOTP-Hackvertor-Tags für Penetrationstests von Webanwendungen mit Burp</title><link>https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;Hackvertor ist ein &lt;a class="reference external" href="https://hackvertor.co.uk/"&gt;Standalone-Werkzeug&lt;/a&gt; und eine &lt;a class="reference external" href="https://portswigger.net/bappstore/65033cbd2c344fbabe57ac060b5dd100"&gt;Erweiterung für das Penetrationstest-Tool Burp Suite&lt;/a&gt;. &lt;a class="reference external" href="https://garethheyes.co.uk/"&gt;Gareth Heyes&lt;/a&gt; vom Portswigger Research Team hat Hackvertor entwickelt. Die Erweiterung führt dynamische Datenkonvertierungen durch. Das Tool kann beispielsweise dazu verwendet werden, Datenfelder als Base64 zu kodieren, bevor Burp eine HTTP-POST-Anfrage an einen Server sendet. Dies geschieht automatisch und es ist nicht notwendig, Daten manuell zu konvertieren oder zwischen verschiedenen Fenstern zu kopieren.&lt;/p&gt;
&lt;p&gt;In unserem Blog schrieben wir über &lt;a class="reference external" href="https://www.pentagrid.ch/de/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/"&gt;das Generieren schweizer Sozialversicherungsnummern bei einem Pentest und das Programmieren benutzerdefinierter Hackvertor-Tags&lt;/a&gt;. Es gibt verschiedene Arten von Tags. Viele sind bereits in Hackvertor integriert und Benutzer können darüber hinaus ihre eigenen Tags programmieren. Hackvertor verfügt mittlerweile über einen &lt;a class="reference external" href="https://github.com/hackvertor/hackvertor/tree/master/tag-store"&gt;öffentlichen Tag Store&lt;/a&gt;, in dem Benutzer Tags einreichen können. Pentagrid hat nun zwei Tags entwickelt und im Hackvertor-Tag-Store veröffentlich. Ein Hackvertor-Tag dient der &lt;a class="reference external" href="https://en.wikipedia.org/wiki/International_Article_Number#Check_digit"&gt;Prüfziffernberechnung von EAN-13-Codes&lt;/a&gt; und ein anderes für die Berechnung von &lt;a class="reference external" href="https://de.wikipedia.org/wiki/Time-based_one-time_password"&gt;Time-based one-time Passwords (TOTP)&lt;/a&gt;.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;p&gt;Wie bereits in unserem Blog-Beitrag &lt;a class="reference external" href="https://www.pentagrid.ch/de/blog/teaching_burp_a_new_http_transport_encoding/"&gt;„Burp eine neue HTTP-Transportkodierung beibringen“&lt;/a&gt; erläutert, ist das Anpassen von Tests in Burp ein wichtiges Instrument, um Tests zu automatisieren und eine hohe Test-Coverage bei einer Sicherheitsuntersuchung zu erzielen.&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 ist die European Article Number, ein Standard zur Kodierung von Artikelnummern. Und obwohl sie eher international als europäisch geworden ist und jetzt Global Trade Item Number heißt, wird dieses Artikelnummernformat oft noch als EAN-13 bezeichnet. Schweizer AHV-Nummern verwenden die Prüfsummenberechnung von EAN-13 und speichern die Prüfsumme als 13. Zeichen.&lt;/p&gt;
&lt;p&gt;Den benutzerdefinierte Tag-Code aus unserem &lt;a class="reference external" href="https://www.pentagrid.ch/de/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/"&gt;Blog-Artikel&lt;/a&gt; haben wir als &lt;a class="reference external" href="https://github.com/hackvertor/hackvertor/pull/112/"&gt;Hackvertor-Tag im Tag Store&lt;/a&gt; veröffentlicht. Das EAN-13-Tag wird wie in den folgenden beiden Beispielen verwendet:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-1" name="rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-1" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-1"&gt;&lt;/a&gt;# the "append" parameter can be set to 0 or 1.
&lt;a id="rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-2" name="rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-2" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-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_6a4d3b13dc9f4983ba2ddb82dd16fd06-3" name="rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-3" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_6a4d3b13dc9f4983ba2ddb82dd16fd06-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;An der Stelle der Auslassung [...] muss ein sogenannter Ausführungsschlüssel eingefügt werden. Die Hackvertor-Extension für Burp fügt den Code-Ausführungsschlüssel automatisch hinzu, wenn die Tags im Hackvertor-Tab in Burp vorbereitet und verwendet werden. Der Ausführungsschlüssel ist eine zufällige Zeichenfolge von 40 Hex-Ziffern, der verhindert, dass mit Burp verarbeitete Webseiten schädliche Aktionen in Burp auslösen. Burp würfelt bei jedem Start einen neuen Ausführungsschlüssel. Nur Codeausführungs-Tags (mit benutzerdefiniertem Code, wie z. B. die im Tag Store) benötigen einen Codeausführungsschlüssel.&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 implementierte ebenfalls ein Hackvertor-Tag für TOTP. Dieser zeitbasierte Token wird für Zweifaktor-Authentifizierung verwendet. Wenn während des Penetrationstests ein derartiger Token notwendig ist, kann das Hackvertor-Tag verwendet werden. Der Code wurde kürzlich &lt;a class="reference external" href="https://github.com/hackvertor/hackvertor/pull/121"&gt;dem Tag Store hinzugefügt&lt;/a&gt;. Um das TOTP-Tag zu verwenden, extrahiert man den Initialisierungswert aus dem QR-Code, der ausgehändigt wurde, um ihn mit einer Authentifikator-App zu scannen. Das Kommandozeilenwerkzeug &lt;cite&gt;zbarimg&lt;/cite&gt; kann den Inhalt des QR-Codes aus einer Bilddatei auslesen:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_16913b37c5da453781fa3ccba3268ad2-1" name="rest_code_16913b37c5da453781fa3ccba3268ad2-1" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_16913b37c5da453781fa3ccba3268ad2-1"&gt;&lt;/a&gt;% zbarimg ~/Authenticator-QR-Code.png
&lt;a id="rest_code_16913b37c5da453781fa3ccba3268ad2-2" name="rest_code_16913b37c5da453781fa3ccba3268ad2-2" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_16913b37c5da453781fa3ccba3268ad2-2"&gt;&lt;/a&gt;QR-Code:otpauth://totp/SomeOrg:something?secret=MYSEEDMYSEED2342&amp;amp;issuer=SomeOrg
&lt;a id="rest_code_16913b37c5da453781fa3ccba3268ad2-3" name="rest_code_16913b37c5da453781fa3ccba3268ad2-3" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_16913b37c5da453781fa3ccba3268ad2-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;Das Hackervertor-Tag kann dann analog zu diesem Beispiel verwendet werden:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code text"&gt;&lt;a id="rest_code_b2e03bd390c5404480464a28d0a34414-1" name="rest_code_b2e03bd390c5404480464a28d0a34414-1" href="https://www.pentagrid.ch/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/#rest_code_b2e03bd390c5404480464a28d0a34414-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;Es gibt mehrere Parameter für TOTP. Das Tag unterstützt nur die in der Praxis häufig verwendeten Parameter SHA1, 30 Sekunden und 6 Ziffern. Falls in der freien Wildbahn andere Konfiguration genutzt werden, sollte es recht einfach sein, das benutzerdefinierte Tag anzupassen.&lt;/p&gt;
&lt;p&gt;Um auf den Tag Store zuzugreifen, gehen Sie einfach zum Menüeintrag „View tag store“ im Hackvertor-Menü in Burp und installieren die gewünschten Erweiterungen. Stellen Sie dann auch sicher, dass Sie die Codeausführungs-Tags über den Menüeintrag „Allow code execution tags“ im Hackvertor-Menü in Burp zulassen.&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 und installierte benutzerdefinierte Tags im Hintergrund." 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: Eine Aktualisierung von Hackvertor in 2025 änderte den Stil für schliessende Elemente von &lt;cite&gt;&amp;lt;@/name&amp;gt;&lt;/cite&gt; nach &lt;cite&gt;&amp;lt;/@name&amp;gt;&lt;/cite&gt;. Daher haben wir den Beitrag aktualisiert.&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/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-burp/</guid><pubDate>Fri, 06 Dec 2024 08:42:00 GMT</pubDate></item><item><title>Ein Open-Source-SMS-Gateway für Pentest-Projekte</title><link>https://www.pentagrid.ch/de/blog/open-source-sms-gateway-for-pentest-projects/</link><dc:creator>Pentagrid AG</dc:creator><description>&lt;p&gt;Zugänge für mobile Anwendungen sind oft an Telefonnummern gebunden. Die Arbeit mit mehreren Personen an einem Projekt kann es irgendwann erfordern, Mobiltelefonnummern für den SMS-Empfang zu teilen. Beim Testen mobiler Anwendungen, die durch eine SMS-basierte Second-Factor-Authentisierung (2FA) geschützt sind, ist die gemeinsame Nutzung von Telefonnummern durch das Testteam manchmal notwendig und sicherheitstechnisch akzeptabel, wenn es sich nur um ein Testsystem handelt. Bei Pentagrid betreiben wir daher ein kleines SMS-Gateway, das wir hiermit als Open Source veröffentlichen.&lt;/p&gt;
&lt;!-- TEASER_END --&gt;
&lt;section id="motivation"&gt;
&lt;h2&gt;Motivation&lt;/h2&gt;
&lt;p&gt;Mit SMS als zweitem Authentisierungsfaktor, sendet ein Zielsystem eine SMS an ein Mobiltelefon, und der Prüfer gibt das Token dann manuell in den Webbrowser ein. Während dies für die normale Arbeit noch einigermaßen praktikabel ist, ist es bei einem Penetrationstest ziemlich ineffizient. Insbesondere, wenn die Serverseite die Sitzung hin und wieder invalidiert, weil die getestete Anwendung die Eingabe nicht mag und lediglich die Ablehnung der HTTP-Anfrage von den Softwareentwicklern als nicht schmerzhaft genug erachtet wurde. Wenn ein System nicht dafür ausgelegt ist, mit halbautomatischen Tools wie dem Burp Proxy getestet zu werden, kann 2FA oft nicht einfach für bestimmte Testkonten deaktiviert werden. Um ein solches System dennoch testen zu können, ist es sinnvoll, den zweiten Faktor in den Burp Proxy einzubinden.&lt;/p&gt;
&lt;p&gt;Es gibt viele kommerzielle SMS-Gateways, die eine API für den Versand und Empfang von SMS anbieten. Da der Token jedoch ein Authentisierungsfaktor ist, wenn auch nur ein Teil des gesamten Prozesses, ist die Weitergabe dieser sensiblen Informationen an Dritte keine Option, auch nicht für Testsysteme. Aus diesem Grund haben wir ein SMS-Gateway implementiert, um Drittanbieter-Infrastruktur zu vermeiden.&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202212_photo_modem_pool.jpg"&gt;
&lt;img alt="Modem pool mit mehreren SIM-Karten" class="align-center" src="https://www.pentagrid.ch/images/202212_photo_modem_pool.thumbnail.jpg"&gt;
&lt;/a&gt;
&lt;/section&gt;
&lt;section id="ansatz"&gt;
&lt;h2&gt;Ansatz&lt;/h2&gt;
&lt;p&gt;Es gibt ebenfalls einige Mobil-Applikationen für das Weiterleiten von SMS, die auf einem Mobiltelefon eingehende Kurznachrichtenan eine Ziel-E-Mail-Adresse weiterleiten. Das funktioniert, aber die Methode hat Nachteile. Sie erhöht Abhängigkeiten: Man muss zusätzlich dem Anwendungsentwickler, dem E-Mail-Anbieter (wenn man sich dabei auf einen Drittanbieter verlässt) und letztlich auch anderen Anwendungen auf dem Mobiltelefon vertrauen - zumindest zu einem gewissen Grad. Der Ansatz ist zudem nicht gut skalierbar. In der Regel kann ein Telefon bis zu zwei physische SIM-Karten aufnehmen. Für drei oder mehr SIM-Karten wären zusätzliche Telefone erforderlich. Außerdem wird Service-Monitoring kaum unterstützt. Um zu prüfen, ob die Weiterleitungsanwendung noch funktioniert, ist die fast einzige Möglichkeit eine Ende-zu-Ende-Prüfung, die das Senden einer SMS und den Empfang einer Mail umfasst.&lt;/p&gt;
&lt;p&gt;Um diese Nachteile zu vermeiden, haben wir ein SMS-Gateway implementiert, dessen Hauptzweck der Empfang von SMS ist. Es ist außerdem möglich, SMS zu senden, was wir für den Versand von Alarmmeldungen bei der Serverüberwachung nutzen, aber das war nicht der Fokus.&lt;/p&gt;
&lt;p&gt;In dieser ersten Version bietet der SMS-Gateway die folgenden Funktionen:&lt;/p&gt;
&lt;ul class="simple"&gt;
&lt;li&gt;&lt;p&gt;Verwalten eines Modempools&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Empfangen und Senden von SMS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Weiterleiten empfangener SMS an eine Mailadresse&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Senden und Abrufen von SMS über eine XMLRPC-Schnittstelle&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unterstützung für Unstructured Supplementary Service Data, also USSD-Codes für das Aufladen von Prepaid-SIM-Karten&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unterstützung von TLS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integration von Icinga2/Nagios für die Prüfung des inneren Funktionszustandes&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integration von Munin für ein paar Statistiken&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/section&gt;
&lt;section id="implementation-und-betriebsmodus"&gt;
&lt;h2&gt;Implementation und Betriebsmodus&lt;/h2&gt;
&lt;p&gt;Der SMS-Gateway ist als Python-Programm für Linux implementiert. Das Modul &lt;a class="reference external" href="https://github.com/babca/python-gsmmodem/tree/master/gsmmodem"&gt;python-gsmmodem&lt;/a&gt; bildet die Schnittstelle zum Modem und verarbeitet Modembefehle. Dazu läuft jedes Modem in seinem eigenen Thread. Mehrere Modems werden zu einem Modem-Pool zusammengefasst, der es uns ermöglicht, mehrere SIM-Karten parallel zu betreiben. Der Modem-Pool überwacht den Gesundheitszustand jedes Modems, einschließlich der seriellen Verbindung zum Modem, der Signalstärke und des Kontostandes bei Prepaid-SIM-Karten. Außerdem versucht der Modem-Pool, die Modems im Falle von Problemen neu zu initialisieren.&lt;/p&gt;
&lt;a class="reference external image-reference" href="https://www.pentagrid.ch/images/202212_SMS_Gateway_Overview.png"&gt;
&lt;img alt="Übersicht über die Untermodule des SMS-Gateways" class="align-center" src="https://www.pentagrid.ch/images/202212_SMS_Gateway_Overview.thumbnail.png"&gt;
&lt;/a&gt;
&lt;p&gt;Wenn ein Modem eine SMS empfängt, wird sie in eine interne Queue eingetragen. Ein Client holt die SMS über die API eines integrierten XMLRPC-Servers ab, der auf der Netzwerk-Engine Twisted basiert. Alternativ ist das SMS-Gateway in der Lage, eingehende SMS über SMTPS an eine Ziel-Mailbox zuzustellen. Die SMS-Weiterleitung über SMTPS wird auch als Health-Check überwacht. Wenn es ein Problem mit der SMTPS-Verbindung gibt, schlägt der Health-Check folglich fehl.&lt;/p&gt;
&lt;p&gt;Mit einem XMLRPC-Client kann man mit dem XMLRPC-Server interagieren. Ein XMLRPC-Client kann empfangene SMS abrufen. Die API dafür ist einfach gehalten. Es gibt keine Benutzerverwaltung. Stattdessen autorisiert der XMLRPC-Server Vorgänge mittels API-Token, welche der Client beim Aufruf von Remote-API-Funktionen als Parameter übergibt. Der Server speichert berechtigte API-Token als Hash in einer Konfigurationsdatei und prüft die Token bei Anfragen auf Gültigkeit. Dabei unterscheidet der XMLRPC-Server API-Token für den allgemeinen Abruf von SMS, für den Abruf von SMS für einzelne Modems, für den Versand von USSD-Codes, für den Versand von SMS, für die Abfrage des Zustellungsstatus von SMS und für Überwachungs- und Statistikzwecke.&lt;/p&gt;
&lt;p&gt;Das SMS-Gateway wird mit einem Munin- und einem Icinga-/Nagios-Plugin ausgeliefert, um die Betriebsüberwachung zu unterstützen. Die Monitoring-Plugins sind als XMLRPC-Clients implementiert, die Zustandsinformationen bzw. Statistiken vom XMLRPC-Server abrufen.&lt;/p&gt;
&lt;p&gt;Das SMS-Gateway unterstützt ebenfalls den Versand von SMS. Das birgt allerdings das Risiko, dass SMS an Premiumdienste versendet werden und erhebliche Kosten verursachen. Ebenfalls lassem sich eventuell Buchungsoptionen ändern. Daher kann das Versenden von SMS über eine Präfix-Liste für erlaubte Ziele eingeschränkt werden.&lt;/p&gt;
&lt;/section&gt;
&lt;section id="betrieb-einer-eigenen-installation"&gt;
&lt;h2&gt;Betrieb einer eigenen Installation&lt;/h2&gt;
&lt;p&gt;Wir haben den Quellcode des SMS-Gateways auf &lt;a class="reference external" href="https://github.com/pentagridsec/smsgate"&gt;Github&lt;/a&gt; veröffentlicht, zusammen mit weiterer Dokumentation, wie man ein solches Gateway einrichtet. Es sollte gängige 2G-/3G-/4G-/5G-Modems unterstützen. Im einfachsten Fall könnte man Plastik-USB-Modem-Sticks verwenden, die als "Surfstick" oder ähnlich gehandelt werden.&lt;/p&gt;
&lt;p&gt;Wie man den SMS-Gateway automatisiert nutzen kann, um während des Testens mit der Portswigger Burp Suite keine 2FA-Tokens eingeben zu müssen, erfährt man in unserem englischen Blog-Post &lt;a class="reference external" href="https://www.pentagrid.ch/de/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/"&gt;Burp Suite - solving E-mail and SMS TAN multi-factor authentication with Hackvertor custom tags&lt;/a&gt;.&lt;/p&gt;
&lt;/section&gt;</description><category>API</category><category>Multi-Factor Authentication</category><category>Pentesting</category><category>Python</category><category>SMS</category><category>Tools</category><guid>https://www.pentagrid.ch/de/blog/open-source-sms-gateway-for-pentest-projects/</guid><pubDate>Tue, 06 Dec 2022 08:23:00 GMT</pubDate></item><item><title>Password reset code brute-force vulnerability in AWS Cognito</title><link>https://www.pentagrid.ch/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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><guid>https://www.pentagrid.ch/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/blog/hackervertor-ean13-und-totp-tags-fuer-penetrationstests-von-webanwendungen-mit-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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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/de/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><guid>https://www.pentagrid.ch/de/blog/burp-suite-hackvertor-custom-tags-email-sms-tan-multi-factor-authentication/</guid><pubDate>Wed, 17 Mar 2021 08:00:00 GMT</pubDate></item></channel></rss>