Add initial codebase

This commit is contained in:
Robert Miles 2019-08-17 01:39:20 +00:00
commit a10ff4d4d8
7 changed files with 127 additions and 0 deletions

22
LICENSE Normal file
View File

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2019 Robert 'khuxkm' Miles, <khuxkm@tilde.team>
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.

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# anon.hmm.st
The setup used for anon.hmm.st, the cosmic.voyage ship.

5
clear_log.py Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/python3
import sys
with open("/home/anonhmmst/log.txt","w") as f:
f.write("")

38
multipart.txt Normal file
View File

@ -0,0 +1,38 @@
Return-Path: <khuxkm@tilde.team>
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 <anonhmmst@cosmic.voyage>; 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 <anonhmmst@cosmic.voyage>; 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: <ec8f97896ad3a161503a3128025a634b@tilde.team>
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
<!DOCTYPE html><html><head><meta http-equiv=3D"Content-Type" content=3D"t=
ext/html; charset=3Dutf-8" /></head><body><div data-html-editor-font-wrap=
per=3D"true" style=3D"font-family: arial, sans-serif; font-size: 13px;"><=
div><div><div style=3D"font-family: arial, sans-serif;font-size: 13px">Th=
is is a test.<br><signature></signature> </div></div></div></div></body><=
/html>
----=_RainLoop_934_776316489.1566002242--

27
parse_email.py Executable file
View File

@ -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))

12
test.txt Normal file
View File

@ -0,0 +1,12 @@
From khuxkm@cosmic.voyage Sat Aug 17 00:16:12 2019
Return-Path: <khuxkm@cosmic.voyage>
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

20
utils.py Normal file
View File

@ -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()