Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Snusbase API not working #166

Open
gmignotte opened this issue Aug 16, 2023 · 1 comment
Open

Snusbase API not working #166

gmignotte opened this issue Aug 16, 2023 · 1 comment

Comments

@gmignotte
Copy link

Hi,

  • h8mail version:2.5.6
  • Python version:3.11.4
  • Operating System:Kali Linux 2023

I've been trying h8mail and i've noticed that Snusbase API not working.

I've try :

h8mail -t compromise.email@gmail.com -k "snusbase_url=https://api-experimental.snusbase.com/data/search" "snusbase_token=xxxxxxxxxxxxxxxxxxxxxxxx" --debug

The response :

[@] DEBUG: Received the following---------------------

[@] https://api-experimental.snusbase.com/data/search

[@] DEBUG: RESPONSE HEADER---------------------
Date: Wed, 16 Aug 2023 14:42:47 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 161
Connection: keep-alive
vary: Origin
access-control-allow-origin: *
x-response-time: 1.435750961303711
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=xxxxxxxxxxxxxxxxxxxxxxxx"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 7f7a72293a49fa44-AMS
alt-svc: h3=":443"; ma=86400

[@] DEBUG: RESPONSE BODY---------------------
b'{"statusCode":415,"code":"FST_ERR_CTP_INVALID_MEDIA_TYPE","error":"Unsupported Media Type","message":"Unsupported Media Type: application/x-www-form-urlencoded"}'
[!] [snusbase]> Unsupported Media Type
[!] Snusbase error with compromise-email@gmail.com

If I try directly with :
curl --request POST --url https://api-experimental.snusbase.com/data/search --header "Auth: xxxxxxxxxxxxxxxxxxxxxxxxxxxx" --header "Content-Type: application/json" --data '{"terms":["compromise-email@gmail.com"], "types":["email"], "wildcard": false}'
It works.

@alegra8611
Copy link

alegra8611 commented Feb 4, 2024

The URL in the run.py is out of date, furthermore, the request method in the classes.py is also misconfigured (mainly in the update headers line). I am currently playing around with the code to see if I can get it to work. Further infor on the api documentation can be found here: https://docs.snusbase.com/#42-python.

EDIT: Never got it working, instead I created my own Python script that may be integratable with h8mail's codebase?

#!/usr/bin/python3

import argparse
import os
import json
import datetime
import requests
import fade
from colorama import Fore, Style
from urllib.request import Request, urlopen

user = os.getlogin() 

def clear_screen():
    os.system('cls' if os.name == 'nt' else 'clear')
    
def create_directory(category):
    directory = f"/home/{user}/snus-email-tool/{category}"
    if not os.path.exists(directory):
        os.makedirs(directory)
    return directory

def save_error_log(error):
    now = datetime.datetime.now()
    timestamp = now.strftime("%Y-%m-%d_%H-%M-%S")
    log_directory = create_directory("logs")
    log_file = os.path.join(log_directory, f"error_{timestamp}.log")
    with open(log_file, "w") as file:
        file.write(str(error))

snusbase_auth = 'sbuncd7b2bfcflweh3dkbeqsuzlzqk'
snusbase_api = 'https://api-experimental.snusbase.com/'

def api_email():
    clear_screen()
    text_default_fade = fade.greenblue(text_default)
    print(text_default_fade)
    
    def send_request(url, body=None):

        headers = {
            'Auth': snusbase_auth,
            'Content-Type': 'application/json',
        }
        method = 'POST' if body else 'GET'
        data = json.dumps(body) if body else None
        response = requests.request(method, snusbase_api + url, headers=headers, data=data)
        return response.json()

    if __name__ == "__main__":
         parser = argparse.ArgumentParser()
         parser.add_argument('-F', '--filename', type=str)
         args = parser.parse_args()
         filename = args.filename

         
         f = open(filename, 'r')
         for line in f:
                result = line.split()
                search_response = send_request('data/search', {
                    'terms': result,
                    'types': ["email"],
                    'wildcard': False,
                })
                
                formatted_response = json.dumps(search_response, indent=2)
                print(formatted_response)

                output_directory = create_directory("output")
                output_file = os.path.join(output_directory, f"{result}.json")
                user_path = os.path.join(f"{output_file}")
                Results_default = f"Results have been saved to: {user_path}"
                Results_default_fade = fade.purpleblue(Results_default)
                print("\n") 
                print (Results_default_fade)
                with open(output_file, "w") as outfile:
                    outfile.write(formatted_response)

text_default ='''
              DMMMMMMD                 
           MMMMMMMMMMMMMMMM             
         MMMMMMMMMMMMMMMMMMMM           
        MMMMMMMMMMMMMMMMMMMMMM.         
      MMMMMMMMMMMMMMMMMMMMMMMMMM        
     MMMMMMMMMMMMMMMMMMMMMMMMMMMM       
    .MMMMMMMMMMMMMMMMMMMMMMMMMMMM       
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM      
    MMMMMMMMMMMMMMMMMMMMMMMMMMMMMM      
    MM+  MMMMMMMMMMMMMMMMMMMM$  MM      
    +M.    ZMMMMMMMMMMMMMMO     M       
     MM       MMMMMMMMMM       MM       
     MMD         MMMM.        .MM       
      MMMMMM    MMM=MMI   DMMMMM        
       MMMMMMMMMMM  +MMMMMMMMMMM        
      MMMMMMMMMMM 8M MMMMMMMMMMMD       
      MMMMM   MMM.MM MMMM    MMM        
       MMM7   MMMMMMMMMMM    M8         
              MM MM M MMM               
              MM MM,M MM                
              MM.MM=M MM                
              MM~MM+M MM                
              8M~MM+M MM                
              ,M~MMIM MM                
               M:MMZM MM                
               M.MMIM MM 

Authors: Alegra
'''

api_email()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants