Ejemplo n.º 1
0
 def login(self):
     # Login
     Request("https://www.share-online.biz/user/login", method="POST", payload={
         "user": Config.get("user"),
         "pass": Config.get("password"),
         "l_rememberme": 1
     }).add_header("referer", "https://www.share-online.biz/").send()
Ejemplo n.º 2
0
 def __init__(self):
     if Hoster.plugin_source is not None:
         return
     plugin_base = PluginBase(package='hoster.plugins')
     Hoster.plugin_source = plugin_base.make_plugin_source(
         searchpath=['./hoster'])
     with Hoster.plugin_source:
         for p in Hoster.plugin_source.list_plugins():
             h = Hoster.plugin_source.load_plugin(p)
             if not hasattr(h, p):
                 log.debug("Plugin " + p + " is invalid (No class named " + p + "in module)")
                 continue
             if not Config.get("hoster/" + p + "/active", True):
                 continue
             h = getattr(h, p)
             if not configured(h):
                 log.error("Plugin " + h.__name__ + " is activated but not configured. Deactivating.")
                 continue
             h = h()
             h.plugin_name = p
             if not isinstance(h, BasePlugin):
                 log.error("Plugin " + p + " is invalid (Not extending BasePlugin)")
                 continue
             log.debug("Loaded plugin " + p)
             Hoster.hoster.append(h)
             for n in h.config_values:
                 if not Config.get("hoster/" + p + "/" + n):
                     print "Hoster", p, \
                         "needs a", n + ". You need to add a", n, "for", p, "to config.json " \
                                                                            "to use the plugin."
Ejemplo n.º 3
0
 def login(self):
     r = Request("http://uploaded.net/io/login", method="POST")
     r.add_header("Origin", "http://uploaded.net")
     r.add_header("Referer", "http://uploaded.net/")
     r.add_header("X-Prototype-Version", "1.6.1")
     r.add_header("X-Requested-With", "XMLHttpRequest")
     r.set_payload({
         "id": Config.get("id"),
         "pw": Config.get("password"),
         "_": ""  # whatever
     })
     r = r.send()
     if r.status_code is not 200 or "err" in r.text:
         log.error("ul.to: Login failed.")
         self.deactivate()
         return
     # Try to find out if ddl is activated
     r = Request("http://uploaded.net/me").send()
     try:
         html = PyQuery(r.text)
         if len(html("#ddl")) > 0:
             if html("#ddl").attr("checked") == "checked":
                 self.ddl = True
     except:
         pass
Ejemplo n.º 4
0
 def login(self):
     r = Request.Request("http://premium.to/login.php", method="POST")
     r.add_header('Content-Type', 'application/json')
     r.add_header('Origin', 'http://premium.to')
     r.add_header('Referer', 'http://premium.to')
     r.set_raw_payload(json.dumps({
         "u": Config.get("user"),
         "p": Config.get("password"),
         "r": True
     }))
     response = r.send()
     return response.status_code == 200
Ejemplo n.º 5
0
 def handle(self, link):
     r = Request.Request("http://www.debriditalia.com/api.php", payload={
         'generate': "on",
         'link': link,
         'p': Config.get("password"),
         'u': Config.get("user")}).send()
     if "ERROR:" not in r.text:
         return Request.Request(url=r.text.strip())
     if "account_expired" in r.text:
         log.error("debriditalia.com account expired!")
         self.deactivate()
     raise Errors.PluginError
Ejemplo n.º 6
0
 def account_status(self):
     r = Request("https://api.premiumize.me/pm-api/v1.php", payload={
         "method": "accountstatus",
         "params[login]": Config.get("user-id"),
         "params[pass]": Config.get("PIN")
     }).send().json
     if r["status"] is not 200:
         log.error("premiumize.me: Unable to get account status. Deactivating.")
         self.deactivate()
         return
     if r["result"]["type"] is "free":
         log.error("premiumize.me: Account is free account. Deactivating.")
         self.deactivate()
         return
Ejemplo n.º 7
0
 def __init__(self):
     super(PremiumizeMe, self).__init__()
     self.account_status()
     # Now this is a decent API!
     r = Request("https://api.premiumize.me/pm-api/v1.php", payload={
         "method": "hosterlist",
         "params[login]": Config.get("user-id"),
         "params[pass]": Config.get("PIN")
     }).send().json
     if r["status"] is not 200:
         log.error("premiumize.me: Receiving hoster list failed: " + r["statusmessage"])
         self.deactivate()
         return
     PremiumizeMe.hostname = r["result"]["tldlist"]
Ejemplo n.º 8
0
 def handle(self, link):
     r = Request("https://api.premiumize.me/pm-api/v1.php", payload={
         "method": "directdownloadlink",
         "params[login]": Config.get("user-id"),
         "params[pass]": Config.get("PIN"),
         "params[link]": link
     }).send().json
     if r["status"] is 200:
         return Request(r["result"]["location"])
     if r["status"] is 400 or r["status"] is 404:
         raise Errors.InvalidLinkError
     if r["status"] in [401, 402, 403]:
         log.error("premiumize.me: " + r["statusmessage"] + " deactivating.")
         self.deactivate()
         return
     raise Errors.PluginError
Ejemplo n.º 9
0
 def handle_link(link):
     okay = [h for h in Hoster.hoster if
             h.match(link) and configured(h) and Config.get("hoster/" + h.plugin_name + "/active", False)]
     if len(okay) < 1:
         print "Can't handle link", link, "because no hoster wants to do it"
         return None
     priorized = []
     for hoster in okay:
         priorized.append(((hoster.priority * hoster.get_downloaded_bytes()) + (10 * hoster.get_badness()), hoster))
     priorized = sorted(priorized, key=lambda x: x[0])
     # Try all plugins until there is no plugin left
     i = 0
     download = None
     wasted = {}
     while i < len(priorized):
         start = time.time()
         try:
             download = priorized[i][1].handle(link)
             break
         except PluginError:
             wasted[priorized[i][1]] = (time.time() - start)
             i += 1
     if download is None:
         print priorized[0][1].plugin_name, "wasn't able to process", link
         raise PluginError
     for k, v in wasted.iteritems():
         k.add_badness(v)
     return priorized[0][1], download
Ejemplo n.º 10
0
def test_path():
    json = '{"test": {"path": true}}'
    with open(Config.CONFIG_PATH, "w") as f:
        f.write(json)
    Config.config_changed = -1
    Config.config = None
    assert Config.get("test/path") is True
Ejemplo n.º 11
0
def get_default_headers():
    return {"User-Agent":
            Config.get("http/user-agent",
                       "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) "
                       "Chrome/41.0.2228.0 Safari/537.36"),
            "Accept-Language": "en-US",
            "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
            }
Ejemplo n.º 12
0
def configured(hoster):
    if not type(hoster) is type:
        hoster = hoster.__class__
    need = hoster.config_values
    for n in need:
        if not Config.get("hoster/" + hoster.__name__ + "/" + n):
            return False
    return True
Ejemplo n.º 13
0
    def login(self):
        pw = Config.get("password")
        salt = pw[::-1]
        # seems like they take security serious
        hash = PBKDF2(pw, salt, 10**3).hexread(16)

        r = Request("https://www.oboom.com/1/login", payload={
            'auth': Config.get("email"),
            'pass': hash
        })
        r.add_header("origin", "https://www.oboom.com")
        r.add_header("referer", "https://www.oboom.com/")
        r.add_header("x-requested-with", "XMLHttpRequest")
        r = r.send()
        if r.status_code is not 200:
            log.error("oboom.com Login failed: " + r.text)
            self.deactivate()
            return
        self.cookie = r.json[1]["session"]
Ejemplo n.º 14
0
def test_unset():
    assert Config.get("q/q") is None
Ejemplo n.º 15
0
def test_none():
    with pytest.raises(TypeError):
        Config.get(None)
Ejemplo n.º 16
0
 def match(self, link):
     if not Config.get("app/debug", False):
         return False
     if link.startswith("http://get.testfile/"):
         return True
Ejemplo n.º 17
0
def test_set():
    Config.set("q/w/e", True)
    assert Config.get("q/w/e") is True
Ejemplo n.º 18
0
parser.add_argument("--show-traffic", nargs='?', help="Prints the traffic statistics and exits.", choices=["user", "hoster", "all"])
args = parser.parse_args()
if args.show_traffic:
    choice = [args.show_traffic]
    if choice == ["all"]:
        choice = ["user", "hoster"]
    traffic_data = Shove('file://traffic_log/')
    for name in choice:
        Stats.make_stats(traffic_data, name)
    exit()

try:
    if os.geteuid() == 0:
        # Oh no, someone started OCHproxy as root!
        # But maybe we can drop the priviliges after getting the port.
        if Config.get("app/user", None) is None or Config.get("app/group", None) is None:
            # There can't be a good reason to do this, can it?
            print "Hey, you shouldn't run this as root!"
            print "If you want to use a priviliged port (80 is a good choice), you can set a group and user in"
            print "config.json for OCHproxy to use after binding the port."
            print "You need to wait at least 5 seconds if you insist on this reckless behaviour."
            for _i in xrange(1, 5):
                print ".",
                time.sleep(1)
except AttributeError:
    pass  # This is Windows.

log.info("Starting OCHproxy...")

socket.setdefaulttimeout(30)
Server()