Auth process
This commit is contained in:
21
main.py
21
main.py
@@ -1,11 +1,15 @@
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from xmlrpc.server import SimpleXMLRPCServer
|
from xmlrpc.server import SimpleXMLRPCServer
|
||||||
|
from xmlrpc.client import ServerProxy
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import requests.graphql
|
import requests.graphql
|
||||||
from pygost import gost34112012256
|
from pygost import gost34112012256
|
||||||
|
|
||||||
|
|
||||||
|
PASSWORD = 'gost_2012$a742ec53198ec2a5027086fba8814a89982a57112d1a72d02260161108f39b50'
|
||||||
|
|
||||||
|
|
||||||
# Expose a function
|
# Expose a function
|
||||||
def list_contents(dir_name):
|
def list_contents(dir_name):
|
||||||
logging.debug('list_contents(%s)', dir_name)
|
logging.debug('list_contents(%s)', dir_name)
|
||||||
@@ -18,11 +22,9 @@ def aud_add(message):
|
|||||||
|
|
||||||
|
|
||||||
def auth_response(challenge, server_id, is_server):
|
def auth_response(challenge, server_id, is_server):
|
||||||
logging.debug(challenge)
|
# logging.debug(f'Challenge: {challenge}, Server: {server_id}, IsServer: {is_server}')
|
||||||
logging.debug(server_id)
|
msg = '%s%s%s' % (challenge, server_id, PASSWORD)
|
||||||
logging.debug(is_server)
|
response = gost34112012256.new(msg.encode('utf-8')[::-1]).digest()[::-1].hex()
|
||||||
msg = '%s%s%s' % (challenge, server_id, '12345678')
|
|
||||||
response = gost34112012256.new(msg.encode('utf-8')).digest().hex()
|
|
||||||
return {'error': False, 'response': response}
|
return {'error': False, 'response': response}
|
||||||
|
|
||||||
|
|
||||||
@@ -31,15 +33,22 @@ def auth_challenge():
|
|||||||
return uuid4().hex
|
return uuid4().hex
|
||||||
|
|
||||||
|
|
||||||
|
def accept(params, files, url):
|
||||||
|
print(params, files, url)
|
||||||
|
print('Accept')
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
print('Use Control-C to exit')
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
server = SimpleXMLRPCServer(('0.0.0.0', 9000), logRequests=True)
|
server = SimpleXMLRPCServer(('0.0.0.0', 9000), logRequests=True)
|
||||||
server.register_function(list_contents)
|
server.register_function(list_contents)
|
||||||
server.register_function(aud_add)
|
server.register_function(aud_add)
|
||||||
server.register_function(auth_response)
|
server.register_function(auth_response)
|
||||||
server.register_function(auth_challenge)
|
server.register_function(auth_challenge)
|
||||||
|
server.register_function(accept)
|
||||||
try:
|
try:
|
||||||
print('Use Control-C to exit')
|
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print('Exiting')
|
print('Exiting')
|
||||||
|
|||||||
Reference in New Issue
Block a user