gen_mbox_testdata.sh (5337B)
1 #!/bin/sh 2 # This file is part of libextractor. 3 # Copyright (C) 2026 Vidyut Samanta and Christian Grothoff 4 # 5 # Regenerate src/plugins/testdata/mbox_test.mbox. 6 # 7 # Requires: nothing beyond a POSIX shell -- the mailbox is plain ASCII 8 # (the non-ASCII header values are RFC 2047 encoded words) and is written 9 # out literally, so the result is byte-for-byte reproducible. 10 # 11 # Three messages in Unix mbox (mboxo) form. The first one carries 12 # everything the plugin is expected to recover: a three-hop Received 13 # chain with two IPv4 literals and one IPv6 literal, an 14 # X-Originating-IP, a DKIM-Signature with a known signing domain, an 15 # Authentication-Results, an X-Mailer, RFC 2047 encoded From and Subject 16 # (base64/UTF-8 and quoted-printable/ISO-8859-1 in the same field), a 17 # References/In-Reply-To pair, and a multipart body with two attachments 18 # -- one with a plain quoted filename and one using the RFC 2231 19 # continuation form. 20 # 21 # The third message's body contains a `>From ' line: that is the mboxo 22 # escaping of a body line that would otherwise look like a message 23 # separator, and it is there so that the message count stays at three. 24 # 25 # All names, addresses and hosts are from the RFC 2606 / RFC 5737 / 26 # RFC 3849 reserved ranges. The file is invented and is dedicated to the 27 # public domain (CC0). 28 set -e 29 30 srcdir=$(dirname "$0")/.. 31 out="$srcdir/src/plugins/testdata/mbox_test.mbox" 32 33 # The two encoded words in the headers below decode to: 34 # =?UTF-8?B?QW5uYSBNw7xsbGVy?= -> "Anna Muller" with u-umlaut 35 # =?UTF-8?B?w5xiZXJ3ZWlzdW5nIE3DpHJ6?= -> "Uberweisung Marz" with umlauts 36 # =?ISO-8859-1?Q?_2024_Beleg?= -> " 2024 Beleg" 37 # `Date: Tue, 12 Mar 2024 09:41:07 +0100' is Unix time 1710232867, 38 # i.e. 2024-03-12T08:41:07Z. 39 40 cat > "$out" <<'EOF' 41 From anna.mueller@example.com Tue Mar 12 09:41:09 2024 42 Received: from mx1.example.net (mx1.example.net [198.51.100.24]) 43 by mail.example.org (Postfix) with ESMTPS id 4B7f2Z1qJz3xYm 44 for <bob@example.org>; Tue, 12 Mar 2024 09:41:09 +0100 (CET) 45 Received: from smtp6.example.net (smtp6.example.net [IPv6:2001:db8:1234::a5]) 46 by mx1.example.net (Postfix) with ESMTPS id 77aa88bb99cc 47 for <bob@example.org>; Tue, 12 Mar 2024 09:41:08 +0100 (CET) 48 Received: from wsbeta.corp.example.com (unknown [203.0.113.77]) 49 by mx1.example.net (Postfix) with ESMTPSA id 9C1a4F0d7b 50 for <bob@example.org>; Tue, 12 Mar 2024 09:41:07 +0100 (CET) 51 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; 52 s=sel2024; t=1710232867; h=from:to:subject:date; 53 bh=2jmj7l5rSw0yVb-vlWAYkK-YBwk=; 54 b=Zm9vYmFyYmF6cXV4Y29ycmdlZ3JhdWx0 55 Authentication-Results: mail.example.org; 56 dkim=pass header.d=example.com; 57 spf=pass smtp.mailfrom=example.com 58 X-Originating-IP: [192.0.2.153] 59 Message-ID: <20240312084107.9C1a4F0d7b@wsbeta.corp.example.com> 60 In-Reply-To: <20240311150122.A1B2C3@mail.example.net> 61 References: <20240310090000.000001@mail.example.net> 62 <20240311150122.A1B2C3@mail.example.net> 63 Date: Tue, 12 Mar 2024 09:41:07 +0100 64 From: =?UTF-8?B?QW5uYSBNw7xsbGVy?= <anna.mueller@example.com> 65 To: Bob Jones <bob@example.org>, carol@example.org 66 Cc: dave@example.org 67 Subject: =?UTF-8?B?w5xiZXJ3ZWlzdW5nIE3DpHJ6?= =?ISO-8859-1?Q?_2024_Beleg?= 68 Organization: Example GmbH 69 X-Mailer: Microsoft Outlook 16.0 70 MIME-Version: 1.0 71 Content-Type: multipart/mixed; boundary="=_boundary_42" 72 73 --=_boundary_42 74 Content-Type: text/plain; charset="ISO-8859-15" 75 Content-Transfer-Encoding: quoted-printable 76 77 Hallo Bob, 78 79 anbei der Beleg und die Reisekosten. 80 81 Gruss, Anna 82 83 --=_boundary_42 84 Content-Type: application/pdf; name="Kontoauszug_2024-03.pdf" 85 Content-Disposition: attachment; filename="Kontoauszug_2024-03.pdf" 86 Content-Transfer-Encoding: base64 87 88 JVBERi0xLjQKJcfsj6IKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c+PgplbmRvYmoK 89 dHJhaWxlcgo8PC9Sb290IDEgMCBSPj4KJSVFT0YK 90 91 --=_boundary_42 92 Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet 93 Content-Disposition: attachment; 94 filename*0="Reise"; 95 filename*1="kosten.xlsx" 96 Content-Transfer-Encoding: base64 97 98 UEsDBBQAAAAIAA== 99 100 --=_boundary_42-- 101 102 From bob@example.org Tue Mar 12 10:02:11 2024 103 Received: from mail.example.org (localhost [127.0.0.1]) 104 by mail.example.org (Postfix) with ESMTP id 0A1B2C3D4E5F 105 for <anna.mueller@example.com>; Tue, 12 Mar 2024 10:02:11 +0100 (CET) 106 Message-ID: <20240312090211.0A1B2C3D4E5F@mail.example.org> 107 In-Reply-To: <20240312084107.9C1a4F0d7b@wsbeta.corp.example.com> 108 Date: Tue, 12 Mar 2024 10:02:11 +0100 109 From: Bob Jones <bob@example.org> 110 To: =?UTF-8?B?QW5uYSBNw7xsbGVy?= <anna.mueller@example.com> 111 Subject: Re: Beleg 112 User-Agent: Mozilla Thunderbird 115.8.0 113 MIME-Version: 1.0 114 Content-Type: text/plain; charset=UTF-8; format=flowed 115 116 Danke, ist angekommen. 117 118 From daemon@example.org Tue Mar 12 10:15:00 2024 119 Received: from relay.example.org (relay.example.org [198.51.100.9]) 120 by mail.example.org (Postfix) with ESMTP id 112233445566 121 for <anna.mueller@example.com>; Tue, 12 Mar 2024 10:15:00 +0100 (CET) 122 Message-ID: <20240312091500.112233445566@relay.example.org> 123 Date: Tue, 12 Mar 2024 10:15:00 +0100 124 From: Mail Delivery System <daemon@example.org> 125 To: anna.mueller@example.com 126 Subject: Delivery Status Notification (Delay) 127 Content-Type: text/plain; charset=US-ASCII 128 129 >From the transcript of the session: 130 131 451 4.4.1 reply: read timeout, delivery deferred 132 133 EOF 134 135 echo "wrote $out ($(wc -c < "$out") bytes)"