0

I have this code I built to solve a problem but I would like to use it in the future. To make the usage simpler I want to be able to pass the arguments via command line like:

python3 code.py -h http://188.161.173.208:31955/ -w /home/list.txt

import random
import hashlib
import requests
import json


def request(hash):
       url = 'http://188.161.173.208:31955/'
       payload = {
              "Host": "188.161.173.208:31955",
              "Connection": "close",
              "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5",
              "Accept": "*/*",
              "Accept-Encoding": "gzip,deflate,sdch",
              "Accept-Language": "fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4",
              "Cookie": hash       }

       # Adding empty header as parameters are being sent in payload
       headers = {}
       r = requests.post(url, data=json.dumps(payload), headers=headers)
       print(r.content)

# Python program to read 
# file word by word
   
# opening the text file
with open('/home/filipe/lists/Usernames/top-usernames-shortlist.txt','r') as file:
   
    # reading each line    
    for line in file:
   
        # reading each word        
        for word in line.split():
   
            # displaying the words           
            #print("1n",word) 
            result = hashlib.md5(word.encode())
            #print(result.hexdigest(), "\n")
            request(result.hexdigest())


I searched a lot but I couldn't find any resource that explained that in a way I can understand.

jonrsharpe
  • 107,083
  • 22
  • 201
  • 376

0 Answers0