def sendShoutbox(msg: str, apitoken: str) -> str: response = rawPostSSL("/shouts/new/", f"text={msg}", apitoken, "x-www-form-urlencoded", "") if '"success":"1"'.encode() in response: return "success" else: return "failed"
def enviar_mensaje_shout(): try: msg = input("\n\t[+] Escribe el mensaje que quieras enviar >>") response = rawPostSSL("/shouts/new/", f"text={msg}", API, "x-www-form-urlencoded", "") print(Fore.GREEN + "[+] Mensaje enviado" + Fore.RESET) except Exception as e: print(Fore.RED + "Error: %s" % (e) + Fore.RESET)
def getShoutboxLatest(apitoken: str) -> dict: response = rawPostSSL(f"/shouts/get/initial/html/1", "", apitoken, "", "}").decode() if '"success":"0"' in response: return "failed" response = response[response.find('{"success":"1"'):] jsondata = json.loads(response) return jsondata
def startConversation(msg: str, recipient: str, apitoken: str) -> str: response = rawPostSSL("/conversations/new/", f"recipients%5B%5D={recipient}&message={msg}", apitoken, "x-www-form-urlencoded", "") if "No valid recipients selected".encode() in response: return "invalid_recipient" elif '{"id":'.encode() in response: return "success" else: return "failed"
def inicia_conversacion(destinatario): try: msg = input("\n\t[+] Escribe el mensaje que quieras enviar >>") response = rawPostSSL( "/conversations/new/", f"recipients%5B%5D={destinatario}&message={msg}", API, "x-www-form-urlencoded", "") print(Fore.GREEN + "[+] Mensaje enviado" + Fore.RESET) except Exception as e: print(Fore.RED + "Error: %s" % (e) + Fore.RESET)
def conversacion_iniciada(): try: response = rawPostSSL("/conversations/list/", "", API, "", '"}]').decode() response = response[response.find('[{"id":'):] jsondata = json.loads(response) for i in jsondata: print(Fore.YELLOW + "\n\t\t%s: %s -> %s" % (i['id'], i['usernames'], i['lastmessage']) + Fore.RESET) conversationid = int(input("\n\t[+]Ingresa el 'ID' del usuario>> ")) msg = input("\n\t[+] Escribe el mensaje que quieras enviar >>") response = rawPostSSL(f"/conversations/send/{conversationid}/", f"id={conversationid}&message={msg}", API, "x-www-form-urlencoded", "") print(Fore.GREEN + "[+] Mensaje enviado" + Fore.RESET) except Exception as e: print(Fore.RED + "Error: %s" % (e) + Fore.RESET)
def todas_conversaciones(): try: response = rawPostSSL("/conversations/list/", "", API, "", '"}]').decode() response = response[response.find('[{"id":'):] jsondata = json.loads(response) for i in jsondata: print(Fore.YELLOW + "\n\t\t%s: %s -> %s" % (i['id'], i['usernames'], i['lastmessage']) + Fore.RESET) except Exception as e: print(Fore.RED + "Error: %s" % (e) + Fore.RESET)
def extendMachine(machineid: int, apitoken: str) -> str: response = rawPostSSL(f"/vm/vip/extend/{machineid}", "", apitoken, "", "") if "Machine not assigned to this lab.".encode() in response: return "machine_not_active" elif "Machine extended by 24 hours.".encode() in response: return "success" elif "Incorrect lab type.".encode() in response: return "no_vip" else: return "failed"
def stopMachine(machineid: int, apitoken: str) -> str: response = rawPostSSL(f"/vm/vip/remove/{machineid}", "", apitoken, "", "") if "Machine scheduled for termination.".encode() in response: return "success" elif "This machine is not active.".encode() in response: return "machine_not_active" elif "Incorrect lab type.".encode() in response: return "no_vip" else: return "failed"
def assignMachine(machineid: int, apitoken: str) -> str: response = rawPostSSL(f"/vm/vip/assign/{machineid}", "", apitoken, "", "") if "Machine deployed to lab.".encode() in response: return "success" elif "You already have an active machine.".encode() in response: return "already_have_machine" elif "Incorrect lab type.".encode() in response: return "no_vip" else: return "failed"
def ownChallenge(challengeid: int, apitoken: str, flag: str, difficulty: int) -> str: response = rawPostSSL("/challenges/own/", f'challenge_id={challengeid}&flag={flag}&difficulty={difficulty * 10}', apitoken, "x-www-form-urlencoded", "") if '"success":"1"'.encode() in response: return "success" elif "Incorrect flag".encode() in response: return "flag_invalid" else: return "failed" # def getAllChallenges(apitoken): # cant seem to find challenge listing... web scraping?
def ownRoot(machineid: int, apitoken: str, flag: str, difficulty: int) -> str: response = rawPostSSL( f"/machines/own/root/{machineid}", f'{{"flag":"{flag}","difficulty":{difficulty * 10}}}', apitoken, "json", "") if '"success":"1"'.encode() in response: return "success" elif "Incorrect hash".encode() in response: return "flag_invalid" else: return "failed"
def sendConversationMessage(msg: str, conversationid: int, apitoken: str) -> str: response = rawPostSSL(f"/conversations/send/{conversationid}/", f"id={conversationid}&message={msg}", apitoken, "x-www-form-urlencoded", "") # if you type an invalid id you for some reason get the skid message... if "You must have Script Kiddie rank or higher to send messages".encode( ) in response: return "no_skid_or_invalid_id" # could be a non-success, but we cant confirm so here we go... elif "HTTP/1.1 200".encode() in response: return "success" else: return "failed"
def comprobar_flag(flag): try: #MODIFICAR #MODIFICAR #MODIFICAR response = rawPostSSL( "/challenges/own/", f'challenge_id={challengeid}&flag={flag}&difficulty={difficulty * 10}', API, "x-www-form-urlencoded", "") if '"success":"1"'.encode() in response: return "success" elif "Incorrect flag".encode() in response: return "flag_invalid" else: return "failed" except Exception as e: print(Fore.RED + "Error: %s" % (e) + Fore.RESET)
def mostrar_ultimo_mensaje(): try: response = rawPostSSL(f"/shouts/get/initial/html/1", "", API, "", "}").decode() if '"success":"0"' in response: return "failed" response = response[response.find('{"success":"1"'):] bs = BeautifulSoup(response, "lxml") ref = bs.find_all('a') span = bs.find_all('span') for r in ref: print(r.contents[0]) for i in span: print(i.contents[0]) except Exception as e: print(Fore.RED + "Error: %s" % (e) + Fore.RESET)
def getConversation(conversationid: int, apitoken: str) -> list: response = rawPostSSL(f"/conversations/load/{conversationid}", "", apitoken, "", "}]\r\n").decode() response = response[response.find('[{"id":'):] jsondata = json.loads(response) return jsondata
def getConversations(apitoken: str) -> list: response = rawPostSSL("/conversations/list/", "", apitoken, "", '"}]').decode() response = response[response.find('[{"id":'):] jsondata = json.loads(response) return jsondata
def resetMachine(machineid: int, apitoken: str) -> str: response = rawPostSSL(f"/vm/reset/{machineid}", "", apitoken, "", "") if "requested a reset on".encode() in response: return "success" else: return "failed"