D
D
Danya Secret2020-06-28 19:29:48
Python
Danya Secret, 2020-06-28 19:29:48

How to register an instagram user?

There is the following code:

import requests
import hmac
import hashlib
import random
import string
import json
import argparse


def randomString(size):
    chars = string.ascii_lowercase + string.digits
    return ''.join(random.choice(chars) for _ in range(size))


def HMAC(text):
    key = '3f0a7d75e094c7385e3dbaa026877f2e067cbd1a4dbcf3867748f6b26f257117'
    hashs = hmac.new(key, text, hashlib.sha256)
    return hashs.hexdigest()


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('name', help='Full Name')
    parser.add_argument('username', help='Username')
    parser.add_argument('email', help='Email')
    parser.add_argument('password', help='Password')
    args = parser.parse_args()

    getHeaders = {
        'User-Agent':'Instagram 7.1.1 Android (21/5.0.2; 480dpi; 1080x1776; LGE/Google; Nexus 5; hammerhead; hammerhead; en_US)',
        'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
        'Accept-Encoding':'gzip, deflate, sdch',
        'Accept-Language':'en-US,en;q=0.8',
        'upgrade-insecure-requests':'1'
    }

    s = requests.Session()
    s.get('https://instagram.com',headers=getHeaders)
    guid = randomString(8) + '-' + randomString(4) + "-" + randomString(4) + '-' + randomString(4) + '-' +randomString(12)
    information = { 
        'username':args.username,
        'first_name':args.name,
        'password':args.password,
        'email':args.email,
        'guid':guid
    }
    js = json.dumps(information)
    payload = {
        'signed_body': HMAC(js) + '.' + js,
        'ig_sig_key_version':'4'
    }
    postHeaders = {'Host':'i.instagram.com',
                  'User-Agent':'Instagram 7.1.1 Android (21/5.0.2; 480dpi; 1080x1776; LGE/Google; Nexus 5; hammerhead; hammerhead; en_US)',
                  'Accept-Language':'en-US',
                  'Accept-Encoding':'gzip',
                  'Cookie2':'$Version=1',
                  'X-IG-Connection-Type':'WIFI',
                  'X-IG-Capabilities':'BQ=='
                  }
    x = s.post('https://i.instagram.com/api/v1/accounts/create/', headers=postHeaders, data=payload)
    result = json.loads(x.content)
    if result['status'] != 'fail':
        if result['account_created'] == True:
            print('Account has been created successfully')
        else:
            print('Error:')
            for i in result['errors']:
                print(str(result['errors'][i][0]))
    else:
        if result['spam'] == True:
            print('Instagram blocks your IP due to spamming behaviour.')


if __name__ == '__main__':
    main()

The part with the HMAC() function does not work. I can not understand. Purpose: to register a user through a script (in my example, the data is set in the console itself). If there are any solutions, please share a link to the source. Thanks in advance

Also possible solution in any browser language(php, js)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2020-06-28
@dimonchik2013

key should be changed to current

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question