commit a10ff4d4d823dbd012b8a9f452f4e914e4e4470c Author: khuxkm fbexl Date: Sat Aug 17 01:39:20 2019 +0000 Add initial codebase diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d61c2f8 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2019 Robert 'khuxkm' Miles, + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/README.md b/README.md new file mode 100644 index 0000000..bd0e8d3 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# anon.hmm.st + +The setup used for anon.hmm.st, the cosmic.voyage ship. diff --git a/clear_log.py b/clear_log.py new file mode 100755 index 0000000..183abb4 --- /dev/null +++ b/clear_log.py @@ -0,0 +1,5 @@ +#!/usr/bin/python3 +import sys + +with open("/home/anonhmmst/log.txt","w") as f: + f.write("") diff --git a/multipart.txt b/multipart.txt new file mode 100644 index 0000000..cf5b3a0 --- /dev/null +++ b/multipart.txt @@ -0,0 +1,38 @@ +Return-Path: +X-Original-To: anonhmmst@cosmic.voyage +Delivered-To: anonhmmst@cosmic.voyage +Received: from tilde.team (tilde.team [51.79.32.48]) + by cosmic.voyage (Postfix) with ESMTPS id 45CF93EA51 + for ; Sat, 17 Aug 2019 00:37:24 +0000 (UTC) +Received: from mail.tilde.team (localhost [127.0.0.1]) + by tilde.team (Postfix) with ESMTPSA id 17CA62E209D6 + for ; Fri, 16 Aug 2019 20:37:23 -0400 (EDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tilde.team; s=mail; + t=1566002243; bh=APyR3pmjfgUNb6Sp7kQ2uVElkWbT7laGub/WT1+2ycg=; + h=Date:From:Subject:To:From; + b=KpFvjLEmUQtWunA00gcJ+oVbKPEB1iolbcCxzDEM0Rzu9CUoIjb8qX9aL+MCWTfXk + ReuProrqbAqfZXNY4Qh7otFeDxxpsRIkbfcWxs57FZbEVpTbki/tRQ8XP1oDsOa0rW + tKNatC5bjYyofks/SicGfNNmhtoHY9xtsw8sHWbQ= +MIME-Version: 1.0 +Date: Sat, 17 Aug 2019 00:37:22 +0000 +Content-Type: multipart/alternative; + boundary="--=_RainLoop_934_776316489.1566002242" +X-Mailer: RainLoop/1.12.0 +From: khuxkm@tilde.team +Message-ID: +Subject: test +To: anonhmmst@cosmic.voyage +----=_RainLoop_934_776316489.1566002242 +Content-Type: text/plain; charset="utf-8" +Content-Transfer-Encoding: quoted-printable +This is a test. +----=_RainLoop_934_776316489.1566002242 +Content-Type: text/html; charset="utf-8" +Content-Transfer-Encoding: quoted-printable +
<= +div>
Th= +is is a test.
<= +/html> +----=_RainLoop_934_776316489.1566002242-- diff --git a/parse_email.py b/parse_email.py new file mode 100755 index 0000000..e5ac5e6 --- /dev/null +++ b/parse_email.py @@ -0,0 +1,27 @@ +#!/usr/bin/python3 +import utils,sys +utils.setcwd("/home/anonhmmst") + +email = utils.input() + +def log(x): + with utils.open("log.txt","a") as f: + f.write(x+"\n") + +title = email.get("Subject") +payload = email.get_payload() + +if type(payload)==list: + payload = {x.get_content_type(): x.get_payload() for x in payload} + if payload.get("text/plain") is not None: + payload = payload["text/plain"] + else: + sys.exit(0) + +if "\r\n" in payload: + payload = payload.replace("\r\n","\n") +if payload==payload.rstrip(): + payload+="\n" + +log("title = {!r}".format(title)) +log("payload = {!r}".format(payload)) diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..3d4720c --- /dev/null +++ b/test.txt @@ -0,0 +1,12 @@ +From khuxkm@cosmic.voyage Sat Aug 17 00:16:12 2019 +Return-Path: +X-Original-To: anonhmmst@cosmic.voyage +Delivered-To: anonhmmst@cosmic.voyage +Received: by cosmic.voyage (Postfix, from userid 1007) + id 453C343A86; Sat, 17 Aug 2019 00:16:12 +0000 (UTC) +From: khuxkm@cosmic.voyage +Subject: test +Message-Id: <20190817001612.453C343A86@cosmic.voyage> +Date: Sat, 17 Aug 2019 00:16:12 +0000 (UTC) + +test diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..f5dee57 --- /dev/null +++ b/utils.py @@ -0,0 +1,20 @@ +import sys,os,contextlib,builtins,email + +inp = email.message_from_file(sys.stdin) +homedir = os.path.dirname(__file__) + +def input(): + return inp + +def setcwd(c): + homedir = c + +@contextlib.contextmanager +def open(*args,**kwargs): + args = list(args) + fn = os.path.join(homedir,args.pop(0)) + f = builtins.open(fn,*args,**kwargs) + try: + yield f + finally: + f.close()