feat: init working prison-break
This commit is contained in:
parent
8d0837d781
commit
182138d33c
|
@ -21,6 +21,7 @@ with prev; {
|
|||
drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final);
|
||||
record-screen = writeShellScriptBin "record-screen" (import ./record-screen.nix final);
|
||||
cockroach-bin = import ./cockroach.nix final;
|
||||
prison-break = import ./prison-break.nix final;
|
||||
|
||||
# ps-fixes
|
||||
}
|
||||
|
|
84
pkgs/prison-break-url.patch
Normal file
84
pkgs/prison-break-url.patch
Normal file
|
@ -0,0 +1,84 @@
|
|||
diff --git a/prisonbreak/cli.py b/prisonbreak/cli.py
|
||||
index 0add782..10eda94 100755
|
||||
--- a/prisonbreak/cli.py
|
||||
+++ b/prisonbreak/cli.py
|
||||
@@ -31,7 +31,7 @@ from straight.plugin import load
|
||||
|
||||
|
||||
def configure_debug(debug: bool) -> None:
|
||||
- if debug:
|
||||
+ if True:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
from http.client import HTTPConnection
|
||||
|
||||
@@ -57,7 +57,7 @@ def send_notify(message,title="Prison-Break",icon="dialog-warning-symbolic",do_n
|
||||
|
||||
def main():
|
||||
args = docopt(__doc__)
|
||||
- secret_url = "http://krebsco.de/secret" # return 1337
|
||||
+ check_online_url = "http://detectportal.firefox.com/canonical.html"
|
||||
profile = environ.get("CONNECTION_FILENAME", None)
|
||||
timeout = float(args['--timeout'])
|
||||
tries = int(args['--retry'])
|
||||
@@ -123,8 +123,8 @@ def main():
|
||||
s = requests.Session()
|
||||
s.headers.update(
|
||||
{
|
||||
- "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:65.0)"
|
||||
- "Gecko/20100101 Firefox/65.0"
|
||||
+ "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:122.0)"
|
||||
+ "Gecko/20100101 Firefox/122.0"
|
||||
}
|
||||
)
|
||||
if wait:
|
||||
@@ -133,7 +133,7 @@ def main():
|
||||
|
||||
for n in range(tries):
|
||||
try:
|
||||
- initial_response = s.get(secret_url,timeout=timeout)
|
||||
+ initial_response = s.get(check_online_url,timeout=timeout)
|
||||
except Timeout as t:
|
||||
log.info(f"Timeout number {n+1}, waiting {timeout_wait} seconds")
|
||||
continue
|
||||
@@ -144,12 +144,12 @@ def main():
|
||||
break
|
||||
sleep(timeout_wait)
|
||||
else:
|
||||
- log.error(f'Unable to Retrieve the initial response after {tries} tires')
|
||||
+ log.error(f'Unable to Retrieve the initial response after {tries} tries')
|
||||
exit(1)
|
||||
|
||||
|
||||
- if initial_response.text.startswith("1337"):
|
||||
- log.info("Received the correct challenge token"
|
||||
+ if 'nginx' == initial_response.headers.get('Server'):
|
||||
+ log.info("Received the correct server header"
|
||||
", assuming no captive portal")
|
||||
if args['--force-token']:
|
||||
log.info("Continuing even though we got the correct token!")
|
||||
@@ -171,8 +171,9 @@ def main():
|
||||
note("Trying to accept AGBs for you now!",title=f"Prison-Break Plugin {name}")
|
||||
#notify2.Notification("Summary", "Some body text", "notification-message-im").show()
|
||||
if plug.accept(initial_response, s):
|
||||
+ log.debug(s.get(check_online_url,timeout=timeout).headers)
|
||||
log.info(f"{name} successful?")
|
||||
- if s.get(secret_url,timeout=timeout).text.startswith("1337"):
|
||||
+ if 'nginx' == s.get(check_online_url,timeout=timeout).headers.get('Server'):
|
||||
#notify2.Notification("Prison-Break", "Plugin {name} successful", "notification-message-im").show()
|
||||
|
||||
log.info(f"{name} successful!")
|
||||
diff --git a/prisonbreak/plugins/wifionice.py b/prisonbreak/plugins/wifionice.py
|
||||
index 1cee64d..38e5c74 100644
|
||||
--- a/prisonbreak/plugins/wifionice.py
|
||||
+++ b/prisonbreak/plugins/wifionice.py
|
||||
@@ -58,8 +58,8 @@ def accept(resp: requests.Response, s: requests.Session) -> bool:
|
||||
log.debug(f"data: {postdata}")
|
||||
|
||||
# TODO: detect the correct URL to query based on form path and url
|
||||
- # The URL changed from http to http, and wifionice.de is now wifi.bahn.de
|
||||
- resp = s.post("https://wifi.bahn.de/de/?url=http%3A%2F%2Fkrebsco.de%2Fsecret", data=postdata)
|
||||
+ # The URL changed from wifi.bahn.de to login.wifionice.de
|
||||
+ resp = s.post("https://login.wifionice.de/en/?url=http%3A%2F%2Fdetectportal.firefox.com%2Fcanonical.html", data=postdata)
|
||||
log.debug(f"Return code: {resp.status_code}")
|
||||
log.debug(resp.headers)
|
||||
return resp.ok
|
41
pkgs/prison-break.nix
Normal file
41
pkgs/prison-break.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
self:
|
||||
with self;
|
||||
let
|
||||
straight-plugin = python3.pkgs.buildPythonPackage rec {
|
||||
pname = "straight-plugin";
|
||||
version = "1.5.0";
|
||||
|
||||
src = fetchPypi {
|
||||
pname = "straight.plugin";
|
||||
inherit version;
|
||||
sha256 = "818a7641068932ed6436d0af0a3bb77bbbde29df0a7142c8bd1a249e7c2f0d38";
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "A simple namespaced plugin facility";
|
||||
homepage = https://github.com/ironfroggy/straight.plugin;
|
||||
license = licenses.mit;
|
||||
maintainers = [ maintainers.makefu ];
|
||||
};
|
||||
};
|
||||
in
|
||||
python3.pkgs.buildPythonPackage {
|
||||
name = "env";
|
||||
src = fetchFromGitHub {
|
||||
owner = "makefu";
|
||||
repo = "prison-break";
|
||||
rev = "15079bb094d37eeba92e17abfb98523076c5800c";
|
||||
sha256 = "sha256-MDzAmeJ6wsTm5+unIsYAZmErVN4sEAfih3YwbXkVIPg=";
|
||||
};
|
||||
propagatedBuildInputs = with python3.pkgs;[
|
||||
docopt
|
||||
requests
|
||||
beautifulsoup4
|
||||
notify2
|
||||
straight-plugin
|
||||
];
|
||||
patches = [
|
||||
./prison-break-url.patch
|
||||
];
|
||||
checkInputs = [ python3.pkgs.black ];
|
||||
}
|
Loading…
Reference in a new issue