Last active
November 17, 2021 01:21
-
-
Save userlandkernel/a5567137446f51767f8bde158470f064 to your computer and use it in GitHub Desktop.
[WIP] Mijn bonusbox, altijd alles in de bonus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
""" | |
Project AlbertPWN | |
(c) 2021, Sem Voigtlander (@userlandkernel) | |
""" | |
import sys | |
import os | |
import struct | |
import time | |
import requests | |
import json | |
from bs4 import BeautifulSoup | |
import http.client | |
import requests | |
HEADERS = { | |
'User-Agent': 'android/6.29.3 Model/phone Android/7.0-API24', | |
'Host': 'ms.ah.nl', | |
} | |
class AppieMobileAPI: | |
@staticmethod | |
def get_anonymous_access_token(): | |
response = requests.post( | |
'https://ms.ah.nl/create-anonymous-member-token', | |
headers=HEADERS, | |
params={"client": "appie-anonymous"} | |
) | |
if not response.ok: | |
response.raise_for_status() | |
return response.json() | |
def __init__(self): | |
self._access_token = self.get_anonymous_access_token() | |
def search_products(self, query=None, page=0, size=750, sort='RELEVANCE'): | |
response = requests.get( | |
'https://ms.ah.nl/mobile-services/product/search/v2?sortOn=RELEVANCE', | |
params={"sortOn": sort, "page": page, "size": size, "query": query}, | |
headers={**HEADERS, "Authorization": "Bearer {}".format(self._access_token.get('access_token'))} | |
) | |
if not response.ok: | |
response.raise_for_status() | |
return response.json() | |
def search_all_products(self, **kwargs): | |
""" | |
Iterate all the products available, filtering by query or other filters. Will return generator. | |
:param kwargs: See params of 'search_products' method, note that size should not be altered to optimize/limit pages | |
:return: generator yielding products | |
""" | |
response = self.search_products(page=0, **kwargs) | |
yield from response['products'] | |
for page in range(1, response['page']['totalPages']): | |
response = self.search_products(page=page, **kwargs) | |
yield from response['products'] | |
def get_product_by_barcode(self, barcode): | |
response = requests.get( | |
'https://ms.ah.nl/mobile-services/product/search/v1/gtin/{}'.format(barcode), | |
headers={**HEADERS, "Authorization": "Bearer {}".format(self._access_token.get('access_token'))} | |
) | |
if not response.ok: | |
response.raise_for_status() | |
return response.json() | |
def get_product_details(self, product): | |
""" | |
Get advanced details of a product | |
:param product: Product ID (also called webshopId) or original object containing webshopId | |
:return: dict containing product information | |
""" | |
product_id = product if not isinstance(product, dict) else product['webshopId'] | |
response = requests.get( | |
'https://ms.ah.nl/mobile-services/product/detail/v3/fir/{}'.format(product_id), | |
headers={**HEADERS, "Authorization": "Bearer {}".format(self._access_token.get('access_token'))} | |
) | |
if not response.ok: | |
response.raise_for_status() | |
return response.json() | |
def get_categories(self): | |
response = requests.get( | |
'https://ms.ah.nl/mobile-services/v1/product-shelves/categories', | |
headers={**HEADERS, "Authorization": "Bearer {}".format(self._access_token.get('access_token'))} | |
) | |
if not response.ok: | |
response.raise_for_status() | |
return response.json() | |
def get_sub_categories(self, category): | |
category_id = category if not isinstance(category, dict) else category['id'] | |
response = requests.get( | |
'https://ms.ah.nl/mobile-services/v1/product-shelves/categories/{}/sub-categories'.format(category_id), | |
headers={**HEADERS, "Authorization": "Bearer {}".format(self._access_token.get('access_token'))} | |
) | |
if not response.ok: | |
response.raise_for_status() | |
return response.json() | |
class AppieAccountMaker: | |
def __init__(self): | |
self.emails = [] | |
def GenerateEmails(self): | |
conn = http.client.HTTPSConnection("1secmail.com") | |
conn.request("GET", "https://www.1secmail.com/api/v1/?action=genRandomMailbox&count=10") | |
res = conn.getresponse() | |
self.emails = json.loads(res.read().decode("utf-8")) | |
def CheckEmails(self): | |
inboxes = [] | |
for email in self.emails: | |
inbox = {'email':email, 'messages':[]} | |
conn = http.client.HTTPSConnection("1secmail.com") | |
conn.request("GET", "https://www.1secmail.com/api/v1/?action=getMessages&login={}&domain=1secmail.com".format(email.split('@')[0],email.split('@')[1])) | |
res = conn.getresponse() | |
inbox['messages'] = json.loads(res.read().decode("utf-8")) | |
inboxes.append(inbox) | |
return inboxes | |
def CheckEmail(self, email=None): | |
if email != None: | |
inbox = [] | |
conn = http.client.HTTPSConnection("1secmail.com") | |
conn.request("GET", "https://www.1secmail.com/api/v1/?action=getMessages&login={}&domain={}".format(email.split('@')[0],email.split('@')[1])) | |
res = conn.getresponse() | |
return json.loads(res.read().decode("utf-8")) | |
return None | |
def CreateAccount(self): | |
pass | |
def VerifyAccount(self): | |
pass | |
if __name__ == "__main__": | |
ah = AppieAccountMaker() | |
ah.GenerateEmails() | |
print(ah.CheckEmail(email='h5dlxznr@oosln.com')) | |
print(AppieMobileAPI().get_product_by_barcode(barcode='8718907153980')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment