From 2a5461338660f2319024c0ac03806a454f3ff3df Mon Sep 17 00:00:00 2001 From: Niles Rogoff Date: Sun, 2 Apr 2017 18:59:39 -0400 Subject: [PATCH] Initial commit --- index.php | 26 ++++++++++++++++++++++++ post.py | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.md | 3 +++ 3 files changed, 89 insertions(+) create mode 100644 index.php create mode 100644 post.py create mode 100644 readme.md diff --git a/index.php b/index.php new file mode 100644 index 0000000..fa63bef --- /dev/null +++ b/index.php @@ -0,0 +1,26 @@ + 0) { + fwrite($fd, "Modified: " . implode(", ", $commit["modified"])); + } + if (count($commit["added"]) > 0) { + fwrite($fd, "; Added: " . implode(", ", $commit["added"])); + } + if (count($commit["removed"]) > 0) { + fwrite($fd, "; Removed: " . implode(", ", $commit["removed"])); + } + fwrite($fd, "\n"); + fwrite($fd, "\t" . $commit["timestamp"] . " " . $commit["id"]); + fwrite($fd, "\n"); + fwrite($fd, "\t" . $commit["url"]); + fclose($fd); + exec("python3 /opt/post.py /tmp/payload"); +} +?> diff --git a/post.py b/post.py new file mode 100644 index 0000000..2221ab7 --- /dev/null +++ b/post.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 +import subprocess +import random +import time +import string +import sys +user = "CHANGEME" +pw = "CHANGEME" +r = random.Random() +date = subprocess.check_output(["date", "+%a, %d %b %Y %T %z"]).decode("utf-8").rstrip() # strftime to the rescue +post = "<" + "".join(r.sample(string.ascii_letters, 18)) + str(int(time.time())) + "@bar2.ano>" # 18 random letters then the epoch +# References: +# X-Sage: optional +# Date: Thu, 02 May 2013 12:16:44 +0000 +header = """Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +From: anonymous +Date: """ + date + """ +Message-ID: """ + post + """ +Newsgroups: overchan.test +References: +Subject: None +Path: bar3.ano""" + +from twisted.internet import reactor, protocol +import twisted.protocols.basic + +class client(twisted.protocols.basic.LineReceiver): + def sl(self, line): # send string line + print("Send: " + line) + self.sendLine(line.encode("utf-8")) + def lineReceived(self, data): + data = data.decode("utf-8") + print("Recv: " + data) + data = data.split() + if data[0] == "200" or data[0] == "281": # posting allowed or authentication successful + self.sl("IHAVE " + post) + if data[0] == "335": # server sends back "335 send it plz" + self.sl(header) + self.sl("") + self.sl(open(" ".join(sys.argv[1:]), "r").read()) + self.sl(".") + if data[0] == "235": # server sends back "235 i got it" + self.sl("QUIT") + if data[0] == "205": # server sends back "205 bai" + reactor.stop() + # sys.exit(0) + if data[0] == "483": # authentication required before posting + self.sl("AUTHINFO USER " + user) + if data[0] == "381": # password required + self.sl("AUTHINFO PASS " + pw) + + +class fac(protocol.ClientFactory): + protocol = client + + +# this connects the protocol to a server running on port 8000 +reactor.connectTCP("10.8.0.1", 1199, fac()) +reactor.run() diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..ae2691f --- /dev/null +++ b/readme.md @@ -0,0 +1,3 @@ +# Send your github commits to nntpchan + +Pretty simple to set up. Configure your server, username and password in post.py then drop it in /opt, add a github hook to the php file. No authentication or verification that it's really github, so keep the url a secret