Compare commits

...

19 Commits

Author SHA1 Message Date
Laura Liberda 9c7163416e utils backported from youtube-dl 2021-05-25 13:17:09 +02:00
Laura Liberda 0646c6f6ac fix crash on pre-3.9 2020-12-24 00:29:54 +01:00
Laura Liberda adf9355069 improve e-mail address generator 2020-12-24 00:25:04 +01:00
Lauren Liberda 8f78531cf6 Merge branch 'poznan-airport' into 'master'
add poznan airport wifi name

See merge request laudom/librefi!8
2020-12-19 14:38:46 +00:00
Lauren Liberda 555aef17cc Merge branch 'fix/nmcli-quotes' into 'master'
fix unnecessary quotes in nmcli connect

See merge request laudom/librefi!7
2020-12-19 14:38:13 +00:00
ptrcnull 661ad3427a add poznan airport wifi name 2020-12-18 12:30:47 +01:00
ptrcnull f7efa06d5e fix unnecessary quotes in nmcli connect 2020-12-18 12:28:07 +01:00
Laura Liberda 9528acb0aa delete trailing comma, because py2.7 2020-12-04 01:17:29 +01:00
Laura Liberda 93d1263510 release 2020.12.04 2020-12-04 01:10:07 +01:00
Laura Liberda 3b6c51200d fix pip cli finally? 2020-12-04 01:09:25 +01:00
Laura Liberda 357d20d99e release 2020.12.03.3 2020-12-03 08:28:47 +01:00
Laura Liberda 1f843d5468 fix package to work on pip installs 2020-12-03 08:25:22 +01:00
Laura Liberda 6226b75fc2 release 2020.12.03.2 2020-12-03 08:03:56 +01:00
Laura Liberda b4c43b16b6 fix requires_python? 2020-12-03 08:03:24 +01:00
Laura Liberda 69ba35de39 release 2020.12.03.1 2020-12-03 07:56:43 +01:00
Laura Liberda a74cd5867a update setup 2020-12-03 07:46:57 +01:00
Laura Liberda cdb591b080 ok, python 3.4 was a mistake 2020-12-03 07:44:53 +01:00
Laura Liberda 68c67fdc12 test, test, test! 2020-12-03 07:40:55 +01:00
Laura Liberda dadab6e8f5 readme update: python 3.4+ and jython supported 2020-12-03 07:40:36 +01:00
10 changed files with 465 additions and 35 deletions

View File

@ -9,12 +9,49 @@ py2.7-unit_tests:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.4-unit_tests:
image: python:3.4-alpine
allow_failure: true
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.5-unit_tests:
image: python:3.5-alpine
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.6-unit_tests:
image: python:3.6-alpine
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.7-unit_tests:
image: python:3.7-alpine
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.8-unit_tests:
image: python:3.8-alpine
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.9-unit_tests:
image: python:3.9-alpine
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
py3.10-rc-unit_tests:
image: python:3.10-rc-alpine
script:
- nosetests tests/*.py
- python setup.py sdist bdist_wheel
jy2.7-unit_tests:
image: openjdk:11-slim
before_script:
@ -38,6 +75,43 @@ py2.7-integration_test:
script:
- python -m librefi
py3.4-integration_test:
image: python:3.4-buster
allow_failure: true
before_script:
- pip install -r requirements.txt
- apt-get -y update
- apt-get -y install network-manager
script:
- python3 -m librefi
py3.5-integration_test:
image: python:3.5-buster
before_script:
- pip install -r requirements.txt
- apt-get -y update
- apt-get -y install network-manager
script:
- python3 -m librefi
py3.6-integration_test:
image: python:3.6-buster
before_script:
- pip install -r requirements.txt
- apt-get -y update
- apt-get -y install network-manager
script:
- python3 -m librefi
py3.7-integration_test:
image: python:3.7-buster
before_script:
- pip install -r requirements.txt
- apt-get -y update
- apt-get -y install network-manager
script:
- python3 -m librefi
py3.8-integration_test:
image: python:3.8-buster
before_script:
@ -56,6 +130,15 @@ py3.9-integration_test:
script:
- python3 -m librefi
py3.10-rc-integration_test:
image: python:3.10-rc-buster
before_script:
- pip install -r requirements.txt
- apt-get -y update
- apt-get -y install network-manager
script:
- python3 -m librefi
jy2.7-integration_tests:
image: openjdk:11-slim
before_script:

View File

@ -1,30 +1,40 @@
# LibreFi
## Free Wi-Fi was so great that we created Free Wi-Fi 2
Note: work is still in progress, this is not stable, may not be usable or useful
## How to use (for now):
## How to use:
release (not to be confused with: _stable_):
```sh
# you may want to use python3.9, python2, python, jython or something like that
$ python3 -m pip install librefi
$ python3 -m librefi # no daemon yet, run to connect
```
development:
```sh
$ git clone https://git.sakamoto.pl/laudom/librefi.git
$ cd librefi
$ pip3 install -r ./librefi/requirements.txt
$ pip3 install -r ./requirements.txt
$ pip3 install -r ./requirements_dev.txt
$ python3 -m librefi # no daemon yet, run to connect
```
## A bit of technical things
- Requires Python 3.8+ or 2.7
- Requires NetworkManager (only Linux and some Unix-like systems) to connect with Wi-Fi networks for now.
- Only tested with CPython for now.
- Requires Python 3.4+ or 2.7 (preferably 3.8+)
- Requires NetworkManager (only Linux and some Unix-like systems) to connect with Wi-Fi networks for now, however, it's ready to implement other connectors.
- Only tested with CPython and Jython, other implementations may work by accident.
- Only works with [these networks](https://git.sakamoto.pl/laudom/librefi/-/blob/master/librefi/fxckers/_map.py)
## Contributing
If you want to contribute, please contact with either [Laura](https://selfisekai.rocks) or [Dominika](https://sakamoto.pl) for a [git.sakamoto.pl](https://git.sakamoto.pl) account, or just [submit patches by e-mail](https://devconnected.com/how-to-create-and-apply-git-patch-files/#Create_Git_Patch_Files) to <librefi-patches@selfisekai.rocks>
If you want to contribute, please contact with either [Lauren](https://selfisekai.rocks) or [Dominika](https://sakamoto.pl) for a [git.sakamoto.pl](https://git.sakamoto.pl) account, or just [submit patches by e-mail](https://devconnected.com/how-to-create-and-apply-git-patch-files/#Create_Git_Patch_Files) to <librefi-patches@selfisekai.rocks>
## Maintainers:
### Core:
- Laura Liberda <laura@selfisekai.rocks>
- Lauren Liberda <lauren@selfisekai.rocks>
- Dominika Liberda <sdomi@sakamoto.pl>
### Fxckers:
- Poland:
- Warsaw:
- Laura Liberda <laura@selfisekai.rocks>
- Lauren Liberda <lauren@selfisekai.rocks>
- Dominika Liberda <sdomi@sakamoto.pl>

6
bin/librefi Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env python
import librefi
if __name__ == '__main__':
librefi.main()

View File

@ -1,6 +1,30 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from .librefi import LibreFi
import sys
__all__ = ['LibreFi']
from .librefi import LibreFi
from .logger import _Logger, LOG_LEVELS
from .utils import LFiError, FxckerError
def _real_main(argv=None):
librefi = LibreFi(logger=_Logger, log_level=LOG_LEVELS.DEBUG)
librefi._periodical_check()
def main(argv=None):
try:
_real_main(argv)
except LFiError:
sys.exit('ERROR (core): report this to librefi@selfisekai.rocks')
except FxckerError:
sys.exit('ERROR (fxcker): report this to librefi@selfisekai.rocks')
except KeyboardInterrupt:
sys.exit('\nERROR: Interrupted by user')
__all__ = [
'LibreFi',
'main',
]

View File

@ -9,10 +9,7 @@ if __package__ is None and not hasattr(sys, 'frozen'):
path = os.path.realpath(os.path.abspath(__file__))
sys.path.insert(0, os.path.dirname(os.path.dirname(path)))
from librefi import LibreFi
from .logger import _Logger, LOG_LEVELS
librefi = LibreFi(logger=_Logger, log_level=LOG_LEVELS.DEBUG)
from librefi import main
if __name__ == '__main__':
librefi._periodical_check()
main()

View File

@ -2,7 +2,6 @@
from __future__ import unicode_literals
import subprocess
import pipes
import re
@ -67,4 +66,4 @@ class NetworkManagerConnector:
def connect(self, network):
self._call_nmcli(["device", "wifi", "connect",
pipes.quote(network["ssid"])], parse=False)
network["ssid"]], parse=False)

View File

@ -17,6 +17,7 @@ fxckers_map = [
([
"Intercity_WiFi",
"_PKP_WIFI",
"Poznan Airport by JustWiFi",
], JustWifiFxcker),
]

View File

@ -3,7 +3,7 @@
from __future__ import unicode_literals
import re
from datetime import datetime
from datetime import date
import random
from .compat import (
@ -23,6 +23,9 @@ class FxckerError(Exception):
pass
TEST_URL = "http://detectportal.firefox.com/success.txt"
def get_user_agent():
if bool(random.getrandbits(1)):
# Google Chrome
@ -85,25 +88,253 @@ def get_user_agent():
def get_email_address():
time_now = datetime.now()
if time_now.month == 5 and time_now.day == 17:
# https://en.wikipedia.org/wiki/International_Day_Against_Homophobia,_Transphobia_and_Biphobia
return random.choice([
"biuro@ordoiuris.pl",
day_today = date.today().strftime('%m-%d')
if day_today in ( # "MM-DD"
'05-17', # https://en.wikipedia.org/wiki/International_Day_Against_Homophobia,_Transphobia_and_Biphobia
'09-28', # https://en.wikipedia.org/wiki/International_Safe_Abortion_Day
'11-20', # https://en.wikipedia.org/wiki/Transgender_Day_of_Remembrance
'12-10', # https://en.wikipedia.org/wiki/Human_Rights_Day
):
return random.choice((
"kontakt@stronazycia.pl",
"kontakt@petycjaonline.pl",
"gejprzeciwkoswiatu@gmail.com",
"biuro.prasowe@konfederacja.net",
"biuro@pis.org.pl",
"Zbigniew.Ziobro@sejm.pl",
])
"Sebastian.Kaleta@sejm.pl",
"Michal.Wojcik@sejm.pl",
"Tomasz.Rzymkowski@sejm.pl",
email = ""
for i in range(random.randint(6, 18)):
# LGB Alliance
"developers@lgballiance.org.uk",
"koalicjalgb@gmail.com",
"frentelgb@gmail.com",
"alianzalgb@gmail.com",
"lgsolidarnamreza@gmail.com",
"redlesbianasgaysbisexuales@gmail.com",
# Agenda Europe - https://agendaeurope.wordpress.com/links-2/
"info@acton.org",
"istitutoacton@acton.org",
"info@institutoacton.com.ar",
"kmauren@acton.org",
"sgregg@acton.org",
"kabbs@acton.org",
"tvogt@acton.org",
"sbarrows@acton.org",
"croelofs@acton.org",
"kmauren@acton.org",
"ekohn@acton.org",
"mseverance@acton.org",
"info@c-fam.org",
"Media@c-fam.org",
"Hannah@c-fam.org",
"press@citizengo.org",
"english@citizengo.org",
"admin@dialoguedynamics.com",
"ipf@ipfe.org",
"internationalipf@ipfe.org",
"ehertfelder@ipfe.org",
"donor@lifesitenews.com",
"support@lifesitenews.com",
"corrections@lifesitenews.com",
"advertising@lifesitenews.com",
"marketing@lifesitenews.com",
"submit@lifesitenews.com",
"info@od.org.au",
"finland@od.org",
"contacto@puertasabiertasal.org",
"philippines@od.org",
"info@puertasabiertas.org",
"info@opendoors.at",
"info@portesouvertes.ch",
"contact@portesouvertes.fr",
"info@opendoors.pl",
"sweden@od.org",
"sarab@od.org",
"presskontakt@od.org",
"falecom@portasabertas.org.br",
"info@opendoors.de",
"youth@opendoors.de",
"pressebuero@opendoors.de",
"info@od.org.nz",
"info@porti-deschise.org",
"info@portesouvertes.ch",
"opendoorsca@odcan.org",
"enquiryhk@od.org",
"norway@od.org",
"mortena@od.org",
"lindaa@od.org",
"southafrica@od.org",
"inspire@opendoorsuk.org",
"odireland@opendoorsuk.org",
"denmark@od.org",
"info@porteaperteitalia.org",
"cristinam@od.org",
"cristiann@od.org",
"odi-nl@od.org",
"info@fedsoc.org",
"Info@C-FAM.org",
"info@womenworldplatform.com",
"info@wcfverona.org",
"webadmin@ifamnews.com",
"info@profam.org",
"wya@wya.net",
"africa@wya.net",
"asiapacific@wya.net",
"europe@wya.net",
"latinamerica@wya.net",
"mena@wya.net",
"northamerica@wya.net",
"info@europeanrenewal.org",
"secretariat@eclj.org",
"office@ecpm.info",
"office@europeandignitywatch.org",
"info@oneofus.eu",
"info@familienforum.at",
"postbox@imabe.org",
"office@ief.at",
"office@youthforlife.net",
"office@kairos-pr.com",
"office@lebenskonferenz.at",
"info@pro-life.by",
"svabulgaria@gmail.com",
"press@uimeobitelji.net",
"cenap@cenap.cz",
"info@hnutiprozivot.cz",
"rodiny@rodiny.cz",
"oujezdska@rodiny.cz",
"charvatova@rodiny.cz",
"horakova@rodiny.cz",
"pavlisova@rodiny.cz",
"kucerova@rodiny.cz",
"jegvilleve@rettentilliv.dk",
"leder@abortlinien.dk",
"ung@rettentilliv.dk",
"web@rettentilliv.dk",
"regnskab@rettentilliv.dk",
"elukultuur@gmail.com",
"info@saptk.ee",
"presse@fondationlejeune.org",
"info@alfa-ev.de",
"berlin@bv-lebensrecht.de",
"info@cdl-online.de",
"info@datenschutz.ekd.de",
"datenschutz@ojc.de",
"kontakt@familien-schutz.de",
"info@jvl-ev.de",
"zfl@juristen-vereinigung-lebensrecht.de",
"kontakt@familie-geht-vor.de",
"info@agalia.org.gr",
"kapcsolat@egyuttazeletert.hu",
"asszonyszovetseg@asszonyszovetseg.hu",
"info@familyandlife.org",
"info@ionainstitute.ie",
"info@famigliadomani.it",
"contact@novaeterrae.eu",
"giuristiperlavita2@gmail.com",
"postmaster@giuristiperlavita.org",
"webmaster@giuristiperlavita.org",
"redazione@lanuovabq.it",
"segreteria@lanuovabq.it",
"inserzioni@lanuovabq.it",
"segreteria@lamanifpourtous.it",
"press@lamanifpourtous.it",
"info@provitaefamiglia.it",
"stampa@provitaefamiglia.it",
"redazione@provitaefamiglia.it",
"asociacijagimene@gmail.com",
"info@schwanger.li",
"beratung@schwanger.li",
"info@schwanger.li",
"af@ateitis.lt",
"info@propatria.lt",
"contact@moldovacrestina.md",
"secretariaat@provita.nl",
"info@schreeuwomleven.nl",
"morten@menneskeverd.no",
"kristin@menneskeverd.no",
"maria@menneskeverd.no",
"susanne@menneskeverd.no",
"ingrid@menneskeverd.no",
"sara@menneskeverd.no",
"fredrik@menneskeverd.no",
"bjarne@menneskeverd.no",
"ingridbs@menneskeverd.no",
"annekari@menneskeverd.no",
"post@menneskeverd.no",
"fundacja@glosdlazycia.pl",
"biuro@mamaitata.org.pl",
"biuro@ordoiuris.pl",
"rzecznik@ordoiuris.pl",
"interwencja@ordoiuris.pl",
"f.p.p.vida@gmail.com",
"office@alianta-familiilor.ro",
"asociatiadiaconia@yahoo.com",
"redactia@culturavietii.ro",
"contact@asociatiaprovita.ro",
"profamilia.ru@gmail.com",
"info@familypolicy.ru",
"info@alianciazarodinu.sk",
"donumvitaeoz@gmail.com",
"forumzivota@forumzivota.sk",
"info@zavod-zivim.si",
"info@cidevida.org",
"forofamilia@forofamilia.org",
"prensa@forofamilia.org",
"prensa@hazteoir.org",
"info@profesionalesetica.org",
"asistencia24@redmadre.es",
"info@valoresysociedad.org",
"info@respektlivet.nu",
"info@shrl.eu",
"info@starke-muetter.com",
"family_institute@ucu.edu.ua",
"info@christianconcern.com",
"press@c4m.org.uk",
"admin@c4m.org.uk",
"info@core-issues.org",
"info@righttolife.org.uk",
"information@spuc.org.uk",
"info@spucscotland.org",
"belfast@spuc.org.uk",
"info@christian.org.uk",
"info@vfjuk.org",
))
# random first name
email = random.choice((
# ok, you got me, not so much random
"laura", "dominika", "patrycja",
# bromine and barium
"andrea", "brock", "jesse", "walter", "mike", "flynn", "marie", "hank", "gustavo", "saul",
# an edgy teenager and her friends
"haruhi", "kyon", "mikuru", "yuki", "itsuki", "ryouko",
# that's totally how they live
"yuuko", "mai", "mio", "nano", "hakase", "sakamoto", "misato", "izumi", "yoshino", "haruna"
))
email += random.choice(("", ".", "_", "-"))
# random a-z chars
for i in range(random.randint(3, 9)):
email += chr(97 + random.randint(0, 24))
return email + "@" + random.choice([
"gmail.com", "outlook.com", "live.com",
])
# ~50% chance
if random.getrandbits(1):
# random digits
email += compat_str(random.randint(0, 9999))
return email + "@" + random.choice((
# only include big corp e-mail domains here, fuck centralization
"gmail.com",
"outlook.com",
"live.com",
"hotmail.com",
"hotmail.co.uk",
"yahoo.com",
"aol.com",
"aim.com",
"yandex.ru",
"mail.ru",
))
def regex_search_string(regexes, string, default=None, multiple=False, whole_match=False):
@ -187,3 +418,63 @@ def absolute_url(new_url, old_url):
# like "hostname/path?query", if other checks fail
return scheme + "://" + new_url
# from youtube-dl
def js_to_json(code):
COMMENT_RE = r'/\*(?:(?!\*/).)*?\*/|//[^\n]*'
SKIP_RE = r'\s*(?:{comment})?\s*'.format(comment=COMMENT_RE)
INTEGER_TABLE = (
(r'(?s)^(0[xX][0-9a-fA-F]+){skip}:?$'.format(skip=SKIP_RE), 16),
(r'(?s)^(0+[0-7]+){skip}:?$'.format(skip=SKIP_RE), 8),
)
def fix_kv(m):
v = m.group(0)
if v in ('true', 'false', 'null'):
return v
elif v.startswith('/*') or v.startswith('//') or v.startswith('!') or v == ',':
return ""
if v[0] in ("'", '"'):
v = re.sub(r'(?s)\\.|"', lambda m: {
'"': '\\"',
"\\'": "'",
'\\\n': '',
'\\x': '\\u00',
}.get(m.group(0), m.group(0)), v[1:-1])
else:
for regex, base in INTEGER_TABLE:
im = re.match(regex, v)
if im:
i = int(im.group(1), base)
return '"%d":' % i if v.endswith(':') else '%d' % i
return '"%s"' % v
return re.sub(r'''(?sx)
"(?:[^"\\]*(?:\\\\|\\['"nurtbfx/\n]))*[^"\\]*"|
'(?:[^'\\]*(?:\\\\|\\['"nurtbfx/\n]))*[^'\\]*'|
{comment}|,(?={skip}[\]}}])|
(?:(?<![0-9])[eE]|[a-df-zA-DF-Z_])[.a-zA-Z_0-9]*|
\b(?:0[xX][0-9a-fA-F]+|0+[0-7]+)(?:{skip}:)?|
[0-9]+(?={skip}:)|
!+
'''.format(comment=COMMENT_RE, skip=SKIP_RE), fix_kv, code)
# from youtube-dl
def hidden_inputs(html):
html = re.sub(r'<!--(?:(?!<!--).)*-->', '', html)
hidden_inputs = {}
for input in re.findall(r'(?i)(<input[^>]+>)', html):
attrs = extract_attributes(input)
if not input:
continue
if attrs.get('type') not in ('hidden', 'submit'):
continue
name = attrs.get('name') or attrs.get('id')
value = attrs.get('value')
if name and value is not None:
hidden_inputs[name] = value
return hidden_inputs

View File

@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-
__version__ = '2020.12.03'
__version__ = '2020.12.04'

View File

@ -6,14 +6,20 @@ import os
import sys
from shutil import rmtree
from setuptools import find_packages, setup, Command
try:
from setuptools import setup, Command
setuptools_available = True
except ImportError:
from distutils.core import setup, Command
setuptools_available = False
NAME = 'librefi'
DESCRIPTION = 'LibreFi logs into public Wi-Fis without user interaction. Just access the network!'
URL = 'https://git.sakamoto.pl/laudom/librefi'
EMAIL = 'librefi@selfisekai.rocks'
AUTHOR = 'Lauren Liberda'
REQUIRES_PYTHON = '==2.7, >=3.8'
REQUIRES_PYTHON = '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4'
REQUIRED = [
'requests',
@ -35,6 +41,12 @@ try:
except FileNotFoundError:
long_description = DESCRIPTION
params = {}
if setuptools_available:
params['entry_points'] = {'console_scripts': ['librefi = librefi:main']}
else:
params['scripts'] = ['bin/librefi']
class UploadCommand(Command):
"""Support setup.py upload."""
@ -84,10 +96,12 @@ setup(
author_email=EMAIL,
python_requires=REQUIRES_PYTHON,
url=URL,
packages=[
'librefi',
'librefi.connectors',
'librefi.fxckers',
],
py_modules=['librefi'],
entry_points={
'console_scripts': ['librefi=librefi:cli'],
},
install_requires=REQUIRED,
extras_require=EXTRAS,
include_package_data=True,
@ -100,12 +114,17 @@ setup(
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: Jython',
],
# $ setup.py publish support.
cmdclass={
'upload': UploadCommand,
},
**params
)